const ju = [
  { 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 }
], or = {
  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"
  }
};
ju.reduce(
  (i, { color: e, primary: t, secondary: n }) => ({
    ...i,
    [e]: {
      primary: or[e][t],
      secondary: or[e][n]
    }
  }),
  {}
);
class Ao extends Error {
  constructor(e) {
    super(e), this.name = "ShareError";
  }
}
async function Pu(i, e) {
  var l;
  if (window.__gradio_space__ == null)
    throw new Ao("Must be on Spaces to share.");
  let t, n, o;
  {
    const u = await fetch(i);
    t = await u.blob(), n = u.headers.get("content-type") || "", o = u.headers.get("content-disposition") || "";
  }
  const r = new File([t], o, { type: n }), s = await fetch("https://huggingface.co/uploads", {
    method: "POST",
    body: r,
    headers: {
      "Content-Type": r.type,
      "X-Requested-With": "XMLHttpRequest"
    }
  });
  if (!s.ok) {
    if ((l = s.headers.get("content-type")) != null && l.includes("application/json")) {
      const u = await s.json();
      throw new Ao(`Upload failed: ${u.error}`);
    }
    throw new Ao("Upload failed.");
  }
  return await s.text();
}
const kn = (i) => {
  const e = Math.floor(i / 3600), t = Math.floor(i % 3600 / 60), n = Math.round(i) % 60, o = `${t < 10 ? "0" : ""}${t}`, r = `${n < 10 ? "0" : ""}${n}`;
  return e > 0 ? `${e}:${o}:${r}` : `${t}:${r}`;
}, {
  SvelteComponent: Tu,
  assign: Nu,
  create_slot: Bu,
  detach: Wu,
  element: Iu,
  get_all_dirty_from_scope: Uu,
  get_slot_changes: Fu,
  get_spread_update: Vu,
  init: Hu,
  insert: Zu,
  safe_not_equal: Gu,
  set_dynamic_element_data: sr,
  set_style: Ze,
  toggle_class: gt,
  transition_in: aa,
  transition_out: ua,
  update_slot_base: Ju
} = window.__gradio__svelte__internal;
function Ku(i) {
  let e, t, n;
  const o = (
    /*#slots*/
    i[18].default
  ), r = Bu(
    o,
    i,
    /*$$scope*/
    i[17],
    null
  );
  let s = [
    { "data-testid": (
      /*test_id*/
      i[7]
    ) },
    { id: (
      /*elem_id*/
      i[2]
    ) },
    {
      class: t = "block " + /*elem_classes*/
      i[3].join(" ") + " svelte-nl1om8"
    }
  ], a = {};
  for (let l = 0; l < s.length; l += 1)
    a = Nu(a, s[l]);
  return {
    c() {
      e = Iu(
        /*tag*/
        i[14]
      ), r && r.c(), sr(
        /*tag*/
        i[14]
      )(e, a), gt(
        e,
        "hidden",
        /*visible*/
        i[10] === !1
      ), gt(
        e,
        "padded",
        /*padding*/
        i[6]
      ), gt(
        e,
        "border_focus",
        /*border_mode*/
        i[5] === "focus"
      ), gt(
        e,
        "border_contrast",
        /*border_mode*/
        i[5] === "contrast"
      ), gt(e, "hide-container", !/*explicit_call*/
      i[8] && !/*container*/
      i[9]), Ze(
        e,
        "height",
        /*get_dimension*/
        i[15](
          /*height*/
          i[0]
        )
      ), Ze(e, "width", typeof /*width*/
      i[1] == "number" ? `calc(min(${/*width*/
      i[1]}px, 100%))` : (
        /*get_dimension*/
        i[15](
          /*width*/
          i[1]
        )
      )), Ze(
        e,
        "border-style",
        /*variant*/
        i[4]
      ), Ze(
        e,
        "overflow",
        /*allow_overflow*/
        i[11] ? "visible" : "hidden"
      ), Ze(
        e,
        "flex-grow",
        /*scale*/
        i[12]
      ), Ze(e, "min-width", `calc(min(${/*min_width*/
      i[13]}px, 100%))`), Ze(e, "border-width", "var(--block-border-width)");
    },
    m(l, u) {
      Zu(l, e, u), r && r.m(e, null), n = !0;
    },
    p(l, u) {
      r && r.p && (!n || u & /*$$scope*/
      131072) && Ju(
        r,
        o,
        l,
        /*$$scope*/
        l[17],
        n ? Fu(
          o,
          /*$$scope*/
          l[17],
          u,
          null
        ) : Uu(
          /*$$scope*/
          l[17]
        ),
        null
      ), sr(
        /*tag*/
        l[14]
      )(e, a = Vu(s, [
        (!n || u & /*test_id*/
        128) && { "data-testid": (
          /*test_id*/
          l[7]
        ) },
        (!n || u & /*elem_id*/
        4) && { id: (
          /*elem_id*/
          l[2]
        ) },
        (!n || u & /*elem_classes*/
        8 && t !== (t = "block " + /*elem_classes*/
        l[3].join(" ") + " svelte-nl1om8")) && { class: t }
      ])), gt(
        e,
        "hidden",
        /*visible*/
        l[10] === !1
      ), gt(
        e,
        "padded",
        /*padding*/
        l[6]
      ), gt(
        e,
        "border_focus",
        /*border_mode*/
        l[5] === "focus"
      ), gt(
        e,
        "border_contrast",
        /*border_mode*/
        l[5] === "contrast"
      ), gt(e, "hide-container", !/*explicit_call*/
      l[8] && !/*container*/
      l[9]), u & /*height*/
      1 && Ze(
        e,
        "height",
        /*get_dimension*/
        l[15](
          /*height*/
          l[0]
        )
      ), u & /*width*/
      2 && Ze(e, "width", typeof /*width*/
      l[1] == "number" ? `calc(min(${/*width*/
      l[1]}px, 100%))` : (
        /*get_dimension*/
        l[15](
          /*width*/
          l[1]
        )
      )), u & /*variant*/
      16 && Ze(
        e,
        "border-style",
        /*variant*/
        l[4]
      ), u & /*allow_overflow*/
      2048 && Ze(
        e,
        "overflow",
        /*allow_overflow*/
        l[11] ? "visible" : "hidden"
      ), u & /*scale*/
      4096 && Ze(
        e,
        "flex-grow",
        /*scale*/
        l[12]
      ), u & /*min_width*/
      8192 && Ze(e, "min-width", `calc(min(${/*min_width*/
      l[13]}px, 100%))`);
    },
    i(l) {
      n || (aa(r, l), n = !0);
    },
    o(l) {
      ua(r, l), n = !1;
    },
    d(l) {
      l && Wu(e), r && r.d(l);
    }
  };
}
function Xu(i) {
  let e, t = (
    /*tag*/
    i[14] && Ku(i)
  );
  return {
    c() {
      t && t.c();
    },
    m(n, o) {
      t && t.m(n, o), e = !0;
    },
    p(n, [o]) {
      /*tag*/
      n[14] && t.p(n, o);
    },
    i(n) {
      e || (aa(t, n), e = !0);
    },
    o(n) {
      ua(t, n), e = !1;
    },
    d(n) {
      t && t.d(n);
    }
  };
}
function Yu(i, e, t) {
  let { $$slots: n = {}, $$scope: o } = e, { height: r = void 0 } = e, { width: s = void 0 } = e, { elem_id: a = "" } = e, { elem_classes: l = [] } = e, { variant: u = "solid" } = e, { border_mode: c = "base" } = e, { padding: d = !0 } = e, { type: _ = "normal" } = e, { test_id: f = void 0 } = e, { explicit_call: h = !1 } = e, { container: p = !0 } = e, { visible: g = !0 } = e, { allow_overflow: m = !0 } = e, { scale: k = null } = e, { min_width: w = 0 } = e, S = _ === "fieldset" ? "fieldset" : "div";
  const v = (b) => {
    if (b !== void 0) {
      if (typeof b == "number")
        return b + "px";
      if (typeof b == "string")
        return b;
    }
  };
  return i.$$set = (b) => {
    "height" in b && t(0, r = b.height), "width" in b && t(1, s = b.width), "elem_id" in b && t(2, a = b.elem_id), "elem_classes" in b && t(3, l = b.elem_classes), "variant" in b && t(4, u = b.variant), "border_mode" in b && t(5, c = b.border_mode), "padding" in b && t(6, d = b.padding), "type" in b && t(16, _ = b.type), "test_id" in b && t(7, f = b.test_id), "explicit_call" in b && t(8, h = b.explicit_call), "container" in b && t(9, p = b.container), "visible" in b && t(10, g = b.visible), "allow_overflow" in b && t(11, m = b.allow_overflow), "scale" in b && t(12, k = b.scale), "min_width" in b && t(13, w = b.min_width), "$$scope" in b && t(17, o = b.$$scope);
  }, [
    r,
    s,
    a,
    l,
    u,
    c,
    d,
    f,
    h,
    p,
    g,
    m,
    k,
    w,
    S,
    v,
    _,
    o,
    n
  ];
}
class ca extends Tu {
  constructor(e) {
    super(), Hu(this, e, Yu, Xu, Gu, {
      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: Qu,
  append: zo,
  attr: Wi,
  create_component: $u,
  destroy_component: xu,
  detach: ec,
  element: rr,
  init: tc,
  insert: nc,
  mount_component: ic,
  safe_not_equal: oc,
  set_data: sc,
  space: rc,
  text: lc,
  toggle_class: Bt,
  transition_in: ac,
  transition_out: uc
} = window.__gradio__svelte__internal;
function cc(i) {
  let e, t, n, o, r, s;
  return n = new /*Icon*/
  i[1]({}), {
    c() {
      e = rr("label"), t = rr("span"), $u(n.$$.fragment), o = rc(), r = lc(
        /*label*/
        i[0]
      ), Wi(t, "class", "svelte-9gxdi0"), Wi(e, "for", ""), Wi(e, "data-testid", "block-label"), Wi(e, "class", "svelte-9gxdi0"), Bt(e, "hide", !/*show_label*/
      i[2]), Bt(e, "sr-only", !/*show_label*/
      i[2]), Bt(
        e,
        "float",
        /*float*/
        i[4]
      ), Bt(
        e,
        "hide-label",
        /*disable*/
        i[3]
      );
    },
    m(a, l) {
      nc(a, e, l), zo(e, t), ic(n, t, null), zo(e, o), zo(e, r), s = !0;
    },
    p(a, [l]) {
      (!s || l & /*label*/
      1) && sc(
        r,
        /*label*/
        a[0]
      ), (!s || l & /*show_label*/
      4) && Bt(e, "hide", !/*show_label*/
      a[2]), (!s || l & /*show_label*/
      4) && Bt(e, "sr-only", !/*show_label*/
      a[2]), (!s || l & /*float*/
      16) && Bt(
        e,
        "float",
        /*float*/
        a[4]
      ), (!s || l & /*disable*/
      8) && Bt(
        e,
        "hide-label",
        /*disable*/
        a[3]
      );
    },
    i(a) {
      s || (ac(n.$$.fragment, a), s = !0);
    },
    o(a) {
      uc(n.$$.fragment, a), s = !1;
    },
    d(a) {
      a && ec(e), xu(n);
    }
  };
}
function dc(i, e, t) {
  let { label: n = null } = e, { Icon: o } = e, { show_label: r = !0 } = e, { disable: s = !1 } = e, { float: a = !0 } = e;
  return i.$$set = (l) => {
    "label" in l && t(0, n = l.label), "Icon" in l && t(1, o = l.Icon), "show_label" in l && t(2, r = l.show_label), "disable" in l && t(3, s = l.disable), "float" in l && t(4, a = l.float);
  }, [n, o, r, s, a];
}
class da extends Qu {
  constructor(e) {
    super(), tc(this, e, dc, cc, oc, {
      label: 0,
      Icon: 1,
      show_label: 2,
      disable: 3,
      float: 4
    });
  }
}
const {
  SvelteComponent: fc,
  append: Es,
  attr: Ot,
  bubble: _c,
  create_component: hc,
  destroy_component: mc,
  detach: fa,
  element: Ds,
  init: pc,
  insert: _a,
  listen: gc,
  mount_component: bc,
  safe_not_equal: vc,
  set_data: wc,
  set_style: Ii,
  space: yc,
  text: kc,
  toggle_class: Xe,
  transition_in: Cc,
  transition_out: Sc
} = window.__gradio__svelte__internal;
function lr(i) {
  let e, t;
  return {
    c() {
      e = Ds("span"), t = kc(
        /*label*/
        i[1]
      ), Ot(e, "class", "svelte-lpi64a");
    },
    m(n, o) {
      _a(n, e, o), Es(e, t);
    },
    p(n, o) {
      o & /*label*/
      2 && wc(
        t,
        /*label*/
        n[1]
      );
    },
    d(n) {
      n && fa(e);
    }
  };
}
function Ec(i) {
  let e, t, n, o, r, s, a, l = (
    /*show_label*/
    i[2] && lr(i)
  );
  return o = new /*Icon*/
  i[0]({}), {
    c() {
      e = Ds("button"), l && l.c(), t = yc(), n = Ds("div"), hc(o.$$.fragment), Ot(n, "class", "svelte-lpi64a"), Xe(
        n,
        "small",
        /*size*/
        i[4] === "small"
      ), Xe(
        n,
        "large",
        /*size*/
        i[4] === "large"
      ), e.disabled = /*disabled*/
      i[7], Ot(
        e,
        "aria-label",
        /*label*/
        i[1]
      ), Ot(
        e,
        "aria-haspopup",
        /*hasPopup*/
        i[8]
      ), Ot(
        e,
        "title",
        /*label*/
        i[1]
      ), Ot(e, "class", "svelte-lpi64a"), Xe(
        e,
        "pending",
        /*pending*/
        i[3]
      ), Xe(
        e,
        "padded",
        /*padded*/
        i[5]
      ), Xe(
        e,
        "highlight",
        /*highlight*/
        i[6]
      ), Xe(
        e,
        "transparent",
        /*transparent*/
        i[9]
      ), Ii(e, "color", !/*disabled*/
      i[7] && /*_color*/
      i[11] ? (
        /*_color*/
        i[11]
      ) : "var(--block-label-text-color)"), Ii(e, "--bg-color", /*disabled*/
      i[7] ? "auto" : (
        /*background*/
        i[10]
      ));
    },
    m(u, c) {
      _a(u, e, c), l && l.m(e, null), Es(e, t), Es(e, n), bc(o, n, null), r = !0, s || (a = gc(
        e,
        "click",
        /*click_handler*/
        i[13]
      ), s = !0);
    },
    p(u, [c]) {
      /*show_label*/
      u[2] ? l ? l.p(u, c) : (l = lr(u), l.c(), l.m(e, t)) : l && (l.d(1), l = null), (!r || c & /*size*/
      16) && Xe(
        n,
        "small",
        /*size*/
        u[4] === "small"
      ), (!r || c & /*size*/
      16) && Xe(
        n,
        "large",
        /*size*/
        u[4] === "large"
      ), (!r || c & /*disabled*/
      128) && (e.disabled = /*disabled*/
      u[7]), (!r || c & /*label*/
      2) && Ot(
        e,
        "aria-label",
        /*label*/
        u[1]
      ), (!r || c & /*hasPopup*/
      256) && Ot(
        e,
        "aria-haspopup",
        /*hasPopup*/
        u[8]
      ), (!r || c & /*label*/
      2) && Ot(
        e,
        "title",
        /*label*/
        u[1]
      ), (!r || c & /*pending*/
      8) && Xe(
        e,
        "pending",
        /*pending*/
        u[3]
      ), (!r || c & /*padded*/
      32) && Xe(
        e,
        "padded",
        /*padded*/
        u[5]
      ), (!r || c & /*highlight*/
      64) && Xe(
        e,
        "highlight",
        /*highlight*/
        u[6]
      ), (!r || c & /*transparent*/
      512) && Xe(
        e,
        "transparent",
        /*transparent*/
        u[9]
      ), c & /*disabled, _color*/
      2176 && Ii(e, "color", !/*disabled*/
      u[7] && /*_color*/
      u[11] ? (
        /*_color*/
        u[11]
      ) : "var(--block-label-text-color)"), c & /*disabled, background*/
      1152 && Ii(e, "--bg-color", /*disabled*/
      u[7] ? "auto" : (
        /*background*/
        u[10]
      ));
    },
    i(u) {
      r || (Cc(o.$$.fragment, u), r = !0);
    },
    o(u) {
      Sc(o.$$.fragment, u), r = !1;
    },
    d(u) {
      u && fa(e), l && l.d(), mc(o), s = !1, a();
    }
  };
}
function Dc(i, e, t) {
  let n, { Icon: o } = e, { label: r = "" } = e, { show_label: s = !1 } = e, { pending: a = !1 } = e, { size: l = "small" } = e, { padded: u = !0 } = e, { highlight: c = !1 } = e, { disabled: d = !1 } = e, { hasPopup: _ = !1 } = e, { color: f = "var(--block-label-text-color)" } = e, { transparent: h = !1 } = e, { background: p = "var(--background-fill-primary)" } = e;
  function g(m) {
    _c.call(this, i, m);
  }
  return i.$$set = (m) => {
    "Icon" in m && t(0, o = m.Icon), "label" in m && t(1, r = m.label), "show_label" in m && t(2, s = m.show_label), "pending" in m && t(3, a = m.pending), "size" in m && t(4, l = m.size), "padded" in m && t(5, u = m.padded), "highlight" in m && t(6, c = m.highlight), "disabled" in m && t(7, d = m.disabled), "hasPopup" in m && t(8, _ = m.hasPopup), "color" in m && t(12, f = m.color), "transparent" in m && t(9, h = m.transparent), "background" in m && t(10, p = m.background);
  }, i.$$.update = () => {
    i.$$.dirty & /*highlight, color*/
    4160 && t(11, n = c ? "var(--color-accent)" : f);
  }, [
    o,
    r,
    s,
    a,
    l,
    u,
    c,
    d,
    _,
    h,
    p,
    n,
    f,
    g
  ];
}
class Ri extends fc {
  constructor(e) {
    super(), pc(this, e, Dc, Ec, vc, {
      Icon: 0,
      label: 1,
      show_label: 2,
      pending: 3,
      size: 4,
      padded: 5,
      highlight: 6,
      disabled: 7,
      hasPopup: 8,
      color: 12,
      transparent: 9,
      background: 10
    });
  }
}
const {
  SvelteComponent: Lc,
  append: Rc,
  attr: jo,
  binding_callbacks: Mc,
  create_slot: Oc,
  detach: qc,
  element: ar,
  get_all_dirty_from_scope: Ac,
  get_slot_changes: zc,
  init: jc,
  insert: Pc,
  safe_not_equal: Tc,
  toggle_class: Wt,
  transition_in: Nc,
  transition_out: Bc,
  update_slot_base: Wc
} = window.__gradio__svelte__internal;
function Ic(i) {
  let e, t, n;
  const o = (
    /*#slots*/
    i[5].default
  ), r = Oc(
    o,
    i,
    /*$$scope*/
    i[4],
    null
  );
  return {
    c() {
      e = ar("div"), t = ar("div"), r && r.c(), jo(t, "class", "icon svelte-3w3rth"), jo(e, "class", "empty svelte-3w3rth"), jo(e, "aria-label", "Empty value"), Wt(
        e,
        "small",
        /*size*/
        i[0] === "small"
      ), Wt(
        e,
        "large",
        /*size*/
        i[0] === "large"
      ), Wt(
        e,
        "unpadded_box",
        /*unpadded_box*/
        i[1]
      ), Wt(
        e,
        "small_parent",
        /*parent_height*/
        i[3]
      );
    },
    m(s, a) {
      Pc(s, e, a), Rc(e, t), r && r.m(t, null), i[6](e), n = !0;
    },
    p(s, [a]) {
      r && r.p && (!n || a & /*$$scope*/
      16) && Wc(
        r,
        o,
        s,
        /*$$scope*/
        s[4],
        n ? zc(
          o,
          /*$$scope*/
          s[4],
          a,
          null
        ) : Ac(
          /*$$scope*/
          s[4]
        ),
        null
      ), (!n || a & /*size*/
      1) && Wt(
        e,
        "small",
        /*size*/
        s[0] === "small"
      ), (!n || a & /*size*/
      1) && Wt(
        e,
        "large",
        /*size*/
        s[0] === "large"
      ), (!n || a & /*unpadded_box*/
      2) && Wt(
        e,
        "unpadded_box",
        /*unpadded_box*/
        s[1]
      ), (!n || a & /*parent_height*/
      8) && Wt(
        e,
        "small_parent",
        /*parent_height*/
        s[3]
      );
    },
    i(s) {
      n || (Nc(r, s), n = !0);
    },
    o(s) {
      Bc(r, s), n = !1;
    },
    d(s) {
      s && qc(e), r && r.d(s), i[6](null);
    }
  };
}
function Uc(i, e, t) {
  let n, { $$slots: o = {}, $$scope: r } = e, { size: s = "small" } = e, { unpadded_box: a = !1 } = e, l;
  function u(d) {
    var _;
    if (!d)
      return !1;
    const { height: f } = d.getBoundingClientRect(), { height: h } = ((_ = d.parentElement) === null || _ === void 0 ? void 0 : _.getBoundingClientRect()) || { height: f };
    return f > h + 2;
  }
  function c(d) {
    Mc[d ? "unshift" : "push"](() => {
      l = d, t(2, l);
    });
  }
  return i.$$set = (d) => {
    "size" in d && t(0, s = d.size), "unpadded_box" in d && t(1, a = d.unpadded_box), "$$scope" in d && t(4, r = d.$$scope);
  }, i.$$.update = () => {
    i.$$.dirty & /*el*/
    4 && t(3, n = u(l));
  }, [s, a, l, n, r, o, c];
}
class ha extends Lc {
  constructor(e) {
    super(), jc(this, e, Uc, Ic, Tc, { size: 0, unpadded_box: 1 });
  }
}
const {
  SvelteComponent: Fc,
  append: Vc,
  attr: Ye,
  detach: Hc,
  init: Zc,
  insert: Gc,
  noop: Po,
  safe_not_equal: Jc,
  svg_element: ur
} = window.__gradio__svelte__internal;
function Kc(i) {
  let e, t;
  return {
    c() {
      e = ur("svg"), t = ur("path"), Ye(t, "stroke", "currentColor"), Ye(t, "stroke-width", "1.5"), Ye(t, "stroke-linecap", "round"), Ye(t, "stroke-linejoin", "round"), Ye(t, "d", "M21.044 5.704a.6.6 0 0 1 .956.483v11.626a.6.6 0 0 1-.956.483l-7.889-5.813a.6.6 0 0 1 0-.966l7.89-5.813ZM10.044 5.704a.6.6 0 0 1 .956.483v11.626a.6.6 0 0 1-.956.483l-7.888-5.813a.6.6 0 0 1 0-.966l7.888-5.813Z"), Ye(e, "xmlns", "http://www.w3.org/2000/svg"), Ye(e, "width", "24px"), Ye(e, "height", "24px"), Ye(e, "fill", "currentColor"), Ye(e, "stroke-width", "1.5"), Ye(e, "viewBox", "0 0 24 24"), Ye(e, "color", "currentColor");
    },
    m(n, o) {
      Gc(n, e, o), Vc(e, t);
    },
    p: Po,
    i: Po,
    o: Po,
    d(n) {
      n && Hc(e);
    }
  };
}
class Xc extends Fc {
  constructor(e) {
    super(), Zc(this, e, null, Kc, Jc, {});
  }
}
const {
  SvelteComponent: Yc,
  append: To,
  attr: rt,
  detach: Qc,
  init: $c,
  insert: xc,
  noop: No,
  safe_not_equal: ed,
  set_style: bt,
  svg_element: Ui
} = window.__gradio__svelte__internal;
function td(i) {
  let e, t, n, o;
  return {
    c() {
      e = Ui("svg"), t = Ui("g"), n = Ui("path"), o = Ui("path"), rt(n, "d", "M18,6L6.087,17.913"), bt(n, "fill", "none"), bt(n, "fill-rule", "nonzero"), bt(n, "stroke-width", "2px"), rt(t, "transform", "matrix(1.14096,-0.140958,-0.140958,1.14096,-0.0559523,0.0559523)"), rt(o, "d", "M4.364,4.364L19.636,19.636"), bt(o, "fill", "none"), bt(o, "fill-rule", "nonzero"), bt(o, "stroke-width", "2px"), rt(e, "width", "100%"), rt(e, "height", "100%"), rt(e, "viewBox", "0 0 24 24"), rt(e, "version", "1.1"), rt(e, "xmlns", "http://www.w3.org/2000/svg"), rt(e, "xmlns:xlink", "http://www.w3.org/1999/xlink"), rt(e, "xml:space", "preserve"), rt(e, "stroke", "currentColor"), bt(e, "fill-rule", "evenodd"), bt(e, "clip-rule", "evenodd"), bt(e, "stroke-linecap", "round"), bt(e, "stroke-linejoin", "round");
    },
    m(r, s) {
      xc(r, e, s), To(e, t), To(t, n), To(e, o);
    },
    p: No,
    i: No,
    o: No,
    d(r) {
      r && Qc(e);
    }
  };
}
class nd extends Yc {
  constructor(e) {
    super(), $c(this, e, null, td, ed, {});
  }
}
const {
  SvelteComponent: id,
  append: od,
  attr: zn,
  detach: sd,
  init: rd,
  insert: ld,
  noop: Bo,
  safe_not_equal: ad,
  svg_element: cr
} = window.__gradio__svelte__internal;
function ud(i) {
  let e, t;
  return {
    c() {
      e = cr("svg"), t = cr("path"), zn(t, "fill", "currentColor"), zn(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"), zn(e, "xmlns", "http://www.w3.org/2000/svg"), zn(e, "width", "100%"), zn(e, "height", "100%"), zn(e, "viewBox", "0 0 32 32");
    },
    m(n, o) {
      ld(n, e, o), od(e, t);
    },
    p: Bo,
    i: Bo,
    o: Bo,
    d(n) {
      n && sd(e);
    }
  };
}
class ma extends id {
  constructor(e) {
    super(), rd(this, e, null, ud, ad, {});
  }
}
const {
  SvelteComponent: cd,
  append: dd,
  attr: lt,
  detach: fd,
  init: _d,
  insert: hd,
  noop: Wo,
  safe_not_equal: md,
  svg_element: dr
} = window.__gradio__svelte__internal;
function pd(i) {
  let e, t;
  return {
    c() {
      e = dr("svg"), t = dr("path"), lt(t, "d", "M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"), 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, "fill", "none"), lt(e, "stroke", "currentColor"), lt(e, "stroke-width", "1.5"), lt(e, "stroke-linecap", "round"), lt(e, "stroke-linejoin", "round"), lt(e, "class", "feather feather-edit-2");
    },
    m(n, o) {
      hd(n, e, o), dd(e, t);
    },
    p: Wo,
    i: Wo,
    o: Wo,
    d(n) {
      n && fd(e);
    }
  };
}
class gd extends cd {
  constructor(e) {
    super(), _d(this, e, null, pd, md, {});
  }
}
const {
  SvelteComponent: bd,
  append: vd,
  attr: Qe,
  detach: wd,
  init: yd,
  insert: kd,
  noop: Io,
  safe_not_equal: Cd,
  svg_element: fr
} = window.__gradio__svelte__internal;
function Sd(i) {
  let e, t;
  return {
    c() {
      e = fr("svg"), t = fr("path"), Qe(t, "stroke", "currentColor"), Qe(t, "stroke-width", "1.5"), Qe(t, "stroke-linecap", "round"), Qe(t, "stroke-linejoin", "round"), Qe(t, "d", "M2.956 5.704A.6.6 0 0 0 2 6.187v11.626a.6.6 0 0 0 .956.483l7.889-5.813a.6.6 0 0 0 0-.966l-7.89-5.813ZM13.956 5.704a.6.6 0 0 0-.956.483v11.626a.6.6 0 0 0 .956.483l7.889-5.813a.6.6 0 0 0 0-.966l-7.89-5.813Z"), Qe(e, "xmlns", "http://www.w3.org/2000/svg"), Qe(e, "width", "24px"), Qe(e, "height", "24px"), Qe(e, "fill", "currentColor"), Qe(e, "stroke-width", "1.5"), Qe(e, "viewBox", "0 0 24 24"), Qe(e, "color", "currentColor");
    },
    m(n, o) {
      kd(n, e, o), vd(e, t);
    },
    p: Io,
    i: Io,
    o: Io,
    d(n) {
      n && wd(e);
    }
  };
}
class Ed extends bd {
  constructor(e) {
    super(), yd(this, e, null, Sd, Cd, {});
  }
}
const {
  SvelteComponent: Dd,
  append: Ld,
  attr: jn,
  detach: Rd,
  init: Md,
  insert: Od,
  noop: Uo,
  safe_not_equal: qd,
  svg_element: _r
} = window.__gradio__svelte__internal;
function Ad(i) {
  let e, t;
  return {
    c() {
      e = _r("svg"), t = _r("path"), jn(t, "fill", "currentColor"), jn(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.78a3.99 3.99 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-2h3.5Zm2.245 2.096L16 4.25c0-.052-.002-.103-.005-.154ZM13.75 3.5h-3.5a.75.75 0 0 0 0 1.5h3.5a.75.75 0 0 0 0-1.5ZM15 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-3h-5Zm0 11a2.985 2.985 0 0 1-1.524-.415l3.494-3.494a.75.75 0 0 1 1.06 0l3.494 3.494A2.985 2.985 0 0 1 20 23h-5Zm5-7a1 1 0 1 1 0-2a1 1 0 0 1 0 2Z"), jn(e, "xmlns", "http://www.w3.org/2000/svg"), jn(e, "width", "100%"), jn(e, "height", "100%"), jn(e, "viewBox", "0 0 24 24");
    },
    m(n, o) {
      Od(n, e, o), Ld(e, t);
    },
    p: Uo,
    i: Uo,
    o: Uo,
    d(n) {
      n && Rd(e);
    }
  };
}
class pa extends Dd {
  constructor(e) {
    super(), Md(this, e, null, Ad, qd, {});
  }
}
const {
  SvelteComponent: zd,
  append: Fi,
  attr: we,
  detach: jd,
  init: Pd,
  insert: Td,
  noop: Fo,
  safe_not_equal: Nd,
  svg_element: ai
} = window.__gradio__svelte__internal;
function Bd(i) {
  let e, t, n, o, r;
  return {
    c() {
      e = ai("svg"), t = ai("path"), n = ai("path"), o = ai("line"), r = ai("line"), we(t, "d", "M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"), we(n, "d", "M19 10v2a7 7 0 0 1-14 0v-2"), we(o, "x1", "12"), we(o, "y1", "19"), we(o, "x2", "12"), we(o, "y2", "23"), we(r, "x1", "8"), we(r, "y1", "23"), we(r, "x2", "16"), we(r, "y2", "23"), we(e, "xmlns", "http://www.w3.org/2000/svg"), we(e, "width", "100%"), we(e, "height", "100%"), we(e, "viewBox", "0 0 24 24"), we(e, "fill", "none"), we(e, "stroke", "currentColor"), we(e, "stroke-width", "2"), we(e, "stroke-linecap", "round"), we(e, "stroke-linejoin", "round"), we(e, "class", "feather feather-mic");
    },
    m(s, a) {
      Td(s, e, a), Fi(e, t), Fi(e, n), Fi(e, o), Fi(e, r);
    },
    p: Fo,
    i: Fo,
    o: Fo,
    d(s) {
      s && jd(e);
    }
  };
}
class Wd extends zd {
  constructor(e) {
    super(), Pd(this, e, null, Bd, Nd, {});
  }
}
const {
  SvelteComponent: Id,
  append: Vo,
  attr: ze,
  detach: Ud,
  init: Fd,
  insert: Vd,
  noop: Ho,
  safe_not_equal: Hd,
  svg_element: Vi
} = window.__gradio__svelte__internal;
function Zd(i) {
  let e, t, n, o;
  return {
    c() {
      e = Vi("svg"), t = Vi("path"), n = Vi("circle"), o = Vi("circle"), ze(t, "d", "M9 18V5l12-2v13"), ze(n, "cx", "6"), ze(n, "cy", "18"), ze(n, "r", "3"), ze(o, "cx", "18"), ze(o, "cy", "16"), ze(o, "r", "3"), ze(e, "xmlns", "http://www.w3.org/2000/svg"), ze(e, "width", "100%"), ze(e, "height", "100%"), ze(e, "viewBox", "0 0 24 24"), ze(e, "fill", "none"), ze(e, "stroke", "currentColor"), ze(e, "stroke-width", "1.5"), ze(e, "stroke-linecap", "round"), ze(e, "stroke-linejoin", "round"), ze(e, "class", "feather feather-music");
    },
    m(r, s) {
      Vd(r, e, s), Vo(e, t), Vo(e, n), Vo(e, o);
    },
    p: Ho,
    i: Ho,
    o: Ho,
    d(r) {
      r && Ud(e);
    }
  };
}
class go extends Id {
  constructor(e) {
    super(), Fd(this, e, null, Zd, Hd, {});
  }
}
const {
  SvelteComponent: Gd,
  append: hr,
  attr: je,
  detach: Jd,
  init: Kd,
  insert: Xd,
  noop: Zo,
  safe_not_equal: Yd,
  svg_element: Go
} = window.__gradio__svelte__internal;
function Qd(i) {
  let e, t, n;
  return {
    c() {
      e = Go("svg"), t = Go("rect"), n = Go("rect"), je(t, "x", "6"), je(t, "y", "4"), je(t, "width", "4"), je(t, "height", "16"), je(n, "x", "14"), je(n, "y", "4"), je(n, "width", "4"), je(n, "height", "16"), je(e, "xmlns", "http://www.w3.org/2000/svg"), je(e, "width", "100%"), je(e, "height", "100%"), je(e, "viewBox", "0 0 24 24"), je(e, "fill", "currentColor"), je(e, "stroke", "currentColor"), je(e, "stroke-width", "1.5"), je(e, "stroke-linecap", "round"), je(e, "stroke-linejoin", "round");
    },
    m(o, r) {
      Xd(o, e, r), hr(e, t), hr(e, n);
    },
    p: Zo,
    i: Zo,
    o: Zo,
    d(o) {
      o && Jd(e);
    }
  };
}
class ga extends Gd {
  constructor(e) {
    super(), Kd(this, e, null, Qd, Yd, {});
  }
}
const {
  SvelteComponent: $d,
  append: xd,
  attr: vt,
  detach: ef,
  init: tf,
  insert: nf,
  noop: Jo,
  safe_not_equal: of,
  svg_element: mr
} = window.__gradio__svelte__internal;
function sf(i) {
  let e, t;
  return {
    c() {
      e = mr("svg"), t = mr("polygon"), vt(t, "points", "5 3 19 12 5 21 5 3"), vt(e, "xmlns", "http://www.w3.org/2000/svg"), vt(e, "width", "100%"), vt(e, "height", "100%"), vt(e, "viewBox", "0 0 24 24"), vt(e, "fill", "currentColor"), vt(e, "stroke", "currentColor"), vt(e, "stroke-width", "1.5"), vt(e, "stroke-linecap", "round"), vt(e, "stroke-linejoin", "round");
    },
    m(n, o) {
      nf(n, e, o), xd(e, t);
    },
    p: Jo,
    i: Jo,
    o: Jo,
    d(n) {
      n && ef(e);
    }
  };
}
class rf extends $d {
  constructor(e) {
    super(), tf(this, e, null, sf, of, {});
  }
}
const {
  SvelteComponent: lf,
  append: ui,
  attr: ce,
  detach: af,
  init: uf,
  insert: cf,
  noop: Ko,
  safe_not_equal: df,
  svg_element: Pn
} = window.__gradio__svelte__internal;
function ff(i) {
  let e, t, n, o, r, s;
  return {
    c() {
      e = Pn("svg"), t = Pn("circle"), n = Pn("circle"), o = Pn("line"), r = Pn("line"), s = Pn("line"), ce(t, "cx", "6"), ce(t, "cy", "6"), ce(t, "r", "3"), ce(n, "cx", "6"), ce(n, "cy", "18"), ce(n, "r", "3"), ce(o, "x1", "20"), ce(o, "y1", "4"), ce(o, "x2", "8.12"), ce(o, "y2", "15.88"), ce(r, "x1", "14.47"), ce(r, "y1", "14.48"), ce(r, "x2", "20"), ce(r, "y2", "20"), ce(s, "x1", "8.12"), ce(s, "y1", "8.12"), ce(s, "x2", "12"), ce(s, "y2", "12"), ce(e, "xmlns", "http://www.w3.org/2000/svg"), ce(e, "width", "100%"), ce(e, "height", "100%"), ce(e, "viewBox", "0 0 24 24"), ce(e, "fill", "none"), ce(e, "stroke", "currentColor"), ce(e, "stroke-width", "2"), ce(e, "stroke-linecap", "round"), ce(e, "stroke-linejoin", "round"), ce(e, "class", "feather feather-scissors");
    },
    m(a, l) {
      cf(a, e, l), ui(e, t), ui(e, n), ui(e, o), ui(e, r), ui(e, s);
    },
    p: Ko,
    i: Ko,
    o: Ko,
    d(a) {
      a && af(e);
    }
  };
}
class _f extends lf {
  constructor(e) {
    super(), uf(this, e, null, ff, df, {});
  }
}
const {
  SvelteComponent: hf,
  append: pr,
  attr: $e,
  detach: mf,
  init: pf,
  insert: gf,
  noop: Xo,
  safe_not_equal: bf,
  svg_element: Yo
} = window.__gradio__svelte__internal;
function vf(i) {
  let e, t, n;
  return {
    c() {
      e = Yo("svg"), t = Yo("polyline"), n = Yo("path"), $e(t, "points", "1 4 1 10 7 10"), $e(n, "d", "M3.51 15a9 9 0 1 0 2.13-9.36L1 10"), $e(e, "xmlns", "http://www.w3.org/2000/svg"), $e(e, "width", "100%"), $e(e, "height", "100%"), $e(e, "viewBox", "0 0 24 24"), $e(e, "fill", "none"), $e(e, "stroke", "currentColor"), $e(e, "stroke-width", "2"), $e(e, "stroke-linecap", "round"), $e(e, "stroke-linejoin", "round"), $e(e, "class", "feather feather-rotate-ccw");
    },
    m(o, r) {
      gf(o, e, r), pr(e, t), pr(e, n);
    },
    p: Xo,
    i: Xo,
    o: Xo,
    d(o) {
      o && mf(e);
    }
  };
}
class ba extends hf {
  constructor(e) {
    super(), pf(this, e, null, vf, bf, {});
  }
}
const {
  SvelteComponent: wf,
  append: Qo,
  attr: Ne,
  detach: yf,
  init: kf,
  insert: Cf,
  noop: $o,
  safe_not_equal: Sf,
  svg_element: Hi
} = window.__gradio__svelte__internal;
function Ef(i) {
  let e, t, n, o;
  return {
    c() {
      e = Hi("svg"), t = Hi("path"), n = Hi("polyline"), o = Hi("line"), Ne(t, "d", "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"), Ne(n, "points", "17 8 12 3 7 8"), Ne(o, "x1", "12"), Ne(o, "y1", "3"), Ne(o, "x2", "12"), Ne(o, "y2", "15"), Ne(e, "xmlns", "http://www.w3.org/2000/svg"), Ne(e, "width", "90%"), Ne(e, "height", "90%"), Ne(e, "viewBox", "0 0 24 24"), Ne(e, "fill", "none"), Ne(e, "stroke", "currentColor"), Ne(e, "stroke-width", "2"), Ne(e, "stroke-linecap", "round"), Ne(e, "stroke-linejoin", "round"), Ne(e, "class", "feather feather-upload");
    },
    m(r, s) {
      Cf(r, e, s), Qo(e, t), Qo(e, n), Qo(e, o);
    },
    p: $o,
    i: $o,
    o: $o,
    d(r) {
      r && yf(e);
    }
  };
}
let va = class extends wf {
  constructor(e) {
    super(), kf(this, e, null, Ef, Sf, {});
  }
};
const {
  SvelteComponent: Df,
  append: Zi,
  attr: Ie,
  detach: Lf,
  init: Rf,
  insert: Mf,
  noop: xo,
  safe_not_equal: Of,
  svg_element: Gi,
  text: qf
} = window.__gradio__svelte__internal;
function Af(i) {
  let e, t, n, o, r;
  return {
    c() {
      e = Gi("svg"), t = Gi("title"), n = qf("Low volume"), o = Gi("path"), r = Gi("path"), Ie(o, "d", "M19.5 7.5C19.5 7.5 21 9 21 11.5C21 14 19.5 15.5 19.5 15.5"), Ie(o, "stroke-width", "1.5"), Ie(o, "stroke-linecap", "round"), Ie(o, "stroke-linejoin", "round"), Ie(r, "d", "M2 13.8571V10.1429C2 9.03829 2.89543 8.14286 4 8.14286H6.9C7.09569 8.14286 7.28708 8.08544 7.45046 7.97772L13.4495 4.02228C14.1144 3.5839 15 4.06075 15 4.85714V19.1429C15 19.9392 14.1144 20.4161 13.4495 19.9777L7.45046 16.0223C7.28708 15.9146 7.09569 15.8571 6.9 15.8571H4C2.89543 15.8571 2 14.9617 2 13.8571Z"), Ie(r, "stroke-width", "1.5"), Ie(e, "width", "100%"), Ie(e, "height", "100%"), Ie(e, "viewBox", "0 0 24 24"), Ie(e, "stroke-width", "1.5"), Ie(e, "fill", "none"), Ie(e, "xmlns", "http://www.w3.org/2000/svg"), Ie(e, "stroke", "currentColor"), Ie(e, "color", "currentColor");
    },
    m(s, a) {
      Mf(s, e, a), Zi(e, t), Zi(t, n), Zi(e, o), Zi(e, r);
    },
    p: xo,
    i: xo,
    o: xo,
    d(s) {
      s && Lf(e);
    }
  };
}
class zf extends Df {
  constructor(e) {
    super(), Rf(this, e, null, Af, Of, {});
  }
}
const {
  SvelteComponent: jf,
  append: ci,
  attr: Me,
  detach: Pf,
  init: Tf,
  insert: Nf,
  noop: es,
  safe_not_equal: Bf,
  svg_element: di,
  text: Wf
} = window.__gradio__svelte__internal;
function If(i) {
  let e, t, n, o, r, s;
  return {
    c() {
      e = di("svg"), t = di("title"), n = Wf("High volume"), o = di("path"), r = di("path"), s = di("path"), Me(o, "d", "M1 13.8571V10.1429C1 9.03829 1.89543 8.14286 3 8.14286H5.9C6.09569 8.14286 6.28708 8.08544 6.45046 7.97772L12.4495 4.02228C13.1144 3.5839 14 4.06075 14 4.85714V19.1429C14 19.9392 13.1144 20.4161 12.4495 19.9777L6.45046 16.0223C6.28708 15.9146 6.09569 15.8571 5.9 15.8571H3C1.89543 15.8571 1 14.9617 1 13.8571Z"), Me(o, "stroke-width", "1.5"), Me(r, "d", "M17.5 7.5C17.5 7.5 19 9 19 11.5C19 14 17.5 15.5 17.5 15.5"), Me(r, "stroke-width", "1.5"), Me(r, "stroke-linecap", "round"), Me(r, "stroke-linejoin", "round"), Me(s, "d", "M20.5 4.5C20.5 4.5 23 7 23 11.5C23 16 20.5 18.5 20.5 18.5"), Me(s, "stroke-width", "1.5"), Me(s, "stroke-linecap", "round"), Me(s, "stroke-linejoin", "round"), Me(e, "width", "100%"), Me(e, "height", "100%"), Me(e, "viewBox", "0 0 24 24"), Me(e, "stroke-width", "1.5"), Me(e, "fill", "none"), Me(e, "stroke", "currentColor"), Me(e, "xmlns", "http://www.w3.org/2000/svg"), Me(e, "color", "currentColor");
    },
    m(a, l) {
      Nf(a, e, l), ci(e, t), ci(t, n), ci(e, o), ci(e, r), ci(e, s);
    },
    p: es,
    i: es,
    o: es,
    d(a) {
      a && Pf(e);
    }
  };
}
class Uf extends jf {
  constructor(e) {
    super(), Tf(this, e, null, If, Bf, {});
  }
}
const {
  SvelteComponent: Ff,
  append: It,
  attr: Ee,
  detach: Vf,
  init: Hf,
  insert: Zf,
  noop: ts,
  safe_not_equal: Gf,
  svg_element: Ut,
  text: Jf
} = window.__gradio__svelte__internal;
function Kf(i) {
  let e, t, n, o, r, s, a, l, u;
  return {
    c() {
      e = Ut("svg"), t = Ut("title"), n = Jf("Muted volume"), o = Ut("g"), r = Ut("path"), s = Ut("path"), a = Ut("defs"), l = Ut("clipPath"), u = Ut("rect"), Ee(r, "d", "M18 14L20.0005 12M22 10L20.0005 12M20.0005 12L18 10M20.0005 12L22 14"), Ee(r, "stroke-width", "1.5"), Ee(r, "stroke-linecap", "round"), Ee(r, "stroke-linejoin", "round"), Ee(s, "d", "M2 13.8571V10.1429C2 9.03829 2.89543 8.14286 4 8.14286H6.9C7.09569 8.14286 7.28708 8.08544 7.45046 7.97772L13.4495 4.02228C14.1144 3.5839 15 4.06075 15 4.85714V19.1429C15 19.9392 14.1144 20.4161 13.4495 19.9777L7.45046 16.0223C7.28708 15.9146 7.09569 15.8571 6.9 15.8571H4C2.89543 15.8571 2 14.9617 2 13.8571Z"), Ee(s, "stroke-width", "1.5"), Ee(o, "clip-path", "url(#clip0_3173_16686)"), Ee(u, "width", "24"), Ee(u, "height", "24"), Ee(u, "fill", "white"), Ee(l, "id", "clip0_3173_16686"), Ee(e, "width", "100%"), Ee(e, "height", "100%"), Ee(e, "viewBox", "0 0 24 24"), Ee(e, "stroke-width", "1.5"), Ee(e, "fill", "none"), Ee(e, "xmlns", "http://www.w3.org/2000/svg"), Ee(e, "stroke", "currentColor"), Ee(e, "color", "currentColor");
    },
    m(c, d) {
      Zf(c, e, d), It(e, t), It(t, n), It(e, o), It(o, r), It(o, s), It(e, a), It(a, l), It(l, u);
    },
    p: ts,
    i: ts,
    o: ts,
    d(c) {
      c && Vf(e);
    }
  };
}
class Xf extends Ff {
  constructor(e) {
    super(), Hf(this, e, null, Kf, Gf, {});
  }
}
const {
  SvelteComponent: Yf,
  append: gr,
  attr: Ft,
  detach: Qf,
  init: $f,
  insert: xf,
  noop: ns,
  safe_not_equal: e_,
  svg_element: is
} = window.__gradio__svelte__internal;
function t_(i) {
  let e, t, n;
  return {
    c() {
      e = is("svg"), t = is("path"), n = is("path"), Ft(t, "fill", "currentColor"), Ft(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"), Ft(n, "fill", "currentColor"), Ft(n, "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"), Ft(e, "xmlns", "http://www.w3.org/2000/svg"), Ft(e, "width", "100%"), Ft(e, "height", "100%"), Ft(e, "viewBox", "0 0 24 24");
    },
    m(o, r) {
      xf(o, e, r), gr(e, t), gr(e, n);
    },
    p: ns,
    i: ns,
    o: ns,
    d(o) {
      o && Qf(e);
    }
  };
}
class n_ extends Yf {
  constructor(e) {
    super(), $f(this, e, null, t_, e_, {});
  }
}
const {
  SvelteComponent: i_,
  append: pn,
  attr: Ls,
  check_outros: o_,
  create_component: wa,
  destroy_component: ya,
  detach: no,
  element: Rs,
  group_outros: s_,
  init: r_,
  insert: io,
  mount_component: ka,
  safe_not_equal: l_,
  set_data: Ms,
  space: Os,
  text: vi,
  toggle_class: br,
  transition_in: ao,
  transition_out: uo
} = window.__gradio__svelte__internal;
function a_(i) {
  let e, t;
  return e = new va({}), {
    c() {
      wa(e.$$.fragment);
    },
    m(n, o) {
      ka(e, n, o), t = !0;
    },
    i(n) {
      t || (ao(e.$$.fragment, n), t = !0);
    },
    o(n) {
      uo(e.$$.fragment, n), t = !1;
    },
    d(n) {
      ya(e, n);
    }
  };
}
function u_(i) {
  let e, t;
  return e = new pa({}), {
    c() {
      wa(e.$$.fragment);
    },
    m(n, o) {
      ka(e, n, o), t = !0;
    },
    i(n) {
      t || (ao(e.$$.fragment, n), t = !0);
    },
    o(n) {
      uo(e.$$.fragment, n), t = !1;
    },
    d(n) {
      ya(e, n);
    }
  };
}
function vr(i) {
  let e, t, n = (
    /*i18n*/
    i[1]("common.or") + ""
  ), o, r, s, a = (
    /*message*/
    (i[2] || /*i18n*/
    i[1]("upload_text.click_to_upload")) + ""
  ), l;
  return {
    c() {
      e = Rs("span"), t = vi("- "), o = vi(n), r = vi(" -"), s = Os(), l = vi(a), Ls(e, "class", "or svelte-kzcjhc");
    },
    m(u, c) {
      io(u, e, c), pn(e, t), pn(e, o), pn(e, r), io(u, s, c), io(u, l, c);
    },
    p(u, c) {
      c & /*i18n*/
      2 && n !== (n = /*i18n*/
      u[1]("common.or") + "") && Ms(o, n), c & /*message, i18n*/
      6 && a !== (a = /*message*/
      (u[2] || /*i18n*/
      u[1]("upload_text.click_to_upload")) + "") && Ms(l, a);
    },
    d(u) {
      u && (no(e), no(s), no(l));
    }
  };
}
function c_(i) {
  let e, t, n, o, r, s = (
    /*i18n*/
    i[1](
      /*defs*/
      i[5][
        /*type*/
        i[0]
      ] || /*defs*/
      i[5].file
    ) + ""
  ), a, l, u;
  const c = [u_, a_], d = [];
  function _(h, p) {
    return (
      /*type*/
      h[0] === "clipboard" ? 0 : 1
    );
  }
  n = _(i), o = d[n] = c[n](i);
  let f = (
    /*mode*/
    i[3] !== "short" && vr(i)
  );
  return {
    c() {
      e = Rs("div"), t = Rs("span"), o.c(), r = Os(), a = vi(s), l = Os(), f && f.c(), Ls(t, "class", "icon-wrap svelte-kzcjhc"), br(
        t,
        "hovered",
        /*hovered*/
        i[4]
      ), Ls(e, "class", "wrap svelte-kzcjhc");
    },
    m(h, p) {
      io(h, e, p), pn(e, t), d[n].m(t, null), pn(e, r), pn(e, a), pn(e, l), f && f.m(e, null), u = !0;
    },
    p(h, [p]) {
      let g = n;
      n = _(h), n !== g && (s_(), uo(d[g], 1, 1, () => {
        d[g] = null;
      }), o_(), o = d[n], o || (o = d[n] = c[n](h), o.c()), ao(o, 1), o.m(t, null)), (!u || p & /*hovered*/
      16) && br(
        t,
        "hovered",
        /*hovered*/
        h[4]
      ), (!u || p & /*i18n, type*/
      3) && s !== (s = /*i18n*/
      h[1](
        /*defs*/
        h[5][
          /*type*/
          h[0]
        ] || /*defs*/
        h[5].file
      ) + "") && Ms(a, s), /*mode*/
      h[3] !== "short" ? f ? f.p(h, p) : (f = vr(h), f.c(), f.m(e, null)) : f && (f.d(1), f = null);
    },
    i(h) {
      u || (ao(o), u = !0);
    },
    o(h) {
      uo(o), u = !1;
    },
    d(h) {
      h && no(e), d[n].d(), f && f.d();
    }
  };
}
function d_(i, e, t) {
  let { type: n = "file" } = e, { i18n: o } = e, { message: r = void 0 } = e, { mode: s = "full" } = e, { hovered: a = !1 } = e;
  const l = {
    image: "upload_text.drop_image",
    video: "upload_text.drop_video",
    audio: "upload_text.drop_audio",
    file: "upload_text.drop_file",
    csv: "upload_text.drop_csv",
    gallery: "upload_text.drop_gallery",
    clipboard: "upload_text.paste_clipboard"
  };
  return i.$$set = (u) => {
    "type" in u && t(0, n = u.type), "i18n" in u && t(1, o = u.i18n), "message" in u && t(2, r = u.message), "mode" in u && t(3, s = u.mode), "hovered" in u && t(4, a = u.hovered);
  }, [n, o, r, s, a, l];
}
class f_ extends i_ {
  constructor(e) {
    super(), r_(this, e, d_, c_, l_, {
      type: 0,
      i18n: 1,
      message: 2,
      mode: 3,
      hovered: 4
    });
  }
}
const {
  SvelteComponent: __,
  append: os,
  attr: Dt,
  check_outros: wi,
  create_component: bo,
  destroy_component: vo,
  detach: ni,
  element: Mi,
  empty: h_,
  group_outros: yi,
  init: m_,
  insert: ii,
  listen: wo,
  mount_component: yo,
  safe_not_equal: p_,
  space: ss,
  toggle_class: tn,
  transition_in: De,
  transition_out: Fe
} = window.__gradio__svelte__internal;
function wr(i) {
  let e, t = (
    /*sources*/
    i[1].includes("upload")
  ), n, o = (
    /*sources*/
    i[1].includes("microphone")
  ), r, s = (
    /*sources*/
    i[1].includes("webcam")
  ), a, l = (
    /*sources*/
    i[1].includes("clipboard")
  ), u, c = t && yr(i), d = o && kr(i), _ = s && Cr(i), f = l && Sr(i);
  return {
    c() {
      e = Mi("span"), c && c.c(), n = ss(), d && d.c(), r = ss(), _ && _.c(), a = ss(), f && f.c(), Dt(e, "class", "source-selection svelte-1jp3vgd"), Dt(e, "data-testid", "source-select");
    },
    m(h, p) {
      ii(h, e, p), c && c.m(e, null), os(e, n), d && d.m(e, null), os(e, r), _ && _.m(e, null), os(e, a), f && f.m(e, null), u = !0;
    },
    p(h, p) {
      p & /*sources*/
      2 && (t = /*sources*/
      h[1].includes("upload")), t ? c ? (c.p(h, p), p & /*sources*/
      2 && De(c, 1)) : (c = yr(h), c.c(), De(c, 1), c.m(e, n)) : c && (yi(), Fe(c, 1, 1, () => {
        c = null;
      }), wi()), p & /*sources*/
      2 && (o = /*sources*/
      h[1].includes("microphone")), o ? d ? (d.p(h, p), p & /*sources*/
      2 && De(d, 1)) : (d = kr(h), d.c(), De(d, 1), d.m(e, r)) : d && (yi(), Fe(d, 1, 1, () => {
        d = null;
      }), wi()), p & /*sources*/
      2 && (s = /*sources*/
      h[1].includes("webcam")), s ? _ ? (_.p(h, p), p & /*sources*/
      2 && De(_, 1)) : (_ = Cr(h), _.c(), De(_, 1), _.m(e, a)) : _ && (yi(), Fe(_, 1, 1, () => {
        _ = null;
      }), wi()), p & /*sources*/
      2 && (l = /*sources*/
      h[1].includes("clipboard")), l ? f ? (f.p(h, p), p & /*sources*/
      2 && De(f, 1)) : (f = Sr(h), f.c(), De(f, 1), f.m(e, null)) : f && (yi(), Fe(f, 1, 1, () => {
        f = null;
      }), wi());
    },
    i(h) {
      u || (De(c), De(d), De(_), De(f), u = !0);
    },
    o(h) {
      Fe(c), Fe(d), Fe(_), Fe(f), u = !1;
    },
    d(h) {
      h && ni(e), c && c.d(), d && d.d(), _ && _.d(), f && f.d();
    }
  };
}
function yr(i) {
  let e, t, n, o, r;
  return t = new va({}), {
    c() {
      e = Mi("button"), bo(t.$$.fragment), Dt(e, "class", "icon svelte-1jp3vgd"), Dt(e, "aria-label", "Upload file"), tn(
        e,
        "selected",
        /*active_source*/
        i[0] === "upload" || !/*active_source*/
        i[0]
      );
    },
    m(s, a) {
      ii(s, e, a), yo(t, e, null), n = !0, o || (r = wo(
        e,
        "click",
        /*click_handler*/
        i[6]
      ), o = !0);
    },
    p(s, a) {
      (!n || a & /*active_source*/
      1) && tn(
        e,
        "selected",
        /*active_source*/
        s[0] === "upload" || !/*active_source*/
        s[0]
      );
    },
    i(s) {
      n || (De(t.$$.fragment, s), n = !0);
    },
    o(s) {
      Fe(t.$$.fragment, s), n = !1;
    },
    d(s) {
      s && ni(e), vo(t), o = !1, r();
    }
  };
}
function kr(i) {
  let e, t, n, o, r;
  return t = new Wd({}), {
    c() {
      e = Mi("button"), bo(t.$$.fragment), Dt(e, "class", "icon svelte-1jp3vgd"), Dt(e, "aria-label", "Record audio"), tn(
        e,
        "selected",
        /*active_source*/
        i[0] === "microphone"
      );
    },
    m(s, a) {
      ii(s, e, a), yo(t, e, null), n = !0, o || (r = wo(
        e,
        "click",
        /*click_handler_1*/
        i[7]
      ), o = !0);
    },
    p(s, a) {
      (!n || a & /*active_source*/
      1) && tn(
        e,
        "selected",
        /*active_source*/
        s[0] === "microphone"
      );
    },
    i(s) {
      n || (De(t.$$.fragment, s), n = !0);
    },
    o(s) {
      Fe(t.$$.fragment, s), n = !1;
    },
    d(s) {
      s && ni(e), vo(t), o = !1, r();
    }
  };
}
function Cr(i) {
  let e, t, n, o, r;
  return t = new n_({}), {
    c() {
      e = Mi("button"), bo(t.$$.fragment), Dt(e, "class", "icon svelte-1jp3vgd"), Dt(e, "aria-label", "Capture from camera"), tn(
        e,
        "selected",
        /*active_source*/
        i[0] === "webcam"
      );
    },
    m(s, a) {
      ii(s, e, a), yo(t, e, null), n = !0, o || (r = wo(
        e,
        "click",
        /*click_handler_2*/
        i[8]
      ), o = !0);
    },
    p(s, a) {
      (!n || a & /*active_source*/
      1) && tn(
        e,
        "selected",
        /*active_source*/
        s[0] === "webcam"
      );
    },
    i(s) {
      n || (De(t.$$.fragment, s), n = !0);
    },
    o(s) {
      Fe(t.$$.fragment, s), n = !1;
    },
    d(s) {
      s && ni(e), vo(t), o = !1, r();
    }
  };
}
function Sr(i) {
  let e, t, n, o, r;
  return t = new pa({}), {
    c() {
      e = Mi("button"), bo(t.$$.fragment), Dt(e, "class", "icon svelte-1jp3vgd"), Dt(e, "aria-label", "Paste from clipboard"), tn(
        e,
        "selected",
        /*active_source*/
        i[0] === "clipboard"
      );
    },
    m(s, a) {
      ii(s, e, a), yo(t, e, null), n = !0, o || (r = wo(
        e,
        "click",
        /*click_handler_3*/
        i[9]
      ), o = !0);
    },
    p(s, a) {
      (!n || a & /*active_source*/
      1) && tn(
        e,
        "selected",
        /*active_source*/
        s[0] === "clipboard"
      );
    },
    i(s) {
      n || (De(t.$$.fragment, s), n = !0);
    },
    o(s) {
      Fe(t.$$.fragment, s), n = !1;
    },
    d(s) {
      s && ni(e), vo(t), o = !1, r();
    }
  };
}
function g_(i) {
  let e, t, n = (
    /*unique_sources*/
    i[2].length > 1 && wr(i)
  );
  return {
    c() {
      n && n.c(), e = h_();
    },
    m(o, r) {
      n && n.m(o, r), ii(o, e, r), t = !0;
    },
    p(o, [r]) {
      /*unique_sources*/
      o[2].length > 1 ? n ? (n.p(o, r), r & /*unique_sources*/
      4 && De(n, 1)) : (n = wr(o), n.c(), De(n, 1), n.m(e.parentNode, e)) : n && (yi(), Fe(n, 1, 1, () => {
        n = null;
      }), wi());
    },
    i(o) {
      t || (De(n), t = !0);
    },
    o(o) {
      Fe(n), t = !1;
    },
    d(o) {
      o && ni(e), n && n.d(o);
    }
  };
}
function b_(i, e, t) {
  let n;
  var o = this && this.__awaiter || function(h, p, g, m) {
    function k(w) {
      return w instanceof g ? w : new g(function(S) {
        S(w);
      });
    }
    return new (g || (g = Promise))(function(w, S) {
      function v(E) {
        try {
          L(m.next(E));
        } catch (D) {
          S(D);
        }
      }
      function b(E) {
        try {
          L(m.throw(E));
        } catch (D) {
          S(D);
        }
      }
      function L(E) {
        E.done ? w(E.value) : k(E.value).then(v, b);
      }
      L((m = m.apply(h, p || [])).next());
    });
  };
  let { sources: r } = e, { active_source: s } = e, { handle_clear: a = () => {
  } } = e, { handle_select: l = () => {
  } } = e;
  function u(h) {
    return o(this, void 0, void 0, function* () {
      a(), t(0, s = h), l(h);
    });
  }
  const c = () => u("upload"), d = () => u("microphone"), _ = () => u("webcam"), f = () => u("clipboard");
  return i.$$set = (h) => {
    "sources" in h && t(1, r = h.sources), "active_source" in h && t(0, s = h.active_source), "handle_clear" in h && t(4, a = h.handle_clear), "handle_select" in h && t(5, l = h.handle_select);
  }, i.$$.update = () => {
    i.$$.dirty & /*sources*/
    2 && t(2, n = [...new Set(r)]);
  }, [
    s,
    r,
    n,
    u,
    a,
    l,
    c,
    d,
    _,
    f
  ];
}
class v_ extends __ {
  constructor(e) {
    super(), m_(this, e, b_, g_, p_, {
      sources: 1,
      active_source: 0,
      handle_clear: 4,
      handle_select: 5
    });
  }
}
const {
  SvelteComponent: w_,
  append: fi,
  attr: at,
  detach: y_,
  init: k_,
  insert: C_,
  noop: rs,
  safe_not_equal: S_,
  svg_element: Tn
} = window.__gradio__svelte__internal;
function E_(i) {
  let e, t, n, o, r, s;
  return {
    c() {
      e = Tn("svg"), t = Tn("g"), n = Tn("g"), o = Tn("path"), r = Tn("path"), s = Tn("polygon"), at(o, "d", `M348.994,102.946L250.04,3.993c-5.323-5.323-13.954-5.324-19.277,0l-153.7,153.701l118.23,118.23l153.701-153.7\r
			C354.317,116.902,354.317,108.271,348.994,102.946z`), at(r, "d", `M52.646,182.11l-41.64,41.64c-5.324,5.322-5.324,13.953,0,19.275l98.954,98.957c5.323,5.322,13.954,5.32,19.277,0\r
			l41.639-41.641L52.646,182.11z`), at(s, "points", "150.133,360 341.767,360 341.767,331.949 182.806,331.949"), at(e, "version", "1.1"), at(e, "id", "Capa_1"), at(e, "xmlns", "http://www.w3.org/2000/svg"), at(e, "xmlns:xlink", "http://www.w3.org/1999/xlink"), at(e, "width", "100%"), at(e, "height", "100%"), at(e, "viewBox", "0 0 360 360"), at(e, "color", "#9CA3AF");
    },
    m(a, l) {
      C_(a, e, l), fi(e, t), fi(t, n), fi(n, o), fi(n, r), fi(n, s);
    },
    p: rs,
    i: rs,
    o: rs,
    d(a) {
      a && y_(e);
    }
  };
}
class D_ extends w_ {
  constructor(e) {
    super(), k_(this, e, null, E_, S_, {});
  }
}
function Se(i, e, t, n) {
  return new (t || (t = Promise))(function(o, r) {
    function s(u) {
      try {
        l(n.next(u));
      } catch (c) {
        r(c);
      }
    }
    function a(u) {
      try {
        l(n.throw(u));
      } catch (c) {
        r(c);
      }
    }
    function l(u) {
      var c;
      u.done ? o(u.value) : (c = u.value, c instanceof t ? c : new t(function(d) {
        d(c);
      })).then(s, a);
    }
    l((n = n.apply(i, e || [])).next());
  });
}
let Oi = class {
  constructor() {
    this.listeners = {};
  }
  on(e, t, n) {
    if (this.listeners[e] || (this.listeners[e] = /* @__PURE__ */ new Set()), this.listeners[e].add(t), n == null ? void 0 : n.once) {
      const o = () => {
        this.un(e, o), this.un(e, t);
      };
      return this.on(e, o), o;
    }
    return () => this.un(e, t);
  }
  un(e, t) {
    var n;
    (n = this.listeners[e]) === null || n === void 0 || n.delete(t);
  }
  once(e, t) {
    return this.on(e, t, { once: !0 });
  }
  unAll() {
    this.listeners = {};
  }
  emit(e, ...t) {
    this.listeners[e] && this.listeners[e].forEach((n) => n(...t));
  }
};
const Er = { decode: function(i, e) {
  return Se(this, void 0, void 0, function* () {
    const t = new AudioContext({ sampleRate: e });
    return t.decodeAudioData(i).finally(() => t.close());
  });
}, createBuffer: function(i, e) {
  return typeof i[0] == "number" && (i = [i]), function(t) {
    const n = t[0];
    if (n.some((o) => o > 1 || o < -1)) {
      const o = n.length;
      let r = 0;
      for (let s = 0; s < o; s++) {
        const a = Math.abs(n[s]);
        a > r && (r = a);
      }
      for (const s of t)
        for (let a = 0; a < o; a++)
          s[a] /= r;
    }
  }(i), { duration: e, length: i[0].length, sampleRate: i[0].length / e, numberOfChannels: i.length, getChannelData: (t) => i == null ? void 0 : i[t], copyFromChannel: AudioBuffer.prototype.copyFromChannel, copyToChannel: AudioBuffer.prototype.copyToChannel };
} };
function Ca(i, e) {
  const t = e.xmlns ? document.createElementNS(e.xmlns, i) : document.createElement(i);
  for (const [n, o] of Object.entries(e))
    if (n === "children")
      for (const [r, s] of Object.entries(e))
        typeof s == "string" ? t.appendChild(document.createTextNode(s)) : t.appendChild(Ca(r, s));
    else
      n === "style" ? Object.assign(t.style, o) : n === "textContent" ? t.textContent = o : t.setAttribute(n, o.toString());
  return t;
}
function Dr(i, e, t) {
  const n = Ca(i, e || {});
  return t == null || t.appendChild(n), n;
}
var L_ = Object.freeze({ __proto__: null, createElement: Dr, default: Dr });
const R_ = { fetchBlob: function(i, e, t) {
  return Se(this, void 0, void 0, function* () {
    const n = yield fetch(i, t);
    if (n.status >= 400)
      throw new Error(`Failed to fetch ${i}: ${n.status} (${n.statusText})`);
    return function(o, r) {
      Se(this, void 0, void 0, function* () {
        if (!o.body || !o.headers)
          return;
        const s = o.body.getReader(), a = Number(o.headers.get("Content-Length")) || 0;
        let l = 0;
        const u = (d) => Se(this, void 0, void 0, function* () {
          l += (d == null ? void 0 : d.length) || 0;
          const _ = Math.round(l / a * 100);
          r(_);
        }), c = () => Se(this, void 0, void 0, function* () {
          let d;
          try {
            d = yield s.read();
          } catch {
            return;
          }
          d.done || (u(d.value), yield c());
        });
        c();
      });
    }(n.clone(), e), n.blob();
  });
} };
class M_ extends Oi {
  constructor(e) {
    super(), this.isExternalMedia = !1, e.media ? (this.media = e.media, this.isExternalMedia = !0) : this.media = document.createElement("audio"), e.mediaControls && (this.media.controls = !0), e.autoplay && (this.media.autoplay = !0), e.playbackRate != null && this.onMediaEvent("canplay", () => {
      e.playbackRate != null && (this.media.playbackRate = e.playbackRate);
    }, { once: !0 });
  }
  onMediaEvent(e, t, n) {
    return this.media.addEventListener(e, t, n), () => this.media.removeEventListener(e, t, n);
  }
  getSrc() {
    return this.media.currentSrc || this.media.src || "";
  }
  revokeSrc() {
    const e = this.getSrc();
    e.startsWith("blob:") && URL.revokeObjectURL(e);
  }
  canPlayType(e) {
    return this.media.canPlayType(e) !== "";
  }
  setSrc(e, t) {
    if (this.getSrc() === e)
      return;
    this.revokeSrc();
    const n = t instanceof Blob && this.canPlayType(t.type) ? URL.createObjectURL(t) : e;
    this.media.src = n;
  }
  destroy() {
    this.media.pause(), this.isExternalMedia || (this.media.remove(), this.revokeSrc(), this.media.src = "", this.media.load());
  }
  setMediaElement(e) {
    this.media = e;
  }
  play() {
    return Se(this, void 0, void 0, function* () {
      return this.media.play();
    });
  }
  pause() {
    this.media.pause();
  }
  isPlaying() {
    return !this.media.paused && !this.media.ended;
  }
  setTime(e) {
    this.media.currentTime = e;
  }
  getDuration() {
    return this.media.duration;
  }
  getCurrentTime() {
    return this.media.currentTime;
  }
  getVolume() {
    return this.media.volume;
  }
  setVolume(e) {
    this.media.volume = e;
  }
  getMuted() {
    return this.media.muted;
  }
  setMuted(e) {
    this.media.muted = e;
  }
  getPlaybackRate() {
    return this.media.playbackRate;
  }
  isSeeking() {
    return this.media.seeking;
  }
  setPlaybackRate(e, t) {
    t != null && (this.media.preservesPitch = t), this.media.playbackRate = e;
  }
  getMediaElement() {
    return this.media;
  }
  setSinkId(e) {
    return this.media.setSinkId(e);
  }
}
class ko extends Oi {
  constructor(e, t) {
    super(), this.timeouts = [], this.isScrollable = !1, this.audioData = null, this.resizeObserver = null, this.lastContainerWidth = 0, this.isDragging = !1, this.subscriptions = [], this.subscriptions = [], this.options = e;
    const n = this.parentFromOptionsContainer(e.container);
    this.parent = n;
    const [o, r] = this.initHtml();
    n.appendChild(o), this.container = o, this.scrollContainer = r.querySelector(".scroll"), this.wrapper = r.querySelector(".wrapper"), this.canvasWrapper = r.querySelector(".canvases"), this.progressWrapper = r.querySelector(".progress"), this.cursor = r.querySelector(".cursor"), t && r.appendChild(t), this.initEvents();
  }
  parentFromOptionsContainer(e) {
    let t;
    if (typeof e == "string" ? t = document.querySelector(e) : e instanceof HTMLElement && (t = e), !t)
      throw new Error("Container not found");
    return t;
  }
  initEvents() {
    const e = (n) => {
      const o = this.wrapper.getBoundingClientRect(), r = n.clientX - o.left, s = n.clientY - o.top;
      return [r / o.width, s / o.height];
    };
    this.wrapper.addEventListener("click", (n) => {
      const [o, r] = e(n);
      this.emit("click", o, r);
    }), this.wrapper.addEventListener("dblclick", (n) => {
      const [o, r] = e(n);
      this.emit("dblclick", o, r);
    }), this.options.dragToSeek !== !0 && typeof this.options.dragToSeek != "object" || this.initDrag(), this.scrollContainer.addEventListener("scroll", () => {
      const { scrollLeft: n, scrollWidth: o, clientWidth: r } = this.scrollContainer, s = n / o, a = (n + r) / o;
      this.emit("scroll", s, a);
    });
    const t = this.createDelay(100);
    this.resizeObserver = new ResizeObserver(() => {
      t().then(() => this.onContainerResize()).catch(() => {
      });
    }), this.resizeObserver.observe(this.scrollContainer);
  }
  onContainerResize() {
    const e = this.parent.clientWidth;
    e === this.lastContainerWidth && this.options.height !== "auto" || (this.lastContainerWidth = e, this.reRender());
  }
  initDrag() {
    this.subscriptions.push(function(e, t, n, o, r = 3, s = 0, a = 100) {
      if (!e)
        return () => {
        };
      const l = matchMedia("(pointer: coarse)").matches;
      let u = () => {
      };
      const c = (d) => {
        if (d.button !== s)
          return;
        d.preventDefault(), d.stopPropagation();
        let _ = d.clientX, f = d.clientY, h = !1;
        const p = Date.now(), g = (v) => {
          if (v.preventDefault(), v.stopPropagation(), l && Date.now() - p < a)
            return;
          const b = v.clientX, L = v.clientY, E = b - _, D = L - f;
          if (h || Math.abs(E) > r || Math.abs(D) > r) {
            const P = e.getBoundingClientRect(), { left: F, top: q } = P;
            h || (n == null || n(_ - F, f - q), h = !0), t(E, D, b - F, L - q), _ = b, f = L;
          }
        }, m = (v) => {
          if (h) {
            const b = v.clientX, L = v.clientY, E = e.getBoundingClientRect(), { left: D, top: P } = E;
            o == null || o(b - D, L - P);
          }
          u();
        }, k = (v) => {
          v.relatedTarget && v.relatedTarget !== document.documentElement || m(v);
        }, w = (v) => {
          h && (v.stopPropagation(), v.preventDefault());
        }, S = (v) => {
          h && v.preventDefault();
        };
        document.addEventListener("pointermove", g), document.addEventListener("pointerup", m), document.addEventListener("pointerout", k), document.addEventListener("pointercancel", k), document.addEventListener("touchmove", S, { passive: !1 }), document.addEventListener("click", w, { capture: !0 }), u = () => {
          document.removeEventListener("pointermove", g), document.removeEventListener("pointerup", m), document.removeEventListener("pointerout", k), document.removeEventListener("pointercancel", k), document.removeEventListener("touchmove", S), setTimeout(() => {
            document.removeEventListener("click", w, { capture: !0 });
          }, 10);
        };
      };
      return e.addEventListener("pointerdown", c), () => {
        u(), e.removeEventListener("pointerdown", c);
      };
    }(this.wrapper, (e, t, n) => {
      this.emit("drag", Math.max(0, Math.min(1, n / this.wrapper.getBoundingClientRect().width)));
    }, (e) => {
      this.isDragging = !0, this.emit("dragstart", Math.max(0, Math.min(1, e / this.wrapper.getBoundingClientRect().width)));
    }, (e) => {
      this.isDragging = !1, this.emit("dragend", Math.max(0, Math.min(1, e / this.wrapper.getBoundingClientRect().width)));
    }));
  }
  getHeight(e, t) {
    var n;
    const o = ((n = this.audioData) === null || n === void 0 ? void 0 : n.numberOfChannels) || 1;
    if (e == null)
      return 128;
    if (!isNaN(Number(e)))
      return Number(e);
    if (e === "auto") {
      const r = this.parent.clientHeight || 128;
      return t != null && t.every((s) => !s.overlay) ? r / o : r;
    }
    return 128;
  }
  initHtml() {
    const e = document.createElement("div"), t = e.attachShadow({ mode: "open" });
    return t.innerHTML = `
      <style>
        :host {
          user-select: none;
          min-width: 1px;
        }
        :host audio {
          display: block;
          width: 100%;
        }
        :host .scroll {
          overflow-x: auto;
          overflow-y: hidden;
          width: 100%;
          position: relative;
        }
        :host .noScrollbar {
          scrollbar-color: transparent;
          scrollbar-width: none;
        }
        :host .noScrollbar::-webkit-scrollbar {
          display: none;
          -webkit-appearance: none;
        }
        :host .wrapper {
          position: relative;
          overflow: visible;
          z-index: 2;
        }
        :host .canvases {
          min-height: ${this.getHeight(this.options.height, this.options.splitChannels)}px;
        }
        :host .canvases > div {
          position: relative;
        }
        :host canvas {
          display: block;
          position: absolute;
          top: 0;
          image-rendering: pixelated;
        }
        :host .progress {
          pointer-events: none;
          position: absolute;
          z-index: 2;
          top: 0;
          left: 0;
          width: 0;
          height: 100%;
          overflow: hidden;
        }
        :host .progress > div {
          position: relative;
        }
        :host .cursor {
          pointer-events: none;
          position: absolute;
          z-index: 5;
          top: 0;
          left: 0;
          height: 100%;
          border-radius: 2px;
        }
      </style>

      <div class="scroll" part="scroll">
        <div class="wrapper" part="wrapper">
          <div class="canvases" part="canvases"></div>
          <div class="progress" part="progress"></div>
          <div class="cursor" part="cursor"></div>
        </div>
      </div>
    `, [e, t];
  }
  setOptions(e) {
    if (this.options.container !== e.container) {
      const t = this.parentFromOptionsContainer(e.container);
      t.appendChild(this.container), this.parent = t;
    }
    e.dragToSeek !== !0 && typeof this.options.dragToSeek != "object" || this.initDrag(), this.options = e, this.reRender();
  }
  getWrapper() {
    return this.wrapper;
  }
  getScroll() {
    return this.scrollContainer.scrollLeft;
  }
  setScroll(e) {
    this.scrollContainer.scrollLeft = e;
  }
  setScrollPercentage(e) {
    const { scrollWidth: t } = this.scrollContainer, n = t * e;
    this.setScroll(n);
  }
  destroy() {
    var e;
    this.subscriptions.forEach((t) => t()), this.container.remove(), (e = this.resizeObserver) === null || e === void 0 || e.disconnect();
  }
  createDelay(e = 10) {
    let t, n;
    const o = () => {
      t && clearTimeout(t), n && n();
    };
    return this.timeouts.push(o), () => new Promise((r, s) => {
      o(), n = s, t = setTimeout(() => {
        t = void 0, n = void 0, r();
      }, e);
    });
  }
  convertColorValues(e) {
    if (!Array.isArray(e))
      return e || "";
    if (e.length < 2)
      return e[0] || "";
    const t = document.createElement("canvas"), n = t.getContext("2d"), o = t.height * (window.devicePixelRatio || 1), r = n.createLinearGradient(0, 0, 0, o), s = 1 / (e.length - 1);
    return e.forEach((a, l) => {
      const u = l * s;
      r.addColorStop(u, a);
    }), r;
  }
  renderBarWaveform(e, t, n, o) {
    const r = e[0], s = e[1] || e[0], a = r.length, { width: l, height: u } = n.canvas, c = u / 2, d = window.devicePixelRatio || 1, _ = t.barWidth ? t.barWidth * d : 1, f = t.barGap ? t.barGap * d : t.barWidth ? _ / 2 : 0, h = t.barRadius || 0, p = l / (_ + f) / a, g = h && "roundRect" in n ? "roundRect" : "rect";
    n.beginPath();
    let m = 0, k = 0, w = 0;
    for (let S = 0; S <= a; S++) {
      const v = Math.round(S * p);
      if (v > m) {
        const E = Math.round(k * c * o), D = E + Math.round(w * c * o) || 1;
        let P = c - E;
        t.barAlign === "top" ? P = 0 : t.barAlign === "bottom" && (P = u - D), n[g](m * (_ + f), P, _, D, h), m = v, k = 0, w = 0;
      }
      const b = Math.abs(r[S] || 0), L = Math.abs(s[S] || 0);
      b > k && (k = b), L > w && (w = L);
    }
    n.fill(), n.closePath();
  }
  renderLineWaveform(e, t, n, o) {
    const r = (s) => {
      const a = e[s] || e[0], l = a.length, { height: u } = n.canvas, c = u / 2, d = n.canvas.width / l;
      n.moveTo(0, c);
      let _ = 0, f = 0;
      for (let h = 0; h <= l; h++) {
        const p = Math.round(h * d);
        if (p > _) {
          const m = c + (Math.round(f * c * o) || 1) * (s === 0 ? -1 : 1);
          n.lineTo(_, m), _ = p, f = 0;
        }
        const g = Math.abs(a[h] || 0);
        g > f && (f = g);
      }
      n.lineTo(_, c);
    };
    n.beginPath(), r(0), r(1), n.fill(), n.closePath();
  }
  renderWaveform(e, t, n) {
    if (n.fillStyle = this.convertColorValues(t.waveColor), t.renderFunction)
      return void t.renderFunction(e, n);
    let o = t.barHeight || 1;
    if (t.normalize) {
      const r = Array.from(e[0]).reduce((s, a) => Math.max(s, Math.abs(a)), 0);
      o = r ? 1 / r : 1;
    }
    t.barWidth || t.barGap || t.barAlign ? this.renderBarWaveform(e, t, n, o) : this.renderLineWaveform(e, t, n, o);
  }
  renderSingleCanvas(e, t, n, o, r, s, a) {
    const l = window.devicePixelRatio || 1, u = document.createElement("canvas");
    u.width = Math.round(n * l), u.height = Math.round(o * l), u.style.width = `${n}px`, u.style.height = `${o}px`, u.style.left = `${Math.round(r)}px`, s.appendChild(u);
    const c = u.getContext("2d");
    if (this.renderWaveform(e, t, c), u.width > 0 && u.height > 0) {
      const d = u.cloneNode(), _ = d.getContext("2d");
      _.drawImage(u, 0, 0), _.globalCompositeOperation = "source-in", _.fillStyle = this.convertColorValues(t.progressColor), _.fillRect(0, 0, u.width, u.height), a.appendChild(d);
    }
  }
  renderMultiCanvas(e, t, n, o, r, s) {
    return Se(this, void 0, void 0, function* () {
      const a = window.devicePixelRatio || 1, l = n / a;
      let u = Math.min(ko.MAX_CANVAS_WIDTH, this.scrollContainer.clientWidth);
      if (t.barWidth || t.barGap) {
        const h = t.barWidth || 0.5, p = h + (t.barGap || h / 2);
        u % p != 0 && (u = Math.floor(u / p) * p);
      }
      const c = (h) => {
        const p = h * u, g = Math.min(l - p, u), m = e.map((k) => {
          const w = Math.floor(p / l * k.length), S = Math.floor((p + g) / l * k.length);
          return k.slice(w, S);
        });
        this.renderSingleCanvas(m, t, g, o, p, r, s);
      }, d = Math.ceil(l / u);
      if (d === 1)
        return void c(0);
      const _ = this.scrollContainer.scrollLeft / l, f = Math.floor(_ * d);
      c(f), c(f + 1), yield Promise.all([Se(this, void 0, void 0, function* () {
        const h = this.createDelay();
        for (let p = f - 1; p >= 0; p--)
          yield h(), c(p);
      }), Se(this, void 0, void 0, function* () {
        const h = this.createDelay();
        for (let p = f + 2; p < d; p++)
          yield h(), c(p);
      })]);
    });
  }
  renderChannel(e, t, n, o) {
    return Se(this, void 0, void 0, function* () {
      var { overlay: r } = t, s = function(c, d) {
        var _ = {};
        for (var f in c)
          Object.prototype.hasOwnProperty.call(c, f) && d.indexOf(f) < 0 && (_[f] = c[f]);
        if (c != null && typeof Object.getOwnPropertySymbols == "function") {
          var h = 0;
          for (f = Object.getOwnPropertySymbols(c); h < f.length; h++)
            d.indexOf(f[h]) < 0 && Object.prototype.propertyIsEnumerable.call(c, f[h]) && (_[f[h]] = c[f[h]]);
        }
        return _;
      }(t, ["overlay"]);
      const a = document.createElement("div"), l = this.getHeight(s.height, s.splitChannels);
      a.style.height = `${l}px`, r && o > 0 && (a.style.marginTop = `-${l}px`), this.canvasWrapper.style.minHeight = `${l}px`, this.canvasWrapper.appendChild(a);
      const u = a.cloneNode();
      this.progressWrapper.appendChild(u), yield this.renderMultiCanvas(e, s, n, l, a, u);
    });
  }
  render(e) {
    return Se(this, void 0, void 0, function* () {
      this.timeouts.forEach((a) => a()), this.timeouts = [], this.canvasWrapper.innerHTML = "", this.progressWrapper.innerHTML = "", this.options.width != null && (this.scrollContainer.style.width = typeof this.options.width == "number" ? `${this.options.width}px` : this.options.width);
      const t = window.devicePixelRatio || 1, n = this.scrollContainer.clientWidth, o = Math.ceil(e.duration * (this.options.minPxPerSec || 0));
      this.isScrollable = o > n;
      const r = this.options.fillParent && !this.isScrollable, s = (r ? n : o) * t;
      this.wrapper.style.width = r ? "100%" : `${o}px`, this.scrollContainer.style.overflowX = this.isScrollable ? "auto" : "hidden", this.scrollContainer.classList.toggle("noScrollbar", !!this.options.hideScrollbar), this.cursor.style.backgroundColor = `${this.options.cursorColor || this.options.progressColor}`, this.cursor.style.width = `${this.options.cursorWidth}px`, this.audioData = e, this.emit("render");
      try {
        if (this.options.splitChannels)
          yield Promise.all(Array.from({ length: e.numberOfChannels }).map((a, l) => {
            var u;
            const c = Object.assign(Object.assign({}, this.options), (u = this.options.splitChannels) === null || u === void 0 ? void 0 : u[l]);
            return this.renderChannel([e.getChannelData(l)], c, s, l);
          }));
        else {
          const a = [e.getChannelData(0)];
          e.numberOfChannels > 1 && a.push(e.getChannelData(1)), yield this.renderChannel(a, this.options, s, 0);
        }
      } catch {
        return;
      }
      this.emit("rendered");
    });
  }
  reRender() {
    if (!this.audioData)
      return;
    const { scrollWidth: e } = this.scrollContainer, { right: t } = this.progressWrapper.getBoundingClientRect();
    if (this.render(this.audioData), this.isScrollable && e !== this.scrollContainer.scrollWidth) {
      const { right: n } = this.progressWrapper.getBoundingClientRect();
      let o = n - t;
      o *= 2, o = o < 0 ? Math.floor(o) : Math.ceil(o), o /= 2, this.scrollContainer.scrollLeft += o;
    }
  }
  zoom(e) {
    this.options.minPxPerSec = e, this.reRender();
  }
  scrollIntoView(e, t = !1) {
    const { scrollLeft: n, scrollWidth: o, clientWidth: r } = this.scrollContainer, s = e * o, a = n, l = n + r, u = r / 2;
    if (this.isDragging)
      s + 30 > l ? this.scrollContainer.scrollLeft += 30 : s - 30 < a && (this.scrollContainer.scrollLeft -= 30);
    else {
      (s < a || s > l) && (this.scrollContainer.scrollLeft = s - (this.options.autoCenter ? u : 0));
      const c = s - n - u;
      t && this.options.autoCenter && c > 0 && (this.scrollContainer.scrollLeft += Math.min(c, 10));
    }
    {
      const c = this.scrollContainer.scrollLeft, d = c / o, _ = (c + r) / o;
      this.emit("scroll", d, _);
    }
  }
  renderProgress(e, t) {
    if (isNaN(e))
      return;
    const n = 100 * e;
    this.canvasWrapper.style.clipPath = `polygon(${n}% 0, 100% 0, 100% 100%, ${n}% 100%)`, this.progressWrapper.style.width = `${n}%`, this.cursor.style.left = `${n}%`, this.cursor.style.transform = `translateX(-${Math.round(n) === 100 ? this.options.cursorWidth : 0}px)`, this.isScrollable && this.options.autoScroll && this.scrollIntoView(e, t);
  }
  exportImage(e, t, n) {
    return Se(this, void 0, void 0, function* () {
      const o = this.canvasWrapper.querySelectorAll("canvas");
      if (!o.length)
        throw new Error("No waveform data");
      if (n === "dataURL") {
        const r = Array.from(o).map((s) => s.toDataURL(e, t));
        return Promise.resolve(r);
      }
      return Promise.all(Array.from(o).map((r) => new Promise((s, a) => {
        r.toBlob((l) => {
          l ? s(l) : a(new Error("Could not export image"));
        }, e, t);
      })));
    });
  }
}
ko.MAX_CANVAS_WIDTH = 4e3;
class O_ extends Oi {
  constructor() {
    super(...arguments), this.unsubscribe = () => {
    };
  }
  start() {
    this.unsubscribe = this.on("tick", () => {
      requestAnimationFrame(() => {
        this.emit("tick");
      });
    }), this.emit("tick");
  }
  stop() {
    this.unsubscribe();
  }
  destroy() {
    this.unsubscribe();
  }
}
class Lr extends Oi {
  constructor(e = new AudioContext()) {
    super(), this.bufferNode = null, this.playStartTime = 0, this.playedDuration = 0, this._muted = !1, this._playbackRate = 1, this._duration = void 0, this.buffer = null, this.currentSrc = "", this.paused = !0, this.crossOrigin = null, this.seeking = !1, this.autoplay = !1, this.addEventListener = this.on, this.removeEventListener = this.un, this.audioContext = e, this.gainNode = this.audioContext.createGain(), this.gainNode.connect(this.audioContext.destination);
  }
  load() {
    return Se(this, void 0, void 0, function* () {
    });
  }
  get src() {
    return this.currentSrc;
  }
  set src(e) {
    if (this.currentSrc = e, this._duration = void 0, !e)
      return this.buffer = null, void this.emit("emptied");
    fetch(e).then((t) => {
      if (t.status >= 400)
        throw new Error(`Failed to fetch ${e}: ${t.status} (${t.statusText})`);
      return t.arrayBuffer();
    }).then((t) => this.currentSrc !== e ? null : this.audioContext.decodeAudioData(t)).then((t) => {
      this.currentSrc === e && (this.buffer = t, this.emit("loadedmetadata"), this.emit("canplay"), this.autoplay && this.play());
    });
  }
  _play() {
    var e;
    if (!this.paused)
      return;
    this.paused = !1, (e = this.bufferNode) === null || e === void 0 || e.disconnect(), this.bufferNode = this.audioContext.createBufferSource(), this.buffer && (this.bufferNode.buffer = this.buffer), this.bufferNode.playbackRate.value = this._playbackRate, this.bufferNode.connect(this.gainNode);
    let t = this.playedDuration * this._playbackRate;
    t >= this.duration && (t = 0, this.playedDuration = 0), this.bufferNode.start(this.audioContext.currentTime, t), this.playStartTime = this.audioContext.currentTime, this.bufferNode.onended = () => {
      this.currentTime >= this.duration && (this.pause(), this.emit("ended"));
    };
  }
  _pause() {
    var e;
    this.paused = !0, (e = this.bufferNode) === null || e === void 0 || e.stop(), this.playedDuration += this.audioContext.currentTime - this.playStartTime;
  }
  play() {
    return Se(this, void 0, void 0, function* () {
      this.paused && (this._play(), this.emit("play"));
    });
  }
  pause() {
    this.paused || (this._pause(), this.emit("pause"));
  }
  stopAt(e) {
    var t, n;
    const o = e - this.currentTime;
    (t = this.bufferNode) === null || t === void 0 || t.stop(this.audioContext.currentTime + o), (n = this.bufferNode) === null || n === void 0 || n.addEventListener("ended", () => {
      this.bufferNode = null, this.pause();
    }, { once: !0 });
  }
  setSinkId(e) {
    return Se(this, void 0, void 0, function* () {
      return this.audioContext.setSinkId(e);
    });
  }
  get playbackRate() {
    return this._playbackRate;
  }
  set playbackRate(e) {
    this._playbackRate = e, this.bufferNode && (this.bufferNode.playbackRate.value = e);
  }
  get currentTime() {
    return (this.paused ? this.playedDuration : this.playedDuration + (this.audioContext.currentTime - this.playStartTime)) * this._playbackRate;
  }
  set currentTime(e) {
    const t = !this.paused;
    t && this._pause(), this.playedDuration = e / this._playbackRate, t && this._play(), this.emit("seeking"), this.emit("timeupdate");
  }
  get duration() {
    var e, t;
    return (e = this._duration) !== null && e !== void 0 ? e : ((t = this.buffer) === null || t === void 0 ? void 0 : t.duration) || 0;
  }
  set duration(e) {
    this._duration = e;
  }
  get volume() {
    return this.gainNode.gain.value;
  }
  set volume(e) {
    this.gainNode.gain.value = e, this.emit("volumechange");
  }
  get muted() {
    return this._muted;
  }
  set muted(e) {
    this._muted !== e && (this._muted = e, this._muted ? this.gainNode.disconnect() : this.gainNode.connect(this.audioContext.destination));
  }
  canPlayType(e) {
    return /^(audio|video)\//.test(e);
  }
  getGainNode() {
    return this.gainNode;
  }
  getChannelData() {
    const e = [];
    if (!this.buffer)
      return e;
    const t = this.buffer.numberOfChannels;
    for (let n = 0; n < t; n++)
      e.push(this.buffer.getChannelData(n));
    return e;
  }
}
const q_ = { waveColor: "#999", progressColor: "#555", cursorWidth: 1, minPxPerSec: 0, fillParent: !0, interact: !0, dragToSeek: !1, autoScroll: !0, autoCenter: !0, sampleRate: 8e3 };
class nn extends M_ {
  static create(e) {
    return new nn(e);
  }
  constructor(e) {
    const t = e.media || (e.backend === "WebAudio" ? new Lr() : void 0);
    super({ media: t, mediaControls: e.mediaControls, autoplay: e.autoplay, playbackRate: e.audioRate }), this.plugins = [], this.decodedData = null, this.subscriptions = [], this.mediaSubscriptions = [], this.abortController = null, this.options = Object.assign({}, q_, e), this.timer = new O_();
    const n = t ? void 0 : this.getMediaElement();
    this.renderer = new ko(this.options, n), this.initPlayerEvents(), this.initRendererEvents(), this.initTimerEvents(), this.initPlugins();
    const o = this.options.url || this.getSrc() || "";
    Promise.resolve().then(() => {
      this.emit("init");
      const { peaks: r, duration: s } = this.options;
      (o || r && s) && this.load(o, r, s).catch(() => null);
    });
  }
  updateProgress(e = this.getCurrentTime()) {
    return this.renderer.renderProgress(e / this.getDuration(), this.isPlaying()), e;
  }
  initTimerEvents() {
    this.subscriptions.push(this.timer.on("tick", () => {
      if (!this.isSeeking()) {
        const e = this.updateProgress();
        this.emit("timeupdate", e), this.emit("audioprocess", e);
      }
    }));
  }
  initPlayerEvents() {
    this.isPlaying() && (this.emit("play"), this.timer.start()), this.mediaSubscriptions.push(this.onMediaEvent("timeupdate", () => {
      const e = this.updateProgress();
      this.emit("timeupdate", e);
    }), this.onMediaEvent("play", () => {
      this.emit("play"), this.timer.start();
    }), this.onMediaEvent("pause", () => {
      this.emit("pause"), this.timer.stop();
    }), this.onMediaEvent("emptied", () => {
      this.timer.stop();
    }), this.onMediaEvent("ended", () => {
      this.emit("finish");
    }), this.onMediaEvent("seeking", () => {
      this.emit("seeking", this.getCurrentTime());
    }), this.onMediaEvent("error", (e) => {
      this.emit("error", e.error);
    }));
  }
  initRendererEvents() {
    this.subscriptions.push(this.renderer.on("click", (e, t) => {
      this.options.interact && (this.seekTo(e), this.emit("interaction", e * this.getDuration()), this.emit("click", e, t));
    }), this.renderer.on("dblclick", (e, t) => {
      this.emit("dblclick", e, t);
    }), this.renderer.on("scroll", (e, t) => {
      const n = this.getDuration();
      this.emit("scroll", e * n, t * n);
    }), this.renderer.on("render", () => {
      this.emit("redraw");
    }), this.renderer.on("rendered", () => {
      this.emit("redrawcomplete");
    }), this.renderer.on("dragstart", (e) => {
      this.emit("dragstart", e);
    }), this.renderer.on("dragend", (e) => {
      this.emit("dragend", e);
    }));
    {
      let e;
      this.subscriptions.push(this.renderer.on("drag", (t) => {
        if (!this.options.interact)
          return;
        let n;
        this.renderer.renderProgress(t), clearTimeout(e), this.isPlaying() ? n = 0 : this.options.dragToSeek === !0 ? n = 200 : typeof this.options.dragToSeek == "object" && this.options.dragToSeek !== void 0 && (n = this.options.dragToSeek.debounceTime), e = setTimeout(() => {
          this.seekTo(t);
        }, n), this.emit("interaction", t * this.getDuration()), this.emit("drag", t);
      }));
    }
  }
  initPlugins() {
    var e;
    !((e = this.options.plugins) === null || e === void 0) && e.length && this.options.plugins.forEach((t) => {
      this.registerPlugin(t);
    });
  }
  unsubscribePlayerEvents() {
    this.mediaSubscriptions.forEach((e) => e()), this.mediaSubscriptions = [];
  }
  setOptions(e) {
    this.options = Object.assign({}, this.options, e), this.renderer.setOptions(this.options), e.audioRate && this.setPlaybackRate(e.audioRate), e.mediaControls != null && (this.getMediaElement().controls = e.mediaControls);
  }
  registerPlugin(e) {
    return e._init(this), this.plugins.push(e), this.subscriptions.push(e.once("destroy", () => {
      this.plugins = this.plugins.filter((t) => t !== e);
    })), e;
  }
  getWrapper() {
    return this.renderer.getWrapper();
  }
  getScroll() {
    return this.renderer.getScroll();
  }
  setScroll(e) {
    return this.renderer.setScroll(e);
  }
  setScrollTime(e) {
    const t = e / this.getDuration();
    this.renderer.setScrollPercentage(t);
  }
  getActivePlugins() {
    return this.plugins;
  }
  loadAudio(e, t, n, o) {
    return Se(this, void 0, void 0, function* () {
      var r;
      if (this.emit("load", e), !this.options.media && this.isPlaying() && this.pause(), this.decodedData = null, !t && !n) {
        const a = this.options.fetchParams || {};
        window.AbortController && !a.signal && (this.abortController = new AbortController(), a.signal = (r = this.abortController) === null || r === void 0 ? void 0 : r.signal);
        const l = (u) => this.emit("loading", u);
        t = yield R_.fetchBlob(e, l, a);
      }
      this.setSrc(e, t);
      const s = o || this.getDuration() || (yield new Promise((a) => {
        this.onMediaEvent("loadedmetadata", () => a(this.getDuration()), { once: !0 });
      }));
      if (!e && !t) {
        const a = this.getMediaElement();
        a instanceof Lr && (a.duration = s);
      }
      if (n)
        this.decodedData = Er.createBuffer(n, s || 0);
      else if (t) {
        const a = yield t.arrayBuffer();
        this.decodedData = yield Er.decode(a, this.options.sampleRate);
      }
      this.decodedData && (this.emit("decode", this.getDuration()), this.renderer.render(this.decodedData)), this.emit("ready", this.getDuration());
    });
  }
  load(e, t, n) {
    return Se(this, void 0, void 0, function* () {
      try {
        return yield this.loadAudio(e, void 0, t, n);
      } catch (o) {
        throw this.emit("error", o), o;
      }
    });
  }
  loadBlob(e, t, n) {
    return Se(this, void 0, void 0, function* () {
      try {
        return yield this.loadAudio("blob", e, t, n);
      } catch (o) {
        throw this.emit("error", o), o;
      }
    });
  }
  zoom(e) {
    if (!this.decodedData)
      throw new Error("No audio loaded");
    this.renderer.zoom(e), this.emit("zoom", e);
  }
  getDecodedData() {
    return this.decodedData;
  }
  exportPeaks({ channels: e = 2, maxLength: t = 8e3, precision: n = 1e4 } = {}) {
    if (!this.decodedData)
      throw new Error("The audio has not been decoded yet");
    const o = Math.min(e, this.decodedData.numberOfChannels), r = [];
    for (let s = 0; s < o; s++) {
      const a = this.decodedData.getChannelData(s), l = [], u = a.length / t;
      for (let c = 0; c < t; c++) {
        const d = a.slice(Math.floor(c * u), Math.ceil((c + 1) * u));
        let _ = 0;
        for (let f = 0; f < d.length; f++) {
          const h = d[f];
          Math.abs(h) > Math.abs(_) && (_ = h);
        }
        l.push(Math.round(_ * n) / n);
      }
      r.push(l);
    }
    return r;
  }
  getDuration() {
    let e = super.getDuration() || 0;
    return e !== 0 && e !== 1 / 0 || !this.decodedData || (e = this.decodedData.duration), e;
  }
  toggleInteraction(e) {
    this.options.interact = e;
  }
  setTime(e) {
    super.setTime(e), this.updateProgress(e), this.emit("timeupdate", e);
  }
  seekTo(e) {
    const t = this.getDuration() * e;
    this.setTime(t);
  }
  playPause() {
    return Se(this, void 0, void 0, function* () {
      return this.isPlaying() ? this.pause() : this.play();
    });
  }
  stop() {
    this.pause(), this.setTime(0);
  }
  skip(e) {
    this.setTime(this.getCurrentTime() + e);
  }
  empty() {
    this.load("", [[0]], 1e-3);
  }
  setMediaElement(e) {
    this.unsubscribePlayerEvents(), super.setMediaElement(e), this.initPlayerEvents();
  }
  exportImage() {
    return Se(this, arguments, void 0, function* (e = "image/png", t = 1, n = "dataURL") {
      return this.renderer.exportImage(e, t, n);
    });
  }
  destroy() {
    var e;
    this.emit("destroy"), (e = this.abortController) === null || e === void 0 || e.abort(), this.plugins.forEach((t) => t.destroy()), this.subscriptions.forEach((t) => t()), this.unsubscribePlayerEvents(), this.timer.destroy(), this.renderer.destroy(), super.destroy();
  }
}
nn.BasePlugin = class extends Oi {
  constructor(i) {
    super(), this.subscriptions = [], this.options = i;
  }
  onInit() {
  }
  _init(i) {
    this.wavesurfer = i, this.onInit();
  }
  destroy() {
    this.emit("destroy"), this.subscriptions.forEach((i) => i());
  }
}, nn.dom = L_;
let Sa = class {
  constructor() {
    this.listeners = {};
  }
  on(e, t, n) {
    if (this.listeners[e] || (this.listeners[e] = /* @__PURE__ */ new Set()), this.listeners[e].add(t), n == null ? void 0 : n.once) {
      const o = () => {
        this.un(e, o), this.un(e, t);
      };
      return this.on(e, o), o;
    }
    return () => this.un(e, t);
  }
  un(e, t) {
    var n;
    (n = this.listeners[e]) === null || n === void 0 || n.delete(t);
  }
  once(e, t) {
    return this.on(e, t, { once: !0 });
  }
  unAll() {
    this.listeners = {};
  }
  emit(e, ...t) {
    this.listeners[e] && this.listeners[e].forEach((n) => n(...t));
  }
}, A_ = class extends Sa {
  constructor(e) {
    super(), this.subscriptions = [], this.options = e;
  }
  onInit() {
  }
  _init(e) {
    this.wavesurfer = e, this.onInit();
  }
  destroy() {
    this.emit("destroy"), this.subscriptions.forEach((e) => e());
  }
};
function oo(i, e, t, n, o = 3, r = 0, s = 100) {
  if (!i)
    return () => {
    };
  const a = matchMedia("(pointer: coarse)").matches;
  let l = () => {
  };
  const u = (c) => {
    if (c.button !== r)
      return;
    c.preventDefault(), c.stopPropagation();
    let d = c.clientX, _ = c.clientY, f = !1;
    const h = Date.now(), p = (S) => {
      if (S.preventDefault(), S.stopPropagation(), a && Date.now() - h < s)
        return;
      const v = S.clientX, b = S.clientY, L = v - d, E = b - _;
      if (f || Math.abs(L) > o || Math.abs(E) > o) {
        const D = i.getBoundingClientRect(), { left: P, top: F } = D;
        f || (t == null || t(d - P, _ - F), f = !0), e(L, E, v - P, b - F), d = v, _ = b;
      }
    }, g = (S) => {
      if (f) {
        const v = S.clientX, b = S.clientY, L = i.getBoundingClientRect(), { left: E, top: D } = L;
        n == null || n(v - E, b - D);
      }
      l();
    }, m = (S) => {
      S.relatedTarget && S.relatedTarget !== document.documentElement || g(S);
    }, k = (S) => {
      f && (S.stopPropagation(), S.preventDefault());
    }, w = (S) => {
      f && S.preventDefault();
    };
    document.addEventListener("pointermove", p), document.addEventListener("pointerup", g), document.addEventListener("pointerout", m), document.addEventListener("pointercancel", m), document.addEventListener("touchmove", w, { passive: !1 }), document.addEventListener("click", k, { capture: !0 }), l = () => {
      document.removeEventListener("pointermove", p), document.removeEventListener("pointerup", g), document.removeEventListener("pointerout", m), document.removeEventListener("pointercancel", m), document.removeEventListener("touchmove", w), setTimeout(() => {
        document.removeEventListener("click", k, { capture: !0 });
      }, 10);
    };
  };
  return i.addEventListener("pointerdown", u), () => {
    l(), i.removeEventListener("pointerdown", u);
  };
}
function Ea(i, e) {
  const t = e.xmlns ? document.createElementNS(e.xmlns, i) : document.createElement(i);
  for (const [n, o] of Object.entries(e))
    if (n === "children")
      for (const [r, s] of Object.entries(e))
        typeof s == "string" ? t.appendChild(document.createTextNode(s)) : t.appendChild(Ea(r, s));
    else
      n === "style" ? Object.assign(t.style, o) : n === "textContent" ? t.textContent = o : t.setAttribute(n, o.toString());
  return t;
}
function ki(i, e, t) {
  const n = Ea(i, e || {});
  return t == null || t.appendChild(n), n;
}
let Rr = class extends Sa {
  constructor(e, t, n = 0) {
    var o, r, s, a, l, u, c, d;
    super(), this.totalDuration = t, this.numberOfChannels = n, this.minLength = 0, this.maxLength = 1 / 0, this.contentEditable = !1, this.subscriptions = [], this.subscriptions = [], this.id = e.id || `region-${Math.random().toString(32).slice(2)}`, this.start = this.clampPosition(e.start), this.end = this.clampPosition((o = e.end) !== null && o !== void 0 ? o : e.start), this.drag = (r = e.drag) === null || r === void 0 || r, this.resize = (s = e.resize) === null || s === void 0 || s, this.color = (a = e.color) !== null && a !== void 0 ? a : "rgba(0, 0, 0, 0.1)", this.minLength = (l = e.minLength) !== null && l !== void 0 ? l : this.minLength, this.maxLength = (u = e.maxLength) !== null && u !== void 0 ? u : this.maxLength, this.channelIdx = (c = e.channelIdx) !== null && c !== void 0 ? c : -1, this.contentEditable = (d = e.contentEditable) !== null && d !== void 0 ? d : this.contentEditable, this.element = this.initElement(), this.setContent(e.content), this.setPart(), this.renderPosition(), this.initMouseEvents();
  }
  clampPosition(e) {
    return Math.max(0, Math.min(this.totalDuration, e));
  }
  setPart() {
    const e = this.start === this.end;
    this.element.setAttribute("part", `${e ? "marker" : "region"} ${this.id}`);
  }
  addResizeHandles(e) {
    const t = { position: "absolute", zIndex: "2", width: "6px", height: "100%", top: "0", cursor: "ew-resize", wordBreak: "keep-all" }, n = ki("div", { part: "region-handle region-handle-left", style: Object.assign(Object.assign({}, t), { left: "0", borderLeft: "2px solid rgba(0, 0, 0, 0.5)", borderRadius: "2px 0 0 2px" }) }, e), o = ki("div", { part: "region-handle region-handle-right", style: Object.assign(Object.assign({}, t), { right: "0", borderRight: "2px solid rgba(0, 0, 0, 0.5)", borderRadius: "0 2px 2px 0" }) }, e);
    this.subscriptions.push(oo(n, (r) => this.onResize(r, "start"), () => null, () => this.onEndResizing(), 1), oo(o, (r) => this.onResize(r, "end"), () => null, () => this.onEndResizing(), 1));
  }
  removeResizeHandles(e) {
    const t = e.querySelector('[part*="region-handle-left"]'), n = e.querySelector('[part*="region-handle-right"]');
    t && e.removeChild(t), n && e.removeChild(n);
  }
  initElement() {
    const e = this.start === this.end;
    let t = 0, n = 100;
    this.channelIdx >= 0 && this.channelIdx < this.numberOfChannels && (n = 100 / this.numberOfChannels, t = n * this.channelIdx);
    const o = ki("div", { style: { position: "absolute", top: `${t}%`, height: `${n}%`, backgroundColor: e ? "none" : this.color, borderLeft: e ? "2px solid " + this.color : "none", borderRadius: "2px", boxSizing: "border-box", transition: "background-color 0.2s ease", cursor: this.drag ? "grab" : "default", pointerEvents: "all" } });
    return !e && this.resize && this.addResizeHandles(o), o;
  }
  renderPosition() {
    const e = this.start / this.totalDuration, t = (this.totalDuration - this.end) / this.totalDuration;
    this.element.style.left = 100 * e + "%", this.element.style.right = 100 * t + "%";
  }
  toggleCursor(e) {
    var t;
    this.drag && (!((t = this.element) === null || t === void 0) && t.style) && (this.element.style.cursor = e ? "grabbing" : "grab");
  }
  initMouseEvents() {
    const { element: e } = this;
    e && (e.addEventListener("click", (t) => this.emit("click", t)), e.addEventListener("mouseenter", (t) => this.emit("over", t)), e.addEventListener("mouseleave", (t) => this.emit("leave", t)), e.addEventListener("dblclick", (t) => this.emit("dblclick", t)), e.addEventListener("pointerdown", () => this.toggleCursor(!0)), e.addEventListener("pointerup", () => this.toggleCursor(!1)), this.subscriptions.push(oo(e, (t) => this.onMove(t), () => this.toggleCursor(!0), () => {
      this.toggleCursor(!1), this.drag && this.emit("update-end");
    })), this.contentEditable && this.content && (this.content.addEventListener("click", (t) => this.onContentClick(t)), this.content.addEventListener("blur", () => this.onContentBlur())));
  }
  _onUpdate(e, t) {
    if (!this.element.parentElement)
      return;
    const { width: n } = this.element.parentElement.getBoundingClientRect(), o = e / n * this.totalDuration, r = t && t !== "start" ? this.start : this.start + o, s = t && t !== "end" ? this.end : this.end + o, a = s - r;
    r >= 0 && s <= this.totalDuration && r <= s && a >= this.minLength && a <= this.maxLength && (this.start = r, this.end = s, this.renderPosition(), this.emit("update", t));
  }
  onMove(e) {
    this.drag && this._onUpdate(e);
  }
  onResize(e, t) {
    this.resize && this._onUpdate(e, t);
  }
  onEndResizing() {
    this.resize && this.emit("update-end");
  }
  onContentClick(e) {
    e.stopPropagation(), e.target.focus(), this.emit("click", e);
  }
  onContentBlur() {
    this.emit("update-end");
  }
  _setTotalDuration(e) {
    this.totalDuration = e, this.renderPosition();
  }
  play() {
    this.emit("play");
  }
  setContent(e) {
    var t;
    if ((t = this.content) === null || t === void 0 || t.remove(), e) {
      if (typeof e == "string") {
        const n = this.start === this.end;
        this.content = ki("div", { style: { padding: `0.2em ${n ? 0.2 : 0.4}em`, display: "inline-block" }, textContent: e });
      } else
        this.content = e;
      this.contentEditable && (this.content.contentEditable = "true"), this.content.setAttribute("part", "region-content"), this.element.appendChild(this.content);
    } else
      this.content = void 0;
  }
  setOptions(e) {
    var t, n;
    if (e.color && (this.color = e.color, this.element.style.backgroundColor = this.color), e.drag !== void 0 && (this.drag = e.drag, this.element.style.cursor = this.drag ? "grab" : "default"), e.start !== void 0 || e.end !== void 0) {
      const o = this.start === this.end;
      this.start = this.clampPosition((t = e.start) !== null && t !== void 0 ? t : this.start), this.end = this.clampPosition((n = e.end) !== null && n !== void 0 ? n : o ? this.start : this.end), this.renderPosition(), this.setPart();
    }
    if (e.content && this.setContent(e.content), e.id && (this.id = e.id, this.setPart()), e.resize !== void 0 && e.resize !== this.resize) {
      const o = this.start === this.end;
      this.resize = e.resize, this.resize && !o ? this.addResizeHandles(this.element) : this.removeResizeHandles(this.element);
    }
  }
  remove() {
    this.emit("remove"), this.subscriptions.forEach((e) => e()), this.element.remove(), this.element = null;
  }
}, z_ = class Da extends A_ {
  constructor(e) {
    super(e), this.regions = [], this.regionsContainer = this.initRegionsContainer();
  }
  static create(e) {
    return new Da(e);
  }
  onInit() {
    if (!this.wavesurfer)
      throw Error("WaveSurfer is not initialized");
    this.wavesurfer.getWrapper().appendChild(this.regionsContainer);
    let e = [];
    this.subscriptions.push(this.wavesurfer.on("timeupdate", (t) => {
      const n = this.regions.filter((o) => o.start <= t && (o.end === o.start ? o.start + 0.05 : o.end) >= t);
      n.forEach((o) => {
        e.includes(o) || this.emit("region-in", o);
      }), e.forEach((o) => {
        n.includes(o) || this.emit("region-out", o);
      }), e = n;
    }));
  }
  initRegionsContainer() {
    return ki("div", { style: { position: "absolute", top: "0", left: "0", width: "100%", height: "100%", zIndex: "3", pointerEvents: "none" } });
  }
  getRegions() {
    return this.regions;
  }
  avoidOverlapping(e) {
    e.content && setTimeout(() => {
      const t = e.content, n = t.getBoundingClientRect(), o = this.regions.map((r) => {
        if (r === e || !r.content)
          return 0;
        const s = r.content.getBoundingClientRect();
        return n.left < s.left + s.width && s.left < n.left + n.width ? s.height : 0;
      }).reduce((r, s) => r + s, 0);
      t.style.marginTop = `${o}px`;
    }, 10);
  }
  adjustScroll(e) {
    var t, n;
    const o = (n = (t = this.wavesurfer) === null || t === void 0 ? void 0 : t.getWrapper()) === null || n === void 0 ? void 0 : n.parentElement;
    if (!o)
      return;
    const { clientWidth: r, scrollWidth: s } = o;
    if (s <= r)
      return;
    const a = o.getBoundingClientRect(), l = e.element.getBoundingClientRect(), u = l.left - a.left, c = l.right - a.left;
    u < 0 ? o.scrollLeft += u : c > r && (o.scrollLeft += c - r);
  }
  saveRegion(e) {
    this.regionsContainer.appendChild(e.element), this.avoidOverlapping(e), this.regions.push(e);
    const t = [e.on("update", (n) => {
      n || this.adjustScroll(e);
    }), e.on("update-end", () => {
      this.avoidOverlapping(e), this.emit("region-updated", e);
    }), e.on("play", () => {
      var n, o;
      (n = this.wavesurfer) === null || n === void 0 || n.play(), (o = this.wavesurfer) === null || o === void 0 || o.setTime(e.start);
    }), e.on("click", (n) => {
      this.emit("region-clicked", e, n);
    }), e.on("dblclick", (n) => {
      this.emit("region-double-clicked", e, n);
    }), e.once("remove", () => {
      t.forEach((n) => n()), this.regions = this.regions.filter((n) => n !== e), this.emit("region-removed", e);
    })];
    this.subscriptions.push(...t), this.emit("region-created", e);
  }
  addRegion(e) {
    var t, n;
    if (!this.wavesurfer)
      throw Error("WaveSurfer is not initialized");
    const o = this.wavesurfer.getDuration(), r = (n = (t = this.wavesurfer) === null || t === void 0 ? void 0 : t.getDecodedData()) === null || n === void 0 ? void 0 : n.numberOfChannels, s = new Rr(e, o, r);
    return o ? this.saveRegion(s) : this.subscriptions.push(this.wavesurfer.once("ready", (a) => {
      s._setTotalDuration(a), this.saveRegion(s);
    })), s;
  }
  enableDragSelection(e, t = 3) {
    var n;
    const o = (n = this.wavesurfer) === null || n === void 0 ? void 0 : n.getWrapper();
    if (!(o && o instanceof HTMLElement))
      return () => {
      };
    let r = null, s = 0;
    return oo(o, (a, l, u) => {
      r && r._onUpdate(a, u > s ? "end" : "start");
    }, (a) => {
      var l, u;
      if (s = a, !this.wavesurfer)
        return;
      const c = this.wavesurfer.getDuration(), d = (u = (l = this.wavesurfer) === null || l === void 0 ? void 0 : l.getDecodedData()) === null || u === void 0 ? void 0 : u.numberOfChannels, { width: _ } = this.wavesurfer.getWrapper().getBoundingClientRect(), f = a / _ * c, h = (a + 5) / _ * c;
      r = new Rr(Object.assign(Object.assign({}, e), { start: f, end: h }), c, d), this.regionsContainer.appendChild(r.element);
    }, () => {
      r && (this.saveRegion(r), r = null);
    }, t);
  }
  clearRegions() {
    this.regions.forEach((e) => e.remove());
  }
  destroy() {
    this.clearRegions(), super.destroy(), this.regionsContainer.remove();
  }
};
const {
  SvelteComponent: j_,
  append: P_,
  attr: Vt,
  detach: T_,
  init: N_,
  insert: B_,
  noop: ls,
  safe_not_equal: W_,
  svg_element: Mr
} = window.__gradio__svelte__internal;
function I_(i) {
  let e, t;
  return {
    c() {
      e = Mr("svg"), t = Mr("path"), Vt(t, "d", "m17.545 15.467-3.779-3.779a6.15 6.15 0 0 0 .898-3.21c0-3.417-2.961-6.377-6.378-6.377A6.185 6.185 0 0 0 2.1 8.287c0 3.416 2.961 6.377 6.377 6.377a6.15 6.15 0 0 0 3.115-.844l3.799 3.801a.953.953 0 0 0 1.346 0l.943-.943c.371-.371.236-.84-.135-1.211zM4.004 8.287a4.282 4.282 0 0 1 4.282-4.283c2.366 0 4.474 2.107 4.474 4.474a4.284 4.284 0 0 1-4.283 4.283c-2.366-.001-4.473-2.109-4.473-4.474z"), Vt(e, "version", "1.0"), Vt(e, "xmlns", "http://www.w3.org/2000/svg"), Vt(e, "viewBox", "0 0 20 20"), Vt(e, "id", "magnifier"), Vt(e, "width", "100%"), Vt(e, "height", "100%"), Vt(e, "color", "currentColor");
    },
    m(n, o) {
      B_(n, e, o), P_(e, t);
    },
    p: ls,
    i: ls,
    o: ls,
    d(n) {
      n && T_(e);
    }
  };
}
class U_ extends j_ {
  constructor(e) {
    super(), N_(this, e, null, I_, W_, {});
  }
}
function F_(i) {
  const e = i.numberOfChannels, t = i.length * e * 2 + 44, n = new ArrayBuffer(t), o = new DataView(n);
  let r = 0;
  const s = function(a, l, u) {
    for (let c = 0; c < u.length; c++)
      a.setUint8(l + c, u.charCodeAt(c));
  };
  s(o, r, "RIFF"), r += 4, o.setUint32(r, t - 8, !0), r += 4, s(o, r, "WAVE"), r += 4, s(o, r, "fmt "), r += 4, o.setUint32(r, 16, !0), r += 4, o.setUint16(r, 1, !0), r += 2, o.setUint16(r, e, !0), r += 2, o.setUint32(r, i.sampleRate, !0), r += 4, o.setUint32(r, i.sampleRate * 2 * e, !0), r += 4, o.setUint16(r, e * 2, !0), r += 2, o.setUint16(r, 16, !0), r += 2, s(o, r, "data"), r += 4, o.setUint32(r, i.length * e * 2, !0), r += 4;
  for (let a = 0; a < i.length; a++)
    for (let l = 0; l < e; l++) {
      const u = Math.max(
        -1,
        Math.min(1, i.getChannelData(l)[a])
      );
      o.setInt16(r, u * 32767, !0), r += 2;
    }
  return new Uint8Array(n);
}
const V_ = async (i, e, t) => {
  const n = new AudioContext(), o = i.numberOfChannels, r = i.sampleRate;
  let s = i.length, a = 0;
  const l = n.createBuffer(
    o,
    s,
    r
  );
  for (let u = 0; u < o; u++) {
    const c = i.getChannelData(u), d = l.getChannelData(u);
    for (let _ = 0; _ < s; _++)
      d[_] = c[a + _];
  }
  return F_(l);
}, Or = (i, e) => {
  i && i.skip(e);
}, Vn = (i, e) => (e || (e = 5), i / 100 * e || 5), {
  SvelteComponent: H_,
  check_outros: Z_,
  create_component: Zs,
  destroy_component: Gs,
  detach: G_,
  empty: J_,
  group_outros: K_,
  init: X_,
  insert: Y_,
  mount_component: Js,
  safe_not_equal: Q_,
  transition_in: Si,
  transition_out: Ei
} = window.__gradio__svelte__internal;
function $_(i) {
  let e, t;
  return e = new Uf({}), {
    c() {
      Zs(e.$$.fragment);
    },
    m(n, o) {
      Js(e, n, o), t = !0;
    },
    i(n) {
      t || (Si(e.$$.fragment, n), t = !0);
    },
    o(n) {
      Ei(e.$$.fragment, n), t = !1;
    },
    d(n) {
      Gs(e, n);
    }
  };
}
function x_(i) {
  let e, t;
  return e = new zf({}), {
    c() {
      Zs(e.$$.fragment);
    },
    m(n, o) {
      Js(e, n, o), t = !0;
    },
    i(n) {
      t || (Si(e.$$.fragment, n), t = !0);
    },
    o(n) {
      Ei(e.$$.fragment, n), t = !1;
    },
    d(n) {
      Gs(e, n);
    }
  };
}
function eh(i) {
  let e, t;
  return e = new Xf({}), {
    c() {
      Zs(e.$$.fragment);
    },
    m(n, o) {
      Js(e, n, o), t = !0;
    },
    i(n) {
      t || (Si(e.$$.fragment, n), t = !0);
    },
    o(n) {
      Ei(e.$$.fragment, n), t = !1;
    },
    d(n) {
      Gs(e, n);
    }
  };
}
function th(i) {
  let e, t, n, o;
  const r = [eh, x_, $_], s = [];
  function a(l, u) {
    return (
      /*currentVolume*/
      l[0] == 0 ? 0 : (
        /*currentVolume*/
        l[0] < 0.5 ? 1 : (
          /*currentVolume*/
          l[0] >= 0.5 ? 2 : -1
        )
      )
    );
  }
  return ~(e = a(i)) && (t = s[e] = r[e](i)), {
    c() {
      t && t.c(), n = J_();
    },
    m(l, u) {
      ~e && s[e].m(l, u), Y_(l, n, u), o = !0;
    },
    p(l, [u]) {
      let c = e;
      e = a(l), e !== c && (t && (K_(), Ei(s[c], 1, 1, () => {
        s[c] = null;
      }), Z_()), ~e ? (t = s[e], t || (t = s[e] = r[e](l), t.c()), Si(t, 1), t.m(n.parentNode, n)) : t = null);
    },
    i(l) {
      o || (Si(t), o = !0);
    },
    o(l) {
      Ei(t), o = !1;
    },
    d(l) {
      l && G_(n), ~e && s[e].d(l);
    }
  };
}
function nh(i, e, t) {
  let { currentVolume: n } = e;
  return i.$$set = (o) => {
    "currentVolume" in o && t(0, n = o.currentVolume);
  }, [n];
}
class ih extends H_ {
  constructor(e) {
    super(), X_(this, e, nh, th, Q_, { currentVolume: 0 });
  }
}
const {
  SvelteComponent: oh,
  attr: Nn,
  binding_callbacks: sh,
  detach: rh,
  element: lh,
  init: ah,
  insert: uh,
  listen: qr,
  noop: Ar,
  run_all: ch,
  safe_not_equal: dh
} = window.__gradio__svelte__internal, { onMount: fh } = window.__gradio__svelte__internal;
function _h(i) {
  let e, t, n;
  return {
    c() {
      e = lh("input"), Nn(e, "id", "volume"), Nn(e, "class", "volume-slider svelte-1xy0951"), Nn(e, "type", "range"), Nn(e, "min", "0"), Nn(e, "max", "1"), Nn(e, "step", "0.01"), e.value = /*currentVolume*/
      i[0];
    },
    m(o, r) {
      uh(o, e, r), i[4](e), t || (n = [
        qr(
          e,
          "focusout",
          /*focusout_handler*/
          i[5]
        ),
        qr(
          e,
          "input",
          /*input_handler*/
          i[6]
        )
      ], t = !0);
    },
    p(o, [r]) {
      r & /*currentVolume*/
      1 && (e.value = /*currentVolume*/
      o[0]);
    },
    i: Ar,
    o: Ar,
    d(o) {
      o && rh(e), i[4](null), t = !1, ch(n);
    }
  };
}
function hh(i, e, t) {
  let { currentVolume: n = 1 } = e, { show_volume_slider: o = !1 } = e, { waveform: r } = e, s;
  fh(() => {
    a();
  });
  const a = () => {
    let d = s;
    d && (d.style.background = `linear-gradient(to right, var(--color-accent) ${n * 100}%, var(--neutral-400) ${n * 100}%)`);
  };
  function l(d) {
    sh[d ? "unshift" : "push"](() => {
      s = d, t(3, s);
    });
  }
  const u = () => t(1, o = !1), c = (d) => {
    d.target instanceof HTMLInputElement && (t(0, n = parseFloat(d.target.value)), r.setVolume(n));
  };
  return i.$$set = (d) => {
    "currentVolume" in d && t(0, n = d.currentVolume), "show_volume_slider" in d && t(1, o = d.show_volume_slider), "waveform" in d && t(2, r = d.waveform);
  }, i.$$.update = () => {
    i.$$.dirty & /*currentVolume*/
    1 && a();
  }, [
    n,
    o,
    r,
    s,
    l,
    u,
    c
  ];
}
class mh extends oh {
  constructor(e) {
    super(), ah(this, e, hh, _h, dh, {
      currentVolume: 0,
      show_volume_slider: 1,
      waveform: 2
    });
  }
}
const {
  SvelteComponent: ph,
  attr: Bn,
  binding_callbacks: gh,
  detach: La,
  element: bh,
  empty: vh,
  init: wh,
  insert: Ra,
  listen: Ji,
  noop: zr,
  run_all: yh,
  safe_not_equal: kh,
  set_input_value: jr,
  to_number: Ch
} = window.__gradio__svelte__internal, { onMount: Sh } = window.__gradio__svelte__internal;
function Pr(i) {
  let e, t, n;
  return {
    c() {
      e = bh("input"), Bn(e, "class", "zoom-slider svelte-lb8lre"), Bn(e, "type", "range"), Bn(
        e,
        "min",
        /*zoomMin*/
        i[2]
      ), Bn(
        e,
        "max",
        /*zoomMax*/
        i[3]
      );
    },
    m(o, r) {
      Ra(o, e, r), i[9](e), jr(
        e,
        /*currentZoom*/
        i[0]
      ), t || (n = [
        Ji(
          e,
          "change",
          /*input_change_input_handler*/
          i[10]
        ),
        Ji(
          e,
          "input",
          /*input_change_input_handler*/
          i[10]
        ),
        Ji(
          e,
          "input",
          /*input_handler*/
          i[11]
        ),
        Ji(
          e,
          "focusout",
          /*focusout_handler*/
          i[12]
        )
      ], t = !0);
    },
    p(o, r) {
      r & /*zoomMin*/
      4 && Bn(
        e,
        "min",
        /*zoomMin*/
        o[2]
      ), r & /*zoomMax*/
      8 && Bn(
        e,
        "max",
        /*zoomMax*/
        o[3]
      ), r & /*currentZoom*/
      1 && jr(
        e,
        /*currentZoom*/
        o[0]
      );
    },
    d(o) {
      o && La(e), i[9](null), t = !1, yh(n);
    }
  };
}
function Eh(i) {
  let e, t = (
    /*showZoomSlider*/
    i[1] && Pr(i)
  );
  return {
    c() {
      t && t.c(), e = vh();
    },
    m(n, o) {
      t && t.m(n, o), Ra(n, e, o);
    },
    p(n, [o]) {
      /*showZoomSlider*/
      n[1] ? t ? t.p(n, o) : (t = Pr(n), t.c(), t.m(e.parentNode, e)) : t && (t.d(1), t = null);
    },
    i: zr,
    o: zr,
    d(n) {
      n && La(e), t && t.d(n);
    }
  };
}
function Dh(i, e, t) {
  let { currentZoom: n = 0 } = e, { zoomMin: o = 0 } = e, { zoomMax: r = 500 } = e, { zoomDelta: s = 50 } = e, { showZoomSlider: a = !1 } = e, { waveform: l } = e, { isDialogOpen: u = !1 } = e, c;
  function d() {
    let m = c;
    m && (m.style.background = `linear-gradient(to right, var(--color-accent) ${n / 5}%, var(--neutral-400) ${n / 5}%)`);
  }
  function _(m) {
    t(0, n = m), n < o ? t(0, n = o) : n > r && t(0, n = r), l.zoom(n);
  }
  Sh(() => {
    window.addEventListener("keydown", (m) => {
      if (!u)
        switch (m.key) {
          case "ArrowUp":
            m.preventDefault(), _(n + s);
            break;
          case "ArrowDown":
            m.preventDefault(), _(n - s);
            break;
        }
    });
  });
  function f(m) {
    gh[m ? "unshift" : "push"](() => {
      c = m, t(4, c);
    });
  }
  function h() {
    n = Ch(this.value), t(0, n);
  }
  const p = (m) => _(m.target.value), g = () => t(1, a = !1);
  return i.$$set = (m) => {
    "currentZoom" in m && t(0, n = m.currentZoom), "zoomMin" in m && t(2, o = m.zoomMin), "zoomMax" in m && t(3, r = m.zoomMax), "zoomDelta" in m && t(6, s = m.zoomDelta), "showZoomSlider" in m && t(1, a = m.showZoomSlider), "waveform" in m && t(7, l = m.waveform), "isDialogOpen" in m && t(8, u = m.isDialogOpen);
  }, i.$$.update = () => {
    i.$$.dirty & /*currentZoom*/
    1 && d(), i.$$.dirty & /*waveform, currentZoom*/
    129 && (l == null || l.on("ready", () => {
      l.zoom(n), d();
    }));
  }, [
    n,
    a,
    o,
    r,
    c,
    _,
    s,
    l,
    u,
    f,
    h,
    p,
    g
  ];
}
class Lh extends ph {
  constructor(e) {
    super(), wh(this, e, Dh, Eh, kh, {
      currentZoom: 0,
      zoomMin: 2,
      zoomMax: 3,
      zoomDelta: 6,
      showZoomSlider: 1,
      waveform: 7,
      isDialogOpen: 8
    });
  }
}
const {
  SvelteComponent: Rh,
  add_flush_callback: qs,
  append: Oe,
  attr: ye,
  bind: As,
  binding_callbacks: zs,
  check_outros: Tr,
  create_component: Jt,
  destroy_component: Kt,
  detach: Mh,
  element: wt,
  group_outros: Nr,
  init: Oh,
  insert: qh,
  listen: Wn,
  mount_component: Xt,
  run_all: Ah,
  safe_not_equal: zh,
  set_data: jh,
  space: ln,
  text: Br,
  toggle_class: Wr,
  transition_in: Ke,
  transition_out: tt
} = window.__gradio__svelte__internal, { onMount: Ph } = window.__gradio__svelte__internal;
function Ir(i) {
  let e, t, n, o;
  function r(l) {
    i[12](l);
  }
  function s(l) {
    i[13](l);
  }
  let a = { waveform: (
    /*waveform*/
    i[2]
  ) };
  return (
    /*currentVolume*/
    i[8] !== void 0 && (a.currentVolume = /*currentVolume*/
    i[8]), /*show_volume_slider*/
    i[0] !== void 0 && (a.show_volume_slider = /*show_volume_slider*/
    i[0]), e = new mh({ props: a }), zs.push(() => As(e, "currentVolume", r)), zs.push(() => As(e, "show_volume_slider", s)), {
      c() {
        Jt(e.$$.fragment);
      },
      m(l, u) {
        Xt(e, l, u), o = !0;
      },
      p(l, u) {
        const c = {};
        u & /*waveform*/
        4 && (c.waveform = /*waveform*/
        l[2]), !t && u & /*currentVolume*/
        256 && (t = !0, c.currentVolume = /*currentVolume*/
        l[8], qs(() => t = !1)), !n && u & /*show_volume_slider*/
        1 && (n = !0, c.show_volume_slider = /*show_volume_slider*/
        l[0], qs(() => n = !1)), e.$set(c);
      },
      i(l) {
        o || (Ke(e.$$.fragment, l), o = !0);
      },
      o(l) {
        tt(e.$$.fragment, l), o = !1;
      },
      d(l) {
        Kt(e, l);
      }
    }
  );
}
function Th(i) {
  let e, t;
  return e = new rf({}), {
    c() {
      Jt(e.$$.fragment);
    },
    m(n, o) {
      Xt(e, n, o), t = !0;
    },
    i(n) {
      t || (Ke(e.$$.fragment, n), t = !0);
    },
    o(n) {
      tt(e.$$.fragment, n), t = !1;
    },
    d(n) {
      Kt(e, n);
    }
  };
}
function Nh(i) {
  let e, t;
  return e = new ga({}), {
    c() {
      Jt(e.$$.fragment);
    },
    m(n, o) {
      Xt(e, n, o), t = !0;
    },
    i(n) {
      t || (Ke(e.$$.fragment, n), t = !0);
    },
    o(n) {
      tt(e.$$.fragment, n), t = !1;
    },
    d(n) {
      Kt(e, n);
    }
  };
}
function Bh(i) {
  let e, t, n, o, r, s, a, l, u, c, d, _, f, h, p, g, m, k, w, S, v, b, L, E, D, P, F, q, N, Y, J, O, T, V;
  o = new ih({
    props: { currentVolume: (
      /*currentVolume*/
      i[8]
    ) }
  });
  let K = (
    /*show_volume_slider*/
    i[0] && Ir(i)
  );
  h = new U_({});
  function I(R) {
    i[16](R);
  }
  let $ = { waveform: (
    /*waveform*/
    i[2]
  ) };
  /*showZoomSlider*/
  i[1] !== void 0 && ($.showZoomSlider = /*showZoomSlider*/
  i[1]), g = new Lh({ props: $ }), zs.push(() => As(g, "showZoomSlider", I)), v = new Xc({});
  const te = [Nh, Th], M = [];
  function C(R, j) {
    return (
      /*playing*/
      R[5] ? 0 : 1
    );
  }
  return D = C(i), P = M[D] = te[D](i), Y = new Ed({}), {
    c() {
      e = wt("div"), t = wt("div"), n = wt("button"), Jt(o.$$.fragment), r = ln(), K && K.c(), s = ln(), a = wt("button"), l = wt("span"), u = Br(
        /*playbackSpeed*/
        i[7]
      ), c = Br("x"), _ = ln(), f = wt("button"), Jt(h.$$.fragment), p = ln(), Jt(g.$$.fragment), k = ln(), w = wt("div"), S = wt("button"), Jt(v.$$.fragment), L = ln(), E = wt("button"), P.c(), q = ln(), N = wt("button"), Jt(Y.$$.fragment), ye(n, "class", "action icon volume svelte-1vl7tvk"), ye(n, "aria-label", "Adjust volume"), ye(l, "class", "svelte-1vl7tvk"), ye(a, "class", "playback icon svelte-1vl7tvk"), ye(a, "aria-label", d = `Adjust playback speed to ${/*playbackSpeeds*/
      i[9][
        /*playbackSpeeds*/
        (i[9].indexOf(
          /*playbackSpeed*/
          i[7]
        ) + 1) % /*playbackSpeeds*/
        i[9].length
      ]}x`), Wr(
        a,
        "hidden",
        /*show_volume_slider*/
        i[0]
      ), ye(f, "class", "zoom-button icon svelte-1vl7tvk"), ye(t, "class", "control-wrapper svelte-1vl7tvk"), ye(S, "class", "rewind icon svelte-1vl7tvk"), ye(S, "aria-label", b = `Skip backwards by ${Vn(
        /*audio_duration*/
        i[3],
        /*waveform_options*/
        i[6].skip_length
      )} seconds`), ye(E, "class", "play-pause-button icon svelte-1vl7tvk"), ye(E, "aria-label", F = /*playing*/
      i[5] ? (
        /*i18n*/
        i[4]("audio.pause")
      ) : (
        /*i18n*/
        i[4]("audio.play")
      )), ye(N, "class", "skip icon svelte-1vl7tvk"), ye(N, "aria-label", J = "Skip forward by " + Vn(
        /*audio_duration*/
        i[3],
        /*waveform_options*/
        i[6].skip_length
      ) + " seconds"), ye(w, "class", "play-pause-wrapper svelte-1vl7tvk"), ye(e, "class", "controls svelte-1vl7tvk"), ye(e, "data-testid", "waveform-controls");
    },
    m(R, j) {
      qh(R, e, j), Oe(e, t), Oe(t, n), Xt(o, n, null), Oe(t, r), K && K.m(t, null), Oe(t, s), Oe(t, a), Oe(a, l), Oe(l, u), Oe(l, c), Oe(t, _), Oe(t, f), Xt(h, f, null), Oe(t, p), Xt(g, t, null), Oe(e, k), Oe(e, w), Oe(w, S), Xt(v, S, null), Oe(w, L), Oe(w, E), M[D].m(E, null), Oe(w, q), Oe(w, N), Xt(Y, N, null), O = !0, T || (V = [
        Wn(
          n,
          "click",
          /*click_handler*/
          i[11]
        ),
        Wn(
          a,
          "click",
          /*click_handler_1*/
          i[14]
        ),
        Wn(
          f,
          "click",
          /*click_handler_2*/
          i[15]
        ),
        Wn(
          S,
          "click",
          /*click_handler_3*/
          i[17]
        ),
        Wn(
          E,
          "click",
          /*click_handler_4*/
          i[18]
        ),
        Wn(
          N,
          "click",
          /*click_handler_5*/
          i[19]
        )
      ], T = !0);
    },
    p(R, [j]) {
      const Q = {};
      j & /*currentVolume*/
      256 && (Q.currentVolume = /*currentVolume*/
      R[8]), o.$set(Q), /*show_volume_slider*/
      R[0] ? K ? (K.p(R, j), j & /*show_volume_slider*/
      1 && Ke(K, 1)) : (K = Ir(R), K.c(), Ke(K, 1), K.m(t, s)) : K && (Nr(), tt(K, 1, 1, () => {
        K = null;
      }), Tr()), (!O || j & /*playbackSpeed*/
      128) && jh(
        u,
        /*playbackSpeed*/
        R[7]
      ), (!O || j & /*playbackSpeed*/
      128 && d !== (d = `Adjust playback speed to ${/*playbackSpeeds*/
      R[9][
        /*playbackSpeeds*/
        (R[9].indexOf(
          /*playbackSpeed*/
          R[7]
        ) + 1) % /*playbackSpeeds*/
        R[9].length
      ]}x`)) && ye(a, "aria-label", d), (!O || j & /*show_volume_slider*/
      1) && Wr(
        a,
        "hidden",
        /*show_volume_slider*/
        R[0]
      );
      const X = {};
      j & /*waveform*/
      4 && (X.waveform = /*waveform*/
      R[2]), !m && j & /*showZoomSlider*/
      2 && (m = !0, X.showZoomSlider = /*showZoomSlider*/
      R[1], qs(() => m = !1)), g.$set(X), (!O || j & /*audio_duration, waveform_options*/
      72 && b !== (b = `Skip backwards by ${Vn(
        /*audio_duration*/
        R[3],
        /*waveform_options*/
        R[6].skip_length
      )} seconds`)) && ye(S, "aria-label", b);
      let B = D;
      D = C(R), D !== B && (Nr(), tt(M[B], 1, 1, () => {
        M[B] = null;
      }), Tr(), P = M[D], P || (P = M[D] = te[D](R), P.c()), Ke(P, 1), P.m(E, null)), (!O || j & /*playing, i18n*/
      48 && F !== (F = /*playing*/
      R[5] ? (
        /*i18n*/
        R[4]("audio.pause")
      ) : (
        /*i18n*/
        R[4]("audio.play")
      ))) && ye(E, "aria-label", F), (!O || j & /*audio_duration, waveform_options*/
      72 && J !== (J = "Skip forward by " + Vn(
        /*audio_duration*/
        R[3],
        /*waveform_options*/
        R[6].skip_length
      ) + " seconds")) && ye(N, "aria-label", J);
    },
    i(R) {
      O || (Ke(o.$$.fragment, R), Ke(K), Ke(h.$$.fragment, R), Ke(g.$$.fragment, R), Ke(v.$$.fragment, R), Ke(P), Ke(Y.$$.fragment, R), O = !0);
    },
    o(R) {
      tt(o.$$.fragment, R), tt(K), tt(h.$$.fragment, R), tt(g.$$.fragment, R), tt(v.$$.fragment, R), tt(P), tt(Y.$$.fragment, R), O = !1;
    },
    d(R) {
      R && Mh(e), Kt(o), K && K.d(), Kt(h), Kt(g), Kt(v), M[D].d(), Kt(Y), T = !1, Ah(V);
    }
  };
}
function Wh(i, e, t) {
  let { waveform: n } = e, { audio_duration: o } = e, { i18n: r } = e, { playing: s } = e, { waveform_options: a = {} } = e, { show_volume_slider: l = !1 } = e, { showZoomSlider: u = !1 } = e, { isDialogOpen: c = !1 } = e, d = [0.5, 1, 1.5, 2], _ = d[1], f = 1;
  Ph(() => {
    window.addEventListener("keydown", (L) => {
      if (!c)
        switch (L.key) {
          case " ":
            n.playPause(), L.preventDefault();
            break;
        }
    });
  });
  const h = () => t(0, l = !l);
  function p(L) {
    f = L, t(8, f);
  }
  function g(L) {
    l = L, t(0, l);
  }
  const m = () => {
    t(7, _ = d[(d.indexOf(_) + 1) % d.length]), n.setPlaybackRate(_);
  }, k = () => t(1, u = !u);
  function w(L) {
    u = L, t(1, u);
  }
  const S = () => n.skip(Vn(o, a.skip_length) * -1), v = () => n.playPause(), b = () => n.skip(Vn(o, a.skip_length));
  return i.$$set = (L) => {
    "waveform" in L && t(2, n = L.waveform), "audio_duration" in L && t(3, o = L.audio_duration), "i18n" in L && t(4, r = L.i18n), "playing" in L && t(5, s = L.playing), "waveform_options" in L && t(6, a = L.waveform_options), "show_volume_slider" in L && t(0, l = L.show_volume_slider), "showZoomSlider" in L && t(1, u = L.showZoomSlider), "isDialogOpen" in L && t(10, c = L.isDialogOpen);
  }, [
    l,
    u,
    n,
    o,
    r,
    s,
    a,
    _,
    f,
    d,
    c,
    h,
    p,
    g,
    m,
    k,
    w,
    S,
    v,
    b
  ];
}
class Ma extends Rh {
  constructor(e) {
    super(), Oh(this, e, Wh, Bh, zh, {
      waveform: 2,
      audio_duration: 3,
      i18n: 4,
      playing: 5,
      waveform_options: 6,
      show_volume_slider: 0,
      showZoomSlider: 1,
      isDialogOpen: 10
    });
  }
}
const { setContext: Yg, getContext: Ih } = window.__gradio__svelte__internal, Uh = "WORKER_PROXY_CONTEXT_KEY";
function Oa() {
  return Ih(Uh);
}
function Fh(i) {
  return i.host === window.location.host || i.host === "localhost:7860" || i.host === "127.0.0.1:7860" || // Ref: https://github.com/gradio-app/gradio/blob/v3.32.0/js/app/src/Index.svelte#L194
  i.host === "lite.local";
}
function qa(i, e) {
  const t = e.toLowerCase();
  for (const [n, o] of Object.entries(i))
    if (n.toLowerCase() === t)
      return o;
}
function Aa(i) {
  if (i == null)
    return !1;
  const e = new URL(i, window.location.href);
  return !(!Fh(e) || e.protocol !== "http:" && e.protocol !== "https:");
}
async function Ur(i) {
  if (i == null || !Aa(i))
    return i;
  const e = Oa();
  if (e == null)
    return i;
  const n = new URL(i, window.location.href).pathname;
  return e.httpRequest({
    method: "GET",
    path: n,
    headers: {},
    query_string: ""
  }).then((o) => {
    if (o.status !== 200)
      throw new Error(`Failed to get file ${n} from the Wasm worker.`);
    const r = new Blob([o.body], {
      type: qa(o.headers, "content-type")
    });
    return URL.createObjectURL(r);
  });
}
const {
  SvelteComponent: Vh,
  assign: co,
  check_outros: za,
  compute_rest_props: Fr,
  create_slot: Ks,
  detach: Co,
  element: ja,
  empty: Pa,
  exclude_internal_props: Hh,
  get_all_dirty_from_scope: Xs,
  get_slot_changes: Ys,
  get_spread_update: Ta,
  group_outros: Na,
  init: Zh,
  insert: So,
  listen: Ba,
  prevent_default: Gh,
  safe_not_equal: Jh,
  set_attributes: fo,
  transition_in: Cn,
  transition_out: Sn,
  update_slot_base: Qs
} = window.__gradio__svelte__internal, { createEventDispatcher: Kh } = window.__gradio__svelte__internal;
function Xh(i) {
  let e, t, n, o, r;
  const s = (
    /*#slots*/
    i[8].default
  ), a = Ks(
    s,
    i,
    /*$$scope*/
    i[7],
    null
  );
  let l = [
    { href: (
      /*href*/
      i[0]
    ) },
    {
      target: t = typeof window < "u" && window.__is_colab__ ? "_blank" : null
    },
    { rel: "noopener noreferrer" },
    { download: (
      /*download*/
      i[1]
    ) },
    /*$$restProps*/
    i[6]
  ], u = {};
  for (let c = 0; c < l.length; c += 1)
    u = co(u, l[c]);
  return {
    c() {
      e = ja("a"), a && a.c(), fo(e, u);
    },
    m(c, d) {
      So(c, e, d), a && a.m(e, null), n = !0, o || (r = Ba(
        e,
        "click",
        /*dispatch*/
        i[3].bind(null, "click")
      ), o = !0);
    },
    p(c, d) {
      a && a.p && (!n || d & /*$$scope*/
      128) && Qs(
        a,
        s,
        c,
        /*$$scope*/
        c[7],
        n ? Ys(
          s,
          /*$$scope*/
          c[7],
          d,
          null
        ) : Xs(
          /*$$scope*/
          c[7]
        ),
        null
      ), fo(e, u = Ta(l, [
        (!n || d & /*href*/
        1) && { href: (
          /*href*/
          c[0]
        ) },
        { target: t },
        { rel: "noopener noreferrer" },
        (!n || d & /*download*/
        2) && { download: (
          /*download*/
          c[1]
        ) },
        d & /*$$restProps*/
        64 && /*$$restProps*/
        c[6]
      ]));
    },
    i(c) {
      n || (Cn(a, c), n = !0);
    },
    o(c) {
      Sn(a, c), n = !1;
    },
    d(c) {
      c && Co(e), a && a.d(c), o = !1, r();
    }
  };
}
function Yh(i) {
  let e, t, n, o;
  const r = [$h, Qh], s = [];
  function a(l, u) {
    return (
      /*is_downloading*/
      l[2] ? 0 : 1
    );
  }
  return e = a(i), t = s[e] = r[e](i), {
    c() {
      t.c(), n = Pa();
    },
    m(l, u) {
      s[e].m(l, u), So(l, n, u), o = !0;
    },
    p(l, u) {
      let c = e;
      e = a(l), e === c ? s[e].p(l, u) : (Na(), Sn(s[c], 1, 1, () => {
        s[c] = null;
      }), za(), t = s[e], t ? t.p(l, u) : (t = s[e] = r[e](l), t.c()), Cn(t, 1), t.m(n.parentNode, n));
    },
    i(l) {
      o || (Cn(t), o = !0);
    },
    o(l) {
      Sn(t), o = !1;
    },
    d(l) {
      l && Co(n), s[e].d(l);
    }
  };
}
function Qh(i) {
  let e, t, n, o;
  const r = (
    /*#slots*/
    i[8].default
  ), s = Ks(
    r,
    i,
    /*$$scope*/
    i[7],
    null
  );
  let a = [
    /*$$restProps*/
    i[6],
    { href: (
      /*href*/
      i[0]
    ) }
  ], l = {};
  for (let u = 0; u < a.length; u += 1)
    l = co(l, a[u]);
  return {
    c() {
      e = ja("a"), s && s.c(), fo(e, l);
    },
    m(u, c) {
      So(u, e, c), s && s.m(e, null), t = !0, n || (o = Ba(e, "click", Gh(
        /*wasm_click_handler*/
        i[5]
      )), n = !0);
    },
    p(u, c) {
      s && s.p && (!t || c & /*$$scope*/
      128) && Qs(
        s,
        r,
        u,
        /*$$scope*/
        u[7],
        t ? Ys(
          r,
          /*$$scope*/
          u[7],
          c,
          null
        ) : Xs(
          /*$$scope*/
          u[7]
        ),
        null
      ), fo(e, l = Ta(a, [
        c & /*$$restProps*/
        64 && /*$$restProps*/
        u[6],
        (!t || c & /*href*/
        1) && { href: (
          /*href*/
          u[0]
        ) }
      ]));
    },
    i(u) {
      t || (Cn(s, u), t = !0);
    },
    o(u) {
      Sn(s, u), t = !1;
    },
    d(u) {
      u && Co(e), s && s.d(u), n = !1, o();
    }
  };
}
function $h(i) {
  let e;
  const t = (
    /*#slots*/
    i[8].default
  ), n = Ks(
    t,
    i,
    /*$$scope*/
    i[7],
    null
  );
  return {
    c() {
      n && n.c();
    },
    m(o, r) {
      n && n.m(o, r), e = !0;
    },
    p(o, r) {
      n && n.p && (!e || r & /*$$scope*/
      128) && Qs(
        n,
        t,
        o,
        /*$$scope*/
        o[7],
        e ? Ys(
          t,
          /*$$scope*/
          o[7],
          r,
          null
        ) : Xs(
          /*$$scope*/
          o[7]
        ),
        null
      );
    },
    i(o) {
      e || (Cn(n, o), e = !0);
    },
    o(o) {
      Sn(n, o), e = !1;
    },
    d(o) {
      n && n.d(o);
    }
  };
}
function xh(i) {
  let e, t, n, o, r;
  const s = [Yh, Xh], a = [];
  function l(u, c) {
    return c & /*href*/
    1 && (e = null), e == null && (e = !!/*worker_proxy*/
    (u[4] && Aa(
      /*href*/
      u[0]
    ))), e ? 0 : 1;
  }
  return t = l(i, -1), n = a[t] = s[t](i), {
    c() {
      n.c(), o = Pa();
    },
    m(u, c) {
      a[t].m(u, c), So(u, o, c), r = !0;
    },
    p(u, [c]) {
      let d = t;
      t = l(u, c), t === d ? a[t].p(u, c) : (Na(), Sn(a[d], 1, 1, () => {
        a[d] = null;
      }), za(), n = a[t], n ? n.p(u, c) : (n = a[t] = s[t](u), n.c()), Cn(n, 1), n.m(o.parentNode, o));
    },
    i(u) {
      r || (Cn(n), r = !0);
    },
    o(u) {
      Sn(n), r = !1;
    },
    d(u) {
      u && Co(o), a[t].d(u);
    }
  };
}
function e0(i, e, t) {
  const n = ["href", "download"];
  let o = Fr(e, n), { $$slots: r = {}, $$scope: s } = e;
  var a = this && this.__awaiter || function(h, p, g, m) {
    function k(w) {
      return w instanceof g ? w : new g(function(S) {
        S(w);
      });
    }
    return new (g || (g = Promise))(function(w, S) {
      function v(E) {
        try {
          L(m.next(E));
        } catch (D) {
          S(D);
        }
      }
      function b(E) {
        try {
          L(m.throw(E));
        } catch (D) {
          S(D);
        }
      }
      function L(E) {
        E.done ? w(E.value) : k(E.value).then(v, b);
      }
      L((m = m.apply(h, p || [])).next());
    });
  };
  let { href: l = void 0 } = e, { download: u } = e;
  const c = Kh();
  let d = !1;
  const _ = Oa();
  function f() {
    return a(this, void 0, void 0, function* () {
      if (d)
        return;
      if (c("click"), l == null)
        throw new Error("href is not defined.");
      if (_ == null)
        throw new Error("Wasm worker proxy is not available.");
      const p = new URL(l, window.location.href).pathname;
      t(2, d = !0), _.httpRequest({
        method: "GET",
        path: p,
        headers: {},
        query_string: ""
      }).then((g) => {
        if (g.status !== 200)
          throw new Error(`Failed to get file ${p} from the Wasm worker.`);
        const m = new Blob(
          [g.body],
          {
            type: qa(g.headers, "content-type")
          }
        ), k = URL.createObjectURL(m), w = document.createElement("a");
        w.href = k, w.download = u, w.click(), URL.revokeObjectURL(k);
      }).finally(() => {
        t(2, d = !1);
      });
    });
  }
  return i.$$set = (h) => {
    e = co(co({}, e), Hh(h)), t(6, o = Fr(e, n)), "href" in h && t(0, l = h.href), "download" in h && t(1, u = h.download), "$$scope" in h && t(7, s = h.$$scope);
  }, [
    l,
    u,
    d,
    c,
    _,
    f,
    o,
    s,
    r
  ];
}
class Wa extends Vh {
  constructor(e) {
    super(), Zh(this, e, e0, xh, Jh, { href: 0, download: 1 });
  }
}
const {
  SvelteComponent: t0,
  append: Vr,
  attr: Rt,
  detach: n0,
  init: i0,
  insert: o0,
  noop: as,
  safe_not_equal: s0,
  svg_element: us
} = window.__gradio__svelte__internal;
function r0(i) {
  let e, t, n;
  return {
    c() {
      e = us("svg"), t = us("g"), n = us("path"), Rt(n, "d", `M41.267,18.557H26.832V4.134C26.832,1.851,24.99,0,22.707,0c-2.283,0-4.124,1.851-4.124,4.135v14.432H4.141\r
		c-2.283,0-4.139,1.851-4.138,4.135c-0.001,1.141,0.46,2.187,1.207,2.934c0.748,0.749,1.78,1.222,2.92,1.222h14.453V41.27\r
		c0,1.142,0.453,2.176,1.201,2.922c0.748,0.748,1.777,1.211,2.919,1.211c2.282,0,4.129-1.851,4.129-4.133V26.857h14.435\r
		c2.283,0,4.134-1.867,4.133-4.15C45.399,20.425,43.548,18.557,41.267,18.557z`), Rt(e, "version", "1.1"), Rt(e, "id", "Capa_1"), Rt(e, "xmlns", "http://www.w3.org/2000/svg"), Rt(e, "xmlns:xlink", "http://www.w3.org/1999/xlink"), Rt(e, "width", "100%"), Rt(e, "height", "100%"), Rt(e, "viewBox", "0 10 45.402 45.402	"), Rt(e, "xml:space", "preserve");
    },
    m(o, r) {
      o0(o, e, r), Vr(e, t), Vr(t, n);
    },
    p: as,
    i: as,
    o: as,
    d(o) {
      o && n0(e);
    }
  };
}
class l0 extends t0 {
  constructor(e) {
    super(), i0(this, e, null, r0, s0, {});
  }
}
const {
  SvelteComponent: a0,
  append: xe,
  attr: ve,
  binding_callbacks: u0,
  detach: c0,
  element: Ht,
  init: d0,
  insert: f0,
  listen: Ki,
  noop: Hr,
  run_all: _0,
  safe_not_equal: h0,
  set_input_value: Xi,
  space: _i
} = window.__gradio__svelte__internal, { createEventDispatcher: m0, onMount: p0 } = window.__gradio__svelte__internal;
function g0(i) {
  let e, t, n, o, r, s, a, l, u, c, d, _, f, h, p;
  return {
    c() {
      e = Ht("dialog"), t = Ht("label"), t.textContent = "Label name:", n = _i(), o = Ht("input"), r = _i(), s = Ht("label"), s.textContent = "Label color:", a = _i(), l = Ht("input"), u = _i(), c = Ht("div"), d = Ht("button"), d.textContent = "Cancel", _ = _i(), f = Ht("button"), f.textContent = "Submit", ve(t, "for", "name"), ve(t, "class", "svelte-9771nr"), ve(o, "type", "text"), ve(o, "maxlength", "30"), ve(o, "id", "name"), ve(o, "name", "name"), ve(o, "class", "svelte-9771nr"), ve(s, "for", "color"), ve(s, "class", "svelte-9771nr"), ve(l, "type", "color"), ve(l, "id", "color"), ve(l, "name", "color"), ve(l, "class", "svelte-9771nr"), ve(d, "id", "cancel"), ve(d, "class", "svelte-9771nr"), ve(f, "id", "submit"), ve(f, "class", "svelte-9771nr"), ve(c, "class", "dialog-buttons svelte-9771nr"), ve(c, "id", "color"), ve(e, "class", "dialog-box svelte-9771nr"), ve(e, "id", "dialog-box"), e.hidden = !0;
    },
    m(g, m) {
      f0(g, e, m), xe(e, t), xe(e, n), xe(e, o), Xi(
        o,
        /*name*/
        i[0]
      ), xe(e, r), xe(e, s), xe(e, a), xe(e, l), Xi(
        l,
        /*color*/
        i[1]
      ), xe(e, u), xe(e, c), xe(c, d), xe(c, _), xe(c, f), i[9](e), h || (p = [
        Ki(
          o,
          "input",
          /*input0_input_handler*/
          i[7]
        ),
        Ki(
          l,
          "input",
          /*input1_input_handler*/
          i[8]
        ),
        Ki(
          d,
          "click",
          /*onClose*/
          i[3]
        ),
        Ki(
          f,
          "click",
          /*onSubmit*/
          i[4]
        )
      ], h = !0);
    },
    p(g, [m]) {
      m & /*name*/
      1 && o.value !== /*name*/
      g[0] && Xi(
        o,
        /*name*/
        g[0]
      ), m & /*color*/
      2 && Xi(
        l,
        /*color*/
        g[1]
      );
    },
    i: Hr,
    o: Hr,
    d(g) {
      g && c0(e), i[9](null), h = !1, _0(p);
    }
  };
}
function b0(i, e, t) {
  let { isOpen: n = !1 } = e, o, r, s, a;
  const l = m0();
  function u(p) {
    t(0, o = p.name), t(1, r = p.color.slice(0, p.color.length - 2)), s = p.shortcut, a.showModal(), document.getElementById("dialog-box").hidden = !1, document.getElementById("name").focus(), t(5, n = !0);
  }
  function c() {
    a.close(), t(0, o = t(1, r = s = void 0)), document.getElementById("dialog-box").hidden = !0, t(5, n = !1);
  }
  function d() {
    l("submit", { name: o, color: r + "80", shortcut: s }), c();
  }
  p0(() => {
    window.addEventListener("keydown", (p) => {
      if (n)
        switch (p.key) {
          case "Enter":
            d();
            break;
          case "Escape":
            c();
            break;
        }
    });
  });
  function _() {
    o = this.value, t(0, o);
  }
  function f() {
    r = this.value, t(1, r);
  }
  function h(p) {
    u0[p ? "unshift" : "push"](() => {
      a = p, t(2, a);
    });
  }
  return i.$$set = (p) => {
    "isOpen" in p && t(5, n = p.isOpen);
  }, [
    o,
    r,
    a,
    c,
    d,
    n,
    u,
    _,
    f,
    h
  ];
}
class v0 extends a0 {
  constructor(e) {
    super(), d0(this, e, b0, g0, h0, { isOpen: 5, openDialog: 6 });
  }
  get openDialog() {
    return this.$$.ctx[6];
  }
}
const {
  SvelteComponent: w0,
  add_flush_callback: y0,
  append: Yi,
  attr: Qi,
  bind: k0,
  binding_callbacks: js,
  create_component: Zr,
  destroy_component: Gr,
  detach: Jr,
  element: $i,
  init: C0,
  insert: Kr,
  listen: S0,
  mount_component: Xr,
  safe_not_equal: E0,
  space: Yr,
  transition_in: Qr,
  transition_out: $r
} = window.__gradio__svelte__internal, { createEventDispatcher: D0, onMount: L0 } = window.__gradio__svelte__internal;
function R0(i) {
  let e, t, n, o, r, s, a, l, u, c, d, _;
  s = new l0({});
  function f(p) {
    i[13](p);
  }
  let h = {};
  return (
    /*isDialogOpen*/
    i[0] !== void 0 && (h.isOpen = /*isDialogOpen*/
    i[0]), l = new v0({ props: h }), i[12](l), js.push(() => k0(l, "isOpen", f)), l.$on(
      "submit",
      /*submit_handler*/
      i[14]
    ), {
      c() {
        e = $i("div"), t = $i("div"), n = Yr(), o = $i("div"), r = $i("button"), Zr(s.$$.fragment), a = Yr(), Zr(l.$$.fragment), Qi(t, "class", "caption svelte-43he0g"), Qi(r, "class", "create-label svelte-43he0g"), Qi(o, "class", "action-buttons svelte-43he0g"), Qi(e, "class", "caption-container svelte-43he0g");
      },
      m(p, g) {
        Kr(p, e, g), Yi(e, t), i[10](t), Yi(e, n), Yi(e, o), Yi(o, r), Xr(s, r, null), Kr(p, a, g), Xr(l, p, g), c = !0, d || (_ = S0(
          r,
          "click",
          /*click_handler*/
          i[11]
        ), d = !0);
      },
      p(p, [g]) {
        const m = {};
        !u && g & /*isDialogOpen*/
        1 && (u = !0, m.isOpen = /*isDialogOpen*/
        p[0], y0(() => u = !1)), l.$set(m);
      },
      i(p) {
        c || (Qr(s.$$.fragment, p), Qr(l.$$.fragment, p), c = !0);
      },
      o(p) {
        $r(s.$$.fragment, p), $r(l.$$.fragment, p), c = !1;
      },
      d(p) {
        p && (Jr(e), Jr(a)), i[10](null), Gr(s), i[12](null), Gr(l, p), d = !1, _();
      }
    }
  );
}
function xr(i) {
  let e = document.getElementById(i.shortcut);
  e.style.backgroundColor = i.color, e.innerHTML = '<span style="font-weight: bold;">' + i.shortcut + "</span>: " + i.name;
}
function M0(i, e, t) {
  let { defaultLabel: n = null } = e, { activeLabel: o = null } = e, { isDialogOpen: r = !1 } = e, s, a = [], l;
  const u = ["#ffd70080", "#0000ff80", "#ff000080", "#00ff0080"], c = D0();
  function d(v) {
    const b = document.createElement("button");
    b.id = v.shortcut, b.addEventListener("focusin", () => p(v.shortcut)), b.addEventListener("focusout", () => p()), b.addEventListener("dblclick", () => l.openDialog(v)), s.appendChild(b), xr(v);
  }
  function _(v) {
    const b = a.length;
    if (b === 26)
      return;
    if (v.name || (v.name = "LABEL_" + b.toString().padStart(2, "0")), f("name", v.name))
      return f("name", v.name);
    if (v.color || (v.color = u[b % u.length]), !v.shortcut)
      for (v.shortcut = "A"; a.some((E) => E.shortcut === v.shortcut) && v.shortcut !== "Z"; )
        v.shortcut = String.fromCharCode(v.shortcut.charCodeAt(0) + 1);
    const L = {
      name: v.name,
      color: v.color,
      shortcut: v.shortcut
    };
    return a.push(L), d(L), t(2, a = a.sort((E, D) => E.shortcut.localeCompare(D.shortcut))), L;
  }
  function f(v, b, L) {
    L === void 0 && (L = !1);
    let E = a.find((D) => D[v] === b);
    if (E == null && L) {
      const D = {};
      D[v] = b, E = _(D);
    }
    return E;
  }
  function h(v, b = {}) {
    const { name: L = v.name, color: E = v.color, shortcut: D = v.shortcut } = b;
    if (v.name !== L && (v.name = L, c("name_update", v)), v.color !== E && (v.color = E, c("color_update", v)), !a.find((P) => P.shortcut === D)) {
      let P = document.getElementById(v.shortcut);
      v.shortcut = D, P.id = v.shortcut;
    }
    xr(v);
  }
  function p(v) {
    let b = null;
    v !== void 0 && (b = f("shortcut", v, !0)), o && (document.getElementById(o.shortcut).classList.remove("active-button"), document.getElementById(o.shortcut).blur()), t(8, o = b), o && (document.getElementById(o.shortcut).classList.add("active-button"), document.getElementById(o.shortcut).focus(), c("select", o));
  }
  L0(() => {
    window.addEventListener("keydown", (v) => {
      if (!r)
        if (v.key.match(/^[a-zA-Z]$/)) {
          let b = v.key.toUpperCase();
          p(b);
        } else
          v.key === "Escape" ? p() : v.key === "F2" && o && l.openDialog(o);
    });
  });
  function g(v) {
    js[v ? "unshift" : "push"](() => {
      s = v, t(3, s);
    });
  }
  const m = () => {
    const v = _({});
    p(v.shortcut);
  };
  function k(v) {
    js[v ? "unshift" : "push"](() => {
      l = v, t(4, l);
    });
  }
  function w(v) {
    r = v, t(0, r);
  }
  const S = (v) => {
    let b = a.find((L) => L.shortcut === v.detail.shortcut);
    h(b, v.detail);
  };
  return i.$$set = (v) => {
    "defaultLabel" in v && t(7, n = v.defaultLabel), "activeLabel" in v && t(8, o = v.activeLabel), "isDialogOpen" in v && t(0, r = v.isDialogOpen);
  }, i.$$.update = () => {
    i.$$.dirty & /*labels*/
    4 && a.length > 0 && t(7, n = a[0]);
  }, [
    r,
    _,
    a,
    s,
    l,
    h,
    p,
    n,
    o,
    f,
    g,
    m,
    k,
    w,
    S
  ];
}
class O0 extends w0 {
  constructor(e) {
    super(), C0(this, e, M0, R0, E0, {
      defaultLabel: 7,
      activeLabel: 8,
      isDialogOpen: 0,
      createLabel: 1,
      getLabel: 9
    });
  }
  get createLabel() {
    return this.$$.ctx[1];
  }
  get getLabel() {
    return this.$$.ctx[9];
  }
}
class $s {
  constructor() {
    this.numNodes = 0, this.edges = /* @__PURE__ */ new Map();
  }
  /**
   * Get the number of node in this graph
   * @returns number of node in this graph
   */
  getNumNodes() {
    return this.numNodes;
  }
  /**
   * Get the list of nodes in this graph
   * @returns list of nodes
   */
  getNodesList() {
    return Array.from(this.edges.keys());
  }
  /**
   * Get nodes adjacent to the specified one
   * @param node
   * @returns adjacent nodes in this graph
   */
  getAdjNodes(e) {
    return this.edges.get(e);
  }
  /**
   *  Check whether the specified node is in this graph
   * @param node node to be be checked
   * @returns true if the specified node is in this graph, false otherwise
   */
  isNodeInGraph(e) {
    return this.edges.get(e) !== void 0;
  }
  /**
   * Check whether the edge (node1, node2) is in this graph. Calling this method for
   * the edge (node2, node1) will return the same result, as the graph is non-oriented.
   * @param node1 edge's first node
   * @param node2 edge's second node
   * @returns true if the edge is in this graph, false otherwise
   */
  isEdgeInGraph(e, t) {
    let n = this.getAdjNodes(e);
    return !(n === void 0 || n.find((o) => o == t) === void 0);
  }
  /**
   * Add specified node to this graph
   * @param node node to be added
   */
  addNode(e) {
    this.isNodeInGraph(e) || (this.edges.set(e, []), this.numNodes += 1);
  }
  /**
   * Add an edge between the two specified node
   * Note: (node1, node2) === (node2, node1)
   * @param node1 edge's first node
   * @param node2 edge's second node
   */
  addEdge(e, t) {
    var n, o;
    e !== t && (this.isEdgeInGraph(e, t) || (this.isNodeInGraph(e) || this.addNode(e), this.isNodeInGraph(t) || this.addNode(t), (n = this.getAdjNodes(e)) == null || n.push(t), (o = this.getAdjNodes(t)) == null || o.push(e)));
  }
  /**
   * Remove the specified node from this graph
   * @param node node to be removed
   * @returns true if the node has been successfully removed, false otherwise
   */
  removeNode(e) {
    let t = this.getAdjNodes(e);
    return t !== void 0 ? (t.forEach((n) => {
      this.removeEdge(e, n);
    }), this.edges.delete(e), this.numNodes -= 1, !0) : !1;
  }
  /**
   * Remove the edge (node1, node2) from this graph. Calling this method for edge
   * (node2, node1) will give the same result.
   * @param node1 edge's first node
   * @param node2 edge's second node
   */
  removeEdge(e, t) {
    var n, o, r, s;
    this.isEdgeInGraph(e, t) && ((o = this.getAdjNodes(e)) == null || o.splice(Number((n = this.getAdjNodes(e)) == null ? void 0 : n.indexOf(t)), 1), (s = this.getAdjNodes(t)) == null || s.splice(Number((r = this.getAdjNodes(e)) == null ? void 0 : r.indexOf(e)), 1));
  }
  /**
   * Remove all the nodes and edges from the graph
   */
  clear() {
    this.edges.clear(), this.numNodes = 0;
  }
  /**
   *
   * @returns
   */
  greedyColoring() {
    let e = /* @__PURE__ */ new Map(), t = new Array(this.numNodes).fill(!0);
    return this.getNodesList().forEach((n) => {
      var r;
      (r = this.getAdjNodes(n)) == null || r.forEach((s) => {
        let a = e.get(s);
        a !== void 0 && (t[a] = !1);
      });
      let o;
      for (o = 0; o < t.length && !t[o]; o++)
        ;
      e.set(n, o), t.fill(!0);
    }), e;
  }
  /**
   * Get the connected component of the graph to which the specified node belongs.
   * @param node
   * @returns A graph representing the connected component of the specified node.
   */
  getConnectedComponent(e) {
    let t = [], n = new $s();
    return this.getConnectedComponentHelper(e, t, n), n;
  }
  getConnectedComponentHelper(e, t, n) {
    var o;
    t.push(e), n.addNode(e), (o = this.getAdjNodes(e)) == null || o.forEach((r) => {
      n.addEdge(e, r), t.find((s) => s === r) === void 0 && this.getConnectedComponentHelper(r, t, n);
    });
  }
}
const {
  SvelteComponent: q0,
  add_flush_callback: so,
  append: nt,
  attr: ae,
  bind: ro,
  binding_callbacks: Yt,
  check_outros: _o,
  create_component: En,
  destroy_component: Dn,
  detach: ht,
  element: Ve,
  empty: Ia,
  group_outros: ho,
  init: A0,
  insert: mt,
  listen: Ps,
  mount_component: Ln,
  noop: el,
  run_all: z0,
  safe_not_equal: j0,
  space: wn,
  src_url_equal: tl,
  transition_in: Le,
  transition_out: We
} = window.__gradio__svelte__internal, { onMount: P0 } = window.__gradio__svelte__internal, { createEventDispatcher: T0 } = window.__gradio__svelte__internal;
function N0(i) {
  let e, t, n, o, r, s, a, l, u, c, d, _, f = (
    /*waveform*/
    i[10] && nl(i)
  );
  return {
    c() {
      e = Ve("div"), t = Ve("div"), n = Ve("div"), o = wn(), r = Ve("div"), s = Ve("time"), s.textContent = "0:00", a = wn(), l = Ve("div"), u = Ve("time"), u.textContent = "0:00", c = wn(), f && f.c(), ae(n, "id", "waveform"), ae(n, "class", "svelte-15fy58k"), ae(t, "class", "waveform-container svelte-15fy58k"), ae(s, "id", "time"), ae(s, "class", "svelte-15fy58k"), ae(u, "id", "duration"), ae(u, "class", "svelte-15fy58k"), ae(r, "class", "timestamps svelte-15fy58k"), ae(e, "class", "component-wrapper svelte-15fy58k"), ae(e, "data-testid", d = /*label*/
      i[3] ? "waveform-" + /*label*/
      i[3] : "unlabelled-audio");
    },
    m(h, p) {
      mt(h, e, p), nt(e, t), nt(t, n), i[30](n), nt(e, o), nt(e, r), nt(r, s), i[31](s), nt(r, a), nt(r, l), nt(l, u), i[32](u), nt(e, c), f && f.m(e, null), _ = !0;
    },
    p(h, p) {
      /*waveform*/
      h[10] ? f ? (f.p(h, p), p[0] & /*waveform*/
      1024 && Le(f, 1)) : (f = nl(h), f.c(), Le(f, 1), f.m(e, null)) : f && (ho(), We(f, 1, 1, () => {
        f = null;
      }), _o()), (!_ || p[0] & /*label*/
      8 && d !== (d = /*label*/
      h[3] ? "waveform-" + /*label*/
      h[3] : "unlabelled-audio")) && ae(e, "data-testid", d);
    },
    i(h) {
      _ || (Le(f), _ = !0);
    },
    o(h) {
      We(f), _ = !1;
    },
    d(h) {
      h && ht(e), i[30](null), i[31](null), i[32](null), f && f.d();
    }
  };
}
function B0(i) {
  let e, t, n;
  return {
    c() {
      e = Ve("audio"), ae(e, "class", "standard-player svelte-15fy58k"), tl(e.src, t = /*value*/
      i[0].file_data.url) || ae(e, "src", t), e.controls = !0, e.autoplay = n = /*waveform_settings*/
      i[7].autoplay;
    },
    m(o, r) {
      mt(o, e, r);
    },
    p(o, r) {
      r[0] & /*value*/
      1 && !tl(e.src, t = /*value*/
      o[0].file_data.url) && ae(e, "src", t), r[0] & /*waveform_settings*/
      128 && n !== (n = /*waveform_settings*/
      o[7].autoplay) && (e.autoplay = n);
    },
    i: el,
    o: el,
    d(o) {
      o && ht(e);
    }
  };
}
function W0(i) {
  let e, t;
  return e = new ha({
    props: {
      size: "small",
      $$slots: { default: [U0] },
      $$scope: { ctx: i }
    }
  }), {
    c() {
      En(e.$$.fragment);
    },
    m(n, o) {
      Ln(e, n, o), t = !0;
    },
    p(n, o) {
      const r = {};
      o[2] & /*$$scope*/
      16 && (r.$$scope = { dirty: o, ctx: n }), e.$set(r);
    },
    i(n) {
      t || (Le(e.$$.fragment, n), t = !0);
    },
    o(n) {
      We(e.$$.fragment, n), t = !1;
    },
    d(n) {
      Dn(e, n);
    }
  };
}
function nl(i) {
  let e, t, n, o, r, s, a, l, u;
  function c(h) {
    i[33](h);
  }
  let d = {
    isDialogOpen: (
      /*isDialogOpen*/
      i[2]
    ),
    waveform: (
      /*waveform*/
      i[10]
    ),
    playing: (
      /*playing*/
      i[16]
    ),
    audio_duration: (
      /*audio_duration*/
      i[15]
    ),
    i18n: (
      /*i18n*/
      i[4]
    ),
    waveform_options: (
      /*waveform_options*/
      i[8]
    )
  };
  /*show_volume_slider*/
  i[17] !== void 0 && (d.show_volume_slider = /*show_volume_slider*/
  i[17]), n = new Ma({ props: d }), Yt.push(() => ro(n, "show_volume_slider", c));
  let _ = (
    /*editable*/
    i[6] && /*interactive*/
    i[5] && /*value*/
    i[0] && il(i)
  ), f = (
    /*value*/
    i[0] && ol(i)
  );
  return {
    c() {
      e = Ve("div"), t = Ve("div"), En(n.$$.fragment), r = wn(), s = Ve("div"), _ && _.c(), a = wn(), f && f.c(), l = Ia(), ae(t, "class", "waveform-controls svelte-15fy58k"), ae(s, "class", "regions-actions svelte-15fy58k"), ae(e, "class", "commands svelte-15fy58k");
    },
    m(h, p) {
      mt(h, e, p), nt(e, t), Ln(n, t, null), nt(e, r), nt(e, s), _ && _.m(s, null), mt(h, a, p), f && f.m(h, p), mt(h, l, p), u = !0;
    },
    p(h, p) {
      const g = {};
      p[0] & /*isDialogOpen*/
      4 && (g.isDialogOpen = /*isDialogOpen*/
      h[2]), p[0] & /*waveform*/
      1024 && (g.waveform = /*waveform*/
      h[10]), p[0] & /*playing*/
      65536 && (g.playing = /*playing*/
      h[16]), p[0] & /*audio_duration*/
      32768 && (g.audio_duration = /*audio_duration*/
      h[15]), p[0] & /*i18n*/
      16 && (g.i18n = /*i18n*/
      h[4]), p[0] & /*waveform_options*/
      256 && (g.waveform_options = /*waveform_options*/
      h[8]), !o && p[0] & /*show_volume_slider*/
      131072 && (o = !0, g.show_volume_slider = /*show_volume_slider*/
      h[17], so(() => o = !1)), n.$set(g), /*editable*/
      h[6] && /*interactive*/
      h[5] && /*value*/
      h[0] ? _ ? (_.p(h, p), p[0] & /*editable, interactive, value*/
      97 && Le(_, 1)) : (_ = il(h), _.c(), Le(_, 1), _.m(s, null)) : _ && (ho(), We(_, 1, 1, () => {
        _ = null;
      }), _o()), /*value*/
      h[0] ? f ? (f.p(h, p), p[0] & /*value*/
      1 && Le(f, 1)) : (f = ol(h), f.c(), Le(f, 1), f.m(l.parentNode, l)) : f && (ho(), We(f, 1, 1, () => {
        f = null;
      }), _o());
    },
    i(h) {
      u || (Le(n.$$.fragment, h), Le(_), Le(f), u = !0);
    },
    o(h) {
      We(n.$$.fragment, h), We(_), We(f), u = !1;
    },
    d(h) {
      h && (ht(e), ht(a), ht(l)), Dn(n), _ && _.d(), f && f.d(h);
    }
  };
}
function il(i) {
  let e, t, n, o, r, s, a, l, u, c, d, _ = (
    /*showRedo*/
    i[21] && I0(i)
  );
  return n = new D_({}), a = new _f({}), {
    c() {
      _ && _.c(), e = wn(), t = Ve("button"), En(n.$$.fragment), r = wn(), s = Ve("button"), En(a.$$.fragment), ae(t, "class", "action icon remove-button svelte-15fy58k"), ae(t, "aria-label", "Remove an annotation"), ae(t, "title", o = /*i18n*/
      i[4]("Remove an annotation")), ae(s, "class", "action icon trim-button svelte-15fy58k"), ae(s, "aria-label", "Split an annotation"), ae(s, "title", l = /*i18n*/
      i[4]("Split an annotation"));
    },
    m(f, h) {
      _ && _.m(f, h), mt(f, e, h), mt(f, t, h), Ln(n, t, null), mt(f, r, h), mt(f, s, h), Ln(a, s, null), u = !0, c || (d = [
        Ps(
          t,
          "click",
          /*click_handler*/
          i[34]
        ),
        Ps(
          s,
          "click",
          /*click_handler_1*/
          i[35]
        )
      ], c = !0);
    },
    p(f, h) {
      /*showRedo*/
      f[21] && _.p(f, h), (!u || h[0] & /*i18n*/
      16 && o !== (o = /*i18n*/
      f[4]("Remove an annotation"))) && ae(t, "title", o), (!u || h[0] & /*i18n*/
      16 && l !== (l = /*i18n*/
      f[4]("Split an annotation"))) && ae(s, "title", l);
    },
    i(f) {
      u || (Le(_), Le(n.$$.fragment, f), Le(a.$$.fragment, f), u = !0);
    },
    o(f) {
      We(_), We(n.$$.fragment, f), We(a.$$.fragment, f), u = !1;
    },
    d(f) {
      f && (ht(e), ht(t), ht(r), ht(s)), _ && _.d(f), Dn(n), Dn(a), c = !1, z0(d);
    }
  };
}
function I0(i) {
  let e, t, n, o, r, s;
  return t = new ba({}), {
    c() {
      e = Ve("button"), En(t.$$.fragment), ae(e, "class", "action icon svelte-15fy58k"), ae(e, "aria-label", "Reset annotations"), ae(e, "title", n = /*i18n*/
      i[4]("Reset annotations"));
    },
    m(a, l) {
      mt(a, e, l), Ln(t, e, null), o = !0, r || (s = Ps(
        e,
        "click",
        /*resetRegions*/
        i[23]
      ), r = !0);
    },
    p(a, l) {
      (!o || l[0] & /*i18n*/
      16 && n !== (n = /*i18n*/
      a[4]("Reset annotations"))) && ae(e, "title", n);
    },
    i(a) {
      o || (Le(t.$$.fragment, a), o = !0);
    },
    o(a) {
      We(t.$$.fragment, a), o = !1;
    },
    d(a) {
      a && ht(e), Dn(t), r = !1, s();
    }
  };
}
function ol(i) {
  let e, t, n, o, r;
  function s(c) {
    i[37](c);
  }
  function a(c) {
    i[38](c);
  }
  function l(c) {
    i[39](c);
  }
  let u = {};
  return (
    /*defaultLabel*/
    i[19] !== void 0 && (u.defaultLabel = /*defaultLabel*/
    i[19]), /*activeLabel*/
    i[20] !== void 0 && (u.activeLabel = /*activeLabel*/
    i[20]), /*isDialogOpen*/
    i[2] !== void 0 && (u.isDialogOpen = /*isDialogOpen*/
    i[2]), e = new O0({ props: u }), i[36](e), Yt.push(() => ro(e, "defaultLabel", s)), Yt.push(() => ro(e, "activeLabel", a)), Yt.push(() => ro(e, "isDialogOpen", l)), e.$on(
      "select",
      /*select_handler*/
      i[40]
    ), e.$on(
      "name_update",
      /*name_update_handler*/
      i[41]
    ), e.$on(
      "color_update",
      /*color_update_handler*/
      i[42]
    ), {
      c() {
        En(e.$$.fragment);
      },
      m(c, d) {
        Ln(e, c, d), r = !0;
      },
      p(c, d) {
        const _ = {};
        !t && d[0] & /*defaultLabel*/
        524288 && (t = !0, _.defaultLabel = /*defaultLabel*/
        c[19], so(() => t = !1)), !n && d[0] & /*activeLabel*/
        1048576 && (n = !0, _.activeLabel = /*activeLabel*/
        c[20], so(() => n = !1)), !o && d[0] & /*isDialogOpen*/
        4 && (o = !0, _.isDialogOpen = /*isDialogOpen*/
        c[2], so(() => o = !1)), e.$set(_);
      },
      i(c) {
        r || (Le(e.$$.fragment, c), r = !0);
      },
      o(c) {
        We(e.$$.fragment, c), r = !1;
      },
      d(c) {
        i[36](null), Dn(e, c);
      }
    }
  );
}
function U0(i) {
  let e, t;
  return e = new go({}), {
    c() {
      En(e.$$.fragment);
    },
    m(n, o) {
      Ln(e, n, o), t = !0;
    },
    i(n) {
      t || (Le(e.$$.fragment, n), t = !0);
    },
    o(n) {
      We(e.$$.fragment, n), t = !1;
    },
    d(n) {
      Dn(e, n);
    }
  };
}
function F0(i) {
  let e, t, n, o;
  const r = [W0, B0, N0], s = [];
  function a(l, u) {
    return (
      /*value*/
      l[0] === null ? 0 : (
        /*value*/
        l[0].file_data.is_stream ? 1 : 2
      )
    );
  }
  return e = a(i), t = s[e] = r[e](i), {
    c() {
      t.c(), n = Ia();
    },
    m(l, u) {
      s[e].m(l, u), mt(l, n, u), o = !0;
    },
    p(l, u) {
      let c = e;
      e = a(l), e === c ? s[e].p(l, u) : (ho(), We(s[c], 1, 1, () => {
        s[c] = null;
      }), _o(), t = s[e], t ? t.p(l, u) : (t = s[e] = r[e](l), t.c()), Le(t, 1), t.m(n.parentNode, n));
    },
    i(l) {
      o || (Le(t), o = !0);
    },
    o(l) {
      We(t), o = !1;
    },
    d(l) {
      l && ht(n), s[e].d(l);
    }
  };
}
function V0(i, e, t) {
  let n = e * (100 / t), o = 100 / t;
  i.element.style.top = n.toString() + "%", i.element.style.height = o.toString() + "%";
}
function sl(i) {
  const e = Math.floor(i / 60), n = `0${Math.round(i) % 60}`.slice(-2);
  return `${e}:${n}`;
}
function H0(i, e, t) {
  let n;
  var o = this && this.__awaiter || function(y, W, U, ee) {
    function Re(be) {
      return be instanceof U ? be : new U(function(sn) {
        sn(be);
      });
    }
    return new (U || (U = Promise))(function(be, sn) {
      function Au(rn) {
        try {
          Oo(ee.next(rn));
        } catch (qo) {
          sn(qo);
        }
      }
      function zu(rn) {
        try {
          Oo(ee.throw(rn));
        } catch (qo) {
          sn(qo);
        }
      }
      function Oo(rn) {
        rn.done ? be(rn.value) : Re(rn.value).then(Au, zu);
      }
      Oo((ee = ee.apply(y, W || [])).next());
    });
  }, r;
  let { value: s = null } = e, { label: a } = e, { i18n: l } = e, { interactive: u = !0 } = e, { editable: c = !0 } = e, { waveform_settings: d } = e, { waveform_options: _ } = e, { mode: f = "" } = e, { isDialogOpen: h } = e, p, g, m, k = null, w, S, v, b, L, E = !1, D = !1, P = u, F = null, q = /* @__PURE__ */ new Map(), N, Y = null, J = null, O = new $s();
  const T = T0();
  function V(y) {
    O.isNodeInGraph(y) || O.addNode(y);
    let W = q.get(y);
    O.getNodesList().forEach((be) => {
      let sn = q.get(be);
      W.start < sn.end && sn.start < W.end ? O.addEdge(y, be) : O.removeEdge(y, be);
    });
    let ee = O.getConnectedComponent(y).greedyColoring(), Re = Math.max(...Array.from(ee.values())) + 1;
    m.getRegions().forEach((be) => {
      ee.get(be.id) !== void 0 && V0(be, ee.get(be.id), Re);
    });
  }
  function K(y) {
    O.removeNode(y);
  }
  function I() {
    var y;
    t(10, g = nn.create(Object.assign({ container: p }, d))), Ur((y = s.file_data) === null || y === void 0 ? void 0 : y.url).then((W) => {
      if (W && g)
        return g.load(W);
    }), g.on("dblclick", () => {
      C(g.getCurrentTime());
    });
  }
  function $(y) {
    if (F || (F = [...y]), y.length === 0)
      return;
    const W = Array.from(q.values());
    y = y.filter((U) => !W.some((ee) => U.start === ee.start && U.end === ee.end && U.speaker === ee.speaker)), y.forEach((U) => {
      let ee = N.createLabel({ name: U.speaker });
      M(
        {
          start: U.start,
          end: U.end,
          color: ee.color,
          drag: !0,
          resize: !0
        },
        U.speaker
      );
    });
  }
  function te() {
    t(0, s.annotations = Array.from(q.values()), s), T("edit", s);
  }
  function M(y, W) {
    let U = m.addRegion(y);
    const ee = {
      start: U.start,
      end: U.end,
      speaker: W,
      color: U.color
    };
    return q.set(U.id, ee), V(U.id), F || (F = [ee]), te(), U;
  }
  function C(y) {
    let W = J || Y;
    W || (W = N.createLabel({}));
    let U = M(
      {
        start: y - 1,
        end: y + 1,
        color: W.color,
        drag: !0,
        resize: !0
      },
      W.name
    );
    B(U);
  }
  function R(y) {
    y === k && B(null), q.delete(y.id), K(y.id), y.remove(), te();
  }
  function j(y, W) {
    if (!k)
      return;
    let U = m.getRegions().find((ee) => ee.id === k.id);
    y === "Delete" || y == "Backspace" && W ? de(!1) : de(!0), R(U);
  }
  function Q() {
    X(), F.forEach((y) => s.annotations.push(Object.assign({}, y))), $(s.annotations), T("edit", s);
  }
  function X() {
    B(null), m == null || m.clearRegions(), t(0, s.annotations = [], s), q.clear(), O.clear();
  }
  function B(y) {
    k && t(12, k.element.style.background = k.color, k), t(12, k = y), k && (ue(y.color), g.setTime(y.start));
  }
  function ue(y) {
    k && t(12, k.element.style.background = "repeating-linear-gradient(45deg," + y + " ," + y + " 10px, #ffffff 10px ,#ffffff 15px)", k);
  }
  function A(y) {
    if (k !== null) {
      k.setOptions({
        start: k.start,
        end: k.end,
        color: y.color,
        drag: !0,
        resize: !0
      }), ue(k.color);
      let W = q.get(k.id);
      W.speaker = y.name, te();
    }
  }
  function de(y) {
    var W = y ? -1 : 1, U = m.getRegions().sort((Re, be) => Re.start > be.start ? 1 : -1);
    if (k === null)
      B(U[0]);
    else {
      var ee = U.indexOf(k);
      B(U.at((ee + W) % U.length));
    }
  }
  function fe(y, W) {
    if (W < y.start || W > y.end)
      throw new RangeError("split time out of region bounds");
    let U = q.get(y.id).speaker;
    M(
      {
        start: y.start,
        end: W,
        color: y.color,
        drag: y.drag,
        resize: y.resize
      },
      U
    );
    let ee = M(
      {
        start: W,
        end: y.end,
        color: y.color,
        drag: y.drag,
        resize: y.resize
      },
      U
    );
    B(ee), R(y);
  }
  function _e(y) {
    let W = m.getRegions().find((U) => U.start < y && U.end > y);
    if (W === void 0) {
      if (k === null)
        return;
      W = k, y = W.start + (W.end - W.start) / 2;
    }
    fe(W, y);
  }
  function Lt(y, W, U) {
    let ee, Re, be = 0.05;
    W && (be = be * 4), U ? y === "ArrowLeft" ? (ee = k.start, Re = k.end - be) : (ee = k.start, Re = k.end + be) : y === "ArrowLeft" ? (ee = k.start - be, Re = k.end) : (ee = k.start + be, Re = k.end), ee > k.end && (ee = k.end - 0.1), Re < k.start && (Re = k.start + 0.1), k.setOptions({ start: ee, end: Re });
  }
  function ne(y, W) {
    let U = g.getCurrentTime(), ee, Re = 0.05;
    W && (Re = Re * 4), y === "ArrowLeft" ? ee = U - Re : ee = U + Re, g.setTime(ee);
  }
  function Tt(y, W, U) {
    if (k) {
      Lt(y, W, U);
      return;
    }
    ne(y, W);
  }
  function Nt(y) {
    return o(this, void 0, void 0, function* () {
      yield Ur(y).then((W) => {
        var U;
        if (!(!W || !((U = s.file_data) === null || U === void 0) && U.is_stream))
          return g == null ? void 0 : g.load(W);
      });
    });
  }
  P0(() => {
    window.addEventListener("keydown", (y) => {
      if (!h)
        switch (y.key) {
          case "ArrowLeft":
            Tt("ArrowLeft", y.shiftKey, y.altKey);
            break;
          case "ArrowRight":
            Tt("ArrowRight", y.shiftKey, y.altKey);
            break;
          case "Escape":
            B(null);
            break;
          case "Tab":
            y.preventDefault(), de(y.shiftKey);
            break;
          case "Delete":
            j("Delete", y.shiftKey);
            break;
          case "Backspace":
            j("Backspace", y.shiftKey);
            break;
          case "Enter":
            y.preventDefault(), y.shiftKey ? _e(g.getCurrentTime()) : C(g.getCurrentTime());
            break;
        }
    });
  });
  function z(y) {
    Yt[y ? "unshift" : "push"](() => {
      p = y, t(9, p), t(10, g);
    });
  }
  function ge(y) {
    Yt[y ? "unshift" : "push"](() => {
      v = y, t(13, v), t(10, g);
    });
  }
  function H(y) {
    Yt[y ? "unshift" : "push"](() => {
      b = y, t(14, b), t(10, g);
    });
  }
  function re(y) {
    D = y, t(17, D);
  }
  const le = () => t(1, f = "remove"), x = () => t(1, f = "split");
  function he(y) {
    Yt[y ? "unshift" : "push"](() => {
      N = y, t(18, N);
    });
  }
  function me(y) {
    Y = y, t(19, Y);
  }
  function oe(y) {
    J = y, t(20, J);
  }
  function se(y) {
    h = y, t(2, h);
  }
  const Ae = (y) => A(y.detail), on = (y) => {
    m.getRegions().forEach((W) => {
      W.color === y.detail.color && (q.get(W.id).speaker = y.detail.name);
    });
  }, qu = (y) => {
    m.getRegions().forEach((W) => {
      q.get(W.id).speaker === y.detail.name && (W.setOptions({ color: y.detail.color }), W === k && ue(W.color));
    });
  };
  return i.$$set = (y) => {
    "value" in y && t(0, s = y.value), "label" in y && t(3, a = y.label), "i18n" in y && t(4, l = y.i18n), "interactive" in y && t(5, u = y.interactive), "editable" in y && t(6, c = y.editable), "waveform_settings" in y && t(7, d = y.waveform_settings), "waveform_options" in y && t(8, _ = y.waveform_options), "mode" in y && t(1, f = y.mode), "isDialogOpen" in y && t(2, h = y.isDialogOpen);
  }, i.$$.update = () => {
    if (i.$$.dirty[0] & /*value, _a*/
    67108865 && t(29, n = t(26, r = s.file_data) === null || r === void 0 ? void 0 : r.url), i.$$.dirty[0] & /*container, waveform*/
    1536 && p !== void 0 && (g !== void 0 && g.destroy(), t(9, p.innerHTML = "", p), I(), t(16, E = !1)), i.$$.dirty[0] & /*waveform, wsRegions, mode, waveform_settings*/
    3202 && (g == null || g.on("ready", () => {
      m === void 0 && (t(11, m = g.registerPlugin(z_.create())), m == null || m.on("region-clicked", (y, W) => {
        switch (f) {
          case "remove":
            R(y);
            break;
          case "split":
            fe(y, y.start + (y.end - y.start) / 2);
            break;
          default:
            B(y), y.play();
        }
        t(1, f = "");
      }), m == null || m.on("region-updated", (y) => {
        let W = q.get(y.id);
        W.start = y.start, W.end = y.end, V(y.id), te();
      })), d.autoplay ? g == null || g.play() : g == null || g.stop();
    })), i.$$.dirty[0] & /*value, wsRegions*/
    2049 && (s == null ? void 0 : s.annotations) !== null && m && $(s.annotations), i.$$.dirty[0] & /*waveform, durationRef*/
    17408 && (g == null || g.on("decode", (y) => {
      t(15, L = y), b && t(14, b.textContent = sl(y), b);
    })), i.$$.dirty[0] & /*waveform, timeRef*/
    9216 && (g == null || g.on("timeupdate", (y) => v && t(13, v.textContent = sl(y), v))), i.$$.dirty[0] & /*waveform*/
    1024 && (g == null || g.on("finish", () => {
      t(16, E = !1), T("stop");
    })), i.$$.dirty[0] & /*waveform*/
    1024 && (g == null || g.on("pause", () => {
      t(16, E = !1), T("pause");
    })), i.$$.dirty[0] & /*waveform*/
    1024 && (g == null || g.on("play", () => {
      t(16, E = !0), T("play");
    })), i.$$.dirty[0] & /*activeRegion, container, leftRegionHandle, rightRegionHandle, wsRegions*/
    402659840 && k) {
      const y = p.children[0].shadowRoot;
      t(28, S = y.querySelector('[data-resize="right"]')), t(27, w = y.querySelector('[data-resize="left"]')), w && S && (w.setAttribute("role", "button"), S.setAttribute("role", "button"), w == null || w.setAttribute("aria-label", "Drag to adjust start time"), S == null || S.setAttribute("aria-label", "Drag to adjust end time"), w == null || w.setAttribute("tabindex", "0"), S == null || S.setAttribute("tabindex", "0"), w.addEventListener("focus", () => {
      }), S.addEventListener("focus", () => {
      }));
    }
    i.$$.dirty[0] & /*url*/
    536870912 && n && Nt(n);
  }, [
    s,
    f,
    h,
    a,
    l,
    u,
    c,
    d,
    _,
    p,
    g,
    m,
    k,
    v,
    b,
    L,
    E,
    D,
    N,
    Y,
    J,
    P,
    q,
    Q,
    ue,
    A,
    r,
    w,
    S,
    n,
    z,
    ge,
    H,
    re,
    le,
    x,
    he,
    me,
    oe,
    se,
    Ae,
    on,
    qu
  ];
}
class Ua extends q0 {
  constructor(e) {
    super(), A0(
      this,
      e,
      H0,
      F0,
      j0,
      {
        value: 0,
        label: 3,
        i18n: 4,
        interactive: 5,
        editable: 6,
        waveform_settings: 7,
        waveform_options: 8,
        mode: 1,
        isDialogOpen: 2
      },
      null,
      [-1, -1, -1]
    );
  }
}
const {
  SvelteComponent: Z0,
  append: G0,
  attr: Fa,
  bubble: hi,
  check_outros: Va,
  create_component: oi,
  destroy_component: si,
  detach: Di,
  element: Ha,
  empty: J0,
  group_outros: Za,
  init: K0,
  insert: Li,
  mount_component: ri,
  safe_not_equal: X0,
  space: Ts,
  transition_in: ot,
  transition_out: pt
} = window.__gradio__svelte__internal, { createEventDispatcher: Y0 } = window.__gradio__svelte__internal;
function Q0(i) {
  let e, t;
  return e = new ha({
    props: {
      size: "small",
      $$slots: { default: [x0] },
      $$scope: { ctx: i }
    }
  }), {
    c() {
      oi(e.$$.fragment);
    },
    m(n, o) {
      ri(e, n, o), t = !0;
    },
    p(n, o) {
      const r = {};
      o & /*$$scope*/
      16384 && (r.$$scope = { dirty: o, ctx: n }), e.$set(r);
    },
    i(n) {
      t || (ot(e.$$.fragment, n), t = !0);
    },
    o(n) {
      pt(e.$$.fragment, n), t = !1;
    },
    d(n) {
      si(e, n);
    }
  };
}
function $0(i) {
  let e, t, n, o, r, s = (
    /*show_download_button*/
    i[3] && /*value*/
    i[0].file_data !== null && rl(i)
  ), a = n1;
  return o = new Ua({
    props: {
      isDialogOpen: !1,
      value: (
        /*value*/
        i[0]
      ),
      interactive: !1,
      label: (
        /*label*/
        i[1]
      ),
      i18n: (
        /*i18n*/
        i[4]
      ),
      waveform_settings: (
        /*waveform_settings*/
        i[5]
      ),
      waveform_options: (
        /*waveform_options*/
        i[6]
      )
    }
  }), o.$on(
    "pause",
    /*pause_handler*/
    i[10]
  ), o.$on(
    "play",
    /*play_handler*/
    i[11]
  ), o.$on(
    "stop",
    /*stop_handler*/
    i[12]
  ), {
    c() {
      e = Ha("div"), s && s.c(), t = Ts(), n = Ts(), oi(o.$$.fragment), Fa(e, "class", "icon-buttons svelte-1mrvp2o");
    },
    m(l, u) {
      Li(l, e, u), s && s.m(e, null), G0(e, t), Li(l, n, u), ri(o, l, u), r = !0;
    },
    p(l, u) {
      /*show_download_button*/
      l[3] && /*value*/
      l[0].file_data !== null ? s ? (s.p(l, u), u & /*show_download_button, value*/
      9 && ot(s, 1)) : (s = rl(l), s.c(), ot(s, 1), s.m(e, t)) : s && (Za(), pt(s, 1, 1, () => {
        s = null;
      }), Va());
      const c = {};
      u & /*value*/
      1 && (c.value = /*value*/
      l[0]), u & /*label*/
      2 && (c.label = /*label*/
      l[1]), u & /*i18n*/
      16 && (c.i18n = /*i18n*/
      l[4]), u & /*waveform_settings*/
      32 && (c.waveform_settings = /*waveform_settings*/
      l[5]), u & /*waveform_options*/
      64 && (c.waveform_options = /*waveform_options*/
      l[6]), o.$set(c);
    },
    i(l) {
      r || (ot(s), ot(a), ot(o.$$.fragment, l), r = !0);
    },
    o(l) {
      pt(s), pt(a), pt(o.$$.fragment, l), r = !1;
    },
    d(l) {
      l && (Di(e), Di(n)), s && s.d(), si(o, l);
    }
  };
}
function x0(i) {
  let e, t;
  return e = new go({}), {
    c() {
      oi(e.$$.fragment);
    },
    m(n, o) {
      ri(e, n, o), t = !0;
    },
    i(n) {
      t || (ot(e.$$.fragment, n), t = !0);
    },
    o(n) {
      pt(e.$$.fragment, n), t = !1;
    },
    d(n) {
      si(e, n);
    }
  };
}
function rl(i) {
  let e, t, n;
  return t = new Wa({
    props: {
      href: (
        /*value*/
        i[0].file_data.url
      ),
      download: (
        /*value*/
        i[0].file_data.orig_name || /*value*/
        i[0].file_data.path
      ),
      $$slots: { default: [e1] },
      $$scope: { ctx: i }
    }
  }), {
    c() {
      e = Ha("div"), oi(t.$$.fragment), Fa(e, "class", "download-button");
    },
    m(o, r) {
      Li(o, e, r), ri(t, e, null), n = !0;
    },
    p(o, r) {
      const s = {};
      r & /*value*/
      1 && (s.href = /*value*/
      o[0].file_data.url), r & /*value*/
      1 && (s.download = /*value*/
      o[0].file_data.orig_name || /*value*/
      o[0].file_data.path), r & /*$$scope, i18n*/
      16400 && (s.$$scope = { dirty: r, ctx: o }), t.$set(s);
    },
    i(o) {
      n || (ot(t.$$.fragment, o), n = !0);
    },
    o(o) {
      pt(t.$$.fragment, o), n = !1;
    },
    d(o) {
      o && Di(e), si(t);
    }
  };
}
function e1(i) {
  let e, t;
  return e = new Ri({
    props: {
      Icon: ma,
      label: (
        /*i18n*/
        i[4]("common.download")
      )
    }
  }), {
    c() {
      oi(e.$$.fragment);
    },
    m(n, o) {
      ri(e, n, o), t = !0;
    },
    p(n, o) {
      const r = {};
      o & /*i18n*/
      16 && (r.label = /*i18n*/
      n[4]("common.download")), e.$set(r);
    },
    i(n) {
      t || (ot(e.$$.fragment, n), t = !0);
    },
    o(n) {
      pt(e.$$.fragment, n), t = !1;
    },
    d(n) {
      si(e, n);
    }
  };
}
function t1(i) {
  let e, t, n, o, r, s;
  e = new da({
    props: {
      show_label: (
        /*show_label*/
        i[2]
      ),
      Icon: go,
      float: !1,
      label: (
        /*label*/
        i[1] || /*i18n*/
        i[4]("audio.audio")
      )
    }
  });
  const a = [$0, Q0], l = [];
  function u(c, d) {
    return (
      /*value*/
      c[0] !== null ? 0 : 1
    );
  }
  return n = u(i), o = l[n] = a[n](i), {
    c() {
      oi(e.$$.fragment), t = Ts(), o.c(), r = J0();
    },
    m(c, d) {
      ri(e, c, d), Li(c, t, d), l[n].m(c, d), Li(c, r, d), s = !0;
    },
    p(c, [d]) {
      const _ = {};
      d & /*show_label*/
      4 && (_.show_label = /*show_label*/
      c[2]), d & /*label, i18n*/
      18 && (_.label = /*label*/
      c[1] || /*i18n*/
      c[4]("audio.audio")), e.$set(_);
      let f = n;
      n = u(c), n === f ? l[n].p(c, d) : (Za(), pt(l[f], 1, 1, () => {
        l[f] = null;
      }), Va(), o = l[n], o ? o.p(c, d) : (o = l[n] = a[n](c), o.c()), ot(o, 1), o.m(r.parentNode, r));
    },
    i(c) {
      s || (ot(e.$$.fragment, c), ot(o), s = !0);
    },
    o(c) {
      pt(e.$$.fragment, c), pt(o), s = !1;
    },
    d(c) {
      c && (Di(t), Di(r)), si(e, c), l[n].d(c);
    }
  };
}
let n1 = !1;
function i1(i, e, t) {
  let { value: n = null } = e, { label: o } = e, { show_label: r = !0 } = e, { show_download_button: s = !0 } = e, { i18n: a } = e, { waveform_settings: l } = e, { waveform_options: u } = e;
  const c = Y0(), d = async (m) => m ? `<audio controls src="${await Pu(m.url)}"></audio>` : "";
  function _(m) {
    hi.call(this, i, m);
  }
  function f(m) {
    hi.call(this, i, m);
  }
  function h(m) {
    hi.call(this, i, m);
  }
  function p(m) {
    hi.call(this, i, m);
  }
  function g(m) {
    hi.call(this, i, m);
  }
  return i.$$set = (m) => {
    "value" in m && t(0, n = m.value), "label" in m && t(1, o = m.label), "show_label" in m && t(2, r = m.show_label), "show_download_button" in m && t(3, s = m.show_download_button), "i18n" in m && t(4, a = m.i18n), "waveform_settings" in m && t(5, l = m.waveform_settings), "waveform_options" in m && t(6, u = m.waveform_options);
  }, i.$$.update = () => {
    i.$$.dirty & /*value*/
    1 && n && c("change", n);
  }, [
    n,
    o,
    r,
    s,
    a,
    l,
    u,
    d,
    _,
    f,
    h,
    p,
    g
  ];
}
class o1 extends Z0 {
  constructor(e) {
    super(), K0(this, e, i1, t1, X0, {
      value: 0,
      label: 1,
      show_label: 2,
      show_download_button: 3,
      i18n: 4,
      waveform_settings: 5,
      waveform_options: 6
    });
  }
}
var cs = new Intl.Collator(0, { numeric: 1 }).compare;
function ll(i, e, t) {
  return i = i.split("."), e = e.split("."), cs(i[0], e[0]) || cs(i[1], e[1]) || (e[2] = e.slice(2).join("."), t = /[.-]/.test(i[2] = i.slice(2).join(".")), t == /[.-]/.test(e[2]) ? cs(i[2], e[2]) : t ? -1 : 1);
}
function Ga(i, e, t) {
  return e.startsWith("http://") || e.startsWith("https://") ? t ? i : e : i + e;
}
function ds(i) {
  if (i.startsWith("http")) {
    const { protocol: e, host: t } = new URL(i);
    return t.endsWith("hf.space") ? {
      ws_protocol: "wss",
      host: t,
      http_protocol: e
    } : {
      ws_protocol: e === "https:" ? "wss" : "ws",
      http_protocol: e,
      host: t
    };
  } else if (i.startsWith("file:"))
    return {
      ws_protocol: "ws",
      http_protocol: "http:",
      host: "lite.local"
      // Special fake hostname only used for this case. This matches the hostname allowed in `is_self_host()` in `js/wasm/network/host.ts`.
    };
  return {
    ws_protocol: "wss",
    http_protocol: "https:",
    host: i
  };
}
const Ja = /^[^\/]*\/[^\/]*$/, s1 = /.*hf\.space\/{0,1}$/;
async function r1(i, e) {
  const t = {};
  e && (t.Authorization = `Bearer ${e}`);
  const n = i.trim();
  if (Ja.test(n))
    try {
      const o = await fetch(
        `https://huggingface.co/api/spaces/${n}/host`,
        { headers: t }
      );
      if (o.status !== 200)
        throw new Error("Space metadata could not be loaded.");
      const r = (await o.json()).host;
      return {
        space_id: i,
        ...ds(r)
      };
    } catch (o) {
      throw new Error("Space metadata could not be loaded." + o.message);
    }
  if (s1.test(n)) {
    const { ws_protocol: o, http_protocol: r, host: s } = ds(n);
    return {
      space_id: s.replace(".hf.space", ""),
      ws_protocol: o,
      http_protocol: r,
      host: s
    };
  }
  return {
    space_id: !1,
    ...ds(n)
  };
}
function l1(i) {
  let e = {};
  return i.forEach(({ api_name: t }, n) => {
    t && (e[t] = n);
  }), e;
}
const a1 = /^(?=[^]*\b[dD]iscussions{0,1}\b)(?=[^]*\b[dD]isabled\b)[^]*$/;
async function al(i) {
  try {
    const t = (await fetch(
      `https://huggingface.co/api/spaces/${i}/discussions`,
      {
        method: "HEAD"
      }
    )).headers.get("x-error-message");
    return !(t && a1.test(t));
  } catch {
    return !1;
  }
}
function u1(i, e, t, n) {
  if (e.length === 0) {
    if (t === "replace")
      return n;
    if (t === "append")
      return i + n;
    throw new Error(`Unsupported action: ${t}`);
  }
  let o = i;
  for (let s = 0; s < e.length - 1; s++)
    o = o[e[s]];
  const r = e[e.length - 1];
  switch (t) {
    case "replace":
      o[r] = n;
      break;
    case "append":
      o[r] += n;
      break;
    case "add":
      Array.isArray(o) ? o.splice(Number(r), 0, n) : o[r] = n;
      break;
    case "delete":
      Array.isArray(o) ? o.splice(Number(r), 1) : delete o[r];
      break;
    default:
      throw new Error(`Unknown action: ${t}`);
  }
  return i;
}
function c1(i, e) {
  return e.forEach(([t, n, o]) => {
    i = u1(i, n, t, o);
  }), i;
}
async function Ka(i, e, t, n = f1) {
  let o = (Array.isArray(i) ? i : [i]).map(
    (r) => r.blob
  );
  return await Promise.all(
    await n(e, o, void 0, t).then(
      async (r) => {
        if (r.error)
          throw new Error(r.error);
        return r.files ? r.files.map((s, a) => new Eo({
          ...i[a],
          path: s,
          url: e + "/file=" + s
        })) : [];
      }
    )
  );
}
async function Xa(i, e) {
  return i.map(
    (t, n) => new Eo({
      path: t.name,
      orig_name: t.name,
      blob: t,
      size: t.size,
      mime_type: t.type,
      is_stream: e
    })
  );
}
class Eo {
  constructor({
    path: e,
    url: t,
    orig_name: n,
    size: o,
    blob: r,
    is_stream: s,
    mime_type: a,
    alt_text: l
  }) {
    this.meta = { _type: "gradio.FileData" }, this.path = e, this.url = t, this.orig_name = n, this.size = o, this.blob = t ? void 0 : r, this.is_stream = s, this.mime_type = a, this.alt_text = l;
  }
}
const Ya = "This application is too busy. Keep trying!", an = "Connection errored out.";
let Qa;
function d1(i, e) {
  return { post_data: t, upload_files: n, client: o, handle_blob: r };
  async function t(s, a, l) {
    const u = { "Content-Type": "application/json" };
    l && (u.Authorization = `Bearer ${l}`);
    try {
      var c = await i(s, {
        method: "POST",
        body: JSON.stringify(a),
        headers: u
      });
    } catch {
      return [{ error: an }, 500];
    }
    let d, _;
    try {
      d = await c.json(), _ = c.status;
    } catch (f) {
      d = { error: `Could not parse server response: ${f}` }, _ = 500;
    }
    return [d, _];
  }
  async function n(s, a, l, u) {
    const c = {};
    l && (c.Authorization = `Bearer ${l}`);
    const d = 1e3, _ = [];
    for (let h = 0; h < a.length; h += d) {
      const p = a.slice(h, h + d), g = new FormData();
      p.forEach((k) => {
        g.append("files", k);
      });
      try {
        const k = u ? `${s}/upload?upload_id=${u}` : `${s}/upload`;
        var f = await i(k, {
          method: "POST",
          body: g,
          headers: c
        });
      } catch {
        return { error: an };
      }
      const m = await f.json();
      _.push(...m);
    }
    return { files: _ };
  }
  async function o(s, a = {}) {
    return new Promise(async (l) => {
      const { status_callback: u, hf_token: c } = a, d = {
        predict: Y,
        submit: J,
        view_api: K,
        component_server: V
      };
      if ((typeof window > "u" || !("WebSocket" in window)) && !global.Websocket) {
        const I = await import("./wrapper-6f348d45-DjpFDl6n.js");
        Qa = (await import("./__vite-browser-external-DYxpcVy9.js")).Blob, global.WebSocket = I.WebSocket;
      }
      const { ws_protocol: _, http_protocol: f, host: h, space_id: p } = await r1(s, c), g = Math.random().toString(36).substring(2), m = {};
      let k = !1, w = {}, S = {}, v = null;
      const b = {}, L = /* @__PURE__ */ new Set();
      let E, D = {}, P = !1;
      c && p && (P = await h1(p, c));
      async function F(I) {
        if (E = I, window.location.protocol === "https:" && (E.root = E.root.replace("http://", "https://")), D = l1((I == null ? void 0 : I.dependencies) || []), E.auth_required)
          return {
            config: E,
            ...d
          };
        try {
          q = await K(E);
        } catch ($) {
          console.error(`Could not get api details: ${$.message}`);
        }
        return {
          config: E,
          ...d
        };
      }
      let q;
      async function N(I) {
        if (u && u(I), I.status === "running")
          try {
            E = await fl(
              i,
              `${f}//${h}`,
              c
            );
            const $ = await F(E);
            l($);
          } catch ($) {
            console.error($), u && u({
              status: "error",
              message: "Could not load this space.",
              load_status: "error",
              detail: "NOT_FOUND"
            });
          }
      }
      try {
        E = await fl(
          i,
          `${f}//${h}`,
          c
        );
        const I = await F(E);
        l(I);
      } catch (I) {
        console.error(I), p ? Bs(
          p,
          Ja.test(p) ? "space_name" : "subdomain",
          N
        ) : u && u({
          status: "error",
          message: "Could not load this space.",
          load_status: "error",
          detail: "NOT_FOUND"
        });
      }
      function Y(I, $, te) {
        let M = !1, C = !1, R;
        if (typeof I == "number")
          R = E.dependencies[I];
        else {
          const j = I.replace(/^\//, "");
          R = E.dependencies[D[j]];
        }
        if (R.types.continuous)
          throw new Error(
            "Cannot call predict on this function as it may run forever. Use submit instead"
          );
        return new Promise((j, Q) => {
          const X = J(I, $, te);
          let B;
          X.on("data", (ue) => {
            C && (X.destroy(), j(ue)), M = !0, B = ue;
          }).on("status", (ue) => {
            ue.stage === "error" && Q(ue), ue.stage === "complete" && (C = !0, M && (X.destroy(), j(B)));
          });
        });
      }
      function J(I, $, te, M = null) {
        let C, R;
        if (typeof I == "number")
          C = I, R = q.unnamed_endpoints[C];
        else {
          const H = I.replace(/^\//, "");
          C = D[H], R = q.named_endpoints[I.trim()];
        }
        if (typeof C != "number")
          throw new Error(
            "There is no endpoint matching that name of fn_index matching that number."
          );
        let j, Q, X = E.protocol ?? "ws";
        const B = typeof I == "number" ? "/predict" : I;
        let ue, A = null, de = !1;
        const fe = {};
        let _e = "";
        typeof window < "u" && (_e = new URLSearchParams(window.location.search).toString()), r(`${E.root}`, $, R, c).then(
          (H) => {
            if (ue = {
              data: H || [],
              event_data: te,
              fn_index: C,
              trigger_id: M
            }, m1(C, E))
              ne({
                type: "status",
                endpoint: B,
                stage: "pending",
                queue: !1,
                fn_index: C,
                time: /* @__PURE__ */ new Date()
              }), t(
                `${E.root}/run${B.startsWith("/") ? B : `/${B}`}${_e ? "?" + _e : ""}`,
                {
                  ...ue,
                  session_hash: g
                },
                c
              ).then(([le, x]) => {
                const he = le.data;
                x == 200 ? (ne({
                  type: "data",
                  endpoint: B,
                  fn_index: C,
                  data: he,
                  time: /* @__PURE__ */ new Date()
                }), ne({
                  type: "status",
                  endpoint: B,
                  fn_index: C,
                  stage: "complete",
                  eta: le.average_duration,
                  queue: !1,
                  time: /* @__PURE__ */ new Date()
                })) : ne({
                  type: "status",
                  stage: "error",
                  endpoint: B,
                  fn_index: C,
                  message: le.error,
                  queue: !1,
                  time: /* @__PURE__ */ new Date()
                });
              }).catch((le) => {
                ne({
                  type: "status",
                  stage: "error",
                  message: le.message,
                  endpoint: B,
                  fn_index: C,
                  queue: !1,
                  time: /* @__PURE__ */ new Date()
                });
              });
            else if (X == "ws") {
              ne({
                type: "status",
                stage: "pending",
                queue: !0,
                endpoint: B,
                fn_index: C,
                time: /* @__PURE__ */ new Date()
              });
              let le = new URL(`${_}://${Ga(
                h,
                E.path,
                !0
              )}
							/queue/join${_e ? "?" + _e : ""}`);
              P && le.searchParams.set("__sign", P), j = new WebSocket(le), j.onclose = (x) => {
                x.wasClean || ne({
                  type: "status",
                  stage: "error",
                  broken: !0,
                  message: an,
                  queue: !0,
                  endpoint: B,
                  fn_index: C,
                  time: /* @__PURE__ */ new Date()
                });
              }, j.onmessage = function(x) {
                const he = JSON.parse(x.data), { type: me, status: oe, data: se } = fs(
                  he,
                  m[C]
                );
                if (me === "update" && oe && !de)
                  ne({
                    type: "status",
                    endpoint: B,
                    fn_index: C,
                    time: /* @__PURE__ */ new Date(),
                    ...oe
                  }), oe.stage === "error" && j.close();
                else if (me === "hash") {
                  j.send(JSON.stringify({ fn_index: C, session_hash: g }));
                  return;
                } else
                  me === "data" ? j.send(JSON.stringify({ ...ue, session_hash: g })) : me === "complete" ? de = oe : me === "log" ? ne({
                    type: "log",
                    log: se.log,
                    level: se.level,
                    endpoint: B,
                    fn_index: C
                  }) : me === "generating" && ne({
                    type: "status",
                    time: /* @__PURE__ */ new Date(),
                    ...oe,
                    stage: oe == null ? void 0 : oe.stage,
                    queue: !0,
                    endpoint: B,
                    fn_index: C
                  });
                se && (ne({
                  type: "data",
                  time: /* @__PURE__ */ new Date(),
                  data: se.data,
                  endpoint: B,
                  fn_index: C
                }), de && (ne({
                  type: "status",
                  time: /* @__PURE__ */ new Date(),
                  ...de,
                  stage: oe == null ? void 0 : oe.stage,
                  queue: !0,
                  endpoint: B,
                  fn_index: C
                }), j.close()));
              }, ll(E.version || "2.0.0", "3.6") < 0 && addEventListener(
                "open",
                () => j.send(JSON.stringify({ hash: g }))
              );
            } else if (X == "sse") {
              ne({
                type: "status",
                stage: "pending",
                queue: !0,
                endpoint: B,
                fn_index: C,
                time: /* @__PURE__ */ new Date()
              });
              var re = new URLSearchParams({
                fn_index: C.toString(),
                session_hash: g
              }).toString();
              let le = new URL(
                `${E.root}/queue/join?${_e ? _e + "&" : ""}${re}`
              );
              Q = e(le), Q.onmessage = async function(x) {
                const he = JSON.parse(x.data), { type: me, status: oe, data: se } = fs(
                  he,
                  m[C]
                );
                if (me === "update" && oe && !de)
                  ne({
                    type: "status",
                    endpoint: B,
                    fn_index: C,
                    time: /* @__PURE__ */ new Date(),
                    ...oe
                  }), oe.stage === "error" && Q.close();
                else if (me === "data") {
                  A = he.event_id;
                  let [Ae, on] = await t(
                    `${E.root}/queue/data`,
                    {
                      ...ue,
                      session_hash: g,
                      event_id: A
                    },
                    c
                  );
                  on !== 200 && (ne({
                    type: "status",
                    stage: "error",
                    message: an,
                    queue: !0,
                    endpoint: B,
                    fn_index: C,
                    time: /* @__PURE__ */ new Date()
                  }), Q.close());
                } else
                  me === "complete" ? de = oe : me === "log" ? ne({
                    type: "log",
                    log: se.log,
                    level: se.level,
                    endpoint: B,
                    fn_index: C
                  }) : me === "generating" && ne({
                    type: "status",
                    time: /* @__PURE__ */ new Date(),
                    ...oe,
                    stage: oe == null ? void 0 : oe.stage,
                    queue: !0,
                    endpoint: B,
                    fn_index: C
                  });
                se && (ne({
                  type: "data",
                  time: /* @__PURE__ */ new Date(),
                  data: se.data,
                  endpoint: B,
                  fn_index: C
                }), de && (ne({
                  type: "status",
                  time: /* @__PURE__ */ new Date(),
                  ...de,
                  stage: oe == null ? void 0 : oe.stage,
                  queue: !0,
                  endpoint: B,
                  fn_index: C
                }), Q.close()));
              };
            } else
              (X == "sse_v1" || X == "sse_v2" || X == "sse_v2.1" || X == "sse_v3") && (ne({
                type: "status",
                stage: "pending",
                queue: !0,
                endpoint: B,
                fn_index: C,
                time: /* @__PURE__ */ new Date()
              }), t(
                `${E.root}/queue/join?${_e}`,
                {
                  ...ue,
                  session_hash: g
                },
                c
              ).then(([le, x]) => {
                if (x === 503)
                  ne({
                    type: "status",
                    stage: "error",
                    message: Ya,
                    queue: !0,
                    endpoint: B,
                    fn_index: C,
                    time: /* @__PURE__ */ new Date()
                  });
                else if (x !== 200)
                  ne({
                    type: "status",
                    stage: "error",
                    message: an,
                    queue: !0,
                    endpoint: B,
                    fn_index: C,
                    time: /* @__PURE__ */ new Date()
                  });
                else {
                  A = le.event_id;
                  let he = async function(me) {
                    try {
                      const { type: oe, status: se, data: Ae } = fs(
                        me,
                        m[C]
                      );
                      if (oe == "heartbeat")
                        return;
                      if (oe === "update" && se && !de)
                        ne({
                          type: "status",
                          endpoint: B,
                          fn_index: C,
                          time: /* @__PURE__ */ new Date(),
                          ...se
                        });
                      else if (oe === "complete")
                        de = se;
                      else if (oe == "unexpected_error")
                        console.error("Unexpected error", se == null ? void 0 : se.message), ne({
                          type: "status",
                          stage: "error",
                          message: (se == null ? void 0 : se.message) || "An Unexpected Error Occurred!",
                          queue: !0,
                          endpoint: B,
                          fn_index: C,
                          time: /* @__PURE__ */ new Date()
                        });
                      else if (oe === "log") {
                        ne({
                          type: "log",
                          log: Ae.log,
                          level: Ae.level,
                          endpoint: B,
                          fn_index: C
                        });
                        return;
                      } else
                        oe === "generating" && (ne({
                          type: "status",
                          time: /* @__PURE__ */ new Date(),
                          ...se,
                          stage: se == null ? void 0 : se.stage,
                          queue: !0,
                          endpoint: B,
                          fn_index: C
                        }), Ae && ["sse_v2", "sse_v2.1", "sse_v3"].includes(X) && Lt(A, Ae));
                      Ae && (ne({
                        type: "data",
                        time: /* @__PURE__ */ new Date(),
                        data: Ae.data,
                        endpoint: B,
                        fn_index: C
                      }), de && ne({
                        type: "status",
                        time: /* @__PURE__ */ new Date(),
                        ...de,
                        stage: se == null ? void 0 : se.stage,
                        queue: !0,
                        endpoint: B,
                        fn_index: C
                      })), ((se == null ? void 0 : se.stage) === "complete" || (se == null ? void 0 : se.stage) === "error") && (b[A] && delete b[A], A in S && delete S[A]);
                    } catch (oe) {
                      console.error("Unexpected client exception", oe), ne({
                        type: "status",
                        stage: "error",
                        message: "An Unexpected Error Occurred!",
                        queue: !0,
                        endpoint: B,
                        fn_index: C,
                        time: /* @__PURE__ */ new Date()
                      }), ["sse_v2", "sse_v2.1"].includes(X) && T();
                    }
                  };
                  A in w && (w[A].forEach(
                    (me) => he(me)
                  ), delete w[A]), b[A] = he, L.add(A), k || O();
                }
              }));
          }
        );
        function Lt(H, re) {
          !S[H] ? (S[H] = [], re.data.forEach((x, he) => {
            S[H][he] = x;
          })) : re.data.forEach((x, he) => {
            let me = c1(
              S[H][he],
              x
            );
            S[H][he] = me, re.data[he] = me;
          });
        }
        function ne(H) {
          const le = fe[H.type] || [];
          le == null || le.forEach((x) => x(H));
        }
        function Tt(H, re) {
          const le = fe, x = le[H] || [];
          return le[H] = x, x == null || x.push(re), { on: Tt, off: Nt, cancel: z, destroy: ge };
        }
        function Nt(H, re) {
          const le = fe;
          let x = le[H] || [];
          return x = x == null ? void 0 : x.filter((he) => he !== re), le[H] = x, { on: Tt, off: Nt, cancel: z, destroy: ge };
        }
        async function z() {
          const H = {
            stage: "complete",
            queue: !1,
            time: /* @__PURE__ */ new Date()
          };
          de = H, ne({
            ...H,
            type: "status",
            endpoint: B,
            fn_index: C
          });
          let re = {};
          X === "ws" ? (j && j.readyState === 0 ? j.addEventListener("open", () => {
            j.close();
          }) : j.close(), re = { fn_index: C, session_hash: g }) : (Q.close(), re = { event_id: A });
          try {
            await i(`${E.root}/reset`, {
              headers: { "Content-Type": "application/json" },
              method: "POST",
              body: JSON.stringify(re)
            });
          } catch {
            console.warn(
              "The `/reset` endpoint could not be called. Subsequent endpoint results may be unreliable."
            );
          }
        }
        function ge() {
          for (const H in fe)
            fe[H].forEach((re) => {
              Nt(H, re);
            });
        }
        return {
          on: Tt,
          off: Nt,
          cancel: z,
          destroy: ge
        };
      }
      function O() {
        k = !0;
        let I = new URLSearchParams({
          session_hash: g
        }).toString(), $ = new URL(`${E.root}/queue/data?${I}`);
        v = e($), v.onmessage = async function(te) {
          let M = JSON.parse(te.data);
          const C = M.event_id;
          if (!C)
            await Promise.all(
              Object.keys(b).map(
                (R) => b[R](M)
              )
            );
          else if (b[C]) {
            M.msg === "process_completed" && ["sse", "sse_v1", "sse_v2", "sse_v2.1"].includes(E.protocol) && (L.delete(C), L.size === 0 && T());
            let R = b[C];
            window.setTimeout(R, 0, M);
          } else
            w[C] || (w[C] = []), w[C].push(M);
          M.msg === "close_stream" && T();
        }, v.onerror = async function(te) {
          await Promise.all(
            Object.keys(b).map(
              (M) => b[M]({
                msg: "unexpected_error",
                message: an
              })
            )
          ), T();
        };
      }
      function T() {
        k = !1, v == null || v.close();
      }
      async function V(I, $, te) {
        var M;
        const C = { "Content-Type": "application/json" };
        c && (C.Authorization = `Bearer ${c}`);
        let R, j = E.components.find(
          (B) => B.id === I
        );
        (M = j == null ? void 0 : j.props) != null && M.root_url ? R = j.props.root_url : R = E.root;
        const Q = await i(
          `${R}/component_server/`,
          {
            method: "POST",
            body: JSON.stringify({
              data: te,
              component_id: I,
              fn_name: $,
              session_hash: g
            }),
            headers: C
          }
        );
        if (!Q.ok)
          throw new Error(
            "Could not connect to component server: " + Q.statusText
          );
        return await Q.json();
      }
      async function K(I) {
        if (q)
          return q;
        const $ = { "Content-Type": "application/json" };
        c && ($.Authorization = `Bearer ${c}`);
        let te;
        if (ll(I.version || "2.0.0", "3.30") < 0 ? te = await i(
          "https://gradio-space-api-fetcher-v2.hf.space/api",
          {
            method: "POST",
            body: JSON.stringify({
              serialize: !1,
              config: JSON.stringify(I)
            }),
            headers: $
          }
        ) : te = await i(`${I.root}/info`, {
          headers: $
        }), !te.ok)
          throw new Error(an);
        let M = await te.json();
        return "api" in M && (M = M.api), M.named_endpoints["/predict"] && !M.unnamed_endpoints[0] && (M.unnamed_endpoints[0] = M.named_endpoints["/predict"]), _1(M, I, D);
      }
    });
  }
  async function r(s, a, l, u) {
    const c = await Ns(
      a,
      void 0,
      [],
      !0,
      l
    );
    return Promise.all(
      c.map(async ({ path: d, blob: _, type: f }) => {
        if (_) {
          const h = (await n(s, [_], u)).files[0];
          return { path: d, file_url: h, type: f, name: _ == null ? void 0 : _.name };
        }
        return { path: d, type: f };
      })
    ).then((d) => (d.forEach(({ path: _, file_url: f, type: h, name: p }) => {
      if (h === "Gallery")
        dl(a, f, _);
      else if (f) {
        const g = new Eo({ path: f, orig_name: p });
        dl(a, g, _);
      }
    }), a));
  }
}
const { post_data: Qg, upload_files: f1, client: $g, handle_blob: xg } = d1(
  fetch,
  (...i) => new EventSource(...i)
);
function ul(i, e, t, n) {
  switch (i.type) {
    case "string":
      return "string";
    case "boolean":
      return "boolean";
    case "number":
      return "number";
  }
  if (t === "JSONSerializable" || t === "StringSerializable")
    return "any";
  if (t === "ListStringSerializable")
    return "string[]";
  if (e === "Image")
    return n === "parameter" ? "Blob | File | Buffer" : "string";
  if (t === "FileSerializable")
    return (i == null ? void 0 : i.type) === "array" ? n === "parameter" ? "(Blob | File | Buffer)[]" : "{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}[]" : n === "parameter" ? "Blob | File | Buffer" : "{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}";
  if (t === "GallerySerializable")
    return n === "parameter" ? "[(Blob | File | Buffer), (string | null)][]" : "[{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}, (string | null))][]";
}
function cl(i, e) {
  return e === "GallerySerializable" ? "array of [file, label] tuples" : e === "ListStringSerializable" ? "array of strings" : e === "FileSerializable" ? "array of files or single file" : i.description;
}
function _1(i, e, t) {
  const n = {
    named_endpoints: {},
    unnamed_endpoints: {}
  };
  for (const o in i) {
    const r = i[o];
    for (const s in r) {
      const a = e.dependencies[s] ? s : t[s.replace("/", "")], l = r[s];
      n[o][s] = {}, n[o][s].parameters = {}, n[o][s].returns = {}, n[o][s].type = e.dependencies[a].types, n[o][s].parameters = l.parameters.map(
        ({ label: u, component: c, type: d, serializer: _ }) => ({
          label: u,
          component: c,
          type: ul(d, c, _, "parameter"),
          description: cl(d, _)
        })
      ), n[o][s].returns = l.returns.map(
        ({ label: u, component: c, type: d, serializer: _ }) => ({
          label: u,
          component: c,
          type: ul(d, c, _, "return"),
          description: cl(d, _)
        })
      );
    }
  }
  return n;
}
async function h1(i, e) {
  try {
    return (await (await fetch(`https://huggingface.co/api/spaces/${i}/jwt`, {
      headers: {
        Authorization: `Bearer ${e}`
      }
    })).json()).token || !1;
  } catch (t) {
    return console.error(t), !1;
  }
}
function dl(i, e, t) {
  for (; t.length > 1; )
    i = i[t.shift()];
  i[t.shift()] = e;
}
async function Ns(i, e = void 0, t = [], n = !1, o = void 0) {
  if (Array.isArray(i)) {
    let r = [];
    return await Promise.all(
      i.map(async (s, a) => {
        var l;
        let u = t.slice();
        u.push(a);
        const c = await Ns(
          i[a],
          n ? ((l = o == null ? void 0 : o.parameters[a]) == null ? void 0 : l.component) || void 0 : e,
          u,
          !1,
          o
        );
        r = r.concat(c);
      })
    ), r;
  } else {
    if (globalThis.Buffer && i instanceof globalThis.Buffer)
      return [
        {
          path: t,
          blob: e === "Image" ? !1 : new Qa([i]),
          type: e
        }
      ];
    if (typeof i == "object") {
      let r = [];
      for (let s in i)
        if (i.hasOwnProperty(s)) {
          let a = t.slice();
          a.push(s), r = r.concat(
            await Ns(
              i[s],
              void 0,
              a,
              !1,
              o
            )
          );
        }
      return r;
    }
  }
  return [];
}
function m1(i, e) {
  var t, n, o, r;
  return !(((n = (t = e == null ? void 0 : e.dependencies) == null ? void 0 : t[i]) == null ? void 0 : n.queue) === null ? e.enable_queue : (r = (o = e == null ? void 0 : e.dependencies) == null ? void 0 : o[i]) != null && r.queue) || !1;
}
async function fl(i, e, t) {
  const n = {};
  if (t && (n.Authorization = `Bearer ${t}`), typeof window < "u" && window.gradio_config && location.origin !== "http://localhost:9876" && !window.gradio_config.dev_mode) {
    const o = window.gradio_config.root, r = window.gradio_config;
    return r.root = Ga(e, r.root, !1), { ...r, path: o };
  } else if (e) {
    let o = await i(`${e}/config`, {
      headers: n
    });
    if (o.status === 200) {
      const r = await o.json();
      return r.path = r.path ?? "", r.root = e, r;
    }
    throw new Error("Could not get config.");
  }
  throw new Error("No config or app endpoint found");
}
async function Bs(i, e, t) {
  let n = e === "subdomain" ? `https://huggingface.co/api/spaces/by-subdomain/${i}` : `https://huggingface.co/api/spaces/${i}`, o, r;
  try {
    if (o = await fetch(n), r = o.status, r !== 200)
      throw new Error();
    o = await o.json();
  } catch {
    t({
      status: "error",
      load_status: "error",
      message: "Could not get space status",
      detail: "NOT_FOUND"
    });
    return;
  }
  if (!o || r !== 200)
    return;
  const {
    runtime: { stage: s },
    id: a
  } = o;
  switch (s) {
    case "STOPPED":
    case "SLEEPING":
      t({
        status: "sleeping",
        load_status: "pending",
        message: "Space is asleep. Waking it up...",
        detail: s
      }), setTimeout(() => {
        Bs(i, e, t);
      }, 1e3);
      break;
    case "PAUSED":
      t({
        status: "paused",
        load_status: "error",
        message: "This space has been paused by the author. If you would like to try this demo, consider duplicating the space.",
        detail: s,
        discussions_enabled: await al(a)
      });
      break;
    case "RUNNING":
    case "RUNNING_BUILDING":
      t({
        status: "running",
        load_status: "complete",
        message: "",
        detail: s
      });
      break;
    case "BUILDING":
      t({
        status: "building",
        load_status: "pending",
        message: "Space is building...",
        detail: s
      }), setTimeout(() => {
        Bs(i, e, t);
      }, 1e3);
      break;
    default:
      t({
        status: "space_error",
        load_status: "error",
        message: "This space is experiencing an issue.",
        detail: s,
        discussions_enabled: await al(a)
      });
      break;
  }
}
function fs(i, e) {
  switch (i.msg) {
    case "send_data":
      return { type: "data" };
    case "send_hash":
      return { type: "hash" };
    case "queue_full":
      return {
        type: "update",
        status: {
          queue: !0,
          message: Ya,
          stage: "error",
          code: i.code,
          success: i.success
        }
      };
    case "heartbeat":
      return {
        type: "heartbeat"
      };
    case "unexpected_error":
      return {
        type: "unexpected_error",
        status: {
          queue: !0,
          message: i.message,
          stage: "error",
          success: !1
        }
      };
    case "estimation":
      return {
        type: "update",
        status: {
          queue: !0,
          stage: e || "pending",
          code: i.code,
          size: i.queue_size,
          position: i.rank,
          eta: i.rank_eta,
          success: i.success
        }
      };
    case "progress":
      return {
        type: "update",
        status: {
          queue: !0,
          stage: "pending",
          code: i.code,
          progress_data: i.progress_data,
          success: i.success
        }
      };
    case "log":
      return { type: "log", data: i };
    case "process_generating":
      return {
        type: "generating",
        status: {
          queue: !0,
          message: i.success ? null : i.output.error,
          stage: i.success ? "generating" : "error",
          code: i.code,
          progress_data: i.progress_data,
          eta: i.average_duration
        },
        data: i.success ? i.output : null
      };
    case "process_completed":
      return "error" in i.output ? {
        type: "update",
        status: {
          queue: !0,
          message: i.output.error,
          stage: "error",
          code: i.code,
          success: i.success
        }
      } : {
        type: "complete",
        status: {
          queue: !0,
          message: i.success ? void 0 : i.output.error,
          stage: i.success ? "complete" : "error",
          code: i.code,
          progress_data: i.progress_data
        },
        data: i.success ? i.output : null
      };
    case "process_starts":
      return {
        type: "update",
        status: {
          queue: !0,
          stage: "pending",
          code: i.code,
          size: i.rank,
          position: 0,
          success: i.success,
          eta: i.eta
        }
      };
  }
  return { type: "none", status: { stage: "error", queue: !0 } };
}
const {
  SvelteComponent: p1,
  append: He,
  attr: _n,
  detach: $a,
  element: hn,
  init: g1,
  insert: xa,
  noop: _l,
  safe_not_equal: b1,
  set_data: mo,
  set_style: _s,
  space: Ws,
  text: Hn,
  toggle_class: hl
} = window.__gradio__svelte__internal, { onMount: v1, createEventDispatcher: w1, getContext: y1 } = window.__gradio__svelte__internal;
function ml(i) {
  let e, t, n, o, r = Ci(
    /*file_to_display*/
    i[2]
  ) + "", s, a, l, u, c = (
    /*file_to_display*/
    i[2].orig_name + ""
  ), d;
  return {
    c() {
      e = hn("div"), t = hn("span"), n = hn("div"), o = hn("progress"), s = Hn(r), l = Ws(), u = hn("span"), d = Hn(c), _s(o, "visibility", "hidden"), _s(o, "height", "0"), _s(o, "width", "0"), o.value = a = Ci(
        /*file_to_display*/
        i[2]
      ), _n(o, "max", "100"), _n(o, "class", "svelte-cr2edf"), _n(n, "class", "progress-bar svelte-cr2edf"), _n(u, "class", "file-name svelte-cr2edf"), _n(e, "class", "file svelte-cr2edf");
    },
    m(_, f) {
      xa(_, e, f), He(e, t), He(t, n), He(n, o), He(o, s), He(e, l), He(e, u), He(u, d);
    },
    p(_, f) {
      f & /*file_to_display*/
      4 && r !== (r = Ci(
        /*file_to_display*/
        _[2]
      ) + "") && mo(s, r), f & /*file_to_display*/
      4 && a !== (a = Ci(
        /*file_to_display*/
        _[2]
      )) && (o.value = a), f & /*file_to_display*/
      4 && c !== (c = /*file_to_display*/
      _[2].orig_name + "") && mo(d, c);
    },
    d(_) {
      _ && $a(e);
    }
  };
}
function k1(i) {
  let e, t, n, o = (
    /*files_with_progress*/
    i[0].length + ""
  ), r, s, a = (
    /*files_with_progress*/
    i[0].length > 1 ? "files" : "file"
  ), l, u, c, d = (
    /*file_to_display*/
    i[2] && ml(i)
  );
  return {
    c() {
      e = hn("div"), t = hn("span"), n = Hn("Uploading "), r = Hn(o), s = Ws(), l = Hn(a), u = Hn("..."), c = Ws(), d && d.c(), _n(t, "class", "uploading svelte-cr2edf"), _n(e, "class", "wrap svelte-cr2edf"), hl(
        e,
        "progress",
        /*progress*/
        i[1]
      );
    },
    m(_, f) {
      xa(_, e, f), He(e, t), He(t, n), He(t, r), He(t, s), He(t, l), He(t, u), He(e, c), d && d.m(e, null);
    },
    p(_, [f]) {
      f & /*files_with_progress*/
      1 && o !== (o = /*files_with_progress*/
      _[0].length + "") && mo(r, o), f & /*files_with_progress*/
      1 && a !== (a = /*files_with_progress*/
      _[0].length > 1 ? "files" : "file") && mo(l, a), /*file_to_display*/
      _[2] ? d ? d.p(_, f) : (d = ml(_), d.c(), d.m(e, null)) : d && (d.d(1), d = null), f & /*progress*/
      2 && hl(
        e,
        "progress",
        /*progress*/
        _[1]
      );
    },
    i: _l,
    o: _l,
    d(_) {
      _ && $a(e), d && d.d();
    }
  };
}
function Ci(i) {
  return i.progress * 100 / (i.size || 0) || 0;
}
function C1(i) {
  let e = 0;
  return i.forEach((t) => {
    e += Ci(t);
  }), document.documentElement.style.setProperty("--upload-progress-width", (e / i.length).toFixed(2) + "%"), e / i.length;
}
function S1(i, e, t) {
  var n = this && this.__awaiter || function(p, g, m, k) {
    function w(S) {
      return S instanceof m ? S : new m(function(v) {
        v(S);
      });
    }
    return new (m || (m = Promise))(function(S, v) {
      function b(D) {
        try {
          E(k.next(D));
        } catch (P) {
          v(P);
        }
      }
      function L(D) {
        try {
          E(k.throw(D));
        } catch (P) {
          v(P);
        }
      }
      function E(D) {
        D.done ? S(D.value) : w(D.value).then(b, L);
      }
      E((k = k.apply(p, g || [])).next());
    });
  };
  let { upload_id: o } = e, { root: r } = e, { files: s } = e, a, l = !1, u, c, d = s.map((p) => Object.assign(Object.assign({}, p), { progress: 0 }));
  const _ = w1();
  function f(p, g) {
    t(0, d = d.map((m) => (m.orig_name === p && (m.progress += g), m)));
  }
  const h = y1("EventSource_factory");
  return v1(() => {
    a = h(new URL(`${r}/upload_progress?upload_id=${o}`)), a.onmessage = function(p) {
      return n(this, void 0, void 0, function* () {
        const g = JSON.parse(p.data);
        l || t(1, l = !0), g.msg === "done" ? (a.close(), _("done")) : (t(6, u = g), f(g.orig_name, g.chunk_size));
      });
    };
  }), i.$$set = (p) => {
    "upload_id" in p && t(3, o = p.upload_id), "root" in p && t(4, r = p.root), "files" in p && t(5, s = p.files);
  }, i.$$.update = () => {
    i.$$.dirty & /*files_with_progress*/
    1 && C1(d), i.$$.dirty & /*current_file_upload, files_with_progress*/
    65 && t(2, c = u || d[0]);
  }, [
    d,
    l,
    c,
    o,
    r,
    s,
    u
  ];
}
class E1 extends p1 {
  constructor(e) {
    super(), g1(this, e, S1, k1, b1, { upload_id: 3, root: 4, files: 5 });
  }
}
const {
  SvelteComponent: D1,
  append: pl,
  attr: Be,
  binding_callbacks: L1,
  bubble: un,
  check_outros: eu,
  create_component: R1,
  create_slot: tu,
  destroy_component: M1,
  detach: Do,
  element: Is,
  empty: nu,
  get_all_dirty_from_scope: iu,
  get_slot_changes: ou,
  group_outros: su,
  init: O1,
  insert: Lo,
  listen: Je,
  mount_component: q1,
  prevent_default: cn,
  run_all: A1,
  safe_not_equal: z1,
  set_style: ru,
  space: j1,
  stop_propagation: dn,
  toggle_class: qe,
  transition_in: en,
  transition_out: Rn,
  update_slot_base: lu
} = window.__gradio__svelte__internal, { createEventDispatcher: P1, tick: T1, getContext: N1 } = window.__gradio__svelte__internal;
function B1(i) {
  let e, t, n, o, r, s, a, l, u, c, d;
  const _ = (
    /*#slots*/
    i[22].default
  ), f = tu(
    _,
    i,
    /*$$scope*/
    i[21],
    null
  );
  return {
    c() {
      e = Is("button"), f && f.c(), t = j1(), n = Is("input"), Be(n, "aria-label", "file upload"), Be(n, "data-testid", "file-upload"), Be(n, "type", "file"), Be(n, "accept", o = /*accept_file_types*/
      i[14] || void 0), n.multiple = r = /*file_count*/
      i[6] === "multiple" || void 0, Be(n, "webkitdirectory", s = /*file_count*/
      i[6] === "directory" || void 0), Be(n, "mozdirectory", a = /*file_count*/
      i[6] === "directory" || void 0), Be(n, "class", "svelte-1s26xmt"), Be(e, "tabindex", l = /*hidden*/
      i[9] ? -1 : 0), Be(e, "class", "svelte-1s26xmt"), qe(
        e,
        "hidden",
        /*hidden*/
        i[9]
      ), qe(
        e,
        "center",
        /*center*/
        i[4]
      ), qe(
        e,
        "boundedheight",
        /*boundedheight*/
        i[3]
      ), qe(
        e,
        "flex",
        /*flex*/
        i[5]
      ), qe(
        e,
        "disable_click",
        /*disable_click*/
        i[7]
      ), ru(e, "height", "100%");
    },
    m(h, p) {
      Lo(h, e, p), f && f.m(e, null), pl(e, t), pl(e, n), i[30](n), u = !0, c || (d = [
        Je(
          n,
          "change",
          /*load_files_from_upload*/
          i[16]
        ),
        Je(e, "drag", dn(cn(
          /*drag_handler*/
          i[23]
        ))),
        Je(e, "dragstart", dn(cn(
          /*dragstart_handler*/
          i[24]
        ))),
        Je(e, "dragend", dn(cn(
          /*dragend_handler*/
          i[25]
        ))),
        Je(e, "dragover", dn(cn(
          /*dragover_handler*/
          i[26]
        ))),
        Je(e, "dragenter", dn(cn(
          /*dragenter_handler*/
          i[27]
        ))),
        Je(e, "dragleave", dn(cn(
          /*dragleave_handler*/
          i[28]
        ))),
        Je(e, "drop", dn(cn(
          /*drop_handler*/
          i[29]
        ))),
        Je(
          e,
          "click",
          /*open_file_upload*/
          i[11]
        ),
        Je(
          e,
          "drop",
          /*loadFilesFromDrop*/
          i[17]
        ),
        Je(
          e,
          "dragenter",
          /*updateDragging*/
          i[15]
        ),
        Je(
          e,
          "dragleave",
          /*updateDragging*/
          i[15]
        )
      ], c = !0);
    },
    p(h, p) {
      f && f.p && (!u || p[0] & /*$$scope*/
      2097152) && lu(
        f,
        _,
        h,
        /*$$scope*/
        h[21],
        u ? ou(
          _,
          /*$$scope*/
          h[21],
          p,
          null
        ) : iu(
          /*$$scope*/
          h[21]
        ),
        null
      ), (!u || p[0] & /*accept_file_types*/
      16384 && o !== (o = /*accept_file_types*/
      h[14] || void 0)) && Be(n, "accept", o), (!u || p[0] & /*file_count*/
      64 && r !== (r = /*file_count*/
      h[6] === "multiple" || void 0)) && (n.multiple = r), (!u || p[0] & /*file_count*/
      64 && s !== (s = /*file_count*/
      h[6] === "directory" || void 0)) && Be(n, "webkitdirectory", s), (!u || p[0] & /*file_count*/
      64 && a !== (a = /*file_count*/
      h[6] === "directory" || void 0)) && Be(n, "mozdirectory", a), (!u || p[0] & /*hidden*/
      512 && l !== (l = /*hidden*/
      h[9] ? -1 : 0)) && Be(e, "tabindex", l), (!u || p[0] & /*hidden*/
      512) && qe(
        e,
        "hidden",
        /*hidden*/
        h[9]
      ), (!u || p[0] & /*center*/
      16) && qe(
        e,
        "center",
        /*center*/
        h[4]
      ), (!u || p[0] & /*boundedheight*/
      8) && qe(
        e,
        "boundedheight",
        /*boundedheight*/
        h[3]
      ), (!u || p[0] & /*flex*/
      32) && qe(
        e,
        "flex",
        /*flex*/
        h[5]
      ), (!u || p[0] & /*disable_click*/
      128) && qe(
        e,
        "disable_click",
        /*disable_click*/
        h[7]
      );
    },
    i(h) {
      u || (en(f, h), u = !0);
    },
    o(h) {
      Rn(f, h), u = !1;
    },
    d(h) {
      h && Do(e), f && f.d(h), i[30](null), c = !1, A1(d);
    }
  };
}
function W1(i) {
  let e, t, n = !/*hidden*/
  i[9] && gl(i);
  return {
    c() {
      n && n.c(), e = nu();
    },
    m(o, r) {
      n && n.m(o, r), Lo(o, e, r), t = !0;
    },
    p(o, r) {
      /*hidden*/
      o[9] ? n && (su(), Rn(n, 1, 1, () => {
        n = null;
      }), eu()) : n ? (n.p(o, r), r[0] & /*hidden*/
      512 && en(n, 1)) : (n = gl(o), n.c(), en(n, 1), n.m(e.parentNode, e));
    },
    i(o) {
      t || (en(n), t = !0);
    },
    o(o) {
      Rn(n), t = !1;
    },
    d(o) {
      o && Do(e), n && n.d(o);
    }
  };
}
function I1(i) {
  let e, t, n, o, r;
  const s = (
    /*#slots*/
    i[22].default
  ), a = tu(
    s,
    i,
    /*$$scope*/
    i[21],
    null
  );
  return {
    c() {
      e = Is("button"), a && a.c(), Be(e, "tabindex", t = /*hidden*/
      i[9] ? -1 : 0), Be(e, "class", "svelte-1s26xmt"), qe(
        e,
        "hidden",
        /*hidden*/
        i[9]
      ), qe(
        e,
        "center",
        /*center*/
        i[4]
      ), qe(
        e,
        "boundedheight",
        /*boundedheight*/
        i[3]
      ), qe(
        e,
        "flex",
        /*flex*/
        i[5]
      ), ru(e, "height", "100%");
    },
    m(l, u) {
      Lo(l, e, u), a && a.m(e, null), n = !0, o || (r = Je(
        e,
        "click",
        /*paste_clipboard*/
        i[10]
      ), o = !0);
    },
    p(l, u) {
      a && a.p && (!n || u[0] & /*$$scope*/
      2097152) && lu(
        a,
        s,
        l,
        /*$$scope*/
        l[21],
        n ? ou(
          s,
          /*$$scope*/
          l[21],
          u,
          null
        ) : iu(
          /*$$scope*/
          l[21]
        ),
        null
      ), (!n || u[0] & /*hidden*/
      512 && t !== (t = /*hidden*/
      l[9] ? -1 : 0)) && Be(e, "tabindex", t), (!n || u[0] & /*hidden*/
      512) && qe(
        e,
        "hidden",
        /*hidden*/
        l[9]
      ), (!n || u[0] & /*center*/
      16) && qe(
        e,
        "center",
        /*center*/
        l[4]
      ), (!n || u[0] & /*boundedheight*/
      8) && qe(
        e,
        "boundedheight",
        /*boundedheight*/
        l[3]
      ), (!n || u[0] & /*flex*/
      32) && qe(
        e,
        "flex",
        /*flex*/
        l[5]
      );
    },
    i(l) {
      n || (en(a, l), n = !0);
    },
    o(l) {
      Rn(a, l), n = !1;
    },
    d(l) {
      l && Do(e), a && a.d(l), o = !1, r();
    }
  };
}
function gl(i) {
  let e, t;
  return e = new E1({
    props: {
      root: (
        /*root*/
        i[8]
      ),
      upload_id: (
        /*upload_id*/
        i[12]
      ),
      files: (
        /*file_data*/
        i[13]
      )
    }
  }), {
    c() {
      R1(e.$$.fragment);
    },
    m(n, o) {
      q1(e, n, o), t = !0;
    },
    p(n, o) {
      const r = {};
      o[0] & /*root*/
      256 && (r.root = /*root*/
      n[8]), o[0] & /*upload_id*/
      4096 && (r.upload_id = /*upload_id*/
      n[12]), o[0] & /*file_data*/
      8192 && (r.files = /*file_data*/
      n[13]), e.$set(r);
    },
    i(n) {
      t || (en(e.$$.fragment, n), t = !0);
    },
    o(n) {
      Rn(e.$$.fragment, n), t = !1;
    },
    d(n) {
      M1(e, n);
    }
  };
}
function U1(i) {
  let e, t, n, o;
  const r = [I1, W1, B1], s = [];
  function a(l, u) {
    return (
      /*filetype*/
      l[0] === "clipboard" ? 0 : (
        /*uploading*/
        l[1] && !/*hidden_upload*/
        l[2] ? 1 : 2
      )
    );
  }
  return e = a(i), t = s[e] = r[e](i), {
    c() {
      t.c(), n = nu();
    },
    m(l, u) {
      s[e].m(l, u), Lo(l, n, u), o = !0;
    },
    p(l, u) {
      let c = e;
      e = a(l), e === c ? s[e].p(l, u) : (su(), Rn(s[c], 1, 1, () => {
        s[c] = null;
      }), eu(), t = s[e], t ? t.p(l, u) : (t = s[e] = r[e](l), t.c()), en(t, 1), t.m(n.parentNode, n));
    },
    i(l) {
      o || (en(t), o = !0);
    },
    o(l) {
      Rn(t), o = !1;
    },
    d(l) {
      l && Do(n), s[e].d(l);
    }
  };
}
function F1(i, e, t) {
  if (!i || i === "*" || i === "file/*" || Array.isArray(i) && i.some((o) => o === "*" || o === "file/*"))
    return !0;
  let n;
  if (typeof i == "string")
    n = i.split(",").map((o) => o.trim());
  else if (Array.isArray(i))
    n = i;
  else
    return !1;
  return n.includes(e) || n.some((o) => {
    const [r] = o.split("/").map((s) => s.trim());
    return o.endsWith("/*") && t.startsWith(r + "/");
  });
}
function V1(i, e, t) {
  let { $$slots: n = {}, $$scope: o } = e;
  var r = this && this.__awaiter || function(C, R, j, Q) {
    function X(B) {
      return B instanceof j ? B : new j(function(ue) {
        ue(B);
      });
    }
    return new (j || (j = Promise))(function(B, ue) {
      function A(_e) {
        try {
          fe(Q.next(_e));
        } catch (Lt) {
          ue(Lt);
        }
      }
      function de(_e) {
        try {
          fe(Q.throw(_e));
        } catch (Lt) {
          ue(Lt);
        }
      }
      function fe(_e) {
        _e.done ? B(_e.value) : X(_e.value).then(A, de);
      }
      fe((Q = Q.apply(C, R || [])).next());
    });
  };
  let { filetype: s = null } = e, { dragging: a = !1 } = e, { boundedheight: l = !0 } = e, { center: u = !0 } = e, { flex: c = !0 } = e, { file_count: d = "single" } = e, { disable_click: _ = !1 } = e, { root: f } = e, { hidden: h = !1 } = e, { format: p = "file" } = e, { uploading: g = !1 } = e, { hidden_upload: m = null } = e, k, w, S;
  const v = N1("upload_files"), b = P1(), L = ["image", "video", "audio", "text", "file"], E = (C) => C.startsWith(".") || C.endsWith("/*") ? C : L.includes(C) ? C + "/*" : "." + C;
  function D() {
    t(18, a = !a);
  }
  function P() {
    navigator.clipboard.read().then((C) => r(this, void 0, void 0, function* () {
      for (let R = 0; R < C.length; R++) {
        const j = C[R].types.find((Q) => Q.startsWith("image/"));
        if (j) {
          C[R].getType(j).then((Q) => r(this, void 0, void 0, function* () {
            const X = new File([Q], `clipboard.${j.replace("image/", "")}`);
            yield N([X]);
          }));
          break;
        }
      }
    }));
  }
  function F() {
    _ || m && (t(2, m.value = "", m), m.click());
  }
  function q(C) {
    return r(this, void 0, void 0, function* () {
      yield T1(), t(12, k = Math.random().toString(36).substring(2, 15)), t(1, g = !0);
      const R = yield Ka(C, f, k, v);
      return b("load", d === "single" ? R == null ? void 0 : R[0] : R), t(1, g = !1), R || [];
    });
  }
  function N(C) {
    return r(this, void 0, void 0, function* () {
      if (!C.length)
        return;
      let R = C.map((j) => new File([j], j.name, { type: j.type }));
      return t(13, w = yield Xa(R)), yield q(w);
    });
  }
  function Y(C) {
    return r(this, void 0, void 0, function* () {
      const R = C.target;
      if (R.files)
        if (p != "blob")
          yield N(Array.from(R.files));
        else {
          if (d === "single") {
            b("load", R.files[0]);
            return;
          }
          b("load", R.files);
        }
    });
  }
  function J(C) {
    return r(this, void 0, void 0, function* () {
      var R;
      if (t(18, a = !1), !(!((R = C.dataTransfer) === null || R === void 0) && R.files))
        return;
      const j = Array.from(C.dataTransfer.files).filter((Q) => {
        const X = "." + Q.name.split(".").pop();
        return X && F1(S, X, Q.type) || (X && Array.isArray(s) ? s.includes(X) : X === s) ? !0 : (b("error", `Invalid file type only ${s} allowed.`), !1);
      });
      yield N(j);
    });
  }
  function O(C) {
    un.call(this, i, C);
  }
  function T(C) {
    un.call(this, i, C);
  }
  function V(C) {
    un.call(this, i, C);
  }
  function K(C) {
    un.call(this, i, C);
  }
  function I(C) {
    un.call(this, i, C);
  }
  function $(C) {
    un.call(this, i, C);
  }
  function te(C) {
    un.call(this, i, C);
  }
  function M(C) {
    L1[C ? "unshift" : "push"](() => {
      m = C, t(2, m);
    });
  }
  return i.$$set = (C) => {
    "filetype" in C && t(0, s = C.filetype), "dragging" in C && t(18, a = C.dragging), "boundedheight" in C && t(3, l = C.boundedheight), "center" in C && t(4, u = C.center), "flex" in C && t(5, c = C.flex), "file_count" in C && t(6, d = C.file_count), "disable_click" in C && t(7, _ = C.disable_click), "root" in C && t(8, f = C.root), "hidden" in C && t(9, h = C.hidden), "format" in C && t(19, p = C.format), "uploading" in C && t(1, g = C.uploading), "hidden_upload" in C && t(2, m = C.hidden_upload), "$$scope" in C && t(21, o = C.$$scope);
  }, i.$$.update = () => {
    i.$$.dirty[0] & /*filetype*/
    1 && (s == null ? t(14, S = null) : typeof s == "string" ? t(14, S = E(s)) : (t(0, s = s.map(E)), t(14, S = s.join(", "))));
  }, [
    s,
    g,
    m,
    l,
    u,
    c,
    d,
    _,
    f,
    h,
    P,
    F,
    k,
    w,
    S,
    D,
    Y,
    J,
    a,
    p,
    N,
    o,
    n,
    O,
    T,
    V,
    K,
    I,
    $,
    te,
    M
  ];
}
class H1 extends D1 {
  constructor(e) {
    super(), O1(
      this,
      e,
      V1,
      U1,
      z1,
      {
        filetype: 0,
        dragging: 18,
        boundedheight: 3,
        center: 4,
        flex: 5,
        file_count: 6,
        disable_click: 7,
        root: 8,
        hidden: 9,
        format: 19,
        uploading: 1,
        hidden_upload: 2,
        paste_clipboard: 10,
        open_file_upload: 11,
        load_files: 20
      },
      null,
      [-1, -1]
    );
  }
  get paste_clipboard() {
    return this.$$.ctx[10];
  }
  get open_file_upload() {
    return this.$$.ctx[11];
  }
  get load_files() {
    return this.$$.ctx[20];
  }
}
const {
  SvelteComponent: Z1,
  append: hs,
  attr: G1,
  check_outros: ms,
  create_component: qi,
  destroy_component: Ai,
  detach: J1,
  element: K1,
  group_outros: ps,
  init: X1,
  insert: Y1,
  mount_component: zi,
  safe_not_equal: Q1,
  set_style: bl,
  space: gs,
  toggle_class: vl,
  transition_in: Ue,
  transition_out: ft
} = window.__gradio__svelte__internal, { createEventDispatcher: $1 } = window.__gradio__svelte__internal;
function wl(i) {
  let e, t;
  return e = new Ri({
    props: {
      Icon: gd,
      label: (
        /*i18n*/
        i[4]("common.edit")
      )
    }
  }), e.$on(
    "click",
    /*click_handler*/
    i[6]
  ), {
    c() {
      qi(e.$$.fragment);
    },
    m(n, o) {
      zi(e, n, o), t = !0;
    },
    p(n, o) {
      const r = {};
      o & /*i18n*/
      16 && (r.label = /*i18n*/
      n[4]("common.edit")), e.$set(r);
    },
    i(n) {
      t || (Ue(e.$$.fragment, n), t = !0);
    },
    o(n) {
      ft(e.$$.fragment, n), t = !1;
    },
    d(n) {
      Ai(e, n);
    }
  };
}
function yl(i) {
  let e, t;
  return e = new Ri({
    props: {
      Icon: ba,
      label: (
        /*i18n*/
        i[4]("common.undo")
      )
    }
  }), e.$on(
    "click",
    /*click_handler_1*/
    i[7]
  ), {
    c() {
      qi(e.$$.fragment);
    },
    m(n, o) {
      zi(e, n, o), t = !0;
    },
    p(n, o) {
      const r = {};
      o & /*i18n*/
      16 && (r.label = /*i18n*/
      n[4]("common.undo")), e.$set(r);
    },
    i(n) {
      t || (Ue(e.$$.fragment, n), t = !0);
    },
    o(n) {
      ft(e.$$.fragment, n), t = !1;
    },
    d(n) {
      Ai(e, n);
    }
  };
}
function kl(i) {
  let e, t;
  return e = new Wa({
    props: {
      href: (
        /*download*/
        i[2]
      ),
      download: !0,
      $$slots: { default: [x1] },
      $$scope: { ctx: i }
    }
  }), {
    c() {
      qi(e.$$.fragment);
    },
    m(n, o) {
      zi(e, n, o), t = !0;
    },
    p(n, o) {
      const r = {};
      o & /*download*/
      4 && (r.href = /*download*/
      n[2]), o & /*$$scope, i18n*/
      528 && (r.$$scope = { dirty: o, ctx: n }), e.$set(r);
    },
    i(n) {
      t || (Ue(e.$$.fragment, n), t = !0);
    },
    o(n) {
      ft(e.$$.fragment, n), t = !1;
    },
    d(n) {
      Ai(e, n);
    }
  };
}
function x1(i) {
  let e, t;
  return e = new Ri({
    props: {
      Icon: ma,
      label: (
        /*i18n*/
        i[4]("common.download")
      )
    }
  }), {
    c() {
      qi(e.$$.fragment);
    },
    m(n, o) {
      zi(e, n, o), t = !0;
    },
    p(n, o) {
      const r = {};
      o & /*i18n*/
      16 && (r.label = /*i18n*/
      n[4]("common.download")), e.$set(r);
    },
    i(n) {
      t || (Ue(e.$$.fragment, n), t = !0);
    },
    o(n) {
      ft(e.$$.fragment, n), t = !1;
    },
    d(n) {
      Ai(e, n);
    }
  };
}
function em(i) {
  let e, t, n, o, r, s, a = (
    /*editable*/
    i[0] && wl(i)
  ), l = (
    /*undoable*/
    i[1] && yl(i)
  ), u = (
    /*download*/
    i[2] && kl(i)
  );
  return r = new Ri({
    props: {
      Icon: nd,
      label: (
        /*i18n*/
        i[4]("common.clear")
      )
    }
  }), r.$on(
    "click",
    /*click_handler_2*/
    i[8]
  ), {
    c() {
      e = K1("div"), a && a.c(), t = gs(), l && l.c(), n = gs(), u && u.c(), o = gs(), qi(r.$$.fragment), G1(e, "class", "svelte-1wj0ocy"), vl(e, "not-absolute", !/*absolute*/
      i[3]), bl(
        e,
        "position",
        /*absolute*/
        i[3] ? "absolute" : "static"
      );
    },
    m(c, d) {
      Y1(c, e, d), a && a.m(e, null), hs(e, t), l && l.m(e, null), hs(e, n), u && u.m(e, null), hs(e, o), zi(r, e, null), s = !0;
    },
    p(c, [d]) {
      /*editable*/
      c[0] ? a ? (a.p(c, d), d & /*editable*/
      1 && Ue(a, 1)) : (a = wl(c), a.c(), Ue(a, 1), a.m(e, t)) : a && (ps(), ft(a, 1, 1, () => {
        a = null;
      }), ms()), /*undoable*/
      c[1] ? l ? (l.p(c, d), d & /*undoable*/
      2 && Ue(l, 1)) : (l = yl(c), l.c(), Ue(l, 1), l.m(e, n)) : l && (ps(), ft(l, 1, 1, () => {
        l = null;
      }), ms()), /*download*/
      c[2] ? u ? (u.p(c, d), d & /*download*/
      4 && Ue(u, 1)) : (u = kl(c), u.c(), Ue(u, 1), u.m(e, o)) : u && (ps(), ft(u, 1, 1, () => {
        u = null;
      }), ms());
      const _ = {};
      d & /*i18n*/
      16 && (_.label = /*i18n*/
      c[4]("common.clear")), r.$set(_), (!s || d & /*absolute*/
      8) && vl(e, "not-absolute", !/*absolute*/
      c[3]), d & /*absolute*/
      8 && bl(
        e,
        "position",
        /*absolute*/
        c[3] ? "absolute" : "static"
      );
    },
    i(c) {
      s || (Ue(a), Ue(l), Ue(u), Ue(r.$$.fragment, c), s = !0);
    },
    o(c) {
      ft(a), ft(l), ft(u), ft(r.$$.fragment, c), s = !1;
    },
    d(c) {
      c && J1(e), a && a.d(), l && l.d(), u && u.d(), Ai(r);
    }
  };
}
function tm(i, e, t) {
  let { editable: n = !1 } = e, { undoable: o = !1 } = e, { download: r = null } = e, { absolute: s = !0 } = e, { i18n: a } = e;
  const l = $1(), u = () => l("edit"), c = () => l("undo"), d = (_) => {
    l("clear"), _.stopPropagation();
  };
  return i.$$set = (_) => {
    "editable" in _ && t(0, n = _.editable), "undoable" in _ && t(1, o = _.undoable), "download" in _ && t(2, r = _.download), "absolute" in _ && t(3, s = _.absolute), "i18n" in _ && t(4, a = _.i18n);
  }, [
    n,
    o,
    r,
    s,
    a,
    l,
    u,
    c,
    d
  ];
}
class au extends Z1 {
  constructor(e) {
    super(), X1(this, e, tm, em, Q1, {
      editable: 0,
      undoable: 1,
      download: 2,
      absolute: 3,
      i18n: 4
    });
  }
}
class Cl {
  constructor({
    path: e,
    url: t,
    orig_name: n,
    size: o,
    blob: r,
    is_stream: s,
    mime_type: a,
    alt_text: l
  }) {
    this.file_data = new Eo({ path: e, url: t, orig_name: n, size: o, blob: r, is_stream: s, mime_type: a, alt_text: l }), this.annotations = null;
  }
}
function bs(i, e, t, n) {
  return new (t || (t = Promise))(function(o, r) {
    function s(u) {
      try {
        l(n.next(u));
      } catch (c) {
        r(c);
      }
    }
    function a(u) {
      try {
        l(n.throw(u));
      } catch (c) {
        r(c);
      }
    }
    function l(u) {
      var c;
      u.done ? o(u.value) : (c = u.value, c instanceof t ? c : new t(function(d) {
        d(c);
      })).then(s, a);
    }
    l((n = n.apply(i, [])).next());
  });
}
class uu {
  constructor() {
    this.listeners = {};
  }
  on(e, t, n) {
    if (this.listeners[e] || (this.listeners[e] = /* @__PURE__ */ new Set()), this.listeners[e].add(t), n == null ? void 0 : n.once) {
      const o = () => {
        this.un(e, o), this.un(e, t);
      };
      return this.on(e, o), o;
    }
    return () => this.un(e, t);
  }
  un(e, t) {
    var n;
    (n = this.listeners[e]) === null || n === void 0 || n.delete(t);
  }
  once(e, t) {
    return this.on(e, t, { once: !0 });
  }
  unAll() {
    this.listeners = {};
  }
  emit(e, ...t) {
    this.listeners[e] && this.listeners[e].forEach((n) => n(...t));
  }
}
class nm extends uu {
  constructor(e) {
    super(), this.subscriptions = [], this.options = e;
  }
  onInit() {
  }
  _init(e) {
    this.wavesurfer = e, this.onInit();
  }
  destroy() {
    this.emit("destroy"), this.subscriptions.forEach((e) => e());
  }
}
class im extends uu {
  constructor() {
    super(...arguments), this.unsubscribe = () => {
    };
  }
  start() {
    this.unsubscribe = this.on("tick", () => {
      requestAnimationFrame(() => {
        this.emit("tick");
      });
    }), this.emit("tick");
  }
  stop() {
    this.unsubscribe();
  }
  destroy() {
    this.unsubscribe();
  }
}
const om = ["audio/webm", "audio/wav", "audio/mpeg", "audio/mp4", "audio/mp3"];
class ji extends nm {
  constructor(e) {
    var t, n, o, r;
    super(Object.assign(Object.assign({}, e), { audioBitsPerSecond: (t = e.audioBitsPerSecond) !== null && t !== void 0 ? t : 128e3, scrollingWaveform: (n = e.scrollingWaveform) !== null && n !== void 0 && n, scrollingWaveformWindow: (o = e.scrollingWaveformWindow) !== null && o !== void 0 ? o : 5, renderRecordedAudio: (r = e.renderRecordedAudio) === null || r === void 0 || r })), this.stream = null, this.mediaRecorder = null, this.dataWindow = null, this.isWaveformPaused = !1, this.lastStartTime = 0, this.lastDuration = 0, this.duration = 0, this.timer = new im(), this.subscriptions.push(this.timer.on("tick", () => {
      const s = performance.now() - this.lastStartTime;
      this.duration = this.isPaused() ? this.duration : this.lastDuration + s, this.emit("record-progress", this.duration);
    }));
  }
  static create(e) {
    return new ji(e || {});
  }
  renderMicStream(e) {
    const t = new AudioContext(), n = t.createMediaStreamSource(e), o = t.createAnalyser();
    n.connect(o);
    const r = o.frequencyBinCount, s = new Float32Array(r);
    let a;
    const l = Math.floor((this.options.scrollingWaveformWindow || 0) * t.sampleRate), u = () => {
      var c;
      if (this.isWaveformPaused)
        return void (a = requestAnimationFrame(u));
      if (o.getFloatTimeDomainData(s), this.options.scrollingWaveform) {
        const _ = Math.min(l, this.dataWindow ? this.dataWindow.length + r : r), f = new Float32Array(l);
        if (this.dataWindow) {
          const h = Math.max(0, l - this.dataWindow.length);
          f.set(this.dataWindow.slice(-_ + r), h);
        }
        f.set(s, l - r), this.dataWindow = f;
      } else
        this.dataWindow = s;
      const d = this.options.scrollingWaveformWindow;
      this.wavesurfer && ((c = this.originalOptions) !== null && c !== void 0 || (this.originalOptions = { cursorWidth: this.wavesurfer.options.cursorWidth, interact: this.wavesurfer.options.interact }), this.wavesurfer.options.cursorWidth = 0, this.wavesurfer.options.interact = !1, this.wavesurfer.load("", [this.dataWindow], d)), a = requestAnimationFrame(u);
    };
    return u(), { onDestroy: () => {
      cancelAnimationFrame(a), n == null || n.disconnect(), t == null || t.close();
    }, onEnd: () => {
      this.isWaveformPaused = !0, cancelAnimationFrame(a), this.stopMic();
    } };
  }
  startMic(e) {
    return bs(this, void 0, void 0, function* () {
      let t;
      try {
        t = yield navigator.mediaDevices.getUserMedia({ audio: !(e != null && e.deviceId) || { deviceId: e.deviceId } });
      } catch (r) {
        throw new Error("Error accessing the microphone: " + r.message);
      }
      const { onDestroy: n, onEnd: o } = this.renderMicStream(t);
      return this.subscriptions.push(this.once("destroy", n)), this.subscriptions.push(this.once("record-end", o)), this.stream = t, t;
    });
  }
  stopMic() {
    this.stream && (this.stream.getTracks().forEach((e) => e.stop()), this.stream = null, this.mediaRecorder = null);
  }
  startRecording(e) {
    return bs(this, void 0, void 0, function* () {
      const t = this.stream || (yield this.startMic(e));
      this.dataWindow = null;
      const n = this.mediaRecorder || new MediaRecorder(t, { mimeType: this.options.mimeType || om.find((s) => MediaRecorder.isTypeSupported(s)), audioBitsPerSecond: this.options.audioBitsPerSecond });
      this.mediaRecorder = n, this.stopRecording();
      const o = [];
      n.ondataavailable = (s) => {
        s.data.size > 0 && o.push(s.data);
      };
      const r = (s) => {
        var a;
        const l = new Blob(o, { type: n.mimeType });
        this.emit(s, l), this.options.renderRecordedAudio && (this.applyOriginalOptionsIfNeeded(), (a = this.wavesurfer) === null || a === void 0 || a.load(URL.createObjectURL(l)));
      };
      n.onpause = () => r("record-pause"), n.onstop = () => r("record-end"), n.start(), this.lastStartTime = performance.now(), this.lastDuration = 0, this.duration = 0, this.isWaveformPaused = !1, this.timer.start(), this.emit("record-start");
    });
  }
  getDuration() {
    return this.duration;
  }
  isRecording() {
    var e;
    return ((e = this.mediaRecorder) === null || e === void 0 ? void 0 : e.state) === "recording";
  }
  isPaused() {
    var e;
    return ((e = this.mediaRecorder) === null || e === void 0 ? void 0 : e.state) === "paused";
  }
  isActive() {
    var e;
    return ((e = this.mediaRecorder) === null || e === void 0 ? void 0 : e.state) !== "inactive";
  }
  stopRecording() {
    var e;
    this.isActive() && ((e = this.mediaRecorder) === null || e === void 0 || e.stop(), this.timer.stop());
  }
  pauseRecording() {
    var e, t;
    this.isRecording() && (this.isWaveformPaused = !0, (e = this.mediaRecorder) === null || e === void 0 || e.requestData(), (t = this.mediaRecorder) === null || t === void 0 || t.pause(), this.timer.stop(), this.lastDuration = this.duration);
  }
  resumeRecording() {
    var e;
    this.isPaused() && (this.isWaveformPaused = !1, (e = this.mediaRecorder) === null || e === void 0 || e.resume(), this.timer.start(), this.lastStartTime = performance.now(), this.emit("record-resume"));
  }
  static getAvailableAudioDevices() {
    return bs(this, void 0, void 0, function* () {
      return navigator.mediaDevices.enumerateDevices().then((e) => e.filter((t) => t.kind === "audioinput"));
    });
  }
  destroy() {
    this.applyOriginalOptionsIfNeeded(), super.destroy(), this.stopRecording(), this.stopMic();
  }
  applyOriginalOptionsIfNeeded() {
    this.wavesurfer && this.originalOptions && (this.wavesurfer.options.cursorWidth = this.originalOptions.cursorWidth, this.wavesurfer.options.interact = this.originalOptions.interact, delete this.originalOptions);
  }
}
const {
  SvelteComponent: sm,
  append: Ce,
  attr: et,
  binding_callbacks: mi,
  create_component: rm,
  destroy_component: lm,
  destroy_each: am,
  detach: Pi,
  element: dt,
  empty: um,
  ensure_array_like: Sl,
  init: cm,
  insert: Ti,
  listen: pi,
  mount_component: dm,
  run_all: fm,
  safe_not_equal: _m,
  set_data: gn,
  set_input_value: Us,
  space: In,
  text: bn,
  transition_in: hm,
  transition_out: mm
} = window.__gradio__svelte__internal, { createEventDispatcher: pm } = window.__gradio__svelte__internal;
function El(i, e, t) {
  const n = i.slice();
  return n[22] = e[t], n;
}
function Dl(i) {
  let e, t;
  return {
    c() {
      e = dt("time"), t = bn(
        /*record_time*/
        i[2]
      ), et(e, "class", "duration-button duration svelte-wjm7x4");
    },
    m(n, o) {
      Ti(n, e, o), Ce(e, t);
    },
    p(n, o) {
      o & /*record_time*/
      4 && gn(
        t,
        /*record_time*/
        n[2]
      );
    },
    d(n) {
      n && Pi(e);
    }
  };
}
function gm(i) {
  let e, t = Sl(
    /*micDevices*/
    i[5]
  ), n = [];
  for (let o = 0; o < t.length; o += 1)
    n[o] = Ll(El(i, t, o));
  return {
    c() {
      for (let o = 0; o < n.length; o += 1)
        n[o].c();
      e = um();
    },
    m(o, r) {
      for (let s = 0; s < n.length; s += 1)
        n[s] && n[s].m(o, r);
      Ti(o, e, r);
    },
    p(o, r) {
      if (r & /*micDevices*/
      32) {
        t = Sl(
          /*micDevices*/
          o[5]
        );
        let s;
        for (s = 0; s < t.length; s += 1) {
          const a = El(o, t, s);
          n[s] ? n[s].p(a, r) : (n[s] = Ll(a), n[s].c(), n[s].m(e.parentNode, e));
        }
        for (; s < n.length; s += 1)
          n[s].d(1);
        n.length = t.length;
      }
    },
    d(o) {
      o && Pi(e), am(n, o);
    }
  };
}
function bm(i) {
  let e, t = (
    /*i18n*/
    i[1]("audio.no_microphone") + ""
  ), n;
  return {
    c() {
      e = dt("option"), n = bn(t), e.__value = "", Us(e, e.__value);
    },
    m(o, r) {
      Ti(o, e, r), Ce(e, n);
    },
    p(o, r) {
      r & /*i18n*/
      2 && t !== (t = /*i18n*/
      o[1]("audio.no_microphone") + "") && gn(n, t);
    },
    d(o) {
      o && Pi(e);
    }
  };
}
function Ll(i) {
  let e, t = (
    /*micDevice*/
    i[22].label + ""
  ), n, o;
  return {
    c() {
      e = dt("option"), n = bn(t), e.__value = o = /*micDevice*/
      i[22].deviceId, Us(e, e.__value);
    },
    m(r, s) {
      Ti(r, e, s), Ce(e, n);
    },
    p(r, s) {
      s & /*micDevices*/
      32 && t !== (t = /*micDevice*/
      r[22].label + "") && gn(n, t), s & /*micDevices*/
      32 && o !== (o = /*micDevice*/
      r[22].deviceId) && (e.__value = o, Us(e, e.__value));
    },
    d(r) {
      r && Pi(e);
    }
  };
}
function vm(i) {
  let e, t, n, o = (
    /*i18n*/
    i[1]("audio.record") + ""
  ), r, s, a, l = (
    /*i18n*/
    i[1]("audio.stop") + ""
  ), u, c, d, _, f = (
    /*i18n*/
    i[1]("audio.stop") + ""
  ), h, p, g, m, k, w, S = (
    /*i18n*/
    i[1]("audio.resume") + ""
  ), v, b, L, E, D, P, F, q;
  m = new ga({});
  let N = (
    /*timing*/
    i[4] && !/*show_recording_waveform*/
    i[3] && Dl(i)
  );
  function Y(T, V) {
    return (
      /*micDevices*/
      T[5].length === 0 ? bm : gm
    );
  }
  let J = Y(i), O = J(i);
  return {
    c() {
      e = dt("div"), t = dt("div"), n = dt("button"), r = bn(o), s = In(), a = dt("button"), u = bn(l), d = In(), _ = dt("button"), h = bn(f), p = In(), g = dt("button"), rm(m.$$.fragment), k = In(), w = dt("button"), v = bn(S), b = In(), N && N.c(), L = In(), E = dt("select"), O.c(), et(n, "class", "record record-button svelte-wjm7x4"), et(a, "class", c = "stop-button " + /*record*/
      (i[0].isPaused() ? "stop-button-paused" : "") + " svelte-wjm7x4"), et(_, "id", "stop-paused"), et(_, "class", "stop-button-paused svelte-wjm7x4"), et(g, "class", "pause-button svelte-wjm7x4"), et(w, "class", "resume-button svelte-wjm7x4"), et(t, "class", "wrapper svelte-wjm7x4"), et(E, "class", "mic-select svelte-wjm7x4"), et(E, "aria-label", "Select input device"), E.disabled = D = /*micDevices*/
      i[5].length === 0, et(e, "class", "controls svelte-wjm7x4");
    },
    m(T, V) {
      Ti(T, e, V), Ce(e, t), Ce(t, n), Ce(n, r), i[11](n), Ce(t, s), Ce(t, a), Ce(a, u), i[13](a), Ce(t, d), Ce(t, _), Ce(_, h), i[15](_), Ce(t, p), Ce(t, g), dm(m, g, null), i[17](g), Ce(t, k), Ce(t, w), Ce(w, v), i[19](w), Ce(t, b), N && N.m(t, null), Ce(e, L), Ce(e, E), O.m(E, null), P = !0, F || (q = [
        pi(
          n,
          "click",
          /*click_handler*/
          i[12]
        ),
        pi(
          a,
          "click",
          /*click_handler_1*/
          i[14]
        ),
        pi(
          _,
          "click",
          /*click_handler_2*/
          i[16]
        ),
        pi(
          g,
          "click",
          /*click_handler_3*/
          i[18]
        ),
        pi(
          w,
          "click",
          /*click_handler_4*/
          i[20]
        )
      ], F = !0);
    },
    p(T, [V]) {
      (!P || V & /*i18n*/
      2) && o !== (o = /*i18n*/
      T[1]("audio.record") + "") && gn(r, o), (!P || V & /*i18n*/
      2) && l !== (l = /*i18n*/
      T[1]("audio.stop") + "") && gn(u, l), (!P || V & /*record*/
      1 && c !== (c = "stop-button " + /*record*/
      (T[0].isPaused() ? "stop-button-paused" : "") + " svelte-wjm7x4")) && et(a, "class", c), (!P || V & /*i18n*/
      2) && f !== (f = /*i18n*/
      T[1]("audio.stop") + "") && gn(h, f), (!P || V & /*i18n*/
      2) && S !== (S = /*i18n*/
      T[1]("audio.resume") + "") && gn(v, S), /*timing*/
      T[4] && !/*show_recording_waveform*/
      T[3] ? N ? N.p(T, V) : (N = Dl(T), N.c(), N.m(t, null)) : N && (N.d(1), N = null), J === (J = Y(T)) && O ? O.p(T, V) : (O.d(1), O = J(T), O && (O.c(), O.m(E, null))), (!P || V & /*micDevices*/
      32 && D !== (D = /*micDevices*/
      T[5].length === 0)) && (E.disabled = D);
    },
    i(T) {
      P || (hm(m.$$.fragment, T), P = !0);
    },
    o(T) {
      mm(m.$$.fragment, T), P = !1;
    },
    d(T) {
      T && Pi(e), i[11](null), i[13](null), i[15](null), lm(m), i[17](null), i[19](null), N && N.d(), O.d(), F = !1, fm(q);
    }
  };
}
function wm(i, e, t) {
  let { record: n } = e, { i18n: o } = e, r = [], s, a, l, u, c, { record_time: d } = e, { show_recording_waveform: _ } = e, { timing: f = !1 } = e;
  const h = pm();
  function p(D) {
    mi[D ? "unshift" : "push"](() => {
      s = D, t(6, s), t(0, n);
    });
  }
  const g = () => n.startRecording();
  function m(D) {
    mi[D ? "unshift" : "push"](() => {
      u = D, t(9, u), t(0, n);
    });
  }
  const k = () => {
    n.isPaused() && (n.resumeRecording(), n.stopRecording()), n.stopRecording();
  };
  function w(D) {
    mi[D ? "unshift" : "push"](() => {
      c = D, t(10, c), t(0, n);
    });
  }
  const S = () => {
    n.isPaused() && (n.resumeRecording(), n.stopRecording()), n.stopRecording();
  };
  function v(D) {
    mi[D ? "unshift" : "push"](() => {
      a = D, t(7, a), t(0, n);
    });
  }
  const b = () => n.pauseRecording();
  function L(D) {
    mi[D ? "unshift" : "push"](() => {
      l = D, t(8, l), t(0, n);
    });
  }
  const E = () => n.resumeRecording();
  return i.$$set = (D) => {
    "record" in D && t(0, n = D.record), "i18n" in D && t(1, o = D.i18n), "record_time" in D && t(2, d = D.record_time), "show_recording_waveform" in D && t(3, _ = D.show_recording_waveform), "timing" in D && t(4, f = D.timing);
  }, i.$$.update = () => {
    if (i.$$.dirty & /*micDevices, i18n*/
    34)
      try {
        let D = [];
        ji.getAvailableAudioDevices().then((P) => {
          t(5, r = P), r.forEach((F) => {
            F.deviceId && D.push(F);
          }), t(5, r = D);
        });
      } catch (D) {
        throw D instanceof DOMException && D.name == "NotAllowedError" && h("error", o("audio.allow_recording_access")), D;
      }
    i.$$.dirty & /*record*/
    1 && n.on("record-start", () => {
      n.startMic(), t(6, s.style.display = "none", s), t(9, u.style.display = "flex", u), t(7, a.style.display = "block", a);
    }), i.$$.dirty & /*record*/
    1 && n.on("record-end", () => {
      n.isPaused() && (n.resumeRecording(), n.stopRecording()), n.stopMic(), t(6, s.style.display = "flex", s), t(9, u.style.display = "none", u), t(7, a.style.display = "none", a), t(6, s.disabled = !1, s);
    }), i.$$.dirty & /*record*/
    1 && n.on("record-pause", () => {
      t(7, a.style.display = "none", a), t(8, l.style.display = "block", l), t(9, u.style.display = "none", u), t(10, c.style.display = "flex", c);
    }), i.$$.dirty & /*record*/
    1 && n.on("record-resume", () => {
      t(7, a.style.display = "block", a), t(8, l.style.display = "none", l), t(6, s.style.display = "none", s), t(9, u.style.display = "flex", u), t(10, c.style.display = "none", c);
    });
  }, [
    n,
    o,
    d,
    _,
    f,
    r,
    s,
    a,
    l,
    u,
    c,
    p,
    g,
    m,
    k,
    w,
    S,
    v,
    b,
    L,
    E
  ];
}
class ym extends sm {
  constructor(e) {
    super(), cm(this, e, wm, vm, _m, {
      record: 0,
      i18n: 1,
      record_time: 2,
      show_recording_waveform: 3,
      timing: 4
    });
  }
}
const {
  SvelteComponent: km,
  add_flush_callback: cu,
  append: _t,
  attr: qt,
  bind: du,
  binding_callbacks: Zn,
  check_outros: Rl,
  create_component: fu,
  destroy_component: _u,
  detach: Ni,
  element: zt,
  group_outros: Ml,
  init: Cm,
  insert: Bi,
  mount_component: hu,
  noop: mu,
  safe_not_equal: Sm,
  set_data: Em,
  space: Gn,
  text: Dm,
  transition_in: Gt,
  transition_out: Jn
} = window.__gradio__svelte__internal, { onMount: Lm } = window.__gradio__svelte__internal, { createEventDispatcher: Rm } = window.__gradio__svelte__internal;
function Ol(i) {
  let e, t, n, o, r, s = (
    /*mode*/
    i[0] === "edit" && Fs > 0 && ql()
  );
  function a(c, d) {
    return (
      /*timing*/
      c[13] ? Om : Mm
    );
  }
  let l = a(i), u = l(i);
  return {
    c() {
      e = zt("div"), t = zt("time"), t.textContent = "0:00", n = Gn(), o = zt("div"), s && s.c(), r = Gn(), u.c(), qt(t, "class", "time svelte-1z0uz8p"), qt(e, "class", "timestamps svelte-1z0uz8p");
    },
    m(c, d) {
      Bi(c, e, d), _t(e, t), i[19](t), _t(e, n), _t(e, o), s && s.m(o, null), _t(o, r), u.m(o, null);
    },
    p(c, d) {
      /*mode*/
      c[0] === "edit" && Fs > 0 ? s ? s.p(c, d) : (s = ql(), s.c(), s.m(o, r)) : s && (s.d(1), s = null), l === (l = a(c)) && u ? u.p(c, d) : (u.d(1), u = l(c), u && (u.c(), u.m(o, null)));
    },
    d(c) {
      c && Ni(e), i[19](null), s && s.d(), u.d();
    }
  };
}
function ql(i) {
  let e;
  return {
    c() {
      e = zt("time"), e.textContent = `${kn(Fs)}`, qt(e, "class", "trim-duration svelte-1z0uz8p");
    },
    m(t, n) {
      Bi(t, e, n);
    },
    p: mu,
    d(t) {
      t && Ni(e);
    }
  };
}
function Mm(i) {
  let e;
  return {
    c() {
      e = zt("time"), e.textContent = "0:00", qt(e, "class", "duration svelte-1z0uz8p");
    },
    m(t, n) {
      Bi(t, e, n), i[20](e);
    },
    p: mu,
    d(t) {
      t && Ni(e), i[20](null);
    }
  };
}
function Om(i) {
  let e, t = kn(
    /*seconds*/
    i[12]
  ) + "", n;
  return {
    c() {
      e = zt("time"), n = Dm(t), qt(e, "class", "duration svelte-1z0uz8p");
    },
    m(o, r) {
      Bi(o, e, r), _t(e, n);
    },
    p(o, r) {
      r & /*seconds*/
      4096 && t !== (t = kn(
        /*seconds*/
        o[12]
      ) + "") && Em(n, t);
    },
    d(o) {
      o && Ni(e);
    }
  };
}
function Al(i) {
  let e, t, n;
  function o(s) {
    i[21](s);
  }
  let r = {
    i18n: (
      /*i18n*/
      i[1]
    ),
    timing: (
      /*timing*/
      i[13]
    ),
    show_recording_waveform: (
      /*waveform_options*/
      i[2].show_recording_waveform
    ),
    record_time: kn(
      /*seconds*/
      i[12]
    )
  };
  return (
    /*record*/
    i[6] !== void 0 && (r.record = /*record*/
    i[6]), e = new ym({ props: r }), Zn.push(() => du(e, "record", o)), {
      c() {
        fu(e.$$.fragment);
      },
      m(s, a) {
        hu(e, s, a), n = !0;
      },
      p(s, a) {
        const l = {};
        a & /*i18n*/
        2 && (l.i18n = /*i18n*/
        s[1]), a & /*timing*/
        8192 && (l.timing = /*timing*/
        s[13]), a & /*waveform_options*/
        4 && (l.show_recording_waveform = /*waveform_options*/
        s[2].show_recording_waveform), a & /*seconds*/
        4096 && (l.record_time = kn(
          /*seconds*/
          s[12]
        )), !t && a & /*record*/
        64 && (t = !0, l.record = /*record*/
        s[6], cu(() => t = !1)), e.$set(l);
      },
      i(s) {
        n || (Gt(e.$$.fragment, s), n = !0);
      },
      o(s) {
        Jn(e.$$.fragment, s), n = !1;
      },
      d(s) {
        _u(e, s);
      }
    }
  );
}
function zl(i) {
  let e, t, n;
  function o(s) {
    i[22](s);
  }
  let r = {
    playing: (
      /*playing*/
      i[10]
    ),
    audio_duration: (
      /*audio_duration*/
      i[11]
    ),
    i18n: (
      /*i18n*/
      i[1]
    ),
    waveform_options: (
      /*waveform_options*/
      i[2]
    )
  };
  return (
    /*recordingWaveform*/
    i[3] !== void 0 && (r.waveform = /*recordingWaveform*/
    i[3]), e = new Ma({ props: r }), Zn.push(() => du(e, "waveform", o)), {
      c() {
        fu(e.$$.fragment);
      },
      m(s, a) {
        hu(e, s, a), n = !0;
      },
      p(s, a) {
        const l = {};
        a & /*playing*/
        1024 && (l.playing = /*playing*/
        s[10]), a & /*audio_duration*/
        2048 && (l.audio_duration = /*audio_duration*/
        s[11]), a & /*i18n*/
        2 && (l.i18n = /*i18n*/
        s[1]), a & /*waveform_options*/
        4 && (l.waveform_options = /*waveform_options*/
        s[2]), !t && a & /*recordingWaveform*/
        8 && (t = !0, l.waveform = /*recordingWaveform*/
        s[3], cu(() => t = !1)), e.$set(l);
      },
      i(s) {
        n || (Gt(e.$$.fragment, s), n = !0);
      },
      o(s) {
        Jn(e.$$.fragment, s), n = !1;
      },
      d(s) {
        _u(e, s);
      }
    }
  );
}
function qm(i) {
  let e, t, n, o, r, s, a, l, u = (
    /*timing*/
    (i[13] || /*recordedAudio*/
    i[7]) && /*waveform_options*/
    i[2].show_recording_waveform && Ol(i)
  ), c = (
    /*microphoneContainer*/
    i[5] && !/*recordedAudio*/
    i[7] && Al(i)
  ), d = (
    /*recordingWaveform*/
    i[3] && /*recordedAudio*/
    i[7] && zl(i)
  );
  return {
    c() {
      e = zt("div"), t = zt("div"), n = Gn(), o = zt("div"), r = Gn(), u && u.c(), s = Gn(), c && c.c(), a = Gn(), d && d.c(), qt(t, "class", "microphone svelte-1z0uz8p"), qt(t, "data-testid", "microphone-waveform"), qt(o, "data-testid", "recording-waveform"), qt(e, "class", "component-wrapper svelte-1z0uz8p");
    },
    m(_, f) {
      Bi(_, e, f), _t(e, t), i[17](t), _t(e, n), _t(e, o), i[18](o), _t(e, r), u && u.m(e, null), _t(e, s), c && c.m(e, null), _t(e, a), d && d.m(e, null), l = !0;
    },
    p(_, [f]) {
      /*timing*/
      (_[13] || /*recordedAudio*/
      _[7]) && /*waveform_options*/
      _[2].show_recording_waveform ? u ? u.p(_, f) : (u = Ol(_), u.c(), u.m(e, s)) : u && (u.d(1), u = null), /*microphoneContainer*/
      _[5] && !/*recordedAudio*/
      _[7] ? c ? (c.p(_, f), f & /*microphoneContainer, recordedAudio*/
      160 && Gt(c, 1)) : (c = Al(_), c.c(), Gt(c, 1), c.m(e, a)) : c && (Ml(), Jn(c, 1, 1, () => {
        c = null;
      }), Rl()), /*recordingWaveform*/
      _[3] && /*recordedAudio*/
      _[7] ? d ? (d.p(_, f), f & /*recordingWaveform, recordedAudio*/
      136 && Gt(d, 1)) : (d = zl(_), d.c(), Gt(d, 1), d.m(e, null)) : d && (Ml(), Jn(d, 1, 1, () => {
        d = null;
      }), Rl());
    },
    i(_) {
      l || (Gt(c), Gt(d), l = !0);
    },
    o(_) {
      Jn(c), Jn(d), l = !1;
    },
    d(_) {
      _ && Ni(e), i[17](null), i[18](null), u && u.d(), c && c.d(), d && d.d();
    }
  };
}
let Fs = 0;
function Am(i, e, t) {
  var n = this && this.__awaiter || function(O, T, V, K) {
    function I($) {
      return $ instanceof V ? $ : new V(function(te) {
        te($);
      });
    }
    return new (V || (V = Promise))(function($, te) {
      function M(j) {
        try {
          R(K.next(j));
        } catch (Q) {
          te(Q);
        }
      }
      function C(j) {
        try {
          R(K.throw(j));
        } catch (Q) {
          te(Q);
        }
      }
      function R(j) {
        j.done ? $(j.value) : I(j.value).then(M, C);
      }
      R((K = K.apply(O, T || [])).next());
    });
  };
  let { mode: o } = e, { i18n: r } = e, { dispatch_blob: s } = e, { waveform_settings: a } = e, { waveform_options: l = { show_recording_waveform: !0 } } = e, u, c, d = !1, _, f, h, p = null, g, m, k, w = 0, S, v = !1;
  const b = () => {
    clearInterval(S), t(16, S = setInterval(
      () => {
        t(12, w++, w);
      },
      1e3
    ));
  }, L = Rm(), E = () => {
    f && t(5, f.innerHTML = "", f), u !== void 0 && u.destroy(), f && (u = nn.create(Object.assign(Object.assign({}, a), {
      normalize: !1,
      container: f
    })), t(6, h = u.registerPlugin(ji.create())), h.startMic());
  }, D = () => {
    let O = _;
    !p || !O || t(3, c = nn.create(Object.assign({ container: O, url: p }, a)));
  };
  Lm(() => {
    E(), window.addEventListener("keydown", (O) => {
      O.key === "ArrowRight" ? Or(c, 0.1) : O.key === "ArrowLeft" && Or(c, -0.1);
    });
  });
  function P(O) {
    Zn[O ? "unshift" : "push"](() => {
      f = O, t(5, f);
    });
  }
  function F(O) {
    Zn[O ? "unshift" : "push"](() => {
      _ = O, t(4, _);
    });
  }
  function q(O) {
    Zn[O ? "unshift" : "push"](() => {
      g = O, t(8, g), t(3, c);
    });
  }
  function N(O) {
    Zn[O ? "unshift" : "push"](() => {
      m = O, t(9, m), t(3, c);
    });
  }
  function Y(O) {
    h = O, t(6, h);
  }
  function J(O) {
    c = O, t(3, c);
  }
  return i.$$set = (O) => {
    "mode" in O && t(0, o = O.mode), "i18n" in O && t(1, r = O.i18n), "dispatch_blob" in O && t(14, s = O.dispatch_blob), "waveform_settings" in O && t(15, a = O.waveform_settings), "waveform_options" in O && t(2, l = O.waveform_options);
  }, i.$$.update = () => {
    i.$$.dirty & /*record, waveform_options, microphoneContainer*/
    100 && (h == null || h.on("record-start", () => {
      if (b(), t(13, v = !0), L("start_recording"), l.show_recording_waveform) {
        let O = f;
        O && (O.style.display = "block");
      }
    })), i.$$.dirty & /*record, interval, waveform_settings, dispatch_blob*/
    114752 && (h == null || h.on("record-end", (O) => n(void 0, void 0, void 0, function* () {
      t(12, w = 0), t(13, v = !1), clearInterval(S);
      try {
        const T = yield O.arrayBuffer(), K = yield new AudioContext({ sampleRate: a.sampleRate }).decodeAudioData(T);
        K && (yield V_(K).then((I) => n(void 0, void 0, void 0, function* () {
          yield s([I], "change"), yield s([I], "stop_recording");
        })));
      } catch (T) {
        console.error(T);
      }
    }))), i.$$.dirty & /*record, interval*/
    65600 && (h == null || h.on("record-pause", () => {
      L("pause_recording"), clearInterval(S);
    })), i.$$.dirty & /*record*/
    64 && (h == null || h.on("record-resume", () => {
      b();
    })), i.$$.dirty & /*recordingWaveform, durationRef*/
    520 && (c == null || c.on("decode", (O) => {
      t(11, k = O), m && t(9, m.textContent = kn(O), m);
    })), i.$$.dirty & /*recordingWaveform, timeRef*/
    264 && (c == null || c.on("timeupdate", (O) => g && t(8, g.textContent = kn(O), g))), i.$$.dirty & /*recordingWaveform*/
    8 && (c == null || c.on("pause", () => {
      L("pause"), t(10, d = !1);
    })), i.$$.dirty & /*recordingWaveform*/
    8 && (c == null || c.on("play", () => {
      L("play"), t(10, d = !0);
    })), i.$$.dirty & /*recordingWaveform*/
    8 && (c == null || c.on("finish", () => {
      L("stop"), t(10, d = !1);
    })), i.$$.dirty & /*record, microphoneContainer, recordingContainer, recordedAudio*/
    240 && (h == null || h.on("record-end", (O) => {
      t(7, p = URL.createObjectURL(O));
      const T = f, V = _;
      T && (T.style.display = "none"), V && p && (V.innerHTML = "", D());
    }));
  }, [
    o,
    r,
    l,
    c,
    _,
    f,
    h,
    p,
    g,
    m,
    d,
    k,
    w,
    v,
    s,
    a,
    S,
    P,
    F,
    q,
    N,
    Y,
    J
  ];
}
class zm extends km {
  constructor(e) {
    super(), Cm(this, e, Am, qm, Sm, {
      mode: 0,
      i18n: 1,
      dispatch_blob: 14,
      waveform_settings: 15,
      waveform_options: 2
    });
  }
}
const {
  SvelteComponent: jm,
  append: yn,
  attr: Xn,
  binding_callbacks: Pm,
  detach: Ro,
  element: Qn,
  init: Tm,
  insert: Mo,
  listen: pu,
  noop: jl,
  null_to_empty: Pl,
  safe_not_equal: Nm,
  set_data: gu,
  set_style: Tl,
  space: xs,
  text: bu
} = window.__gradio__svelte__internal, { onMount: Bm } = window.__gradio__svelte__internal;
function Nl(i) {
  let e;
  return {
    c() {
      e = Qn("div"), Tl(
        e,
        "display",
        /*recording*/
        i[0] ? "block" : "none"
      );
    },
    m(t, n) {
      Mo(t, e, n), i[9](e);
    },
    p(t, n) {
      n & /*recording*/
      1 && Tl(
        e,
        "display",
        /*recording*/
        t[0] ? "block" : "none"
      );
    },
    d(t) {
      t && Ro(e), i[9](null);
    }
  };
}
function Wm(i) {
  let e, t, n, o = (
    /*i18n*/
    i[4]("audio.record") + ""
  ), r, s, a;
  return {
    c() {
      e = Qn("button"), t = Qn("span"), t.innerHTML = '<span class="dot"></span>', n = xs(), r = bu(o), Xn(t, "class", "record-icon"), Xn(e, "class", "record-button svelte-4ycsjo");
    },
    m(l, u) {
      Mo(l, e, u), yn(e, t), yn(e, n), yn(e, r), s || (a = pu(
        e,
        "click",
        /*click_handler_1*/
        i[11]
      ), s = !0);
    },
    p(l, u) {
      u & /*i18n*/
      16 && o !== (o = /*i18n*/
      l[4]("audio.record") + "") && gu(r, o);
    },
    d(l) {
      l && Ro(e), s = !1, a();
    }
  };
}
function Im(i) {
  let e, t, n, o = (
    /*paused_recording*/
    (i[1] ? (
      /*i18n*/
      i[4]("audio.pause")
    ) : (
      /*i18n*/
      i[4]("audio.stop")
    )) + ""
  ), r, s, a, l;
  return {
    c() {
      e = Qn("button"), t = Qn("span"), t.innerHTML = '<span class="pinger"></span> <span class="dot"></span>', n = xs(), r = bu(o), Xn(t, "class", "record-icon"), Xn(e, "class", s = Pl(
        /*paused_recording*/
        i[1] ? "stop-button-paused" : "stop-button"
      ) + " svelte-4ycsjo");
    },
    m(u, c) {
      Mo(u, e, c), yn(e, t), yn(e, n), yn(e, r), a || (l = pu(
        e,
        "click",
        /*click_handler*/
        i[10]
      ), a = !0);
    },
    p(u, c) {
      c & /*paused_recording, i18n*/
      18 && o !== (o = /*paused_recording*/
      (u[1] ? (
        /*i18n*/
        u[4]("audio.pause")
      ) : (
        /*i18n*/
        u[4]("audio.stop")
      )) + "") && gu(r, o), c & /*paused_recording*/
      2 && s !== (s = Pl(
        /*paused_recording*/
        u[1] ? "stop-button-paused" : "stop-button"
      ) + " svelte-4ycsjo") && Xn(e, "class", s);
    },
    d(u) {
      u && Ro(e), a = !1, l();
    }
  };
}
function Um(i) {
  let e, t, n = (
    /*waveform_options*/
    i[5].show_recording_waveform && Nl(i)
  );
  function o(a, l) {
    return (
      /*recording*/
      a[0] ? Im : Wm
    );
  }
  let r = o(i), s = r(i);
  return {
    c() {
      e = Qn("div"), n && n.c(), t = xs(), s.c(), Xn(e, "class", "mic-wrap svelte-4ycsjo");
    },
    m(a, l) {
      Mo(a, e, l), n && n.m(e, null), yn(e, t), s.m(e, null);
    },
    p(a, [l]) {
      /*waveform_options*/
      a[5].show_recording_waveform ? n ? n.p(a, l) : (n = Nl(a), n.c(), n.m(e, t)) : n && (n.d(1), n = null), r === (r = o(a)) && s ? s.p(a, l) : (s.d(1), s = r(a), s && (s.c(), s.m(e, null)));
    },
    i: jl,
    o: jl,
    d(a) {
      a && Ro(e), n && n.d(), s.d();
    }
  };
}
function Fm(i, e, t) {
  let { recording: n = !1 } = e, { paused_recording: o = !1 } = e, { stop: r } = e, { record: s } = e, { i18n: a } = e, { waveform_settings: l } = e, { waveform_options: u = { show_recording_waveform: !0 } } = e, c, d, _;
  Bm(() => {
    f();
  });
  const f = () => {
    c !== void 0 && c.destroy(), _ && (c = nn.create(Object.assign(Object.assign({}, l), {
      height: 100,
      container: _
    })), t(6, d = c.registerPlugin(ji.create())));
  };
  function h(m) {
    Pm[m ? "unshift" : "push"](() => {
      _ = m, t(7, _);
    });
  }
  const p = () => {
    d == null || d.stopMic(), r();
  }, g = () => {
    d == null || d.startMic(), s();
  };
  return i.$$set = (m) => {
    "recording" in m && t(0, n = m.recording), "paused_recording" in m && t(1, o = m.paused_recording), "stop" in m && t(2, r = m.stop), "record" in m && t(3, s = m.record), "i18n" in m && t(4, a = m.i18n), "waveform_settings" in m && t(8, l = m.waveform_settings), "waveform_options" in m && t(5, u = m.waveform_options);
  }, [
    n,
    o,
    r,
    s,
    a,
    u,
    d,
    _,
    l,
    h,
    p,
    g
  ];
}
class Vm extends jm {
  constructor(e) {
    super(), Tm(this, e, Fm, Um, Nm, {
      recording: 0,
      paused_recording: 1,
      stop: 2,
      record: 3,
      i18n: 4,
      waveform_settings: 8,
      waveform_options: 5
    });
  }
}
const {
  SvelteComponent: Hm,
  append: Bl,
  attr: Ge,
  detach: Zm,
  init: Gm,
  insert: Jm,
  noop: vs,
  safe_not_equal: Km,
  svg_element: ws
} = window.__gradio__svelte__internal;
function Xm(i) {
  let e, t, n;
  return {
    c() {
      e = ws("svg"), t = ws("path"), n = ws("path"), Ge(t, "d", "M983.678752 314.585575c-25.849513-60.781287-62.777388-115.474464-109.785575-162.482651s-101.701365-83.936062-162.482651-109.785575C648.433528 15.569591 581.663938 1.996101 512.998051 1.996101c-68.665887 0-135.435478 13.573489-198.412476 40.321248-60.781287 25.849513-115.474464 62.777388-162.482651 109.785575s-83.936062 101.701365-109.785575 162.482651C15.569591 377.562573 1.996101 444.332164 1.996101 512.998051c0 68.665887 13.573489 135.435478 40.321248 198.412475 25.849513 60.781287 62.777388 115.474464 109.785575 162.482651s101.701365 83.936062 162.482651 109.785575c62.976998 26.747758 129.746589 40.321248 198.412476 40.321248 68.665887 0 135.435478-13.573489 198.412475-40.321248 60.781287-25.849513 115.474464-62.777388 162.482651-109.785575s83.936062-101.701365 109.785575-162.482651c26.747758-62.976998 40.321248-129.746589 40.321248-198.412475 0-68.665887-13.573489-135.435478-40.321248-198.412476zM673.684211 894.752437c-51.00039 21.6577-105.094737 32.636257-160.68616 32.636257s-109.68577-10.978558-160.68616-32.636257c-49.403509-21.058869-93.816764-51.100195-131.9423-89.125926-38.125536-38.125536-68.067057-82.438986-89.125926-131.9423-21.6577-51.00039-32.636257-105.094737-32.636258-160.68616s10.978558-109.68577 32.636258-160.68616c21.058869-49.403509 51.100195-93.816764 89.125926-131.9423 38.125536-38.125536 82.438986-68.067057 131.9423-89.125926 51.00039-21.6577 105.094737-32.636257 160.68616-32.636258s109.68577 10.978558 160.68616 32.636258c49.403509 21.058869 93.816764 51.100195 131.9423 89.125926 38.125536 38.125536 68.067057 82.438986 89.125926 131.9423 21.6577 51.00039 32.636257 105.094737 32.636257 160.68616s-10.978558 109.68577-32.636257 160.68616c-21.058869 49.403509-51.100195 93.816764-89.125926 131.9423-38.125536 38.025731-82.538791 68.067057-131.9423 89.125926z"), Ge(n, "d", "M476.868616 808.820273h74.554386c8.283821 0 14.97076-6.68694 14.97076-14.97076v-68.366472c0-8.283821-6.68694-14.97076-14.97076-14.97076h-74.554386c-8.283821 0-14.97076 6.68694-14.97076 14.97076v68.366472c0 8.283821 6.68694 14.97076 14.97076 14.97076zM687.557115 373.270955c-3.293567-51.299805-19.262378-90.922417-47.307602-117.869785-28.045224-26.947368-68.266667-41.119688-119.566472-42.217544h-0.998051c-58.585575 2.195712-104.096686 19.461988-135.235867 51.100195-31.039376 31.638207-47.906433 77.847953-50.102144 137.331774-0.299415 8.483431 6.487329 15.469786 14.97076 15.469785h65.272514c8.084211 0 14.77115-6.487329 14.970761-14.57154 1.896296-72.558285 30.440546-107.490058 90.024171-109.68577h1.297466c48.904483 2.095906 73.65614 26.947368 77.548538 77.947758 0 0.499025 0.099805 1.097856 0 1.596882-0.59883 26.548148-19.961014 59.0846-57.687329 96.810916-51.100195 48.904483-75.951657 93.118129-75.951657 135.036257v55.990643c0 8.283821 6.68694 14.97076 14.97076 14.970761h68.366472c8.283821 0 14.97076-6.68694 14.97076-14.970761v-65.272514c0-11.377778 7.8846-32.736062 45.211696-70.162963 52.497466-50.301754 79.145419-101.002729 79.145419-150.605848l0.099805-0.898246z"), Ge(e, "class", "svg-icon"), Ge(e, "width", "100%"), Ge(e, "height", "100%"), Ge(e, "fill", "currentColor"), Ge(e, "stroke", "currentColor"), Ge(e, "stroke-width", "2"), Ge(e, "stroke-linecap", "round"), Ge(e, "stroke-linejoin", "round"), Ge(e, "viewBox", "0 0 1028 1024"), Ge(e, "version", "1.1"), Ge(e, "xmlns", "http://www.w3.org/2000/svg");
    },
    m(o, r) {
      Jm(o, e, r), Bl(e, t), Bl(e, n);
    },
    p: vs,
    i: vs,
    o: vs,
    d(o) {
      o && Zm(e);
    }
  };
}
class Ym extends Hm {
  constructor(e) {
    super(), Gm(this, e, null, Xm, Km, {});
  }
}
const {
  SvelteComponent: Qm,
  append: fn,
  attr: Zt,
  binding_callbacks: $m,
  detach: xm,
  element: gi,
  init: ep,
  insert: tp,
  listen: np,
  noop: ys,
  safe_not_equal: ip,
  space: ks,
  src_url_equal: op
} = window.__gradio__svelte__internal, { onMount: sp } = window.__gradio__svelte__internal;
function rp(i) {
  let e, t, n, o, r, s, a, l, u, c, d;
  return {
    c() {
      e = gi("dialog"), t = gi("p"), t.innerHTML = `Do you have a problem or a suggestion about the component?
        Feel free to open an issue on the <a href="https://github.com/clement-pages/gryannote/issues/new" target="_blank" class="svelte-tb0ggh">gryannote github directory</a>!`, n = ks(), o = gi("p"), o.textContent = "Component's keyboard shortcuts:", r = ks(), s = gi("img"), l = ks(), u = gi("button"), u.textContent = "Close", Zt(t, "class", "svelte-tb0ggh"), Zt(o, "class", "svelte-tb0ggh"), op(s.src, a = "https://github.com/clement-pages/gryannote/blob/main/docs/assets/shortcuts.png?raw=true") || Zt(s, "src", a), Zt(s, "alt", "component keyboard shortcut"), Zt(u, "id", "close"), Zt(u, "class", "svelte-tb0ggh"), Zt(e, "id", "help-dialog-box"), e.hidden = !0, Zt(e, "class", "svelte-tb0ggh");
    },
    m(_, f) {
      tp(_, e, f), fn(e, t), fn(e, n), fn(e, o), fn(e, r), fn(e, s), fn(e, l), fn(e, u), i[5](e), c || (d = np(
        u,
        "click",
        /*click_handler*/
        i[4]
      ), c = !0);
    },
    p: ys,
    i: ys,
    o: ys,
    d(_) {
      _ && xm(e), i[5](null), c = !1, d();
    }
  };
}
function lp(i, e, t) {
  let { isOpen: n = !1 } = e, o;
  function r() {
    o.showModal(), document.getElementById("help-dialog-box").hidden = !1, t(2, n = !0);
  }
  function s() {
    o.close(), document.getElementById("help-dialog-box").hidden = !0, t(2, n = !1);
  }
  sp(() => {
    window.addEventListener("keydown", (u) => {
      if (n)
        switch (u.key) {
          case "Escape":
            s();
            break;
        }
    });
  });
  const a = () => s();
  function l(u) {
    $m[u ? "unshift" : "push"](() => {
      o = u, t(0, o);
    });
  }
  return i.$$set = (u) => {
    "isOpen" in u && t(2, n = u.isOpen);
  }, [o, s, n, r, a, l];
}
class ap extends Qm {
  constructor(e) {
    super(), ep(this, e, lp, rp, ip, { isOpen: 2, openDialog: 3 });
  }
  get openDialog() {
    return this.$$.ctx[3];
  }
}
const {
  SvelteComponent: up,
  add_flush_callback: $n,
  append: bi,
  attr: Mt,
  bind: xn,
  binding_callbacks: Mn,
  bubble: Cs,
  check_outros: er,
  create_component: yt,
  create_slot: cp,
  destroy_component: kt,
  detach: Qt,
  element: xi,
  empty: vu,
  get_all_dirty_from_scope: dp,
  get_slot_changes: fp,
  group_outros: tr,
  init: _p,
  insert: $t,
  listen: hp,
  mount_component: Ct,
  safe_not_equal: mp,
  space: mn,
  transition_in: Pe,
  transition_out: Te,
  update_slot_base: pp
} = window.__gradio__svelte__internal, { getContext: gp, onDestroy: bp, createEventDispatcher: vp } = window.__gradio__svelte__internal;
function wp(i) {
  let e, t, n, o, r, s;
  e = new au({
    props: {
      i18n: (
        /*i18n*/
        i[9]
      ),
      download: (
        /*show_download_button*/
        i[6] ? (
          /*value*/
          i[1].file_data.url
        ) : null
      ),
      absolute: !0
    }
  }), e.$on(
    "clear",
    /*clear*/
    i[20]
  ), e.$on(
    "edit",
    /*edit_handler*/
    i[31]
  );
  function a(c) {
    i[32](c);
  }
  function l(c) {
    i[33](c);
  }
  let u = {
    value: (
      /*value*/
      i[1]
    ),
    label: (
      /*label*/
      i[3]
    ),
    i18n: (
      /*i18n*/
      i[9]
    ),
    waveform_settings: (
      /*waveform_settings*/
      i[10]
    ),
    waveform_options: (
      /*waveform_options*/
      i[11]
    ),
    editable: (
      /*editable*/
      i[12]
    ),
    interactive: !0
  };
  return (
    /*mode*/
    i[14] !== void 0 && (u.mode = /*mode*/
    i[14]), /*isDialogOpen*/
    i[15] !== void 0 && (u.isDialogOpen = /*isDialogOpen*/
    i[15]), n = new Ua({ props: u }), Mn.push(() => xn(n, "mode", a)), Mn.push(() => xn(n, "isDialogOpen", l)), n.$on(
      "stop",
      /*stop_handler*/
      i[34]
    ), n.$on(
      "play",
      /*play_handler*/
      i[35]
    ), n.$on(
      "pause",
      /*pause_handler*/
      i[36]
    ), n.$on(
      "edit",
      /*edit_handler_1*/
      i[37]
    ), {
      c() {
        yt(e.$$.fragment), t = mn(), yt(n.$$.fragment);
      },
      m(c, d) {
        Ct(e, c, d), $t(c, t, d), Ct(n, c, d), s = !0;
      },
      p(c, d) {
        const _ = {};
        d[0] & /*i18n*/
        512 && (_.i18n = /*i18n*/
        c[9]), d[0] & /*show_download_button, value*/
        66 && (_.download = /*show_download_button*/
        c[6] ? (
          /*value*/
          c[1].file_data.url
        ) : null), e.$set(_);
        const f = {};
        d[0] & /*value*/
        2 && (f.value = /*value*/
        c[1]), d[0] & /*label*/
        8 && (f.label = /*label*/
        c[3]), d[0] & /*i18n*/
        512 && (f.i18n = /*i18n*/
        c[9]), d[0] & /*waveform_settings*/
        1024 && (f.waveform_settings = /*waveform_settings*/
        c[10]), d[0] & /*waveform_options*/
        2048 && (f.waveform_options = /*waveform_options*/
        c[11]), d[0] & /*editable*/
        4096 && (f.editable = /*editable*/
        c[12]), !o && d[0] & /*mode*/
        16384 && (o = !0, f.mode = /*mode*/
        c[14], $n(() => o = !1)), !r && d[0] & /*isDialogOpen*/
        32768 && (r = !0, f.isDialogOpen = /*isDialogOpen*/
        c[15], $n(() => r = !1)), n.$set(f);
      },
      i(c) {
        s || (Pe(e.$$.fragment, c), Pe(n.$$.fragment, c), s = !0);
      },
      o(c) {
        Te(e.$$.fragment, c), Te(n.$$.fragment, c), s = !1;
      },
      d(c) {
        c && Qt(t), kt(e, c), kt(n, c);
      }
    }
  );
}
function yp(i) {
  let e, t, n, o;
  const r = [Cp, kp], s = [];
  function a(l, u) {
    return (
      /*active_source*/
      l[2] === "microphone" ? 0 : (
        /*active_source*/
        l[2] === "upload" ? 1 : -1
      )
    );
  }
  return ~(e = a(i)) && (t = s[e] = r[e](i)), {
    c() {
      t && t.c(), n = vu();
    },
    m(l, u) {
      ~e && s[e].m(l, u), $t(l, n, u), o = !0;
    },
    p(l, u) {
      let c = e;
      e = a(l), e === c ? ~e && s[e].p(l, u) : (t && (tr(), Te(s[c], 1, 1, () => {
        s[c] = null;
      }), er()), ~e ? (t = s[e], t ? t.p(l, u) : (t = s[e] = r[e](l), t.c()), Pe(t, 1), t.m(n.parentNode, n)) : t = null);
    },
    i(l) {
      o || (Pe(t), o = !0);
    },
    o(l) {
      Te(t), o = !1;
    },
    d(l) {
      l && Qt(n), ~e && s[e].d(l);
    }
  };
}
function kp(i) {
  let e, t, n;
  function o(s) {
    i[29](s);
  }
  let r = {
    filetype: "audio/aac,audio/midi,audio/mpeg,audio/ogg,audio/wav,audio/x-wav,audio/opus,audio/webm,audio/flac,audio/vnd.rn-realaudio,audio/x-ms-wma,audio/x-aiff,audio/amr,audio/*",
    root: (
      /*root*/
      i[4]
    ),
    $$slots: { default: [Sp] },
    $$scope: { ctx: i }
  };
  return (
    /*dragging*/
    i[0] !== void 0 && (r.dragging = /*dragging*/
    i[0]), e = new H1({ props: r }), Mn.push(() => xn(e, "dragging", o)), e.$on(
      "load",
      /*handle_load*/
      i[21]
    ), e.$on(
      "error",
      /*error_handler*/
      i[30]
    ), {
      c() {
        yt(e.$$.fragment);
      },
      m(s, a) {
        Ct(e, s, a), n = !0;
      },
      p(s, a) {
        const l = {};
        a[0] & /*root*/
        16 && (l.root = /*root*/
        s[4]), a[1] & /*$$scope*/
        2048 && (l.$$scope = { dirty: a, ctx: s }), !t && a[0] & /*dragging*/
        1 && (t = !0, l.dragging = /*dragging*/
        s[0], $n(() => t = !1)), e.$set(l);
      },
      i(s) {
        n || (Pe(e.$$.fragment, s), n = !0);
      },
      o(s) {
        Te(e.$$.fragment, s), n = !1;
      },
      d(s) {
        kt(e, s);
      }
    }
  );
}
function Cp(i) {
  let e, t, n, o, r, s;
  e = new au({
    props: { i18n: (
      /*i18n*/
      i[9]
    ), absolute: !0 }
  }), e.$on(
    "clear",
    /*clear*/
    i[20]
  );
  const a = [Dp, Ep], l = [];
  function u(c, d) {
    return (
      /*streaming*/
      c[8] ? 0 : 1
    );
  }
  return n = u(i), o = l[n] = a[n](i), {
    c() {
      yt(e.$$.fragment), t = mn(), o.c(), r = vu();
    },
    m(c, d) {
      Ct(e, c, d), $t(c, t, d), l[n].m(c, d), $t(c, r, d), s = !0;
    },
    p(c, d) {
      const _ = {};
      d[0] & /*i18n*/
      512 && (_.i18n = /*i18n*/
      c[9]), e.$set(_);
      let f = n;
      n = u(c), n === f ? l[n].p(c, d) : (tr(), Te(l[f], 1, 1, () => {
        l[f] = null;
      }), er(), o = l[n], o ? o.p(c, d) : (o = l[n] = a[n](c), o.c()), Pe(o, 1), o.m(r.parentNode, r));
    },
    i(c) {
      s || (Pe(e.$$.fragment, c), Pe(o), s = !0);
    },
    o(c) {
      Te(e.$$.fragment, c), Te(o), s = !1;
    },
    d(c) {
      c && (Qt(t), Qt(r)), kt(e, c), l[n].d(c);
    }
  };
}
function Sp(i) {
  let e;
  const t = (
    /*#slots*/
    i[27].default
  ), n = cp(
    t,
    i,
    /*$$scope*/
    i[42],
    null
  );
  return {
    c() {
      n && n.c();
    },
    m(o, r) {
      n && n.m(o, r), e = !0;
    },
    p(o, r) {
      n && n.p && (!e || r[1] & /*$$scope*/
      2048) && pp(
        n,
        t,
        o,
        /*$$scope*/
        o[42],
        e ? fp(
          t,
          /*$$scope*/
          o[42],
          r,
          null
        ) : dp(
          /*$$scope*/
          o[42]
        ),
        null
      );
    },
    i(o) {
      e || (Pe(n, o), e = !0);
    },
    o(o) {
      Te(n, o), e = !1;
    },
    d(o) {
      n && n.d(o);
    }
  };
}
function Ep(i) {
  let e, t, n;
  function o(s) {
    i[28](s);
  }
  let r = {
    i18n: (
      /*i18n*/
      i[9]
    ),
    dispatch_blob: (
      /*dispatch_blob*/
      i[18]
    ),
    waveform_settings: (
      /*waveform_settings*/
      i[10]
    ),
    waveform_options: (
      /*waveform_options*/
      i[11]
    )
  };
  return (
    /*mode*/
    i[14] !== void 0 && (r.mode = /*mode*/
    i[14]), e = new zm({ props: r }), Mn.push(() => xn(e, "mode", o)), {
      c() {
        yt(e.$$.fragment);
      },
      m(s, a) {
        Ct(e, s, a), n = !0;
      },
      p(s, a) {
        const l = {};
        a[0] & /*i18n*/
        512 && (l.i18n = /*i18n*/
        s[9]), a[0] & /*waveform_settings*/
        1024 && (l.waveform_settings = /*waveform_settings*/
        s[10]), a[0] & /*waveform_options*/
        2048 && (l.waveform_options = /*waveform_options*/
        s[11]), !t && a[0] & /*mode*/
        16384 && (t = !0, l.mode = /*mode*/
        s[14], $n(() => t = !1)), e.$set(l);
      },
      i(s) {
        n || (Pe(e.$$.fragment, s), n = !0);
      },
      o(s) {
        Te(e.$$.fragment, s), n = !1;
      },
      d(s) {
        kt(e, s);
      }
    }
  );
}
function Dp(i) {
  let e, t;
  return e = new Vm({
    props: {
      record: (
        /*record*/
        i[19]
      ),
      recording: (
        /*recording*/
        i[13]
      ),
      stop: (
        /*stop*/
        i[22]
      ),
      i18n: (
        /*i18n*/
        i[9]
      ),
      waveform_settings: (
        /*waveform_settings*/
        i[10]
      ),
      waveform_options: (
        /*waveform_options*/
        i[11]
      )
    }
  }), {
    c() {
      yt(e.$$.fragment);
    },
    m(n, o) {
      Ct(e, n, o), t = !0;
    },
    p(n, o) {
      const r = {};
      o[0] & /*recording*/
      8192 && (r.recording = /*recording*/
      n[13]), o[0] & /*i18n*/
      512 && (r.i18n = /*i18n*/
      n[9]), o[0] & /*waveform_settings*/
      1024 && (r.waveform_settings = /*waveform_settings*/
      n[10]), o[0] & /*waveform_options*/
      2048 && (r.waveform_options = /*waveform_options*/
      n[11]), e.$set(r);
    },
    i(n) {
      t || (Pe(e.$$.fragment, n), t = !0);
    },
    o(n) {
      Te(e.$$.fragment, n), t = !1;
    },
    d(n) {
      kt(e, n);
    }
  };
}
function Lp(i) {
  let e, t, n, o, r, s, a, l, u, c, d, _, f, h, p, g, m, k, w, S;
  e = new da({
    props: {
      show_label: (
        /*show_label*/
        i[5]
      ),
      Icon: go,
      float: (
        /*active_source*/
        i[2] === "upload" && /*value*/
        i[1] === null
      ),
      label: (
        /*label*/
        i[3] || /*i18n*/
        i[9]("audio.audio")
      )
    }
  });
  const v = [yp, wp], b = [];
  function L(q, N) {
    return (
      /*value*/
      q[1] === null || /*streaming*/
      q[8] ? 0 : 1
    );
  }
  n = L(i), o = b[n] = v[n](i);
  function E(q) {
    i[38](q);
  }
  let D = {
    sources: (
      /*sources*/
      i[7]
    ),
    handle_clear: (
      /*clear*/
      i[20]
    )
  };
  /*active_source*/
  i[2] !== void 0 && (D.active_source = /*active_source*/
  i[2]), c = new v_({ props: D }), Mn.push(() => xn(c, "active_source", E)), h = new Ym({});
  function P(q) {
    i[41](q);
  }
  let F = {};
  return (
    /*isDialogOpen*/
    i[15] !== void 0 && (F.isOpen = /*isDialogOpen*/
    i[15]), g = new ap({ props: F }), i[40](g), Mn.push(() => xn(g, "isOpen", P)), {
      c() {
        yt(e.$$.fragment), t = mn(), o.c(), r = mn(), s = xi("div"), a = xi("a"), a.innerHTML = '<img src="https://github.com/clement-pages/gryannote/blob/main/docs/assets/logo-gryannote.png?raw=true" alt=" " id="logo" class="svelte-10l5pns"/> <p>provided by gryannote</p>', l = mn(), u = xi("div"), yt(c.$$.fragment), _ = mn(), f = xi("button"), yt(h.$$.fragment), p = mn(), yt(g.$$.fragment), Mt(a, "href", "https://github.com/clement-pages/gryannote"), Mt(a, "id", "logo-link"), Mt(a, "class", "svelte-10l5pns"), Mt(u, "id", "select-source"), Mt(u, "class", "svelte-10l5pns"), Mt(f, "id", "help-button"), Mt(f, "title", "help"), Mt(f, "class", "svelte-10l5pns"), Mt(s, "class", "button-zone svelte-10l5pns");
      },
      m(q, N) {
        Ct(e, q, N), $t(q, t, N), b[n].m(q, N), $t(q, r, N), $t(q, s, N), bi(s, a), bi(s, l), bi(s, u), Ct(c, u, null), bi(s, _), bi(s, f), Ct(h, f, null), $t(q, p, N), Ct(g, q, N), k = !0, w || (S = hp(
          f,
          "click",
          /*click_handler*/
          i[39]
        ), w = !0);
      },
      p(q, N) {
        const Y = {};
        N[0] & /*show_label*/
        32 && (Y.show_label = /*show_label*/
        q[5]), N[0] & /*active_source, value*/
        6 && (Y.float = /*active_source*/
        q[2] === "upload" && /*value*/
        q[1] === null), N[0] & /*label, i18n*/
        520 && (Y.label = /*label*/
        q[3] || /*i18n*/
        q[9]("audio.audio")), e.$set(Y);
        let J = n;
        n = L(q), n === J ? b[n].p(q, N) : (tr(), Te(b[J], 1, 1, () => {
          b[J] = null;
        }), er(), o = b[n], o ? o.p(q, N) : (o = b[n] = v[n](q), o.c()), Pe(o, 1), o.m(r.parentNode, r));
        const O = {};
        N[0] & /*sources*/
        128 && (O.sources = /*sources*/
        q[7]), !d && N[0] & /*active_source*/
        4 && (d = !0, O.active_source = /*active_source*/
        q[2], $n(() => d = !1)), c.$set(O);
        const T = {};
        !m && N[0] & /*isDialogOpen*/
        32768 && (m = !0, T.isOpen = /*isDialogOpen*/
        q[15], $n(() => m = !1)), g.$set(T);
      },
      i(q) {
        k || (Pe(e.$$.fragment, q), Pe(o), Pe(c.$$.fragment, q), Pe(h.$$.fragment, q), Pe(g.$$.fragment, q), k = !0);
      },
      o(q) {
        Te(e.$$.fragment, q), Te(o), Te(c.$$.fragment, q), Te(h.$$.fragment, q), Te(g.$$.fragment, q), k = !1;
      },
      d(q) {
        q && (Qt(t), Qt(r), Qt(s), Qt(p)), kt(e, q), b[n].d(q), kt(c), kt(h), i[40](null), kt(g, q), w = !1, S();
      }
    }
  );
}
const Rp = 500, Wl = 44;
function Mp(i, e, t) {
  let { $$slots: n = {}, $$scope: o } = e;
  var r = this && this.__awaiter || function(z, ge, H, re) {
    function le(x) {
      return x instanceof H ? x : new H(function(he) {
        he(x);
      });
    }
    return new (H || (H = Promise))(function(x, he) {
      function me(Ae) {
        try {
          se(re.next(Ae));
        } catch (on) {
          he(on);
        }
      }
      function oe(Ae) {
        try {
          se(re.throw(Ae));
        } catch (on) {
          he(on);
        }
      }
      function se(Ae) {
        Ae.done ? x(Ae.value) : le(Ae.value).then(me, oe);
      }
      se((re = re.apply(z, ge || [])).next());
    });
  };
  let { value: s = null } = e, { label: a } = e, { root: l } = e, { show_label: u = !0 } = e, { show_download_button: c = !0 } = e, { sources: d = ["microphone", "upload"] } = e, { pending: _ = !1 } = e, { streaming: f = !1 } = e, { i18n: h } = e, { waveform_settings: p } = e, { waveform_options: g = {} } = e, { dragging: m } = e, { active_source: k } = e, { editable: w = !0 } = e;
  const S = gp("upload_files");
  let v = !1, b, L = "", E, D = [], P = !1, F = !1, q = !1, N, Y = [], J;
  function O() {
    J = [
      import("./module-DzLvOVma.js"),
      import("./module-wPUp6Scx.js")
    ];
  }
  f && O();
  const T = vp(), V = (z, ge) => r(void 0, void 0, void 0, function* () {
    var H;
    let re = new File(z, "audio.wav");
    const le = yield Xa([re], ge === "stream");
    let x = ((H = yield Ka(le, l, void 0, S)) === null || H === void 0 ? void 0 : H.filter(Boolean))[0];
    s === null ? t(1, s = new Cl(x)) : t(1, s.file_data = x, s), T(ge, s);
  });
  bp(() => {
    f && b && b.state !== "inactive" && b.stop();
  });
  function K() {
    return r(this, void 0, void 0, function* () {
      let z;
      try {
        z = yield navigator.mediaDevices.getUserMedia({ audio: !0 });
      } catch (ge) {
        if (!navigator.mediaDevices) {
          T("error", h("audio.no_device_support"));
          return;
        }
        if (ge instanceof DOMException && ge.name == "NotAllowedError") {
          T("error", h("audio.allow_recording_access"));
          return;
        }
        throw ge;
      }
      if (z != null) {
        if (f) {
          const [{ MediaRecorder: ge, register: H }, { connect: re }] = yield Promise.all(J);
          yield H(yield re()), b = new ge(z, { mimeType: "audio/wav" }), b.addEventListener("dataavailable", I);
        } else
          b = new MediaRecorder(z), b.addEventListener("dataavailable", (ge) => {
            Y.push(ge.data);
          }), b.addEventListener("stop", () => r(this, void 0, void 0, function* () {
            t(13, v = !1), yield V(Y, "change"), yield V(Y, "stop_recording"), Y = [];
          }));
        F = !0;
      }
    });
  }
  function I(z) {
    return r(this, void 0, void 0, function* () {
      let ge = yield z.data.arrayBuffer(), H = new Uint8Array(ge);
      if (E || (t(24, E = new Uint8Array(ge.slice(0, Wl))), H = new Uint8Array(ge.slice(Wl))), _)
        D.push(H);
      else {
        let re = [E].concat(D, [H]);
        V(re, "stream"), t(25, D = []);
      }
    });
  }
  function $() {
    return r(this, void 0, void 0, function* () {
      t(13, v = !0), T("start_recording"), F || (yield K()), t(24, E = void 0), f && b.start(Rp);
    });
  }
  function te() {
    T("change", null), T("clear"), t(14, L = ""), t(1, s = null);
  }
  function M({ detail: z }) {
    t(1, s = new Cl(z)), T("change", s), T("upload", z);
  }
  function C() {
    t(13, v = !1), f && (T("stop_recording"), b.stop(), _ && t(26, P = !0), V(Y, "stop_recording"), T("clear"), t(14, L = ""));
  }
  function R(z) {
    L = z, t(14, L);
  }
  function j(z) {
    m = z, t(0, m);
  }
  const Q = ({ detail: z }) => T("error", z), X = () => t(14, L = "edit");
  function B(z) {
    L = z, t(14, L);
  }
  function ue(z) {
    q = z, t(15, q);
  }
  function A(z) {
    Cs.call(this, i, z);
  }
  function de(z) {
    Cs.call(this, i, z);
  }
  function fe(z) {
    Cs.call(this, i, z);
  }
  const _e = (z) => T("edit", z.detail);
  function Lt(z) {
    k = z, t(2, k);
  }
  const ne = () => N.openDialog();
  function Tt(z) {
    Mn[z ? "unshift" : "push"](() => {
      N = z, t(16, N);
    });
  }
  function Nt(z) {
    q = z, t(15, q);
  }
  return i.$$set = (z) => {
    "value" in z && t(1, s = z.value), "label" in z && t(3, a = z.label), "root" in z && t(4, l = z.root), "show_label" in z && t(5, u = z.show_label), "show_download_button" in z && t(6, c = z.show_download_button), "sources" in z && t(7, d = z.sources), "pending" in z && t(23, _ = z.pending), "streaming" in z && t(8, f = z.streaming), "i18n" in z && t(9, h = z.i18n), "waveform_settings" in z && t(10, p = z.waveform_settings), "waveform_options" in z && t(11, g = z.waveform_options), "dragging" in z && t(0, m = z.dragging), "active_source" in z && t(2, k = z.active_source), "editable" in z && t(12, w = z.editable), "$$scope" in z && t(42, o = z.$$scope);
  }, i.$$.update = () => {
    if (i.$$.dirty[0] & /*dragging*/
    1 && T("drag", m), i.$$.dirty[0] & /*submit_pending_stream_on_pending_end, pending, header, pending_stream*/
    125829120 && P && _ === !1 && (t(26, P = !1), E && D)) {
      let z = [E].concat(D);
      t(25, D = []), V(z, "stream");
    }
  }, [
    m,
    s,
    k,
    a,
    l,
    u,
    c,
    d,
    f,
    h,
    p,
    g,
    w,
    v,
    L,
    q,
    N,
    T,
    V,
    $,
    te,
    M,
    C,
    _,
    E,
    D,
    P,
    n,
    R,
    j,
    Q,
    X,
    B,
    ue,
    A,
    de,
    fe,
    _e,
    Lt,
    ne,
    Tt,
    Nt,
    o
  ];
}
class Op extends up {
  constructor(e) {
    super(), _p(
      this,
      e,
      Mp,
      Lp,
      mp,
      {
        value: 1,
        label: 3,
        root: 4,
        show_label: 5,
        show_download_button: 6,
        sources: 7,
        pending: 23,
        streaming: 8,
        i18n: 9,
        waveform_settings: 10,
        waveform_options: 11,
        dragging: 0,
        active_source: 2,
        editable: 12
      },
      null,
      [-1, -1]
    );
  }
}
function Kn(i) {
  let e = ["", "k", "M", "G", "T", "P", "E", "Z"], t = 0;
  for (; i > 1e3 && t < e.length - 1; )
    i /= 1e3, t++;
  let n = e[t];
  return (Number.isInteger(i) ? i : i.toFixed(1)) + n;
}
function lo() {
}
function qp(i, e) {
  return i != i ? e == e : i !== e || i && typeof i == "object" || typeof i == "function";
}
const wu = typeof window < "u";
let Il = wu ? () => window.performance.now() : () => Date.now(), yu = wu ? (i) => requestAnimationFrame(i) : lo;
const Yn = /* @__PURE__ */ new Set();
function ku(i) {
  Yn.forEach((e) => {
    e.c(i) || (Yn.delete(e), e.f());
  }), Yn.size !== 0 && yu(ku);
}
function Ap(i) {
  let e;
  return Yn.size === 0 && yu(ku), {
    promise: new Promise((t) => {
      Yn.add(e = { c: i, f: t });
    }),
    abort() {
      Yn.delete(e);
    }
  };
}
const Un = [];
function zp(i, e = lo) {
  let t;
  const n = /* @__PURE__ */ new Set();
  function o(a) {
    if (qp(i, a) && (i = a, t)) {
      const l = !Un.length;
      for (const u of n)
        u[1](), Un.push(u, i);
      if (l) {
        for (let u = 0; u < Un.length; u += 2)
          Un[u][0](Un[u + 1]);
        Un.length = 0;
      }
    }
  }
  function r(a) {
    o(a(i));
  }
  function s(a, l = lo) {
    const u = [a, l];
    return n.add(u), n.size === 1 && (t = e(o, r) || lo), a(i), () => {
      n.delete(u), n.size === 0 && t && (t(), t = null);
    };
  }
  return { set: o, update: r, subscribe: s };
}
function Ul(i) {
  return Object.prototype.toString.call(i) === "[object Date]";
}
function Vs(i, e, t, n) {
  if (typeof t == "number" || Ul(t)) {
    const o = n - t, r = (t - e) / (i.dt || 1 / 60), s = i.opts.stiffness * o, a = i.opts.damping * r, l = (s - a) * i.inv_mass, u = (r + l) * i.dt;
    return Math.abs(u) < i.opts.precision && Math.abs(o) < i.opts.precision ? n : (i.settled = !1, Ul(t) ? new Date(t.getTime() + u) : t + u);
  } else {
    if (Array.isArray(t))
      return t.map(
        (o, r) => Vs(i, e[r], t[r], n[r])
      );
    if (typeof t == "object") {
      const o = {};
      for (const r in t)
        o[r] = Vs(i, e[r], t[r], n[r]);
      return o;
    } else
      throw new Error(`Cannot spring ${typeof t} values`);
  }
}
function Fl(i, e = {}) {
  const t = zp(i), { stiffness: n = 0.15, damping: o = 0.8, precision: r = 0.01 } = e;
  let s, a, l, u = i, c = i, d = 1, _ = 0, f = !1;
  function h(g, m = {}) {
    c = g;
    const k = l = {};
    return i == null || m.hard || p.stiffness >= 1 && p.damping >= 1 ? (f = !0, s = Il(), u = g, t.set(i = c), Promise.resolve()) : (m.soft && (_ = 1 / ((m.soft === !0 ? 0.5 : +m.soft) * 60), d = 0), a || (s = Il(), f = !1, a = Ap((w) => {
      if (f)
        return f = !1, a = null, !1;
      d = Math.min(d + _, 1);
      const S = {
        inv_mass: d,
        opts: p,
        settled: !0,
        dt: (w - s) * 60 / 1e3
      }, v = Vs(S, u, i, c);
      return s = w, u = i, t.set(i = v), S.settled && (a = null), !S.settled;
    })), new Promise((w) => {
      a.promise.then(() => {
        k === l && w();
      });
    }));
  }
  const p = {
    set: h,
    update: (g, m) => h(g(c, i), m),
    subscribe: t.subscribe,
    stiffness: n,
    damping: o,
    precision: r
  };
  return p;
}
const {
  SvelteComponent: jp,
  append: ut,
  attr: ie,
  component_subscribe: Vl,
  detach: Pp,
  element: Tp,
  init: Np,
  insert: Bp,
  noop: Hl,
  safe_not_equal: Wp,
  set_style: eo,
  svg_element: ct,
  toggle_class: Zl
} = window.__gradio__svelte__internal, { onMount: Ip } = window.__gradio__svelte__internal;
function Up(i) {
  let e, t, n, o, r, s, a, l, u, c, d, _;
  return {
    c() {
      e = Tp("div"), t = ct("svg"), n = ct("g"), o = ct("path"), r = ct("path"), s = ct("path"), a = ct("path"), l = ct("g"), u = ct("path"), c = ct("path"), d = ct("path"), _ = ct("path"), ie(o, "d", "M255.926 0.754768L509.702 139.936V221.027L255.926 81.8465V0.754768Z"), ie(o, "fill", "#FF7C00"), ie(o, "fill-opacity", "0.4"), ie(o, "class", "svelte-43sxxs"), ie(r, "d", "M509.69 139.936L254.981 279.641V361.255L509.69 221.55V139.936Z"), ie(r, "fill", "#FF7C00"), ie(r, "class", "svelte-43sxxs"), ie(s, "d", "M0.250138 139.937L254.981 279.641V361.255L0.250138 221.55V139.937Z"), ie(s, "fill", "#FF7C00"), ie(s, "fill-opacity", "0.4"), ie(s, "class", "svelte-43sxxs"), ie(a, "d", "M255.923 0.232622L0.236328 139.936V221.55L255.923 81.8469V0.232622Z"), ie(a, "fill", "#FF7C00"), ie(a, "class", "svelte-43sxxs"), eo(n, "transform", "translate(" + /*$top*/
      i[1][0] + "px, " + /*$top*/
      i[1][1] + "px)"), ie(u, "d", "M255.926 141.5L509.702 280.681V361.773L255.926 222.592V141.5Z"), ie(u, "fill", "#FF7C00"), ie(u, "fill-opacity", "0.4"), ie(u, "class", "svelte-43sxxs"), ie(c, "d", "M509.69 280.679L254.981 420.384V501.998L509.69 362.293V280.679Z"), ie(c, "fill", "#FF7C00"), ie(c, "class", "svelte-43sxxs"), ie(d, "d", "M0.250138 280.681L254.981 420.386V502L0.250138 362.295V280.681Z"), ie(d, "fill", "#FF7C00"), ie(d, "fill-opacity", "0.4"), ie(d, "class", "svelte-43sxxs"), ie(_, "d", "M255.923 140.977L0.236328 280.68V362.294L255.923 222.591V140.977Z"), ie(_, "fill", "#FF7C00"), ie(_, "class", "svelte-43sxxs"), eo(l, "transform", "translate(" + /*$bottom*/
      i[2][0] + "px, " + /*$bottom*/
      i[2][1] + "px)"), ie(t, "viewBox", "-1200 -1200 3000 3000"), ie(t, "fill", "none"), ie(t, "xmlns", "http://www.w3.org/2000/svg"), ie(t, "class", "svelte-43sxxs"), ie(e, "class", "svelte-43sxxs"), Zl(
        e,
        "margin",
        /*margin*/
        i[0]
      );
    },
    m(f, h) {
      Bp(f, e, h), ut(e, t), ut(t, n), ut(n, o), ut(n, r), ut(n, s), ut(n, a), ut(t, l), ut(l, u), ut(l, c), ut(l, d), ut(l, _);
    },
    p(f, [h]) {
      h & /*$top*/
      2 && eo(n, "transform", "translate(" + /*$top*/
      f[1][0] + "px, " + /*$top*/
      f[1][1] + "px)"), h & /*$bottom*/
      4 && eo(l, "transform", "translate(" + /*$bottom*/
      f[2][0] + "px, " + /*$bottom*/
      f[2][1] + "px)"), h & /*margin*/
      1 && Zl(
        e,
        "margin",
        /*margin*/
        f[0]
      );
    },
    i: Hl,
    o: Hl,
    d(f) {
      f && Pp(e);
    }
  };
}
function Fp(i, e, t) {
  let n, o;
  var r = this && this.__awaiter || function(f, h, p, g) {
    function m(k) {
      return k instanceof p ? k : new p(function(w) {
        w(k);
      });
    }
    return new (p || (p = Promise))(function(k, w) {
      function S(L) {
        try {
          b(g.next(L));
        } catch (E) {
          w(E);
        }
      }
      function v(L) {
        try {
          b(g.throw(L));
        } catch (E) {
          w(E);
        }
      }
      function b(L) {
        L.done ? k(L.value) : m(L.value).then(S, v);
      }
      b((g = g.apply(f, h || [])).next());
    });
  };
  let { margin: s = !0 } = e;
  const a = Fl([0, 0]);
  Vl(i, a, (f) => t(1, n = f));
  const l = Fl([0, 0]);
  Vl(i, l, (f) => t(2, o = f));
  let u;
  function c() {
    return r(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 d() {
    return r(this, void 0, void 0, function* () {
      yield c(), u || d();
    });
  }
  function _() {
    return r(this, void 0, void 0, function* () {
      yield Promise.all([a.set([125, 0]), l.set([-125, 0])]), d();
    });
  }
  return Ip(() => (_(), () => u = !0)), i.$$set = (f) => {
    "margin" in f && t(0, s = f.margin);
  }, [s, n, o, a, l];
}
class Vp extends jp {
  constructor(e) {
    super(), Np(this, e, Fp, Up, Wp, { margin: 0 });
  }
}
const {
  SvelteComponent: Hp,
  append: vn,
  attr: St,
  binding_callbacks: Gl,
  check_outros: Cu,
  create_component: Zp,
  create_slot: Gp,
  destroy_component: Jp,
  destroy_each: Su,
  detach: Z,
  element: At,
  empty: li,
  ensure_array_like: po,
  get_all_dirty_from_scope: Kp,
  get_slot_changes: Xp,
  group_outros: Eu,
  init: Yp,
  insert: G,
  mount_component: Qp,
  noop: Hs,
  safe_not_equal: $p,
  set_data: st,
  set_style: xt,
  space: Et,
  text: pe,
  toggle_class: it,
  transition_in: ei,
  transition_out: ti,
  update_slot_base: xp
} = window.__gradio__svelte__internal, { tick: eg } = window.__gradio__svelte__internal, { onDestroy: tg } = window.__gradio__svelte__internal, ng = (i) => ({}), Jl = (i) => ({});
function Kl(i, e, t) {
  const n = i.slice();
  return n[39] = e[t], n[41] = t, n;
}
function Xl(i, e, t) {
  const n = i.slice();
  return n[39] = e[t], n;
}
function ig(i) {
  let e, t = (
    /*i18n*/
    i[1]("common.error") + ""
  ), n, o, r;
  const s = (
    /*#slots*/
    i[29].error
  ), a = Gp(
    s,
    i,
    /*$$scope*/
    i[28],
    Jl
  );
  return {
    c() {
      e = At("span"), n = pe(t), o = Et(), a && a.c(), St(e, "class", "error svelte-1yserjw");
    },
    m(l, u) {
      G(l, e, u), vn(e, n), G(l, o, u), a && a.m(l, u), r = !0;
    },
    p(l, u) {
      (!r || u[0] & /*i18n*/
      2) && t !== (t = /*i18n*/
      l[1]("common.error") + "") && st(n, t), a && a.p && (!r || u[0] & /*$$scope*/
      268435456) && xp(
        a,
        s,
        l,
        /*$$scope*/
        l[28],
        r ? Xp(
          s,
          /*$$scope*/
          l[28],
          u,
          ng
        ) : Kp(
          /*$$scope*/
          l[28]
        ),
        Jl
      );
    },
    i(l) {
      r || (ei(a, l), r = !0);
    },
    o(l) {
      ti(a, l), r = !1;
    },
    d(l) {
      l && (Z(e), Z(o)), a && a.d(l);
    }
  };
}
function og(i) {
  let e, t, n, o, r, s, a, l, u, c = (
    /*variant*/
    i[8] === "default" && /*show_eta_bar*/
    i[18] && /*show_progress*/
    i[6] === "full" && Yl(i)
  );
  function d(w, S) {
    if (
      /*progress*/
      w[7]
    )
      return lg;
    if (
      /*queue_position*/
      w[2] !== null && /*queue_size*/
      w[3] !== void 0 && /*queue_position*/
      w[2] >= 0
    )
      return rg;
    if (
      /*queue_position*/
      w[2] === 0
    )
      return sg;
  }
  let _ = d(i), f = _ && _(i), h = (
    /*timer*/
    i[5] && xl(i)
  );
  const p = [dg, cg], g = [];
  function m(w, S) {
    return (
      /*last_progress_level*/
      w[15] != null ? 0 : (
        /*show_progress*/
        w[6] === "full" ? 1 : -1
      )
    );
  }
  ~(r = m(i)) && (s = g[r] = p[r](i));
  let k = !/*timer*/
  i[5] && ra(i);
  return {
    c() {
      c && c.c(), e = Et(), t = At("div"), f && f.c(), n = Et(), h && h.c(), o = Et(), s && s.c(), a = Et(), k && k.c(), l = li(), St(t, "class", "progress-text svelte-1yserjw"), it(
        t,
        "meta-text-center",
        /*variant*/
        i[8] === "center"
      ), it(
        t,
        "meta-text",
        /*variant*/
        i[8] === "default"
      );
    },
    m(w, S) {
      c && c.m(w, S), G(w, e, S), G(w, t, S), f && f.m(t, null), vn(t, n), h && h.m(t, null), G(w, o, S), ~r && g[r].m(w, S), G(w, a, S), k && k.m(w, S), G(w, l, S), u = !0;
    },
    p(w, S) {
      /*variant*/
      w[8] === "default" && /*show_eta_bar*/
      w[18] && /*show_progress*/
      w[6] === "full" ? c ? c.p(w, S) : (c = Yl(w), c.c(), c.m(e.parentNode, e)) : c && (c.d(1), c = null), _ === (_ = d(w)) && f ? f.p(w, S) : (f && f.d(1), f = _ && _(w), f && (f.c(), f.m(t, n))), /*timer*/
      w[5] ? h ? h.p(w, S) : (h = xl(w), h.c(), h.m(t, null)) : h && (h.d(1), h = null), (!u || S[0] & /*variant*/
      256) && it(
        t,
        "meta-text-center",
        /*variant*/
        w[8] === "center"
      ), (!u || S[0] & /*variant*/
      256) && it(
        t,
        "meta-text",
        /*variant*/
        w[8] === "default"
      );
      let v = r;
      r = m(w), r === v ? ~r && g[r].p(w, S) : (s && (Eu(), ti(g[v], 1, 1, () => {
        g[v] = null;
      }), Cu()), ~r ? (s = g[r], s ? s.p(w, S) : (s = g[r] = p[r](w), s.c()), ei(s, 1), s.m(a.parentNode, a)) : s = null), /*timer*/
      w[5] ? k && (k.d(1), k = null) : k ? k.p(w, S) : (k = ra(w), k.c(), k.m(l.parentNode, l));
    },
    i(w) {
      u || (ei(s), u = !0);
    },
    o(w) {
      ti(s), u = !1;
    },
    d(w) {
      w && (Z(e), Z(t), Z(o), Z(a), Z(l)), c && c.d(w), f && f.d(), h && h.d(), ~r && g[r].d(w), k && k.d(w);
    }
  };
}
function Yl(i) {
  let e, t = `translateX(${/*eta_level*/
  (i[17] || 0) * 100 - 100}%)`;
  return {
    c() {
      e = At("div"), St(e, "class", "eta-bar svelte-1yserjw"), xt(e, "transform", t);
    },
    m(n, o) {
      G(n, e, o);
    },
    p(n, o) {
      o[0] & /*eta_level*/
      131072 && t !== (t = `translateX(${/*eta_level*/
      (n[17] || 0) * 100 - 100}%)`) && xt(e, "transform", t);
    },
    d(n) {
      n && Z(e);
    }
  };
}
function sg(i) {
  let e;
  return {
    c() {
      e = pe("processing |");
    },
    m(t, n) {
      G(t, e, n);
    },
    p: Hs,
    d(t) {
      t && Z(e);
    }
  };
}
function rg(i) {
  let e, t = (
    /*queue_position*/
    i[2] + 1 + ""
  ), n, o, r, s;
  return {
    c() {
      e = pe("queue: "), n = pe(t), o = pe("/"), r = pe(
        /*queue_size*/
        i[3]
      ), s = pe(" |");
    },
    m(a, l) {
      G(a, e, l), G(a, n, l), G(a, o, l), G(a, r, l), G(a, s, l);
    },
    p(a, l) {
      l[0] & /*queue_position*/
      4 && t !== (t = /*queue_position*/
      a[2] + 1 + "") && st(n, t), l[0] & /*queue_size*/
      8 && st(
        r,
        /*queue_size*/
        a[3]
      );
    },
    d(a) {
      a && (Z(e), Z(n), Z(o), Z(r), Z(s));
    }
  };
}
function lg(i) {
  let e, t = po(
    /*progress*/
    i[7]
  ), n = [];
  for (let o = 0; o < t.length; o += 1)
    n[o] = $l(Xl(i, t, o));
  return {
    c() {
      for (let o = 0; o < n.length; o += 1)
        n[o].c();
      e = li();
    },
    m(o, r) {
      for (let s = 0; s < n.length; s += 1)
        n[s] && n[s].m(o, r);
      G(o, e, r);
    },
    p(o, r) {
      if (r[0] & /*progress*/
      128) {
        t = po(
          /*progress*/
          o[7]
        );
        let s;
        for (s = 0; s < t.length; s += 1) {
          const a = Xl(o, t, s);
          n[s] ? n[s].p(a, r) : (n[s] = $l(a), n[s].c(), n[s].m(e.parentNode, e));
        }
        for (; s < n.length; s += 1)
          n[s].d(1);
        n.length = t.length;
      }
    },
    d(o) {
      o && Z(e), Su(n, o);
    }
  };
}
function Ql(i) {
  let e, t = (
    /*p*/
    i[39].unit + ""
  ), n, o, r = " ", s;
  function a(c, d) {
    return (
      /*p*/
      c[39].length != null ? ug : ag
    );
  }
  let l = a(i), u = l(i);
  return {
    c() {
      u.c(), e = Et(), n = pe(t), o = pe(" | "), s = pe(r);
    },
    m(c, d) {
      u.m(c, d), G(c, e, d), G(c, n, d), G(c, o, d), G(c, s, d);
    },
    p(c, d) {
      l === (l = a(c)) && u ? u.p(c, d) : (u.d(1), u = l(c), u && (u.c(), u.m(e.parentNode, e))), d[0] & /*progress*/
      128 && t !== (t = /*p*/
      c[39].unit + "") && st(n, t);
    },
    d(c) {
      c && (Z(e), Z(n), Z(o), Z(s)), u.d(c);
    }
  };
}
function ag(i) {
  let e = Kn(
    /*p*/
    i[39].index || 0
  ) + "", t;
  return {
    c() {
      t = pe(e);
    },
    m(n, o) {
      G(n, t, o);
    },
    p(n, o) {
      o[0] & /*progress*/
      128 && e !== (e = Kn(
        /*p*/
        n[39].index || 0
      ) + "") && st(t, e);
    },
    d(n) {
      n && Z(t);
    }
  };
}
function ug(i) {
  let e = Kn(
    /*p*/
    i[39].index || 0
  ) + "", t, n, o = Kn(
    /*p*/
    i[39].length
  ) + "", r;
  return {
    c() {
      t = pe(e), n = pe("/"), r = pe(o);
    },
    m(s, a) {
      G(s, t, a), G(s, n, a), G(s, r, a);
    },
    p(s, a) {
      a[0] & /*progress*/
      128 && e !== (e = Kn(
        /*p*/
        s[39].index || 0
      ) + "") && st(t, e), a[0] & /*progress*/
      128 && o !== (o = Kn(
        /*p*/
        s[39].length
      ) + "") && st(r, o);
    },
    d(s) {
      s && (Z(t), Z(n), Z(r));
    }
  };
}
function $l(i) {
  let e, t = (
    /*p*/
    i[39].index != null && Ql(i)
  );
  return {
    c() {
      t && t.c(), e = li();
    },
    m(n, o) {
      t && t.m(n, o), G(n, e, o);
    },
    p(n, o) {
      /*p*/
      n[39].index != null ? t ? t.p(n, o) : (t = Ql(n), t.c(), t.m(e.parentNode, e)) : t && (t.d(1), t = null);
    },
    d(n) {
      n && Z(e), t && t.d(n);
    }
  };
}
function xl(i) {
  let e, t = (
    /*eta*/
    i[0] ? `/${/*formatted_eta*/
    i[19]}` : ""
  ), n, o;
  return {
    c() {
      e = pe(
        /*formatted_timer*/
        i[20]
      ), n = pe(t), o = pe("s");
    },
    m(r, s) {
      G(r, e, s), G(r, n, s), G(r, o, s);
    },
    p(r, s) {
      s[0] & /*formatted_timer*/
      1048576 && st(
        e,
        /*formatted_timer*/
        r[20]
      ), s[0] & /*eta, formatted_eta*/
      524289 && t !== (t = /*eta*/
      r[0] ? `/${/*formatted_eta*/
      r[19]}` : "") && st(n, t);
    },
    d(r) {
      r && (Z(e), Z(n), Z(o));
    }
  };
}
function cg(i) {
  let e, t;
  return e = new Vp({
    props: { margin: (
      /*variant*/
      i[8] === "default"
    ) }
  }), {
    c() {
      Zp(e.$$.fragment);
    },
    m(n, o) {
      Qp(e, n, o), t = !0;
    },
    p(n, o) {
      const r = {};
      o[0] & /*variant*/
      256 && (r.margin = /*variant*/
      n[8] === "default"), e.$set(r);
    },
    i(n) {
      t || (ei(e.$$.fragment, n), t = !0);
    },
    o(n) {
      ti(e.$$.fragment, n), t = !1;
    },
    d(n) {
      Jp(e, n);
    }
  };
}
function dg(i) {
  let e, t, n, o, r, s = `${/*last_progress_level*/
  i[15] * 100}%`, a = (
    /*progress*/
    i[7] != null && ea(i)
  );
  return {
    c() {
      e = At("div"), t = At("div"), a && a.c(), n = Et(), o = At("div"), r = At("div"), St(t, "class", "progress-level-inner svelte-1yserjw"), St(r, "class", "progress-bar svelte-1yserjw"), xt(r, "width", s), St(o, "class", "progress-bar-wrap svelte-1yserjw"), St(e, "class", "progress-level svelte-1yserjw");
    },
    m(l, u) {
      G(l, e, u), vn(e, t), a && a.m(t, null), vn(e, n), vn(e, o), vn(o, r), i[30](r);
    },
    p(l, u) {
      /*progress*/
      l[7] != null ? a ? a.p(l, u) : (a = ea(l), a.c(), a.m(t, null)) : a && (a.d(1), a = null), u[0] & /*last_progress_level*/
      32768 && s !== (s = `${/*last_progress_level*/
      l[15] * 100}%`) && xt(r, "width", s);
    },
    i: Hs,
    o: Hs,
    d(l) {
      l && Z(e), a && a.d(), i[30](null);
    }
  };
}
function ea(i) {
  let e, t = po(
    /*progress*/
    i[7]
  ), n = [];
  for (let o = 0; o < t.length; o += 1)
    n[o] = sa(Kl(i, t, o));
  return {
    c() {
      for (let o = 0; o < n.length; o += 1)
        n[o].c();
      e = li();
    },
    m(o, r) {
      for (let s = 0; s < n.length; s += 1)
        n[s] && n[s].m(o, r);
      G(o, e, r);
    },
    p(o, r) {
      if (r[0] & /*progress_level, progress*/
      16512) {
        t = po(
          /*progress*/
          o[7]
        );
        let s;
        for (s = 0; s < t.length; s += 1) {
          const a = Kl(o, t, s);
          n[s] ? n[s].p(a, r) : (n[s] = sa(a), n[s].c(), n[s].m(e.parentNode, e));
        }
        for (; s < n.length; s += 1)
          n[s].d(1);
        n.length = t.length;
      }
    },
    d(o) {
      o && Z(e), Su(n, o);
    }
  };
}
function ta(i) {
  let e, t, n, o, r = (
    /*i*/
    i[41] !== 0 && fg()
  ), s = (
    /*p*/
    i[39].desc != null && na(i)
  ), a = (
    /*p*/
    i[39].desc != null && /*progress_level*/
    i[14] && /*progress_level*/
    i[14][
      /*i*/
      i[41]
    ] != null && ia()
  ), l = (
    /*progress_level*/
    i[14] != null && oa(i)
  );
  return {
    c() {
      r && r.c(), e = Et(), s && s.c(), t = Et(), a && a.c(), n = Et(), l && l.c(), o = li();
    },
    m(u, c) {
      r && r.m(u, c), G(u, e, c), s && s.m(u, c), G(u, t, c), a && a.m(u, c), G(u, n, c), l && l.m(u, c), G(u, o, c);
    },
    p(u, c) {
      /*p*/
      u[39].desc != null ? s ? s.p(u, c) : (s = na(u), s.c(), s.m(t.parentNode, t)) : s && (s.d(1), s = null), /*p*/
      u[39].desc != null && /*progress_level*/
      u[14] && /*progress_level*/
      u[14][
        /*i*/
        u[41]
      ] != null ? a || (a = ia(), a.c(), a.m(n.parentNode, n)) : a && (a.d(1), a = null), /*progress_level*/
      u[14] != null ? l ? l.p(u, c) : (l = oa(u), l.c(), l.m(o.parentNode, o)) : l && (l.d(1), l = null);
    },
    d(u) {
      u && (Z(e), Z(t), Z(n), Z(o)), r && r.d(u), s && s.d(u), a && a.d(u), l && l.d(u);
    }
  };
}
function fg(i) {
  let e;
  return {
    c() {
      e = pe(" /");
    },
    m(t, n) {
      G(t, e, n);
    },
    d(t) {
      t && Z(e);
    }
  };
}
function na(i) {
  let e = (
    /*p*/
    i[39].desc + ""
  ), t;
  return {
    c() {
      t = pe(e);
    },
    m(n, o) {
      G(n, t, o);
    },
    p(n, o) {
      o[0] & /*progress*/
      128 && e !== (e = /*p*/
      n[39].desc + "") && st(t, e);
    },
    d(n) {
      n && Z(t);
    }
  };
}
function ia(i) {
  let e;
  return {
    c() {
      e = pe("-");
    },
    m(t, n) {
      G(t, e, n);
    },
    d(t) {
      t && Z(e);
    }
  };
}
function oa(i) {
  let e = (100 * /*progress_level*/
  (i[14][
    /*i*/
    i[41]
  ] || 0)).toFixed(1) + "", t, n;
  return {
    c() {
      t = pe(e), n = pe("%");
    },
    m(o, r) {
      G(o, t, r), G(o, n, r);
    },
    p(o, r) {
      r[0] & /*progress_level*/
      16384 && e !== (e = (100 * /*progress_level*/
      (o[14][
        /*i*/
        o[41]
      ] || 0)).toFixed(1) + "") && st(t, e);
    },
    d(o) {
      o && (Z(t), Z(n));
    }
  };
}
function sa(i) {
  let e, t = (
    /*p*/
    (i[39].desc != null || /*progress_level*/
    i[14] && /*progress_level*/
    i[14][
      /*i*/
      i[41]
    ] != null) && ta(i)
  );
  return {
    c() {
      t && t.c(), e = li();
    },
    m(n, o) {
      t && t.m(n, o), G(n, e, o);
    },
    p(n, o) {
      /*p*/
      n[39].desc != null || /*progress_level*/
      n[14] && /*progress_level*/
      n[14][
        /*i*/
        n[41]
      ] != null ? t ? t.p(n, o) : (t = ta(n), t.c(), t.m(e.parentNode, e)) : t && (t.d(1), t = null);
    },
    d(n) {
      n && Z(e), t && t.d(n);
    }
  };
}
function ra(i) {
  let e, t;
  return {
    c() {
      e = At("p"), t = pe(
        /*loading_text*/
        i[9]
      ), St(e, "class", "loading svelte-1yserjw");
    },
    m(n, o) {
      G(n, e, o), vn(e, t);
    },
    p(n, o) {
      o[0] & /*loading_text*/
      512 && st(
        t,
        /*loading_text*/
        n[9]
      );
    },
    d(n) {
      n && Z(e);
    }
  };
}
function _g(i) {
  let e, t, n, o, r;
  const s = [og, ig], a = [];
  function l(u, c) {
    return (
      /*status*/
      u[4] === "pending" ? 0 : (
        /*status*/
        u[4] === "error" ? 1 : -1
      )
    );
  }
  return ~(t = l(i)) && (n = a[t] = s[t](i)), {
    c() {
      e = At("div"), n && n.c(), St(e, "class", o = "wrap " + /*variant*/
      i[8] + " " + /*show_progress*/
      i[6] + " svelte-1yserjw"), it(e, "hide", !/*status*/
      i[4] || /*status*/
      i[4] === "complete" || /*show_progress*/
      i[6] === "hidden"), it(
        e,
        "translucent",
        /*variant*/
        i[8] === "center" && /*status*/
        (i[4] === "pending" || /*status*/
        i[4] === "error") || /*translucent*/
        i[11] || /*show_progress*/
        i[6] === "minimal"
      ), it(
        e,
        "generating",
        /*status*/
        i[4] === "generating"
      ), it(
        e,
        "border",
        /*border*/
        i[12]
      ), xt(
        e,
        "position",
        /*absolute*/
        i[10] ? "absolute" : "static"
      ), xt(
        e,
        "padding",
        /*absolute*/
        i[10] ? "0" : "var(--size-8) 0"
      );
    },
    m(u, c) {
      G(u, e, c), ~t && a[t].m(e, null), i[31](e), r = !0;
    },
    p(u, c) {
      let d = t;
      t = l(u), t === d ? ~t && a[t].p(u, c) : (n && (Eu(), ti(a[d], 1, 1, () => {
        a[d] = null;
      }), Cu()), ~t ? (n = a[t], n ? n.p(u, c) : (n = a[t] = s[t](u), n.c()), ei(n, 1), n.m(e, null)) : n = null), (!r || c[0] & /*variant, show_progress*/
      320 && o !== (o = "wrap " + /*variant*/
      u[8] + " " + /*show_progress*/
      u[6] + " svelte-1yserjw")) && St(e, "class", o), (!r || c[0] & /*variant, show_progress, status, show_progress*/
      336) && it(e, "hide", !/*status*/
      u[4] || /*status*/
      u[4] === "complete" || /*show_progress*/
      u[6] === "hidden"), (!r || c[0] & /*variant, show_progress, variant, status, translucent, show_progress*/
      2384) && it(
        e,
        "translucent",
        /*variant*/
        u[8] === "center" && /*status*/
        (u[4] === "pending" || /*status*/
        u[4] === "error") || /*translucent*/
        u[11] || /*show_progress*/
        u[6] === "minimal"
      ), (!r || c[0] & /*variant, show_progress, status*/
      336) && it(
        e,
        "generating",
        /*status*/
        u[4] === "generating"
      ), (!r || c[0] & /*variant, show_progress, border*/
      4416) && it(
        e,
        "border",
        /*border*/
        u[12]
      ), c[0] & /*absolute*/
      1024 && xt(
        e,
        "position",
        /*absolute*/
        u[10] ? "absolute" : "static"
      ), c[0] & /*absolute*/
      1024 && xt(
        e,
        "padding",
        /*absolute*/
        u[10] ? "0" : "var(--size-8) 0"
      );
    },
    i(u) {
      r || (ei(n), r = !0);
    },
    o(u) {
      ti(n), r = !1;
    },
    d(u) {
      u && Z(e), ~t && a[t].d(), i[31](null);
    }
  };
}
var hg = function(i, e, t, n) {
  function o(r) {
    return r instanceof t ? r : new t(function(s) {
      s(r);
    });
  }
  return new (t || (t = Promise))(function(r, s) {
    function a(c) {
      try {
        u(n.next(c));
      } catch (d) {
        s(d);
      }
    }
    function l(c) {
      try {
        u(n.throw(c));
      } catch (d) {
        s(d);
      }
    }
    function u(c) {
      c.done ? r(c.value) : o(c.value).then(a, l);
    }
    u((n = n.apply(i, e || [])).next());
  });
};
let to = [], Ss = !1;
function mg(i) {
  return hg(this, arguments, void 0, function* (e, t = !0) {
    if (!(window.__gradio_mode__ === "website" || window.__gradio_mode__ !== "app" && t !== !0)) {
      if (to.push(e), !Ss)
        Ss = !0;
      else
        return;
      yield eg(), requestAnimationFrame(() => {
        let n = [0, 0];
        for (let o = 0; o < to.length; o++) {
          const s = to[o].getBoundingClientRect();
          (o === 0 || s.top + window.scrollY <= n[0]) && (n[0] = s.top + window.scrollY, n[1] = o);
        }
        window.scrollTo({ top: n[0] - 20, behavior: "smooth" }), Ss = !1, to = [];
      });
    }
  });
}
function pg(i, e, t) {
  let n, { $$slots: o = {}, $$scope: r } = e;
  this && this.__awaiter;
  let { i18n: s } = e, { eta: a = null } = e, { queue_position: l } = e, { queue_size: u } = e, { status: c } = e, { scroll_to_output: d = !1 } = e, { timer: _ = !0 } = e, { show_progress: f = "full" } = e, { message: h = null } = e, { progress: p = null } = e, { variant: g = "default" } = e, { loading_text: m = "Loading..." } = e, { absolute: k = !0 } = e, { translucent: w = !1 } = e, { border: S = !1 } = e, { autoscroll: v } = e, b, L = !1, E = 0, D = 0, P = null, F = null, q = 0, N = null, Y, J = null, O = !0;
  const T = () => {
    t(0, a = t(26, P = t(19, I = null))), t(24, E = performance.now()), t(25, D = 0), L = !0, V();
  };
  function V() {
    requestAnimationFrame(() => {
      t(25, D = (performance.now() - E) / 1e3), L && V();
    });
  }
  function K() {
    t(25, D = 0), t(0, a = t(26, P = t(19, I = null))), L && (L = !1);
  }
  tg(() => {
    L && K();
  });
  let I = null;
  function $(M) {
    Gl[M ? "unshift" : "push"](() => {
      J = M, t(16, J), t(7, p), t(14, N), t(15, Y);
    });
  }
  function te(M) {
    Gl[M ? "unshift" : "push"](() => {
      b = M, t(13, b);
    });
  }
  return i.$$set = (M) => {
    "i18n" in M && t(1, s = M.i18n), "eta" in M && t(0, a = M.eta), "queue_position" in M && t(2, l = M.queue_position), "queue_size" in M && t(3, u = M.queue_size), "status" in M && t(4, c = M.status), "scroll_to_output" in M && t(21, d = M.scroll_to_output), "timer" in M && t(5, _ = M.timer), "show_progress" in M && t(6, f = M.show_progress), "message" in M && t(22, h = M.message), "progress" in M && t(7, p = M.progress), "variant" in M && t(8, g = M.variant), "loading_text" in M && t(9, m = M.loading_text), "absolute" in M && t(10, k = M.absolute), "translucent" in M && t(11, w = M.translucent), "border" in M && t(12, S = M.border), "autoscroll" in M && t(23, v = M.autoscroll), "$$scope" in M && t(28, r = M.$$scope);
  }, i.$$.update = () => {
    i.$$.dirty[0] & /*eta, old_eta, timer_start, eta_from_start*/
    218103809 && (a === null && t(0, a = P), a != null && P !== a && (t(27, F = (performance.now() - E) / 1e3 + a), t(19, I = F.toFixed(1)), t(26, P = a))), i.$$.dirty[0] & /*eta_from_start, timer_diff*/
    167772160 && t(17, q = F === null || F <= 0 || !D ? null : Math.min(D / F, 1)), i.$$.dirty[0] & /*progress*/
    128 && p != null && t(18, O = !1), i.$$.dirty[0] & /*progress, progress_level, progress_bar, last_progress_level*/
    114816 && (p != null ? t(14, N = p.map((M) => {
      if (M.index != null && M.length != null)
        return M.index / M.length;
      if (M.progress != null)
        return M.progress;
    })) : t(14, N = null), N ? (t(15, Y = N[N.length - 1]), J && (Y === 0 ? t(16, J.style.transition = "0", J) : t(16, J.style.transition = "150ms", J))) : t(15, Y = void 0)), i.$$.dirty[0] & /*status*/
    16 && (c === "pending" ? T() : K()), i.$$.dirty[0] & /*el, scroll_to_output, status, autoscroll*/
    10493968 && b && d && (c === "pending" || c === "complete") && mg(b, v), i.$$.dirty[0] & /*status, message*/
    4194320, i.$$.dirty[0] & /*timer_diff*/
    33554432 && t(20, n = D.toFixed(1));
  }, [
    a,
    s,
    l,
    u,
    c,
    _,
    f,
    p,
    g,
    m,
    k,
    w,
    S,
    b,
    N,
    Y,
    J,
    q,
    O,
    I,
    n,
    d,
    h,
    v,
    E,
    D,
    P,
    F,
    r,
    o,
    $,
    te
  ];
}
class Du extends Hp {
  constructor(e) {
    super(), Yp(
      this,
      e,
      pg,
      _g,
      $p,
      {
        i18n: 1,
        eta: 0,
        queue_position: 2,
        queue_size: 3,
        status: 4,
        scroll_to_output: 21,
        timer: 5,
        show_progress: 6,
        message: 22,
        progress: 7,
        variant: 8,
        loading_text: 9,
        absolute: 10,
        translucent: 11,
        border: 12,
        autoscroll: 23
      },
      null,
      [-1, -1]
    );
  }
}
const {
  SvelteComponent: gg,
  add_flush_callback: bg,
  assign: Lu,
  bind: vg,
  binding_callbacks: wg,
  check_outros: yg,
  create_component: On,
  destroy_component: qn,
  detach: nr,
  empty: kg,
  flush: ke,
  get_spread_object: Ru,
  get_spread_update: Mu,
  group_outros: Cg,
  init: Sg,
  insert: ir,
  mount_component: An,
  safe_not_equal: Eg,
  space: Ou,
  transition_in: jt,
  transition_out: Pt
} = window.__gradio__svelte__internal;
function Dg(i) {
  let e, t;
  return e = new ca({
    props: {
      variant: (
        /*value*/
        i[0] === null && /*active_source*/
        i[19] === "upload" ? "dashed" : "solid"
      ),
      border_mode: (
        /*dragging*/
        i[20] ? "focus" : "base"
      ),
      padding: !1,
      elem_id: (
        /*elem_id*/
        i[2]
      ),
      elem_classes: (
        /*elem_classes*/
        i[3]
      ),
      visible: (
        /*visible*/
        i[4]
      ),
      container: (
        /*container*/
        i[11]
      ),
      scale: (
        /*scale*/
        i[12]
      ),
      min_width: (
        /*min_width*/
        i[13]
      ),
      $$slots: { default: [Mg] },
      $$scope: { ctx: i }
    }
  }), {
    c() {
      On(e.$$.fragment);
    },
    m(n, o) {
      An(e, n, o), t = !0;
    },
    p(n, o) {
      const r = {};
      o[0] & /*value, active_source*/
      524289 && (r.variant = /*value*/
      n[0] === null && /*active_source*/
      n[19] === "upload" ? "dashed" : "solid"), o[0] & /*dragging*/
      1048576 && (r.border_mode = /*dragging*/
      n[20] ? "focus" : "base"), o[0] & /*elem_id*/
      4 && (r.elem_id = /*elem_id*/
      n[2]), o[0] & /*elem_classes*/
      8 && (r.elem_classes = /*elem_classes*/
      n[3]), o[0] & /*visible*/
      16 && (r.visible = /*visible*/
      n[4]), o[0] & /*container*/
      2048 && (r.container = /*container*/
      n[11]), o[0] & /*scale*/
      4096 && (r.scale = /*scale*/
      n[12]), o[0] & /*min_width*/
      8192 && (r.min_width = /*min_width*/
      n[13]), o[0] & /*label, show_label, show_download_button, value, root, sources, active_source, pending, streaming, editable, gradio, waveform_settings, waveform_options, dragging, loading_status*/
      4179907 | o[1] & /*$$scope*/
      16384 && (r.$$scope = { dirty: o, ctx: n }), e.$set(r);
    },
    i(n) {
      t || (jt(e.$$.fragment, n), t = !0);
    },
    o(n) {
      Pt(e.$$.fragment, n), t = !1;
    },
    d(n) {
      qn(e, n);
    }
  };
}
function Lg(i) {
  let e, t;
  return e = new ca({
    props: {
      variant: "solid",
      border_mode: (
        /*dragging*/
        i[20] ? "focus" : "base"
      ),
      padding: !1,
      elem_id: (
        /*elem_id*/
        i[2]
      ),
      elem_classes: (
        /*elem_classes*/
        i[3]
      ),
      visible: (
        /*visible*/
        i[4]
      ),
      container: (
        /*container*/
        i[11]
      ),
      scale: (
        /*scale*/
        i[12]
      ),
      min_width: (
        /*min_width*/
        i[13]
      ),
      $$slots: { default: [Og] },
      $$scope: { ctx: i }
    }
  }), {
    c() {
      On(e.$$.fragment);
    },
    m(n, o) {
      An(e, n, o), t = !0;
    },
    p(n, o) {
      const r = {};
      o[0] & /*dragging*/
      1048576 && (r.border_mode = /*dragging*/
      n[20] ? "focus" : "base"), o[0] & /*elem_id*/
      4 && (r.elem_id = /*elem_id*/
      n[2]), o[0] & /*elem_classes*/
      8 && (r.elem_classes = /*elem_classes*/
      n[3]), o[0] & /*visible*/
      16 && (r.visible = /*visible*/
      n[4]), o[0] & /*container*/
      2048 && (r.container = /*container*/
      n[11]), o[0] & /*scale*/
      4096 && (r.scale = /*scale*/
      n[12]), o[0] & /*min_width*/
      8192 && (r.min_width = /*min_width*/
      n[13]), o[0] & /*gradio, show_label, show_download_button, value, label, waveform_settings, waveform_options, loading_status*/
      2393731 | o[1] & /*$$scope*/
      16384 && (r.$$scope = { dirty: o, ctx: n }), e.$set(r);
    },
    i(n) {
      t || (jt(e.$$.fragment, n), t = !0);
    },
    o(n) {
      Pt(e.$$.fragment, n), t = !1;
    },
    d(n) {
      qn(e, n);
    }
  };
}
function Rg(i) {
  let e, t;
  return e = new f_({
    props: {
      i18n: (
        /*gradio*/
        i[18].i18n
      ),
      type: "audio"
    }
  }), {
    c() {
      On(e.$$.fragment);
    },
    m(n, o) {
      An(e, n, o), t = !0;
    },
    p(n, o) {
      const r = {};
      o[0] & /*gradio*/
      262144 && (r.i18n = /*gradio*/
      n[18].i18n), e.$set(r);
    },
    i(n) {
      t || (jt(e.$$.fragment, n), t = !0);
    },
    o(n) {
      Pt(e.$$.fragment, n), t = !1;
    },
    d(n) {
      qn(e, n);
    }
  };
}
function Mg(i) {
  let e, t, n, o, r;
  const s = [
    {
      autoscroll: (
        /*gradio*/
        i[18].autoscroll
      )
    },
    { i18n: (
      /*gradio*/
      i[18].i18n
    ) },
    /*loading_status*/
    i[1]
  ];
  let a = {};
  for (let c = 0; c < s.length; c += 1)
    a = Lu(a, s[c]);
  e = new Du({ props: a });
  function l(c) {
    i[31](c);
  }
  let u = {
    label: (
      /*label*/
      i[7]
    ),
    show_label: (
      /*show_label*/
      i[9]
    ),
    show_download_button: (
      /*show_download_button*/
      i[10]
    ),
    value: (
      /*value*/
      i[0]
    ),
    root: (
      /*root*/
      i[8]
    ),
    sources: (
      /*sources*/
      i[6]
    ),
    active_source: (
      /*active_source*/
      i[19]
    ),
    pending: (
      /*pending*/
      i[16]
    ),
    streaming: (
      /*streaming*/
      i[17]
    ),
    editable: (
      /*editable*/
      i[14]
    ),
    i18n: (
      /*gradio*/
      i[18].i18n
    ),
    waveform_settings: (
      /*waveform_settings*/
      i[21]
    ),
    waveform_options: (
      /*waveform_options*/
      i[15]
    ),
    $$slots: { default: [Rg] },
    $$scope: { ctx: i }
  };
  return (
    /*dragging*/
    i[20] !== void 0 && (u.dragging = /*dragging*/
    i[20]), n = new Op({ props: u }), wg.push(() => vg(n, "dragging", l)), n.$on(
      "change",
      /*change_handler*/
      i[32]
    ), n.$on(
      "stream",
      /*stream_handler*/
      i[33]
    ), n.$on(
      "drag",
      /*drag_handler*/
      i[34]
    ), n.$on(
      "edit",
      /*edit_handler*/
      i[35]
    ), n.$on(
      "play",
      /*play_handler_1*/
      i[36]
    ), n.$on(
      "pause",
      /*pause_handler_1*/
      i[37]
    ), n.$on(
      "stop",
      /*stop_handler_1*/
      i[38]
    ), n.$on(
      "start_recording",
      /*start_recording_handler*/
      i[39]
    ), n.$on(
      "pause_recording",
      /*pause_recording_handler*/
      i[40]
    ), n.$on(
      "stop_recording",
      /*stop_recording_handler*/
      i[41]
    ), n.$on(
      "upload",
      /*upload_handler*/
      i[42]
    ), n.$on(
      "clear",
      /*clear_handler*/
      i[43]
    ), n.$on(
      "error",
      /*handle_error*/
      i[22]
    ), {
      c() {
        On(e.$$.fragment), t = Ou(), On(n.$$.fragment);
      },
      m(c, d) {
        An(e, c, d), ir(c, t, d), An(n, c, d), r = !0;
      },
      p(c, d) {
        const _ = d[0] & /*gradio, loading_status*/
        262146 ? Mu(s, [
          d[0] & /*gradio*/
          262144 && {
            autoscroll: (
              /*gradio*/
              c[18].autoscroll
            )
          },
          d[0] & /*gradio*/
          262144 && { i18n: (
            /*gradio*/
            c[18].i18n
          ) },
          d[0] & /*loading_status*/
          2 && Ru(
            /*loading_status*/
            c[1]
          )
        ]) : {};
        e.$set(_);
        const f = {};
        d[0] & /*label*/
        128 && (f.label = /*label*/
        c[7]), d[0] & /*show_label*/
        512 && (f.show_label = /*show_label*/
        c[9]), d[0] & /*show_download_button*/
        1024 && (f.show_download_button = /*show_download_button*/
        c[10]), d[0] & /*value*/
        1 && (f.value = /*value*/
        c[0]), d[0] & /*root*/
        256 && (f.root = /*root*/
        c[8]), d[0] & /*sources*/
        64 && (f.sources = /*sources*/
        c[6]), d[0] & /*active_source*/
        524288 && (f.active_source = /*active_source*/
        c[19]), d[0] & /*pending*/
        65536 && (f.pending = /*pending*/
        c[16]), d[0] & /*streaming*/
        131072 && (f.streaming = /*streaming*/
        c[17]), d[0] & /*editable*/
        16384 && (f.editable = /*editable*/
        c[14]), d[0] & /*gradio*/
        262144 && (f.i18n = /*gradio*/
        c[18].i18n), d[0] & /*waveform_settings*/
        2097152 && (f.waveform_settings = /*waveform_settings*/
        c[21]), d[0] & /*waveform_options*/
        32768 && (f.waveform_options = /*waveform_options*/
        c[15]), d[0] & /*gradio*/
        262144 | d[1] & /*$$scope*/
        16384 && (f.$$scope = { dirty: d, ctx: c }), !o && d[0] & /*dragging*/
        1048576 && (o = !0, f.dragging = /*dragging*/
        c[20], bg(() => o = !1)), n.$set(f);
      },
      i(c) {
        r || (jt(e.$$.fragment, c), jt(n.$$.fragment, c), r = !0);
      },
      o(c) {
        Pt(e.$$.fragment, c), Pt(n.$$.fragment, c), r = !1;
      },
      d(c) {
        c && nr(t), qn(e, c), qn(n, c);
      }
    }
  );
}
function Og(i) {
  let e, t, n, o;
  const r = [
    {
      autoscroll: (
        /*gradio*/
        i[18].autoscroll
      )
    },
    { i18n: (
      /*gradio*/
      i[18].i18n
    ) },
    /*loading_status*/
    i[1]
  ];
  let s = {};
  for (let a = 0; a < r.length; a += 1)
    s = Lu(s, r[a]);
  return e = new Du({ props: s }), n = new o1({
    props: {
      i18n: (
        /*gradio*/
        i[18].i18n
      ),
      show_label: (
        /*show_label*/
        i[9]
      ),
      show_download_button: (
        /*show_download_button*/
        i[10]
      ),
      value: (
        /*value*/
        i[0]
      ),
      label: (
        /*label*/
        i[7]
      ),
      waveform_settings: (
        /*waveform_settings*/
        i[21]
      ),
      waveform_options: (
        /*waveform_options*/
        i[15]
      )
    }
  }), n.$on(
    "share",
    /*share_handler*/
    i[26]
  ), n.$on(
    "error",
    /*error_handler*/
    i[27]
  ), n.$on(
    "play",
    /*play_handler*/
    i[28]
  ), n.$on(
    "pause",
    /*pause_handler*/
    i[29]
  ), n.$on(
    "stop",
    /*stop_handler*/
    i[30]
  ), {
    c() {
      On(e.$$.fragment), t = Ou(), On(n.$$.fragment);
    },
    m(a, l) {
      An(e, a, l), ir(a, t, l), An(n, a, l), o = !0;
    },
    p(a, l) {
      const u = l[0] & /*gradio, loading_status*/
      262146 ? Mu(r, [
        l[0] & /*gradio*/
        262144 && {
          autoscroll: (
            /*gradio*/
            a[18].autoscroll
          )
        },
        l[0] & /*gradio*/
        262144 && { i18n: (
          /*gradio*/
          a[18].i18n
        ) },
        l[0] & /*loading_status*/
        2 && Ru(
          /*loading_status*/
          a[1]
        )
      ]) : {};
      e.$set(u);
      const c = {};
      l[0] & /*gradio*/
      262144 && (c.i18n = /*gradio*/
      a[18].i18n), l[0] & /*show_label*/
      512 && (c.show_label = /*show_label*/
      a[9]), l[0] & /*show_download_button*/
      1024 && (c.show_download_button = /*show_download_button*/
      a[10]), l[0] & /*value*/
      1 && (c.value = /*value*/
      a[0]), l[0] & /*label*/
      128 && (c.label = /*label*/
      a[7]), l[0] & /*waveform_settings*/
      2097152 && (c.waveform_settings = /*waveform_settings*/
      a[21]), l[0] & /*waveform_options*/
      32768 && (c.waveform_options = /*waveform_options*/
      a[15]), n.$set(c);
    },
    i(a) {
      o || (jt(e.$$.fragment, a), jt(n.$$.fragment, a), o = !0);
    },
    o(a) {
      Pt(e.$$.fragment, a), Pt(n.$$.fragment, a), o = !1;
    },
    d(a) {
      a && nr(t), qn(e, a), qn(n, a);
    }
  };
}
function qg(i) {
  let e, t, n, o;
  const r = [Lg, Dg], s = [];
  function a(l, u) {
    return (
      /*interactive*/
      l[5] ? 1 : 0
    );
  }
  return e = a(i), t = s[e] = r[e](i), {
    c() {
      t.c(), n = kg();
    },
    m(l, u) {
      s[e].m(l, u), ir(l, n, u), o = !0;
    },
    p(l, u) {
      let c = e;
      e = a(l), e === c ? s[e].p(l, u) : (Cg(), Pt(s[c], 1, 1, () => {
        s[c] = null;
      }), yg(), t = s[e], t ? t.p(l, u) : (t = s[e] = r[e](l), t.c()), jt(t, 1), t.m(n.parentNode, n));
    },
    i(l) {
      o || (jt(t), o = !0);
    },
    o(l) {
      Pt(t), o = !1;
    },
    d(l) {
      l && nr(n), s[e].d(l);
    }
  };
}
function Ag(i, e, t) {
  let { elem_id: n = "" } = e, { elem_classes: o = [] } = e, { visible: r = !0 } = e, { interactive: s } = e, { value: a = null } = e, { sources: l } = e, { label: u } = e, { root: c } = e, { show_label: d } = e, { show_download_button: _ = !0 } = e, { container: f = !0 } = e, { scale: h = null } = e, { min_width: p = void 0 } = e, { loading_status: g } = e, { autoplay: m = !1 } = e, { editable: k = !0 } = e, { waveform_options: w = {} } = e, { pending: S } = e, { streaming: v } = e, { gradio: b } = e, L = null, E, D = a, P, F;
  function q({ detail: A }) {
    const [de, fe] = A.includes("Invalid file type") ? ["warning", "complete"] : ["error", "error"];
    t(1, g = g || {}), t(1, g.status = fe, g), t(1, g.message = A, g), b.dispatch(de, A);
  }
  const N = (A) => b.dispatch("share", A.detail), Y = (A) => b.dispatch("error", A.detail), J = () => b.dispatch("play"), O = () => b.dispatch("pause"), T = () => b.dispatch("stop");
  function V(A) {
    P = A, t(20, P);
  }
  const K = ({ detail: A }) => t(0, a = A), I = ({ detail: A }) => {
    t(0, a = A), b.dispatch("stream", a);
  }, $ = ({ detail: A }) => t(20, P = A), te = (A) => b.dispatch("edit", A.detail), M = () => b.dispatch("play"), C = () => b.dispatch("pause"), R = () => b.dispatch("stop"), j = () => b.dispatch("start_recording"), Q = () => b.dispatch("pause_recording"), X = (A) => b.dispatch("stop_recording", A.detail), B = () => b.dispatch("upload"), ue = () => b.dispatch("clear");
  return i.$$set = (A) => {
    "elem_id" in A && t(2, n = A.elem_id), "elem_classes" in A && t(3, o = A.elem_classes), "visible" in A && t(4, r = A.visible), "interactive" in A && t(5, s = A.interactive), "value" in A && t(0, a = A.value), "sources" in A && t(6, l = A.sources), "label" in A && t(7, u = A.label), "root" in A && t(8, c = A.root), "show_label" in A && t(9, d = A.show_label), "show_download_button" in A && t(10, _ = A.show_download_button), "container" in A && t(11, f = A.container), "scale" in A && t(12, h = A.scale), "min_width" in A && t(13, p = A.min_width), "loading_status" in A && t(1, g = A.loading_status), "autoplay" in A && t(23, m = A.autoplay), "editable" in A && t(14, k = A.editable), "waveform_options" in A && t(15, w = A.waveform_options), "pending" in A && t(16, S = A.pending), "streaming" in A && t(17, v = A.streaming), "gradio" in A && t(18, b = A.gradio);
  }, i.$$.update = () => {
    i.$$.dirty[0] & /*value, initial_value*/
    33554433 && a && D === null && t(25, D = a), i.$$.dirty[0] & /*value, old_value, gradio*/
    17039361 && JSON.stringify(a) !== JSON.stringify(L) && (t(24, L = a), b.dispatch("change")), i.$$.dirty[0] & /*active_source, sources*/
    524352 && !E && l && t(19, E = l[0]), i.$$.dirty[0] & /*waveform_options, autoplay*/
    8421376 && t(21, F = {
      height: 50,
      waveColor: w.waveform_color || "#9ca3af",
      progressColor: w.waveform_progress_color || "#f97316",
      barWidth: 2,
      barGap: 3,
      cursorWidth: 2,
      cursorColor: "#ddd5e9",
      autoplay: m,
      barRadius: 10,
      dragToSeek: !0,
      normalize: !0,
      minPxPerSec: 20,
      mediaControls: w.show_controls
    });
  }, [
    a,
    g,
    n,
    o,
    r,
    s,
    l,
    u,
    c,
    d,
    _,
    f,
    h,
    p,
    k,
    w,
    S,
    v,
    b,
    E,
    P,
    F,
    q,
    m,
    L,
    D,
    N,
    Y,
    J,
    O,
    T,
    V,
    K,
    I,
    $,
    te,
    M,
    C,
    R,
    j,
    Q,
    X,
    B,
    ue
  ];
}
class eb extends gg {
  constructor(e) {
    super(), Sg(
      this,
      e,
      Ag,
      qg,
      Eg,
      {
        elem_id: 2,
        elem_classes: 3,
        visible: 4,
        interactive: 5,
        value: 0,
        sources: 6,
        label: 7,
        root: 8,
        show_label: 9,
        show_download_button: 10,
        container: 11,
        scale: 12,
        min_width: 13,
        loading_status: 1,
        autoplay: 23,
        editable: 14,
        waveform_options: 15,
        pending: 16,
        streaming: 17,
        gradio: 18
      },
      null,
      [-1, -1]
    );
  }
  get elem_id() {
    return this.$$.ctx[2];
  }
  set elem_id(e) {
    this.$$set({ elem_id: e }), ke();
  }
  get elem_classes() {
    return this.$$.ctx[3];
  }
  set elem_classes(e) {
    this.$$set({ elem_classes: e }), ke();
  }
  get visible() {
    return this.$$.ctx[4];
  }
  set visible(e) {
    this.$$set({ visible: e }), ke();
  }
  get interactive() {
    return this.$$.ctx[5];
  }
  set interactive(e) {
    this.$$set({ interactive: e }), ke();
  }
  get value() {
    return this.$$.ctx[0];
  }
  set value(e) {
    this.$$set({ value: e }), ke();
  }
  get sources() {
    return this.$$.ctx[6];
  }
  set sources(e) {
    this.$$set({ sources: e }), ke();
  }
  get label() {
    return this.$$.ctx[7];
  }
  set label(e) {
    this.$$set({ label: e }), ke();
  }
  get root() {
    return this.$$.ctx[8];
  }
  set root(e) {
    this.$$set({ root: e }), ke();
  }
  get show_label() {
    return this.$$.ctx[9];
  }
  set show_label(e) {
    this.$$set({ show_label: e }), ke();
  }
  get show_download_button() {
    return this.$$.ctx[10];
  }
  set show_download_button(e) {
    this.$$set({ show_download_button: e }), ke();
  }
  get container() {
    return this.$$.ctx[11];
  }
  set container(e) {
    this.$$set({ container: e }), ke();
  }
  get scale() {
    return this.$$.ctx[12];
  }
  set scale(e) {
    this.$$set({ scale: e }), ke();
  }
  get min_width() {
    return this.$$.ctx[13];
  }
  set min_width(e) {
    this.$$set({ min_width: e }), ke();
  }
  get loading_status() {
    return this.$$.ctx[1];
  }
  set loading_status(e) {
    this.$$set({ loading_status: e }), ke();
  }
  get autoplay() {
    return this.$$.ctx[23];
  }
  set autoplay(e) {
    this.$$set({ autoplay: e }), ke();
  }
  get editable() {
    return this.$$.ctx[14];
  }
  set editable(e) {
    this.$$set({ editable: e }), ke();
  }
  get waveform_options() {
    return this.$$.ctx[15];
  }
  set waveform_options(e) {
    this.$$set({ waveform_options: e }), ke();
  }
  get pending() {
    return this.$$.ctx[16];
  }
  set pending(e) {
    this.$$set({ pending: e }), ke();
  }
  get streaming() {
    return this.$$.ctx[17];
  }
  set streaming(e) {
    this.$$set({ streaming: e }), ke();
  }
  get gradio() {
    return this.$$.ctx[18];
  }
  set gradio(e) {
    this.$$set({ gradio: e }), ke();
  }
}
const {
  SvelteComponent: zg,
  append: jg,
  attr: Pg,
  detach: Tg,
  element: Ng,
  init: Bg,
  insert: Wg,
  noop: la,
  safe_not_equal: Ig,
  set_data: Ug,
  text: Fg,
  toggle_class: Fn
} = window.__gradio__svelte__internal;
function Vg(i) {
  let e, t;
  return {
    c() {
      e = Ng("div"), t = Fg(
        /*value*/
        i[0]
      ), Pg(e, "class", "svelte-1gecy8w"), Fn(
        e,
        "table",
        /*type*/
        i[1] === "table"
      ), Fn(
        e,
        "gallery",
        /*type*/
        i[1] === "gallery"
      ), Fn(
        e,
        "selected",
        /*selected*/
        i[2]
      );
    },
    m(n, o) {
      Wg(n, e, o), jg(e, t);
    },
    p(n, [o]) {
      o & /*value*/
      1 && Ug(
        t,
        /*value*/
        n[0]
      ), o & /*type*/
      2 && Fn(
        e,
        "table",
        /*type*/
        n[1] === "table"
      ), o & /*type*/
      2 && Fn(
        e,
        "gallery",
        /*type*/
        n[1] === "gallery"
      ), o & /*selected*/
      4 && Fn(
        e,
        "selected",
        /*selected*/
        n[2]
      );
    },
    i: la,
    o: la,
    d(n) {
      n && Tg(e);
    }
  };
}
function Hg(i, e, t) {
  let { value: n } = e, { type: o } = e, { selected: r = !1 } = e;
  return i.$$set = (s) => {
    "value" in s && t(0, n = s.value), "type" in s && t(1, o = s.type), "selected" in s && t(2, r = s.selected);
  }, [n, o, r];
}
class tb extends zg {
  constructor(e) {
    super(), Bg(this, e, Hg, Vg, Ig, { value: 0, type: 1, selected: 2 });
  }
}
export {
  tb as BaseExample,
  Op as BaseInteractiveAudio,
  Ua as BasePlayer,
  o1 as BaseStaticAudio,
  eb as default
};
