const {
  SvelteComponent: Ql,
  assign: Jl,
  create_slot: Kl,
  detach: $l,
  element: eu,
  get_all_dirty_from_scope: tu,
  get_slot_changes: nu,
  get_spread_update: iu,
  init: ru,
  insert: au,
  safe_not_equal: su,
  set_dynamic_element_data: Oa,
  set_style: Se,
  toggle_class: ut,
  transition_in: No,
  transition_out: Io,
  update_slot_base: ou
} = window.__gradio__svelte__internal;
function lu(t) {
  let e, n, i;
  const r = (
    /*#slots*/
    t[17].default
  ), a = Kl(
    r,
    t,
    /*$$scope*/
    t[16],
    null
  );
  let s = [
    { "data-testid": (
      /*test_id*/
      t[7]
    ) },
    { id: (
      /*elem_id*/
      t[2]
    ) },
    {
      class: n = "block " + /*elem_classes*/
      t[3].join(" ") + " svelte-1t38q2d"
    }
  ], l = {};
  for (let o = 0; o < s.length; o += 1)
    l = Jl(l, s[o]);
  return {
    c() {
      e = eu(
        /*tag*/
        t[14]
      ), a && a.c(), Oa(
        /*tag*/
        t[14]
      )(e, l), ut(
        e,
        "hidden",
        /*visible*/
        t[10] === !1
      ), ut(
        e,
        "padded",
        /*padding*/
        t[6]
      ), ut(
        e,
        "border_focus",
        /*border_mode*/
        t[5] === "focus"
      ), ut(e, "hide-container", !/*explicit_call*/
      t[8] && !/*container*/
      t[9]), Se(e, "height", typeof /*height*/
      t[0] == "number" ? (
        /*height*/
        t[0] + "px"
      ) : void 0), Se(e, "width", typeof /*width*/
      t[1] == "number" ? `calc(min(${/*width*/
      t[1]}px, 100%))` : void 0), Se(
        e,
        "border-style",
        /*variant*/
        t[4]
      ), Se(
        e,
        "overflow",
        /*allow_overflow*/
        t[11] ? "visible" : "hidden"
      ), Se(
        e,
        "flex-grow",
        /*scale*/
        t[12]
      ), Se(e, "min-width", `calc(min(${/*min_width*/
      t[13]}px, 100%))`), Se(e, "border-width", "var(--block-border-width)");
    },
    m(o, u) {
      au(o, e, u), a && a.m(e, null), i = !0;
    },
    p(o, u) {
      a && a.p && (!i || u & /*$$scope*/
      65536) && ou(
        a,
        r,
        o,
        /*$$scope*/
        o[16],
        i ? nu(
          r,
          /*$$scope*/
          o[16],
          u,
          null
        ) : tu(
          /*$$scope*/
          o[16]
        ),
        null
      ), Oa(
        /*tag*/
        o[14]
      )(e, l = iu(s, [
        (!i || u & /*test_id*/
        128) && { "data-testid": (
          /*test_id*/
          o[7]
        ) },
        (!i || u & /*elem_id*/
        4) && { id: (
          /*elem_id*/
          o[2]
        ) },
        (!i || u & /*elem_classes*/
        8 && n !== (n = "block " + /*elem_classes*/
        o[3].join(" ") + " svelte-1t38q2d")) && { class: n }
      ])), ut(
        e,
        "hidden",
        /*visible*/
        o[10] === !1
      ), ut(
        e,
        "padded",
        /*padding*/
        o[6]
      ), ut(
        e,
        "border_focus",
        /*border_mode*/
        o[5] === "focus"
      ), ut(e, "hide-container", !/*explicit_call*/
      o[8] && !/*container*/
      o[9]), u & /*height*/
      1 && Se(e, "height", typeof /*height*/
      o[0] == "number" ? (
        /*height*/
        o[0] + "px"
      ) : void 0), u & /*width*/
      2 && Se(e, "width", typeof /*width*/
      o[1] == "number" ? `calc(min(${/*width*/
      o[1]}px, 100%))` : void 0), u & /*variant*/
      16 && Se(
        e,
        "border-style",
        /*variant*/
        o[4]
      ), u & /*allow_overflow*/
      2048 && Se(
        e,
        "overflow",
        /*allow_overflow*/
        o[11] ? "visible" : "hidden"
      ), u & /*scale*/
      4096 && Se(
        e,
        "flex-grow",
        /*scale*/
        o[12]
      ), u & /*min_width*/
      8192 && Se(e, "min-width", `calc(min(${/*min_width*/
      o[13]}px, 100%))`);
    },
    i(o) {
      i || (No(a, o), i = !0);
    },
    o(o) {
      Io(a, o), i = !1;
    },
    d(o) {
      o && $l(e), a && a.d(o);
    }
  };
}
function uu(t) {
  let e, n = (
    /*tag*/
    t[14] && lu(t)
  );
  return {
    c() {
      n && n.c();
    },
    m(i, r) {
      n && n.m(i, r), e = !0;
    },
    p(i, [r]) {
      /*tag*/
      i[14] && n.p(i, r);
    },
    i(i) {
      e || (No(n, i), e = !0);
    },
    o(i) {
      Io(n, i), e = !1;
    },
    d(i) {
      n && n.d(i);
    }
  };
}
function fu(t, e, n) {
  let { $$slots: i = {}, $$scope: r } = e, { height: a = void 0 } = e, { width: s = void 0 } = e, { elem_id: l = "" } = e, { elem_classes: o = [] } = e, { variant: u = "solid" } = e, { border_mode: f = "base" } = e, { padding: h = !0 } = e, { type: c = "normal" } = e, { test_id: d = void 0 } = e, { explicit_call: _ = !1 } = e, { container: m = !0 } = e, { visible: b = !0 } = e, { allow_overflow: C = !0 } = e, { scale: T = null } = e, { min_width: y = 0 } = e, S = c === "fieldset" ? "fieldset" : "div";
  return t.$$set = (p) => {
    "height" in p && n(0, a = p.height), "width" in p && n(1, s = p.width), "elem_id" in p && n(2, l = p.elem_id), "elem_classes" in p && n(3, o = p.elem_classes), "variant" in p && n(4, u = p.variant), "border_mode" in p && n(5, f = p.border_mode), "padding" in p && n(6, h = p.padding), "type" in p && n(15, c = p.type), "test_id" in p && n(7, d = p.test_id), "explicit_call" in p && n(8, _ = p.explicit_call), "container" in p && n(9, m = p.container), "visible" in p && n(10, b = p.visible), "allow_overflow" in p && n(11, C = p.allow_overflow), "scale" in p && n(12, T = p.scale), "min_width" in p && n(13, y = p.min_width), "$$scope" in p && n(16, r = p.$$scope);
  }, [
    a,
    s,
    l,
    o,
    u,
    f,
    h,
    d,
    _,
    m,
    b,
    C,
    T,
    y,
    S,
    c,
    r,
    i
  ];
}
class Ro extends Ql {
  constructor(e) {
    super(), ru(this, e, fu, uu, su, {
      height: 0,
      width: 1,
      elem_id: 2,
      elem_classes: 3,
      variant: 4,
      border_mode: 5,
      padding: 6,
      type: 15,
      test_id: 7,
      explicit_call: 8,
      container: 9,
      visible: 10,
      allow_overflow: 11,
      scale: 12,
      min_width: 13
    });
  }
}
const {
  SvelteComponent: hu,
  append: qi,
  attr: ei,
  create_component: cu,
  destroy_component: du,
  detach: _u,
  element: Da,
  init: mu,
  insert: gu,
  mount_component: pu,
  safe_not_equal: bu,
  set_data: vu,
  space: wu,
  text: yu,
  toggle_class: ft,
  transition_in: Eu,
  transition_out: ku
} = window.__gradio__svelte__internal;
function Tu(t) {
  let e, n, i, r, a, s;
  return i = new /*Icon*/
  t[1]({}), {
    c() {
      e = Da("label"), n = Da("span"), cu(i.$$.fragment), r = wu(), a = yu(
        /*label*/
        t[0]
      ), ei(n, "class", "svelte-9gxdi0"), ei(e, "for", ""), ei(e, "data-testid", "block-label"), ei(e, "class", "svelte-9gxdi0"), ft(e, "hide", !/*show_label*/
      t[2]), ft(e, "sr-only", !/*show_label*/
      t[2]), ft(
        e,
        "float",
        /*float*/
        t[4]
      ), ft(
        e,
        "hide-label",
        /*disable*/
        t[3]
      );
    },
    m(l, o) {
      gu(l, e, o), qi(e, n), pu(i, n, null), qi(e, r), qi(e, a), s = !0;
    },
    p(l, [o]) {
      (!s || o & /*label*/
      1) && vu(
        a,
        /*label*/
        l[0]
      ), (!s || o & /*show_label*/
      4) && ft(e, "hide", !/*show_label*/
      l[2]), (!s || o & /*show_label*/
      4) && ft(e, "sr-only", !/*show_label*/
      l[2]), (!s || o & /*float*/
      16) && ft(
        e,
        "float",
        /*float*/
        l[4]
      ), (!s || o & /*disable*/
      8) && ft(
        e,
        "hide-label",
        /*disable*/
        l[3]
      );
    },
    i(l) {
      s || (Eu(i.$$.fragment, l), s = !0);
    },
    o(l) {
      ku(i.$$.fragment, l), s = !1;
    },
    d(l) {
      l && _u(e), du(i);
    }
  };
}
function Su(t, e, n) {
  let { label: i = null } = e, { Icon: r } = e, { show_label: a = !0 } = e, { disable: s = !1 } = e, { float: l = !0 } = e;
  return t.$$set = (o) => {
    "label" in o && n(0, i = o.label), "Icon" in o && n(1, r = o.Icon), "show_label" in o && n(2, a = o.show_label), "disable" in o && n(3, s = o.disable), "float" in o && n(4, l = o.float);
  }, [i, r, a, s, l];
}
class Lo extends hu {
  constructor(e) {
    super(), mu(this, e, Su, Tu, bu, {
      label: 0,
      Icon: 1,
      show_label: 2,
      disable: 3,
      float: 4
    });
  }
}
const {
  SvelteComponent: Cu,
  append: kr,
  attr: Ot,
  bubble: Mu,
  create_component: Au,
  destroy_component: Ou,
  detach: Po,
  element: Tr,
  init: Du,
  insert: Uo,
  listen: Bu,
  mount_component: Hu,
  safe_not_equal: Nu,
  set_data: Iu,
  space: Ru,
  text: Lu,
  toggle_class: ht,
  transition_in: Pu,
  transition_out: Uu
} = window.__gradio__svelte__internal;
function Ba(t) {
  let e, n;
  return {
    c() {
      e = Tr("span"), n = Lu(
        /*label*/
        t[1]
      ), Ot(e, "class", "svelte-xtz2g8");
    },
    m(i, r) {
      Uo(i, e, r), kr(e, n);
    },
    p(i, r) {
      r & /*label*/
      2 && Iu(
        n,
        /*label*/
        i[1]
      );
    },
    d(i) {
      i && Po(e);
    }
  };
}
function Fu(t) {
  let e, n, i, r, a, s, l, o = (
    /*show_label*/
    t[2] && Ba(t)
  );
  return r = new /*Icon*/
  t[0]({}), {
    c() {
      e = Tr("button"), o && o.c(), n = Ru(), i = Tr("div"), Au(r.$$.fragment), Ot(i, "class", "svelte-xtz2g8"), ht(
        i,
        "small",
        /*size*/
        t[4] === "small"
      ), ht(
        i,
        "large",
        /*size*/
        t[4] === "large"
      ), Ot(
        e,
        "aria-label",
        /*label*/
        t[1]
      ), Ot(
        e,
        "title",
        /*label*/
        t[1]
      ), Ot(e, "class", "svelte-xtz2g8"), ht(
        e,
        "pending",
        /*pending*/
        t[3]
      ), ht(
        e,
        "padded",
        /*padded*/
        t[5]
      );
    },
    m(u, f) {
      Uo(u, e, f), o && o.m(e, null), kr(e, n), kr(e, i), Hu(r, i, null), a = !0, s || (l = Bu(
        e,
        "click",
        /*click_handler*/
        t[6]
      ), s = !0);
    },
    p(u, [f]) {
      /*show_label*/
      u[2] ? o ? o.p(u, f) : (o = Ba(u), o.c(), o.m(e, n)) : o && (o.d(1), o = null), (!a || f & /*size*/
      16) && ht(
        i,
        "small",
        /*size*/
        u[4] === "small"
      ), (!a || f & /*size*/
      16) && ht(
        i,
        "large",
        /*size*/
        u[4] === "large"
      ), (!a || f & /*label*/
      2) && Ot(
        e,
        "aria-label",
        /*label*/
        u[1]
      ), (!a || f & /*label*/
      2) && Ot(
        e,
        "title",
        /*label*/
        u[1]
      ), (!a || f & /*pending*/
      8) && ht(
        e,
        "pending",
        /*pending*/
        u[3]
      ), (!a || f & /*padded*/
      32) && ht(
        e,
        "padded",
        /*padded*/
        u[5]
      );
    },
    i(u) {
      a || (Pu(r.$$.fragment, u), a = !0);
    },
    o(u) {
      Uu(r.$$.fragment, u), a = !1;
    },
    d(u) {
      u && Po(e), o && o.d(), Ou(r), s = !1, l();
    }
  };
}
function Gu(t, e, n) {
  let { Icon: i } = e, { label: r = "" } = e, { show_label: a = !1 } = e, { pending: s = !1 } = e, { size: l = "small" } = e, { padded: o = !0 } = e;
  function u(f) {
    Mu.call(this, t, f);
  }
  return t.$$set = (f) => {
    "Icon" in f && n(0, i = f.Icon), "label" in f && n(1, r = f.label), "show_label" in f && n(2, a = f.show_label), "pending" in f && n(3, s = f.pending), "size" in f && n(4, l = f.size), "padded" in f && n(5, o = f.padded);
  }, [i, r, a, s, l, o, u];
}
class rt extends Cu {
  constructor(e) {
    super(), Du(this, e, Gu, Fu, Nu, {
      Icon: 0,
      label: 1,
      show_label: 2,
      pending: 3,
      size: 4,
      padded: 5
    });
  }
}
const {
  SvelteComponent: zu,
  append: ju,
  attr: xi,
  binding_callbacks: qu,
  create_slot: xu,
  detach: Xu,
  element: Ha,
  get_all_dirty_from_scope: Vu,
  get_slot_changes: Wu,
  init: Yu,
  insert: Zu,
  safe_not_equal: Qu,
  toggle_class: ct,
  transition_in: Ju,
  transition_out: Ku,
  update_slot_base: $u
} = window.__gradio__svelte__internal;
function ef(t) {
  let e, n, i;
  const r = (
    /*#slots*/
    t[5].default
  ), a = xu(
    r,
    t,
    /*$$scope*/
    t[4],
    null
  );
  return {
    c() {
      e = Ha("div"), n = Ha("div"), a && a.c(), xi(n, "class", "icon svelte-3w3rth"), xi(e, "class", "empty svelte-3w3rth"), xi(e, "aria-label", "Empty value"), ct(
        e,
        "small",
        /*size*/
        t[0] === "small"
      ), ct(
        e,
        "large",
        /*size*/
        t[0] === "large"
      ), ct(
        e,
        "unpadded_box",
        /*unpadded_box*/
        t[1]
      ), ct(
        e,
        "small_parent",
        /*parent_height*/
        t[3]
      );
    },
    m(s, l) {
      Zu(s, e, l), ju(e, n), a && a.m(n, null), t[6](e), i = !0;
    },
    p(s, [l]) {
      a && a.p && (!i || l & /*$$scope*/
      16) && $u(
        a,
        r,
        s,
        /*$$scope*/
        s[4],
        i ? Wu(
          r,
          /*$$scope*/
          s[4],
          l,
          null
        ) : Vu(
          /*$$scope*/
          s[4]
        ),
        null
      ), (!i || l & /*size*/
      1) && ct(
        e,
        "small",
        /*size*/
        s[0] === "small"
      ), (!i || l & /*size*/
      1) && ct(
        e,
        "large",
        /*size*/
        s[0] === "large"
      ), (!i || l & /*unpadded_box*/
      2) && ct(
        e,
        "unpadded_box",
        /*unpadded_box*/
        s[1]
      ), (!i || l & /*parent_height*/
      8) && ct(
        e,
        "small_parent",
        /*parent_height*/
        s[3]
      );
    },
    i(s) {
      i || (Ju(a, s), i = !0);
    },
    o(s) {
      Ku(a, s), i = !1;
    },
    d(s) {
      s && Xu(e), a && a.d(s), t[6](null);
    }
  };
}
function tf(t) {
  let e, n = t[0], i = 1;
  for (; i < t.length; ) {
    const r = t[i], a = t[i + 1];
    if (i += 2, (r === "optionalAccess" || r === "optionalCall") && n == null)
      return;
    r === "access" || r === "optionalAccess" ? (e = n, n = a(n)) : (r === "call" || r === "optionalCall") && (n = a((...s) => n.call(e, ...s)), e = void 0);
  }
  return n;
}
function nf(t, e, n) {
  let i, { $$slots: r = {}, $$scope: a } = e, { size: s = "small" } = e, { unpadded_box: l = !1 } = e, o;
  function u(h) {
    if (!h)
      return !1;
    const { height: c } = h.getBoundingClientRect(), { height: d } = tf([
      h,
      "access",
      (_) => _.parentElement,
      "optionalAccess",
      (_) => _.getBoundingClientRect,
      "call",
      (_) => _()
    ]) || { height: c };
    return c > d + 2;
  }
  function f(h) {
    qu[h ? "unshift" : "push"](() => {
      o = h, n(2, o);
    });
  }
  return t.$$set = (h) => {
    "size" in h && n(0, s = h.size), "unpadded_box" in h && n(1, l = h.unpadded_box), "$$scope" in h && n(4, a = h.$$scope);
  }, t.$$.update = () => {
    t.$$.dirty & /*el*/
    4 && n(3, i = u(o));
  }, [s, l, o, i, a, r, f];
}
class rf extends zu {
  constructor(e) {
    super(), Yu(this, e, nf, ef, Qu, { size: 0, unpadded_box: 1 });
  }
}
const {
  SvelteComponent: af,
  append: Na,
  attr: Et,
  detach: sf,
  init: of,
  insert: lf,
  noop: Xi,
  safe_not_equal: uf,
  svg_element: Vi
} = window.__gradio__svelte__internal;
function ff(t) {
  let e, n, i;
  return {
    c() {
      e = Vi("svg"), n = Vi("path"), i = Vi("path"), Et(n, "d", "M28.828 3.172a4.094 4.094 0 0 0-5.656 0L4.05 22.292A6.954 6.954 0 0 0 2 27.242V30h2.756a6.952 6.952 0 0 0 4.95-2.05L28.828 8.829a3.999 3.999 0 0 0 0-5.657zM10.91 18.26l2.829 2.829l-2.122 2.121l-2.828-2.828zm-2.619 8.276A4.966 4.966 0 0 1 4.756 28H4v-.759a4.967 4.967 0 0 1 1.464-3.535l1.91-1.91l2.829 2.828zM27.415 7.414l-12.261 12.26l-2.829-2.828l12.262-12.26a2.047 2.047 0 0 1 2.828 0a2 2 0 0 1 0 2.828z"), Et(n, "fill", "currentColor"), Et(i, "d", "M6.5 15a3.5 3.5 0 0 1-2.475-5.974l3.5-3.5a1.502 1.502 0 0 0 0-2.121a1.537 1.537 0 0 0-2.121 0L3.415 5.394L2 3.98l1.99-1.988a3.585 3.585 0 0 1 4.95 0a3.504 3.504 0 0 1 0 4.949L5.439 10.44a1.502 1.502 0 0 0 0 2.121a1.537 1.537 0 0 0 2.122 0l4.024-4.024L13 9.95l-4.025 4.024A3.475 3.475 0 0 1 6.5 15z"), Et(i, "fill", "currentColor"), Et(e, "width", "100%"), Et(e, "height", "100%"), Et(e, "viewBox", "0 0 32 32");
    },
    m(r, a) {
      lf(r, e, a), Na(e, n), Na(e, i);
    },
    p: Xi,
    i: Xi,
    o: Xi,
    d(r) {
      r && sf(e);
    }
  };
}
class hf extends af {
  constructor(e) {
    super(), of(this, e, null, ff, uf, {});
  }
}
const {
  SvelteComponent: cf,
  append: Ia,
  attr: ye,
  detach: df,
  init: _f,
  insert: mf,
  noop: Wi,
  safe_not_equal: gf,
  svg_element: Yi
} = window.__gradio__svelte__internal;
function pf(t) {
  let e, n, i;
  return {
    c() {
      e = Yi("svg"), n = Yi("path"), i = Yi("circle"), ye(n, "d", "M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"), ye(i, "cx", "12"), ye(i, "cy", "13"), ye(i, "r", "4"), ye(e, "xmlns", "http://www.w3.org/2000/svg"), ye(e, "width", "100%"), ye(e, "height", "100%"), ye(e, "viewBox", "0 0 24 24"), ye(e, "fill", "none"), ye(e, "stroke", "currentColor"), ye(e, "stroke-width", "1.5"), ye(e, "stroke-linecap", "round"), ye(e, "stroke-linejoin", "round"), ye(e, "class", "feather feather-camera");
    },
    m(r, a) {
      mf(r, e, a), Ia(e, n), Ia(e, i);
    },
    p: Wi,
    i: Wi,
    o: Wi,
    d(r) {
      r && df(e);
    }
  };
}
class bf extends cf {
  constructor(e) {
    super(), _f(this, e, null, pf, gf, {});
  }
}
const {
  SvelteComponent: vf,
  append: wf,
  attr: Ce,
  detach: yf,
  init: Ef,
  insert: kf,
  noop: Zi,
  safe_not_equal: Tf,
  svg_element: Ra
} = window.__gradio__svelte__internal;
function Sf(t) {
  let e, n;
  return {
    c() {
      e = Ra("svg"), n = Ra("circle"), Ce(n, "cx", "12"), Ce(n, "cy", "12"), Ce(n, "r", "10"), 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", "red"), Ce(e, "stroke", "red"), Ce(e, "stroke-width", "1.5"), Ce(e, "stroke-linecap", "round"), Ce(e, "stroke-linejoin", "round"), Ce(e, "class", "feather feather-circle");
    },
    m(i, r) {
      kf(i, e, r), wf(e, n);
    },
    p: Zi,
    i: Zi,
    o: Zi,
    d(i) {
      i && yf(e);
    }
  };
}
class Cf extends vf {
  constructor(e) {
    super(), Ef(this, e, null, Sf, Tf, {});
  }
}
const {
  SvelteComponent: Mf,
  append: Qi,
  attr: Fe,
  detach: Af,
  init: Of,
  insert: Df,
  noop: Ji,
  safe_not_equal: Bf,
  set_style: We,
  svg_element: ti
} = window.__gradio__svelte__internal;
function Hf(t) {
  let e, n, i, r;
  return {
    c() {
      e = ti("svg"), n = ti("g"), i = ti("path"), r = ti("path"), Fe(i, "d", "M18,6L6.087,17.913"), We(i, "fill", "none"), We(i, "fill-rule", "nonzero"), We(i, "stroke-width", "2px"), Fe(n, "transform", "matrix(1.14096,-0.140958,-0.140958,1.14096,-0.0559523,0.0559523)"), Fe(r, "d", "M4.364,4.364L19.636,19.636"), We(r, "fill", "none"), We(r, "fill-rule", "nonzero"), We(r, "stroke-width", "2px"), Fe(e, "width", "100%"), Fe(e, "height", "100%"), Fe(e, "viewBox", "0 0 24 24"), Fe(e, "version", "1.1"), Fe(e, "xmlns", "http://www.w3.org/2000/svg"), Fe(e, "xmlns:xlink", "http://www.w3.org/1999/xlink"), Fe(e, "xml:space", "preserve"), Fe(e, "stroke", "currentColor"), We(e, "fill-rule", "evenodd"), We(e, "clip-rule", "evenodd"), We(e, "stroke-linecap", "round"), We(e, "stroke-linejoin", "round");
    },
    m(a, s) {
      Df(a, e, s), Qi(e, n), Qi(n, i), Qi(e, r);
    },
    p: Ji,
    i: Ji,
    o: Ji,
    d(a) {
      a && Af(e);
    }
  };
}
class Fo extends Mf {
  constructor(e) {
    super(), Of(this, e, null, Hf, Bf, {});
  }
}
const {
  SvelteComponent: Nf,
  append: jt,
  attr: $,
  detach: If,
  init: Rf,
  insert: Lf,
  noop: Ki,
  safe_not_equal: Pf,
  svg_element: kt
} = window.__gradio__svelte__internal;
function Uf(t) {
  let e, n, i, r, a, s, l;
  return {
    c() {
      e = kt("svg"), n = kt("circle"), i = kt("circle"), r = kt("circle"), a = kt("circle"), s = kt("circle"), l = kt("path"), $(n, "cx", "10"), $(n, "cy", "12"), $(n, "r", "2"), $(n, "fill", "currentColor"), $(i, "cx", "16"), $(i, "cy", "9"), $(i, "r", "2"), $(i, "fill", "currentColor"), $(r, "cx", "22"), $(r, "cy", "12"), $(r, "r", "2"), $(r, "fill", "currentColor"), $(a, "cx", "23"), $(a, "cy", "18"), $(a, "r", "2"), $(a, "fill", "currentColor"), $(s, "cx", "19"), $(s, "cy", "23"), $(s, "r", "2"), $(s, "fill", "currentColor"), $(l, "fill", "currentColor"), $(l, "d", "M16.54 2A14 14 0 0 0 2 16a4.82 4.82 0 0 0 6.09 4.65l1.12-.31a3 3 0 0 1 3.79 2.9V27a3 3 0 0 0 3 3a14 14 0 0 0 14-14.54A14.05 14.05 0 0 0 16.54 2Zm8.11 22.31A11.93 11.93 0 0 1 16 28a1 1 0 0 1-1-1v-3.76a5 5 0 0 0-5-5a5.07 5.07 0 0 0-1.33.18l-1.12.31A2.82 2.82 0 0 1 4 16A12 12 0 0 1 16.47 4A12.18 12.18 0 0 1 28 15.53a11.89 11.89 0 0 1-3.35 8.79Z"), $(e, "width", "100%"), $(e, "height", "100%"), $(e, "viewBox", "0 0 32 32");
    },
    m(o, u) {
      Lf(o, e, u), jt(e, n), jt(e, i), jt(e, r), jt(e, a), jt(e, s), jt(e, l);
    },
    p: Ki,
    i: Ki,
    o: Ki,
    d(o) {
      o && If(e);
    }
  };
}
class Ff extends Nf {
  constructor(e) {
    super(), Rf(this, e, null, Uf, Pf, {});
  }
}
const {
  SvelteComponent: Gf,
  append: zf,
  attr: yn,
  detach: jf,
  init: qf,
  insert: xf,
  noop: $i,
  safe_not_equal: Xf,
  svg_element: La
} = window.__gradio__svelte__internal;
function Vf(t) {
  let e, n;
  return {
    c() {
      e = La("svg"), n = La("path"), yn(n, "d", "M23,20a5,5,0,0,0-3.89,1.89L11.8,17.32a4.46,4.46,0,0,0,0-2.64l7.31-4.57A5,5,0,1,0,18,7a4.79,4.79,0,0,0,.2,1.32l-7.31,4.57a5,5,0,1,0,0,6.22l7.31,4.57A4.79,4.79,0,0,0,18,25a5,5,0,1,0,5-5ZM23,4a3,3,0,1,1-3,3A3,3,0,0,1,23,4ZM7,19a3,3,0,1,1,3-3A3,3,0,0,1,7,19Zm16,9a3,3,0,1,1,3-3A3,3,0,0,1,23,28Z"), yn(n, "fill", "currentColor"), yn(e, "id", "icon"), yn(e, "xmlns", "http://www.w3.org/2000/svg"), yn(e, "viewBox", "0 0 32 32");
    },
    m(i, r) {
      xf(i, e, r), zf(e, n);
    },
    p: $i,
    i: $i,
    o: $i,
    d(i) {
      i && jf(e);
    }
  };
}
class Wf extends Gf {
  constructor(e) {
    super(), qf(this, e, null, Vf, Xf, {});
  }
}
const {
  SvelteComponent: Yf,
  append: Zf,
  attr: qt,
  detach: Qf,
  init: Jf,
  insert: Kf,
  noop: er,
  safe_not_equal: $f,
  svg_element: Pa
} = window.__gradio__svelte__internal;
function eh(t) {
  let e, n;
  return {
    c() {
      e = Pa("svg"), n = Pa("path"), qt(n, "fill", "currentColor"), qt(n, "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"), qt(e, "xmlns", "http://www.w3.org/2000/svg"), qt(e, "width", "100%"), qt(e, "height", "100%"), qt(e, "viewBox", "0 0 32 32");
    },
    m(i, r) {
      Kf(i, e, r), Zf(e, n);
    },
    p: er,
    i: er,
    o: er,
    d(i) {
      i && Qf(e);
    }
  };
}
class th extends Yf {
  constructor(e) {
    super(), Jf(this, e, null, eh, $f, {});
  }
}
const {
  SvelteComponent: nh,
  append: ih,
  attr: Ge,
  detach: rh,
  init: ah,
  insert: sh,
  noop: tr,
  safe_not_equal: oh,
  svg_element: Ua
} = window.__gradio__svelte__internal;
function lh(t) {
  let e, n;
  return {
    c() {
      e = Ua("svg"), n = Ua("path"), Ge(n, "d", "M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"), Ge(e, "xmlns", "http://www.w3.org/2000/svg"), Ge(e, "width", "100%"), Ge(e, "height", "100%"), Ge(e, "viewBox", "0 0 24 24"), Ge(e, "fill", "none"), Ge(e, "stroke", "currentColor"), Ge(e, "stroke-width", "1.5"), Ge(e, "stroke-linecap", "round"), Ge(e, "stroke-linejoin", "round"), Ge(e, "class", "feather feather-edit-2");
    },
    m(i, r) {
      sh(i, e, r), ih(e, n);
    },
    p: tr,
    i: tr,
    o: tr,
    d(i) {
      i && rh(e);
    }
  };
}
class uh extends nh {
  constructor(e) {
    super(), ah(this, e, null, lh, oh, {});
  }
}
const {
  SvelteComponent: fh,
  append: hh,
  attr: xt,
  detach: ch,
  init: dh,
  insert: _h,
  noop: nr,
  safe_not_equal: mh,
  svg_element: Fa
} = window.__gradio__svelte__internal;
function gh(t) {
  let e, n;
  return {
    c() {
      e = Fa("svg"), n = Fa("path"), xt(n, "fill", "currentColor"), xt(n, "d", "M7 27h23v2H7zm20.38-16.49l-7.93-7.92a2 2 0 0 0-2.83 0l-14 14a2 2 0 0 0 0 2.83L7.13 24h9.59l10.66-10.66a2 2 0 0 0 0-2.83zM15.89 22H8l-4-4l6.31-6.31l7.93 7.92zm3.76-3.76l-7.92-7.93L18 4l8 7.93z"), xt(e, "xmlns", "http://www.w3.org/2000/svg"), xt(e, "width", "100%"), xt(e, "height", "100%"), xt(e, "viewBox", "0 0 32 32");
    },
    m(i, r) {
      _h(i, e, r), hh(e, n);
    },
    p: nr,
    i: nr,
    o: nr,
    d(i) {
      i && ch(e);
    }
  };
}
class ph extends fh {
  constructor(e) {
    super(), dh(this, e, null, gh, mh, {});
  }
}
const {
  SvelteComponent: bh,
  append: ir,
  attr: se,
  detach: vh,
  init: wh,
  insert: yh,
  noop: rr,
  safe_not_equal: Eh,
  svg_element: ni
} = window.__gradio__svelte__internal;
function kh(t) {
  let e, n, i, r;
  return {
    c() {
      e = ni("svg"), n = ni("rect"), i = ni("circle"), r = ni("polyline"), se(n, "x", "3"), se(n, "y", "3"), se(n, "width", "18"), se(n, "height", "18"), se(n, "rx", "2"), se(n, "ry", "2"), se(i, "cx", "8.5"), se(i, "cy", "8.5"), se(i, "r", "1.5"), se(r, "points", "21 15 16 10 5 21"), se(e, "xmlns", "http://www.w3.org/2000/svg"), se(e, "width", "100%"), se(e, "height", "100%"), se(e, "viewBox", "0 0 24 24"), se(e, "fill", "none"), se(e, "stroke", "currentColor"), se(e, "stroke-width", "1.5"), se(e, "stroke-linecap", "round"), se(e, "stroke-linejoin", "round"), se(e, "class", "feather feather-image");
    },
    m(a, s) {
      yh(a, e, s), ir(e, n), ir(e, i), ir(e, r);
    },
    p: rr,
    i: rr,
    o: rr,
    d(a) {
      a && vh(e);
    }
  };
}
class vi extends bh {
  constructor(e) {
    super(), wh(this, e, null, kh, Eh, {});
  }
}
const {
  SvelteComponent: Th,
  append: Sh,
  attr: ze,
  detach: Ch,
  init: Mh,
  insert: Ah,
  noop: ar,
  safe_not_equal: Oh,
  svg_element: Ga
} = window.__gradio__svelte__internal;
function Dh(t) {
  let e, n;
  return {
    c() {
      e = Ga("svg"), n = Ga("path"), ze(n, "d", "M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"), 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-edit-2");
    },
    m(i, r) {
      Ah(i, e, r), Sh(e, n);
    },
    p: ar,
    i: ar,
    o: ar,
    d(i) {
      i && Ch(e);
    }
  };
}
let za = class extends Th {
  constructor(e) {
    super(), Mh(this, e, null, Dh, Oh, {});
  }
};
const {
  SvelteComponent: Bh,
  append: Hh,
  attr: ge,
  detach: Nh,
  init: Ih,
  insert: Rh,
  noop: sr,
  safe_not_equal: Lh,
  svg_element: ja
} = window.__gradio__svelte__internal;
function Ph(t) {
  let e, n;
  return {
    c() {
      e = ja("svg"), n = ja("rect"), ge(n, "x", "3"), ge(n, "y", "3"), ge(n, "width", "18"), ge(n, "height", "18"), ge(n, "rx", "2"), ge(n, "ry", "2"), ge(e, "xmlns", "http://www.w3.org/2000/svg"), ge(e, "width", "100%"), ge(e, "height", "100%"), ge(e, "viewBox", "0 0 24 24"), ge(e, "fill", "red"), ge(e, "stroke", "red"), ge(e, "stroke-width", "1.5"), ge(e, "stroke-linecap", "round"), ge(e, "stroke-linejoin", "round"), ge(e, "class", "feather feather-square");
    },
    m(i, r) {
      Rh(i, e, r), Hh(e, n);
    },
    p: sr,
    i: sr,
    o: sr,
    d(i) {
      i && Nh(e);
    }
  };
}
class Uh extends Bh {
  constructor(e) {
    super(), Ih(this, e, null, Ph, Lh, {});
  }
}
const {
  SvelteComponent: Fh,
  append: qa,
  attr: Ne,
  detach: Gh,
  init: zh,
  insert: jh,
  noop: or,
  safe_not_equal: qh,
  svg_element: lr
} = window.__gradio__svelte__internal;
function xh(t) {
  let e, n, i;
  return {
    c() {
      e = lr("svg"), n = lr("polyline"), i = lr("path"), Ne(n, "points", "1 4 1 10 7 10"), Ne(i, "d", "M3.51 15a9 9 0 1 0 2.13-9.36L1 10"), Ne(e, "xmlns", "http://www.w3.org/2000/svg"), Ne(e, "width", "100%"), Ne(e, "height", "100%"), 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-rotate-ccw");
    },
    m(r, a) {
      jh(r, e, a), qa(e, n), qa(e, i);
    },
    p: or,
    i: or,
    o: or,
    d(r) {
      r && Gh(e);
    }
  };
}
class Xh extends Fh {
  constructor(e) {
    super(), zh(this, e, null, xh, qh, {});
  }
}
const {
  SvelteComponent: Vh,
  append: ur,
  attr: pe,
  detach: Wh,
  init: Yh,
  insert: Zh,
  noop: fr,
  safe_not_equal: Qh,
  svg_element: ii
} = window.__gradio__svelte__internal;
function Jh(t) {
  let e, n, i, r;
  return {
    c() {
      e = ii("svg"), n = ii("path"), i = ii("polyline"), r = ii("line"), pe(n, "d", "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"), pe(i, "points", "17 8 12 3 7 8"), pe(r, "x1", "12"), pe(r, "y1", "3"), pe(r, "x2", "12"), pe(r, "y2", "15"), pe(e, "xmlns", "http://www.w3.org/2000/svg"), pe(e, "width", "90%"), pe(e, "height", "90%"), pe(e, "viewBox", "0 0 24 24"), pe(e, "fill", "none"), pe(e, "stroke", "currentColor"), pe(e, "stroke-width", "2"), pe(e, "stroke-linecap", "round"), pe(e, "stroke-linejoin", "round"), pe(e, "class", "feather feather-upload");
    },
    m(a, s) {
      Zh(a, e, s), ur(e, n), ur(e, i), ur(e, r);
    },
    p: fr,
    i: fr,
    o: fr,
    d(a) {
      a && Wh(e);
    }
  };
}
let Kh = class extends Vh {
  constructor(e) {
    super(), Yh(this, e, null, Jh, Qh, {});
  }
};
const $h = [
  { 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 }
], xa = {
  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"
  }
};
$h.reduce(
  (t, { color: e, primary: n, secondary: i }) => ({
    ...t,
    [e]: {
      primary: xa[e][n],
      secondary: xa[e][i]
    }
  }),
  {}
);
function ec(t) {
  let e, n = t[0], i = 1;
  for (; i < t.length; ) {
    const r = t[i], a = t[i + 1];
    if (i += 2, (r === "optionalAccess" || r === "optionalCall") && n == null)
      return;
    r === "access" || r === "optionalAccess" ? (e = n, n = a(n)) : (r === "call" || r === "optionalCall") && (n = a((...s) => n.call(e, ...s)), e = void 0);
  }
  return n;
}
class hi extends Error {
  constructor(e) {
    super(e), this.name = "ShareError";
  }
}
async function tc(t, e) {
  if (window.__gradio_space__ == null)
    throw new hi("Must be on Spaces to share.");
  let n, i, r;
  if (e === "url") {
    const o = await fetch(t);
    n = await o.blob(), i = o.headers.get("content-type") || "", r = o.headers.get("content-disposition") || "";
  } else
    n = nc(t), i = t.split(";")[0].split(":")[1], r = "file" + i.split("/")[1];
  const a = new File([n], r, { type: i }), s = await fetch("https://huggingface.co/uploads", {
    method: "POST",
    body: a,
    headers: {
      "Content-Type": a.type,
      "X-Requested-With": "XMLHttpRequest"
    }
  });
  if (!s.ok) {
    if (ec([s, "access", (o) => o.headers, "access", (o) => o.get, "call", (o) => o("content-type"), "optionalAccess", (o) => o.includes, "call", (o) => o("application/json")])) {
      const o = await s.json();
      throw new hi(`Upload failed: ${o.error}`);
    }
    throw new hi("Upload failed.");
  }
  return await s.text();
}
function nc(t) {
  for (var e = t.split(","), n = e[0].match(/:(.*?);/)[1], i = atob(e[1]), r = i.length, a = new Uint8Array(r); r--; )
    a[r] = i.charCodeAt(r);
  return new Blob([a], { type: n });
}
const {
  SvelteComponent: ic,
  create_component: rc,
  destroy_component: ac,
  init: sc,
  mount_component: oc,
  safe_not_equal: lc,
  transition_in: uc,
  transition_out: fc
} = window.__gradio__svelte__internal, { createEventDispatcher: hc } = window.__gradio__svelte__internal;
function cc(t) {
  let e, n;
  return e = new rt({
    props: {
      Icon: Wf,
      label: (
        /*i18n*/
        t[2]("common.share")
      ),
      pending: (
        /*pending*/
        t[3]
      )
    }
  }), e.$on(
    "click",
    /*click_handler*/
    t[5]
  ), {
    c() {
      rc(e.$$.fragment);
    },
    m(i, r) {
      oc(e, i, r), n = !0;
    },
    p(i, [r]) {
      const a = {};
      r & /*i18n*/
      4 && (a.label = /*i18n*/
      i[2]("common.share")), r & /*pending*/
      8 && (a.pending = /*pending*/
      i[3]), e.$set(a);
    },
    i(i) {
      n || (uc(e.$$.fragment, i), n = !0);
    },
    o(i) {
      fc(e.$$.fragment, i), n = !1;
    },
    d(i) {
      ac(e, i);
    }
  };
}
function dc(t, e, n) {
  const i = hc();
  let { formatter: r } = e, { value: a } = e, { i18n: s } = e, l = !1;
  const o = async () => {
    try {
      n(3, l = !0);
      const u = await r(a);
      i("share", { description: u });
    } catch (u) {
      console.error(u);
      let f = u instanceof hi ? u.message : "Share failed.";
      i("error", f);
    } finally {
      n(3, l = !1);
    }
  };
  return t.$$set = (u) => {
    "formatter" in u && n(0, r = u.formatter), "value" in u && n(1, a = u.value), "i18n" in u && n(2, s = u.i18n);
  }, [r, a, s, l, i, o];
}
class _c extends ic {
  constructor(e) {
    super(), sc(this, e, dc, cc, lc, { formatter: 0, value: 1, i18n: 2 });
  }
}
const {
  SvelteComponent: mc,
  append: Dt,
  attr: Sr,
  create_component: gc,
  destroy_component: pc,
  detach: ci,
  element: Cr,
  init: bc,
  insert: di,
  mount_component: vc,
  safe_not_equal: wc,
  set_data: Mr,
  space: Ar,
  text: Mn,
  toggle_class: Xa,
  transition_in: yc,
  transition_out: Ec
} = window.__gradio__svelte__internal;
function Va(t) {
  let e, n, i = (
    /*i18n*/
    t[1]("common.or") + ""
  ), r, a, s, l = (
    /*message*/
    (t[2] || /*i18n*/
    t[1]("upload_text.click_to_upload")) + ""
  ), o;
  return {
    c() {
      e = Cr("span"), n = Mn("- "), r = Mn(i), a = Mn(" -"), s = Ar(), o = Mn(l), Sr(e, "class", "or svelte-kzcjhc");
    },
    m(u, f) {
      di(u, e, f), Dt(e, n), Dt(e, r), Dt(e, a), di(u, s, f), di(u, o, f);
    },
    p(u, f) {
      f & /*i18n*/
      2 && i !== (i = /*i18n*/
      u[1]("common.or") + "") && Mr(r, i), f & /*message, i18n*/
      6 && l !== (l = /*message*/
      (u[2] || /*i18n*/
      u[1]("upload_text.click_to_upload")) + "") && Mr(o, l);
    },
    d(u) {
      u && (ci(e), ci(s), ci(o));
    }
  };
}
function kc(t) {
  let e, n, i, r, a = (
    /*i18n*/
    t[1](
      /*defs*/
      t[5][
        /*type*/
        t[0]
      ] || /*defs*/
      t[5].file
    ) + ""
  ), s, l, o;
  i = new Kh({});
  let u = (
    /*mode*/
    t[3] !== "short" && Va(t)
  );
  return {
    c() {
      e = Cr("div"), n = Cr("span"), gc(i.$$.fragment), r = Ar(), s = Mn(a), l = Ar(), u && u.c(), Sr(n, "class", "icon-wrap svelte-kzcjhc"), Xa(
        n,
        "hovered",
        /*hovered*/
        t[4]
      ), Sr(e, "class", "wrap svelte-kzcjhc");
    },
    m(f, h) {
      di(f, e, h), Dt(e, n), vc(i, n, null), Dt(e, r), Dt(e, s), Dt(e, l), u && u.m(e, null), o = !0;
    },
    p(f, [h]) {
      (!o || h & /*hovered*/
      16) && Xa(
        n,
        "hovered",
        /*hovered*/
        f[4]
      ), (!o || h & /*i18n, type*/
      3) && a !== (a = /*i18n*/
      f[1](
        /*defs*/
        f[5][
          /*type*/
          f[0]
        ] || /*defs*/
        f[5].file
      ) + "") && Mr(s, a), /*mode*/
      f[3] !== "short" ? u ? u.p(f, h) : (u = Va(f), u.c(), u.m(e, null)) : u && (u.d(1), u = null);
    },
    i(f) {
      o || (yc(i.$$.fragment, f), o = !0);
    },
    o(f) {
      Ec(i.$$.fragment, f), o = !1;
    },
    d(f) {
      f && ci(e), pc(i), u && u.d();
    }
  };
}
function Tc(t, e, n) {
  let { type: i = "file" } = e, { i18n: r } = e, { message: a = void 0 } = e, { mode: s = "full" } = e, { hovered: l = !1 } = e;
  const o = {
    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"
  };
  return t.$$set = (u) => {
    "type" in u && n(0, i = u.type), "i18n" in u && n(1, r = u.i18n), "message" in u && n(2, a = u.message), "mode" in u && n(3, s = u.mode), "hovered" in u && n(4, l = u.hovered);
  }, [i, r, a, s, l, o];
}
class Sc extends mc {
  constructor(e) {
    super(), bc(this, e, Tc, kc, wc, {
      type: 0,
      i18n: 1,
      message: 2,
      mode: 3,
      hovered: 4
    });
  }
}
/*!
 * Cropper.js v1.6.1
 * https://fengyuanchen.github.io/cropperjs
 *
 * Copyright 2015-present Chen Fengyuan
 * Released under the MIT license
 *
 * Date: 2023-09-17T03:44:19.860Z
 */
function Wa(t, e) {
  var n = Object.keys(t);
  if (Object.getOwnPropertySymbols) {
    var i = Object.getOwnPropertySymbols(t);
    e && (i = i.filter(function(r) {
      return Object.getOwnPropertyDescriptor(t, r).enumerable;
    })), n.push.apply(n, i);
  }
  return n;
}
function Go(t) {
  for (var e = 1; e < arguments.length; e++) {
    var n = arguments[e] != null ? arguments[e] : {};
    e % 2 ? Wa(Object(n), !0).forEach(function(i) {
      Ac(t, i, n[i]);
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) : Wa(Object(n)).forEach(function(i) {
      Object.defineProperty(t, i, Object.getOwnPropertyDescriptor(n, i));
    });
  }
  return t;
}
function Or(t) {
  "@babel/helpers - typeof";
  return Or = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
    return typeof e;
  } : function(e) {
    return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
  }, Or(t);
}
function Cc(t, e) {
  if (!(t instanceof e))
    throw new TypeError("Cannot call a class as a function");
}
function Ya(t, e) {
  for (var n = 0; n < e.length; n++) {
    var i = e[n];
    i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(t, jo(i.key), i);
  }
}
function Mc(t, e, n) {
  return e && Ya(t.prototype, e), n && Ya(t, n), Object.defineProperty(t, "prototype", {
    writable: !1
  }), t;
}
function Ac(t, e, n) {
  return e = jo(e), e in t ? Object.defineProperty(t, e, {
    value: n,
    enumerable: !0,
    configurable: !0,
    writable: !0
  }) : t[e] = n, t;
}
function zo(t) {
  return Oc(t) || Dc(t) || Bc(t) || Hc();
}
function Oc(t) {
  if (Array.isArray(t))
    return Dr(t);
}
function Dc(t) {
  if (typeof Symbol < "u" && t[Symbol.iterator] != null || t["@@iterator"] != null)
    return Array.from(t);
}
function Bc(t, e) {
  if (t) {
    if (typeof t == "string")
      return Dr(t, e);
    var n = Object.prototype.toString.call(t).slice(8, -1);
    if (n === "Object" && t.constructor && (n = t.constructor.name), n === "Map" || n === "Set")
      return Array.from(t);
    if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
      return Dr(t, e);
  }
}
function Dr(t, e) {
  (e == null || e > t.length) && (e = t.length);
  for (var n = 0, i = new Array(e); n < e; n++)
    i[n] = t[n];
  return i;
}
function Hc() {
  throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
}
function Nc(t, e) {
  if (typeof t != "object" || t === null)
    return t;
  var n = t[Symbol.toPrimitive];
  if (n !== void 0) {
    var i = n.call(t, e || "default");
    if (typeof i != "object")
      return i;
    throw new TypeError("@@toPrimitive must return a primitive value.");
  }
  return (e === "string" ? String : Number)(t);
}
function jo(t) {
  var e = Nc(t, "string");
  return typeof e == "symbol" ? e : String(e);
}
var Oi = typeof window < "u" && typeof window.document < "u", $e = Oi ? window : {}, sa = Oi && $e.document.documentElement ? "ontouchstart" in $e.document.documentElement : !1, oa = Oi ? "PointerEvent" in $e : !1, ne = "cropper", la = "all", qo = "crop", xo = "move", Xo = "zoom", Tt = "e", St = "w", Xt = "s", dt = "n", En = "ne", kn = "nw", Tn = "se", Sn = "sw", Br = "".concat(ne, "-crop"), Za = "".concat(ne, "-disabled"), ke = "".concat(ne, "-hidden"), Qa = "".concat(ne, "-hide"), Ic = "".concat(ne, "-invisible"), wi = "".concat(ne, "-modal"), Hr = "".concat(ne, "-move"), Hn = "".concat(ne, "Action"), ri = "".concat(ne, "Preview"), ua = "crop", Vo = "move", Wo = "none", Nr = "crop", Ir = "cropend", Rr = "cropmove", Lr = "cropstart", Ja = "dblclick", Rc = sa ? "touchstart" : "mousedown", Lc = sa ? "touchmove" : "mousemove", Pc = sa ? "touchend touchcancel" : "mouseup", Ka = oa ? "pointerdown" : Rc, $a = oa ? "pointermove" : Lc, es = oa ? "pointerup pointercancel" : Pc, ts = "ready", ns = "resize", is = "wheel", Pr = "zoom", rs = "image/jpeg", Uc = /^e|w|s|n|se|sw|ne|nw|all|crop|move|zoom$/, Fc = /^data:/, Gc = /^data:image\/jpeg;base64,/, zc = /^img|canvas$/i, Yo = 200, Zo = 100, as = {
  // Define the view mode of the cropper
  viewMode: 0,
  // 0, 1, 2, 3
  // Define the dragging mode of the cropper
  dragMode: ua,
  // 'crop', 'move' or 'none'
  // Define the initial aspect ratio of the crop box
  initialAspectRatio: NaN,
  // Define the aspect ratio of the crop box
  aspectRatio: NaN,
  // An object with the previous cropping result data
  data: null,
  // A selector for adding extra containers to preview
  preview: "",
  // Re-render the cropper when resize the window
  responsive: !0,
  // Restore the cropped area after resize the window
  restore: !0,
  // Check if the current image is a cross-origin image
  checkCrossOrigin: !0,
  // Check the current image's Exif Orientation information
  checkOrientation: !0,
  // Show the black modal
  modal: !0,
  // Show the dashed lines for guiding
  guides: !0,
  // Show the center indicator for guiding
  center: !0,
  // Show the white modal to highlight the crop box
  highlight: !0,
  // Show the grid background
  background: !0,
  // Enable to crop the image automatically when initialize
  autoCrop: !0,
  // Define the percentage of automatic cropping area when initializes
  autoCropArea: 0.8,
  // Enable to move the image
  movable: !0,
  // Enable to rotate the image
  rotatable: !0,
  // Enable to scale the image
  scalable: !0,
  // Enable to zoom the image
  zoomable: !0,
  // Enable to zoom the image by dragging touch
  zoomOnTouch: !0,
  // Enable to zoom the image by wheeling mouse
  zoomOnWheel: !0,
  // Define zoom ratio when zoom the image by wheeling mouse
  wheelZoomRatio: 0.1,
  // Enable to move the crop box
  cropBoxMovable: !0,
  // Enable to resize the crop box
  cropBoxResizable: !0,
  // Toggle drag mode between "crop" and "move" when click twice on the cropper
  toggleDragModeOnDblclick: !0,
  // Size limitation
  minCanvasWidth: 0,
  minCanvasHeight: 0,
  minCropBoxWidth: 0,
  minCropBoxHeight: 0,
  minContainerWidth: Yo,
  minContainerHeight: Zo,
  // Shortcuts of events
  ready: null,
  cropstart: null,
  cropmove: null,
  cropend: null,
  crop: null,
  zoom: null
}, jc = '<div class="cropper-container" touch-action="none"><div class="cropper-wrap-box"><div class="cropper-canvas"></div></div><div class="cropper-drag-box"></div><div class="cropper-crop-box"><span class="cropper-view-box"></span><span class="cropper-dashed dashed-h"></span><span class="cropper-dashed dashed-v"></span><span class="cropper-center"></span><span class="cropper-face"></span><span class="cropper-line line-e" data-cropper-action="e"></span><span class="cropper-line line-n" data-cropper-action="n"></span><span class="cropper-line line-w" data-cropper-action="w"></span><span class="cropper-line line-s" data-cropper-action="s"></span><span class="cropper-point point-e" data-cropper-action="e"></span><span class="cropper-point point-n" data-cropper-action="n"></span><span class="cropper-point point-w" data-cropper-action="w"></span><span class="cropper-point point-s" data-cropper-action="s"></span><span class="cropper-point point-ne" data-cropper-action="ne"></span><span class="cropper-point point-nw" data-cropper-action="nw"></span><span class="cropper-point point-sw" data-cropper-action="sw"></span><span class="cropper-point point-se" data-cropper-action="se"></span></div></div>', qc = Number.isNaN || $e.isNaN;
function R(t) {
  return typeof t == "number" && !qc(t);
}
var ss = function(e) {
  return e > 0 && e < 1 / 0;
};
function hr(t) {
  return typeof t > "u";
}
function Nt(t) {
  return Or(t) === "object" && t !== null;
}
var xc = Object.prototype.hasOwnProperty;
function Zt(t) {
  if (!Nt(t))
    return !1;
  try {
    var e = t.constructor, n = e.prototype;
    return e && n && xc.call(n, "isPrototypeOf");
  } catch {
    return !1;
  }
}
function Ee(t) {
  return typeof t == "function";
}
var Xc = Array.prototype.slice;
function Qo(t) {
  return Array.from ? Array.from(t) : Xc.call(t);
}
function le(t, e) {
  return t && Ee(e) && (Array.isArray(t) || R(t.length) ? Qo(t).forEach(function(n, i) {
    e.call(t, n, i, t);
  }) : Nt(t) && Object.keys(t).forEach(function(n) {
    e.call(t, t[n], n, t);
  })), t;
}
var re = Object.assign || function(e) {
  for (var n = arguments.length, i = new Array(n > 1 ? n - 1 : 0), r = 1; r < n; r++)
    i[r - 1] = arguments[r];
  return Nt(e) && i.length > 0 && i.forEach(function(a) {
    Nt(a) && Object.keys(a).forEach(function(s) {
      e[s] = a[s];
    });
  }), e;
}, Vc = /\.\d*(?:0|9){12}\d*$/;
function Kt(t) {
  var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1e11;
  return Vc.test(t) ? Math.round(t * e) / e : t;
}
var Wc = /^width|height|left|top|marginLeft|marginTop$/;
function _t(t, e) {
  var n = t.style;
  le(e, function(i, r) {
    Wc.test(r) && R(i) && (i = "".concat(i, "px")), n[r] = i;
  });
}
function Yc(t, e) {
  return t.classList ? t.classList.contains(e) : t.className.indexOf(e) > -1;
}
function ce(t, e) {
  if (e) {
    if (R(t.length)) {
      le(t, function(i) {
        ce(i, e);
      });
      return;
    }
    if (t.classList) {
      t.classList.add(e);
      return;
    }
    var n = t.className.trim();
    n ? n.indexOf(e) < 0 && (t.className = "".concat(n, " ").concat(e)) : t.className = e;
  }
}
function Je(t, e) {
  if (e) {
    if (R(t.length)) {
      le(t, function(n) {
        Je(n, e);
      });
      return;
    }
    if (t.classList) {
      t.classList.remove(e);
      return;
    }
    t.className.indexOf(e) >= 0 && (t.className = t.className.replace(e, ""));
  }
}
function Qt(t, e, n) {
  if (e) {
    if (R(t.length)) {
      le(t, function(i) {
        Qt(i, e, n);
      });
      return;
    }
    n ? ce(t, e) : Je(t, e);
  }
}
var Zc = /([a-z\d])([A-Z])/g;
function fa(t) {
  return t.replace(Zc, "$1-$2").toLowerCase();
}
function Ur(t, e) {
  return Nt(t[e]) ? t[e] : t.dataset ? t.dataset[e] : t.getAttribute("data-".concat(fa(e)));
}
function Nn(t, e, n) {
  Nt(n) ? t[e] = n : t.dataset ? t.dataset[e] = n : t.setAttribute("data-".concat(fa(e)), n);
}
function Qc(t, e) {
  if (Nt(t[e]))
    try {
      delete t[e];
    } catch {
      t[e] = void 0;
    }
  else if (t.dataset)
    try {
      delete t.dataset[e];
    } catch {
      t.dataset[e] = void 0;
    }
  else
    t.removeAttribute("data-".concat(fa(e)));
}
var Jo = /\s\s*/, Ko = function() {
  var t = !1;
  if (Oi) {
    var e = !1, n = function() {
    }, i = Object.defineProperty({}, "once", {
      get: function() {
        return t = !0, e;
      },
      /**
       * This setter can fix a `TypeError` in strict mode
       * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Getter_only}
       * @param {boolean} value - The value to set
       */
      set: function(a) {
        e = a;
      }
    });
    $e.addEventListener("test", n, i), $e.removeEventListener("test", n, i);
  }
  return t;
}();
function je(t, e, n) {
  var i = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {}, r = n;
  e.trim().split(Jo).forEach(function(a) {
    if (!Ko) {
      var s = t.listeners;
      s && s[a] && s[a][n] && (r = s[a][n], delete s[a][n], Object.keys(s[a]).length === 0 && delete s[a], Object.keys(s).length === 0 && delete t.listeners);
    }
    t.removeEventListener(a, r, i);
  });
}
function Re(t, e, n) {
  var i = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {}, r = n;
  e.trim().split(Jo).forEach(function(a) {
    if (i.once && !Ko) {
      var s = t.listeners, l = s === void 0 ? {} : s;
      r = function() {
        delete l[a][n], t.removeEventListener(a, r, i);
        for (var u = arguments.length, f = new Array(u), h = 0; h < u; h++)
          f[h] = arguments[h];
        n.apply(t, f);
      }, l[a] || (l[a] = {}), l[a][n] && t.removeEventListener(a, l[a][n], i), l[a][n] = r, t.listeners = l;
    }
    t.addEventListener(a, r, i);
  });
}
function $t(t, e, n) {
  var i;
  return Ee(Event) && Ee(CustomEvent) ? i = new CustomEvent(e, {
    detail: n,
    bubbles: !0,
    cancelable: !0
  }) : (i = document.createEvent("CustomEvent"), i.initCustomEvent(e, !0, !0, n)), t.dispatchEvent(i);
}
function $o(t) {
  var e = t.getBoundingClientRect();
  return {
    left: e.left + (window.pageXOffset - document.documentElement.clientLeft),
    top: e.top + (window.pageYOffset - document.documentElement.clientTop)
  };
}
var cr = $e.location, Jc = /^(\w+:)\/\/([^:/?#]*):?(\d*)/i;
function os(t) {
  var e = t.match(Jc);
  return e !== null && (e[1] !== cr.protocol || e[2] !== cr.hostname || e[3] !== cr.port);
}
function ls(t) {
  var e = "timestamp=".concat((/* @__PURE__ */ new Date()).getTime());
  return t + (t.indexOf("?") === -1 ? "?" : "&") + e;
}
function Bn(t) {
  var e = t.rotate, n = t.scaleX, i = t.scaleY, r = t.translateX, a = t.translateY, s = [];
  R(r) && r !== 0 && s.push("translateX(".concat(r, "px)")), R(a) && a !== 0 && s.push("translateY(".concat(a, "px)")), R(e) && e !== 0 && s.push("rotate(".concat(e, "deg)")), R(n) && n !== 1 && s.push("scaleX(".concat(n, ")")), R(i) && i !== 1 && s.push("scaleY(".concat(i, ")"));
  var l = s.length ? s.join(" ") : "none";
  return {
    WebkitTransform: l,
    msTransform: l,
    transform: l
  };
}
function Kc(t) {
  var e = Go({}, t), n = 0;
  return le(t, function(i, r) {
    delete e[r], le(e, function(a) {
      var s = Math.abs(i.startX - a.startX), l = Math.abs(i.startY - a.startY), o = Math.abs(i.endX - a.endX), u = Math.abs(i.endY - a.endY), f = Math.sqrt(s * s + l * l), h = Math.sqrt(o * o + u * u), c = (h - f) / f;
      Math.abs(c) > Math.abs(n) && (n = c);
    });
  }), n;
}
function ai(t, e) {
  var n = t.pageX, i = t.pageY, r = {
    endX: n,
    endY: i
  };
  return e ? r : Go({
    startX: n,
    startY: i
  }, r);
}
function $c(t) {
  var e = 0, n = 0, i = 0;
  return le(t, function(r) {
    var a = r.startX, s = r.startY;
    e += a, n += s, i += 1;
  }), e /= i, n /= i, {
    pageX: e,
    pageY: n
  };
}
function mt(t) {
  var e = t.aspectRatio, n = t.height, i = t.width, r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "contain", a = ss(i), s = ss(n);
  if (a && s) {
    var l = n * e;
    r === "contain" && l > i || r === "cover" && l < i ? n = i / e : i = n * e;
  } else
    a ? n = i / e : s && (i = n * e);
  return {
    width: i,
    height: n
  };
}
function e0(t) {
  var e = t.width, n = t.height, i = t.degree;
  if (i = Math.abs(i) % 180, i === 90)
    return {
      width: n,
      height: e
    };
  var r = i % 90 * Math.PI / 180, a = Math.sin(r), s = Math.cos(r), l = e * s + n * a, o = e * a + n * s;
  return i > 90 ? {
    width: o,
    height: l
  } : {
    width: l,
    height: o
  };
}
function t0(t, e, n, i) {
  var r = e.aspectRatio, a = e.naturalWidth, s = e.naturalHeight, l = e.rotate, o = l === void 0 ? 0 : l, u = e.scaleX, f = u === void 0 ? 1 : u, h = e.scaleY, c = h === void 0 ? 1 : h, d = n.aspectRatio, _ = n.naturalWidth, m = n.naturalHeight, b = i.fillColor, C = b === void 0 ? "transparent" : b, T = i.imageSmoothingEnabled, y = T === void 0 ? !0 : T, S = i.imageSmoothingQuality, p = S === void 0 ? "low" : S, g = i.maxWidth, M = g === void 0 ? 1 / 0 : g, O = i.maxHeight, G = O === void 0 ? 1 / 0 : O, q = i.minWidth, ee = q === void 0 ? 0 : q, z = i.minHeight, E = z === void 0 ? 0 : z, D = document.createElement("canvas"), L = D.getContext("2d"), Y = mt({
    aspectRatio: d,
    width: M,
    height: G
  }), Z = mt({
    aspectRatio: d,
    width: ee,
    height: E
  }, "cover"), V = Math.min(Y.width, Math.max(Z.width, _)), fe = Math.min(Y.height, Math.max(Z.height, m)), Te = mt({
    aspectRatio: r,
    width: M,
    height: G
  }), be = mt({
    aspectRatio: r,
    width: ee,
    height: E
  }, "cover"), He = Math.min(Te.width, Math.max(be.width, a)), A = Math.min(Te.height, Math.max(be.height, s)), lt = [-He / 2, -A / 2, He, A];
  return D.width = Kt(V), D.height = Kt(fe), L.fillStyle = C, L.fillRect(0, 0, V, fe), L.save(), L.translate(V / 2, fe / 2), L.rotate(o * Math.PI / 180), L.scale(f, c), L.imageSmoothingEnabled = y, L.imageSmoothingQuality = p, L.drawImage.apply(L, [t].concat(zo(lt.map(function(wt) {
    return Math.floor(Kt(wt));
  })))), L.restore(), D;
}
var el = String.fromCharCode;
function n0(t, e, n) {
  var i = "";
  n += e;
  for (var r = e; r < n; r += 1)
    i += el(t.getUint8(r));
  return i;
}
var i0 = /^data:.*,/;
function r0(t) {
  var e = t.replace(i0, ""), n = atob(e), i = new ArrayBuffer(n.length), r = new Uint8Array(i);
  return le(r, function(a, s) {
    r[s] = n.charCodeAt(s);
  }), i;
}
function a0(t, e) {
  for (var n = [], i = 8192, r = new Uint8Array(t); r.length > 0; )
    n.push(el.apply(null, Qo(r.subarray(0, i)))), r = r.subarray(i);
  return "data:".concat(e, ";base64,").concat(btoa(n.join("")));
}
function s0(t) {
  var e = new DataView(t), n;
  try {
    var i, r, a;
    if (e.getUint8(0) === 255 && e.getUint8(1) === 216)
      for (var s = e.byteLength, l = 2; l + 1 < s; ) {
        if (e.getUint8(l) === 255 && e.getUint8(l + 1) === 225) {
          r = l;
          break;
        }
        l += 1;
      }
    if (r) {
      var o = r + 4, u = r + 10;
      if (n0(e, o, 4) === "Exif") {
        var f = e.getUint16(u);
        if (i = f === 18761, (i || f === 19789) && e.getUint16(u + 2, i) === 42) {
          var h = e.getUint32(u + 4, i);
          h >= 8 && (a = u + h);
        }
      }
    }
    if (a) {
      var c = e.getUint16(a, i), d, _;
      for (_ = 0; _ < c; _ += 1)
        if (d = a + _ * 12 + 2, e.getUint16(d, i) === 274) {
          d += 8, n = e.getUint16(d, i), e.setUint16(d, 1, i);
          break;
        }
    }
  } catch {
    n = 1;
  }
  return n;
}
function o0(t) {
  var e = 0, n = 1, i = 1;
  switch (t) {
    case 2:
      n = -1;
      break;
    case 3:
      e = -180;
      break;
    case 4:
      i = -1;
      break;
    case 5:
      e = 90, i = -1;
      break;
    case 6:
      e = 90;
      break;
    case 7:
      e = 90, n = -1;
      break;
    case 8:
      e = -90;
      break;
  }
  return {
    rotate: e,
    scaleX: n,
    scaleY: i
  };
}
var l0 = {
  render: function() {
    this.initContainer(), this.initCanvas(), this.initCropBox(), this.renderCanvas(), this.cropped && this.renderCropBox();
  },
  initContainer: function() {
    var e = this.element, n = this.options, i = this.container, r = this.cropper, a = Number(n.minContainerWidth), s = Number(n.minContainerHeight);
    ce(r, ke), Je(e, ke);
    var l = {
      width: Math.max(i.offsetWidth, a >= 0 ? a : Yo),
      height: Math.max(i.offsetHeight, s >= 0 ? s : Zo)
    };
    this.containerData = l, _t(r, {
      width: l.width,
      height: l.height
    }), ce(e, ke), Je(r, ke);
  },
  // Canvas (image wrapper)
  initCanvas: function() {
    var e = this.containerData, n = this.imageData, i = this.options.viewMode, r = Math.abs(n.rotate) % 180 === 90, a = r ? n.naturalHeight : n.naturalWidth, s = r ? n.naturalWidth : n.naturalHeight, l = a / s, o = e.width, u = e.height;
    e.height * l > e.width ? i === 3 ? o = e.height * l : u = e.width / l : i === 3 ? u = e.width / l : o = e.height * l;
    var f = {
      aspectRatio: l,
      naturalWidth: a,
      naturalHeight: s,
      width: o,
      height: u
    };
    this.canvasData = f, this.limited = i === 1 || i === 2, this.limitCanvas(!0, !0), f.width = Math.min(Math.max(f.width, f.minWidth), f.maxWidth), f.height = Math.min(Math.max(f.height, f.minHeight), f.maxHeight), f.left = (e.width - f.width) / 2, f.top = (e.height - f.height) / 2, f.oldLeft = f.left, f.oldTop = f.top, this.initialCanvasData = re({}, f);
  },
  limitCanvas: function(e, n) {
    var i = this.options, r = this.containerData, a = this.canvasData, s = this.cropBoxData, l = i.viewMode, o = a.aspectRatio, u = this.cropped && s;
    if (e) {
      var f = Number(i.minCanvasWidth) || 0, h = Number(i.minCanvasHeight) || 0;
      l > 1 ? (f = Math.max(f, r.width), h = Math.max(h, r.height), l === 3 && (h * o > f ? f = h * o : h = f / o)) : l > 0 && (f ? f = Math.max(f, u ? s.width : 0) : h ? h = Math.max(h, u ? s.height : 0) : u && (f = s.width, h = s.height, h * o > f ? f = h * o : h = f / o));
      var c = mt({
        aspectRatio: o,
        width: f,
        height: h
      });
      f = c.width, h = c.height, a.minWidth = f, a.minHeight = h, a.maxWidth = 1 / 0, a.maxHeight = 1 / 0;
    }
    if (n)
      if (l > (u ? 0 : 1)) {
        var d = r.width - a.width, _ = r.height - a.height;
        a.minLeft = Math.min(0, d), a.minTop = Math.min(0, _), a.maxLeft = Math.max(0, d), a.maxTop = Math.max(0, _), u && this.limited && (a.minLeft = Math.min(s.left, s.left + (s.width - a.width)), a.minTop = Math.min(s.top, s.top + (s.height - a.height)), a.maxLeft = s.left, a.maxTop = s.top, l === 2 && (a.width >= r.width && (a.minLeft = Math.min(0, d), a.maxLeft = Math.max(0, d)), a.height >= r.height && (a.minTop = Math.min(0, _), a.maxTop = Math.max(0, _))));
      } else
        a.minLeft = -a.width, a.minTop = -a.height, a.maxLeft = r.width, a.maxTop = r.height;
  },
  renderCanvas: function(e, n) {
    var i = this.canvasData, r = this.imageData;
    if (n) {
      var a = e0({
        width: r.naturalWidth * Math.abs(r.scaleX || 1),
        height: r.naturalHeight * Math.abs(r.scaleY || 1),
        degree: r.rotate || 0
      }), s = a.width, l = a.height, o = i.width * (s / i.naturalWidth), u = i.height * (l / i.naturalHeight);
      i.left -= (o - i.width) / 2, i.top -= (u - i.height) / 2, i.width = o, i.height = u, i.aspectRatio = s / l, i.naturalWidth = s, i.naturalHeight = l, this.limitCanvas(!0, !1);
    }
    (i.width > i.maxWidth || i.width < i.minWidth) && (i.left = i.oldLeft), (i.height > i.maxHeight || i.height < i.minHeight) && (i.top = i.oldTop), i.width = Math.min(Math.max(i.width, i.minWidth), i.maxWidth), i.height = Math.min(Math.max(i.height, i.minHeight), i.maxHeight), this.limitCanvas(!1, !0), i.left = Math.min(Math.max(i.left, i.minLeft), i.maxLeft), i.top = Math.min(Math.max(i.top, i.minTop), i.maxTop), i.oldLeft = i.left, i.oldTop = i.top, _t(this.canvas, re({
      width: i.width,
      height: i.height
    }, Bn({
      translateX: i.left,
      translateY: i.top
    }))), this.renderImage(e), this.cropped && this.limited && this.limitCropBox(!0, !0);
  },
  renderImage: function(e) {
    var n = this.canvasData, i = this.imageData, r = i.naturalWidth * (n.width / n.naturalWidth), a = i.naturalHeight * (n.height / n.naturalHeight);
    re(i, {
      width: r,
      height: a,
      left: (n.width - r) / 2,
      top: (n.height - a) / 2
    }), _t(this.image, re({
      width: i.width,
      height: i.height
    }, Bn(re({
      translateX: i.left,
      translateY: i.top
    }, i)))), e && this.output();
  },
  initCropBox: function() {
    var e = this.options, n = this.canvasData, i = e.aspectRatio || e.initialAspectRatio, r = Number(e.autoCropArea) || 0.8, a = {
      width: n.width,
      height: n.height
    };
    i && (n.height * i > n.width ? a.height = a.width / i : a.width = a.height * i), this.cropBoxData = a, this.limitCropBox(!0, !0), a.width = Math.min(Math.max(a.width, a.minWidth), a.maxWidth), a.height = Math.min(Math.max(a.height, a.minHeight), a.maxHeight), a.width = Math.max(a.minWidth, a.width * r), a.height = Math.max(a.minHeight, a.height * r), a.left = n.left + (n.width - a.width) / 2, a.top = n.top + (n.height - a.height) / 2, a.oldLeft = a.left, a.oldTop = a.top, this.initialCropBoxData = re({}, a);
  },
  limitCropBox: function(e, n) {
    var i = this.options, r = this.containerData, a = this.canvasData, s = this.cropBoxData, l = this.limited, o = i.aspectRatio;
    if (e) {
      var u = Number(i.minCropBoxWidth) || 0, f = Number(i.minCropBoxHeight) || 0, h = l ? Math.min(r.width, a.width, a.width + a.left, r.width - a.left) : r.width, c = l ? Math.min(r.height, a.height, a.height + a.top, r.height - a.top) : r.height;
      u = Math.min(u, r.width), f = Math.min(f, r.height), o && (u && f ? f * o > u ? f = u / o : u = f * o : u ? f = u / o : f && (u = f * o), c * o > h ? c = h / o : h = c * o), s.minWidth = Math.min(u, h), s.minHeight = Math.min(f, c), s.maxWidth = h, s.maxHeight = c;
    }
    n && (l ? (s.minLeft = Math.max(0, a.left), s.minTop = Math.max(0, a.top), s.maxLeft = Math.min(r.width, a.left + a.width) - s.width, s.maxTop = Math.min(r.height, a.top + a.height) - s.height) : (s.minLeft = 0, s.minTop = 0, s.maxLeft = r.width - s.width, s.maxTop = r.height - s.height));
  },
  renderCropBox: function() {
    var e = this.options, n = this.containerData, i = this.cropBoxData;
    (i.width > i.maxWidth || i.width < i.minWidth) && (i.left = i.oldLeft), (i.height > i.maxHeight || i.height < i.minHeight) && (i.top = i.oldTop), i.width = Math.min(Math.max(i.width, i.minWidth), i.maxWidth), i.height = Math.min(Math.max(i.height, i.minHeight), i.maxHeight), this.limitCropBox(!1, !0), i.left = Math.min(Math.max(i.left, i.minLeft), i.maxLeft), i.top = Math.min(Math.max(i.top, i.minTop), i.maxTop), i.oldLeft = i.left, i.oldTop = i.top, e.movable && e.cropBoxMovable && Nn(this.face, Hn, i.width >= n.width && i.height >= n.height ? xo : la), _t(this.cropBox, re({
      width: i.width,
      height: i.height
    }, Bn({
      translateX: i.left,
      translateY: i.top
    }))), this.cropped && this.limited && this.limitCanvas(!0, !0), this.disabled || this.output();
  },
  output: function() {
    this.preview(), $t(this.element, Nr, this.getData());
  }
}, u0 = {
  initPreview: function() {
    var e = this.element, n = this.crossOrigin, i = this.options.preview, r = n ? this.crossOriginUrl : this.url, a = e.alt || "The image to preview", s = document.createElement("img");
    if (n && (s.crossOrigin = n), s.src = r, s.alt = a, this.viewBox.appendChild(s), this.viewBoxImage = s, !!i) {
      var l = i;
      typeof i == "string" ? l = e.ownerDocument.querySelectorAll(i) : i.querySelector && (l = [i]), this.previews = l, le(l, function(o) {
        var u = document.createElement("img");
        Nn(o, ri, {
          width: o.offsetWidth,
          height: o.offsetHeight,
          html: o.innerHTML
        }), n && (u.crossOrigin = n), u.src = r, u.alt = a, u.style.cssText = 'display:block;width:100%;height:auto;min-width:0!important;min-height:0!important;max-width:none!important;max-height:none!important;image-orientation:0deg!important;"', o.innerHTML = "", o.appendChild(u);
      });
    }
  },
  resetPreview: function() {
    le(this.previews, function(e) {
      var n = Ur(e, ri);
      _t(e, {
        width: n.width,
        height: n.height
      }), e.innerHTML = n.html, Qc(e, ri);
    });
  },
  preview: function() {
    var e = this.imageData, n = this.canvasData, i = this.cropBoxData, r = i.width, a = i.height, s = e.width, l = e.height, o = i.left - n.left - e.left, u = i.top - n.top - e.top;
    !this.cropped || this.disabled || (_t(this.viewBoxImage, re({
      width: s,
      height: l
    }, Bn(re({
      translateX: -o,
      translateY: -u
    }, e)))), le(this.previews, function(f) {
      var h = Ur(f, ri), c = h.width, d = h.height, _ = c, m = d, b = 1;
      r && (b = c / r, m = a * b), a && m > d && (b = d / a, _ = r * b, m = d), _t(f, {
        width: _,
        height: m
      }), _t(f.getElementsByTagName("img")[0], re({
        width: s * b,
        height: l * b
      }, Bn(re({
        translateX: -o * b,
        translateY: -u * b
      }, e))));
    }));
  }
}, f0 = {
  bind: function() {
    var e = this.element, n = this.options, i = this.cropper;
    Ee(n.cropstart) && Re(e, Lr, n.cropstart), Ee(n.cropmove) && Re(e, Rr, n.cropmove), Ee(n.cropend) && Re(e, Ir, n.cropend), Ee(n.crop) && Re(e, Nr, n.crop), Ee(n.zoom) && Re(e, Pr, n.zoom), Re(i, Ka, this.onCropStart = this.cropStart.bind(this)), n.zoomable && n.zoomOnWheel && Re(i, is, this.onWheel = this.wheel.bind(this), {
      passive: !1,
      capture: !0
    }), n.toggleDragModeOnDblclick && Re(i, Ja, this.onDblclick = this.dblclick.bind(this)), Re(e.ownerDocument, $a, this.onCropMove = this.cropMove.bind(this)), Re(e.ownerDocument, es, this.onCropEnd = this.cropEnd.bind(this)), n.responsive && Re(window, ns, this.onResize = this.resize.bind(this));
  },
  unbind: function() {
    var e = this.element, n = this.options, i = this.cropper;
    Ee(n.cropstart) && je(e, Lr, n.cropstart), Ee(n.cropmove) && je(e, Rr, n.cropmove), Ee(n.cropend) && je(e, Ir, n.cropend), Ee(n.crop) && je(e, Nr, n.crop), Ee(n.zoom) && je(e, Pr, n.zoom), je(i, Ka, this.onCropStart), n.zoomable && n.zoomOnWheel && je(i, is, this.onWheel, {
      passive: !1,
      capture: !0
    }), n.toggleDragModeOnDblclick && je(i, Ja, this.onDblclick), je(e.ownerDocument, $a, this.onCropMove), je(e.ownerDocument, es, this.onCropEnd), n.responsive && je(window, ns, this.onResize);
  }
}, h0 = {
  resize: function() {
    if (!this.disabled) {
      var e = this.options, n = this.container, i = this.containerData, r = n.offsetWidth / i.width, a = n.offsetHeight / i.height, s = Math.abs(r - 1) > Math.abs(a - 1) ? r : a;
      if (s !== 1) {
        var l, o;
        e.restore && (l = this.getCanvasData(), o = this.getCropBoxData()), this.render(), e.restore && (this.setCanvasData(le(l, function(u, f) {
          l[f] = u * s;
        })), this.setCropBoxData(le(o, function(u, f) {
          o[f] = u * s;
        })));
      }
    }
  },
  dblclick: function() {
    this.disabled || this.options.dragMode === Wo || this.setDragMode(Yc(this.dragBox, Br) ? Vo : ua);
  },
  wheel: function(e) {
    var n = this, i = Number(this.options.wheelZoomRatio) || 0.1, r = 1;
    this.disabled || (e.preventDefault(), !this.wheeling && (this.wheeling = !0, setTimeout(function() {
      n.wheeling = !1;
    }, 50), e.deltaY ? r = e.deltaY > 0 ? 1 : -1 : e.wheelDelta ? r = -e.wheelDelta / 120 : e.detail && (r = e.detail > 0 ? 1 : -1), this.zoom(-r * i, e)));
  },
  cropStart: function(e) {
    var n = e.buttons, i = e.button;
    if (!(this.disabled || (e.type === "mousedown" || e.type === "pointerdown" && e.pointerType === "mouse") && // No primary button (Usually the left button)
    (R(n) && n !== 1 || R(i) && i !== 0 || e.ctrlKey))) {
      var r = this.options, a = this.pointers, s;
      e.changedTouches ? le(e.changedTouches, function(l) {
        a[l.identifier] = ai(l);
      }) : a[e.pointerId || 0] = ai(e), Object.keys(a).length > 1 && r.zoomable && r.zoomOnTouch ? s = Xo : s = Ur(e.target, Hn), Uc.test(s) && $t(this.element, Lr, {
        originalEvent: e,
        action: s
      }) !== !1 && (e.preventDefault(), this.action = s, this.cropping = !1, s === qo && (this.cropping = !0, ce(this.dragBox, wi)));
    }
  },
  cropMove: function(e) {
    var n = this.action;
    if (!(this.disabled || !n)) {
      var i = this.pointers;
      e.preventDefault(), $t(this.element, Rr, {
        originalEvent: e,
        action: n
      }) !== !1 && (e.changedTouches ? le(e.changedTouches, function(r) {
        re(i[r.identifier] || {}, ai(r, !0));
      }) : re(i[e.pointerId || 0] || {}, ai(e, !0)), this.change(e));
    }
  },
  cropEnd: function(e) {
    if (!this.disabled) {
      var n = this.action, i = this.pointers;
      e.changedTouches ? le(e.changedTouches, function(r) {
        delete i[r.identifier];
      }) : delete i[e.pointerId || 0], n && (e.preventDefault(), Object.keys(i).length || (this.action = ""), this.cropping && (this.cropping = !1, Qt(this.dragBox, wi, this.cropped && this.options.modal)), $t(this.element, Ir, {
        originalEvent: e,
        action: n
      }));
    }
  }
}, c0 = {
  change: function(e) {
    var n = this.options, i = this.canvasData, r = this.containerData, a = this.cropBoxData, s = this.pointers, l = this.action, o = n.aspectRatio, u = a.left, f = a.top, h = a.width, c = a.height, d = u + h, _ = f + c, m = 0, b = 0, C = r.width, T = r.height, y = !0, S;
    !o && e.shiftKey && (o = h && c ? h / c : 1), this.limited && (m = a.minLeft, b = a.minTop, C = m + Math.min(r.width, i.width, i.left + i.width), T = b + Math.min(r.height, i.height, i.top + i.height));
    var p = s[Object.keys(s)[0]], g = {
      x: p.endX - p.startX,
      y: p.endY - p.startY
    }, M = function(G) {
      switch (G) {
        case Tt:
          d + g.x > C && (g.x = C - d);
          break;
        case St:
          u + g.x < m && (g.x = m - u);
          break;
        case dt:
          f + g.y < b && (g.y = b - f);
          break;
        case Xt:
          _ + g.y > T && (g.y = T - _);
          break;
      }
    };
    switch (l) {
      case la:
        u += g.x, f += g.y;
        break;
      case Tt:
        if (g.x >= 0 && (d >= C || o && (f <= b || _ >= T))) {
          y = !1;
          break;
        }
        M(Tt), h += g.x, h < 0 && (l = St, h = -h, u -= h), o && (c = h / o, f += (a.height - c) / 2);
        break;
      case dt:
        if (g.y <= 0 && (f <= b || o && (u <= m || d >= C))) {
          y = !1;
          break;
        }
        M(dt), c -= g.y, f += g.y, c < 0 && (l = Xt, c = -c, f -= c), o && (h = c * o, u += (a.width - h) / 2);
        break;
      case St:
        if (g.x <= 0 && (u <= m || o && (f <= b || _ >= T))) {
          y = !1;
          break;
        }
        M(St), h -= g.x, u += g.x, h < 0 && (l = Tt, h = -h, u -= h), o && (c = h / o, f += (a.height - c) / 2);
        break;
      case Xt:
        if (g.y >= 0 && (_ >= T || o && (u <= m || d >= C))) {
          y = !1;
          break;
        }
        M(Xt), c += g.y, c < 0 && (l = dt, c = -c, f -= c), o && (h = c * o, u += (a.width - h) / 2);
        break;
      case En:
        if (o) {
          if (g.y <= 0 && (f <= b || d >= C)) {
            y = !1;
            break;
          }
          M(dt), c -= g.y, f += g.y, h = c * o;
        } else
          M(dt), M(Tt), g.x >= 0 ? d < C ? h += g.x : g.y <= 0 && f <= b && (y = !1) : h += g.x, g.y <= 0 ? f > b && (c -= g.y, f += g.y) : (c -= g.y, f += g.y);
        h < 0 && c < 0 ? (l = Sn, c = -c, h = -h, f -= c, u -= h) : h < 0 ? (l = kn, h = -h, u -= h) : c < 0 && (l = Tn, c = -c, f -= c);
        break;
      case kn:
        if (o) {
          if (g.y <= 0 && (f <= b || u <= m)) {
            y = !1;
            break;
          }
          M(dt), c -= g.y, f += g.y, h = c * o, u += a.width - h;
        } else
          M(dt), M(St), g.x <= 0 ? u > m ? (h -= g.x, u += g.x) : g.y <= 0 && f <= b && (y = !1) : (h -= g.x, u += g.x), g.y <= 0 ? f > b && (c -= g.y, f += g.y) : (c -= g.y, f += g.y);
        h < 0 && c < 0 ? (l = Tn, c = -c, h = -h, f -= c, u -= h) : h < 0 ? (l = En, h = -h, u -= h) : c < 0 && (l = Sn, c = -c, f -= c);
        break;
      case Sn:
        if (o) {
          if (g.x <= 0 && (u <= m || _ >= T)) {
            y = !1;
            break;
          }
          M(St), h -= g.x, u += g.x, c = h / o;
        } else
          M(Xt), M(St), g.x <= 0 ? u > m ? (h -= g.x, u += g.x) : g.y >= 0 && _ >= T && (y = !1) : (h -= g.x, u += g.x), g.y >= 0 ? _ < T && (c += g.y) : c += g.y;
        h < 0 && c < 0 ? (l = En, c = -c, h = -h, f -= c, u -= h) : h < 0 ? (l = Tn, h = -h, u -= h) : c < 0 && (l = kn, c = -c, f -= c);
        break;
      case Tn:
        if (o) {
          if (g.x >= 0 && (d >= C || _ >= T)) {
            y = !1;
            break;
          }
          M(Tt), h += g.x, c = h / o;
        } else
          M(Xt), M(Tt), g.x >= 0 ? d < C ? h += g.x : g.y >= 0 && _ >= T && (y = !1) : h += g.x, g.y >= 0 ? _ < T && (c += g.y) : c += g.y;
        h < 0 && c < 0 ? (l = kn, c = -c, h = -h, f -= c, u -= h) : h < 0 ? (l = Sn, h = -h, u -= h) : c < 0 && (l = En, c = -c, f -= c);
        break;
      case xo:
        this.move(g.x, g.y), y = !1;
        break;
      case Xo:
        this.zoom(Kc(s), e), y = !1;
        break;
      case qo:
        if (!g.x || !g.y) {
          y = !1;
          break;
        }
        S = $o(this.cropper), u = p.startX - S.left, f = p.startY - S.top, h = a.minWidth, c = a.minHeight, g.x > 0 ? l = g.y > 0 ? Tn : En : g.x < 0 && (u -= h, l = g.y > 0 ? Sn : kn), g.y < 0 && (f -= c), this.cropped || (Je(this.cropBox, ke), this.cropped = !0, this.limited && this.limitCropBox(!0, !0));
        break;
    }
    y && (a.width = h, a.height = c, a.left = u, a.top = f, this.action = l, this.renderCropBox()), le(s, function(O) {
      O.startX = O.endX, O.startY = O.endY;
    });
  }
}, d0 = {
  // Show the crop box manually
  crop: function() {
    return this.ready && !this.cropped && !this.disabled && (this.cropped = !0, this.limitCropBox(!0, !0), this.options.modal && ce(this.dragBox, wi), Je(this.cropBox, ke), this.setCropBoxData(this.initialCropBoxData)), this;
  },
  // Reset the image and crop box to their initial states
  reset: function() {
    return this.ready && !this.disabled && (this.imageData = re({}, this.initialImageData), this.canvasData = re({}, this.initialCanvasData), this.cropBoxData = re({}, this.initialCropBoxData), this.renderCanvas(), this.cropped && this.renderCropBox()), this;
  },
  // Clear the crop box
  clear: function() {
    return this.cropped && !this.disabled && (re(this.cropBoxData, {
      left: 0,
      top: 0,
      width: 0,
      height: 0
    }), this.cropped = !1, this.renderCropBox(), this.limitCanvas(!0, !0), this.renderCanvas(), Je(this.dragBox, wi), ce(this.cropBox, ke)), this;
  },
  /**
   * Replace the image's src and rebuild the cropper
   * @param {string} url - The new URL.
   * @param {boolean} [hasSameSize] - Indicate if the new image has the same size as the old one.
   * @returns {Cropper} this
   */
  replace: function(e) {
    var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1;
    return !this.disabled && e && (this.isImg && (this.element.src = e), n ? (this.url = e, this.image.src = e, this.ready && (this.viewBoxImage.src = e, le(this.previews, function(i) {
      i.getElementsByTagName("img")[0].src = e;
    }))) : (this.isImg && (this.replaced = !0), this.options.data = null, this.uncreate(), this.load(e))), this;
  },
  // Enable (unfreeze) the cropper
  enable: function() {
    return this.ready && this.disabled && (this.disabled = !1, Je(this.cropper, Za)), this;
  },
  // Disable (freeze) the cropper
  disable: function() {
    return this.ready && !this.disabled && (this.disabled = !0, ce(this.cropper, Za)), this;
  },
  /**
   * Destroy the cropper and remove the instance from the image
   * @returns {Cropper} this
   */
  destroy: function() {
    var e = this.element;
    return e[ne] ? (e[ne] = void 0, this.isImg && this.replaced && (e.src = this.originalUrl), this.uncreate(), this) : this;
  },
  /**
   * Move the canvas with relative offsets
   * @param {number} offsetX - The relative offset distance on the x-axis.
   * @param {number} [offsetY=offsetX] - The relative offset distance on the y-axis.
   * @returns {Cropper} this
   */
  move: function(e) {
    var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : e, i = this.canvasData, r = i.left, a = i.top;
    return this.moveTo(hr(e) ? e : r + Number(e), hr(n) ? n : a + Number(n));
  },
  /**
   * Move the canvas to an absolute point
   * @param {number} x - The x-axis coordinate.
   * @param {number} [y=x] - The y-axis coordinate.
   * @returns {Cropper} this
   */
  moveTo: function(e) {
    var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : e, i = this.canvasData, r = !1;
    return e = Number(e), n = Number(n), this.ready && !this.disabled && this.options.movable && (R(e) && (i.left = e, r = !0), R(n) && (i.top = n, r = !0), r && this.renderCanvas(!0)), this;
  },
  /**
   * Zoom the canvas with a relative ratio
   * @param {number} ratio - The target ratio.
   * @param {Event} _originalEvent - The original event if any.
   * @returns {Cropper} this
   */
  zoom: function(e, n) {
    var i = this.canvasData;
    return e = Number(e), e < 0 ? e = 1 / (1 - e) : e = 1 + e, this.zoomTo(i.width * e / i.naturalWidth, null, n);
  },
  /**
   * Zoom the canvas to an absolute ratio
   * @param {number} ratio - The target ratio.
   * @param {Object} pivot - The zoom pivot point coordinate.
   * @param {Event} _originalEvent - The original event if any.
   * @returns {Cropper} this
   */
  zoomTo: function(e, n, i) {
    var r = this.options, a = this.canvasData, s = a.width, l = a.height, o = a.naturalWidth, u = a.naturalHeight;
    if (e = Number(e), e >= 0 && this.ready && !this.disabled && r.zoomable) {
      var f = o * e, h = u * e;
      if ($t(this.element, Pr, {
        ratio: e,
        oldRatio: s / o,
        originalEvent: i
      }) === !1)
        return this;
      if (i) {
        var c = this.pointers, d = $o(this.cropper), _ = c && Object.keys(c).length ? $c(c) : {
          pageX: i.pageX,
          pageY: i.pageY
        };
        a.left -= (f - s) * ((_.pageX - d.left - a.left) / s), a.top -= (h - l) * ((_.pageY - d.top - a.top) / l);
      } else
        Zt(n) && R(n.x) && R(n.y) ? (a.left -= (f - s) * ((n.x - a.left) / s), a.top -= (h - l) * ((n.y - a.top) / l)) : (a.left -= (f - s) / 2, a.top -= (h - l) / 2);
      a.width = f, a.height = h, this.renderCanvas(!0);
    }
    return this;
  },
  /**
   * Rotate the canvas with a relative degree
   * @param {number} degree - The rotate degree.
   * @returns {Cropper} this
   */
  rotate: function(e) {
    return this.rotateTo((this.imageData.rotate || 0) + Number(e));
  },
  /**
   * Rotate the canvas to an absolute degree
   * @param {number} degree - The rotate degree.
   * @returns {Cropper} this
   */
  rotateTo: function(e) {
    return e = Number(e), R(e) && this.ready && !this.disabled && this.options.rotatable && (this.imageData.rotate = e % 360, this.renderCanvas(!0, !0)), this;
  },
  /**
   * Scale the image on the x-axis.
   * @param {number} scaleX - The scale ratio on the x-axis.
   * @returns {Cropper} this
   */
  scaleX: function(e) {
    var n = this.imageData.scaleY;
    return this.scale(e, R(n) ? n : 1);
  },
  /**
   * Scale the image on the y-axis.
   * @param {number} scaleY - The scale ratio on the y-axis.
   * @returns {Cropper} this
   */
  scaleY: function(e) {
    var n = this.imageData.scaleX;
    return this.scale(R(n) ? n : 1, e);
  },
  /**
   * Scale the image
   * @param {number} scaleX - The scale ratio on the x-axis.
   * @param {number} [scaleY=scaleX] - The scale ratio on the y-axis.
   * @returns {Cropper} this
   */
  scale: function(e) {
    var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : e, i = this.imageData, r = !1;
    return e = Number(e), n = Number(n), this.ready && !this.disabled && this.options.scalable && (R(e) && (i.scaleX = e, r = !0), R(n) && (i.scaleY = n, r = !0), r && this.renderCanvas(!0, !0)), this;
  },
  /**
   * Get the cropped area position and size data (base on the original image)
   * @param {boolean} [rounded=false] - Indicate if round the data values or not.
   * @returns {Object} The result cropped data.
   */
  getData: function() {
    var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !1, n = this.options, i = this.imageData, r = this.canvasData, a = this.cropBoxData, s;
    if (this.ready && this.cropped) {
      s = {
        x: a.left - r.left,
        y: a.top - r.top,
        width: a.width,
        height: a.height
      };
      var l = i.width / i.naturalWidth;
      if (le(s, function(f, h) {
        s[h] = f / l;
      }), e) {
        var o = Math.round(s.y + s.height), u = Math.round(s.x + s.width);
        s.x = Math.round(s.x), s.y = Math.round(s.y), s.width = u - s.x, s.height = o - s.y;
      }
    } else
      s = {
        x: 0,
        y: 0,
        width: 0,
        height: 0
      };
    return n.rotatable && (s.rotate = i.rotate || 0), n.scalable && (s.scaleX = i.scaleX || 1, s.scaleY = i.scaleY || 1), s;
  },
  /**
   * Set the cropped area position and size with new data
   * @param {Object} data - The new data.
   * @returns {Cropper} this
   */
  setData: function(e) {
    var n = this.options, i = this.imageData, r = this.canvasData, a = {};
    if (this.ready && !this.disabled && Zt(e)) {
      var s = !1;
      n.rotatable && R(e.rotate) && e.rotate !== i.rotate && (i.rotate = e.rotate, s = !0), n.scalable && (R(e.scaleX) && e.scaleX !== i.scaleX && (i.scaleX = e.scaleX, s = !0), R(e.scaleY) && e.scaleY !== i.scaleY && (i.scaleY = e.scaleY, s = !0)), s && this.renderCanvas(!0, !0);
      var l = i.width / i.naturalWidth;
      R(e.x) && (a.left = e.x * l + r.left), R(e.y) && (a.top = e.y * l + r.top), R(e.width) && (a.width = e.width * l), R(e.height) && (a.height = e.height * l), this.setCropBoxData(a);
    }
    return this;
  },
  /**
   * Get the container size data.
   * @returns {Object} The result container data.
   */
  getContainerData: function() {
    return this.ready ? re({}, this.containerData) : {};
  },
  /**
   * Get the image position and size data.
   * @returns {Object} The result image data.
   */
  getImageData: function() {
    return this.sized ? re({}, this.imageData) : {};
  },
  /**
   * Get the canvas position and size data.
   * @returns {Object} The result canvas data.
   */
  getCanvasData: function() {
    var e = this.canvasData, n = {};
    return this.ready && le(["left", "top", "width", "height", "naturalWidth", "naturalHeight"], function(i) {
      n[i] = e[i];
    }), n;
  },
  /**
   * Set the canvas position and size with new data.
   * @param {Object} data - The new canvas data.
   * @returns {Cropper} this
   */
  setCanvasData: function(e) {
    var n = this.canvasData, i = n.aspectRatio;
    return this.ready && !this.disabled && Zt(e) && (R(e.left) && (n.left = e.left), R(e.top) && (n.top = e.top), R(e.width) ? (n.width = e.width, n.height = e.width / i) : R(e.height) && (n.height = e.height, n.width = e.height * i), this.renderCanvas(!0)), this;
  },
  /**
   * Get the crop box position and size data.
   * @returns {Object} The result crop box data.
   */
  getCropBoxData: function() {
    var e = this.cropBoxData, n;
    return this.ready && this.cropped && (n = {
      left: e.left,
      top: e.top,
      width: e.width,
      height: e.height
    }), n || {};
  },
  /**
   * Set the crop box position and size with new data.
   * @param {Object} data - The new crop box data.
   * @returns {Cropper} this
   */
  setCropBoxData: function(e) {
    var n = this.cropBoxData, i = this.options.aspectRatio, r, a;
    return this.ready && this.cropped && !this.disabled && Zt(e) && (R(e.left) && (n.left = e.left), R(e.top) && (n.top = e.top), R(e.width) && e.width !== n.width && (r = !0, n.width = e.width), R(e.height) && e.height !== n.height && (a = !0, n.height = e.height), i && (r ? n.height = n.width / i : a && (n.width = n.height * i)), this.renderCropBox()), this;
  },
  /**
   * Get a canvas drawn the cropped image.
   * @param {Object} [options={}] - The config options.
   * @returns {HTMLCanvasElement} - The result canvas.
   */
  getCroppedCanvas: function() {
    var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
    if (!this.ready || !window.HTMLCanvasElement)
      return null;
    var n = this.canvasData, i = t0(this.image, this.imageData, n, e);
    if (!this.cropped)
      return i;
    var r = this.getData(e.rounded), a = r.x, s = r.y, l = r.width, o = r.height, u = i.width / Math.floor(n.naturalWidth);
    u !== 1 && (a *= u, s *= u, l *= u, o *= u);
    var f = l / o, h = mt({
      aspectRatio: f,
      width: e.maxWidth || 1 / 0,
      height: e.maxHeight || 1 / 0
    }), c = mt({
      aspectRatio: f,
      width: e.minWidth || 0,
      height: e.minHeight || 0
    }, "cover"), d = mt({
      aspectRatio: f,
      width: e.width || (u !== 1 ? i.width : l),
      height: e.height || (u !== 1 ? i.height : o)
    }), _ = d.width, m = d.height;
    _ = Math.min(h.width, Math.max(c.width, _)), m = Math.min(h.height, Math.max(c.height, m));
    var b = document.createElement("canvas"), C = b.getContext("2d");
    b.width = Kt(_), b.height = Kt(m), C.fillStyle = e.fillColor || "transparent", C.fillRect(0, 0, _, m);
    var T = e.imageSmoothingEnabled, y = T === void 0 ? !0 : T, S = e.imageSmoothingQuality;
    C.imageSmoothingEnabled = y, S && (C.imageSmoothingQuality = S);
    var p = i.width, g = i.height, M = a, O = s, G, q, ee, z, E, D;
    M <= -l || M > p ? (M = 0, G = 0, ee = 0, E = 0) : M <= 0 ? (ee = -M, M = 0, G = Math.min(p, l + M), E = G) : M <= p && (ee = 0, G = Math.min(l, p - M), E = G), G <= 0 || O <= -o || O > g ? (O = 0, q = 0, z = 0, D = 0) : O <= 0 ? (z = -O, O = 0, q = Math.min(g, o + O), D = q) : O <= g && (z = 0, q = Math.min(o, g - O), D = q);
    var L = [M, O, G, q];
    if (E > 0 && D > 0) {
      var Y = _ / l;
      L.push(ee * Y, z * Y, E * Y, D * Y);
    }
    return C.drawImage.apply(C, [i].concat(zo(L.map(function(Z) {
      return Math.floor(Kt(Z));
    })))), b;
  },
  /**
   * Change the aspect ratio of the crop box.
   * @param {number} aspectRatio - The new aspect ratio.
   * @returns {Cropper} this
   */
  setAspectRatio: function(e) {
    var n = this.options;
    return !this.disabled && !hr(e) && (n.aspectRatio = Math.max(0, e) || NaN, this.ready && (this.initCropBox(), this.cropped && this.renderCropBox())), this;
  },
  /**
   * Change the drag mode.
   * @param {string} mode - The new drag mode.
   * @returns {Cropper} this
   */
  setDragMode: function(e) {
    var n = this.options, i = this.dragBox, r = this.face;
    if (this.ready && !this.disabled) {
      var a = e === ua, s = n.movable && e === Vo;
      e = a || s ? e : Wo, n.dragMode = e, Nn(i, Hn, e), Qt(i, Br, a), Qt(i, Hr, s), n.cropBoxMovable || (Nn(r, Hn, e), Qt(r, Br, a), Qt(r, Hr, s));
    }
    return this;
  }
}, _0 = $e.Cropper, tl = /* @__PURE__ */ function() {
  function t(e) {
    var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
    if (Cc(this, t), !e || !zc.test(e.tagName))
      throw new Error("The first argument is required and must be an <img> or <canvas> element.");
    this.element = e, this.options = re({}, as, Zt(n) && n), this.cropped = !1, this.disabled = !1, this.pointers = {}, this.ready = !1, this.reloading = !1, this.replaced = !1, this.sized = !1, this.sizing = !1, this.init();
  }
  return Mc(t, [{
    key: "init",
    value: function() {
      var n = this.element, i = n.tagName.toLowerCase(), r;
      if (!n[ne]) {
        if (n[ne] = this, i === "img") {
          if (this.isImg = !0, r = n.getAttribute("src") || "", this.originalUrl = r, !r)
            return;
          r = n.src;
        } else
          i === "canvas" && window.HTMLCanvasElement && (r = n.toDataURL());
        this.load(r);
      }
    }
  }, {
    key: "load",
    value: function(n) {
      var i = this;
      if (n) {
        this.url = n, this.imageData = {};
        var r = this.element, a = this.options;
        if (!a.rotatable && !a.scalable && (a.checkOrientation = !1), !a.checkOrientation || !window.ArrayBuffer) {
          this.clone();
          return;
        }
        if (Fc.test(n)) {
          Gc.test(n) ? this.read(r0(n)) : this.clone();
          return;
        }
        var s = new XMLHttpRequest(), l = this.clone.bind(this);
        this.reloading = !0, this.xhr = s, s.onabort = l, s.onerror = l, s.ontimeout = l, s.onprogress = function() {
          s.getResponseHeader("content-type") !== rs && s.abort();
        }, s.onload = function() {
          i.read(s.response);
        }, s.onloadend = function() {
          i.reloading = !1, i.xhr = null;
        }, a.checkCrossOrigin && os(n) && r.crossOrigin && (n = ls(n)), s.open("GET", n, !0), s.responseType = "arraybuffer", s.withCredentials = r.crossOrigin === "use-credentials", s.send();
      }
    }
  }, {
    key: "read",
    value: function(n) {
      var i = this.options, r = this.imageData, a = s0(n), s = 0, l = 1, o = 1;
      if (a > 1) {
        this.url = a0(n, rs);
        var u = o0(a);
        s = u.rotate, l = u.scaleX, o = u.scaleY;
      }
      i.rotatable && (r.rotate = s), i.scalable && (r.scaleX = l, r.scaleY = o), this.clone();
    }
  }, {
    key: "clone",
    value: function() {
      var n = this.element, i = this.url, r = n.crossOrigin, a = i;
      this.options.checkCrossOrigin && os(i) && (r || (r = "anonymous"), a = ls(i)), this.crossOrigin = r, this.crossOriginUrl = a;
      var s = document.createElement("img");
      r && (s.crossOrigin = r), s.src = a || i, s.alt = n.alt || "The image to crop", this.image = s, s.onload = this.start.bind(this), s.onerror = this.stop.bind(this), ce(s, Qa), n.parentNode.insertBefore(s, n.nextSibling);
    }
  }, {
    key: "start",
    value: function() {
      var n = this, i = this.image;
      i.onload = null, i.onerror = null, this.sizing = !0;
      var r = $e.navigator && /(?:iPad|iPhone|iPod).*?AppleWebKit/i.test($e.navigator.userAgent), a = function(u, f) {
        re(n.imageData, {
          naturalWidth: u,
          naturalHeight: f,
          aspectRatio: u / f
        }), n.initialImageData = re({}, n.imageData), n.sizing = !1, n.sized = !0, n.build();
      };
      if (i.naturalWidth && !r) {
        a(i.naturalWidth, i.naturalHeight);
        return;
      }
      var s = document.createElement("img"), l = document.body || document.documentElement;
      this.sizingImage = s, s.onload = function() {
        a(s.width, s.height), r || l.removeChild(s);
      }, s.src = i.src, r || (s.style.cssText = "left:0;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;opacity:0;position:absolute;top:0;z-index:-1;", l.appendChild(s));
    }
  }, {
    key: "stop",
    value: function() {
      var n = this.image;
      n.onload = null, n.onerror = null, n.parentNode.removeChild(n), this.image = null;
    }
  }, {
    key: "build",
    value: function() {
      if (!(!this.sized || this.ready)) {
        var n = this.element, i = this.options, r = this.image, a = n.parentNode, s = document.createElement("div");
        s.innerHTML = jc;
        var l = s.querySelector(".".concat(ne, "-container")), o = l.querySelector(".".concat(ne, "-canvas")), u = l.querySelector(".".concat(ne, "-drag-box")), f = l.querySelector(".".concat(ne, "-crop-box")), h = f.querySelector(".".concat(ne, "-face"));
        this.container = a, this.cropper = l, this.canvas = o, this.dragBox = u, this.cropBox = f, this.viewBox = l.querySelector(".".concat(ne, "-view-box")), this.face = h, o.appendChild(r), ce(n, ke), a.insertBefore(l, n.nextSibling), Je(r, Qa), this.initPreview(), this.bind(), i.initialAspectRatio = Math.max(0, i.initialAspectRatio) || NaN, i.aspectRatio = Math.max(0, i.aspectRatio) || NaN, i.viewMode = Math.max(0, Math.min(3, Math.round(i.viewMode))) || 0, ce(f, ke), i.guides || ce(f.getElementsByClassName("".concat(ne, "-dashed")), ke), i.center || ce(f.getElementsByClassName("".concat(ne, "-center")), ke), i.background && ce(l, "".concat(ne, "-bg")), i.highlight || ce(h, Ic), i.cropBoxMovable && (ce(h, Hr), Nn(h, Hn, la)), i.cropBoxResizable || (ce(f.getElementsByClassName("".concat(ne, "-line")), ke), ce(f.getElementsByClassName("".concat(ne, "-point")), ke)), this.render(), this.ready = !0, this.setDragMode(i.dragMode), i.autoCrop && this.crop(), this.setData(i.data), Ee(i.ready) && Re(n, ts, i.ready, {
          once: !0
        }), $t(n, ts);
      }
    }
  }, {
    key: "unbuild",
    value: function() {
      if (this.ready) {
        this.ready = !1, this.unbind(), this.resetPreview();
        var n = this.cropper.parentNode;
        n && n.removeChild(this.cropper), Je(this.element, ke);
      }
    }
  }, {
    key: "uncreate",
    value: function() {
      this.ready ? (this.unbuild(), this.ready = !1, this.cropped = !1) : this.sizing ? (this.sizingImage.onload = null, this.sizing = !1, this.sized = !1) : this.reloading ? (this.xhr.onabort = null, this.xhr.abort()) : this.image && this.stop();
    }
    /**
     * Get the no conflict cropper class.
     * @returns {Cropper} The cropper class.
     */
  }], [{
    key: "noConflict",
    value: function() {
      return window.Cropper = _0, t;
    }
    /**
     * Change the default options.
     * @param {Object} options - The new default options.
     */
  }, {
    key: "setDefaults",
    value: function(n) {
      re(as, Zt(n) && n);
    }
  }]), t;
}();
re(tl.prototype, l0, u0, f0, h0, c0, d0);
const {
  SvelteComponent: m0,
  attr: dr,
  binding_callbacks: g0,
  detach: p0,
  element: b0,
  flush: v0,
  init: w0,
  insert: y0,
  noop: us,
  safe_not_equal: E0,
  src_url_equal: fs
} = window.__gradio__svelte__internal, { onMount: c1, createEventDispatcher: k0 } = window.__gradio__svelte__internal;
function T0(t) {
  let e, n;
  return {
    c() {
      e = b0("img"), fs(e.src, n = /*image*/
      t[0]) || dr(e, "src", n), dr(e, "alt", "");
    },
    m(i, r) {
      y0(i, e, r), t[4](e);
    },
    p(i, [r]) {
      r & /*image*/
      1 && !fs(e.src, n = /*image*/
      i[0]) && dr(e, "src", n);
    },
    i: us,
    o: us,
    d(i) {
      i && p0(e), t[4](null);
    }
  };
}
function S0(t, e, n) {
  let { image: i } = e, r;
  const a = k0();
  let s;
  function l() {
    s.destroy();
  }
  function o() {
    s && l(), s = new tl(
      r,
      {
        autoCropArea: 1,
        cropend() {
          const f = s.getCroppedCanvas().toDataURL();
          a("crop", f);
        }
      }
    ), a("crop", i);
  }
  function u(f) {
    g0[f ? "unshift" : "push"](() => {
      r = f, n(1, r);
    });
  }
  return t.$$set = (f) => {
    "image" in f && n(0, i = f.image);
  }, [i, r, l, o, u];
}
class nl extends m0 {
  constructor(e) {
    super(), w0(this, e, S0, T0, E0, { image: 0, destroy: 2, create: 3 });
  }
  get image() {
    return this.$$.ctx[0];
  }
  set image(e) {
    this.$$set({ image: e }), v0();
  }
  get destroy() {
    return this.$$.ctx[2];
  }
  get create() {
    return this.$$.ctx[3];
  }
}
function Ht() {
}
const C0 = (t) => t;
function M0(t) {
  return t();
}
function A0(t) {
  t.forEach(M0);
}
function O0(t) {
  return typeof t == "function";
}
function D0(t, e) {
  return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function";
}
function B0(t, ...e) {
  if (t == null) {
    for (const i of e)
      i(void 0);
    return Ht;
  }
  const n = t.subscribe(...e);
  return n.unsubscribe ? () => n.unsubscribe() : n;
}
const il = typeof window < "u";
let hs = il ? () => window.performance.now() : () => Date.now(), rl = il ? (t) => requestAnimationFrame(t) : Ht;
const en = /* @__PURE__ */ new Set();
function al(t) {
  en.forEach((e) => {
    e.c(t) || (en.delete(e), e.f());
  }), en.size !== 0 && rl(al);
}
function H0(t) {
  let e;
  return en.size === 0 && rl(al), {
    promise: new Promise((n) => {
      en.add(e = { c: t, f: n });
    }),
    abort() {
      en.delete(e);
    }
  };
}
function cs(t, { delay: e = 0, duration: n = 400, easing: i = C0 } = {}) {
  const r = +getComputedStyle(t).opacity;
  return {
    delay: e,
    duration: n,
    easing: i,
    css: (a) => `opacity: ${a * r}`
  };
}
const Vt = [];
function N0(t, e) {
  return {
    subscribe: Pn(t, e).subscribe
  };
}
function Pn(t, e = Ht) {
  let n;
  const i = /* @__PURE__ */ new Set();
  function r(l) {
    if (D0(t, l) && (t = l, n)) {
      const o = !Vt.length;
      for (const u of i)
        u[1](), Vt.push(u, t);
      if (o) {
        for (let u = 0; u < Vt.length; u += 2)
          Vt[u][0](Vt[u + 1]);
        Vt.length = 0;
      }
    }
  }
  function a(l) {
    r(l(t));
  }
  function s(l, o = Ht) {
    const u = [l, o];
    return i.add(u), i.size === 1 && (n = e(r, a) || Ht), l(t), () => {
      i.delete(u), i.size === 0 && n && (n(), n = null);
    };
  }
  return { set: r, update: a, subscribe: s };
}
function dn(t, e, n) {
  const i = !Array.isArray(t), r = i ? [t] : t;
  if (!r.every(Boolean))
    throw new Error("derived() expects stores as input, got a falsy value");
  const a = e.length < 2;
  return N0(n, (s, l) => {
    let o = !1;
    const u = [];
    let f = 0, h = Ht;
    const c = () => {
      if (f)
        return;
      h();
      const _ = e(i ? u[0] : u, s, l);
      a ? s(_) : h = O0(_) ? _ : Ht;
    }, d = r.map(
      (_, m) => B0(
        _,
        (b) => {
          u[m] = b, f &= ~(1 << m), o && c();
        },
        () => {
          f |= 1 << m;
        }
      )
    );
    return o = !0, c(), function() {
      A0(d), h(), o = !1;
    };
  });
}
function ds(t) {
  return Object.prototype.toString.call(t) === "[object Date]";
}
function Fr(t, e, n, i) {
  if (typeof n == "number" || ds(n)) {
    const r = i - n, a = (n - e) / (t.dt || 1 / 60), s = t.opts.stiffness * r, l = t.opts.damping * a, o = (s - l) * t.inv_mass, u = (a + o) * t.dt;
    return Math.abs(u) < t.opts.precision && Math.abs(r) < t.opts.precision ? i : (t.settled = !1, ds(n) ? new Date(n.getTime() + u) : n + u);
  } else {
    if (Array.isArray(n))
      return n.map(
        (r, a) => Fr(t, e[a], n[a], i[a])
      );
    if (typeof n == "object") {
      const r = {};
      for (const a in n)
        r[a] = Fr(t, e[a], n[a], i[a]);
      return r;
    } else
      throw new Error(`Cannot spring ${typeof n} values`);
  }
}
function _s(t, e = {}) {
  const n = Pn(t), { stiffness: i = 0.15, damping: r = 0.8, precision: a = 0.01 } = e;
  let s, l, o, u = t, f = t, h = 1, c = 0, d = !1;
  function _(b, C = {}) {
    f = b;
    const T = o = {};
    return t == null || C.hard || m.stiffness >= 1 && m.damping >= 1 ? (d = !0, s = hs(), u = b, n.set(t = f), Promise.resolve()) : (C.soft && (c = 1 / ((C.soft === !0 ? 0.5 : +C.soft) * 60), h = 0), l || (s = hs(), d = !1, l = H0((y) => {
      if (d)
        return d = !1, l = null, !1;
      h = Math.min(h + c, 1);
      const S = {
        inv_mass: h,
        opts: m,
        settled: !0,
        dt: (y - s) * 60 / 1e3
      }, p = Fr(S, u, t, f);
      return s = y, u = t, n.set(t = p), S.settled && (l = null), !S.settled;
    })), new Promise((y) => {
      l.promise.then(() => {
        T === o && y();
      });
    }));
  }
  const m = {
    set: _,
    update: (b, C) => _(b(f, t), C),
    subscribe: n.subscribe,
    stiffness: i,
    damping: r,
    precision: a
  };
  return m;
}
class ms {
  /**
   *
   * @param {number} x
   * @param {number} y
   */
  constructor(e, n) {
    this.x = e, this.y = n;
  }
}
class gs extends ms {
  /**
   * Update the x and y values
   *
   * @param {Point} point
   */
  update(e) {
    this.x = e.x, this.y = e.y;
  }
  /**
   * Move the point to another position using an angle and distance
   *
   * @param {number} angle The angle in radians
   * @param {number} distance How much the point should be moved
   */
  moveByAngle(e, n) {
    const i = e + Math.PI / 2;
    this.x = this.x + Math.sin(i) * n, this.y = this.y - Math.cos(i) * n;
  }
  /**
   * Check if this point is the same as another point
   *
   * @param {Point} point
   * @returns {boolean}
   */
  equalsTo(e) {
    return this.x === e.x && this.y === e.y;
  }
  /**
   * Get the difference for x and y axis to another point
   *
   * @param {Point} point
   * @returns {Point}
   */
  getDifferenceTo(e) {
    return new ms(this.x - e.x, this.y - e.y);
  }
  /**
   * Calculate distance to another point
   *
   * @param {Point} point
   * @returns {Point}
   */
  getDistanceTo(e) {
    const n = this.getDifferenceTo(e);
    return Math.sqrt(Math.pow(n.x, 2) + Math.pow(n.y, 2));
  }
  /**
   * Calculate the angle to another point
   *
   * @param {Point} point
   * @returns {Point}
   */
  getAngleTo(e) {
    const n = this.getDifferenceTo(e);
    return Math.atan2(n.y, n.x);
  }
  /**
   * Return a simple object with x and y properties
   *
   * @returns {object}
   */
  toObject() {
    return {
      x: this.x,
      y: this.y
    };
  }
}
const I0 = 30;
class R0 {
  /**
   * constructor
   *
   * @param {object} settings
   * @param {number} settings.radius The radius for the lazy area
   * @param {boolean} settings.enabled
   */
  constructor({ radius: e = I0, enabled: n = !0, initialPoint: i = { x: 0, y: 0 } } = {}) {
    this.radius = e, this._isEnabled = n, this.pointer = new gs(i.x, i.y), this.brush = new gs(i.x, i.y), this.angle = 0, this.distance = 0, this._hasMoved = !1;
  }
  /**
   * Enable lazy brush calculations.
   *
   */
  enable() {
    this._isEnabled = !0;
  }
  /**
   * Disable lazy brush calculations.
   *
   */
  disable() {
    this._isEnabled = !1;
  }
  /**
   * @returns {boolean}
   */
  isEnabled() {
    return this._isEnabled;
  }
  /**
   * Update the radius
   *
   * @param {number} radius
   */
  setRadius(e) {
    this.radius = e;
  }
  /**
   * Return the current radius
   *
   * @returns {number}
   */
  getRadius() {
    return this.radius;
  }
  /**
   * Return the brush coordinates as a simple object
   *
   * @returns {object}
   */
  getBrushCoordinates() {
    return this.brush.toObject();
  }
  /**
   * Return the pointer coordinates as a simple object
   *
   * @returns {object}
   */
  getPointerCoordinates() {
    return this.pointer.toObject();
  }
  /**
   * Return the brush as a LazyPoint
   *
   * @returns {LazyPoint}
   */
  getBrush() {
    return this.brush;
  }
  /**
   * Return the pointer as a LazyPoint
   *
   * @returns {LazyPoint}
   */
  getPointer() {
    return this.pointer;
  }
  /**
   * Return the angle between pointer and brush
   *
   * @returns {number} Angle in radians
   */
  getAngle() {
    return this.angle;
  }
  /**
   * Return the distance between pointer and brush
   *
   * @returns {number} Distance in pixels
   */
  getDistance() {
    return this.distance;
  }
  /**
   * Return if the previous update has moved the brush.
   *
   * @returns {boolean} Whether the brush moved previously.
   */
  brushHasMoved() {
    return this._hasMoved;
  }
  /**
   * Updates the pointer point and calculates the new brush point.
   *
   * @param {Point} newPointerPoint
   * @param {Object} options
   * @param {Boolean} options.both Force update pointer and brush
   * @returns {Boolean} Whether any of the two points changed
   */
  update(e, { both: n = !1 } = {}) {
    return this._hasMoved = !1, this.pointer.equalsTo(e) && !n ? !1 : (this.pointer.update(e), n ? (this._hasMoved = !0, this.brush.update(e), !0) : (this._isEnabled ? (this.distance = this.pointer.getDistanceTo(this.brush), this.angle = this.pointer.getAngleTo(this.brush), this.distance > this.radius && (this.brush.moveByAngle(this.angle, this.distance - this.radius), this._hasMoved = !0)) : (this.distance = 0, this.angle = 0, this.brush.update(e), this._hasMoved = !0), !0));
  }
}
var sl = function() {
  if (typeof Map < "u")
    return Map;
  function t(e, n) {
    var i = -1;
    return e.some(function(r, a) {
      return r[0] === n ? (i = a, !0) : !1;
    }), i;
  }
  return (
    /** @class */
    function() {
      function e() {
        this.__entries__ = [];
      }
      return Object.defineProperty(e.prototype, "size", {
        /**
         * @returns {boolean}
         */
        get: function() {
          return this.__entries__.length;
        },
        enumerable: !0,
        configurable: !0
      }), e.prototype.get = function(n) {
        var i = t(this.__entries__, n), r = this.__entries__[i];
        return r && r[1];
      }, e.prototype.set = function(n, i) {
        var r = t(this.__entries__, n);
        ~r ? this.__entries__[r][1] = i : this.__entries__.push([n, i]);
      }, e.prototype.delete = function(n) {
        var i = this.__entries__, r = t(i, n);
        ~r && i.splice(r, 1);
      }, e.prototype.has = function(n) {
        return !!~t(this.__entries__, n);
      }, e.prototype.clear = function() {
        this.__entries__.splice(0);
      }, e.prototype.forEach = function(n, i) {
        i === void 0 && (i = null);
        for (var r = 0, a = this.__entries__; r < a.length; r++) {
          var s = a[r];
          n.call(i, s[1], s[0]);
        }
      }, e;
    }()
  );
}(), Gr = typeof window < "u" && typeof document < "u" && window.document === document, yi = function() {
  return typeof global < "u" && global.Math === Math ? global : typeof self < "u" && self.Math === Math ? self : typeof window < "u" && window.Math === Math ? window : Function("return this")();
}(), L0 = function() {
  return typeof requestAnimationFrame == "function" ? requestAnimationFrame.bind(yi) : function(t) {
    return setTimeout(function() {
      return t(Date.now());
    }, 1e3 / 60);
  };
}(), P0 = 2;
function U0(t, e) {
  var n = !1, i = !1, r = 0;
  function a() {
    n && (n = !1, t()), i && l();
  }
  function s() {
    L0(a);
  }
  function l() {
    var o = Date.now();
    if (n) {
      if (o - r < P0)
        return;
      i = !0;
    } else
      n = !0, i = !1, setTimeout(s, e);
    r = o;
  }
  return l;
}
var F0 = 20, G0 = ["top", "right", "bottom", "left", "width", "height", "size", "weight"], z0 = typeof MutationObserver < "u", j0 = (
  /** @class */
  function() {
    function t() {
      this.connected_ = !1, this.mutationEventsAdded_ = !1, this.mutationsObserver_ = null, this.observers_ = [], this.onTransitionEnd_ = this.onTransitionEnd_.bind(this), this.refresh = U0(this.refresh.bind(this), F0);
    }
    return t.prototype.addObserver = function(e) {
      ~this.observers_.indexOf(e) || this.observers_.push(e), this.connected_ || this.connect_();
    }, t.prototype.removeObserver = function(e) {
      var n = this.observers_, i = n.indexOf(e);
      ~i && n.splice(i, 1), !n.length && this.connected_ && this.disconnect_();
    }, t.prototype.refresh = function() {
      var e = this.updateObservers_();
      e && this.refresh();
    }, t.prototype.updateObservers_ = function() {
      var e = this.observers_.filter(function(n) {
        return n.gatherActive(), n.hasActive();
      });
      return e.forEach(function(n) {
        return n.broadcastActive();
      }), e.length > 0;
    }, t.prototype.connect_ = function() {
      !Gr || this.connected_ || (document.addEventListener("transitionend", this.onTransitionEnd_), window.addEventListener("resize", this.refresh), z0 ? (this.mutationsObserver_ = new MutationObserver(this.refresh), this.mutationsObserver_.observe(document, {
        attributes: !0,
        childList: !0,
        characterData: !0,
        subtree: !0
      })) : (document.addEventListener("DOMSubtreeModified", this.refresh), this.mutationEventsAdded_ = !0), this.connected_ = !0);
    }, t.prototype.disconnect_ = function() {
      !Gr || !this.connected_ || (document.removeEventListener("transitionend", this.onTransitionEnd_), window.removeEventListener("resize", this.refresh), this.mutationsObserver_ && this.mutationsObserver_.disconnect(), this.mutationEventsAdded_ && document.removeEventListener("DOMSubtreeModified", this.refresh), this.mutationsObserver_ = null, this.mutationEventsAdded_ = !1, this.connected_ = !1);
    }, t.prototype.onTransitionEnd_ = function(e) {
      var n = e.propertyName, i = n === void 0 ? "" : n, r = G0.some(function(a) {
        return !!~i.indexOf(a);
      });
      r && this.refresh();
    }, t.getInstance = function() {
      return this.instance_ || (this.instance_ = new t()), this.instance_;
    }, t.instance_ = null, t;
  }()
), ol = function(t, e) {
  for (var n = 0, i = Object.keys(e); n < i.length; n++) {
    var r = i[n];
    Object.defineProperty(t, r, {
      value: e[r],
      enumerable: !1,
      writable: !1,
      configurable: !0
    });
  }
  return t;
}, rn = function(t) {
  var e = t && t.ownerDocument && t.ownerDocument.defaultView;
  return e || yi;
}, ll = Di(0, 0, 0, 0);
function Ei(t) {
  return parseFloat(t) || 0;
}
function ps(t) {
  for (var e = [], n = 1; n < arguments.length; n++)
    e[n - 1] = arguments[n];
  return e.reduce(function(i, r) {
    var a = t["border-" + r + "-width"];
    return i + Ei(a);
  }, 0);
}
function q0(t) {
  for (var e = ["top", "right", "bottom", "left"], n = {}, i = 0, r = e; i < r.length; i++) {
    var a = r[i], s = t["padding-" + a];
    n[a] = Ei(s);
  }
  return n;
}
function x0(t) {
  var e = t.getBBox();
  return Di(0, 0, e.width, e.height);
}
function X0(t) {
  var e = t.clientWidth, n = t.clientHeight;
  if (!e && !n)
    return ll;
  var i = rn(t).getComputedStyle(t), r = q0(i), a = r.left + r.right, s = r.top + r.bottom, l = Ei(i.width), o = Ei(i.height);
  if (i.boxSizing === "border-box" && (Math.round(l + a) !== e && (l -= ps(i, "left", "right") + a), Math.round(o + s) !== n && (o -= ps(i, "top", "bottom") + s)), !W0(t)) {
    var u = Math.round(l + a) - e, f = Math.round(o + s) - n;
    Math.abs(u) !== 1 && (l -= u), Math.abs(f) !== 1 && (o -= f);
  }
  return Di(r.left, r.top, l, o);
}
var V0 = function() {
  return typeof SVGGraphicsElement < "u" ? function(t) {
    return t instanceof rn(t).SVGGraphicsElement;
  } : function(t) {
    return t instanceof rn(t).SVGElement && typeof t.getBBox == "function";
  };
}();
function W0(t) {
  return t === rn(t).document.documentElement;
}
function Y0(t) {
  return Gr ? V0(t) ? x0(t) : X0(t) : ll;
}
function Z0(t) {
  var e = t.x, n = t.y, i = t.width, r = t.height, a = typeof DOMRectReadOnly < "u" ? DOMRectReadOnly : Object, s = Object.create(a.prototype);
  return ol(s, {
    x: e,
    y: n,
    width: i,
    height: r,
    top: n,
    right: e + i,
    bottom: r + n,
    left: e
  }), s;
}
function Di(t, e, n, i) {
  return { x: t, y: e, width: n, height: i };
}
var Q0 = (
  /** @class */
  function() {
    function t(e) {
      this.broadcastWidth = 0, this.broadcastHeight = 0, this.contentRect_ = Di(0, 0, 0, 0), this.target = e;
    }
    return t.prototype.isActive = function() {
      var e = Y0(this.target);
      return this.contentRect_ = e, e.width !== this.broadcastWidth || e.height !== this.broadcastHeight;
    }, t.prototype.broadcastRect = function() {
      var e = this.contentRect_;
      return this.broadcastWidth = e.width, this.broadcastHeight = e.height, e;
    }, t;
  }()
), J0 = (
  /** @class */
  function() {
    function t(e, n) {
      var i = Z0(n);
      ol(this, { target: e, contentRect: i });
    }
    return t;
  }()
), K0 = (
  /** @class */
  function() {
    function t(e, n, i) {
      if (this.activeObservations_ = [], this.observations_ = new sl(), typeof e != "function")
        throw new TypeError("The callback provided as parameter 1 is not a function.");
      this.callback_ = e, this.controller_ = n, this.callbackCtx_ = i;
    }
    return t.prototype.observe = function(e) {
      if (!arguments.length)
        throw new TypeError("1 argument required, but only 0 present.");
      if (!(typeof Element > "u" || !(Element instanceof Object))) {
        if (!(e instanceof rn(e).Element))
          throw new TypeError('parameter 1 is not of type "Element".');
        var n = this.observations_;
        n.has(e) || (n.set(e, new Q0(e)), this.controller_.addObserver(this), this.controller_.refresh());
      }
    }, t.prototype.unobserve = function(e) {
      if (!arguments.length)
        throw new TypeError("1 argument required, but only 0 present.");
      if (!(typeof Element > "u" || !(Element instanceof Object))) {
        if (!(e instanceof rn(e).Element))
          throw new TypeError('parameter 1 is not of type "Element".');
        var n = this.observations_;
        n.has(e) && (n.delete(e), n.size || this.controller_.removeObserver(this));
      }
    }, t.prototype.disconnect = function() {
      this.clearActive(), this.observations_.clear(), this.controller_.removeObserver(this);
    }, t.prototype.gatherActive = function() {
      var e = this;
      this.clearActive(), this.observations_.forEach(function(n) {
        n.isActive() && e.activeObservations_.push(n);
      });
    }, t.prototype.broadcastActive = function() {
      if (this.hasActive()) {
        var e = this.callbackCtx_, n = this.activeObservations_.map(function(i) {
          return new J0(i.target, i.broadcastRect());
        });
        this.callback_.call(e, n, e), this.clearActive();
      }
    }, t.prototype.clearActive = function() {
      this.activeObservations_.splice(0);
    }, t.prototype.hasActive = function() {
      return this.activeObservations_.length > 0;
    }, t;
  }()
), ul = typeof WeakMap < "u" ? /* @__PURE__ */ new WeakMap() : new sl(), fl = (
  /** @class */
  function() {
    function t(e) {
      if (!(this instanceof t))
        throw new TypeError("Cannot call a class as a function.");
      if (!arguments.length)
        throw new TypeError("1 argument required, but only 0 present.");
      var n = j0.getInstance(), i = new K0(e, n, this);
      ul.set(this, i);
    }
    return t;
  }()
);
[
  "observe",
  "unobserve",
  "disconnect"
].forEach(function(t) {
  fl.prototype[t] = function() {
    var e;
    return (e = ul.get(this))[t].apply(e, arguments);
  };
});
var $0 = function() {
  return typeof yi.ResizeObserver < "u" ? yi.ResizeObserver : fl;
}();
const {
  SvelteComponent: ed,
  add_iframe_resize_listener: td,
  add_render_callback: hl,
  append: nd,
  attr: ki,
  binding_callbacks: bs,
  bubble: id,
  check_outros: rd,
  create_bidirectional_transition: vs,
  destroy_each: ad,
  detach: ha,
  element: ca,
  ensure_array_like: ws,
  group_outros: sd,
  init: od,
  insert: da,
  listen: Ye,
  run_all: ld,
  safe_not_equal: ud,
  set_style: ys,
  space: fd,
  stop_propagation: hd,
  toggle_class: si,
  transition_in: _r,
  transition_out: Es
} = window.__gradio__svelte__internal, { onMount: cd, onDestroy: dd, createEventDispatcher: _d, tick: mr } = window.__gradio__svelte__internal;
function ks(t, e, n) {
  const i = t.slice();
  return i[61] = e[n].name, i[62] = e[n].zIndex, i[63] = e[n].opacity, i[64] = e, i[65] = n, i;
}
function Ts(t) {
  let e, n, i;
  return {
    c() {
      e = ca("div"), e.textContent = "Start drawing", ki(e, "class", "start-prompt svelte-14l85k0");
    },
    m(r, a) {
      da(r, e, a), i = !0;
    },
    i(r) {
      i || (r && hl(() => {
        i && (n || (n = vs(e, cs, { duration: 50 }, !0)), n.run(1));
      }), i = !0);
    },
    o(r) {
      r && (n || (n = vs(e, cs, { duration: 50 }, !1)), n.run(0)), i = !1;
    },
    d(r) {
      r && ha(e), r && n && n.end();
    }
  };
}
function Ss(t) {
  let e, n = (
    /*name*/
    t[61]
  ), i, r;
  const a = () => (
    /*canvas_1_binding*/
    t[31](e, n)
  ), s = () => (
    /*canvas_1_binding*/
    t[31](null, n)
  );
  return {
    c() {
      e = ca("canvas"), ki(
        e,
        "key",
        /*name*/
        t[61]
      ), ys(
        e,
        "z-index",
        /*zIndex*/
        t[62]
      ), ki(e, "class", "svelte-14l85k0"), si(
        e,
        "lr",
        /*add_lr_border*/
        t[5]
      ), si(e, "tb", !/*add_lr_border*/
      t[5]), ys(
        e,
        "opacity",
        /*opacity*/
        t[63]
      );
    },
    m(l, o) {
      da(l, e, o), a(), i || (r = [
        Ye(
          e,
          "mousedown",
          /*name*/
          t[61] === "interface" ? (
            /*handle_draw_start*/
            t[7]
          ) : void 0
        ),
        Ye(
          e,
          "mousemove",
          /*name*/
          t[61] === "interface" ? (
            /*handle_draw_move*/
            t[8]
          ) : void 0
        ),
        Ye(
          e,
          "mouseup",
          /*name*/
          t[61] === "interface" ? (
            /*handle_draw_end*/
            t[9]
          ) : void 0
        ),
        Ye(
          e,
          "mouseout",
          /*name*/
          t[61] === "interface" ? (
            /*handle_draw_end*/
            t[9]
          ) : void 0
        ),
        Ye(
          e,
          "blur",
          /*name*/
          t[61] === "interface" ? (
            /*handle_draw_end*/
            t[9]
          ) : void 0
        ),
        Ye(
          e,
          "touchstart",
          /*name*/
          t[61] === "interface" ? (
            /*handle_draw_start*/
            t[7]
          ) : void 0
        ),
        Ye(
          e,
          "touchmove",
          /*name*/
          t[61] === "interface" ? (
            /*handle_draw_move*/
            t[8]
          ) : void 0
        ),
        Ye(
          e,
          "touchend",
          /*name*/
          t[61] === "interface" ? (
            /*handle_draw_end*/
            t[9]
          ) : void 0
        ),
        Ye(
          e,
          "touchcancel",
          /*name*/
          t[61] === "interface" ? (
            /*handle_draw_end*/
            t[9]
          ) : void 0
        ),
        Ye(e, "click", hd(
          /*click_handler*/
          t[30]
        ))
      ], i = !0);
    },
    p(l, o) {
      t = l, n !== /*name*/
      t[61] && (s(), n = /*name*/
      t[61], a()), o[0] & /*add_lr_border*/
      32 && si(
        e,
        "lr",
        /*add_lr_border*/
        t[5]
      ), o[0] & /*add_lr_border*/
      32 && si(e, "tb", !/*add_lr_border*/
      t[5]);
    },
    d(l) {
      l && ha(e), s(), i = !1, ld(r);
    }
  };
}
function md(t) {
  let e, n, i, r = (
    /*line_count*/
    t[4] === 0 && Ts()
  ), a = ws(
    /*canvas_types*/
    t[6]
  ), s = [];
  for (let l = 0; l < a.length; l += 1)
    s[l] = Ss(ks(t, a, l));
  return {
    c() {
      e = ca("div"), r && r.c(), n = fd();
      for (let l = 0; l < s.length; l += 1)
        s[l].c();
      ki(e, "class", "wrap svelte-14l85k0"), hl(() => (
        /*div_elementresize_handler*/
        t[33].call(e)
      ));
    },
    m(l, o) {
      da(l, e, o), r && r.m(e, null), nd(e, n);
      for (let u = 0; u < s.length; u += 1)
        s[u] && s[u].m(e, null);
      t[32](e), i = td(
        e,
        /*div_elementresize_handler*/
        t[33].bind(e)
      );
    },
    p(l, o) {
      if (/*line_count*/
      l[4] === 0 ? r ? o[0] & /*line_count*/
      16 && _r(r, 1) : (r = Ts(), r.c(), _r(r, 1), r.m(e, n)) : r && (sd(), Es(r, 1, 1, () => {
        r = null;
      }), rd()), o[0] & /*canvas_types, canvas, add_lr_border, handle_draw_start, handle_draw_move, handle_draw_end*/
      993) {
        a = ws(
          /*canvas_types*/
          l[6]
        );
        let u;
        for (u = 0; u < a.length; u += 1) {
          const f = ks(l, a, u);
          s[u] ? s[u].p(f, o) : (s[u] = Ss(f), s[u].c(), s[u].m(e, null));
        }
        for (; u < s.length; u += 1)
          s[u].d(1);
        s.length = a.length;
      }
    },
    i(l) {
      _r(r);
    },
    o(l) {
      Es(r);
    },
    d(l) {
      l && ha(e), r && r.d(), ad(s, l), t[32](null), i();
    }
  };
}
let gd = "#aaa";
function pd(t, e) {
  return {
    x: t.x + (e.x - t.x) / 2,
    y: t.y + (e.y - t.y) / 2
  };
}
function bd(t, e, n) {
  let i;
  const r = _d();
  let { value: a } = e, { value_img: s } = e, { mode: l = "sketch" } = e, { brush_color: o = "#0b0f19" } = e, { brush_radius: u } = e, { mask_opacity: f = 0.7 } = e, { source: h } = e, { width: c = 400 } = e, { height: d = 200 } = e, { container_height: _ = 200 } = e, { shape: m } = e, b, C = c, T = d, y;
  const S = [
    { name: "interface", zIndex: 15 },
    {
      name: "mask",
      zIndex: 13,
      opacity: f
    },
    { name: "drawing", zIndex: 11 },
    { name: "temp", zIndex: 12 }
  ];
  let p = {}, g = {}, M = [], O = [], G = !0, q = !0, ee = !1, z = !1, E = null, D = null, L = null, Y = 0;
  function Z() {
    if (!m) {
      g.temp.drawImage(s, 0, 0, c, d);
      return;
    }
    let v = s.naturalWidth, B = s.naturalHeight;
    const x = m[0] / m[1], he = v / B;
    let te = 0, we = 0;
    x < he ? (v = m[1] * he, B = m[1], te = (m[0] - v) / 2) : x > he ? (v = m[0], B = m[0] / he, we = (m[1] - B) / 2) : (te = 0, we = 0, v = m[0], B = m[1]), g.temp.drawImage(s, te, we, v, B);
  }
  cd(async () => {
    Object.keys(p).forEach((v) => {
      n(27, g[v] = p[v].getContext("2d"), g);
    }), await mr(), s && (s.addEventListener("load", (v) => {
      h === "webcam" ? (g.temp.save(), g.temp.translate(c, 0), g.temp.scale(-1, 1), g.temp.drawImage(s, 0, 0), g.temp.restore()) : Z(), g.drawing.drawImage(p.temp, 0, 0, c, d), et();
    }), setTimeout(
      () => {
        h === "webcam" ? (g.temp.save(), g.temp.translate(c, 0), g.temp.scale(-1, 1), g.temp.drawImage(s, 0, 0), g.temp.restore()) : Z(), g.drawing.drawImage(p.temp, 0, 0, c, d), He({ lines: O.slice() }), et();
      },
      100
    )), n(29, E = new R0({
      radius: u * 0.05,
      enabled: !0,
      initialPoint: { x: c / 2, y: d / 2 }
    })), L = new $0((v, B, ...x) => {
      Xn();
    }), L.observe(D), wn(), n(25, b = !0), requestAnimationFrame(() => {
      V(), requestAnimationFrame(() => {
        yt();
      });
    });
  });
  function V() {
    const v = c / 2, B = d / 2;
    E.update({ x: v, y: B }, { both: !0 }), E.update({ x: v, y: B }, { both: !1 }), G = !0, q = !0;
  }
  dd(() => {
    n(25, b = !1), L.unobserve(D);
  });
  function fe(v) {
    Jn(), s && (h === "webcam" ? (g.temp.save(), g.temp.translate(c, 0), g.temp.scale(-1, 1), g.temp.drawImage(s, 0, 0), g.temp.restore()) : Z(), (!O || !O.length) && g.drawing.drawImage(p.temp, 0, 0, c, d)), He({ lines: v }), n(4, Y = v.length), n(28, O = v), g.drawing.drawImage(p.temp, 0, 0, c, d), O.length == 0 && r("clear");
  }
  function Te() {
    fe([]), et();
  }
  function be() {
    const v = O.slice(0, -1);
    fe(v), et();
  }
  let He = ({ lines: v }) => {
    v.forEach((B) => {
      const { points: x, brush_color: he, brush_radius: te } = B;
      Yn({
        points: x,
        brush_color: he,
        brush_radius: te,
        mask: l === "mask"
      });
    }), Qn(), l === "mask" && Zn();
  }, A = (v) => {
    v.preventDefault(), z = !0;
    const { x: B, y: x } = Vn(v);
    v.touches && v.touches.length > 0 && E.update({ x: B, y: x }, { both: !0 }), Wn(B, x), n(4, Y += 1);
  }, lt = (v) => {
    v.preventDefault();
    const { x: B, y: x } = Vn(v);
    Wn(B, x);
  }, wt = (v) => {
    v.preventDefault(), lt(v), ee = !1, z = !1, Qn(), l === "mask" && Zn();
  }, Ft = 0, k = 0, qn = 0, xn = !1, Xn = async () => {
    if (m && D) {
      const x = D == null ? void 0 : D.getBoundingClientRect(), he = m[0] / m[1], te = x.width / x.height;
      n(5, xn = he < te);
    }
    if (c === Ft && d === k && qn === _)
      return;
    const v = { width: c, height: d }, B = {
      height: _,
      width: _ * (v.width / v.height)
    };
    await Promise.all([
      Gt(p.interface, v, B),
      Gt(p.drawing, v, B),
      Gt(p.temp, v, B),
      Gt(p.mask, v, B, !1)
    ]), u || n(10, u = 20 * (v.width / B.width)), wn({ once: !0 }), setTimeout(
      () => {
        k = d, Ft = c, qn = _;
      },
      10
    ), await mr(), yt();
  }, Gt = async (v, B, x, he = !0) => {
    if (!b)
      return;
    await mr();
    const te = window.devicePixelRatio || 1;
    v.width = B.width * (he ? te : 1), v.height = B.height * (he ? te : 1);
    const we = v.getContext("2d");
    he && we.scale(te, te), v.style.width = `${x.width}px`, v.style.height = `${x.height}px`;
  }, Vn = (v) => {
    const B = p.interface.getBoundingClientRect();
    let x = v.clientX, he = v.clientY;
    return v.changedTouches && v.changedTouches.length > 0 && (x = v.changedTouches[0].clientX, he = v.changedTouches[0].clientY), {
      x: (x - B.left) / B.width * c,
      y: (he - B.top) / B.height * d
    };
  }, Wn = (v, B) => {
    E.update({ x: v, y: B });
    const x = !E.isEnabled();
    (z && !ee || x && z) && (ee = !0, M.push(E.brush.toObject())), ee && (M.push(E.brush.toObject()), Yn({
      points: M,
      brush_color: o,
      brush_radius: u,
      mask: l === "mask"
    })), G = !0;
  }, Yn = ({ points: v, brush_color: B, brush_radius: x, mask: he }) => {
    if (!v || v.length < 2)
      return;
    let te = he ? g.mask : g.temp;
    te.lineJoin = "round", te.lineCap = "round", te.strokeStyle = B, te.lineWidth = x;
    let we = v[0], zt = v[1];
    te.moveTo(zt.x, zt.y), te.beginPath();
    for (var w = 1, Ve = v.length; w < Ve; w++) {
      var $n = pd(we, zt);
      te.quadraticCurveTo(we.x, we.y, $n.x, $n.y), we = v[w], zt = v[w + 1];
    }
    te.lineTo(we.x, we.y), te.stroke();
  }, Zn = () => {
    M.length < 1 || (M.length = 0, et());
  }, Qn = () => {
    M.length < 1 || (O.push({
      points: M.slice(),
      brush_color: o,
      brush_radius: u
    }), l !== "mask" && (M.length = 0), g.drawing.drawImage(p.temp, 0, 0, c, d), et());
  }, et = () => {
    const v = Kn();
    r("change", v);
  };
  function yt() {
    return n(28, O = []), Jn(), n(4, Y = 0), !0;
  }
  function Jn() {
    q = !0, g.temp.clearRect(0, 0, c, d), n(27, g.temp.fillStyle = l === "mask" ? "transparent" : "#FFFFFF", g), g.temp.fillRect(0, 0, c, d), l === "mask" && g.mask.clearRect(0, 0, p.mask.width, p.mask.height);
  }
  let wn = ({ once: v = !1 } = {}) => {
    if (G || q) {
      const B = E.getPointerCoordinates(), x = E.getBrushCoordinates();
      Ui(g.interface, B, x), G = !1, q = !1;
    }
    v || window.requestAnimationFrame(() => {
      wn();
    });
  }, Ui = (v, B, x) => {
    v.clearRect(0, 0, c, d), v.beginPath(), v.fillStyle = o, v.arc(x.x, x.y, u / 2, 0, Math.PI * 2, !0), v.fill(), v.beginPath(), v.fillStyle = gd, v.arc(x.x, x.y, i, 0, Math.PI * 2, !0), v.fill();
  };
  function Kn() {
    return l === "mask" ? p.mask.toDataURL("image/png") : p.drawing.toDataURL("image/jpg");
  }
  function Fi(v) {
    id.call(this, t, v);
  }
  function Gi(v, B) {
    bs[v ? "unshift" : "push"](() => {
      p[B] = v, n(0, p);
    });
  }
  function zi(v) {
    bs[v ? "unshift" : "push"](() => {
      D = v, n(3, D);
    });
  }
  function ji() {
    C = this.offsetWidth, T = this.offsetHeight, n(1, C), n(2, T);
  }
  return t.$$set = (v) => {
    "value" in v && n(13, a = v.value), "value_img" in v && n(14, s = v.value_img), "mode" in v && n(15, l = v.mode), "brush_color" in v && n(16, o = v.brush_color), "brush_radius" in v && n(10, u = v.brush_radius), "mask_opacity" in v && n(17, f = v.mask_opacity), "source" in v && n(18, h = v.source), "width" in v && n(11, c = v.width), "height" in v && n(12, d = v.height), "container_height" in v && n(19, _ = v.container_height), "shape" in v && n(20, m = v.shape);
  }, t.$$.update = () => {
    t.$$.dirty[0] & /*shape, width, height*/
    1054720 && m && (c || d) && (n(11, c = m[0]), n(12, d = m[1])), t.$$.dirty[0] & /*mounted, value*/
    33562624 && b && !a && yt(), t.$$.dirty[0] & /*mounted, value_img, last_value_img, source, ctx, width, canvas, height, lines*/
    503601153 && b && s !== y && (n(26, y = s), yt(), setTimeout(
      () => {
        h === "webcam" ? (g.temp.save(), g.temp.translate(c, 0), g.temp.scale(-1, 1), g.temp.drawImage(s, 0, 0), g.temp.restore()) : Z(), g.drawing.drawImage(p.temp, 0, 0, c, d), He({ lines: O.slice() }), et();
      },
      50
    )), t.$$.dirty[0] & /*lazy, brush_radius*/
    536871936 && E && (V(), E.setRadius(u * 0.05)), t.$$.dirty[0] & /*width, height*/
    6144 && (c || d) && Xn(), t.$$.dirty[0] & /*brush_radius*/
    1024 && (i = u * 0.075);
  }, [
    p,
    C,
    T,
    D,
    Y,
    xn,
    S,
    A,
    lt,
    wt,
    u,
    c,
    d,
    a,
    s,
    l,
    o,
    f,
    h,
    _,
    m,
    Te,
    be,
    yt,
    Kn,
    b,
    y,
    g,
    O,
    E,
    Fi,
    Gi,
    zi,
    ji
  ];
}
class _a extends ed {
  constructor(e) {
    super(), od(
      this,
      e,
      bd,
      md,
      ud,
      {
        value: 13,
        value_img: 14,
        mode: 15,
        brush_color: 16,
        brush_radius: 10,
        mask_opacity: 17,
        source: 18,
        width: 11,
        height: 12,
        container_height: 19,
        shape: 20,
        clear_mask: 21,
        undo: 22,
        clear: 23,
        get_image_data: 24
      },
      null,
      [-1, -1, -1]
    );
  }
  get clear_mask() {
    return this.$$.ctx[21];
  }
  get undo() {
    return this.$$.ctx[22];
  }
  get clear() {
    return this.$$.ctx[23];
  }
  get get_image_data() {
    return this.$$.ctx[24];
  }
}
function vd(t) {
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
}
var wd = function(e) {
  return yd(e) && !Ed(e);
};
function yd(t) {
  return !!t && typeof t == "object";
}
function Ed(t) {
  var e = Object.prototype.toString.call(t);
  return e === "[object RegExp]" || e === "[object Date]" || Sd(t);
}
var kd = typeof Symbol == "function" && Symbol.for, Td = kd ? Symbol.for("react.element") : 60103;
function Sd(t) {
  return t.$$typeof === Td;
}
function Cd(t) {
  return Array.isArray(t) ? [] : {};
}
function In(t, e) {
  return e.clone !== !1 && e.isMergeableObject(t) ? an(Cd(t), t, e) : t;
}
function Md(t, e, n) {
  return t.concat(e).map(function(i) {
    return In(i, n);
  });
}
function Ad(t, e) {
  if (!e.customMerge)
    return an;
  var n = e.customMerge(t);
  return typeof n == "function" ? n : an;
}
function Od(t) {
  return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(t).filter(function(e) {
    return Object.propertyIsEnumerable.call(t, e);
  }) : [];
}
function Cs(t) {
  return Object.keys(t).concat(Od(t));
}
function cl(t, e) {
  try {
    return e in t;
  } catch {
    return !1;
  }
}
function Dd(t, e) {
  return cl(t, e) && !(Object.hasOwnProperty.call(t, e) && Object.propertyIsEnumerable.call(t, e));
}
function Bd(t, e, n) {
  var i = {};
  return n.isMergeableObject(t) && Cs(t).forEach(function(r) {
    i[r] = In(t[r], n);
  }), Cs(e).forEach(function(r) {
    Dd(t, r) || (cl(t, r) && n.isMergeableObject(e[r]) ? i[r] = Ad(r, n)(t[r], e[r], n) : i[r] = In(e[r], n));
  }), i;
}
function an(t, e, n) {
  n = n || {}, n.arrayMerge = n.arrayMerge || Md, n.isMergeableObject = n.isMergeableObject || wd, n.cloneUnlessOtherwiseSpecified = In;
  var i = Array.isArray(e), r = Array.isArray(t), a = i === r;
  return a ? i ? n.arrayMerge(t, e, n) : Bd(t, e, n) : In(e, n);
}
an.all = function(e, n) {
  if (!Array.isArray(e))
    throw new Error("first argument should be an array");
  return e.reduce(function(i, r) {
    return an(i, r, n);
  }, {});
};
var Hd = an, Nd = Hd;
const Id = /* @__PURE__ */ vd(Nd);
var zr = function(t, e) {
  return zr = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(n, i) {
    n.__proto__ = i;
  } || function(n, i) {
    for (var r in i)
      Object.prototype.hasOwnProperty.call(i, r) && (n[r] = i[r]);
  }, zr(t, e);
};
function Bi(t, e) {
  if (typeof e != "function" && e !== null)
    throw new TypeError("Class extends value " + String(e) + " is not a constructor or null");
  zr(t, e);
  function n() {
    this.constructor = t;
  }
  t.prototype = e === null ? Object.create(e) : (n.prototype = e.prototype, new n());
}
var X = function() {
  return X = Object.assign || function(e) {
    for (var n, i = 1, r = arguments.length; i < r; i++) {
      n = arguments[i];
      for (var a in n)
        Object.prototype.hasOwnProperty.call(n, a) && (e[a] = n[a]);
    }
    return e;
  }, X.apply(this, arguments);
};
function gr(t, e, n) {
  if (n || arguments.length === 2)
    for (var i = 0, r = e.length, a; i < r; i++)
      (a || !(i in e)) && (a || (a = Array.prototype.slice.call(e, 0, i)), a[i] = e[i]);
  return t.concat(a || Array.prototype.slice.call(e));
}
var P;
(function(t) {
  t[t.EXPECT_ARGUMENT_CLOSING_BRACE = 1] = "EXPECT_ARGUMENT_CLOSING_BRACE", t[t.EMPTY_ARGUMENT = 2] = "EMPTY_ARGUMENT", t[t.MALFORMED_ARGUMENT = 3] = "MALFORMED_ARGUMENT", t[t.EXPECT_ARGUMENT_TYPE = 4] = "EXPECT_ARGUMENT_TYPE", t[t.INVALID_ARGUMENT_TYPE = 5] = "INVALID_ARGUMENT_TYPE", t[t.EXPECT_ARGUMENT_STYLE = 6] = "EXPECT_ARGUMENT_STYLE", t[t.INVALID_NUMBER_SKELETON = 7] = "INVALID_NUMBER_SKELETON", t[t.INVALID_DATE_TIME_SKELETON = 8] = "INVALID_DATE_TIME_SKELETON", t[t.EXPECT_NUMBER_SKELETON = 9] = "EXPECT_NUMBER_SKELETON", t[t.EXPECT_DATE_TIME_SKELETON = 10] = "EXPECT_DATE_TIME_SKELETON", t[t.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE = 11] = "UNCLOSED_QUOTE_IN_ARGUMENT_STYLE", t[t.EXPECT_SELECT_ARGUMENT_OPTIONS = 12] = "EXPECT_SELECT_ARGUMENT_OPTIONS", t[t.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE = 13] = "EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE", t[t.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE = 14] = "INVALID_PLURAL_ARGUMENT_OFFSET_VALUE", t[t.EXPECT_SELECT_ARGUMENT_SELECTOR = 15] = "EXPECT_SELECT_ARGUMENT_SELECTOR", t[t.EXPECT_PLURAL_ARGUMENT_SELECTOR = 16] = "EXPECT_PLURAL_ARGUMENT_SELECTOR", t[t.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT = 17] = "EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT", t[t.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT = 18] = "EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT", t[t.INVALID_PLURAL_ARGUMENT_SELECTOR = 19] = "INVALID_PLURAL_ARGUMENT_SELECTOR", t[t.DUPLICATE_PLURAL_ARGUMENT_SELECTOR = 20] = "DUPLICATE_PLURAL_ARGUMENT_SELECTOR", t[t.DUPLICATE_SELECT_ARGUMENT_SELECTOR = 21] = "DUPLICATE_SELECT_ARGUMENT_SELECTOR", t[t.MISSING_OTHER_CLAUSE = 22] = "MISSING_OTHER_CLAUSE", t[t.INVALID_TAG = 23] = "INVALID_TAG", t[t.INVALID_TAG_NAME = 25] = "INVALID_TAG_NAME", t[t.UNMATCHED_CLOSING_TAG = 26] = "UNMATCHED_CLOSING_TAG", t[t.UNCLOSED_TAG = 27] = "UNCLOSED_TAG";
})(P || (P = {}));
var ie;
(function(t) {
  t[t.literal = 0] = "literal", t[t.argument = 1] = "argument", t[t.number = 2] = "number", t[t.date = 3] = "date", t[t.time = 4] = "time", t[t.select = 5] = "select", t[t.plural = 6] = "plural", t[t.pound = 7] = "pound", t[t.tag = 8] = "tag";
})(ie || (ie = {}));
var sn;
(function(t) {
  t[t.number = 0] = "number", t[t.dateTime = 1] = "dateTime";
})(sn || (sn = {}));
function Ms(t) {
  return t.type === ie.literal;
}
function Rd(t) {
  return t.type === ie.argument;
}
function dl(t) {
  return t.type === ie.number;
}
function _l(t) {
  return t.type === ie.date;
}
function ml(t) {
  return t.type === ie.time;
}
function gl(t) {
  return t.type === ie.select;
}
function pl(t) {
  return t.type === ie.plural;
}
function Ld(t) {
  return t.type === ie.pound;
}
function bl(t) {
  return t.type === ie.tag;
}
function vl(t) {
  return !!(t && typeof t == "object" && t.type === sn.number);
}
function jr(t) {
  return !!(t && typeof t == "object" && t.type === sn.dateTime);
}
var wl = /[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/, Pd = /(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g;
function Ud(t) {
  var e = {};
  return t.replace(Pd, function(n) {
    var i = n.length;
    switch (n[0]) {
      case "G":
        e.era = i === 4 ? "long" : i === 5 ? "narrow" : "short";
        break;
      case "y":
        e.year = i === 2 ? "2-digit" : "numeric";
        break;
      case "Y":
      case "u":
      case "U":
      case "r":
        throw new RangeError("`Y/u/U/r` (year) patterns are not supported, use `y` instead");
      case "q":
      case "Q":
        throw new RangeError("`q/Q` (quarter) patterns are not supported");
      case "M":
      case "L":
        e.month = ["numeric", "2-digit", "short", "long", "narrow"][i - 1];
        break;
      case "w":
      case "W":
        throw new RangeError("`w/W` (week) patterns are not supported");
      case "d":
        e.day = ["numeric", "2-digit"][i - 1];
        break;
      case "D":
      case "F":
      case "g":
        throw new RangeError("`D/F/g` (day) patterns are not supported, use `d` instead");
      case "E":
        e.weekday = i === 4 ? "short" : i === 5 ? "narrow" : "short";
        break;
      case "e":
        if (i < 4)
          throw new RangeError("`e..eee` (weekday) patterns are not supported");
        e.weekday = ["short", "long", "narrow", "short"][i - 4];
        break;
      case "c":
        if (i < 4)
          throw new RangeError("`c..ccc` (weekday) patterns are not supported");
        e.weekday = ["short", "long", "narrow", "short"][i - 4];
        break;
      case "a":
        e.hour12 = !0;
        break;
      case "b":
      case "B":
        throw new RangeError("`b/B` (period) patterns are not supported, use `a` instead");
      case "h":
        e.hourCycle = "h12", e.hour = ["numeric", "2-digit"][i - 1];
        break;
      case "H":
        e.hourCycle = "h23", e.hour = ["numeric", "2-digit"][i - 1];
        break;
      case "K":
        e.hourCycle = "h11", e.hour = ["numeric", "2-digit"][i - 1];
        break;
      case "k":
        e.hourCycle = "h24", e.hour = ["numeric", "2-digit"][i - 1];
        break;
      case "j":
      case "J":
      case "C":
        throw new RangeError("`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead");
      case "m":
        e.minute = ["numeric", "2-digit"][i - 1];
        break;
      case "s":
        e.second = ["numeric", "2-digit"][i - 1];
        break;
      case "S":
      case "A":
        throw new RangeError("`S/A` (second) patterns are not supported, use `s` instead");
      case "z":
        e.timeZoneName = i < 4 ? "short" : "long";
        break;
      case "Z":
      case "O":
      case "v":
      case "V":
      case "X":
      case "x":
        throw new RangeError("`Z/O/v/V/X/x` (timeZone) patterns are not supported, use `z` instead");
    }
    return "";
  }), e;
}
var Fd = /[\t-\r \x85\u200E\u200F\u2028\u2029]/i;
function Gd(t) {
  if (t.length === 0)
    throw new Error("Number skeleton cannot be empty");
  for (var e = t.split(Fd).filter(function(c) {
    return c.length > 0;
  }), n = [], i = 0, r = e; i < r.length; i++) {
    var a = r[i], s = a.split("/");
    if (s.length === 0)
      throw new Error("Invalid number skeleton");
    for (var l = s[0], o = s.slice(1), u = 0, f = o; u < f.length; u++) {
      var h = f[u];
      if (h.length === 0)
        throw new Error("Invalid number skeleton");
    }
    n.push({ stem: l, options: o });
  }
  return n;
}
function zd(t) {
  return t.replace(/^(.*?)-/, "");
}
var As = /^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g, yl = /^(@+)?(\+|#+)?[rs]?$/g, jd = /(\*)(0+)|(#+)(0+)|(0+)/g, El = /^(0+)$/;
function Os(t) {
  var e = {};
  return t[t.length - 1] === "r" ? e.roundingPriority = "morePrecision" : t[t.length - 1] === "s" && (e.roundingPriority = "lessPrecision"), t.replace(yl, function(n, i, r) {
    return typeof r != "string" ? (e.minimumSignificantDigits = i.length, e.maximumSignificantDigits = i.length) : r === "+" ? e.minimumSignificantDigits = i.length : i[0] === "#" ? e.maximumSignificantDigits = i.length : (e.minimumSignificantDigits = i.length, e.maximumSignificantDigits = i.length + (typeof r == "string" ? r.length : 0)), "";
  }), e;
}
function kl(t) {
  switch (t) {
    case "sign-auto":
      return {
        signDisplay: "auto"
      };
    case "sign-accounting":
    case "()":
      return {
        currencySign: "accounting"
      };
    case "sign-always":
    case "+!":
      return {
        signDisplay: "always"
      };
    case "sign-accounting-always":
    case "()!":
      return {
        signDisplay: "always",
        currencySign: "accounting"
      };
    case "sign-except-zero":
    case "+?":
      return {
        signDisplay: "exceptZero"
      };
    case "sign-accounting-except-zero":
    case "()?":
      return {
        signDisplay: "exceptZero",
        currencySign: "accounting"
      };
    case "sign-never":
    case "+_":
      return {
        signDisplay: "never"
      };
  }
}
function qd(t) {
  var e;
  if (t[0] === "E" && t[1] === "E" ? (e = {
    notation: "engineering"
  }, t = t.slice(2)) : t[0] === "E" && (e = {
    notation: "scientific"
  }, t = t.slice(1)), e) {
    var n = t.slice(0, 2);
    if (n === "+!" ? (e.signDisplay = "always", t = t.slice(2)) : n === "+?" && (e.signDisplay = "exceptZero", t = t.slice(2)), !El.test(t))
      throw new Error("Malformed concise eng/scientific notation");
    e.minimumIntegerDigits = t.length;
  }
  return e;
}
function Ds(t) {
  var e = {}, n = kl(t);
  return n || e;
}
function xd(t) {
  for (var e = {}, n = 0, i = t; n < i.length; n++) {
    var r = i[n];
    switch (r.stem) {
      case "percent":
      case "%":
        e.style = "percent";
        continue;
      case "%x100":
        e.style = "percent", e.scale = 100;
        continue;
      case "currency":
        e.style = "currency", e.currency = r.options[0];
        continue;
      case "group-off":
      case ",_":
        e.useGrouping = !1;
        continue;
      case "precision-integer":
      case ".":
        e.maximumFractionDigits = 0;
        continue;
      case "measure-unit":
      case "unit":
        e.style = "unit", e.unit = zd(r.options[0]);
        continue;
      case "compact-short":
      case "K":
        e.notation = "compact", e.compactDisplay = "short";
        continue;
      case "compact-long":
      case "KK":
        e.notation = "compact", e.compactDisplay = "long";
        continue;
      case "scientific":
        e = X(X(X({}, e), { notation: "scientific" }), r.options.reduce(function(o, u) {
          return X(X({}, o), Ds(u));
        }, {}));
        continue;
      case "engineering":
        e = X(X(X({}, e), { notation: "engineering" }), r.options.reduce(function(o, u) {
          return X(X({}, o), Ds(u));
        }, {}));
        continue;
      case "notation-simple":
        e.notation = "standard";
        continue;
      case "unit-width-narrow":
        e.currencyDisplay = "narrowSymbol", e.unitDisplay = "narrow";
        continue;
      case "unit-width-short":
        e.currencyDisplay = "code", e.unitDisplay = "short";
        continue;
      case "unit-width-full-name":
        e.currencyDisplay = "name", e.unitDisplay = "long";
        continue;
      case "unit-width-iso-code":
        e.currencyDisplay = "symbol";
        continue;
      case "scale":
        e.scale = parseFloat(r.options[0]);
        continue;
      case "integer-width":
        if (r.options.length > 1)
          throw new RangeError("integer-width stems only accept a single optional option");
        r.options[0].replace(jd, function(o, u, f, h, c, d) {
          if (u)
            e.minimumIntegerDigits = f.length;
          else {
            if (h && c)
              throw new Error("We currently do not support maximum integer digits");
            if (d)
              throw new Error("We currently do not support exact integer digits");
          }
          return "";
        });
        continue;
    }
    if (El.test(r.stem)) {
      e.minimumIntegerDigits = r.stem.length;
      continue;
    }
    if (As.test(r.stem)) {
      if (r.options.length > 1)
        throw new RangeError("Fraction-precision stems only accept a single optional option");
      r.stem.replace(As, function(o, u, f, h, c, d) {
        return f === "*" ? e.minimumFractionDigits = u.length : h && h[0] === "#" ? e.maximumFractionDigits = h.length : c && d ? (e.minimumFractionDigits = c.length, e.maximumFractionDigits = c.length + d.length) : (e.minimumFractionDigits = u.length, e.maximumFractionDigits = u.length), "";
      });
      var a = r.options[0];
      a === "w" ? e = X(X({}, e), { trailingZeroDisplay: "stripIfInteger" }) : a && (e = X(X({}, e), Os(a)));
      continue;
    }
    if (yl.test(r.stem)) {
      e = X(X({}, e), Os(r.stem));
      continue;
    }
    var s = kl(r.stem);
    s && (e = X(X({}, e), s));
    var l = qd(r.stem);
    l && (e = X(X({}, e), l));
  }
  return e;
}
var oi = {
  AX: [
    "H"
  ],
  BQ: [
    "H"
  ],
  CP: [
    "H"
  ],
  CZ: [
    "H"
  ],
  DK: [
    "H"
  ],
  FI: [
    "H"
  ],
  ID: [
    "H"
  ],
  IS: [
    "H"
  ],
  ML: [
    "H"
  ],
  NE: [
    "H"
  ],
  RU: [
    "H"
  ],
  SE: [
    "H"
  ],
  SJ: [
    "H"
  ],
  SK: [
    "H"
  ],
  AS: [
    "h",
    "H"
  ],
  BT: [
    "h",
    "H"
  ],
  DJ: [
    "h",
    "H"
  ],
  ER: [
    "h",
    "H"
  ],
  GH: [
    "h",
    "H"
  ],
  IN: [
    "h",
    "H"
  ],
  LS: [
    "h",
    "H"
  ],
  PG: [
    "h",
    "H"
  ],
  PW: [
    "h",
    "H"
  ],
  SO: [
    "h",
    "H"
  ],
  TO: [
    "h",
    "H"
  ],
  VU: [
    "h",
    "H"
  ],
  WS: [
    "h",
    "H"
  ],
  "001": [
    "H",
    "h"
  ],
  AL: [
    "h",
    "H",
    "hB"
  ],
  TD: [
    "h",
    "H",
    "hB"
  ],
  "ca-ES": [
    "H",
    "h",
    "hB"
  ],
  CF: [
    "H",
    "h",
    "hB"
  ],
  CM: [
    "H",
    "h",
    "hB"
  ],
  "fr-CA": [
    "H",
    "h",
    "hB"
  ],
  "gl-ES": [
    "H",
    "h",
    "hB"
  ],
  "it-CH": [
    "H",
    "h",
    "hB"
  ],
  "it-IT": [
    "H",
    "h",
    "hB"
  ],
  LU: [
    "H",
    "h",
    "hB"
  ],
  NP: [
    "H",
    "h",
    "hB"
  ],
  PF: [
    "H",
    "h",
    "hB"
  ],
  SC: [
    "H",
    "h",
    "hB"
  ],
  SM: [
    "H",
    "h",
    "hB"
  ],
  SN: [
    "H",
    "h",
    "hB"
  ],
  TF: [
    "H",
    "h",
    "hB"
  ],
  VA: [
    "H",
    "h",
    "hB"
  ],
  CY: [
    "h",
    "H",
    "hb",
    "hB"
  ],
  GR: [
    "h",
    "H",
    "hb",
    "hB"
  ],
  CO: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  DO: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  KP: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  KR: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  NA: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  PA: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  PR: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  VE: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  AC: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  AI: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  BW: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  BZ: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  CC: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  CK: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  CX: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  DG: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  FK: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  GB: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  GG: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  GI: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  IE: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  IM: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  IO: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  JE: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  LT: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  MK: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  MN: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  MS: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  NF: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  NG: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  NR: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  NU: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  PN: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  SH: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  SX: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  TA: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  ZA: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  "af-ZA": [
    "H",
    "h",
    "hB",
    "hb"
  ],
  AR: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  CL: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  CR: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  CU: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  EA: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  "es-BO": [
    "H",
    "h",
    "hB",
    "hb"
  ],
  "es-BR": [
    "H",
    "h",
    "hB",
    "hb"
  ],
  "es-EC": [
    "H",
    "h",
    "hB",
    "hb"
  ],
  "es-ES": [
    "H",
    "h",
    "hB",
    "hb"
  ],
  "es-GQ": [
    "H",
    "h",
    "hB",
    "hb"
  ],
  "es-PE": [
    "H",
    "h",
    "hB",
    "hb"
  ],
  GT: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  HN: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  IC: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  KG: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  KM: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  LK: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  MA: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  MX: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  NI: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  PY: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  SV: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  UY: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  JP: [
    "H",
    "h",
    "K"
  ],
  AD: [
    "H",
    "hB"
  ],
  AM: [
    "H",
    "hB"
  ],
  AO: [
    "H",
    "hB"
  ],
  AT: [
    "H",
    "hB"
  ],
  AW: [
    "H",
    "hB"
  ],
  BE: [
    "H",
    "hB"
  ],
  BF: [
    "H",
    "hB"
  ],
  BJ: [
    "H",
    "hB"
  ],
  BL: [
    "H",
    "hB"
  ],
  BR: [
    "H",
    "hB"
  ],
  CG: [
    "H",
    "hB"
  ],
  CI: [
    "H",
    "hB"
  ],
  CV: [
    "H",
    "hB"
  ],
  DE: [
    "H",
    "hB"
  ],
  EE: [
    "H",
    "hB"
  ],
  FR: [
    "H",
    "hB"
  ],
  GA: [
    "H",
    "hB"
  ],
  GF: [
    "H",
    "hB"
  ],
  GN: [
    "H",
    "hB"
  ],
  GP: [
    "H",
    "hB"
  ],
  GW: [
    "H",
    "hB"
  ],
  HR: [
    "H",
    "hB"
  ],
  IL: [
    "H",
    "hB"
  ],
  IT: [
    "H",
    "hB"
  ],
  KZ: [
    "H",
    "hB"
  ],
  MC: [
    "H",
    "hB"
  ],
  MD: [
    "H",
    "hB"
  ],
  MF: [
    "H",
    "hB"
  ],
  MQ: [
    "H",
    "hB"
  ],
  MZ: [
    "H",
    "hB"
  ],
  NC: [
    "H",
    "hB"
  ],
  NL: [
    "H",
    "hB"
  ],
  PM: [
    "H",
    "hB"
  ],
  PT: [
    "H",
    "hB"
  ],
  RE: [
    "H",
    "hB"
  ],
  RO: [
    "H",
    "hB"
  ],
  SI: [
    "H",
    "hB"
  ],
  SR: [
    "H",
    "hB"
  ],
  ST: [
    "H",
    "hB"
  ],
  TG: [
    "H",
    "hB"
  ],
  TR: [
    "H",
    "hB"
  ],
  WF: [
    "H",
    "hB"
  ],
  YT: [
    "H",
    "hB"
  ],
  BD: [
    "h",
    "hB",
    "H"
  ],
  PK: [
    "h",
    "hB",
    "H"
  ],
  AZ: [
    "H",
    "hB",
    "h"
  ],
  BA: [
    "H",
    "hB",
    "h"
  ],
  BG: [
    "H",
    "hB",
    "h"
  ],
  CH: [
    "H",
    "hB",
    "h"
  ],
  GE: [
    "H",
    "hB",
    "h"
  ],
  LI: [
    "H",
    "hB",
    "h"
  ],
  ME: [
    "H",
    "hB",
    "h"
  ],
  RS: [
    "H",
    "hB",
    "h"
  ],
  UA: [
    "H",
    "hB",
    "h"
  ],
  UZ: [
    "H",
    "hB",
    "h"
  ],
  XK: [
    "H",
    "hB",
    "h"
  ],
  AG: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  AU: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  BB: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  BM: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  BS: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  CA: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  DM: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  "en-001": [
    "h",
    "hb",
    "H",
    "hB"
  ],
  FJ: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  FM: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  GD: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  GM: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  GU: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  GY: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  JM: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  KI: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  KN: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  KY: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  LC: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  LR: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  MH: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  MP: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  MW: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  NZ: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  SB: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  SG: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  SL: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  SS: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  SZ: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  TC: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  TT: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  UM: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  US: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  VC: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  VG: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  VI: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  ZM: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  BO: [
    "H",
    "hB",
    "h",
    "hb"
  ],
  EC: [
    "H",
    "hB",
    "h",
    "hb"
  ],
  ES: [
    "H",
    "hB",
    "h",
    "hb"
  ],
  GQ: [
    "H",
    "hB",
    "h",
    "hb"
  ],
  PE: [
    "H",
    "hB",
    "h",
    "hb"
  ],
  AE: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  "ar-001": [
    "h",
    "hB",
    "hb",
    "H"
  ],
  BH: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  DZ: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  EG: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  EH: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  HK: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  IQ: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  JO: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  KW: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  LB: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  LY: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  MO: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  MR: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  OM: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  PH: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  PS: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  QA: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  SA: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  SD: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  SY: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  TN: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  YE: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  AF: [
    "H",
    "hb",
    "hB",
    "h"
  ],
  LA: [
    "H",
    "hb",
    "hB",
    "h"
  ],
  CN: [
    "H",
    "hB",
    "hb",
    "h"
  ],
  LV: [
    "H",
    "hB",
    "hb",
    "h"
  ],
  TL: [
    "H",
    "hB",
    "hb",
    "h"
  ],
  "zu-ZA": [
    "H",
    "hB",
    "hb",
    "h"
  ],
  CD: [
    "hB",
    "H"
  ],
  IR: [
    "hB",
    "H"
  ],
  "hi-IN": [
    "hB",
    "h",
    "H"
  ],
  "kn-IN": [
    "hB",
    "h",
    "H"
  ],
  "ml-IN": [
    "hB",
    "h",
    "H"
  ],
  "te-IN": [
    "hB",
    "h",
    "H"
  ],
  KH: [
    "hB",
    "h",
    "H",
    "hb"
  ],
  "ta-IN": [
    "hB",
    "h",
    "hb",
    "H"
  ],
  BN: [
    "hb",
    "hB",
    "h",
    "H"
  ],
  MY: [
    "hb",
    "hB",
    "h",
    "H"
  ],
  ET: [
    "hB",
    "hb",
    "h",
    "H"
  ],
  "gu-IN": [
    "hB",
    "hb",
    "h",
    "H"
  ],
  "mr-IN": [
    "hB",
    "hb",
    "h",
    "H"
  ],
  "pa-IN": [
    "hB",
    "hb",
    "h",
    "H"
  ],
  TW: [
    "hB",
    "hb",
    "h",
    "H"
  ],
  KE: [
    "hB",
    "hb",
    "H",
    "h"
  ],
  MM: [
    "hB",
    "hb",
    "H",
    "h"
  ],
  TZ: [
    "hB",
    "hb",
    "H",
    "h"
  ],
  UG: [
    "hB",
    "hb",
    "H",
    "h"
  ]
};
function Xd(t, e) {
  for (var n = "", i = 0; i < t.length; i++) {
    var r = t.charAt(i);
    if (r === "j") {
      for (var a = 0; i + 1 < t.length && t.charAt(i + 1) === r; )
        a++, i++;
      var s = 1 + (a & 1), l = a < 2 ? 1 : 3 + (a >> 1), o = "a", u = Vd(e);
      for ((u == "H" || u == "k") && (l = 0); l-- > 0; )
        n += o;
      for (; s-- > 0; )
        n = u + n;
    } else
      r === "J" ? n += "H" : n += r;
  }
  return n;
}
function Vd(t) {
  var e = t.hourCycle;
  if (e === void 0 && // @ts-ignore hourCycle(s) is not identified yet
  t.hourCycles && // @ts-ignore
  t.hourCycles.length && (e = t.hourCycles[0]), e)
    switch (e) {
      case "h24":
        return "k";
      case "h23":
        return "H";
      case "h12":
        return "h";
      case "h11":
        return "K";
      default:
        throw new Error("Invalid hourCycle");
    }
  var n = t.language, i;
  n !== "root" && (i = t.maximize().region);
  var r = oi[i || ""] || oi[n || ""] || oi["".concat(n, "-001")] || oi["001"];
  return r[0];
}
var pr, Wd = new RegExp("^".concat(wl.source, "*")), Yd = new RegExp("".concat(wl.source, "*$"));
function F(t, e) {
  return { start: t, end: e };
}
var Zd = !!String.prototype.startsWith, Qd = !!String.fromCodePoint, Jd = !!Object.fromEntries, Kd = !!String.prototype.codePointAt, $d = !!String.prototype.trimStart, e_ = !!String.prototype.trimEnd, t_ = !!Number.isSafeInteger, n_ = t_ ? Number.isSafeInteger : function(t) {
  return typeof t == "number" && isFinite(t) && Math.floor(t) === t && Math.abs(t) <= 9007199254740991;
}, qr = !0;
try {
  var i_ = Sl("([^\\p{White_Space}\\p{Pattern_Syntax}]*)", "yu");
  qr = ((pr = i_.exec("a")) === null || pr === void 0 ? void 0 : pr[0]) === "a";
} catch {
  qr = !1;
}
var Bs = Zd ? (
  // Native
  function(e, n, i) {
    return e.startsWith(n, i);
  }
) : (
  // For IE11
  function(e, n, i) {
    return e.slice(i, i + n.length) === n;
  }
), xr = Qd ? String.fromCodePoint : (
  // IE11
  function() {
    for (var e = [], n = 0; n < arguments.length; n++)
      e[n] = arguments[n];
    for (var i = "", r = e.length, a = 0, s; r > a; ) {
      if (s = e[a++], s > 1114111)
        throw RangeError(s + " is not a valid code point");
      i += s < 65536 ? String.fromCharCode(s) : String.fromCharCode(((s -= 65536) >> 10) + 55296, s % 1024 + 56320);
    }
    return i;
  }
), Hs = (
  // native
  Jd ? Object.fromEntries : (
    // Ponyfill
    function(e) {
      for (var n = {}, i = 0, r = e; i < r.length; i++) {
        var a = r[i], s = a[0], l = a[1];
        n[s] = l;
      }
      return n;
    }
  )
), Tl = Kd ? (
  // Native
  function(e, n) {
    return e.codePointAt(n);
  }
) : (
  // IE 11
  function(e, n) {
    var i = e.length;
    if (!(n < 0 || n >= i)) {
      var r = e.charCodeAt(n), a;
      return r < 55296 || r > 56319 || n + 1 === i || (a = e.charCodeAt(n + 1)) < 56320 || a > 57343 ? r : (r - 55296 << 10) + (a - 56320) + 65536;
    }
  }
), r_ = $d ? (
  // Native
  function(e) {
    return e.trimStart();
  }
) : (
  // Ponyfill
  function(e) {
    return e.replace(Wd, "");
  }
), a_ = e_ ? (
  // Native
  function(e) {
    return e.trimEnd();
  }
) : (
  // Ponyfill
  function(e) {
    return e.replace(Yd, "");
  }
);
function Sl(t, e) {
  return new RegExp(t, e);
}
var Xr;
if (qr) {
  var Ns = Sl("([^\\p{White_Space}\\p{Pattern_Syntax}]*)", "yu");
  Xr = function(e, n) {
    var i;
    Ns.lastIndex = n;
    var r = Ns.exec(e);
    return (i = r[1]) !== null && i !== void 0 ? i : "";
  };
} else
  Xr = function(e, n) {
    for (var i = []; ; ) {
      var r = Tl(e, n);
      if (r === void 0 || Cl(r) || u_(r))
        break;
      i.push(r), n += r >= 65536 ? 2 : 1;
    }
    return xr.apply(void 0, i);
  };
var s_ = (
  /** @class */
  function() {
    function t(e, n) {
      n === void 0 && (n = {}), this.message = e, this.position = { offset: 0, line: 1, column: 1 }, this.ignoreTag = !!n.ignoreTag, this.locale = n.locale, this.requiresOtherClause = !!n.requiresOtherClause, this.shouldParseSkeletons = !!n.shouldParseSkeletons;
    }
    return t.prototype.parse = function() {
      if (this.offset() !== 0)
        throw Error("parser can only be used once");
      return this.parseMessage(0, "", !1);
    }, t.prototype.parseMessage = function(e, n, i) {
      for (var r = []; !this.isEOF(); ) {
        var a = this.char();
        if (a === 123) {
          var s = this.parseArgument(e, i);
          if (s.err)
            return s;
          r.push(s.val);
        } else {
          if (a === 125 && e > 0)
            break;
          if (a === 35 && (n === "plural" || n === "selectordinal")) {
            var l = this.clonePosition();
            this.bump(), r.push({
              type: ie.pound,
              location: F(l, this.clonePosition())
            });
          } else if (a === 60 && !this.ignoreTag && this.peek() === 47) {
            if (i)
              break;
            return this.error(P.UNMATCHED_CLOSING_TAG, F(this.clonePosition(), this.clonePosition()));
          } else if (a === 60 && !this.ignoreTag && Vr(this.peek() || 0)) {
            var s = this.parseTag(e, n);
            if (s.err)
              return s;
            r.push(s.val);
          } else {
            var s = this.parseLiteral(e, n);
            if (s.err)
              return s;
            r.push(s.val);
          }
        }
      }
      return { val: r, err: null };
    }, t.prototype.parseTag = function(e, n) {
      var i = this.clonePosition();
      this.bump();
      var r = this.parseTagName();
      if (this.bumpSpace(), this.bumpIf("/>"))
        return {
          val: {
            type: ie.literal,
            value: "<".concat(r, "/>"),
            location: F(i, this.clonePosition())
          },
          err: null
        };
      if (this.bumpIf(">")) {
        var a = this.parseMessage(e + 1, n, !0);
        if (a.err)
          return a;
        var s = a.val, l = this.clonePosition();
        if (this.bumpIf("</")) {
          if (this.isEOF() || !Vr(this.char()))
            return this.error(P.INVALID_TAG, F(l, this.clonePosition()));
          var o = this.clonePosition(), u = this.parseTagName();
          return r !== u ? this.error(P.UNMATCHED_CLOSING_TAG, F(o, this.clonePosition())) : (this.bumpSpace(), this.bumpIf(">") ? {
            val: {
              type: ie.tag,
              value: r,
              children: s,
              location: F(i, this.clonePosition())
            },
            err: null
          } : this.error(P.INVALID_TAG, F(l, this.clonePosition())));
        } else
          return this.error(P.UNCLOSED_TAG, F(i, this.clonePosition()));
      } else
        return this.error(P.INVALID_TAG, F(i, this.clonePosition()));
    }, t.prototype.parseTagName = function() {
      var e = this.offset();
      for (this.bump(); !this.isEOF() && l_(this.char()); )
        this.bump();
      return this.message.slice(e, this.offset());
    }, t.prototype.parseLiteral = function(e, n) {
      for (var i = this.clonePosition(), r = ""; ; ) {
        var a = this.tryParseQuote(n);
        if (a) {
          r += a;
          continue;
        }
        var s = this.tryParseUnquoted(e, n);
        if (s) {
          r += s;
          continue;
        }
        var l = this.tryParseLeftAngleBracket();
        if (l) {
          r += l;
          continue;
        }
        break;
      }
      var o = F(i, this.clonePosition());
      return {
        val: { type: ie.literal, value: r, location: o },
        err: null
      };
    }, t.prototype.tryParseLeftAngleBracket = function() {
      return !this.isEOF() && this.char() === 60 && (this.ignoreTag || // If at the opening tag or closing tag position, bail.
      !o_(this.peek() || 0)) ? (this.bump(), "<") : null;
    }, t.prototype.tryParseQuote = function(e) {
      if (this.isEOF() || this.char() !== 39)
        return null;
      switch (this.peek()) {
        case 39:
          return this.bump(), this.bump(), "'";
        case 123:
        case 60:
        case 62:
        case 125:
          break;
        case 35:
          if (e === "plural" || e === "selectordinal")
            break;
          return null;
        default:
          return null;
      }
      this.bump();
      var n = [this.char()];
      for (this.bump(); !this.isEOF(); ) {
        var i = this.char();
        if (i === 39)
          if (this.peek() === 39)
            n.push(39), this.bump();
          else {
            this.bump();
            break;
          }
        else
          n.push(i);
        this.bump();
      }
      return xr.apply(void 0, n);
    }, t.prototype.tryParseUnquoted = function(e, n) {
      if (this.isEOF())
        return null;
      var i = this.char();
      return i === 60 || i === 123 || i === 35 && (n === "plural" || n === "selectordinal") || i === 125 && e > 0 ? null : (this.bump(), xr(i));
    }, t.prototype.parseArgument = function(e, n) {
      var i = this.clonePosition();
      if (this.bump(), this.bumpSpace(), this.isEOF())
        return this.error(P.EXPECT_ARGUMENT_CLOSING_BRACE, F(i, this.clonePosition()));
      if (this.char() === 125)
        return this.bump(), this.error(P.EMPTY_ARGUMENT, F(i, this.clonePosition()));
      var r = this.parseIdentifierIfPossible().value;
      if (!r)
        return this.error(P.MALFORMED_ARGUMENT, F(i, this.clonePosition()));
      if (this.bumpSpace(), this.isEOF())
        return this.error(P.EXPECT_ARGUMENT_CLOSING_BRACE, F(i, this.clonePosition()));
      switch (this.char()) {
        case 125:
          return this.bump(), {
            val: {
              type: ie.argument,
              // value does not include the opening and closing braces.
              value: r,
              location: F(i, this.clonePosition())
            },
            err: null
          };
        case 44:
          return this.bump(), this.bumpSpace(), this.isEOF() ? this.error(P.EXPECT_ARGUMENT_CLOSING_BRACE, F(i, this.clonePosition())) : this.parseArgumentOptions(e, n, r, i);
        default:
          return this.error(P.MALFORMED_ARGUMENT, F(i, this.clonePosition()));
      }
    }, t.prototype.parseIdentifierIfPossible = function() {
      var e = this.clonePosition(), n = this.offset(), i = Xr(this.message, n), r = n + i.length;
      this.bumpTo(r);
      var a = this.clonePosition(), s = F(e, a);
      return { value: i, location: s };
    }, t.prototype.parseArgumentOptions = function(e, n, i, r) {
      var a, s = this.clonePosition(), l = this.parseIdentifierIfPossible().value, o = this.clonePosition();
      switch (l) {
        case "":
          return this.error(P.EXPECT_ARGUMENT_TYPE, F(s, o));
        case "number":
        case "date":
        case "time": {
          this.bumpSpace();
          var u = null;
          if (this.bumpIf(",")) {
            this.bumpSpace();
            var f = this.clonePosition(), h = this.parseSimpleArgStyleIfPossible();
            if (h.err)
              return h;
            var c = a_(h.val);
            if (c.length === 0)
              return this.error(P.EXPECT_ARGUMENT_STYLE, F(this.clonePosition(), this.clonePosition()));
            var d = F(f, this.clonePosition());
            u = { style: c, styleLocation: d };
          }
          var _ = this.tryParseArgumentClose(r);
          if (_.err)
            return _;
          var m = F(r, this.clonePosition());
          if (u && Bs(u == null ? void 0 : u.style, "::", 0)) {
            var b = r_(u.style.slice(2));
            if (l === "number") {
              var h = this.parseNumberSkeletonFromString(b, u.styleLocation);
              return h.err ? h : {
                val: { type: ie.number, value: i, location: m, style: h.val },
                err: null
              };
            } else {
              if (b.length === 0)
                return this.error(P.EXPECT_DATE_TIME_SKELETON, m);
              var C = b;
              this.locale && (C = Xd(b, this.locale));
              var c = {
                type: sn.dateTime,
                pattern: C,
                location: u.styleLocation,
                parsedOptions: this.shouldParseSkeletons ? Ud(C) : {}
              }, T = l === "date" ? ie.date : ie.time;
              return {
                val: { type: T, value: i, location: m, style: c },
                err: null
              };
            }
          }
          return {
            val: {
              type: l === "number" ? ie.number : l === "date" ? ie.date : ie.time,
              value: i,
              location: m,
              style: (a = u == null ? void 0 : u.style) !== null && a !== void 0 ? a : null
            },
            err: null
          };
        }
        case "plural":
        case "selectordinal":
        case "select": {
          var y = this.clonePosition();
          if (this.bumpSpace(), !this.bumpIf(","))
            return this.error(P.EXPECT_SELECT_ARGUMENT_OPTIONS, F(y, X({}, y)));
          this.bumpSpace();
          var S = this.parseIdentifierIfPossible(), p = 0;
          if (l !== "select" && S.value === "offset") {
            if (!this.bumpIf(":"))
              return this.error(P.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, F(this.clonePosition(), this.clonePosition()));
            this.bumpSpace();
            var h = this.tryParseDecimalInteger(P.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, P.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);
            if (h.err)
              return h;
            this.bumpSpace(), S = this.parseIdentifierIfPossible(), p = h.val;
          }
          var g = this.tryParsePluralOrSelectOptions(e, l, n, S);
          if (g.err)
            return g;
          var _ = this.tryParseArgumentClose(r);
          if (_.err)
            return _;
          var M = F(r, this.clonePosition());
          return l === "select" ? {
            val: {
              type: ie.select,
              value: i,
              options: Hs(g.val),
              location: M
            },
            err: null
          } : {
            val: {
              type: ie.plural,
              value: i,
              options: Hs(g.val),
              offset: p,
              pluralType: l === "plural" ? "cardinal" : "ordinal",
              location: M
            },
            err: null
          };
        }
        default:
          return this.error(P.INVALID_ARGUMENT_TYPE, F(s, o));
      }
    }, t.prototype.tryParseArgumentClose = function(e) {
      return this.isEOF() || this.char() !== 125 ? this.error(P.EXPECT_ARGUMENT_CLOSING_BRACE, F(e, this.clonePosition())) : (this.bump(), { val: !0, err: null });
    }, t.prototype.parseSimpleArgStyleIfPossible = function() {
      for (var e = 0, n = this.clonePosition(); !this.isEOF(); ) {
        var i = this.char();
        switch (i) {
          case 39: {
            this.bump();
            var r = this.clonePosition();
            if (!this.bumpUntil("'"))
              return this.error(P.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE, F(r, this.clonePosition()));
            this.bump();
            break;
          }
          case 123: {
            e += 1, this.bump();
            break;
          }
          case 125: {
            if (e > 0)
              e -= 1;
            else
              return {
                val: this.message.slice(n.offset, this.offset()),
                err: null
              };
            break;
          }
          default:
            this.bump();
            break;
        }
      }
      return {
        val: this.message.slice(n.offset, this.offset()),
        err: null
      };
    }, t.prototype.parseNumberSkeletonFromString = function(e, n) {
      var i = [];
      try {
        i = Gd(e);
      } catch {
        return this.error(P.INVALID_NUMBER_SKELETON, n);
      }
      return {
        val: {
          type: sn.number,
          tokens: i,
          location: n,
          parsedOptions: this.shouldParseSkeletons ? xd(i) : {}
        },
        err: null
      };
    }, t.prototype.tryParsePluralOrSelectOptions = function(e, n, i, r) {
      for (var a, s = !1, l = [], o = /* @__PURE__ */ new Set(), u = r.value, f = r.location; ; ) {
        if (u.length === 0) {
          var h = this.clonePosition();
          if (n !== "select" && this.bumpIf("=")) {
            var c = this.tryParseDecimalInteger(P.EXPECT_PLURAL_ARGUMENT_SELECTOR, P.INVALID_PLURAL_ARGUMENT_SELECTOR);
            if (c.err)
              return c;
            f = F(h, this.clonePosition()), u = this.message.slice(h.offset, this.offset());
          } else
            break;
        }
        if (o.has(u))
          return this.error(n === "select" ? P.DUPLICATE_SELECT_ARGUMENT_SELECTOR : P.DUPLICATE_PLURAL_ARGUMENT_SELECTOR, f);
        u === "other" && (s = !0), this.bumpSpace();
        var d = this.clonePosition();
        if (!this.bumpIf("{"))
          return this.error(n === "select" ? P.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT : P.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT, F(this.clonePosition(), this.clonePosition()));
        var _ = this.parseMessage(e + 1, n, i);
        if (_.err)
          return _;
        var m = this.tryParseArgumentClose(d);
        if (m.err)
          return m;
        l.push([
          u,
          {
            value: _.val,
            location: F(d, this.clonePosition())
          }
        ]), o.add(u), this.bumpSpace(), a = this.parseIdentifierIfPossible(), u = a.value, f = a.location;
      }
      return l.length === 0 ? this.error(n === "select" ? P.EXPECT_SELECT_ARGUMENT_SELECTOR : P.EXPECT_PLURAL_ARGUMENT_SELECTOR, F(this.clonePosition(), this.clonePosition())) : this.requiresOtherClause && !s ? this.error(P.MISSING_OTHER_CLAUSE, F(this.clonePosition(), this.clonePosition())) : { val: l, err: null };
    }, t.prototype.tryParseDecimalInteger = function(e, n) {
      var i = 1, r = this.clonePosition();
      this.bumpIf("+") || this.bumpIf("-") && (i = -1);
      for (var a = !1, s = 0; !this.isEOF(); ) {
        var l = this.char();
        if (l >= 48 && l <= 57)
          a = !0, s = s * 10 + (l - 48), this.bump();
        else
          break;
      }
      var o = F(r, this.clonePosition());
      return a ? (s *= i, n_(s) ? { val: s, err: null } : this.error(n, o)) : this.error(e, o);
    }, t.prototype.offset = function() {
      return this.position.offset;
    }, t.prototype.isEOF = function() {
      return this.offset() === this.message.length;
    }, t.prototype.clonePosition = function() {
      return {
        offset: this.position.offset,
        line: this.position.line,
        column: this.position.column
      };
    }, t.prototype.char = function() {
      var e = this.position.offset;
      if (e >= this.message.length)
        throw Error("out of bound");
      var n = Tl(this.message, e);
      if (n === void 0)
        throw Error("Offset ".concat(e, " is at invalid UTF-16 code unit boundary"));
      return n;
    }, t.prototype.error = function(e, n) {
      return {
        val: null,
        err: {
          kind: e,
          message: this.message,
          location: n
        }
      };
    }, t.prototype.bump = function() {
      if (!this.isEOF()) {
        var e = this.char();
        e === 10 ? (this.position.line += 1, this.position.column = 1, this.position.offset += 1) : (this.position.column += 1, this.position.offset += e < 65536 ? 1 : 2);
      }
    }, t.prototype.bumpIf = function(e) {
      if (Bs(this.message, e, this.offset())) {
        for (var n = 0; n < e.length; n++)
          this.bump();
        return !0;
      }
      return !1;
    }, t.prototype.bumpUntil = function(e) {
      var n = this.offset(), i = this.message.indexOf(e, n);
      return i >= 0 ? (this.bumpTo(i), !0) : (this.bumpTo(this.message.length), !1);
    }, t.prototype.bumpTo = function(e) {
      if (this.offset() > e)
        throw Error("targetOffset ".concat(e, " must be greater than or equal to the current offset ").concat(this.offset()));
      for (e = Math.min(e, this.message.length); ; ) {
        var n = this.offset();
        if (n === e)
          break;
        if (n > e)
          throw Error("targetOffset ".concat(e, " is at invalid UTF-16 code unit boundary"));
        if (this.bump(), this.isEOF())
          break;
      }
    }, t.prototype.bumpSpace = function() {
      for (; !this.isEOF() && Cl(this.char()); )
        this.bump();
    }, t.prototype.peek = function() {
      if (this.isEOF())
        return null;
      var e = this.char(), n = this.offset(), i = this.message.charCodeAt(n + (e >= 65536 ? 2 : 1));
      return i ?? null;
    }, t;
  }()
);
function Vr(t) {
  return t >= 97 && t <= 122 || t >= 65 && t <= 90;
}
function o_(t) {
  return Vr(t) || t === 47;
}
function l_(t) {
  return t === 45 || t === 46 || t >= 48 && t <= 57 || t === 95 || t >= 97 && t <= 122 || t >= 65 && t <= 90 || t == 183 || t >= 192 && t <= 214 || t >= 216 && t <= 246 || t >= 248 && t <= 893 || t >= 895 && t <= 8191 || t >= 8204 && t <= 8205 || t >= 8255 && t <= 8256 || t >= 8304 && t <= 8591 || t >= 11264 && t <= 12271 || t >= 12289 && t <= 55295 || t >= 63744 && t <= 64975 || t >= 65008 && t <= 65533 || t >= 65536 && t <= 983039;
}
function Cl(t) {
  return t >= 9 && t <= 13 || t === 32 || t === 133 || t >= 8206 && t <= 8207 || t === 8232 || t === 8233;
}
function u_(t) {
  return t >= 33 && t <= 35 || t === 36 || t >= 37 && t <= 39 || t === 40 || t === 41 || t === 42 || t === 43 || t === 44 || t === 45 || t >= 46 && t <= 47 || t >= 58 && t <= 59 || t >= 60 && t <= 62 || t >= 63 && t <= 64 || t === 91 || t === 92 || t === 93 || t === 94 || t === 96 || t === 123 || t === 124 || t === 125 || t === 126 || t === 161 || t >= 162 && t <= 165 || t === 166 || t === 167 || t === 169 || t === 171 || t === 172 || t === 174 || t === 176 || t === 177 || t === 182 || t === 187 || t === 191 || t === 215 || t === 247 || t >= 8208 && t <= 8213 || t >= 8214 && t <= 8215 || t === 8216 || t === 8217 || t === 8218 || t >= 8219 && t <= 8220 || t === 8221 || t === 8222 || t === 8223 || t >= 8224 && t <= 8231 || t >= 8240 && t <= 8248 || t === 8249 || t === 8250 || t >= 8251 && t <= 8254 || t >= 8257 && t <= 8259 || t === 8260 || t === 8261 || t === 8262 || t >= 8263 && t <= 8273 || t === 8274 || t === 8275 || t >= 8277 && t <= 8286 || t >= 8592 && t <= 8596 || t >= 8597 && t <= 8601 || t >= 8602 && t <= 8603 || t >= 8604 && t <= 8607 || t === 8608 || t >= 8609 && t <= 8610 || t === 8611 || t >= 8612 && t <= 8613 || t === 8614 || t >= 8615 && t <= 8621 || t === 8622 || t >= 8623 && t <= 8653 || t >= 8654 && t <= 8655 || t >= 8656 && t <= 8657 || t === 8658 || t === 8659 || t === 8660 || t >= 8661 && t <= 8691 || t >= 8692 && t <= 8959 || t >= 8960 && t <= 8967 || t === 8968 || t === 8969 || t === 8970 || t === 8971 || t >= 8972 && t <= 8991 || t >= 8992 && t <= 8993 || t >= 8994 && t <= 9e3 || t === 9001 || t === 9002 || t >= 9003 && t <= 9083 || t === 9084 || t >= 9085 && t <= 9114 || t >= 9115 && t <= 9139 || t >= 9140 && t <= 9179 || t >= 9180 && t <= 9185 || t >= 9186 && t <= 9254 || t >= 9255 && t <= 9279 || t >= 9280 && t <= 9290 || t >= 9291 && t <= 9311 || t >= 9472 && t <= 9654 || t === 9655 || t >= 9656 && t <= 9664 || t === 9665 || t >= 9666 && t <= 9719 || t >= 9720 && t <= 9727 || t >= 9728 && t <= 9838 || t === 9839 || t >= 9840 && t <= 10087 || t === 10088 || t === 10089 || t === 10090 || t === 10091 || t === 10092 || t === 10093 || t === 10094 || t === 10095 || t === 10096 || t === 10097 || t === 10098 || t === 10099 || t === 10100 || t === 10101 || t >= 10132 && t <= 10175 || t >= 10176 && t <= 10180 || t === 10181 || t === 10182 || t >= 10183 && t <= 10213 || t === 10214 || t === 10215 || t === 10216 || t === 10217 || t === 10218 || t === 10219 || t === 10220 || t === 10221 || t === 10222 || t === 10223 || t >= 10224 && t <= 10239 || t >= 10240 && t <= 10495 || t >= 10496 && t <= 10626 || t === 10627 || t === 10628 || t === 10629 || t === 10630 || t === 10631 || t === 10632 || t === 10633 || t === 10634 || t === 10635 || t === 10636 || t === 10637 || t === 10638 || t === 10639 || t === 10640 || t === 10641 || t === 10642 || t === 10643 || t === 10644 || t === 10645 || t === 10646 || t === 10647 || t === 10648 || t >= 10649 && t <= 10711 || t === 10712 || t === 10713 || t === 10714 || t === 10715 || t >= 10716 && t <= 10747 || t === 10748 || t === 10749 || t >= 10750 && t <= 11007 || t >= 11008 && t <= 11055 || t >= 11056 && t <= 11076 || t >= 11077 && t <= 11078 || t >= 11079 && t <= 11084 || t >= 11085 && t <= 11123 || t >= 11124 && t <= 11125 || t >= 11126 && t <= 11157 || t === 11158 || t >= 11159 && t <= 11263 || t >= 11776 && t <= 11777 || t === 11778 || t === 11779 || t === 11780 || t === 11781 || t >= 11782 && t <= 11784 || t === 11785 || t === 11786 || t === 11787 || t === 11788 || t === 11789 || t >= 11790 && t <= 11798 || t === 11799 || t >= 11800 && t <= 11801 || t === 11802 || t === 11803 || t === 11804 || t === 11805 || t >= 11806 && t <= 11807 || t === 11808 || t === 11809 || t === 11810 || t === 11811 || t === 11812 || t === 11813 || t === 11814 || t === 11815 || t === 11816 || t === 11817 || t >= 11818 && t <= 11822 || t === 11823 || t >= 11824 && t <= 11833 || t >= 11834 && t <= 11835 || t >= 11836 && t <= 11839 || t === 11840 || t === 11841 || t === 11842 || t >= 11843 && t <= 11855 || t >= 11856 && t <= 11857 || t === 11858 || t >= 11859 && t <= 11903 || t >= 12289 && t <= 12291 || t === 12296 || t === 12297 || t === 12298 || t === 12299 || t === 12300 || t === 12301 || t === 12302 || t === 12303 || t === 12304 || t === 12305 || t >= 12306 && t <= 12307 || t === 12308 || t === 12309 || t === 12310 || t === 12311 || t === 12312 || t === 12313 || t === 12314 || t === 12315 || t === 12316 || t === 12317 || t >= 12318 && t <= 12319 || t === 12320 || t === 12336 || t === 64830 || t === 64831 || t >= 65093 && t <= 65094;
}
function Wr(t) {
  t.forEach(function(e) {
    if (delete e.location, gl(e) || pl(e))
      for (var n in e.options)
        delete e.options[n].location, Wr(e.options[n].value);
    else
      dl(e) && vl(e.style) || (_l(e) || ml(e)) && jr(e.style) ? delete e.style.location : bl(e) && Wr(e.children);
  });
}
function f_(t, e) {
  e === void 0 && (e = {}), e = X({ shouldParseSkeletons: !0, requiresOtherClause: !0 }, e);
  var n = new s_(t, e).parse();
  if (n.err) {
    var i = SyntaxError(P[n.err.kind]);
    throw i.location = n.err.location, i.originalMessage = n.err.message, i;
  }
  return e != null && e.captureLocation || Wr(n.val), n.val;
}
function br(t, e) {
  var n = e && e.cache ? e.cache : g_, i = e && e.serializer ? e.serializer : m_, r = e && e.strategy ? e.strategy : c_;
  return r(t, {
    cache: n,
    serializer: i
  });
}
function h_(t) {
  return t == null || typeof t == "number" || typeof t == "boolean";
}
function Ml(t, e, n, i) {
  var r = h_(i) ? i : n(i), a = e.get(r);
  return typeof a > "u" && (a = t.call(this, i), e.set(r, a)), a;
}
function Al(t, e, n) {
  var i = Array.prototype.slice.call(arguments, 3), r = n(i), a = e.get(r);
  return typeof a > "u" && (a = t.apply(this, i), e.set(r, a)), a;
}
function ma(t, e, n, i, r) {
  return n.bind(e, t, i, r);
}
function c_(t, e) {
  var n = t.length === 1 ? Ml : Al;
  return ma(t, this, n, e.cache.create(), e.serializer);
}
function d_(t, e) {
  return ma(t, this, Al, e.cache.create(), e.serializer);
}
function __(t, e) {
  return ma(t, this, Ml, e.cache.create(), e.serializer);
}
var m_ = function() {
  return JSON.stringify(arguments);
};
function ga() {
  this.cache = /* @__PURE__ */ Object.create(null);
}
ga.prototype.get = function(t) {
  return this.cache[t];
};
ga.prototype.set = function(t, e) {
  this.cache[t] = e;
};
var g_ = {
  create: function() {
    return new ga();
  }
}, vr = {
  variadic: d_,
  monadic: __
}, on;
(function(t) {
  t.MISSING_VALUE = "MISSING_VALUE", t.INVALID_VALUE = "INVALID_VALUE", t.MISSING_INTL_API = "MISSING_INTL_API";
})(on || (on = {}));
var Hi = (
  /** @class */
  function(t) {
    Bi(e, t);
    function e(n, i, r) {
      var a = t.call(this, n) || this;
      return a.code = i, a.originalMessage = r, a;
    }
    return e.prototype.toString = function() {
      return "[formatjs Error: ".concat(this.code, "] ").concat(this.message);
    }, e;
  }(Error)
), Is = (
  /** @class */
  function(t) {
    Bi(e, t);
    function e(n, i, r, a) {
      return t.call(this, 'Invalid values for "'.concat(n, '": "').concat(i, '". Options are "').concat(Object.keys(r).join('", "'), '"'), on.INVALID_VALUE, a) || this;
    }
    return e;
  }(Hi)
), p_ = (
  /** @class */
  function(t) {
    Bi(e, t);
    function e(n, i, r) {
      return t.call(this, 'Value for "'.concat(n, '" must be of type ').concat(i), on.INVALID_VALUE, r) || this;
    }
    return e;
  }(Hi)
), b_ = (
  /** @class */
  function(t) {
    Bi(e, t);
    function e(n, i) {
      return t.call(this, 'The intl string context variable "'.concat(n, '" was not provided to the string "').concat(i, '"'), on.MISSING_VALUE, i) || this;
    }
    return e;
  }(Hi)
), ve;
(function(t) {
  t[t.literal = 0] = "literal", t[t.object = 1] = "object";
})(ve || (ve = {}));
function v_(t) {
  return t.length < 2 ? t : t.reduce(function(e, n) {
    var i = e[e.length - 1];
    return !i || i.type !== ve.literal || n.type !== ve.literal ? e.push(n) : i.value += n.value, e;
  }, []);
}
function w_(t) {
  return typeof t == "function";
}
function _i(t, e, n, i, r, a, s) {
  if (t.length === 1 && Ms(t[0]))
    return [
      {
        type: ve.literal,
        value: t[0].value
      }
    ];
  for (var l = [], o = 0, u = t; o < u.length; o++) {
    var f = u[o];
    if (Ms(f)) {
      l.push({
        type: ve.literal,
        value: f.value
      });
      continue;
    }
    if (Ld(f)) {
      typeof a == "number" && l.push({
        type: ve.literal,
        value: n.getNumberFormat(e).format(a)
      });
      continue;
    }
    var h = f.value;
    if (!(r && h in r))
      throw new b_(h, s);
    var c = r[h];
    if (Rd(f)) {
      (!c || typeof c == "string" || typeof c == "number") && (c = typeof c == "string" || typeof c == "number" ? String(c) : ""), l.push({
        type: typeof c == "string" ? ve.literal : ve.object,
        value: c
      });
      continue;
    }
    if (_l(f)) {
      var d = typeof f.style == "string" ? i.date[f.style] : jr(f.style) ? f.style.parsedOptions : void 0;
      l.push({
        type: ve.literal,
        value: n.getDateTimeFormat(e, d).format(c)
      });
      continue;
    }
    if (ml(f)) {
      var d = typeof f.style == "string" ? i.time[f.style] : jr(f.style) ? f.style.parsedOptions : i.time.medium;
      l.push({
        type: ve.literal,
        value: n.getDateTimeFormat(e, d).format(c)
      });
      continue;
    }
    if (dl(f)) {
      var d = typeof f.style == "string" ? i.number[f.style] : vl(f.style) ? f.style.parsedOptions : void 0;
      d && d.scale && (c = c * (d.scale || 1)), l.push({
        type: ve.literal,
        value: n.getNumberFormat(e, d).format(c)
      });
      continue;
    }
    if (bl(f)) {
      var _ = f.children, m = f.value, b = r[m];
      if (!w_(b))
        throw new p_(m, "function", s);
      var C = _i(_, e, n, i, r, a), T = b(C.map(function(p) {
        return p.value;
      }));
      Array.isArray(T) || (T = [T]), l.push.apply(l, T.map(function(p) {
        return {
          type: typeof p == "string" ? ve.literal : ve.object,
          value: p
        };
      }));
    }
    if (gl(f)) {
      var y = f.options[c] || f.options.other;
      if (!y)
        throw new Is(f.value, c, Object.keys(f.options), s);
      l.push.apply(l, _i(y.value, e, n, i, r));
      continue;
    }
    if (pl(f)) {
      var y = f.options["=".concat(c)];
      if (!y) {
        if (!Intl.PluralRules)
          throw new Hi(`Intl.PluralRules is not available in this environment.
Try polyfilling it using "@formatjs/intl-pluralrules"
`, on.MISSING_INTL_API, s);
        var S = n.getPluralRules(e, { type: f.pluralType }).select(c - (f.offset || 0));
        y = f.options[S] || f.options.other;
      }
      if (!y)
        throw new Is(f.value, c, Object.keys(f.options), s);
      l.push.apply(l, _i(y.value, e, n, i, r, c - (f.offset || 0)));
      continue;
    }
  }
  return v_(l);
}
function y_(t, e) {
  return e ? X(X(X({}, t || {}), e || {}), Object.keys(t).reduce(function(n, i) {
    return n[i] = X(X({}, t[i]), e[i] || {}), n;
  }, {})) : t;
}
function E_(t, e) {
  return e ? Object.keys(t).reduce(function(n, i) {
    return n[i] = y_(t[i], e[i]), n;
  }, X({}, t)) : t;
}
function wr(t) {
  return {
    create: function() {
      return {
        get: function(e) {
          return t[e];
        },
        set: function(e, n) {
          t[e] = n;
        }
      };
    }
  };
}
function k_(t) {
  return t === void 0 && (t = {
    number: {},
    dateTime: {},
    pluralRules: {}
  }), {
    getNumberFormat: br(function() {
      for (var e, n = [], i = 0; i < arguments.length; i++)
        n[i] = arguments[i];
      return new ((e = Intl.NumberFormat).bind.apply(e, gr([void 0], n, !1)))();
    }, {
      cache: wr(t.number),
      strategy: vr.variadic
    }),
    getDateTimeFormat: br(function() {
      for (var e, n = [], i = 0; i < arguments.length; i++)
        n[i] = arguments[i];
      return new ((e = Intl.DateTimeFormat).bind.apply(e, gr([void 0], n, !1)))();
    }, {
      cache: wr(t.dateTime),
      strategy: vr.variadic
    }),
    getPluralRules: br(function() {
      for (var e, n = [], i = 0; i < arguments.length; i++)
        n[i] = arguments[i];
      return new ((e = Intl.PluralRules).bind.apply(e, gr([void 0], n, !1)))();
    }, {
      cache: wr(t.pluralRules),
      strategy: vr.variadic
    })
  };
}
var T_ = (
  /** @class */
  function() {
    function t(e, n, i, r) {
      var a = this;
      if (n === void 0 && (n = t.defaultLocale), this.formatterCache = {
        number: {},
        dateTime: {},
        pluralRules: {}
      }, this.format = function(s) {
        var l = a.formatToParts(s);
        if (l.length === 1)
          return l[0].value;
        var o = l.reduce(function(u, f) {
          return !u.length || f.type !== ve.literal || typeof u[u.length - 1] != "string" ? u.push(f.value) : u[u.length - 1] += f.value, u;
        }, []);
        return o.length <= 1 ? o[0] || "" : o;
      }, this.formatToParts = function(s) {
        return _i(a.ast, a.locales, a.formatters, a.formats, s, void 0, a.message);
      }, this.resolvedOptions = function() {
        return {
          locale: a.resolvedLocale.toString()
        };
      }, this.getAst = function() {
        return a.ast;
      }, this.locales = n, this.resolvedLocale = t.resolveLocale(n), typeof e == "string") {
        if (this.message = e, !t.__parse)
          throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");
        this.ast = t.__parse(e, {
          ignoreTag: r == null ? void 0 : r.ignoreTag,
          locale: this.resolvedLocale
        });
      } else
        this.ast = e;
      if (!Array.isArray(this.ast))
        throw new TypeError("A message must be provided as a String or AST.");
      this.formats = E_(t.formats, i), this.formatters = r && r.formatters || k_(this.formatterCache);
    }
    return Object.defineProperty(t, "defaultLocale", {
      get: function() {
        return t.memoizedDefaultLocale || (t.memoizedDefaultLocale = new Intl.NumberFormat().resolvedOptions().locale), t.memoizedDefaultLocale;
      },
      enumerable: !1,
      configurable: !0
    }), t.memoizedDefaultLocale = null, t.resolveLocale = function(e) {
      var n = Intl.NumberFormat.supportedLocalesOf(e);
      return n.length > 0 ? new Intl.Locale(n[0]) : new Intl.Locale(typeof e == "string" ? e : e[0]);
    }, t.__parse = f_, t.formats = {
      number: {
        integer: {
          maximumFractionDigits: 0
        },
        currency: {
          style: "currency"
        },
        percent: {
          style: "percent"
        }
      },
      date: {
        short: {
          month: "numeric",
          day: "numeric",
          year: "2-digit"
        },
        medium: {
          month: "short",
          day: "numeric",
          year: "numeric"
        },
        long: {
          month: "long",
          day: "numeric",
          year: "numeric"
        },
        full: {
          weekday: "long",
          month: "long",
          day: "numeric",
          year: "numeric"
        }
      },
      time: {
        short: {
          hour: "numeric",
          minute: "numeric"
        },
        medium: {
          hour: "numeric",
          minute: "numeric",
          second: "numeric"
        },
        long: {
          hour: "numeric",
          minute: "numeric",
          second: "numeric",
          timeZoneName: "short"
        },
        full: {
          hour: "numeric",
          minute: "numeric",
          second: "numeric",
          timeZoneName: "short"
        }
      }
    }, t;
  }()
);
function S_(t, e) {
  if (e == null)
    return;
  if (e in t)
    return t[e];
  const n = e.split(".");
  let i = t;
  for (let r = 0; r < n.length; r++)
    if (typeof i == "object") {
      if (r > 0) {
        const a = n.slice(r, n.length).join(".");
        if (a in i) {
          i = i[a];
          break;
        }
      }
      i = i[n[r]];
    } else
      i = void 0;
  return i;
}
const gt = {}, C_ = (t, e, n) => n && (e in gt || (gt[e] = {}), t in gt[e] || (gt[e][t] = n), n), Ol = (t, e) => {
  if (e == null)
    return;
  if (e in gt && t in gt[e])
    return gt[e][t];
  const n = Ni(e);
  for (let i = 0; i < n.length; i++) {
    const r = n[i], a = A_(r, t);
    if (a)
      return C_(t, e, a);
  }
};
let pa;
const Un = Pn({});
function M_(t) {
  return pa[t] || null;
}
function Dl(t) {
  return t in pa;
}
function A_(t, e) {
  if (!Dl(t))
    return null;
  const n = M_(t);
  return S_(n, e);
}
function O_(t) {
  if (t == null)
    return;
  const e = Ni(t);
  for (let n = 0; n < e.length; n++) {
    const i = e[n];
    if (Dl(i))
      return i;
  }
}
function D_(t, ...e) {
  delete gt[t], Un.update((n) => (n[t] = Id.all([n[t] || {}, ...e]), n));
}
dn(
  [Un],
  ([t]) => Object.keys(t)
);
Un.subscribe((t) => pa = t);
const mi = {};
function B_(t, e) {
  mi[t].delete(e), mi[t].size === 0 && delete mi[t];
}
function Bl(t) {
  return mi[t];
}
function H_(t) {
  return Ni(t).map((e) => {
    const n = Bl(e);
    return [e, n ? [...n] : []];
  }).filter(([, e]) => e.length > 0);
}
function Yr(t) {
  return t == null ? !1 : Ni(t).some(
    (e) => {
      var n;
      return (n = Bl(e)) == null ? void 0 : n.size;
    }
  );
}
function N_(t, e) {
  return Promise.all(
    e.map((i) => (B_(t, i), i().then((r) => r.default || r)))
  ).then((i) => D_(t, ...i));
}
const Cn = {};
function Hl(t) {
  if (!Yr(t))
    return t in Cn ? Cn[t] : Promise.resolve();
  const e = H_(t);
  return Cn[t] = Promise.all(
    e.map(
      ([n, i]) => N_(n, i)
    )
  ).then(() => {
    if (Yr(t))
      return Hl(t);
    delete Cn[t];
  }), Cn[t];
}
const I_ = {
  number: {
    scientific: { notation: "scientific" },
    engineering: { notation: "engineering" },
    compactLong: { notation: "compact", compactDisplay: "long" },
    compactShort: { notation: "compact", compactDisplay: "short" }
  },
  date: {
    short: { month: "numeric", day: "numeric", year: "2-digit" },
    medium: { month: "short", day: "numeric", year: "numeric" },
    long: { month: "long", day: "numeric", year: "numeric" },
    full: { weekday: "long", month: "long", day: "numeric", year: "numeric" }
  },
  time: {
    short: { hour: "numeric", minute: "numeric" },
    medium: { hour: "numeric", minute: "numeric", second: "numeric" },
    long: {
      hour: "numeric",
      minute: "numeric",
      second: "numeric",
      timeZoneName: "short"
    },
    full: {
      hour: "numeric",
      minute: "numeric",
      second: "numeric",
      timeZoneName: "short"
    }
  }
}, R_ = {
  fallbackLocale: null,
  loadingDelay: 200,
  formats: I_,
  warnOnMissingMessages: !0,
  handleMissingMessage: void 0,
  ignoreTag: !0
}, L_ = R_;
function ln() {
  return L_;
}
const yr = Pn(!1);
var P_ = Object.defineProperty, U_ = Object.defineProperties, F_ = Object.getOwnPropertyDescriptors, Rs = Object.getOwnPropertySymbols, G_ = Object.prototype.hasOwnProperty, z_ = Object.prototype.propertyIsEnumerable, Ls = (t, e, n) => e in t ? P_(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, j_ = (t, e) => {
  for (var n in e || (e = {}))
    G_.call(e, n) && Ls(t, n, e[n]);
  if (Rs)
    for (var n of Rs(e))
      z_.call(e, n) && Ls(t, n, e[n]);
  return t;
}, q_ = (t, e) => U_(t, F_(e));
let Zr;
const Ti = Pn(null);
function Ps(t) {
  return t.split("-").map((e, n, i) => i.slice(0, n + 1).join("-")).reverse();
}
function Ni(t, e = ln().fallbackLocale) {
  const n = Ps(t);
  return e ? [.../* @__PURE__ */ new Set([...n, ...Ps(e)])] : n;
}
function Pt() {
  return Zr ?? void 0;
}
Ti.subscribe((t) => {
  Zr = t ?? void 0, typeof window < "u" && t != null && document.documentElement.setAttribute("lang", t);
});
const x_ = (t) => {
  if (t && O_(t) && Yr(t)) {
    const { loadingDelay: e } = ln();
    let n;
    return typeof window < "u" && Pt() != null && e ? n = window.setTimeout(
      () => yr.set(!0),
      e
    ) : yr.set(!0), Hl(t).then(() => {
      Ti.set(t);
    }).finally(() => {
      clearTimeout(n), yr.set(!1);
    });
  }
  return Ti.set(t);
}, Fn = q_(j_({}, Ti), {
  set: x_
}), Ii = (t) => {
  const e = /* @__PURE__ */ Object.create(null);
  return (i) => {
    const r = JSON.stringify(i);
    return r in e ? e[r] : e[r] = t(i);
  };
};
var X_ = Object.defineProperty, Si = Object.getOwnPropertySymbols, Nl = Object.prototype.hasOwnProperty, Il = Object.prototype.propertyIsEnumerable, Us = (t, e, n) => e in t ? X_(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, ba = (t, e) => {
  for (var n in e || (e = {}))
    Nl.call(e, n) && Us(t, n, e[n]);
  if (Si)
    for (var n of Si(e))
      Il.call(e, n) && Us(t, n, e[n]);
  return t;
}, _n = (t, e) => {
  var n = {};
  for (var i in t)
    Nl.call(t, i) && e.indexOf(i) < 0 && (n[i] = t[i]);
  if (t != null && Si)
    for (var i of Si(t))
      e.indexOf(i) < 0 && Il.call(t, i) && (n[i] = t[i]);
  return n;
};
const Rn = (t, e) => {
  const { formats: n } = ln();
  if (t in n && e in n[t])
    return n[t][e];
  throw new Error(`[svelte-i18n] Unknown "${e}" ${t} format.`);
}, V_ = Ii(
  (t) => {
    var e = t, { locale: n, format: i } = e, r = _n(e, ["locale", "format"]);
    if (n == null)
      throw new Error('[svelte-i18n] A "locale" must be set to format numbers');
    return i && (r = Rn("number", i)), new Intl.NumberFormat(n, r);
  }
), W_ = Ii(
  (t) => {
    var e = t, { locale: n, format: i } = e, r = _n(e, ["locale", "format"]);
    if (n == null)
      throw new Error('[svelte-i18n] A "locale" must be set to format dates');
    return i ? r = Rn("date", i) : Object.keys(r).length === 0 && (r = Rn("date", "short")), new Intl.DateTimeFormat(n, r);
  }
), Y_ = Ii(
  (t) => {
    var e = t, { locale: n, format: i } = e, r = _n(e, ["locale", "format"]);
    if (n == null)
      throw new Error(
        '[svelte-i18n] A "locale" must be set to format time values'
      );
    return i ? r = Rn("time", i) : Object.keys(r).length === 0 && (r = Rn("time", "short")), new Intl.DateTimeFormat(n, r);
  }
), Z_ = (t = {}) => {
  var e = t, {
    locale: n = Pt()
  } = e, i = _n(e, [
    "locale"
  ]);
  return V_(ba({ locale: n }, i));
}, Q_ = (t = {}) => {
  var e = t, {
    locale: n = Pt()
  } = e, i = _n(e, [
    "locale"
  ]);
  return W_(ba({ locale: n }, i));
}, J_ = (t = {}) => {
  var e = t, {
    locale: n = Pt()
  } = e, i = _n(e, [
    "locale"
  ]);
  return Y_(ba({ locale: n }, i));
}, K_ = Ii(
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
  (t, e = Pt()) => new T_(t, e, ln().formats, {
    ignoreTag: ln().ignoreTag
  })
), $_ = (t, e = {}) => {
  var n, i, r, a;
  let s = e;
  typeof t == "object" && (s = t, t = s.id);
  const {
    values: l,
    locale: o = Pt(),
    default: u
  } = s;
  if (o == null)
    throw new Error(
      "[svelte-i18n] Cannot format a message without first setting the initial locale."
    );
  let f = Ol(t, o);
  if (!f)
    f = (a = (r = (i = (n = ln()).handleMissingMessage) == null ? void 0 : i.call(n, { locale: o, id: t, defaultValue: u })) != null ? r : u) != null ? a : t;
  else if (typeof f != "string")
    return console.warn(
      `[svelte-i18n] Message with id "${t}" must be of type "string", found: "${typeof f}". Gettin its value through the "$format" method is deprecated; use the "json" method instead.`
    ), f;
  if (!l)
    return f;
  let h = f;
  try {
    h = K_(f, o).format(l);
  } catch (c) {
    c instanceof Error && console.warn(
      `[svelte-i18n] Message "${t}" has syntax error:`,
      c.message
    );
  }
  return h;
}, em = (t, e) => J_(e).format(t), tm = (t, e) => Q_(e).format(t), nm = (t, e) => Z_(e).format(t), im = (t, e = Pt()) => Ol(t, e), rm = dn([Fn, Un], () => $_);
dn([Fn], () => em);
dn([Fn], () => tm);
dn([Fn], () => nm);
dn([Fn, Un], () => im);
const {
  SvelteComponent: am,
  append: Fs,
  attr: un,
  binding_callbacks: sm,
  check_outros: va,
  component_subscribe: om,
  create_component: wa,
  destroy_component: ya,
  detach: mn,
  element: fn,
  empty: lm,
  group_outros: Ea,
  init: um,
  insert: gn,
  is_function: fm,
  listen: hm,
  mount_component: ka,
  noop: cm,
  safe_not_equal: dm,
  space: _m,
  toggle_class: Gs,
  transition_in: Ke,
  transition_out: at
} = window.__gradio__svelte__internal, { createEventDispatcher: mm, onMount: gm } = window.__gradio__svelte__internal;
function zs(t) {
  let e, n, i, r, a, s;
  const l = [bm, pm], o = [];
  function u(f, h) {
    return (
      /*mode*/
      f[1] === "video" ? 0 : 1
    );
  }
  return n = u(t), i = o[n] = l[n](t), {
    c() {
      e = fn("button"), i.c(), un(e, "class", "svelte-ji57xm");
    },
    m(f, h) {
      gn(f, e, h), o[n].m(e, null), r = !0, a || (s = hm(e, "click", function() {
        fm(
          /*mode*/
          t[1] === "image" ? (
            /*take_picture*/
            t[5]
          ) : (
            /*take_recording*/
            t[6]
          )
        ) && /*mode*/
        (t[1] === "image" ? (
          /*take_picture*/
          t[5]
        ) : (
          /*take_recording*/
          t[6]
        )).apply(this, arguments);
      }), a = !0);
    },
    p(f, h) {
      t = f;
      let c = n;
      n = u(t), n === c ? o[n].p(t, h) : (Ea(), at(o[c], 1, 1, () => {
        o[c] = null;
      }), va(), i = o[n], i ? i.p(t, h) : (i = o[n] = l[n](t), i.c()), Ke(i, 1), i.m(e, null));
    },
    i(f) {
      r || (Ke(i), r = !0);
    },
    o(f) {
      at(i), r = !1;
    },
    d(f) {
      f && mn(e), o[n].d(), a = !1, s();
    }
  };
}
function pm(t) {
  let e, n, i;
  return n = new bf({}), {
    c() {
      e = fn("div"), wa(n.$$.fragment), un(e, "class", "icon svelte-ji57xm");
    },
    m(r, a) {
      gn(r, e, a), ka(n, e, null), i = !0;
    },
    p: cm,
    i(r) {
      i || (Ke(n.$$.fragment, r), i = !0);
    },
    o(r) {
      at(n.$$.fragment, r), i = !1;
    },
    d(r) {
      r && mn(e), ya(n);
    }
  };
}
function bm(t) {
  let e, n, i, r;
  const a = [wm, vm], s = [];
  function l(o, u) {
    return (
      /*recording*/
      o[4] ? 0 : 1
    );
  }
  return e = l(t), n = s[e] = a[e](t), {
    c() {
      n.c(), i = lm();
    },
    m(o, u) {
      s[e].m(o, u), gn(o, i, u), r = !0;
    },
    p(o, u) {
      let f = e;
      e = l(o), e !== f && (Ea(), at(s[f], 1, 1, () => {
        s[f] = null;
      }), va(), n = s[e], n || (n = s[e] = a[e](o), n.c()), Ke(n, 1), n.m(i.parentNode, i));
    },
    i(o) {
      r || (Ke(n), r = !0);
    },
    o(o) {
      at(n), r = !1;
    },
    d(o) {
      o && mn(i), s[e].d(o);
    }
  };
}
function vm(t) {
  let e, n, i;
  return n = new Cf({}), {
    c() {
      e = fn("div"), wa(n.$$.fragment), un(e, "class", "icon svelte-ji57xm");
    },
    m(r, a) {
      gn(r, e, a), ka(n, e, null), i = !0;
    },
    i(r) {
      i || (Ke(n.$$.fragment, r), i = !0);
    },
    o(r) {
      at(n.$$.fragment, r), i = !1;
    },
    d(r) {
      r && mn(e), ya(n);
    }
  };
}
function wm(t) {
  let e, n, i;
  return n = new Uh({}), {
    c() {
      e = fn("div"), wa(n.$$.fragment), un(e, "class", "icon svelte-ji57xm");
    },
    m(r, a) {
      gn(r, e, a), ka(n, e, null), i = !0;
    },
    i(r) {
      i || (Ke(n.$$.fragment, r), i = !0);
    },
    o(r) {
      at(n.$$.fragment, r), i = !1;
    },
    d(r) {
      r && mn(e), ya(n);
    }
  };
}
function ym(t) {
  let e, n, i, r, a = !/*streaming*/
  t[0] && zs(t);
  return {
    c() {
      e = fn("div"), n = fn("video"), i = _m(), a && a.c(), un(n, "class", "svelte-ji57xm"), Gs(
        n,
        "flip",
        /*mirror_webcam*/
        t[2]
      ), un(e, "class", "wrap svelte-ji57xm");
    },
    m(s, l) {
      gn(s, e, l), Fs(e, n), t[9](n), Fs(e, i), a && a.m(e, null), r = !0;
    },
    p(s, [l]) {
      (!r || l & /*mirror_webcam*/
      4) && Gs(
        n,
        "flip",
        /*mirror_webcam*/
        s[2]
      ), /*streaming*/
      s[0] ? a && (Ea(), at(a, 1, 1, () => {
        a = null;
      }), va()) : a ? (a.p(s, l), l & /*streaming*/
      1 && Ke(a, 1)) : (a = zs(s), a.c(), Ke(a, 1), a.m(e, null));
    },
    i(s) {
      r || (Ke(a), r = !0);
    },
    o(s) {
      at(a), r = !1;
    },
    d(s) {
      s && mn(e), t[9](null), a && a.d();
    }
  };
}
function Em(t, e, n) {
  let i;
  om(t, rm, (p) => n(15, i = p));
  let r, a, { streaming: s = !1 } = e, { pending: l = !1 } = e, { mode: o = "image" } = e, { mirror_webcam: u } = e, { include_audio: f } = e;
  const h = mm();
  gm(() => a = document.createElement("canvas"));
  async function c() {
    try {
      b = await navigator.mediaDevices.getUserMedia({ video: !0, audio: f }), n(3, r.srcObject = b, r), n(3, r.muted = !0, r), r.play();
    } catch (p) {
      if (p instanceof DOMException && p.name == "NotAllowedError")
        h("error", i("image.allow_webcam_access"));
      else
        throw p;
    }
  }
  function d() {
    var p = a.getContext("2d");
    if (r.videoWidth && r.videoHeight) {
      a.width = r.videoWidth, a.height = r.videoHeight, p.drawImage(r, 0, 0, r.videoWidth, r.videoHeight);
      var g = a.toDataURL("image/png");
      h(s ? "stream" : "capture", g);
    }
  }
  let _ = !1, m = [], b, C, T;
  function y() {
    if (_) {
      T.stop();
      let p = new Blob(m, { type: C }), g = new FileReader();
      g.onload = function(M) {
        M.target && (h("capture", {
          data: M.target.result,
          name: "sample." + C.substring(6),
          is_example: !1
        }), h("stop_recording"));
      }, g.readAsDataURL(p);
    } else {
      h("start_recording"), m = [];
      let p = ["video/webm", "video/mp4"];
      for (let g of p)
        if (MediaRecorder.isTypeSupported(g)) {
          C = g;
          break;
        }
      if (C === null) {
        console.error("No supported MediaRecorder mimeType");
        return;
      }
      T = new MediaRecorder(b, { mimeType: C }), T.addEventListener("dataavailable", function(g) {
        m.push(g.data);
      }), T.start(200);
    }
    n(4, _ = !_);
  }
  c(), s && o === "image" && window.setInterval(
    () => {
      r && !l && d();
    },
    500
  );
  function S(p) {
    sm[p ? "unshift" : "push"](() => {
      r = p, n(3, r);
    });
  }
  return t.$$set = (p) => {
    "streaming" in p && n(0, s = p.streaming), "pending" in p && n(7, l = p.pending), "mode" in p && n(1, o = p.mode), "mirror_webcam" in p && n(2, u = p.mirror_webcam), "include_audio" in p && n(8, f = p.include_audio);
  }, [
    s,
    o,
    u,
    r,
    _,
    d,
    y,
    l,
    f,
    S
  ];
}
class km extends am {
  constructor(e) {
    super(), um(this, e, Em, ym, dm, {
      streaming: 0,
      pending: 7,
      mode: 1,
      mirror_webcam: 2,
      include_audio: 8
    });
  }
}
const {
  SvelteComponent: Tm,
  append: js,
  attr: Sm,
  check_outros: Cm,
  create_component: Qr,
  destroy_component: Jr,
  detach: Mm,
  element: Am,
  group_outros: Om,
  init: Dm,
  insert: Bm,
  mount_component: Kr,
  noop: Hm,
  safe_not_equal: Nm,
  space: qs,
  transition_in: Yt,
  transition_out: An
} = window.__gradio__svelte__internal, { createEventDispatcher: Im } = window.__gradio__svelte__internal;
function xs(t) {
  let e, n;
  return e = new rt({ props: { Icon: ph, label: "Clear" } }), e.$on(
    "click",
    /*click_handler_1*/
    t[3]
  ), {
    c() {
      Qr(e.$$.fragment);
    },
    m(i, r) {
      Kr(e, i, r), n = !0;
    },
    p: Hm,
    i(i) {
      n || (Yt(e.$$.fragment, i), n = !0);
    },
    o(i) {
      An(e.$$.fragment, i), n = !1;
    },
    d(i) {
      Jr(e, i);
    }
  };
}
function Rm(t) {
  let e, n, i, r, a, s;
  n = new rt({ props: { Icon: Xh, label: "Undo" } }), n.$on(
    "click",
    /*click_handler*/
    t[2]
  );
  let l = (
    /*show_eraser*/
    t[0] && xs(t)
  );
  return a = new rt({
    props: { Icon: Fo, label: "Remove Image" }
  }), a.$on(
    "click",
    /*click_handler_2*/
    t[4]
  ), {
    c() {
      e = Am("div"), Qr(n.$$.fragment), i = qs(), l && l.c(), r = qs(), Qr(a.$$.fragment), Sm(e, "class", "svelte-1g74h68");
    },
    m(o, u) {
      Bm(o, e, u), Kr(n, e, null), js(e, i), l && l.m(e, null), js(e, r), Kr(a, e, null), s = !0;
    },
    p(o, [u]) {
      /*show_eraser*/
      o[0] ? l ? (l.p(o, u), u & /*show_eraser*/
      1 && Yt(l, 1)) : (l = xs(o), l.c(), Yt(l, 1), l.m(e, r)) : l && (Om(), An(l, 1, 1, () => {
        l = null;
      }), Cm());
    },
    i(o) {
      s || (Yt(n.$$.fragment, o), Yt(l), Yt(a.$$.fragment, o), s = !0);
    },
    o(o) {
      An(n.$$.fragment, o), An(l), An(a.$$.fragment, o), s = !1;
    },
    d(o) {
      o && Mm(e), Jr(n), l && l.d(), Jr(a);
    }
  };
}
function Lm(t, e, n) {
  const i = Im();
  let { show_eraser: r = !1 } = e;
  const a = () => i("undo"), s = (o) => {
    i("clear_mask"), o.stopPropagation();
  }, l = (o) => {
    i("remove_image"), o.stopPropagation();
  };
  return t.$$set = (o) => {
    "show_eraser" in o && n(0, r = o.show_eraser);
  }, [r, i, a, s, l];
}
class Ta extends Tm {
  constructor(e) {
    super(), Dm(this, e, Lm, Rm, Nm, { show_eraser: 0 });
  }
}
const {
  SvelteComponent: Pm,
  append: gi,
  attr: Me,
  check_outros: Um,
  create_component: Rl,
  destroy_component: Ll,
  detach: Ri,
  element: Ln,
  group_outros: Fm,
  init: Gm,
  insert: Li,
  listen: $r,
  mount_component: Pl,
  run_all: zm,
  safe_not_equal: jm,
  set_input_value: Ci,
  space: ea,
  to_number: qm,
  transition_in: On,
  transition_out: pi
} = window.__gradio__svelte__internal;
function Xs(t) {
  let e, n, i, r, a;
  return {
    c() {
      e = Ln("input"), Me(e, "aria-label", "Brush radius"), Me(e, "type", "range"), Me(e, "min", n = 0.5 * /*img_width*/
      (t[2] / /*width*/
      t[6])), Me(e, "max", i = 75 * /*img_width*/
      (t[2] / /*width*/
      t[6])), Me(e, "class", "svelte-1hdlygn");
    },
    m(s, l) {
      Li(s, e, l), Ci(
        e,
        /*brush_radius*/
        t[0]
      ), r || (a = [
        $r(
          e,
          "change",
          /*input_change_input_handler*/
          t[10]
        ),
        $r(
          e,
          "input",
          /*input_change_input_handler*/
          t[10]
        )
      ], r = !0);
    },
    p(s, l) {
      l & /*img_width, width*/
      68 && n !== (n = 0.5 * /*img_width*/
      (s[2] / /*width*/
      s[6])) && Me(e, "min", n), l & /*img_width, width*/
      68 && i !== (i = 75 * /*img_width*/
      (s[2] / /*width*/
      s[6])) && Me(e, "max", i), l & /*brush_radius*/
      1 && Ci(
        e,
        /*brush_radius*/
        s[0]
      );
    },
    d(s) {
      s && Ri(e), r = !1, zm(a);
    }
  };
}
function Vs(t) {
  let e, n, i, r;
  n = new rt({
    props: { Icon: Ff, label: "Select brush color" }
  }), n.$on(
    "click",
    /*click_handler_1*/
    t[11]
  );
  let a = (
    /*show_col*/
    t[5] && Ws(t)
  );
  return {
    c() {
      e = Ln("span"), Rl(n.$$.fragment), i = ea(), a && a.c(), Me(e, "class", "col svelte-1hdlygn");
    },
    m(s, l) {
      Li(s, e, l), Pl(n, e, null), gi(e, i), a && a.m(e, null), r = !0;
    },
    p(s, l) {
      /*show_col*/
      s[5] ? a ? a.p(s, l) : (a = Ws(s), a.c(), a.m(e, null)) : a && (a.d(1), a = null);
    },
    i(s) {
      r || (On(n.$$.fragment, s), r = !0);
    },
    o(s) {
      pi(n.$$.fragment, s), r = !1;
    },
    d(s) {
      s && Ri(e), Ll(n), a && a.d();
    }
  };
}
function Ws(t) {
  let e, n, i;
  return {
    c() {
      e = Ln("input"), Me(e, "aria-label", "Brush color"), Me(e, "type", "color"), Me(e, "class", "svelte-1hdlygn");
    },
    m(r, a) {
      Li(r, e, a), Ci(
        e,
        /*brush_color*/
        t[1]
      ), n || (i = $r(
        e,
        "input",
        /*input_input_handler*/
        t[12]
      ), n = !0);
    },
    p(r, a) {
      a & /*brush_color*/
      2 && Ci(
        e,
        /*brush_color*/
        r[1]
      );
    },
    d(r) {
      r && Ri(e), n = !1, i();
    }
  };
}
function xm(t) {
  let e, n, i, r, a, s;
  i = new rt({
    props: { Icon: hf, label: "Use brush" }
  }), i.$on(
    "click",
    /*click_handler*/
    t[9]
  );
  let l = (
    /*show_size*/
    t[4] && Xs(t)
  ), o = (
    /*mode*/
    t[3] !== "mask" && Vs(t)
  );
  return {
    c() {
      e = Ln("div"), n = Ln("span"), Rl(i.$$.fragment), r = ea(), l && l.c(), a = ea(), o && o.c(), Me(n, "class", "brush svelte-1hdlygn"), Me(e, "class", "wrap svelte-1hdlygn");
    },
    m(u, f) {
      Li(u, e, f), gi(e, n), Pl(i, n, null), gi(n, r), l && l.m(n, null), gi(e, a), o && o.m(e, null), s = !0;
    },
    p(u, [f]) {
      /*show_size*/
      u[4] ? l ? l.p(u, f) : (l = Xs(u), l.c(), l.m(n, null)) : l && (l.d(1), l = null), /*mode*/
      u[3] !== "mask" ? o ? (o.p(u, f), f & /*mode*/
      8 && On(o, 1)) : (o = Vs(u), o.c(), On(o, 1), o.m(e, null)) : o && (Fm(), pi(o, 1, 1, () => {
        o = null;
      }), Um());
    },
    i(u) {
      s || (On(i.$$.fragment, u), On(o), s = !0);
    },
    o(u) {
      pi(i.$$.fragment, u), pi(o), s = !1;
    },
    d(u) {
      u && Ri(e), Ll(i), l && l.d(), o && o.d();
    }
  };
}
function Xm(t, e, n) {
  let i, r = !1, a = !1, { brush_radius: s = 20 } = e, { brush_color: l = "#000" } = e, { container_height: o } = e, { img_width: u } = e, { img_height: f } = e, { mode: h = "other" } = e;
  const c = () => n(4, r = !r);
  function d() {
    s = qm(this.value), n(0, s);
  }
  const _ = () => n(5, a = !a);
  function m() {
    l = this.value, n(1, l);
  }
  return t.$$set = (b) => {
    "brush_radius" in b && n(0, s = b.brush_radius), "brush_color" in b && n(1, l = b.brush_color), "container_height" in b && n(7, o = b.container_height), "img_width" in b && n(2, u = b.img_width), "img_height" in b && n(8, f = b.img_height), "mode" in b && n(3, h = b.mode);
  }, t.$$.update = () => {
    t.$$.dirty & /*container_height, img_width, img_height*/
    388 && n(6, i = o * (u / f));
  }, [
    s,
    l,
    u,
    h,
    r,
    a,
    i,
    o,
    f,
    c,
    d,
    _,
    m
  ];
}
class Sa extends Pm {
  constructor(e) {
    super(), Gm(this, e, Xm, xm, jm, {
      brush_radius: 0,
      brush_color: 1,
      container_height: 7,
      img_width: 2,
      img_height: 8,
      mode: 3
    });
  }
}
const Vm = (t) => {
  const e = new FileReader();
  return e.readAsDataURL(t), new Promise((n) => {
    e.onloadend = () => {
      n(e.result);
    };
  });
}, Ul = (t) => {
  let e = t.currentTarget;
  const n = e.getBoundingClientRect(), i = e.naturalWidth / n.width, r = e.naturalHeight / n.height;
  if (i > r) {
    const l = e.naturalHeight / i, o = (n.height - l) / 2;
    var a = Math.round((t.clientX - n.left) * i), s = Math.round((t.clientY - n.top - o) * i);
  } else {
    const l = e.naturalWidth / r, o = (n.width - l) / 2;
    var a = Math.round((t.clientX - n.left - o) * r), s = Math.round((t.clientY - n.top) * r);
  }
  return a < 0 || a >= e.naturalWidth || s < 0 || s >= e.naturalHeight ? null : [a, s];
};
const {
  SvelteComponent: Wm,
  append: Ys,
  attr: tt,
  binding_callbacks: Ym,
  bubble: Ct,
  create_slot: Zm,
  detach: Qm,
  element: Zs,
  get_all_dirty_from_scope: Jm,
  get_slot_changes: Km,
  init: $m,
  insert: eg,
  listen: Ie,
  prevent_default: Mt,
  run_all: tg,
  safe_not_equal: ng,
  space: ig,
  stop_propagation: At,
  toggle_class: Wt,
  transition_in: rg,
  transition_out: ag,
  update_slot_base: sg
} = window.__gradio__svelte__internal, { createEventDispatcher: og } = window.__gradio__svelte__internal;
function lg(t) {
  let e, n, i, r, a, s, l, o, u;
  const f = (
    /*#slots*/
    t[15].default
  ), h = Zm(
    f,
    t,
    /*$$scope*/
    t[14],
    null
  );
  return {
    c() {
      e = Zs("div"), h && h.c(), n = ig(), i = Zs("input"), tt(i, "type", "file"), tt(
        i,
        "accept",
        /*filetype*/
        t[0]
      ), i.multiple = r = /*file_count*/
      t[4] === "multiple" || void 0, tt(i, "webkitdirectory", a = /*file_count*/
      t[4] === "directory" || void 0), tt(i, "mozdirectory", s = /*file_count*/
      t[4] === "directory" || void 0), tt(i, "class", "svelte-1h87ywf"), tt(e, "class", "svelte-1h87ywf"), Wt(
        e,
        "center",
        /*center*/
        t[2]
      ), Wt(
        e,
        "boundedheight",
        /*boundedheight*/
        t[1]
      ), Wt(
        e,
        "flex",
        /*flex*/
        t[3]
      );
    },
    m(c, d) {
      eg(c, e, d), h && h.m(e, null), Ys(e, n), Ys(e, i), t[23](i), l = !0, o || (u = [
        Ie(
          i,
          "change",
          /*loadFilesFromUpload*/
          t[8]
        ),
        Ie(e, "drag", At(Mt(
          /*drag_handler*/
          t[16]
        ))),
        Ie(e, "dragstart", At(Mt(
          /*dragstart_handler*/
          t[17]
        ))),
        Ie(e, "dragend", At(Mt(
          /*dragend_handler*/
          t[18]
        ))),
        Ie(e, "dragover", At(Mt(
          /*dragover_handler*/
          t[19]
        ))),
        Ie(e, "dragenter", At(Mt(
          /*dragenter_handler*/
          t[20]
        ))),
        Ie(e, "dragleave", At(Mt(
          /*dragleave_handler*/
          t[21]
        ))),
        Ie(e, "drop", At(Mt(
          /*drop_handler*/
          t[22]
        ))),
        Ie(
          e,
          "click",
          /*openFileUpload*/
          t[7]
        ),
        Ie(
          e,
          "drop",
          /*loadFilesFromDrop*/
          t[9]
        ),
        Ie(
          e,
          "dragenter",
          /*updateDragging*/
          t[6]
        ),
        Ie(
          e,
          "dragleave",
          /*updateDragging*/
          t[6]
        )
      ], o = !0);
    },
    p(c, [d]) {
      h && h.p && (!l || d & /*$$scope*/
      16384) && sg(
        h,
        f,
        c,
        /*$$scope*/
        c[14],
        l ? Km(
          f,
          /*$$scope*/
          c[14],
          d,
          null
        ) : Jm(
          /*$$scope*/
          c[14]
        ),
        null
      ), (!l || d & /*filetype*/
      1) && tt(
        i,
        "accept",
        /*filetype*/
        c[0]
      ), (!l || d & /*file_count*/
      16 && r !== (r = /*file_count*/
      c[4] === "multiple" || void 0)) && (i.multiple = r), (!l || d & /*file_count*/
      16 && a !== (a = /*file_count*/
      c[4] === "directory" || void 0)) && tt(i, "webkitdirectory", a), (!l || d & /*file_count*/
      16 && s !== (s = /*file_count*/
      c[4] === "directory" || void 0)) && tt(i, "mozdirectory", s), (!l || d & /*center*/
      4) && Wt(
        e,
        "center",
        /*center*/
        c[2]
      ), (!l || d & /*boundedheight*/
      2) && Wt(
        e,
        "boundedheight",
        /*boundedheight*/
        c[1]
      ), (!l || d & /*flex*/
      8) && Wt(
        e,
        "flex",
        /*flex*/
        c[3]
      );
    },
    i(c) {
      l || (rg(h, c), l = !0);
    },
    o(c) {
      ag(h, c), l = !1;
    },
    d(c) {
      c && Qm(e), h && h.d(c), t[23](null), o = !1, tg(u);
    }
  };
}
function ug(t) {
  let e, n = t[0], i = 1;
  for (; i < t.length; ) {
    const r = t[i], a = t[i + 1];
    if (i += 2, (r === "optionalAccess" || r === "optionalCall") && n == null)
      return;
    r === "access" || r === "optionalAccess" ? (e = n, n = a(n)) : (r === "call" || r === "optionalCall") && (n = a((...s) => n.call(e, ...s)), e = void 0);
  }
  return n;
}
function fg(t, e, n) {
  let { $$slots: i = {}, $$scope: r } = e, { filetype: a = null } = e, { include_file_metadata: s = !0 } = e, { dragging: l = !1 } = e, { boundedheight: o = !0 } = e, { center: u = !0 } = e, { flex: f = !0 } = e, { file_count: h = "single" } = e, { disable_click: c = !1 } = e, { parse_to_data_url: d = !0 } = e, _;
  const m = og();
  function b() {
    n(10, l = !l);
  }
  function C() {
    c || (n(5, _.value = "", _), _.click());
  }
  async function T(E) {
    let D = Array.from(E);
    if (!(!E.length || !window.FileReader)) {
      if (h === "single" && (D = [E[0]]), s)
        var L = D.map((V) => ({ name: V.name, size: V.size }));
      var Y = [], Z = [];
      d ? Z = await Promise.all(D.map((V) => Vm(V))) : Z = D, s ? d ? Y = Z.map((V, fe) => ({ data: V, ...L[fe] })) : Y = Z.map((V, fe) => ({
        data: "",
        blob: V,
        ...L[fe]
      })) : Y = Z, m("load", h === "single" ? Y[0] : Y);
    }
  }
  async function y(E) {
    const D = E.target;
    D.files && await T(D.files);
  }
  async function S(E) {
    n(10, l = !1), ug([E, "access", (D) => D.dataTransfer, "optionalAccess", (D) => D.files]) && await T(E.dataTransfer.files);
  }
  function p(E) {
    Ct.call(this, t, E);
  }
  function g(E) {
    Ct.call(this, t, E);
  }
  function M(E) {
    Ct.call(this, t, E);
  }
  function O(E) {
    Ct.call(this, t, E);
  }
  function G(E) {
    Ct.call(this, t, E);
  }
  function q(E) {
    Ct.call(this, t, E);
  }
  function ee(E) {
    Ct.call(this, t, E);
  }
  function z(E) {
    Ym[E ? "unshift" : "push"](() => {
      _ = E, n(5, _);
    });
  }
  return t.$$set = (E) => {
    "filetype" in E && n(0, a = E.filetype), "include_file_metadata" in E && n(11, s = E.include_file_metadata), "dragging" in E && n(10, l = E.dragging), "boundedheight" in E && n(1, o = E.boundedheight), "center" in E && n(2, u = E.center), "flex" in E && n(3, f = E.flex), "file_count" in E && n(4, h = E.file_count), "disable_click" in E && n(12, c = E.disable_click), "parse_to_data_url" in E && n(13, d = E.parse_to_data_url), "$$scope" in E && n(14, r = E.$$scope);
  }, [
    a,
    o,
    u,
    f,
    h,
    _,
    b,
    C,
    y,
    S,
    l,
    s,
    c,
    d,
    r,
    i,
    p,
    g,
    M,
    O,
    G,
    q,
    ee,
    z
  ];
}
class hg extends Wm {
  constructor(e) {
    super(), $m(this, e, fg, lg, ng, {
      filetype: 0,
      include_file_metadata: 11,
      dragging: 10,
      boundedheight: 1,
      center: 2,
      flex: 3,
      file_count: 4,
      disable_click: 12,
      parse_to_data_url: 13
    });
  }
}
const {
  SvelteComponent: cg,
  append: dg,
  attr: _g,
  check_outros: mg,
  create_component: Fl,
  destroy_component: Gl,
  detach: gg,
  element: pg,
  group_outros: bg,
  init: vg,
  insert: wg,
  mount_component: zl,
  safe_not_equal: yg,
  set_style: Qs,
  space: Eg,
  toggle_class: Js,
  transition_in: Dn,
  transition_out: bi
} = window.__gradio__svelte__internal, { createEventDispatcher: kg } = window.__gradio__svelte__internal;
function Ks(t) {
  let e, n;
  return e = new rt({
    props: {
      Icon: uh,
      label: (
        /*i18n*/
        t[2]("common.edit")
      )
    }
  }), e.$on(
    "click",
    /*click_handler*/
    t[4]
  ), {
    c() {
      Fl(e.$$.fragment);
    },
    m(i, r) {
      zl(e, i, r), n = !0;
    },
    p(i, r) {
      const a = {};
      r & /*i18n*/
      4 && (a.label = /*i18n*/
      i[2]("common.edit")), e.$set(a);
    },
    i(i) {
      n || (Dn(e.$$.fragment, i), n = !0);
    },
    o(i) {
      bi(e.$$.fragment, i), n = !1;
    },
    d(i) {
      Gl(e, i);
    }
  };
}
function Tg(t) {
  let e, n, i, r, a = (
    /*editable*/
    t[0] && Ks(t)
  );
  return i = new rt({
    props: {
      Icon: Fo,
      label: (
        /*i18n*/
        t[2]("common.clear")
      )
    }
  }), i.$on(
    "click",
    /*click_handler_1*/
    t[5]
  ), {
    c() {
      e = pg("div"), a && a.c(), n = Eg(), Fl(i.$$.fragment), _g(e, "class", "svelte-1wj0ocy"), Js(e, "not-absolute", !/*absolute*/
      t[1]), Qs(
        e,
        "position",
        /*absolute*/
        t[1] ? "absolute" : "static"
      );
    },
    m(s, l) {
      wg(s, e, l), a && a.m(e, null), dg(e, n), zl(i, e, null), r = !0;
    },
    p(s, [l]) {
      /*editable*/
      s[0] ? a ? (a.p(s, l), l & /*editable*/
      1 && Dn(a, 1)) : (a = Ks(s), a.c(), Dn(a, 1), a.m(e, n)) : a && (bg(), bi(a, 1, 1, () => {
        a = null;
      }), mg());
      const o = {};
      l & /*i18n*/
      4 && (o.label = /*i18n*/
      s[2]("common.clear")), i.$set(o), (!r || l & /*absolute*/
      2) && Js(e, "not-absolute", !/*absolute*/
      s[1]), l & /*absolute*/
      2 && Qs(
        e,
        "position",
        /*absolute*/
        s[1] ? "absolute" : "static"
      );
    },
    i(s) {
      r || (Dn(a), Dn(i.$$.fragment, s), r = !0);
    },
    o(s) {
      bi(a), bi(i.$$.fragment, s), r = !1;
    },
    d(s) {
      s && gg(e), a && a.d(), Gl(i);
    }
  };
}
function Sg(t, e, n) {
  let { editable: i = !1 } = e, { absolute: r = !0 } = e, { i18n: a } = e;
  const s = kg(), l = () => s("edit"), o = (u) => {
    s("clear"), u.stopPropagation();
  };
  return t.$$set = (u) => {
    "editable" in u && n(0, i = u.editable), "absolute" in u && n(1, r = u.absolute), "i18n" in u && n(2, a = u.i18n);
  }, [i, r, a, s, l, o];
}
class Pi extends cg {
  constructor(e) {
    super(), vg(this, e, Sg, Tg, yg, { editable: 0, absolute: 1, i18n: 2 });
  }
}
const {
  SvelteComponent: Cg,
  add_flush_callback: Oe,
  add_iframe_resize_listener: Mg,
  add_render_callback: Ag,
  attr: Q,
  bind: De,
  binding_callbacks: oe,
  bubble: $s,
  check_outros: bt,
  create_component: de,
  create_slot: Og,
  destroy_component: _e,
  detach: J,
  element: Ut,
  empty: pn,
  get_all_dirty_from_scope: Dg,
  get_slot_changes: Bg,
  group_outros: vt,
  init: Hg,
  insert: K,
  listen: bn,
  mount_component: me,
  noop: Mi,
  safe_not_equal: Ca,
  space: Be,
  src_url_equal: Pe,
  toggle_class: ue,
  transition_in: H,
  transition_out: U,
  update_slot_base: Ng
} = window.__gradio__svelte__internal, { createEventDispatcher: Ig, tick: li, onMount: Rg } = window.__gradio__svelte__internal;
function Lg(t) {
  let e, n, i, r;
  return {
    c() {
      e = Ut("img"), Pe(e.src, n = /*value*/
      t[0].back) || Q(e, "src", n), Q(e, "alt", ""), Q(e, "class", "svelte-14sn87y"), ue(
        e,
        "webcam",
        /*source*/
        t[6] === "webcam" && /*mirror_webcam*/
        t[10]
      ), ue(
        e,
        "selectable",
        /*selectable*/
        t[12]
      );
    },
    m(a, s) {
      K(a, e, s), i || (r = bn(
        e,
        "click",
        /*handle_click*/
        t[32]
      ), i = !0);
    },
    p(a, s) {
      s[0] & /*value*/
      1 && !Pe(e.src, n = /*value*/
      a[0].back) && Q(e, "src", n), s[0] & /*source, mirror_webcam*/
      1088 && ue(
        e,
        "webcam",
        /*source*/
        a[6] === "webcam" && /*mirror_webcam*/
        a[10]
      ), s[0] & /*selectable*/
      4096 && ue(
        e,
        "selectable",
        /*selectable*/
        a[12]
      );
    },
    i: Mi,
    o: Mi,
    d(a) {
      a && J(e), i = !1, r();
    }
  };
}
function Pg(t) {
  let e = (
    /*static_image*/
    t[25]
  ), n, i, r, a = eo(t), s = (
    /*img_width*/
    t[19] > 0 && to(t)
  );
  return {
    c() {
      a.c(), n = Be(), s && s.c(), i = pn();
    },
    m(l, o) {
      a.m(l, o), K(l, n, o), s && s.m(l, o), K(l, i, o), r = !0;
    },
    p(l, o) {
      o[0] & /*static_image*/
      33554432 && Ca(e, e = /*static_image*/
      l[25]) ? (a.d(1), a = eo(l), a.c(), a.m(n.parentNode, n)) : a.p(l, o), /*img_width*/
      l[19] > 0 ? s ? (s.p(l, o), o[0] & /*img_width*/
      524288 && H(s, 1)) : (s = to(l), s.c(), H(s, 1), s.m(i.parentNode, i)) : s && (vt(), U(s, 1, 1, () => {
        s = null;
      }), bt());
    },
    i(l) {
      r || (H(s), r = !0);
    },
    o(l) {
      U(s), r = !1;
    },
    d(l) {
      l && (J(n), J(i)), a.d(l), s && s.d(l);
    }
  };
}
function Ug(t) {
  let e, n, i, r, a, s, l;
  return e = new Pi({
    props: { i18n: (
      /*i18n*/
      t[14]
    ), editable: !0 }
  }), e.$on(
    "edit",
    /*edit_handler_1*/
    t[56]
  ), e.$on(
    "clear",
    /*handle_clear*/
    t[27]
  ), {
    c() {
      de(e.$$.fragment), n = Be(), i = Ut("img"), Pe(i.src, r = /*value*/
      t[0].back) || Q(i, "src", r), Q(i, "alt", ""), Q(i, "class", "svelte-14sn87y"), ue(
        i,
        "selectable",
        /*selectable*/
        t[12]
      ), ue(
        i,
        "webcam",
        /*source*/
        t[6] === "webcam" && /*mirror_webcam*/
        t[10]
      );
    },
    m(o, u) {
      me(e, o, u), K(o, n, u), K(o, i, u), a = !0, s || (l = bn(
        i,
        "click",
        /*handle_click*/
        t[32]
      ), s = !0);
    },
    p(o, u) {
      const f = {};
      u[0] & /*i18n*/
      16384 && (f.i18n = /*i18n*/
      o[14]), e.$set(f), (!a || u[0] & /*value*/
      1 && !Pe(i.src, r = /*value*/
      o[0].back)) && Q(i, "src", r), (!a || u[0] & /*selectable*/
      4096) && ue(
        i,
        "selectable",
        /*selectable*/
        o[12]
      ), (!a || u[0] & /*source, mirror_webcam*/
      1088) && ue(
        i,
        "webcam",
        /*source*/
        o[6] === "webcam" && /*mirror_webcam*/
        o[10]
      );
    },
    i(o) {
      a || (H(e.$$.fragment, o), a = !0);
    },
    o(o) {
      U(e.$$.fragment, o), a = !1;
    },
    d(o) {
      o && (J(n), J(i)), _e(e, o), s = !1, l();
    }
  };
}
function Fg(t) {
  let e, n, i, r, a = { image: (
    /*value*/
    t[0].back
  ) };
  return e = new nl({ props: a }), t[54](e), e.$on(
    "crop",
    /*handle_save*/
    t[28]
  ), i = new Pi({ props: { i18n: (
    /*i18n*/
    t[14]
  ) } }), i.$on(
    "clear",
    /*clear_handler_1*/
    t[55]
  ), {
    c() {
      de(e.$$.fragment), n = Be(), de(i.$$.fragment);
    },
    m(s, l) {
      me(e, s, l), K(s, n, l), me(i, s, l), r = !0;
    },
    p(s, l) {
      const o = {};
      l[0] & /*value*/
      1 && (o.image = /*value*/
      s[0].back), e.$set(o);
      const u = {};
      l[0] & /*i18n*/
      16384 && (u.i18n = /*i18n*/
      s[14]), i.$set(u);
    },
    i(s) {
      r || (H(e.$$.fragment, s), H(i.$$.fragment, s), r = !0);
    },
    o(s) {
      U(e.$$.fragment, s), U(i.$$.fragment, s), r = !1;
    },
    d(s) {
      s && J(n), t[54](null), _e(e, s), _e(i, s);
    }
  };
}
function Gg(t) {
  let e, n, i = (
    /*source*/
    t[6] === "webcam" && !/*static_image*/
    t[25] && io(t)
  );
  return {
    c() {
      i && i.c(), e = pn();
    },
    m(r, a) {
      i && i.m(r, a), K(r, e, a), n = !0;
    },
    p(r, a) {
      /*source*/
      r[6] === "webcam" && !/*static_image*/
      r[25] ? i ? (i.p(r, a), a[0] & /*source, static_image*/
      33554496 && H(i, 1)) : (i = io(r), i.c(), H(i, 1), i.m(e.parentNode, e)) : i && (vt(), U(i, 1, 1, () => {
        i = null;
      }), bt());
    },
    i(r) {
      n || (H(i), n = !0);
    },
    o(r) {
      U(i), n = !1;
    },
    d(r) {
      r && J(e), i && i.d(r);
    }
  };
}
function zg(t) {
  var c;
  let e, n, i, r, a, s, l;
  e = new Ta({}), e.$on(
    "undo",
    /*undo_handler_1*/
    t[46]
  ), e.$on(
    "remove_image",
    /*handle_sketch_clear*/
    t[30]
  );
  let o = (
    /*tool*/
    t[1] === "color-sketch" && ro(t)
  );
  function u(d) {
    t[49](d);
  }
  function f(d) {
    t[50](d);
  }
  let h = {
    value: (
      /*value*/
      (c = t[0]) == null ? void 0 : c.back
    ),
    mode: (
      /*mode*/
      t[21]
    ),
    width: (
      /*img_width*/
      t[19] || /*max_width*/
      t[24]
    ),
    height: (
      /*img_height*/
      t[18] || /*max_height*/
      t[23]
    ),
    container_height: (
      /*container_height*/
      t[20] || /*max_height*/
      t[23]
    ),
    shape: (
      /*shape*/
      t[7]
    )
  };
  return (
    /*brush_radius*/
    t[2] !== void 0 && (h.brush_radius = /*brush_radius*/
    t[2]), /*brush_color*/
    t[3] !== void 0 && (h.brush_color = /*brush_color*/
    t[3]), r = new _a({ props: h }), oe.push(() => De(r, "brush_radius", u)), oe.push(() => De(r, "brush_color", f)), t[51](r), r.$on(
      "change",
      /*handle_save*/
      t[28]
    ), r.$on(
      "clear",
      /*handle_sketch_clear*/
      t[30]
    ), {
      c() {
        de(e.$$.fragment), n = Be(), o && o.c(), i = Be(), de(r.$$.fragment);
      },
      m(d, _) {
        me(e, d, _), K(d, n, _), o && o.m(d, _), K(d, i, _), me(r, d, _), l = !0;
      },
      p(d, _) {
        var b;
        /*tool*/
        d[1] === "color-sketch" ? o ? (o.p(d, _), _[0] & /*tool*/
        2 && H(o, 1)) : (o = ro(d), o.c(), H(o, 1), o.m(i.parentNode, i)) : o && (vt(), U(o, 1, 1, () => {
          o = null;
        }), bt());
        const m = {};
        _[0] & /*value*/
        1 && (m.value = /*value*/
        (b = d[0]) == null ? void 0 : b.back), _[0] & /*mode*/
        2097152 && (m.mode = /*mode*/
        d[21]), _[0] & /*img_width, max_width*/
        17301504 && (m.width = /*img_width*/
        d[19] || /*max_width*/
        d[24]), _[0] & /*img_height, max_height*/
        8650752 && (m.height = /*img_height*/
        d[18] || /*max_height*/
        d[23]), _[0] & /*container_height, max_height*/
        9437184 && (m.container_height = /*container_height*/
        d[20] || /*max_height*/
        d[23]), _[0] & /*shape*/
        128 && (m.shape = /*shape*/
        d[7]), !a && _[0] & /*brush_radius*/
        4 && (a = !0, m.brush_radius = /*brush_radius*/
        d[2], Oe(() => a = !1)), !s && _[0] & /*brush_color*/
        8 && (s = !0, m.brush_color = /*brush_color*/
        d[3], Oe(() => s = !1)), r.$set(m);
      },
      i(d) {
        l || (H(e.$$.fragment, d), H(o), H(r.$$.fragment, d), l = !0);
      },
      o(d) {
        U(e.$$.fragment, d), U(o), U(r.$$.fragment, d), l = !1;
      },
      d(d) {
        d && (J(n), J(i)), _e(e, d), o && o.d(d), t[51](null), _e(r, d);
      }
    }
  );
}
function jg(t) {
  let e, n, i;
  function r(s) {
    t[44](s);
  }
  let a = {
    filetype: "image/*",
    root: (
      /*root*/
      t[13]
    ),
    include_file_metadata: !1,
    disable_click: !!/*value*/
    t[0],
    $$slots: { default: [Yg] },
    $$scope: { ctx: t }
  };
  return (
    /*dragging*/
    t[16] !== void 0 && (a.dragging = /*dragging*/
    t[16]), e = new hg({ props: a }), oe.push(() => De(e, "dragging", r)), e.$on(
      "load",
      /*handle_upload*/
      t[26]
    ), e.$on(
      "error",
      /*error_handler*/
      t[45]
    ), {
      c() {
        de(e.$$.fragment);
      },
      m(s, l) {
        me(e, s, l), i = !0;
      },
      p(s, l) {
        const o = {};
        l[0] & /*root*/
        8192 && (o.root = /*root*/
        s[13]), l[0] & /*value*/
        1 && (o.disable_click = !!/*value*/
        s[0]), l[0] & /*value, static_image, streaming, i18n, tool, cropper, source, mirror_webcam, selectable, container_height, max_height, img_width, max_width, img_height, mode, brush_radius, brush_color, value_img, sketch, mask_opacity, shape*/
        67034575 | l[2] & /*$$scope*/
        8 && (o.$$scope = { dirty: l, ctx: s }), !n && l[0] & /*dragging*/
        65536 && (n = !0, o.dragging = /*dragging*/
        s[16], Oe(() => n = !1)), e.$set(o);
      },
      i(s) {
        i || (H(e.$$.fragment, s), i = !0);
      },
      o(s) {
        U(e.$$.fragment, s), i = !1;
      },
      d(s) {
        _e(e, s);
      }
    }
  );
}
function eo(t) {
  let e, n, i, r;
  return {
    c() {
      e = Ut("img"), Q(e, "class", "absolute-img svelte-14sn87y"), Pe(e.src, n = /*static_image*/
      t[25] || /*value*/
      t[0].back) || Q(e, "src", n), Q(e, "alt", ""), ue(
        e,
        "webcam",
        /*source*/
        t[6] === "webcam" && /*mirror_webcam*/
        t[10]
      );
    },
    m(a, s) {
      K(a, e, s), t[57](e), i || (r = bn(
        e,
        "load",
        /*handle_image_load*/
        t[29]
      ), i = !0);
    },
    p(a, s) {
      s[0] & /*static_image, value*/
      33554433 && !Pe(e.src, n = /*static_image*/
      a[25] || /*value*/
      a[0].back) && Q(e, "src", n), s[0] & /*source, mirror_webcam*/
      1088 && ue(
        e,
        "webcam",
        /*source*/
        a[6] === "webcam" && /*mirror_webcam*/
        a[10]
      );
    },
    d(a) {
      a && J(e), t[57](null), i = !1, r();
    }
  };
}
function to(t) {
  let e, n, i, r, a, s, l, o;
  function u(d) {
    t[59](d);
  }
  function f(d) {
    t[60](d);
  }
  let h = {
    value: (
      /*value*/
      t[0].back
    ),
    mode: (
      /*mode*/
      t[21]
    ),
    width: (
      /*img_width*/
      t[19] || /*max_width*/
      t[24]
    ),
    height: (
      /*img_height*/
      t[18] || /*max_height*/
      t[23]
    ),
    container_height: (
      /*container_height*/
      t[20] || /*max_height*/
      t[23]
    ),
    value_img: (
      /*value_img*/
      t[22]
    ),
    source: (
      /*source*/
      t[6]
    )
  };
  /*brush_radius*/
  t[2] !== void 0 && (h.brush_radius = /*brush_radius*/
  t[2]), /*brush_color*/
  t[3] !== void 0 && (h.brush_color = /*brush_color*/
  t[3]), e = new _a({ props: h }), t[58](e), oe.push(() => De(e, "brush_radius", u)), oe.push(() => De(e, "brush_color", f)), e.$on(
    "change",
    /*handle_save*/
    t[28]
  ), a = new Ta({}), a.$on(
    "undo",
    /*undo_handler_2*/
    t[61]
  ), a.$on(
    "remove_image",
    /*handle_sketch_clear*/
    t[30]
  );
  let c = (
    /*tool*/
    (t[1] === "color-sketch" || /*tool*/
    t[1] === "sketch") && no(t)
  );
  return {
    c() {
      de(e.$$.fragment), r = Be(), de(a.$$.fragment), s = Be(), c && c.c(), l = pn();
    },
    m(d, _) {
      me(e, d, _), K(d, r, _), me(a, d, _), K(d, s, _), c && c.m(d, _), K(d, l, _), o = !0;
    },
    p(d, _) {
      const m = {};
      _[0] & /*value*/
      1 && (m.value = /*value*/
      d[0].back), _[0] & /*mode*/
      2097152 && (m.mode = /*mode*/
      d[21]), _[0] & /*img_width, max_width*/
      17301504 && (m.width = /*img_width*/
      d[19] || /*max_width*/
      d[24]), _[0] & /*img_height, max_height*/
      8650752 && (m.height = /*img_height*/
      d[18] || /*max_height*/
      d[23]), _[0] & /*container_height, max_height*/
      9437184 && (m.container_height = /*container_height*/
      d[20] || /*max_height*/
      d[23]), _[0] & /*value_img*/
      4194304 && (m.value_img = /*value_img*/
      d[22]), _[0] & /*source*/
      64 && (m.source = /*source*/
      d[6]), !n && _[0] & /*brush_radius*/
      4 && (n = !0, m.brush_radius = /*brush_radius*/
      d[2], Oe(() => n = !1)), !i && _[0] & /*brush_color*/
      8 && (i = !0, m.brush_color = /*brush_color*/
      d[3], Oe(() => i = !1)), e.$set(m), /*tool*/
      d[1] === "color-sketch" || /*tool*/
      d[1] === "sketch" ? c ? (c.p(d, _), _[0] & /*tool*/
      2 && H(c, 1)) : (c = no(d), c.c(), H(c, 1), c.m(l.parentNode, l)) : c && (vt(), U(c, 1, 1, () => {
        c = null;
      }), bt());
    },
    i(d) {
      o || (H(e.$$.fragment, d), H(a.$$.fragment, d), H(c), o = !0);
    },
    o(d) {
      U(e.$$.fragment, d), U(a.$$.fragment, d), U(c), o = !1;
    },
    d(d) {
      d && (J(r), J(s), J(l)), t[58](null), _e(e, d), _e(a, d), c && c.d(d);
    }
  };
}
function no(t) {
  let e, n, i, r;
  function a(o) {
    t[62](o);
  }
  function s(o) {
    t[63](o);
  }
  let l = {
    container_height: (
      /*container_height*/
      t[20] || /*max_height*/
      t[23]
    ),
    img_width: (
      /*img_width*/
      t[19] || /*max_width*/
      t[24]
    ),
    img_height: (
      /*img_height*/
      t[18] || /*max_height*/
      t[23]
    ),
    mode: (
      /*mode*/
      t[21]
    )
  };
  return (
    /*brush_radius*/
    t[2] !== void 0 && (l.brush_radius = /*brush_radius*/
    t[2]), /*brush_color*/
    t[3] !== void 0 && (l.brush_color = /*brush_color*/
    t[3]), e = new Sa({ props: l }), oe.push(() => De(e, "brush_radius", a)), oe.push(() => De(e, "brush_color", s)), {
      c() {
        de(e.$$.fragment);
      },
      m(o, u) {
        me(e, o, u), r = !0;
      },
      p(o, u) {
        const f = {};
        u[0] & /*container_height, max_height*/
        9437184 && (f.container_height = /*container_height*/
        o[20] || /*max_height*/
        o[23]), u[0] & /*img_width, max_width*/
        17301504 && (f.img_width = /*img_width*/
        o[19] || /*max_width*/
        o[24]), u[0] & /*img_height, max_height*/
        8650752 && (f.img_height = /*img_height*/
        o[18] || /*max_height*/
        o[23]), u[0] & /*mode*/
        2097152 && (f.mode = /*mode*/
        o[21]), !n && u[0] & /*brush_radius*/
        4 && (n = !0, f.brush_radius = /*brush_radius*/
        o[2], Oe(() => n = !1)), !i && u[0] & /*brush_color*/
        8 && (i = !0, f.brush_color = /*brush_color*/
        o[3], Oe(() => i = !1)), e.$set(f);
      },
      i(o) {
        r || (H(e.$$.fragment, o), r = !0);
      },
      o(o) {
        U(e.$$.fragment, o), r = !1;
      },
      d(o) {
        _e(e, o);
      }
    }
  );
}
function io(t) {
  let e, n;
  return e = new km({
    props: {
      streaming: (
        /*streaming*/
        t[8]
      ),
      pending: (
        /*pending*/
        t[9]
      ),
      mirror_webcam: (
        /*mirror_webcam*/
        t[10]
      )
    }
  }), e.$on(
    "capture",
    /*capture_handler*/
    t[52]
  ), e.$on(
    "stream",
    /*handle_save*/
    t[28]
  ), e.$on(
    "error",
    /*error_handler_1*/
    t[53]
  ), {
    c() {
      de(e.$$.fragment);
    },
    m(i, r) {
      me(e, i, r), n = !0;
    },
    p(i, r) {
      const a = {};
      r[0] & /*streaming*/
      256 && (a.streaming = /*streaming*/
      i[8]), r[0] & /*pending*/
      512 && (a.pending = /*pending*/
      i[9]), r[0] & /*mirror_webcam*/
      1024 && (a.mirror_webcam = /*mirror_webcam*/
      i[10]), e.$set(a);
    },
    i(i) {
      n || (H(e.$$.fragment, i), n = !0);
    },
    o(i) {
      U(e.$$.fragment, i), n = !1;
    },
    d(i) {
      _e(e, i);
    }
  };
}
function ro(t) {
  let e, n, i, r;
  function a(o) {
    t[47](o);
  }
  function s(o) {
    t[48](o);
  }
  let l = {
    container_height: (
      /*container_height*/
      t[20] || /*max_height*/
      t[23]
    ),
    img_width: (
      /*img_width*/
      t[19] || /*max_width*/
      t[24]
    ),
    img_height: (
      /*img_height*/
      t[18] || /*max_height*/
      t[23]
    )
  };
  return (
    /*brush_radius*/
    t[2] !== void 0 && (l.brush_radius = /*brush_radius*/
    t[2]), /*brush_color*/
    t[3] !== void 0 && (l.brush_color = /*brush_color*/
    t[3]), e = new Sa({ props: l }), oe.push(() => De(e, "brush_radius", a)), oe.push(() => De(e, "brush_color", s)), {
      c() {
        de(e.$$.fragment);
      },
      m(o, u) {
        me(e, o, u), r = !0;
      },
      p(o, u) {
        const f = {};
        u[0] & /*container_height, max_height*/
        9437184 && (f.container_height = /*container_height*/
        o[20] || /*max_height*/
        o[23]), u[0] & /*img_width, max_width*/
        17301504 && (f.img_width = /*img_width*/
        o[19] || /*max_width*/
        o[24]), u[0] & /*img_height, max_height*/
        8650752 && (f.img_height = /*img_height*/
        o[18] || /*max_height*/
        o[23]), !n && u[0] & /*brush_radius*/
        4 && (n = !0, f.brush_radius = /*brush_radius*/
        o[2], Oe(() => n = !1)), !i && u[0] & /*brush_color*/
        8 && (i = !0, f.brush_color = /*brush_color*/
        o[3], Oe(() => i = !1)), e.$set(f);
      },
      i(o) {
        r || (H(e.$$.fragment, o), r = !0);
      },
      o(o) {
        U(e.$$.fragment, o), r = !1;
      },
      d(o) {
        _e(e, o);
      }
    }
  );
}
function qg(t) {
  let e, n, i, r;
  return {
    c() {
      e = Ut("img"), Pe(e.src, n = /*value*/
      t[0].back) || Q(e, "src", n), Q(e, "alt", "hello"), Q(e, "class", "svelte-14sn87y"), ue(
        e,
        "webcam",
        /*source*/
        t[6] === "webcam" && /*mirror_webcam*/
        t[10]
      ), ue(
        e,
        "selectable",
        /*selectable*/
        t[12]
      );
    },
    m(a, s) {
      K(a, e, s), i || (r = bn(
        e,
        "click",
        /*handle_click*/
        t[32]
      ), i = !0);
    },
    p(a, s) {
      s[0] & /*value*/
      1 && !Pe(e.src, n = /*value*/
      a[0].back) && Q(e, "src", n), s[0] & /*source, mirror_webcam*/
      1088 && ue(
        e,
        "webcam",
        /*source*/
        a[6] === "webcam" && /*mirror_webcam*/
        a[10]
      ), s[0] & /*selectable*/
      4096 && ue(
        e,
        "selectable",
        /*selectable*/
        a[12]
      );
    },
    i: Mi,
    o: Mi,
    d(a) {
      a && J(e), i = !1, r();
    }
  };
}
function xg(t) {
  let e = (
    /*static_image*/
    t[25]
  ), n, i, r, a = ao(t), s = (
    /*img_width*/
    t[19] > 0 && so(t)
  );
  return {
    c() {
      a.c(), n = Be(), s && s.c(), i = pn();
    },
    m(l, o) {
      a.m(l, o), K(l, n, o), s && s.m(l, o), K(l, i, o), r = !0;
    },
    p(l, o) {
      o[0] & /*static_image*/
      33554432 && Ca(e, e = /*static_image*/
      l[25]) ? (a.d(1), a = ao(l), a.c(), a.m(n.parentNode, n)) : a.p(l, o), /*img_width*/
      l[19] > 0 ? s ? (s.p(l, o), o[0] & /*img_width*/
      524288 && H(s, 1)) : (s = so(l), s.c(), H(s, 1), s.m(i.parentNode, i)) : s && (vt(), U(s, 1, 1, () => {
        s = null;
      }), bt());
    },
    i(l) {
      r || (H(s), r = !0);
    },
    o(l) {
      U(s), r = !1;
    },
    d(l) {
      l && (J(n), J(i)), a.d(l), s && s.d(l);
    }
  };
}
function Xg(t) {
  let e, n, i, r, a, s, l;
  return e = new Pi({
    props: { i18n: (
      /*i18n*/
      t[14]
    ), editable: !0 }
  }), e.$on(
    "edit",
    /*edit_handler*/
    t[36]
  ), e.$on(
    "clear",
    /*handle_clear*/
    t[27]
  ), {
    c() {
      de(e.$$.fragment), n = Be(), i = Ut("img"), Pe(i.src, r = /*value*/
      t[0].back) || Q(i, "src", r), Q(i, "alt", ""), Q(i, "class", "svelte-14sn87y"), ue(
        i,
        "scale-x-[-1]",
        /*source*/
        t[6] === "webcam" && /*mirror_webcam*/
        t[10]
      ), ue(
        i,
        "selectable",
        /*selectable*/
        t[12]
      );
    },
    m(o, u) {
      me(e, o, u), K(o, n, u), K(o, i, u), a = !0, s || (l = bn(
        i,
        "click",
        /*handle_click*/
        t[32]
      ), s = !0);
    },
    p(o, u) {
      const f = {};
      u[0] & /*i18n*/
      16384 && (f.i18n = /*i18n*/
      o[14]), e.$set(f), (!a || u[0] & /*value*/
      1 && !Pe(i.src, r = /*value*/
      o[0].back)) && Q(i, "src", r), (!a || u[0] & /*source, mirror_webcam*/
      1088) && ue(
        i,
        "scale-x-[-1]",
        /*source*/
        o[6] === "webcam" && /*mirror_webcam*/
        o[10]
      ), (!a || u[0] & /*selectable*/
      4096) && ue(
        i,
        "selectable",
        /*selectable*/
        o[12]
      );
    },
    i(o) {
      a || (H(e.$$.fragment, o), a = !0);
    },
    o(o) {
      U(e.$$.fragment, o), a = !1;
    },
    d(o) {
      o && (J(n), J(i)), _e(e, o), s = !1, l();
    }
  };
}
function Vg(t) {
  let e, n, i, r, a = { image: (
    /*value*/
    t[0].back
  ) };
  return e = new nl({ props: a }), t[34](e), e.$on(
    "crop",
    /*handle_save*/
    t[28]
  ), i = new Pi({ props: { i18n: (
    /*i18n*/
    t[14]
  ) } }), i.$on(
    "clear",
    /*clear_handler*/
    t[35]
  ), {
    c() {
      de(e.$$.fragment), n = Be(), de(i.$$.fragment);
    },
    m(s, l) {
      me(e, s, l), K(s, n, l), me(i, s, l), r = !0;
    },
    p(s, l) {
      const o = {};
      l[0] & /*value*/
      1 && (o.image = /*value*/
      s[0].back), e.$set(o);
      const u = {};
      l[0] & /*i18n*/
      16384 && (u.i18n = /*i18n*/
      s[14]), i.$set(u);
    },
    i(s) {
      r || (H(e.$$.fragment, s), H(i.$$.fragment, s), r = !0);
    },
    o(s) {
      U(e.$$.fragment, s), U(i.$$.fragment, s), r = !1;
    },
    d(s) {
      s && J(n), t[34](null), _e(e, s), _e(i, s);
    }
  };
}
function Wg(t) {
  let e;
  const n = (
    /*#slots*/
    t[33].default
  ), i = Og(
    n,
    t,
    /*$$scope*/
    t[65],
    null
  );
  return {
    c() {
      i && i.c();
    },
    m(r, a) {
      i && i.m(r, a), e = !0;
    },
    p(r, a) {
      i && i.p && (!e || a[2] & /*$$scope*/
      8) && Ng(
        i,
        n,
        r,
        /*$$scope*/
        r[65],
        e ? Bg(
          n,
          /*$$scope*/
          r[65],
          a,
          null
        ) : Dg(
          /*$$scope*/
          r[65]
        ),
        null
      );
    },
    i(r) {
      e || (H(i, r), e = !0);
    },
    o(r) {
      U(i, r), e = !1;
    },
    d(r) {
      i && i.d(r);
    }
  };
}
function ao(t) {
  let e, n, i, r;
  return {
    c() {
      e = Ut("img"), Q(e, "class", "absolute-img svelte-14sn87y"), Pe(e.src, n = /*static_image*/
      t[25] || /*value*/
      t[0].back) || Q(e, "src", n), Q(e, "alt", ""), ue(
        e,
        "webcam",
        /*source*/
        t[6] === "webcam" && /*mirror_webcam*/
        t[10]
      );
    },
    m(a, s) {
      K(a, e, s), t[37](e), i || (r = bn(
        e,
        "load",
        /*handle_image_load*/
        t[29]
      ), i = !0);
    },
    p(a, s) {
      s[0] & /*static_image, value*/
      33554433 && !Pe(e.src, n = /*static_image*/
      a[25] || /*value*/
      a[0].back) && Q(e, "src", n), s[0] & /*source, mirror_webcam*/
      1088 && ue(
        e,
        "webcam",
        /*source*/
        a[6] === "webcam" && /*mirror_webcam*/
        a[10]
      );
    },
    d(a) {
      a && J(e), t[37](null), i = !1, r();
    }
  };
}
function so(t) {
  var d;
  let e, n, i, r, a, s, l, o;
  function u(_) {
    t[39](_);
  }
  function f(_) {
    t[40](_);
  }
  let h = {
    value: (
      /*value*/
      (d = t[0]) == null ? void 0 : d.back
    ),
    mask_opacity: (
      /*mask_opacity*/
      t[11]
    ),
    mode: (
      /*mode*/
      t[21]
    ),
    width: (
      /*img_width*/
      t[19] || /*max_width*/
      t[24]
    ),
    height: (
      /*img_height*/
      t[18] || /*max_height*/
      t[23]
    ),
    container_height: (
      /*container_height*/
      t[20] || /*max_height*/
      t[23]
    ),
    value_img: (
      /*value_img*/
      t[22]
    ),
    source: (
      /*source*/
      t[6]
    ),
    shape: (
      /*shape*/
      t[7]
    )
  };
  /*brush_radius*/
  t[2] !== void 0 && (h.brush_radius = /*brush_radius*/
  t[2]), /*brush_color*/
  t[3] !== void 0 && (h.brush_color = /*brush_color*/
  t[3]), e = new _a({ props: h }), t[38](e), oe.push(() => De(e, "brush_radius", u)), oe.push(() => De(e, "brush_color", f)), e.$on(
    "change",
    /*handle_save*/
    t[28]
  ), a = new Ta({
    props: { show_eraser: (
      /*value_img*/
      t[22]
    ) }
  }), a.$on(
    "undo",
    /*undo_handler*/
    t[41]
  ), a.$on(
    "clear_mask",
    /*handle_mask_clear*/
    t[31]
  ), a.$on(
    "remove_image",
    /*handle_sketch_clear*/
    t[30]
  );
  let c = (
    /*tool*/
    (t[1] === "color-sketch" || /*tool*/
    t[1] === "sketch") && oo(t)
  );
  return {
    c() {
      de(e.$$.fragment), r = Be(), de(a.$$.fragment), s = Be(), c && c.c(), l = pn();
    },
    m(_, m) {
      me(e, _, m), K(_, r, m), me(a, _, m), K(_, s, m), c && c.m(_, m), K(_, l, m), o = !0;
    },
    p(_, m) {
      var T;
      const b = {};
      m[0] & /*value*/
      1 && (b.value = /*value*/
      (T = _[0]) == null ? void 0 : T.back), m[0] & /*mask_opacity*/
      2048 && (b.mask_opacity = /*mask_opacity*/
      _[11]), m[0] & /*mode*/
      2097152 && (b.mode = /*mode*/
      _[21]), m[0] & /*img_width, max_width*/
      17301504 && (b.width = /*img_width*/
      _[19] || /*max_width*/
      _[24]), m[0] & /*img_height, max_height*/
      8650752 && (b.height = /*img_height*/
      _[18] || /*max_height*/
      _[23]), m[0] & /*container_height, max_height*/
      9437184 && (b.container_height = /*container_height*/
      _[20] || /*max_height*/
      _[23]), m[0] & /*value_img*/
      4194304 && (b.value_img = /*value_img*/
      _[22]), m[0] & /*source*/
      64 && (b.source = /*source*/
      _[6]), m[0] & /*shape*/
      128 && (b.shape = /*shape*/
      _[7]), !n && m[0] & /*brush_radius*/
      4 && (n = !0, b.brush_radius = /*brush_radius*/
      _[2], Oe(() => n = !1)), !i && m[0] & /*brush_color*/
      8 && (i = !0, b.brush_color = /*brush_color*/
      _[3], Oe(() => i = !1)), e.$set(b);
      const C = {};
      m[0] & /*value_img*/
      4194304 && (C.show_eraser = /*value_img*/
      _[22]), a.$set(C), /*tool*/
      _[1] === "color-sketch" || /*tool*/
      _[1] === "sketch" ? c ? (c.p(_, m), m[0] & /*tool*/
      2 && H(c, 1)) : (c = oo(_), c.c(), H(c, 1), c.m(l.parentNode, l)) : c && (vt(), U(c, 1, 1, () => {
        c = null;
      }), bt());
    },
    i(_) {
      o || (H(e.$$.fragment, _), H(a.$$.fragment, _), H(c), o = !0);
    },
    o(_) {
      U(e.$$.fragment, _), U(a.$$.fragment, _), U(c), o = !1;
    },
    d(_) {
      _ && (J(r), J(s), J(l)), t[38](null), _e(e, _), _e(a, _), c && c.d(_);
    }
  };
}
function oo(t) {
  let e, n, i, r;
  function a(o) {
    t[42](o);
  }
  function s(o) {
    t[43](o);
  }
  let l = {
    container_height: (
      /*container_height*/
      t[20] || /*max_height*/
      t[23]
    ),
    img_width: (
      /*img_width*/
      t[19] || /*max_width*/
      t[24]
    ),
    img_height: (
      /*img_height*/
      t[18] || /*max_height*/
      t[23]
    ),
    mode: (
      /*mode*/
      t[21]
    )
  };
  return (
    /*brush_radius*/
    t[2] !== void 0 && (l.brush_radius = /*brush_radius*/
    t[2]), /*brush_color*/
    t[3] !== void 0 && (l.brush_color = /*brush_color*/
    t[3]), e = new Sa({ props: l }), oe.push(() => De(e, "brush_radius", a)), oe.push(() => De(e, "brush_color", s)), {
      c() {
        de(e.$$.fragment);
      },
      m(o, u) {
        me(e, o, u), r = !0;
      },
      p(o, u) {
        const f = {};
        u[0] & /*container_height, max_height*/
        9437184 && (f.container_height = /*container_height*/
        o[20] || /*max_height*/
        o[23]), u[0] & /*img_width, max_width*/
        17301504 && (f.img_width = /*img_width*/
        o[19] || /*max_width*/
        o[24]), u[0] & /*img_height, max_height*/
        8650752 && (f.img_height = /*img_height*/
        o[18] || /*max_height*/
        o[23]), u[0] & /*mode*/
        2097152 && (f.mode = /*mode*/
        o[21]), !n && u[0] & /*brush_radius*/
        4 && (n = !0, f.brush_radius = /*brush_radius*/
        o[2], Oe(() => n = !1)), !i && u[0] & /*brush_color*/
        8 && (i = !0, f.brush_color = /*brush_color*/
        o[3], Oe(() => i = !1)), e.$set(f);
      },
      i(o) {
        r || (H(e.$$.fragment, o), r = !0);
      },
      o(o) {
        U(e.$$.fragment, o), r = !1;
      },
      d(o) {
        _e(e, o);
      }
    }
  );
}
function Yg(t) {
  let e, n, i, r;
  const a = [
    Wg,
    Vg,
    Xg,
    xg,
    qg
  ], s = [];
  function l(o, u) {
    return (
      /*value*/
      o[0] === null && !/*static_image*/
      o[25] || /*streaming*/
      o[8] ? 0 : (
        /*tool*/
        o[1] === "select" ? 1 : (
          /*tool*/
          o[1] === "editor" ? 2 : (
            /*tool*/
            (o[1] === "sketch" || /*tool*/
            o[1] === "color-sketch") && /*value*/
            (o[0] !== null || /*static_image*/
            o[25]) ? 3 : 4
          )
        )
      )
    );
  }
  return e = l(t), n = s[e] = a[e](t), {
    c() {
      n.c(), i = pn();
    },
    m(o, u) {
      s[e].m(o, u), K(o, i, u), r = !0;
    },
    p(o, u) {
      let f = e;
      e = l(o), e === f ? s[e].p(o, u) : (vt(), U(s[f], 1, 1, () => {
        s[f] = null;
      }), bt(), n = s[e], n ? n.p(o, u) : (n = s[e] = a[e](o), n.c()), H(n, 1), n.m(i.parentNode, i));
    },
    i(o) {
      r || (H(n), r = !0);
    },
    o(o) {
      U(n), r = !1;
    },
    d(o) {
      o && J(i), s[e].d(o);
    }
  };
}
function Zg(t) {
  let e, n, i, r, a, s, l;
  e = new Lo({
    props: {
      show_label: (
        /*show_label*/
        t[5]
      ),
      Icon: (
        /*source*/
        t[6] === "canvas" ? za : vi
      ),
      label: (
        /*label*/
        t[4] || /*source*/
        (t[6] === "canvas" ? "Sketch" : "Image")
      )
    }
  });
  const o = [
    jg,
    zg,
    Gg,
    Fg,
    Ug,
    Pg,
    Lg
  ], u = [];
  function f(h, c) {
    return (
      /*source*/
      h[6] === "upload" ? 0 : (
        /*source*/
        h[6] === "canvas" ? 1 : (
          /*value*/
          h[0] === null && !/*static_image*/
          h[25] || /*streaming*/
          h[8] ? 2 : (
            /*tool*/
            h[1] === "select" ? 3 : (
              /*tool*/
              h[1] === "editor" ? 4 : (
                /*tool*/
                (h[1] === "sketch" || /*tool*/
                h[1] === "color-sketch") && /*value*/
                (h[0] !== null || /*static_image*/
                h[25]) ? 5 : 6
              )
            )
          )
        )
      )
    );
  }
  return r = f(t), a = u[r] = o[r](t), {
    c() {
      de(e.$$.fragment), n = Be(), i = Ut("div"), a.c(), Q(i, "data-testid", "image"), Q(i, "class", "image-container svelte-14sn87y"), Ag(() => (
        /*div_elementresize_handler*/
        t[64].call(i)
      ));
    },
    m(h, c) {
      me(e, h, c), K(h, n, c), K(h, i, c), u[r].m(i, null), s = Mg(
        i,
        /*div_elementresize_handler*/
        t[64].bind(i)
      ), l = !0;
    },
    p(h, c) {
      const d = {};
      c[0] & /*show_label*/
      32 && (d.show_label = /*show_label*/
      h[5]), c[0] & /*source*/
      64 && (d.Icon = /*source*/
      h[6] === "canvas" ? za : vi), c[0] & /*label, source*/
      80 && (d.label = /*label*/
      h[4] || /*source*/
      (h[6] === "canvas" ? "Sketch" : "Image")), e.$set(d);
      let _ = r;
      r = f(h), r === _ ? u[r].p(h, c) : (vt(), U(u[_], 1, 1, () => {
        u[_] = null;
      }), bt(), a = u[r], a ? a.p(h, c) : (a = u[r] = o[r](h), a.c()), H(a, 1), a.m(i, null));
    },
    i(h) {
      l || (H(e.$$.fragment, h), H(a), l = !0);
    },
    o(h) {
      U(e.$$.fragment, h), U(a), l = !1;
    },
    d(h) {
      h && (J(n), J(i)), _e(e, h), u[r].d(), s();
    }
  };
}
function Qg(t) {
  let e, n = t[0], i = 1;
  for (; i < t.length; ) {
    const r = t[i], a = t[i + 1];
    if (i += 2, (r === "optionalAccess" || r === "optionalCall") && n == null)
      return;
    r === "access" || r === "optionalAccess" ? (e = n, n = a(n)) : (r === "call" || r === "optionalCall") && (n = a((...s) => n.call(e, ...s)), e = void 0);
  }
  return n;
}
function Jg(t, e, n) {
  let { $$slots: i = {}, $$scope: r } = e, { value: a } = e, { label: s = void 0 } = e, { show_label: l } = e, { source: o = "upload" } = e, { tool: u = "editor" } = e, { shape: f } = e, { streaming: h = !1 } = e, { pending: c = !1 } = e, { mirror_webcam: d } = e, { brush_radius: _ } = e, { brush_color: m = "#000000" } = e, { mask_opacity: b } = e, { selectable: C = !1 } = e, { root: T } = e, { i18n: y } = e, S, p;
  function g({ detail: w }) {
    u === "color-sketch" ? n(25, be = w) : n(0, a = { back: w, mask: null }), G("upload", w);
  }
  function M({ detail: w }) {
    n(0, a = null), n(25, be = void 0), G("clear");
  }
  async function O({ detail: w }, Ve) {
    Z === "mask" && !(o === "webcam" && Ve) ? n(0, a = {
      back: Qg([a, "optionalAccess", ($n) => $n.back]) || null,
      mask: w
    }) : n(0, a = { back: w, mask: null }), await li(), G(h ? "stream" : "edit");
  }
  const G = Ig();
  let q = !1;
  function ee(w) {
    const Ve = w.currentTarget;
    n(19, L = Ve.naturalWidth), n(18, D = Ve.naturalHeight), n(20, Y = Ve.getBoundingClientRect().height);
  }
  async function z() {
    S.clear(), await li(), n(0, a = null), n(25, be = void 0);
  }
  async function E() {
    S.clear_mask(), await li();
  }
  let D = 0, L = 0, Y = 0, Z, V, fe, Te, be;
  Rg(async () => {
    u === "color-sketch" && a && (n(25, be = a.back), await li(), ee({ currentTarget: V }));
  });
  function He(w) {
    let Ve = Ul(w);
    Ve && G("select", { index: Ve, value: null });
  }
  function A(w) {
    oe[w ? "unshift" : "push"](() => {
      p = w, n(15, p), n(0, a);
    });
  }
  const lt = (w) => (M(w), n(1, u = "editor")), wt = () => n(1, u = "select");
  function Ft(w) {
    oe[w ? "unshift" : "push"](() => {
      V = w, n(22, V);
    });
  }
  function k(w) {
    oe[w ? "unshift" : "push"](() => {
      S = w, n(17, S);
    });
  }
  function qn(w) {
    _ = w, n(2, _);
  }
  function xn(w) {
    m = w, n(3, m);
  }
  const Xn = () => S.undo();
  function Gt(w) {
    _ = w, n(2, _);
  }
  function Vn(w) {
    m = w, n(3, m);
  }
  function Wn(w) {
    q = w, n(16, q);
  }
  function Yn(w) {
    $s.call(this, t, w);
  }
  const Zn = () => S.undo();
  function Qn(w) {
    _ = w, n(2, _);
  }
  function et(w) {
    m = w, n(3, m);
  }
  function yt(w) {
    _ = w, n(2, _);
  }
  function Jn(w) {
    m = w, n(3, m);
  }
  function wn(w) {
    oe[w ? "unshift" : "push"](() => {
      S = w, n(17, S);
    });
  }
  const Ui = (w) => u === "color-sketch" ? g(w) : O(w, !0);
  function Kn(w) {
    $s.call(this, t, w);
  }
  function Fi(w) {
    oe[w ? "unshift" : "push"](() => {
      p = w, n(15, p), n(0, a);
    });
  }
  const Gi = (w) => (M(w), n(1, u = "editor")), zi = () => n(1, u = "select");
  function ji(w) {
    oe[w ? "unshift" : "push"](() => {
      V = w, n(22, V);
    });
  }
  function v(w) {
    oe[w ? "unshift" : "push"](() => {
      S = w, n(17, S);
    });
  }
  function B(w) {
    _ = w, n(2, _);
  }
  function x(w) {
    m = w, n(3, m);
  }
  const he = () => S.undo();
  function te(w) {
    _ = w, n(2, _);
  }
  function we(w) {
    m = w, n(3, m);
  }
  function zt() {
    fe = this.offsetHeight, Te = this.offsetWidth, n(23, fe), n(24, Te);
  }
  return t.$$set = (w) => {
    "value" in w && n(0, a = w.value), "label" in w && n(4, s = w.label), "show_label" in w && n(5, l = w.show_label), "source" in w && n(6, o = w.source), "tool" in w && n(1, u = w.tool), "shape" in w && n(7, f = w.shape), "streaming" in w && n(8, h = w.streaming), "pending" in w && n(9, c = w.pending), "mirror_webcam" in w && n(10, d = w.mirror_webcam), "brush_radius" in w && n(2, _ = w.brush_radius), "brush_color" in w && n(3, m = w.brush_color), "mask_opacity" in w && n(11, b = w.mask_opacity), "selectable" in w && n(12, C = w.selectable), "root" in w && n(13, T = w.root), "i18n" in w && n(14, y = w.i18n), "$$scope" in w && n(65, r = w.$$scope);
  }, t.$$.update = () => {
    t.$$.dirty[0] & /*dragging*/
    65536 && G("drag", q), t.$$.dirty[0] & /*source, tool*/
    66 && (o === "canvas" && u === "sketch" ? n(21, Z = "bw-sketch") : u === "color-sketch" ? n(21, Z = "color-sketch") : (o === "upload" || o === "webcam") && u === "sketch" ? n(21, Z = "mask") : n(21, Z = "editor")), t.$$.dirty[0] & /*value*/
    1 && (a === null || a.back === null && a.mask === null) && n(25, be = void 0), t.$$.dirty[0] & /*cropper, value*/
    32769 && p && (a ? (n(15, p.image = a.back, p), p.create()) : p.destroy());
  }, [
    a,
    u,
    _,
    m,
    s,
    l,
    o,
    f,
    h,
    c,
    d,
    b,
    C,
    T,
    y,
    p,
    q,
    S,
    D,
    L,
    Y,
    Z,
    V,
    fe,
    Te,
    be,
    g,
    M,
    O,
    ee,
    z,
    E,
    He,
    i,
    A,
    lt,
    wt,
    Ft,
    k,
    qn,
    xn,
    Xn,
    Gt,
    Vn,
    Wn,
    Yn,
    Zn,
    Qn,
    et,
    yt,
    Jn,
    wn,
    Ui,
    Kn,
    Fi,
    Gi,
    zi,
    ji,
    v,
    B,
    x,
    he,
    te,
    we,
    zt,
    r
  ];
}
class Kg extends Cg {
  constructor(e) {
    super(), Hg(
      this,
      e,
      Jg,
      Zg,
      Ca,
      {
        value: 0,
        label: 4,
        show_label: 5,
        source: 6,
        tool: 1,
        shape: 7,
        streaming: 8,
        pending: 9,
        mirror_webcam: 10,
        brush_radius: 2,
        brush_color: 3,
        mask_opacity: 11,
        selectable: 12,
        root: 13,
        i18n: 14
      },
      null,
      [-1, -1, -1]
    );
  }
}
const {
  SvelteComponent: $g,
  append: ep,
  attr: nt,
  bubble: lo,
  check_outros: ta,
  create_component: Gn,
  destroy_component: zn,
  detach: tn,
  element: na,
  empty: tp,
  group_outros: ia,
  init: np,
  insert: nn,
  listen: ip,
  mount_component: jn,
  safe_not_equal: rp,
  space: ra,
  src_url_equal: uo,
  toggle_class: fo,
  transition_in: Ae,
  transition_out: Xe
} = window.__gradio__svelte__internal, { createEventDispatcher: ap } = window.__gradio__svelte__internal;
function sp(t) {
  let e, n, i, r, a, s, l, o, u = (
    /*show_download_button*/
    t[3] && ho(t)
  ), f = (
    /*show_share_button*/
    t[5] && co(t)
  );
  return {
    c() {
      e = na("div"), u && u.c(), n = ra(), f && f.c(), i = ra(), r = na("img"), nt(e, "class", "icon-buttons svelte-v9w493"), uo(r.src, a = /*value*/
      t[0].back) || nt(r, "src", a), nt(r, "alt", ""), nt(r, "class", "svelte-v9w493"), fo(
        r,
        "selectable",
        /*selectable*/
        t[4]
      );
    },
    m(h, c) {
      nn(h, e, c), u && u.m(e, null), ep(e, n), f && f.m(e, null), nn(h, i, c), nn(h, r, c), s = !0, l || (o = ip(
        r,
        "click",
        /*handle_click*/
        t[7]
      ), l = !0);
    },
    p(h, c) {
      /*show_download_button*/
      h[3] ? u ? (u.p(h, c), c & /*show_download_button*/
      8 && Ae(u, 1)) : (u = ho(h), u.c(), Ae(u, 1), u.m(e, n)) : u && (ia(), Xe(u, 1, 1, () => {
        u = null;
      }), ta()), /*show_share_button*/
      h[5] ? f ? (f.p(h, c), c & /*show_share_button*/
      32 && Ae(f, 1)) : (f = co(h), f.c(), Ae(f, 1), f.m(e, null)) : f && (ia(), Xe(f, 1, 1, () => {
        f = null;
      }), ta()), (!s || c & /*value*/
      1 && !uo(r.src, a = /*value*/
      h[0].back)) && nt(r, "src", a), (!s || c & /*selectable*/
      16) && fo(
        r,
        "selectable",
        /*selectable*/
        h[4]
      );
    },
    i(h) {
      s || (Ae(u), Ae(f), s = !0);
    },
    o(h) {
      Xe(u), Xe(f), s = !1;
    },
    d(h) {
      h && (tn(e), tn(i), tn(r)), u && u.d(), f && f.d(), l = !1, o();
    }
  };
}
function op(t) {
  let e, n;
  return e = new rf({
    props: {
      unpadded_box: !0,
      size: "large",
      $$slots: { default: [lp] },
      $$scope: { ctx: t }
    }
  }), {
    c() {
      Gn(e.$$.fragment);
    },
    m(i, r) {
      jn(e, i, r), n = !0;
    },
    p(i, r) {
      const a = {};
      r & /*$$scope*/
      4096 && (a.$$scope = { dirty: r, ctx: i }), e.$set(a);
    },
    i(i) {
      n || (Ae(e.$$.fragment, i), n = !0);
    },
    o(i) {
      Xe(e.$$.fragment, i), n = !1;
    },
    d(i) {
      zn(e, i);
    }
  };
}
function ho(t) {
  let e, n, i, r;
  return n = new rt({
    props: {
      Icon: th,
      label: (
        /*i18n*/
        t[6]("common.download")
      )
    }
  }), {
    c() {
      e = na("a"), Gn(n.$$.fragment), nt(e, "href", i = /*value*/
      t[0].back), nt(e, "target", window.__is_colab__ ? "_blank" : null), nt(e, "download", "image");
    },
    m(a, s) {
      nn(a, e, s), jn(n, e, null), r = !0;
    },
    p(a, s) {
      const l = {};
      s & /*i18n*/
      64 && (l.label = /*i18n*/
      a[6]("common.download")), n.$set(l), (!r || s & /*value*/
      1 && i !== (i = /*value*/
      a[0].back)) && nt(e, "href", i);
    },
    i(a) {
      r || (Ae(n.$$.fragment, a), r = !0);
    },
    o(a) {
      Xe(n.$$.fragment, a), r = !1;
    },
    d(a) {
      a && tn(e), zn(n);
    }
  };
}
function co(t) {
  let e, n;
  return e = new _c({
    props: {
      i18n: (
        /*i18n*/
        t[6]
      ),
      formatter: (
        /*func*/
        t[8]
      ),
      value: (
        /*value*/
        t[0]
      )
    }
  }), e.$on(
    "share",
    /*share_handler*/
    t[9]
  ), e.$on(
    "error",
    /*error_handler*/
    t[10]
  ), {
    c() {
      Gn(e.$$.fragment);
    },
    m(i, r) {
      jn(e, i, r), n = !0;
    },
    p(i, r) {
      const a = {};
      r & /*i18n*/
      64 && (a.i18n = /*i18n*/
      i[6]), r & /*value*/
      1 && (a.value = /*value*/
      i[0]), e.$set(a);
    },
    i(i) {
      n || (Ae(e.$$.fragment, i), n = !0);
    },
    o(i) {
      Xe(e.$$.fragment, i), n = !1;
    },
    d(i) {
      zn(e, i);
    }
  };
}
function lp(t) {
  let e, n;
  return e = new vi({}), {
    c() {
      Gn(e.$$.fragment);
    },
    m(i, r) {
      jn(e, i, r), n = !0;
    },
    i(i) {
      n || (Ae(e.$$.fragment, i), n = !0);
    },
    o(i) {
      Xe(e.$$.fragment, i), n = !1;
    },
    d(i) {
      zn(e, i);
    }
  };
}
function up(t) {
  let e, n, i, r, a, s;
  e = new Lo({
    props: {
      show_label: (
        /*show_label*/
        t[2]
      ),
      Icon: vi,
      label: (
        /*label*/
        t[1] || /*i18n*/
        t[6]("image.image")
      )
    }
  });
  const l = [op, sp], o = [];
  function u(f, h) {
    return (
      /*value*/
      f[0] === null ? 0 : 1
    );
  }
  return i = u(t), r = o[i] = l[i](t), {
    c() {
      Gn(e.$$.fragment), n = ra(), r.c(), a = tp();
    },
    m(f, h) {
      jn(e, f, h), nn(f, n, h), o[i].m(f, h), nn(f, a, h), s = !0;
    },
    p(f, [h]) {
      const c = {};
      h & /*show_label*/
      4 && (c.show_label = /*show_label*/
      f[2]), h & /*label, i18n*/
      66 && (c.label = /*label*/
      f[1] || /*i18n*/
      f[6]("image.image")), e.$set(c);
      let d = i;
      i = u(f), i === d ? o[i].p(f, h) : (ia(), Xe(o[d], 1, 1, () => {
        o[d] = null;
      }), ta(), r = o[i], r ? r.p(f, h) : (r = o[i] = l[i](f), r.c()), Ae(r, 1), r.m(a.parentNode, a));
    },
    i(f) {
      s || (Ae(e.$$.fragment, f), Ae(r), s = !0);
    },
    o(f) {
      Xe(e.$$.fragment, f), Xe(r), s = !1;
    },
    d(f) {
      f && (tn(n), tn(a)), zn(e, f), o[i].d(f);
    }
  };
}
function fp(t, e, n) {
  let { value: i } = e, { label: r = void 0 } = e, { show_label: a } = e, { show_download_button: s = !0 } = e, { selectable: l = !1 } = e, { show_share_button: o = !1 } = e, { i18n: u } = e;
  const f = ap(), h = (m) => {
    let b = Ul(m);
    b && f("select", { index: b, value: null });
  }, c = async (m) => m ? `<img src="${await tc(m, "base64")}" />` : "";
  function d(m) {
    lo.call(this, t, m);
  }
  function _(m) {
    lo.call(this, t, m);
  }
  return t.$$set = (m) => {
    "value" in m && n(0, i = m.value), "label" in m && n(1, r = m.label), "show_label" in m && n(2, a = m.show_label), "show_download_button" in m && n(3, s = m.show_download_button), "selectable" in m && n(4, l = m.selectable), "show_share_button" in m && n(5, o = m.show_share_button), "i18n" in m && n(6, u = m.i18n);
  }, t.$$.update = () => {
    t.$$.dirty & /*value*/
    1 && i && f("change", i.back);
  }, [
    i,
    r,
    a,
    s,
    l,
    o,
    u,
    h,
    c,
    d,
    _
  ];
}
class hp extends $g {
  constructor(e) {
    super(), np(this, e, fp, up, rp, {
      value: 0,
      label: 1,
      show_label: 2,
      show_download_button: 3,
      selectable: 4,
      show_share_button: 5,
      i18n: 6
    });
  }
}
function Jt(t) {
  let e = ["", "k", "M", "G", "T", "P", "E", "Z"], n = 0;
  for (; t > 1e3 && n < e.length - 1; )
    t /= 1e3, n++;
  let i = e[n];
  return (Number.isInteger(t) ? t : t.toFixed(1)) + i;
}
const {
  SvelteComponent: cp,
  append: qe,
  attr: j,
  component_subscribe: _o,
  detach: dp,
  element: _p,
  init: mp,
  insert: gp,
  noop: mo,
  safe_not_equal: pp,
  set_style: ui,
  svg_element: xe,
  toggle_class: go
} = window.__gradio__svelte__internal, { onMount: bp } = window.__gradio__svelte__internal;
function vp(t) {
  let e, n, i, r, a, s, l, o, u, f, h, c;
  return {
    c() {
      e = _p("div"), n = xe("svg"), i = xe("g"), r = xe("path"), a = xe("path"), s = xe("path"), l = xe("path"), o = xe("g"), u = xe("path"), f = xe("path"), h = xe("path"), c = xe("path"), j(r, "d", "M255.926 0.754768L509.702 139.936V221.027L255.926 81.8465V0.754768Z"), j(r, "fill", "#FF7C00"), j(r, "fill-opacity", "0.4"), j(r, "class", "svelte-43sxxs"), j(a, "d", "M509.69 139.936L254.981 279.641V361.255L509.69 221.55V139.936Z"), j(a, "fill", "#FF7C00"), j(a, "class", "svelte-43sxxs"), j(s, "d", "M0.250138 139.937L254.981 279.641V361.255L0.250138 221.55V139.937Z"), j(s, "fill", "#FF7C00"), j(s, "fill-opacity", "0.4"), j(s, "class", "svelte-43sxxs"), j(l, "d", "M255.923 0.232622L0.236328 139.936V221.55L255.923 81.8469V0.232622Z"), j(l, "fill", "#FF7C00"), j(l, "class", "svelte-43sxxs"), ui(i, "transform", "translate(" + /*$top*/
      t[1][0] + "px, " + /*$top*/
      t[1][1] + "px)"), j(u, "d", "M255.926 141.5L509.702 280.681V361.773L255.926 222.592V141.5Z"), j(u, "fill", "#FF7C00"), j(u, "fill-opacity", "0.4"), j(u, "class", "svelte-43sxxs"), j(f, "d", "M509.69 280.679L254.981 420.384V501.998L509.69 362.293V280.679Z"), j(f, "fill", "#FF7C00"), j(f, "class", "svelte-43sxxs"), j(h, "d", "M0.250138 280.681L254.981 420.386V502L0.250138 362.295V280.681Z"), j(h, "fill", "#FF7C00"), j(h, "fill-opacity", "0.4"), j(h, "class", "svelte-43sxxs"), j(c, "d", "M255.923 140.977L0.236328 280.68V362.294L255.923 222.591V140.977Z"), j(c, "fill", "#FF7C00"), j(c, "class", "svelte-43sxxs"), ui(o, "transform", "translate(" + /*$bottom*/
      t[2][0] + "px, " + /*$bottom*/
      t[2][1] + "px)"), j(n, "viewBox", "-1200 -1200 3000 3000"), j(n, "fill", "none"), j(n, "xmlns", "http://www.w3.org/2000/svg"), j(n, "class", "svelte-43sxxs"), j(e, "class", "svelte-43sxxs"), go(
        e,
        "margin",
        /*margin*/
        t[0]
      );
    },
    m(d, _) {
      gp(d, e, _), qe(e, n), qe(n, i), qe(i, r), qe(i, a), qe(i, s), qe(i, l), qe(n, o), qe(o, u), qe(o, f), qe(o, h), qe(o, c);
    },
    p(d, [_]) {
      _ & /*$top*/
      2 && ui(i, "transform", "translate(" + /*$top*/
      d[1][0] + "px, " + /*$top*/
      d[1][1] + "px)"), _ & /*$bottom*/
      4 && ui(o, "transform", "translate(" + /*$bottom*/
      d[2][0] + "px, " + /*$bottom*/
      d[2][1] + "px)"), _ & /*margin*/
      1 && go(
        e,
        "margin",
        /*margin*/
        d[0]
      );
    },
    i: mo,
    o: mo,
    d(d) {
      d && dp(e);
    }
  };
}
function wp(t, e, n) {
  let i, r, { margin: a = !0 } = e;
  const s = _s([0, 0]);
  _o(t, s, (c) => n(1, i = c));
  const l = _s([0, 0]);
  _o(t, l, (c) => n(2, r = c));
  let o;
  async function u() {
    await Promise.all([s.set([125, 140]), l.set([-125, -140])]), await Promise.all([s.set([-125, 140]), l.set([125, -140])]), await Promise.all([s.set([-125, 0]), l.set([125, -0])]), await Promise.all([s.set([125, 0]), l.set([-125, 0])]);
  }
  async function f() {
    await u(), o || f();
  }
  async function h() {
    await Promise.all([s.set([125, 0]), l.set([-125, 0])]), f();
  }
  return bp(() => (h(), () => o = !0)), t.$$set = (c) => {
    "margin" in c && n(0, a = c.margin);
  }, [a, i, r, s, l];
}
class yp extends cp {
  constructor(e) {
    super(), mp(this, e, wp, vp, pp, { margin: 0 });
  }
}
const {
  SvelteComponent: Ep,
  append: Bt,
  attr: Ze,
  binding_callbacks: po,
  check_outros: jl,
  create_component: kp,
  create_slot: Tp,
  destroy_component: Sp,
  destroy_each: ql,
  detach: N,
  element: it,
  empty: vn,
  ensure_array_like: Ai,
  get_all_dirty_from_scope: Cp,
  get_slot_changes: Mp,
  group_outros: xl,
  init: Ap,
  insert: I,
  mount_component: Op,
  noop: aa,
  safe_not_equal: Dp,
  set_data: Ue,
  set_style: pt,
  space: Qe,
  text: ae,
  toggle_class: Le,
  transition_in: hn,
  transition_out: cn,
  update_slot_base: Bp
} = window.__gradio__svelte__internal, { tick: Hp } = window.__gradio__svelte__internal, { onDestroy: Np } = window.__gradio__svelte__internal, Ip = (t) => ({}), bo = (t) => ({});
function vo(t, e, n) {
  const i = t.slice();
  return i[38] = e[n], i[40] = n, i;
}
function wo(t, e, n) {
  const i = t.slice();
  return i[38] = e[n], i;
}
function Rp(t) {
  let e, n = (
    /*i18n*/
    t[1]("common.error") + ""
  ), i, r, a;
  const s = (
    /*#slots*/
    t[29].error
  ), l = Tp(
    s,
    t,
    /*$$scope*/
    t[28],
    bo
  );
  return {
    c() {
      e = it("span"), i = ae(n), r = Qe(), l && l.c(), Ze(e, "class", "error svelte-14miwb5");
    },
    m(o, u) {
      I(o, e, u), Bt(e, i), I(o, r, u), l && l.m(o, u), a = !0;
    },
    p(o, u) {
      (!a || u[0] & /*i18n*/
      2) && n !== (n = /*i18n*/
      o[1]("common.error") + "") && Ue(i, n), l && l.p && (!a || u[0] & /*$$scope*/
      268435456) && Bp(
        l,
        s,
        o,
        /*$$scope*/
        o[28],
        a ? Mp(
          s,
          /*$$scope*/
          o[28],
          u,
          Ip
        ) : Cp(
          /*$$scope*/
          o[28]
        ),
        bo
      );
    },
    i(o) {
      a || (hn(l, o), a = !0);
    },
    o(o) {
      cn(l, o), a = !1;
    },
    d(o) {
      o && (N(e), N(r)), l && l.d(o);
    }
  };
}
function Lp(t) {
  let e, n, i, r, a, s, l, o, u, f = (
    /*variant*/
    t[8] === "default" && /*show_eta_bar*/
    t[18] && /*show_progress*/
    t[6] === "full" && yo(t)
  );
  function h(y, S) {
    if (
      /*progress*/
      y[7]
    )
      return Fp;
    if (
      /*queue_position*/
      y[2] !== null && /*queue_size*/
      y[3] !== void 0 && /*queue_position*/
      y[2] >= 0
    )
      return Up;
    if (
      /*queue_position*/
      y[2] === 0
    )
      return Pp;
  }
  let c = h(t), d = c && c(t), _ = (
    /*timer*/
    t[5] && To(t)
  );
  const m = [qp, jp], b = [];
  function C(y, S) {
    return (
      /*last_progress_level*/
      y[15] != null ? 0 : (
        /*show_progress*/
        y[6] === "full" ? 1 : -1
      )
    );
  }
  ~(a = C(t)) && (s = b[a] = m[a](t));
  let T = !/*timer*/
  t[5] && Bo(t);
  return {
    c() {
      f && f.c(), e = Qe(), n = it("div"), d && d.c(), i = Qe(), _ && _.c(), r = Qe(), s && s.c(), l = Qe(), T && T.c(), o = vn(), Ze(n, "class", "progress-text svelte-14miwb5"), Le(
        n,
        "meta-text-center",
        /*variant*/
        t[8] === "center"
      ), Le(
        n,
        "meta-text",
        /*variant*/
        t[8] === "default"
      );
    },
    m(y, S) {
      f && f.m(y, S), I(y, e, S), I(y, n, S), d && d.m(n, null), Bt(n, i), _ && _.m(n, null), I(y, r, S), ~a && b[a].m(y, S), I(y, l, S), T && T.m(y, S), I(y, o, S), u = !0;
    },
    p(y, S) {
      /*variant*/
      y[8] === "default" && /*show_eta_bar*/
      y[18] && /*show_progress*/
      y[6] === "full" ? f ? f.p(y, S) : (f = yo(y), f.c(), f.m(e.parentNode, e)) : f && (f.d(1), f = null), c === (c = h(y)) && d ? d.p(y, S) : (d && d.d(1), d = c && c(y), d && (d.c(), d.m(n, i))), /*timer*/
      y[5] ? _ ? _.p(y, S) : (_ = To(y), _.c(), _.m(n, null)) : _ && (_.d(1), _ = null), (!u || S[0] & /*variant*/
      256) && Le(
        n,
        "meta-text-center",
        /*variant*/
        y[8] === "center"
      ), (!u || S[0] & /*variant*/
      256) && Le(
        n,
        "meta-text",
        /*variant*/
        y[8] === "default"
      );
      let p = a;
      a = C(y), a === p ? ~a && b[a].p(y, S) : (s && (xl(), cn(b[p], 1, 1, () => {
        b[p] = null;
      }), jl()), ~a ? (s = b[a], s ? s.p(y, S) : (s = b[a] = m[a](y), s.c()), hn(s, 1), s.m(l.parentNode, l)) : s = null), /*timer*/
      y[5] ? T && (T.d(1), T = null) : T ? T.p(y, S) : (T = Bo(y), T.c(), T.m(o.parentNode, o));
    },
    i(y) {
      u || (hn(s), u = !0);
    },
    o(y) {
      cn(s), u = !1;
    },
    d(y) {
      y && (N(e), N(n), N(r), N(l), N(o)), f && f.d(y), d && d.d(), _ && _.d(), ~a && b[a].d(y), T && T.d(y);
    }
  };
}
function yo(t) {
  let e, n = `translateX(${/*eta_level*/
  (t[17] || 0) * 100 - 100}%)`;
  return {
    c() {
      e = it("div"), Ze(e, "class", "eta-bar svelte-14miwb5"), pt(e, "transform", n);
    },
    m(i, r) {
      I(i, e, r);
    },
    p(i, r) {
      r[0] & /*eta_level*/
      131072 && n !== (n = `translateX(${/*eta_level*/
      (i[17] || 0) * 100 - 100}%)`) && pt(e, "transform", n);
    },
    d(i) {
      i && N(e);
    }
  };
}
function Pp(t) {
  let e;
  return {
    c() {
      e = ae("processing |");
    },
    m(n, i) {
      I(n, e, i);
    },
    p: aa,
    d(n) {
      n && N(e);
    }
  };
}
function Up(t) {
  let e, n = (
    /*queue_position*/
    t[2] + 1 + ""
  ), i, r, a, s;
  return {
    c() {
      e = ae("queue: "), i = ae(n), r = ae("/"), a = ae(
        /*queue_size*/
        t[3]
      ), s = ae(" |");
    },
    m(l, o) {
      I(l, e, o), I(l, i, o), I(l, r, o), I(l, a, o), I(l, s, o);
    },
    p(l, o) {
      o[0] & /*queue_position*/
      4 && n !== (n = /*queue_position*/
      l[2] + 1 + "") && Ue(i, n), o[0] & /*queue_size*/
      8 && Ue(
        a,
        /*queue_size*/
        l[3]
      );
    },
    d(l) {
      l && (N(e), N(i), N(r), N(a), N(s));
    }
  };
}
function Fp(t) {
  let e, n = Ai(
    /*progress*/
    t[7]
  ), i = [];
  for (let r = 0; r < n.length; r += 1)
    i[r] = ko(wo(t, n, r));
  return {
    c() {
      for (let r = 0; r < i.length; r += 1)
        i[r].c();
      e = vn();
    },
    m(r, a) {
      for (let s = 0; s < i.length; s += 1)
        i[s] && i[s].m(r, a);
      I(r, e, a);
    },
    p(r, a) {
      if (a[0] & /*progress*/
      128) {
        n = Ai(
          /*progress*/
          r[7]
        );
        let s;
        for (s = 0; s < n.length; s += 1) {
          const l = wo(r, n, s);
          i[s] ? i[s].p(l, a) : (i[s] = ko(l), i[s].c(), i[s].m(e.parentNode, e));
        }
        for (; s < i.length; s += 1)
          i[s].d(1);
        i.length = n.length;
      }
    },
    d(r) {
      r && N(e), ql(i, r);
    }
  };
}
function Eo(t) {
  let e, n = (
    /*p*/
    t[38].unit + ""
  ), i, r, a = " ", s;
  function l(f, h) {
    return (
      /*p*/
      f[38].length != null ? zp : Gp
    );
  }
  let o = l(t), u = o(t);
  return {
    c() {
      u.c(), e = Qe(), i = ae(n), r = ae(" | "), s = ae(a);
    },
    m(f, h) {
      u.m(f, h), I(f, e, h), I(f, i, h), I(f, r, h), I(f, s, h);
    },
    p(f, h) {
      o === (o = l(f)) && u ? u.p(f, h) : (u.d(1), u = o(f), u && (u.c(), u.m(e.parentNode, e))), h[0] & /*progress*/
      128 && n !== (n = /*p*/
      f[38].unit + "") && Ue(i, n);
    },
    d(f) {
      f && (N(e), N(i), N(r), N(s)), u.d(f);
    }
  };
}
function Gp(t) {
  let e = Jt(
    /*p*/
    t[38].index || 0
  ) + "", n;
  return {
    c() {
      n = ae(e);
    },
    m(i, r) {
      I(i, n, r);
    },
    p(i, r) {
      r[0] & /*progress*/
      128 && e !== (e = Jt(
        /*p*/
        i[38].index || 0
      ) + "") && Ue(n, e);
    },
    d(i) {
      i && N(n);
    }
  };
}
function zp(t) {
  let e = Jt(
    /*p*/
    t[38].index || 0
  ) + "", n, i, r = Jt(
    /*p*/
    t[38].length
  ) + "", a;
  return {
    c() {
      n = ae(e), i = ae("/"), a = ae(r);
    },
    m(s, l) {
      I(s, n, l), I(s, i, l), I(s, a, l);
    },
    p(s, l) {
      l[0] & /*progress*/
      128 && e !== (e = Jt(
        /*p*/
        s[38].index || 0
      ) + "") && Ue(n, e), l[0] & /*progress*/
      128 && r !== (r = Jt(
        /*p*/
        s[38].length
      ) + "") && Ue(a, r);
    },
    d(s) {
      s && (N(n), N(i), N(a));
    }
  };
}
function ko(t) {
  let e, n = (
    /*p*/
    t[38].index != null && Eo(t)
  );
  return {
    c() {
      n && n.c(), e = vn();
    },
    m(i, r) {
      n && n.m(i, r), I(i, e, r);
    },
    p(i, r) {
      /*p*/
      i[38].index != null ? n ? n.p(i, r) : (n = Eo(i), n.c(), n.m(e.parentNode, e)) : n && (n.d(1), n = null);
    },
    d(i) {
      i && N(e), n && n.d(i);
    }
  };
}
function To(t) {
  let e, n = (
    /*eta*/
    t[0] ? `/${/*formatted_eta*/
    t[19]}` : ""
  ), i, r;
  return {
    c() {
      e = ae(
        /*formatted_timer*/
        t[20]
      ), i = ae(n), r = ae("s");
    },
    m(a, s) {
      I(a, e, s), I(a, i, s), I(a, r, s);
    },
    p(a, s) {
      s[0] & /*formatted_timer*/
      1048576 && Ue(
        e,
        /*formatted_timer*/
        a[20]
      ), s[0] & /*eta, formatted_eta*/
      524289 && n !== (n = /*eta*/
      a[0] ? `/${/*formatted_eta*/
      a[19]}` : "") && Ue(i, n);
    },
    d(a) {
      a && (N(e), N(i), N(r));
    }
  };
}
function jp(t) {
  let e, n;
  return e = new yp({
    props: { margin: (
      /*variant*/
      t[8] === "default"
    ) }
  }), {
    c() {
      kp(e.$$.fragment);
    },
    m(i, r) {
      Op(e, i, r), n = !0;
    },
    p(i, r) {
      const a = {};
      r[0] & /*variant*/
      256 && (a.margin = /*variant*/
      i[8] === "default"), e.$set(a);
    },
    i(i) {
      n || (hn(e.$$.fragment, i), n = !0);
    },
    o(i) {
      cn(e.$$.fragment, i), n = !1;
    },
    d(i) {
      Sp(e, i);
    }
  };
}
function qp(t) {
  let e, n, i, r, a, s = `${/*last_progress_level*/
  t[15] * 100}%`, l = (
    /*progress*/
    t[7] != null && So(t)
  );
  return {
    c() {
      e = it("div"), n = it("div"), l && l.c(), i = Qe(), r = it("div"), a = it("div"), Ze(n, "class", "progress-level-inner svelte-14miwb5"), Ze(a, "class", "progress-bar svelte-14miwb5"), pt(a, "width", s), Ze(r, "class", "progress-bar-wrap svelte-14miwb5"), Ze(e, "class", "progress-level svelte-14miwb5");
    },
    m(o, u) {
      I(o, e, u), Bt(e, n), l && l.m(n, null), Bt(e, i), Bt(e, r), Bt(r, a), t[30](a);
    },
    p(o, u) {
      /*progress*/
      o[7] != null ? l ? l.p(o, u) : (l = So(o), l.c(), l.m(n, null)) : l && (l.d(1), l = null), u[0] & /*last_progress_level*/
      32768 && s !== (s = `${/*last_progress_level*/
      o[15] * 100}%`) && pt(a, "width", s);
    },
    i: aa,
    o: aa,
    d(o) {
      o && N(e), l && l.d(), t[30](null);
    }
  };
}
function So(t) {
  let e, n = Ai(
    /*progress*/
    t[7]
  ), i = [];
  for (let r = 0; r < n.length; r += 1)
    i[r] = Do(vo(t, n, r));
  return {
    c() {
      for (let r = 0; r < i.length; r += 1)
        i[r].c();
      e = vn();
    },
    m(r, a) {
      for (let s = 0; s < i.length; s += 1)
        i[s] && i[s].m(r, a);
      I(r, e, a);
    },
    p(r, a) {
      if (a[0] & /*progress_level, progress*/
      16512) {
        n = Ai(
          /*progress*/
          r[7]
        );
        let s;
        for (s = 0; s < n.length; s += 1) {
          const l = vo(r, n, s);
          i[s] ? i[s].p(l, a) : (i[s] = Do(l), i[s].c(), i[s].m(e.parentNode, e));
        }
        for (; s < i.length; s += 1)
          i[s].d(1);
        i.length = n.length;
      }
    },
    d(r) {
      r && N(e), ql(i, r);
    }
  };
}
function Co(t) {
  let e, n, i, r, a = (
    /*i*/
    t[40] !== 0 && xp()
  ), s = (
    /*p*/
    t[38].desc != null && Mo(t)
  ), l = (
    /*p*/
    t[38].desc != null && /*progress_level*/
    t[14] && /*progress_level*/
    t[14][
      /*i*/
      t[40]
    ] != null && Ao()
  ), o = (
    /*progress_level*/
    t[14] != null && Oo(t)
  );
  return {
    c() {
      a && a.c(), e = Qe(), s && s.c(), n = Qe(), l && l.c(), i = Qe(), o && o.c(), r = vn();
    },
    m(u, f) {
      a && a.m(u, f), I(u, e, f), s && s.m(u, f), I(u, n, f), l && l.m(u, f), I(u, i, f), o && o.m(u, f), I(u, r, f);
    },
    p(u, f) {
      /*p*/
      u[38].desc != null ? s ? s.p(u, f) : (s = Mo(u), s.c(), s.m(n.parentNode, n)) : s && (s.d(1), s = null), /*p*/
      u[38].desc != null && /*progress_level*/
      u[14] && /*progress_level*/
      u[14][
        /*i*/
        u[40]
      ] != null ? l || (l = Ao(), l.c(), l.m(i.parentNode, i)) : l && (l.d(1), l = null), /*progress_level*/
      u[14] != null ? o ? o.p(u, f) : (o = Oo(u), o.c(), o.m(r.parentNode, r)) : o && (o.d(1), o = null);
    },
    d(u) {
      u && (N(e), N(n), N(i), N(r)), a && a.d(u), s && s.d(u), l && l.d(u), o && o.d(u);
    }
  };
}
function xp(t) {
  let e;
  return {
    c() {
      e = ae(" /");
    },
    m(n, i) {
      I(n, e, i);
    },
    d(n) {
      n && N(e);
    }
  };
}
function Mo(t) {
  let e = (
    /*p*/
    t[38].desc + ""
  ), n;
  return {
    c() {
      n = ae(e);
    },
    m(i, r) {
      I(i, n, r);
    },
    p(i, r) {
      r[0] & /*progress*/
      128 && e !== (e = /*p*/
      i[38].desc + "") && Ue(n, e);
    },
    d(i) {
      i && N(n);
    }
  };
}
function Ao(t) {
  let e;
  return {
    c() {
      e = ae("-");
    },
    m(n, i) {
      I(n, e, i);
    },
    d(n) {
      n && N(e);
    }
  };
}
function Oo(t) {
  let e = (100 * /*progress_level*/
  (t[14][
    /*i*/
    t[40]
  ] || 0)).toFixed(1) + "", n, i;
  return {
    c() {
      n = ae(e), i = ae("%");
    },
    m(r, a) {
      I(r, n, a), I(r, i, a);
    },
    p(r, a) {
      a[0] & /*progress_level*/
      16384 && e !== (e = (100 * /*progress_level*/
      (r[14][
        /*i*/
        r[40]
      ] || 0)).toFixed(1) + "") && Ue(n, e);
    },
    d(r) {
      r && (N(n), N(i));
    }
  };
}
function Do(t) {
  let e, n = (
    /*p*/
    (t[38].desc != null || /*progress_level*/
    t[14] && /*progress_level*/
    t[14][
      /*i*/
      t[40]
    ] != null) && Co(t)
  );
  return {
    c() {
      n && n.c(), e = vn();
    },
    m(i, r) {
      n && n.m(i, r), I(i, e, r);
    },
    p(i, r) {
      /*p*/
      i[38].desc != null || /*progress_level*/
      i[14] && /*progress_level*/
      i[14][
        /*i*/
        i[40]
      ] != null ? n ? n.p(i, r) : (n = Co(i), n.c(), n.m(e.parentNode, e)) : n && (n.d(1), n = null);
    },
    d(i) {
      i && N(e), n && n.d(i);
    }
  };
}
function Bo(t) {
  let e, n;
  return {
    c() {
      e = it("p"), n = ae(
        /*loading_text*/
        t[9]
      ), Ze(e, "class", "loading svelte-14miwb5");
    },
    m(i, r) {
      I(i, e, r), Bt(e, n);
    },
    p(i, r) {
      r[0] & /*loading_text*/
      512 && Ue(
        n,
        /*loading_text*/
        i[9]
      );
    },
    d(i) {
      i && N(e);
    }
  };
}
function Xp(t) {
  let e, n, i, r, a;
  const s = [Lp, Rp], l = [];
  function o(u, f) {
    return (
      /*status*/
      u[4] === "pending" ? 0 : (
        /*status*/
        u[4] === "error" ? 1 : -1
      )
    );
  }
  return ~(n = o(t)) && (i = l[n] = s[n](t)), {
    c() {
      e = it("div"), i && i.c(), Ze(e, "class", r = "wrap " + /*variant*/
      t[8] + " " + /*show_progress*/
      t[6] + " svelte-14miwb5"), Le(e, "hide", !/*status*/
      t[4] || /*status*/
      t[4] === "complete" || /*show_progress*/
      t[6] === "hidden"), Le(
        e,
        "translucent",
        /*variant*/
        t[8] === "center" && /*status*/
        (t[4] === "pending" || /*status*/
        t[4] === "error") || /*translucent*/
        t[11] || /*show_progress*/
        t[6] === "minimal"
      ), Le(
        e,
        "generating",
        /*status*/
        t[4] === "generating"
      ), Le(
        e,
        "border",
        /*border*/
        t[12]
      ), pt(
        e,
        "position",
        /*absolute*/
        t[10] ? "absolute" : "static"
      ), pt(
        e,
        "padding",
        /*absolute*/
        t[10] ? "0" : "var(--size-8) 0"
      );
    },
    m(u, f) {
      I(u, e, f), ~n && l[n].m(e, null), t[31](e), a = !0;
    },
    p(u, f) {
      let h = n;
      n = o(u), n === h ? ~n && l[n].p(u, f) : (i && (xl(), cn(l[h], 1, 1, () => {
        l[h] = null;
      }), jl()), ~n ? (i = l[n], i ? i.p(u, f) : (i = l[n] = s[n](u), i.c()), hn(i, 1), i.m(e, null)) : i = null), (!a || f[0] & /*variant, show_progress*/
      320 && r !== (r = "wrap " + /*variant*/
      u[8] + " " + /*show_progress*/
      u[6] + " svelte-14miwb5")) && Ze(e, "class", r), (!a || f[0] & /*variant, show_progress, status, show_progress*/
      336) && Le(e, "hide", !/*status*/
      u[4] || /*status*/
      u[4] === "complete" || /*show_progress*/
      u[6] === "hidden"), (!a || f[0] & /*variant, show_progress, variant, status, translucent, show_progress*/
      2384) && Le(
        e,
        "translucent",
        /*variant*/
        u[8] === "center" && /*status*/
        (u[4] === "pending" || /*status*/
        u[4] === "error") || /*translucent*/
        u[11] || /*show_progress*/
        u[6] === "minimal"
      ), (!a || f[0] & /*variant, show_progress, status*/
      336) && Le(
        e,
        "generating",
        /*status*/
        u[4] === "generating"
      ), (!a || f[0] & /*variant, show_progress, border*/
      4416) && Le(
        e,
        "border",
        /*border*/
        u[12]
      ), f[0] & /*absolute*/
      1024 && pt(
        e,
        "position",
        /*absolute*/
        u[10] ? "absolute" : "static"
      ), f[0] & /*absolute*/
      1024 && pt(
        e,
        "padding",
        /*absolute*/
        u[10] ? "0" : "var(--size-8) 0"
      );
    },
    i(u) {
      a || (hn(i), a = !0);
    },
    o(u) {
      cn(i), a = !1;
    },
    d(u) {
      u && N(e), ~n && l[n].d(), t[31](null);
    }
  };
}
let fi = [], Er = !1;
async function Vp(t, e = !0) {
  if (!(window.__gradio_mode__ === "website" || window.__gradio_mode__ !== "app" && e !== !0)) {
    if (fi.push(t), !Er)
      Er = !0;
    else
      return;
    await Hp(), requestAnimationFrame(() => {
      let n = [0, 0];
      for (let i = 0; i < fi.length; i++) {
        const a = fi[i].getBoundingClientRect();
        (i === 0 || a.top + window.scrollY <= n[0]) && (n[0] = a.top + window.scrollY, n[1] = i);
      }
      window.scrollTo({ top: n[0] - 20, behavior: "smooth" }), Er = !1, fi = [];
    });
  }
}
function Wp(t, e, n) {
  let i, { $$slots: r = {}, $$scope: a } = e, { i18n: s } = e, { eta: l = null } = e, { queue: o = !1 } = e, { queue_position: u } = e, { queue_size: f } = e, { status: h } = e, { scroll_to_output: c = !1 } = e, { timer: d = !0 } = e, { show_progress: _ = "full" } = e, { message: m = null } = e, { progress: b = null } = e, { variant: C = "default" } = e, { loading_text: T = "Loading..." } = e, { absolute: y = !0 } = e, { translucent: S = !1 } = e, { border: p = !1 } = e, { autoscroll: g } = e, M, O = !1, G = 0, q = 0, ee = null, z = 0, E = null, D, L = null, Y = !0;
  const Z = () => {
    n(25, G = performance.now()), n(26, q = 0), O = !0, V();
  };
  function V() {
    requestAnimationFrame(() => {
      n(26, q = (performance.now() - G) / 1e3), O && V();
    });
  }
  function fe() {
    n(26, q = 0), O && (O = !1);
  }
  Np(() => {
    O && fe();
  });
  let Te = null;
  function be(A) {
    po[A ? "unshift" : "push"](() => {
      L = A, n(16, L), n(7, b), n(14, E), n(15, D);
    });
  }
  function He(A) {
    po[A ? "unshift" : "push"](() => {
      M = A, n(13, M);
    });
  }
  return t.$$set = (A) => {
    "i18n" in A && n(1, s = A.i18n), "eta" in A && n(0, l = A.eta), "queue" in A && n(21, o = A.queue), "queue_position" in A && n(2, u = A.queue_position), "queue_size" in A && n(3, f = A.queue_size), "status" in A && n(4, h = A.status), "scroll_to_output" in A && n(22, c = A.scroll_to_output), "timer" in A && n(5, d = A.timer), "show_progress" in A && n(6, _ = A.show_progress), "message" in A && n(23, m = A.message), "progress" in A && n(7, b = A.progress), "variant" in A && n(8, C = A.variant), "loading_text" in A && n(9, T = A.loading_text), "absolute" in A && n(10, y = A.absolute), "translucent" in A && n(11, S = A.translucent), "border" in A && n(12, p = A.border), "autoscroll" in A && n(24, g = A.autoscroll), "$$scope" in A && n(28, a = A.$$scope);
  }, t.$$.update = () => {
    t.$$.dirty[0] & /*eta, old_eta, queue, timer_start*/
    169869313 && (l === null ? n(0, l = ee) : o && n(0, l = (performance.now() - G) / 1e3 + l), l != null && (n(19, Te = l.toFixed(1)), n(27, ee = l))), t.$$.dirty[0] & /*eta, timer_diff*/
    67108865 && n(17, z = l === null || l <= 0 || !q ? null : Math.min(q / l, 1)), t.$$.dirty[0] & /*progress*/
    128 && b != null && n(18, Y = !1), t.$$.dirty[0] & /*progress, progress_level, progress_bar, last_progress_level*/
    114816 && (b != null ? n(14, E = b.map((A) => {
      if (A.index != null && A.length != null)
        return A.index / A.length;
      if (A.progress != null)
        return A.progress;
    })) : n(14, E = null), E ? (n(15, D = E[E.length - 1]), L && (D === 0 ? n(16, L.style.transition = "0", L) : n(16, L.style.transition = "150ms", L))) : n(15, D = void 0)), t.$$.dirty[0] & /*status*/
    16 && (h === "pending" ? Z() : fe()), t.$$.dirty[0] & /*el, scroll_to_output, status, autoscroll*/
    20979728 && M && c && (h === "pending" || h === "complete") && Vp(M, g), t.$$.dirty[0] & /*status, message*/
    8388624, t.$$.dirty[0] & /*timer_diff*/
    67108864 && n(20, i = q.toFixed(1));
  }, [
    l,
    s,
    u,
    f,
    h,
    d,
    _,
    b,
    C,
    T,
    y,
    S,
    p,
    M,
    E,
    D,
    L,
    z,
    Y,
    Te,
    i,
    o,
    c,
    m,
    g,
    G,
    q,
    ee,
    a,
    r,
    be,
    He
  ];
}
class Xl extends Ep {
  constructor(e) {
    super(), Ap(
      this,
      e,
      Wp,
      Xp,
      Dp,
      {
        i18n: 1,
        eta: 0,
        queue: 21,
        queue_position: 2,
        queue_size: 3,
        status: 4,
        scroll_to_output: 22,
        timer: 5,
        show_progress: 6,
        message: 23,
        progress: 7,
        variant: 8,
        loading_text: 9,
        absolute: 10,
        translucent: 11,
        border: 12,
        autoscroll: 24
      },
      null,
      [-1, -1]
    );
  }
}
const {
  SvelteComponent: Yp,
  add_flush_callback: Zp,
  assign: Vl,
  bind: Qp,
  binding_callbacks: Jp,
  check_outros: Kp,
  create_component: It,
  destroy_component: Rt,
  detach: Ma,
  empty: $p,
  flush: W,
  get_spread_object: Wl,
  get_spread_update: Yl,
  group_outros: e1,
  init: t1,
  insert: Aa,
  mount_component: Lt,
  safe_not_equal: n1,
  space: Zl,
  transition_in: st,
  transition_out: ot
} = window.__gradio__svelte__internal;
function i1(t) {
  let e, n;
  return e = new Ro({
    props: {
      visible: (
        /*visible*/
        t[4]
      ),
      variant: (
        /*value*/
        t[0] === null && /*source*/
        t[7] === "upload" ? "dashed" : "solid"
      ),
      border_mode: (
        /*dragging*/
        t[27] ? "focus" : "base"
      ),
      padding: !1,
      elem_id: (
        /*elem_id*/
        t[2]
      ),
      elem_classes: (
        /*elem_classes*/
        t[3]
      ),
      height: (
        /*height*/
        t[11] || /*source*/
        (t[7] === "webcam" ? void 0 : Ho)
      ),
      width: (
        /*width*/
        t[12]
      ),
      allow_overflow: !1,
      container: (
        /*container*/
        t[19]
      ),
      scale: (
        /*scale*/
        t[20]
      ),
      min_width: (
        /*min_width*/
        t[21]
      ),
      $$slots: { default: [s1] },
      $$scope: { ctx: t }
    }
  }), {
    c() {
      It(e.$$.fragment);
    },
    m(i, r) {
      Lt(e, i, r), n = !0;
    },
    p(i, r) {
      const a = {};
      r[0] & /*visible*/
      16 && (a.visible = /*visible*/
      i[4]), r[0] & /*value, source*/
      129 && (a.variant = /*value*/
      i[0] === null && /*source*/
      i[7] === "upload" ? "dashed" : "solid"), r[0] & /*dragging*/
      134217728 && (a.border_mode = /*dragging*/
      i[27] ? "focus" : "base"), r[0] & /*elem_id*/
      4 && (a.elem_id = /*elem_id*/
      i[2]), r[0] & /*elem_classes*/
      8 && (a.elem_classes = /*elem_classes*/
      i[3]), r[0] & /*height, source*/
      2176 && (a.height = /*height*/
      i[11] || /*source*/
      (i[7] === "webcam" ? void 0 : Ho)), r[0] & /*width*/
      4096 && (a.width = /*width*/
      i[12]), r[0] & /*container*/
      524288 && (a.container = /*container*/
      i[19]), r[0] & /*scale*/
      1048576 && (a.scale = /*scale*/
      i[20]), r[0] & /*min_width*/
      2097152 && (a.min_width = /*min_width*/
      i[21]), r[0] & /*brush_radius, brush_color, shape, source, tool, selectable, mask_opacity, label, show_label, pending, streaming, mirror_webcam, root, gradio, value, dragging, loading_status*/
      235399139 | r[1] & /*$$scope*/
      512 && (a.$$scope = { dirty: r, ctx: i }), e.$set(a);
    },
    i(i) {
      n || (st(e.$$.fragment, i), n = !0);
    },
    o(i) {
      ot(e.$$.fragment, i), n = !1;
    },
    d(i) {
      Rt(e, i);
    }
  };
}
function r1(t) {
  let e, n;
  return e = new Ro({
    props: {
      visible: (
        /*visible*/
        t[4]
      ),
      variant: "solid",
      border_mode: (
        /*dragging*/
        t[27] ? "focus" : "base"
      ),
      padding: !1,
      elem_id: (
        /*elem_id*/
        t[2]
      ),
      elem_classes: (
        /*elem_classes*/
        t[3]
      ),
      height: (
        /*height*/
        t[11] || void 0
      ),
      width: (
        /*width*/
        t[12]
      ),
      allow_overflow: !1,
      container: (
        /*container*/
        t[19]
      ),
      scale: (
        /*scale*/
        t[20]
      ),
      min_width: (
        /*min_width*/
        t[21]
      ),
      $$slots: { default: [o1] },
      $$scope: { ctx: t }
    }
  }), {
    c() {
      It(e.$$.fragment);
    },
    m(i, r) {
      Lt(e, i, r), n = !0;
    },
    p(i, r) {
      const a = {};
      r[0] & /*visible*/
      16 && (a.visible = /*visible*/
      i[4]), r[0] & /*dragging*/
      134217728 && (a.border_mode = /*dragging*/
      i[27] ? "focus" : "base"), r[0] & /*elem_id*/
      4 && (a.elem_id = /*elem_id*/
      i[2]), r[0] & /*elem_classes*/
      8 && (a.elem_classes = /*elem_classes*/
      i[3]), r[0] & /*height*/
      2048 && (a.height = /*height*/
      i[11] || void 0), r[0] & /*width*/
      4096 && (a.width = /*width*/
      i[12]), r[0] & /*container*/
      524288 && (a.container = /*container*/
      i[19]), r[0] & /*scale*/
      1048576 && (a.scale = /*scale*/
      i[20]), r[0] & /*min_width*/
      2097152 && (a.min_width = /*min_width*/
      i[21]), r[0] & /*value, label, show_label, show_download_button, selectable, show_share_button, root, gradio, loading_status*/
      113508451 | r[1] & /*$$scope*/
      512 && (a.$$scope = { dirty: r, ctx: i }), e.$set(a);
    },
    i(i) {
      n || (st(e.$$.fragment, i), n = !0);
    },
    o(i) {
      ot(e.$$.fragment, i), n = !1;
    },
    d(i) {
      Rt(e, i);
    }
  };
}
function a1(t) {
  let e, n;
  return e = new Sc({
    props: {
      i18n: (
        /*gradio*/
        t[25].i18n
      ),
      type: "image"
    }
  }), {
    c() {
      It(e.$$.fragment);
    },
    m(i, r) {
      Lt(e, i, r), n = !0;
    },
    p(i, r) {
      const a = {};
      r[0] & /*gradio*/
      33554432 && (a.i18n = /*gradio*/
      i[25].i18n), e.$set(a);
    },
    i(i) {
      n || (st(e.$$.fragment, i), n = !0);
    },
    o(i) {
      ot(e.$$.fragment, i), n = !1;
    },
    d(i) {
      Rt(e, i);
    }
  };
}
function s1(t) {
  let e, n, i, r, a;
  const s = [
    {
      autoscroll: (
        /*gradio*/
        t[25].autoscroll
      )
    },
    { i18n: (
      /*gradio*/
      t[25].i18n
    ) },
    /*loading_status*/
    t[1]
  ];
  let l = {};
  for (let f = 0; f < s.length; f += 1)
    l = Vl(l, s[f]);
  e = new Xl({ props: l });
  function o(f) {
    t[31](f);
  }
  let u = {
    brush_radius: (
      /*brush_radius*/
      t[15]
    ),
    brush_color: (
      /*brush_color*/
      t[16]
    ),
    shape: (
      /*shape*/
      t[14]
    ),
    source: (
      /*source*/
      t[7]
    ),
    tool: (
      /*tool*/
      t[8]
    ),
    selectable: (
      /*selectable*/
      t[18]
    ),
    mask_opacity: (
      /*mask_opacity*/
      t[17]
    ),
    label: (
      /*label*/
      t[5]
    ),
    show_label: (
      /*show_label*/
      t[6]
    ),
    pending: (
      /*pending*/
      t[10]
    ),
    streaming: (
      /*streaming*/
      t[9]
    ),
    mirror_webcam: (
      /*mirror_webcam*/
      t[13]
    ),
    root: (
      /*root*/
      t[26]
    ),
    i18n: (
      /*gradio*/
      t[25].i18n
    ),
    $$slots: { default: [a1] },
    $$scope: { ctx: t }
  };
  return (
    /*value*/
    t[0] !== void 0 && (u.value = /*value*/
    t[0]), i = new Kg({ props: u }), Jp.push(() => Qp(i, "value", o)), i.$on(
      "edit",
      /*edit_handler*/
      t[32]
    ), i.$on(
      "clear",
      /*clear_handler*/
      t[33]
    ), i.$on(
      "stream",
      /*stream_handler*/
      t[34]
    ), i.$on(
      "drag",
      /*drag_handler*/
      t[35]
    ), i.$on(
      "upload",
      /*upload_handler*/
      t[36]
    ), i.$on(
      "select",
      /*select_handler_1*/
      t[37]
    ), i.$on(
      "share",
      /*share_handler_1*/
      t[38]
    ), i.$on(
      "error",
      /*error_handler_1*/
      t[39]
    ), {
      c() {
        It(e.$$.fragment), n = Zl(), It(i.$$.fragment);
      },
      m(f, h) {
        Lt(e, f, h), Aa(f, n, h), Lt(i, f, h), a = !0;
      },
      p(f, h) {
        const c = h[0] & /*gradio, loading_status*/
        33554434 ? Yl(s, [
          h[0] & /*gradio*/
          33554432 && {
            autoscroll: (
              /*gradio*/
              f[25].autoscroll
            )
          },
          h[0] & /*gradio*/
          33554432 && { i18n: (
            /*gradio*/
            f[25].i18n
          ) },
          h[0] & /*loading_status*/
          2 && Wl(
            /*loading_status*/
            f[1]
          )
        ]) : {};
        e.$set(c);
        const d = {};
        h[0] & /*brush_radius*/
        32768 && (d.brush_radius = /*brush_radius*/
        f[15]), h[0] & /*brush_color*/
        65536 && (d.brush_color = /*brush_color*/
        f[16]), h[0] & /*shape*/
        16384 && (d.shape = /*shape*/
        f[14]), h[0] & /*source*/
        128 && (d.source = /*source*/
        f[7]), h[0] & /*tool*/
        256 && (d.tool = /*tool*/
        f[8]), h[0] & /*selectable*/
        262144 && (d.selectable = /*selectable*/
        f[18]), h[0] & /*mask_opacity*/
        131072 && (d.mask_opacity = /*mask_opacity*/
        f[17]), h[0] & /*label*/
        32 && (d.label = /*label*/
        f[5]), h[0] & /*show_label*/
        64 && (d.show_label = /*show_label*/
        f[6]), h[0] & /*pending*/
        1024 && (d.pending = /*pending*/
        f[10]), h[0] & /*streaming*/
        512 && (d.streaming = /*streaming*/
        f[9]), h[0] & /*mirror_webcam*/
        8192 && (d.mirror_webcam = /*mirror_webcam*/
        f[13]), h[0] & /*root*/
        67108864 && (d.root = /*root*/
        f[26]), h[0] & /*gradio*/
        33554432 && (d.i18n = /*gradio*/
        f[25].i18n), h[0] & /*gradio*/
        33554432 | h[1] & /*$$scope*/
        512 && (d.$$scope = { dirty: h, ctx: f }), !r && h[0] & /*value*/
        1 && (r = !0, d.value = /*value*/
        f[0], Zp(() => r = !1)), i.$set(d);
      },
      i(f) {
        a || (st(e.$$.fragment, f), st(i.$$.fragment, f), a = !0);
      },
      o(f) {
        ot(e.$$.fragment, f), ot(i.$$.fragment, f), a = !1;
      },
      d(f) {
        f && Ma(n), Rt(e, f), Rt(i, f);
      }
    }
  );
}
function o1(t) {
  let e, n, i, r;
  const a = [
    {
      autoscroll: (
        /*gradio*/
        t[25].autoscroll
      )
    },
    { i18n: (
      /*gradio*/
      t[25].i18n
    ) },
    /*loading_status*/
    t[1]
  ];
  let s = {};
  for (let l = 0; l < a.length; l += 1)
    s = Vl(s, a[l]);
  return e = new Xl({ props: s }), i = new hp({
    props: {
      value: (
        /*value*/
        t[0]
      ),
      label: (
        /*label*/
        t[5]
      ),
      show_label: (
        /*show_label*/
        t[6]
      ),
      show_download_button: (
        /*show_download_button*/
        t[22]
      ),
      selectable: (
        /*selectable*/
        t[18]
      ),
      show_share_button: (
        /*show_share_button*/
        t[23]
      ),
      root: (
        /*root*/
        t[26]
      ),
      i18n: (
        /*gradio*/
        t[25].i18n
      )
    }
  }), i.$on(
    "select",
    /*select_handler*/
    t[28]
  ), i.$on(
    "share",
    /*share_handler*/
    t[29]
  ), i.$on(
    "error",
    /*error_handler*/
    t[30]
  ), {
    c() {
      It(e.$$.fragment), n = Zl(), It(i.$$.fragment);
    },
    m(l, o) {
      Lt(e, l, o), Aa(l, n, o), Lt(i, l, o), r = !0;
    },
    p(l, o) {
      const u = o[0] & /*gradio, loading_status*/
      33554434 ? Yl(a, [
        o[0] & /*gradio*/
        33554432 && {
          autoscroll: (
            /*gradio*/
            l[25].autoscroll
          )
        },
        o[0] & /*gradio*/
        33554432 && { i18n: (
          /*gradio*/
          l[25].i18n
        ) },
        o[0] & /*loading_status*/
        2 && Wl(
          /*loading_status*/
          l[1]
        )
      ]) : {};
      e.$set(u);
      const f = {};
      o[0] & /*value*/
      1 && (f.value = /*value*/
      l[0]), o[0] & /*label*/
      32 && (f.label = /*label*/
      l[5]), o[0] & /*show_label*/
      64 && (f.show_label = /*show_label*/
      l[6]), o[0] & /*show_download_button*/
      4194304 && (f.show_download_button = /*show_download_button*/
      l[22]), o[0] & /*selectable*/
      262144 && (f.selectable = /*selectable*/
      l[18]), o[0] & /*show_share_button*/
      8388608 && (f.show_share_button = /*show_share_button*/
      l[23]), o[0] & /*root*/
      67108864 && (f.root = /*root*/
      l[26]), o[0] & /*gradio*/
      33554432 && (f.i18n = /*gradio*/
      l[25].i18n), i.$set(f);
    },
    i(l) {
      r || (st(e.$$.fragment, l), st(i.$$.fragment, l), r = !0);
    },
    o(l) {
      ot(e.$$.fragment, l), ot(i.$$.fragment, l), r = !1;
    },
    d(l) {
      l && Ma(n), Rt(e, l), Rt(i, l);
    }
  };
}
function l1(t) {
  let e, n, i, r;
  const a = [r1, i1], s = [];
  function l(o, u) {
    return (
      /*interactive*/
      o[24] ? 1 : 0
    );
  }
  return e = l(t), n = s[e] = a[e](t), {
    c() {
      n.c(), i = $p();
    },
    m(o, u) {
      s[e].m(o, u), Aa(o, i, u), r = !0;
    },
    p(o, u) {
      let f = e;
      e = l(o), e === f ? s[e].p(o, u) : (e1(), ot(s[f], 1, 1, () => {
        s[f] = null;
      }), Kp(), n = s[e], n ? n.p(o, u) : (n = s[e] = a[e](o), n.c()), st(n, 1), n.m(i.parentNode, i));
    },
    i(o) {
      r || (st(n), r = !0);
    },
    o(o) {
      ot(n), r = !1;
    },
    d(o) {
      o && Ma(i), s[e].d(o);
    }
  };
}
const Ho = 240;
function u1(t, e, n) {
  let { elem_id: i = "" } = e, { elem_classes: r = [] } = e, { visible: a = !0 } = e, { value: s = null } = e, { label: l } = e, { show_label: o } = e, { source: u = "upload" } = e, { tool: f = "editor" } = e, { streaming: h } = e, { pending: c } = e, { height: d } = e, { width: _ } = e, { mirror_webcam: m } = e, { shape: b } = e, { brush_radius: C } = e, { brush_color: T } = e, { mask_opacity: y } = e, { selectable: S = !1 } = e, { container: p = !0 } = e, { scale: g = null } = e, { min_width: M = void 0 } = e, { loading_status: O } = e, { show_download_button: G } = e, { show_share_button: q = !1 } = e, { interactive: ee } = e, { gradio: z } = e, { root: E } = e, D;
  const L = ({ detail: k }) => z.dispatch("select", k), Y = ({ detail: k }) => z.dispatch("share", k), Z = ({ detail: k }) => z.dispatch("error", k);
  function V(k) {
    s = k, n(0, s);
  }
  const fe = () => z.dispatch("edit"), Te = () => z.dispatch("clear"), be = () => z.dispatch("stream"), He = ({ detail: k }) => n(27, D = k), A = () => z.dispatch("upload"), lt = ({ detail: k }) => z.dispatch("select", k), wt = ({ detail: k }) => z.dispatch("share", k), Ft = ({ detail: k }) => {
    n(1, O = O || {}), n(1, O.status = "error", O), z.dispatch("error", k);
  };
  return t.$$set = (k) => {
    "elem_id" in k && n(2, i = k.elem_id), "elem_classes" in k && n(3, r = k.elem_classes), "visible" in k && n(4, a = k.visible), "value" in k && n(0, s = k.value), "label" in k && n(5, l = k.label), "show_label" in k && n(6, o = k.show_label), "source" in k && n(7, u = k.source), "tool" in k && n(8, f = k.tool), "streaming" in k && n(9, h = k.streaming), "pending" in k && n(10, c = k.pending), "height" in k && n(11, d = k.height), "width" in k && n(12, _ = k.width), "mirror_webcam" in k && n(13, m = k.mirror_webcam), "shape" in k && n(14, b = k.shape), "brush_radius" in k && n(15, C = k.brush_radius), "brush_color" in k && n(16, T = k.brush_color), "mask_opacity" in k && n(17, y = k.mask_opacity), "selectable" in k && n(18, S = k.selectable), "container" in k && n(19, p = k.container), "scale" in k && n(20, g = k.scale), "min_width" in k && n(21, M = k.min_width), "loading_status" in k && n(1, O = k.loading_status), "show_download_button" in k && n(22, G = k.show_download_button), "show_share_button" in k && n(23, q = k.show_share_button), "interactive" in k && n(24, ee = k.interactive), "gradio" in k && n(25, z = k.gradio), "root" in k && n(26, E = k.root);
  }, t.$$.update = () => {
    t.$$.dirty[0] & /*value*/
    1 && n(0, s = s || null), t.$$.dirty[0] & /*value, gradio*/
    33554433 && z.dispatch("change");
  }, [
    s,
    O,
    i,
    r,
    a,
    l,
    o,
    u,
    f,
    h,
    c,
    d,
    _,
    m,
    b,
    C,
    T,
    y,
    S,
    p,
    g,
    M,
    G,
    q,
    ee,
    z,
    E,
    D,
    L,
    Y,
    Z,
    V,
    fe,
    Te,
    be,
    He,
    A,
    lt,
    wt,
    Ft
  ];
}
class d1 extends Yp {
  constructor(e) {
    super(), t1(
      this,
      e,
      u1,
      l1,
      n1,
      {
        elem_id: 2,
        elem_classes: 3,
        visible: 4,
        value: 0,
        label: 5,
        show_label: 6,
        source: 7,
        tool: 8,
        streaming: 9,
        pending: 10,
        height: 11,
        width: 12,
        mirror_webcam: 13,
        shape: 14,
        brush_radius: 15,
        brush_color: 16,
        mask_opacity: 17,
        selectable: 18,
        container: 19,
        scale: 20,
        min_width: 21,
        loading_status: 1,
        show_download_button: 22,
        show_share_button: 23,
        interactive: 24,
        gradio: 25,
        root: 26
      },
      null,
      [-1, -1]
    );
  }
  get elem_id() {
    return this.$$.ctx[2];
  }
  set elem_id(e) {
    this.$$set({ elem_id: e }), W();
  }
  get elem_classes() {
    return this.$$.ctx[3];
  }
  set elem_classes(e) {
    this.$$set({ elem_classes: e }), W();
  }
  get visible() {
    return this.$$.ctx[4];
  }
  set visible(e) {
    this.$$set({ visible: e }), W();
  }
  get value() {
    return this.$$.ctx[0];
  }
  set value(e) {
    this.$$set({ value: e }), W();
  }
  get label() {
    return this.$$.ctx[5];
  }
  set label(e) {
    this.$$set({ label: e }), W();
  }
  get show_label() {
    return this.$$.ctx[6];
  }
  set show_label(e) {
    this.$$set({ show_label: e }), W();
  }
  get source() {
    return this.$$.ctx[7];
  }
  set source(e) {
    this.$$set({ source: e }), W();
  }
  get tool() {
    return this.$$.ctx[8];
  }
  set tool(e) {
    this.$$set({ tool: e }), W();
  }
  get streaming() {
    return this.$$.ctx[9];
  }
  set streaming(e) {
    this.$$set({ streaming: e }), W();
  }
  get pending() {
    return this.$$.ctx[10];
  }
  set pending(e) {
    this.$$set({ pending: e }), W();
  }
  get height() {
    return this.$$.ctx[11];
  }
  set height(e) {
    this.$$set({ height: e }), W();
  }
  get width() {
    return this.$$.ctx[12];
  }
  set width(e) {
    this.$$set({ width: e }), W();
  }
  get mirror_webcam() {
    return this.$$.ctx[13];
  }
  set mirror_webcam(e) {
    this.$$set({ mirror_webcam: e }), W();
  }
  get shape() {
    return this.$$.ctx[14];
  }
  set shape(e) {
    this.$$set({ shape: e }), W();
  }
  get brush_radius() {
    return this.$$.ctx[15];
  }
  set brush_radius(e) {
    this.$$set({ brush_radius: e }), W();
  }
  get brush_color() {
    return this.$$.ctx[16];
  }
  set brush_color(e) {
    this.$$set({ brush_color: e }), W();
  }
  get mask_opacity() {
    return this.$$.ctx[17];
  }
  set mask_opacity(e) {
    this.$$set({ mask_opacity: e }), W();
  }
  get selectable() {
    return this.$$.ctx[18];
  }
  set selectable(e) {
    this.$$set({ selectable: e }), W();
  }
  get container() {
    return this.$$.ctx[19];
  }
  set container(e) {
    this.$$set({ container: e }), W();
  }
  get scale() {
    return this.$$.ctx[20];
  }
  set scale(e) {
    this.$$set({ scale: e }), W();
  }
  get min_width() {
    return this.$$.ctx[21];
  }
  set min_width(e) {
    this.$$set({ min_width: e }), W();
  }
  get loading_status() {
    return this.$$.ctx[1];
  }
  set loading_status(e) {
    this.$$set({ loading_status: e }), W();
  }
  get show_download_button() {
    return this.$$.ctx[22];
  }
  set show_download_button(e) {
    this.$$set({ show_download_button: e }), W();
  }
  get show_share_button() {
    return this.$$.ctx[23];
  }
  set show_share_button(e) {
    this.$$set({ show_share_button: e }), W();
  }
  get interactive() {
    return this.$$.ctx[24];
  }
  set interactive(e) {
    this.$$set({ interactive: e }), W();
  }
  get gradio() {
    return this.$$.ctx[25];
  }
  set gradio(e) {
    this.$$set({ gradio: e }), W();
  }
  get root() {
    return this.$$.ctx[26];
  }
  set root(e) {
    this.$$set({ root: e }), W();
  }
}
export {
  km as Webcam,
  d1 as default
};
