const _u = [
  { 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 }
], Ba = {
  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"
  }
};
_u.reduce(
  (t, { color: e, primary: n, secondary: i }) => ({
    ...t,
    [e]: {
      primary: Ba[e][n],
      secondary: Ba[e][i]
    }
  }),
  {}
);
function xt() {
}
const mu = (t) => t;
function gu(t) {
  return t();
}
function pu(t) {
  t.forEach(gu);
}
function bu(t) {
  return typeof t == "function";
}
function vu(t, e) {
  return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function";
}
function Jo(t, ...e) {
  if (t == null) {
    for (const i of e)
      i(void 0);
    return xt;
  }
  const n = t.subscribe(...e);
  return n.unsubscribe ? () => n.unsubscribe() : n;
}
function wu(t) {
  let e;
  return Jo(t, (n) => e = n)(), e;
}
const Qo = typeof window < "u";
let Na = Qo ? () => window.performance.now() : () => Date.now(), Ko = Qo ? (t) => requestAnimationFrame(t) : xt;
const fn = /* @__PURE__ */ new Set();
function $o(t) {
  fn.forEach((e) => {
    e.c(t) || (fn.delete(e), e.f());
  }), fn.size !== 0 && Ko($o);
}
function yu(t) {
  let e;
  return fn.size === 0 && Ko($o), {
    promise: new Promise((n) => {
      fn.add(e = { c: t, f: n });
    }),
    abort() {
      fn.delete(e);
    }
  };
}
function Ia(t, { delay: e = 0, duration: n = 400, easing: i = mu } = {}) {
  const r = +getComputedStyle(t).opacity;
  return {
    delay: e,
    duration: n,
    easing: i,
    css: (a) => `opacity: ${a * r}`
  };
}
const Kt = [];
function Eu(t, e) {
  return {
    subscribe: Wn(t, e).subscribe
  };
}
function Wn(t, e = xt) {
  let n;
  const i = /* @__PURE__ */ new Set();
  function r(l) {
    if (vu(t, l) && (t = l, n)) {
      const o = !Kt.length;
      for (const u of i)
        u[1](), Kt.push(u, t);
      if (o) {
        for (let u = 0; u < Kt.length; u += 2)
          Kt[u][0](Kt[u + 1]);
        Kt.length = 0;
      }
    }
  }
  function a(l) {
    r(l(t));
  }
  function s(l, o = xt) {
    const u = [l, o];
    return i.add(u), i.size === 1 && (n = e(r, a) || xt), l(t), () => {
      i.delete(u), i.size === 0 && n && (n(), n = null);
    };
  }
  return { set: r, update: a, subscribe: s };
}
function kn(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 Eu(n, (s, l) => {
    let o = !1;
    const u = [];
    let f = 0, c = xt;
    const h = () => {
      if (f)
        return;
      c();
      const _ = e(i ? u[0] : u, s, l);
      a ? s(_) : c = bu(_) ? _ : xt;
    }, d = r.map(
      (_, g) => Jo(
        _,
        (v) => {
          u[g] = v, f &= ~(1 << g), o && h();
        },
        () => {
          f |= 1 << g;
        }
      )
    );
    return o = !0, h(), function() {
      pu(d), c(), o = !1;
    };
  });
}
function Ha(t) {
  return Object.prototype.toString.call(t) === "[object Date]";
}
function Tr(t, e, n, i) {
  if (typeof n == "number" || Ha(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, Ha(n) ? new Date(n.getTime() + u) : n + u);
  } else {
    if (Array.isArray(n))
      return n.map(
        (r, a) => Tr(t, e[a], n[a], i[a])
      );
    if (typeof n == "object") {
      const r = {};
      for (const a in n)
        r[a] = Tr(t, e[a], n[a], i[a]);
      return r;
    } else
      throw new Error(`Cannot spring ${typeof n} values`);
  }
}
function Ra(t, e = {}) {
  const n = Wn(t), { stiffness: i = 0.15, damping: r = 0.8, precision: a = 0.01 } = e;
  let s, l, o, u = t, f = t, c = 1, h = 0, d = !1;
  function _(v, k = {}) {
    f = v;
    const T = o = {};
    return t == null || k.hard || g.stiffness >= 1 && g.damping >= 1 ? (d = !0, s = Na(), u = v, n.set(t = f), Promise.resolve()) : (k.soft && (h = 1 / ((k.soft === !0 ? 0.5 : +k.soft) * 60), c = 0), l || (s = Na(), d = !1, l = yu((E) => {
      if (d)
        return d = !1, l = null, !1;
      c = Math.min(c + h, 1);
      const S = {
        inv_mass: c,
        opts: g,
        settled: !0,
        dt: (E - s) * 60 / 1e3
      }, p = Tr(S, u, t, f);
      return s = E, u = t, n.set(t = p), S.settled && (l = null), !S.settled;
    })), new Promise((E) => {
      l.promise.then(() => {
        T === o && E();
      });
    }));
  }
  const g = {
    set: _,
    update: (v, k) => _(v(f, t), k),
    subscribe: n.subscribe,
    stiffness: i,
    damping: r,
    precision: a
  };
  return g;
}
function ku(t) {
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
}
var Su = function(e) {
  return Tu(e) && !Cu(e);
};
function Tu(t) {
  return !!t && typeof t == "object";
}
function Cu(t) {
  var e = Object.prototype.toString.call(t);
  return e === "[object RegExp]" || e === "[object Date]" || Du(t);
}
var Au = typeof Symbol == "function" && Symbol.for, Mu = Au ? Symbol.for("react.element") : 60103;
function Du(t) {
  return t.$$typeof === Mu;
}
function Ou(t) {
  return Array.isArray(t) ? [] : {};
}
function jn(t, e) {
  return e.clone !== !1 && e.isMergeableObject(t) ? mn(Ou(t), t, e) : t;
}
function Bu(t, e, n) {
  return t.concat(e).map(function(i) {
    return jn(i, n);
  });
}
function Nu(t, e) {
  if (!e.customMerge)
    return mn;
  var n = e.customMerge(t);
  return typeof n == "function" ? n : mn;
}
function Iu(t) {
  return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(t).filter(function(e) {
    return Object.propertyIsEnumerable.call(t, e);
  }) : [];
}
function La(t) {
  return Object.keys(t).concat(Iu(t));
}
function el(t, e) {
  try {
    return e in t;
  } catch {
    return !1;
  }
}
function Hu(t, e) {
  return el(t, e) && !(Object.hasOwnProperty.call(t, e) && Object.propertyIsEnumerable.call(t, e));
}
function Ru(t, e, n) {
  var i = {};
  return n.isMergeableObject(t) && La(t).forEach(function(r) {
    i[r] = jn(t[r], n);
  }), La(e).forEach(function(r) {
    Hu(t, r) || (el(t, r) && n.isMergeableObject(e[r]) ? i[r] = Nu(r, n)(t[r], e[r], n) : i[r] = jn(e[r], n));
  }), i;
}
function mn(t, e, n) {
  n = n || {}, n.arrayMerge = n.arrayMerge || Bu, n.isMergeableObject = n.isMergeableObject || Su, n.cloneUnlessOtherwiseSpecified = jn;
  var i = Array.isArray(e), r = Array.isArray(t), a = i === r;
  return a ? i ? n.arrayMerge(t, e, n) : Ru(t, e, n) : jn(e, n);
}
mn.all = function(e, n) {
  if (!Array.isArray(e))
    throw new Error("first argument should be an array");
  return e.reduce(function(i, r) {
    return mn(i, r, n);
  }, {});
};
var Lu = mn, Pu = Lu;
const Uu = /* @__PURE__ */ ku(Pu);
var Cr = function(t, e) {
  return Cr = 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]);
  }, Cr(t, e);
};
function Di(t, e) {
  if (typeof e != "function" && e !== null)
    throw new TypeError("Class extends value " + String(e) + " is not a constructor or null");
  Cr(t, e);
  function n() {
    this.constructor = t;
  }
  t.prototype = e === null ? Object.create(e) : (n.prototype = e.prototype, new n());
}
var J = function() {
  return J = 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;
  }, J.apply(this, arguments);
};
function qi(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 q;
(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";
})(q || (q = {}));
var se;
(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";
})(se || (se = {}));
var gn;
(function(t) {
  t[t.number = 0] = "number", t[t.dateTime = 1] = "dateTime";
})(gn || (gn = {}));
function Pa(t) {
  return t.type === se.literal;
}
function Fu(t) {
  return t.type === se.argument;
}
function tl(t) {
  return t.type === se.number;
}
function nl(t) {
  return t.type === se.date;
}
function il(t) {
  return t.type === se.time;
}
function rl(t) {
  return t.type === se.select;
}
function al(t) {
  return t.type === se.plural;
}
function zu(t) {
  return t.type === se.pound;
}
function sl(t) {
  return t.type === se.tag;
}
function ol(t) {
  return !!(t && typeof t == "object" && t.type === gn.number);
}
function Ar(t) {
  return !!(t && typeof t == "object" && t.type === gn.dateTime);
}
var ll = /[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/, Gu = /(?:[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 ju(t) {
  var e = {};
  return t.replace(Gu, 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 qu = /[\t-\r \x85\u200E\u200F\u2028\u2029]/i;
function xu(t) {
  if (t.length === 0)
    throw new Error("Number skeleton cannot be empty");
  for (var e = t.split(qu).filter(function(h) {
    return h.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 c = f[u];
      if (c.length === 0)
        throw new Error("Invalid number skeleton");
    }
    n.push({ stem: l, options: o });
  }
  return n;
}
function Xu(t) {
  return t.replace(/^(.*?)-/, "");
}
var Ua = /^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g, ul = /^(@+)?(\+|#+)?[rs]?$/g, Vu = /(\*)(0+)|(#+)(0+)|(0+)/g, fl = /^(0+)$/;
function Fa(t) {
  var e = {};
  return t[t.length - 1] === "r" ? e.roundingPriority = "morePrecision" : t[t.length - 1] === "s" && (e.roundingPriority = "lessPrecision"), t.replace(ul, 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 cl(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 Wu(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)), !fl.test(t))
      throw new Error("Malformed concise eng/scientific notation");
    e.minimumIntegerDigits = t.length;
  }
  return e;
}
function za(t) {
  var e = {}, n = cl(t);
  return n || e;
}
function Yu(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 = Xu(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 = J(J(J({}, e), { notation: "scientific" }), r.options.reduce(function(o, u) {
          return J(J({}, o), za(u));
        }, {}));
        continue;
      case "engineering":
        e = J(J(J({}, e), { notation: "engineering" }), r.options.reduce(function(o, u) {
          return J(J({}, o), za(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(Vu, function(o, u, f, c, h, d) {
          if (u)
            e.minimumIntegerDigits = f.length;
          else {
            if (c && h)
              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 (fl.test(r.stem)) {
      e.minimumIntegerDigits = r.stem.length;
      continue;
    }
    if (Ua.test(r.stem)) {
      if (r.options.length > 1)
        throw new RangeError("Fraction-precision stems only accept a single optional option");
      r.stem.replace(Ua, function(o, u, f, c, h, d) {
        return f === "*" ? e.minimumFractionDigits = u.length : c && c[0] === "#" ? e.maximumFractionDigits = c.length : h && d ? (e.minimumFractionDigits = h.length, e.maximumFractionDigits = h.length + d.length) : (e.minimumFractionDigits = u.length, e.maximumFractionDigits = u.length), "";
      });
      var a = r.options[0];
      a === "w" ? e = J(J({}, e), { trailingZeroDisplay: "stripIfInteger" }) : a && (e = J(J({}, e), Fa(a)));
      continue;
    }
    if (ul.test(r.stem)) {
      e = J(J({}, e), Fa(r.stem));
      continue;
    }
    var s = cl(r.stem);
    s && (e = J(J({}, e), s));
    var l = Wu(r.stem);
    l && (e = J(J({}, e), l));
  }
  return e;
}
var ni = {
  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 Zu(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 = Ju(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 Ju(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 = ni[i || ""] || ni[n || ""] || ni["".concat(n, "-001")] || ni["001"];
  return r[0];
}
var xi, Qu = new RegExp("^".concat(ll.source, "*")), Ku = new RegExp("".concat(ll.source, "*$"));
function V(t, e) {
  return { start: t, end: e };
}
var $u = !!String.prototype.startsWith, ef = !!String.fromCodePoint, tf = !!Object.fromEntries, nf = !!String.prototype.codePointAt, rf = !!String.prototype.trimStart, af = !!String.prototype.trimEnd, sf = !!Number.isSafeInteger, of = sf ? Number.isSafeInteger : function(t) {
  return typeof t == "number" && isFinite(t) && Math.floor(t) === t && Math.abs(t) <= 9007199254740991;
}, Mr = !0;
try {
  var lf = dl("([^\\p{White_Space}\\p{Pattern_Syntax}]*)", "yu");
  Mr = ((xi = lf.exec("a")) === null || xi === void 0 ? void 0 : xi[0]) === "a";
} catch {
  Mr = !1;
}
var Ga = $u ? (
  // Native
  function(e, n, i) {
    return e.startsWith(n, i);
  }
) : (
  // For IE11
  function(e, n, i) {
    return e.slice(i, i + n.length) === n;
  }
), Dr = ef ? 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;
  }
), ja = (
  // native
  tf ? 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;
    }
  )
), hl = nf ? (
  // 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;
    }
  }
), uf = rf ? (
  // Native
  function(e) {
    return e.trimStart();
  }
) : (
  // Ponyfill
  function(e) {
    return e.replace(Qu, "");
  }
), ff = af ? (
  // Native
  function(e) {
    return e.trimEnd();
  }
) : (
  // Ponyfill
  function(e) {
    return e.replace(Ku, "");
  }
);
function dl(t, e) {
  return new RegExp(t, e);
}
var Or;
if (Mr) {
  var qa = dl("([^\\p{White_Space}\\p{Pattern_Syntax}]*)", "yu");
  Or = function(e, n) {
    var i;
    qa.lastIndex = n;
    var r = qa.exec(e);
    return (i = r[1]) !== null && i !== void 0 ? i : "";
  };
} else
  Or = function(e, n) {
    for (var i = []; ; ) {
      var r = hl(e, n);
      if (r === void 0 || _l(r) || _f(r))
        break;
      i.push(r), n += r >= 65536 ? 2 : 1;
    }
    return Dr.apply(void 0, i);
  };
var cf = (
  /** @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: se.pound,
              location: V(l, this.clonePosition())
            });
          } else if (a === 60 && !this.ignoreTag && this.peek() === 47) {
            if (i)
              break;
            return this.error(q.UNMATCHED_CLOSING_TAG, V(this.clonePosition(), this.clonePosition()));
          } else if (a === 60 && !this.ignoreTag && Br(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: se.literal,
            value: "<".concat(r, "/>"),
            location: V(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() || !Br(this.char()))
            return this.error(q.INVALID_TAG, V(l, this.clonePosition()));
          var o = this.clonePosition(), u = this.parseTagName();
          return r !== u ? this.error(q.UNMATCHED_CLOSING_TAG, V(o, this.clonePosition())) : (this.bumpSpace(), this.bumpIf(">") ? {
            val: {
              type: se.tag,
              value: r,
              children: s,
              location: V(i, this.clonePosition())
            },
            err: null
          } : this.error(q.INVALID_TAG, V(l, this.clonePosition())));
        } else
          return this.error(q.UNCLOSED_TAG, V(i, this.clonePosition()));
      } else
        return this.error(q.INVALID_TAG, V(i, this.clonePosition()));
    }, t.prototype.parseTagName = function() {
      var e = this.offset();
      for (this.bump(); !this.isEOF() && df(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 = V(i, this.clonePosition());
      return {
        val: { type: se.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.
      !hf(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 Dr.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(), Dr(i));
    }, t.prototype.parseArgument = function(e, n) {
      var i = this.clonePosition();
      if (this.bump(), this.bumpSpace(), this.isEOF())
        return this.error(q.EXPECT_ARGUMENT_CLOSING_BRACE, V(i, this.clonePosition()));
      if (this.char() === 125)
        return this.bump(), this.error(q.EMPTY_ARGUMENT, V(i, this.clonePosition()));
      var r = this.parseIdentifierIfPossible().value;
      if (!r)
        return this.error(q.MALFORMED_ARGUMENT, V(i, this.clonePosition()));
      if (this.bumpSpace(), this.isEOF())
        return this.error(q.EXPECT_ARGUMENT_CLOSING_BRACE, V(i, this.clonePosition()));
      switch (this.char()) {
        case 125:
          return this.bump(), {
            val: {
              type: se.argument,
              // value does not include the opening and closing braces.
              value: r,
              location: V(i, this.clonePosition())
            },
            err: null
          };
        case 44:
          return this.bump(), this.bumpSpace(), this.isEOF() ? this.error(q.EXPECT_ARGUMENT_CLOSING_BRACE, V(i, this.clonePosition())) : this.parseArgumentOptions(e, n, r, i);
        default:
          return this.error(q.MALFORMED_ARGUMENT, V(i, this.clonePosition()));
      }
    }, t.prototype.parseIdentifierIfPossible = function() {
      var e = this.clonePosition(), n = this.offset(), i = Or(this.message, n), r = n + i.length;
      this.bumpTo(r);
      var a = this.clonePosition(), s = V(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(q.EXPECT_ARGUMENT_TYPE, V(s, o));
        case "number":
        case "date":
        case "time": {
          this.bumpSpace();
          var u = null;
          if (this.bumpIf(",")) {
            this.bumpSpace();
            var f = this.clonePosition(), c = this.parseSimpleArgStyleIfPossible();
            if (c.err)
              return c;
            var h = ff(c.val);
            if (h.length === 0)
              return this.error(q.EXPECT_ARGUMENT_STYLE, V(this.clonePosition(), this.clonePosition()));
            var d = V(f, this.clonePosition());
            u = { style: h, styleLocation: d };
          }
          var _ = this.tryParseArgumentClose(r);
          if (_.err)
            return _;
          var g = V(r, this.clonePosition());
          if (u && Ga(u == null ? void 0 : u.style, "::", 0)) {
            var v = uf(u.style.slice(2));
            if (l === "number") {
              var c = this.parseNumberSkeletonFromString(v, u.styleLocation);
              return c.err ? c : {
                val: { type: se.number, value: i, location: g, style: c.val },
                err: null
              };
            } else {
              if (v.length === 0)
                return this.error(q.EXPECT_DATE_TIME_SKELETON, g);
              var k = v;
              this.locale && (k = Zu(v, this.locale));
              var h = {
                type: gn.dateTime,
                pattern: k,
                location: u.styleLocation,
                parsedOptions: this.shouldParseSkeletons ? ju(k) : {}
              }, T = l === "date" ? se.date : se.time;
              return {
                val: { type: T, value: i, location: g, style: h },
                err: null
              };
            }
          }
          return {
            val: {
              type: l === "number" ? se.number : l === "date" ? se.date : se.time,
              value: i,
              location: g,
              style: (a = u == null ? void 0 : u.style) !== null && a !== void 0 ? a : null
            },
            err: null
          };
        }
        case "plural":
        case "selectordinal":
        case "select": {
          var E = this.clonePosition();
          if (this.bumpSpace(), !this.bumpIf(","))
            return this.error(q.EXPECT_SELECT_ARGUMENT_OPTIONS, V(E, J({}, E)));
          this.bumpSpace();
          var S = this.parseIdentifierIfPossible(), p = 0;
          if (l !== "select" && S.value === "offset") {
            if (!this.bumpIf(":"))
              return this.error(q.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, V(this.clonePosition(), this.clonePosition()));
            this.bumpSpace();
            var c = this.tryParseDecimalInteger(q.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, q.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);
            if (c.err)
              return c;
            this.bumpSpace(), S = this.parseIdentifierIfPossible(), p = c.val;
          }
          var m = this.tryParsePluralOrSelectOptions(e, l, n, S);
          if (m.err)
            return m;
          var _ = this.tryParseArgumentClose(r);
          if (_.err)
            return _;
          var D = V(r, this.clonePosition());
          return l === "select" ? {
            val: {
              type: se.select,
              value: i,
              options: ja(m.val),
              location: D
            },
            err: null
          } : {
            val: {
              type: se.plural,
              value: i,
              options: ja(m.val),
              offset: p,
              pluralType: l === "plural" ? "cardinal" : "ordinal",
              location: D
            },
            err: null
          };
        }
        default:
          return this.error(q.INVALID_ARGUMENT_TYPE, V(s, o));
      }
    }, t.prototype.tryParseArgumentClose = function(e) {
      return this.isEOF() || this.char() !== 125 ? this.error(q.EXPECT_ARGUMENT_CLOSING_BRACE, V(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(q.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE, V(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 = xu(e);
      } catch {
        return this.error(q.INVALID_NUMBER_SKELETON, n);
      }
      return {
        val: {
          type: gn.number,
          tokens: i,
          location: n,
          parsedOptions: this.shouldParseSkeletons ? Yu(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 c = this.clonePosition();
          if (n !== "select" && this.bumpIf("=")) {
            var h = this.tryParseDecimalInteger(q.EXPECT_PLURAL_ARGUMENT_SELECTOR, q.INVALID_PLURAL_ARGUMENT_SELECTOR);
            if (h.err)
              return h;
            f = V(c, this.clonePosition()), u = this.message.slice(c.offset, this.offset());
          } else
            break;
        }
        if (o.has(u))
          return this.error(n === "select" ? q.DUPLICATE_SELECT_ARGUMENT_SELECTOR : q.DUPLICATE_PLURAL_ARGUMENT_SELECTOR, f);
        u === "other" && (s = !0), this.bumpSpace();
        var d = this.clonePosition();
        if (!this.bumpIf("{"))
          return this.error(n === "select" ? q.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT : q.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT, V(this.clonePosition(), this.clonePosition()));
        var _ = this.parseMessage(e + 1, n, i);
        if (_.err)
          return _;
        var g = this.tryParseArgumentClose(d);
        if (g.err)
          return g;
        l.push([
          u,
          {
            value: _.val,
            location: V(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" ? q.EXPECT_SELECT_ARGUMENT_SELECTOR : q.EXPECT_PLURAL_ARGUMENT_SELECTOR, V(this.clonePosition(), this.clonePosition())) : this.requiresOtherClause && !s ? this.error(q.MISSING_OTHER_CLAUSE, V(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 = V(r, this.clonePosition());
      return a ? (s *= i, of(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 = hl(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 (Ga(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() && _l(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 Br(t) {
  return t >= 97 && t <= 122 || t >= 65 && t <= 90;
}
function hf(t) {
  return Br(t) || t === 47;
}
function df(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 _l(t) {
  return t >= 9 && t <= 13 || t === 32 || t === 133 || t >= 8206 && t <= 8207 || t === 8232 || t === 8233;
}
function _f(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 Nr(t) {
  t.forEach(function(e) {
    if (delete e.location, rl(e) || al(e))
      for (var n in e.options)
        delete e.options[n].location, Nr(e.options[n].value);
    else
      tl(e) && ol(e.style) || (nl(e) || il(e)) && Ar(e.style) ? delete e.style.location : sl(e) && Nr(e.children);
  });
}
function mf(t, e) {
  e === void 0 && (e = {}), e = J({ shouldParseSkeletons: !0, requiresOtherClause: !0 }, e);
  var n = new cf(t, e).parse();
  if (n.err) {
    var i = SyntaxError(q[n.err.kind]);
    throw i.location = n.err.location, i.originalMessage = n.err.message, i;
  }
  return e != null && e.captureLocation || Nr(n.val), n.val;
}
function Xi(t, e) {
  var n = e && e.cache ? e.cache : yf, i = e && e.serializer ? e.serializer : wf, r = e && e.strategy ? e.strategy : pf;
  return r(t, {
    cache: n,
    serializer: i
  });
}
function gf(t) {
  return t == null || typeof t == "number" || typeof t == "boolean";
}
function ml(t, e, n, i) {
  var r = gf(i) ? i : n(i), a = e.get(r);
  return typeof a > "u" && (a = t.call(this, i), e.set(r, a)), a;
}
function gl(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 aa(t, e, n, i, r) {
  return n.bind(e, t, i, r);
}
function pf(t, e) {
  var n = t.length === 1 ? ml : gl;
  return aa(t, this, n, e.cache.create(), e.serializer);
}
function bf(t, e) {
  return aa(t, this, gl, e.cache.create(), e.serializer);
}
function vf(t, e) {
  return aa(t, this, ml, e.cache.create(), e.serializer);
}
var wf = function() {
  return JSON.stringify(arguments);
};
function sa() {
  this.cache = /* @__PURE__ */ Object.create(null);
}
sa.prototype.get = function(t) {
  return this.cache[t];
};
sa.prototype.set = function(t, e) {
  this.cache[t] = e;
};
var yf = {
  create: function() {
    return new sa();
  }
}, Vi = {
  variadic: bf,
  monadic: vf
}, pn;
(function(t) {
  t.MISSING_VALUE = "MISSING_VALUE", t.INVALID_VALUE = "INVALID_VALUE", t.MISSING_INTL_API = "MISSING_INTL_API";
})(pn || (pn = {}));
var Oi = (
  /** @class */
  function(t) {
    Di(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)
), xa = (
  /** @class */
  function(t) {
    Di(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('", "'), '"'), pn.INVALID_VALUE, a) || this;
    }
    return e;
  }(Oi)
), Ef = (
  /** @class */
  function(t) {
    Di(e, t);
    function e(n, i, r) {
      return t.call(this, 'Value for "'.concat(n, '" must be of type ').concat(i), pn.INVALID_VALUE, r) || this;
    }
    return e;
  }(Oi)
), kf = (
  /** @class */
  function(t) {
    Di(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, '"'), pn.MISSING_VALUE, i) || this;
    }
    return e;
  }(Oi)
), Ce;
(function(t) {
  t[t.literal = 0] = "literal", t[t.object = 1] = "object";
})(Ce || (Ce = {}));
function Sf(t) {
  return t.length < 2 ? t : t.reduce(function(e, n) {
    var i = e[e.length - 1];
    return !i || i.type !== Ce.literal || n.type !== Ce.literal ? e.push(n) : i.value += n.value, e;
  }, []);
}
function Tf(t) {
  return typeof t == "function";
}
function di(t, e, n, i, r, a, s) {
  if (t.length === 1 && Pa(t[0]))
    return [
      {
        type: Ce.literal,
        value: t[0].value
      }
    ];
  for (var l = [], o = 0, u = t; o < u.length; o++) {
    var f = u[o];
    if (Pa(f)) {
      l.push({
        type: Ce.literal,
        value: f.value
      });
      continue;
    }
    if (zu(f)) {
      typeof a == "number" && l.push({
        type: Ce.literal,
        value: n.getNumberFormat(e).format(a)
      });
      continue;
    }
    var c = f.value;
    if (!(r && c in r))
      throw new kf(c, s);
    var h = r[c];
    if (Fu(f)) {
      (!h || typeof h == "string" || typeof h == "number") && (h = typeof h == "string" || typeof h == "number" ? String(h) : ""), l.push({
        type: typeof h == "string" ? Ce.literal : Ce.object,
        value: h
      });
      continue;
    }
    if (nl(f)) {
      var d = typeof f.style == "string" ? i.date[f.style] : Ar(f.style) ? f.style.parsedOptions : void 0;
      l.push({
        type: Ce.literal,
        value: n.getDateTimeFormat(e, d).format(h)
      });
      continue;
    }
    if (il(f)) {
      var d = typeof f.style == "string" ? i.time[f.style] : Ar(f.style) ? f.style.parsedOptions : i.time.medium;
      l.push({
        type: Ce.literal,
        value: n.getDateTimeFormat(e, d).format(h)
      });
      continue;
    }
    if (tl(f)) {
      var d = typeof f.style == "string" ? i.number[f.style] : ol(f.style) ? f.style.parsedOptions : void 0;
      d && d.scale && (h = h * (d.scale || 1)), l.push({
        type: Ce.literal,
        value: n.getNumberFormat(e, d).format(h)
      });
      continue;
    }
    if (sl(f)) {
      var _ = f.children, g = f.value, v = r[g];
      if (!Tf(v))
        throw new Ef(g, "function", s);
      var k = di(_, e, n, i, r, a), T = v(k.map(function(p) {
        return p.value;
      }));
      Array.isArray(T) || (T = [T]), l.push.apply(l, T.map(function(p) {
        return {
          type: typeof p == "string" ? Ce.literal : Ce.object,
          value: p
        };
      }));
    }
    if (rl(f)) {
      var E = f.options[h] || f.options.other;
      if (!E)
        throw new xa(f.value, h, Object.keys(f.options), s);
      l.push.apply(l, di(E.value, e, n, i, r));
      continue;
    }
    if (al(f)) {
      var E = f.options["=".concat(h)];
      if (!E) {
        if (!Intl.PluralRules)
          throw new Oi(`Intl.PluralRules is not available in this environment.
Try polyfilling it using "@formatjs/intl-pluralrules"
`, pn.MISSING_INTL_API, s);
        var S = n.getPluralRules(e, { type: f.pluralType }).select(h - (f.offset || 0));
        E = f.options[S] || f.options.other;
      }
      if (!E)
        throw new xa(f.value, h, Object.keys(f.options), s);
      l.push.apply(l, di(E.value, e, n, i, r, h - (f.offset || 0)));
      continue;
    }
  }
  return Sf(l);
}
function Cf(t, e) {
  return e ? J(J(J({}, t || {}), e || {}), Object.keys(t).reduce(function(n, i) {
    return n[i] = J(J({}, t[i]), e[i] || {}), n;
  }, {})) : t;
}
function Af(t, e) {
  return e ? Object.keys(t).reduce(function(n, i) {
    return n[i] = Cf(t[i], e[i]), n;
  }, J({}, t)) : t;
}
function Wi(t) {
  return {
    create: function() {
      return {
        get: function(e) {
          return t[e];
        },
        set: function(e, n) {
          t[e] = n;
        }
      };
    }
  };
}
function Mf(t) {
  return t === void 0 && (t = {
    number: {},
    dateTime: {},
    pluralRules: {}
  }), {
    getNumberFormat: Xi(function() {
      for (var e, n = [], i = 0; i < arguments.length; i++)
        n[i] = arguments[i];
      return new ((e = Intl.NumberFormat).bind.apply(e, qi([void 0], n, !1)))();
    }, {
      cache: Wi(t.number),
      strategy: Vi.variadic
    }),
    getDateTimeFormat: Xi(function() {
      for (var e, n = [], i = 0; i < arguments.length; i++)
        n[i] = arguments[i];
      return new ((e = Intl.DateTimeFormat).bind.apply(e, qi([void 0], n, !1)))();
    }, {
      cache: Wi(t.dateTime),
      strategy: Vi.variadic
    }),
    getPluralRules: Xi(function() {
      for (var e, n = [], i = 0; i < arguments.length; i++)
        n[i] = arguments[i];
      return new ((e = Intl.PluralRules).bind.apply(e, qi([void 0], n, !1)))();
    }, {
      cache: Wi(t.pluralRules),
      strategy: Vi.variadic
    })
  };
}
var Df = (
  /** @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 !== Ce.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 di(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 = Af(t.formats, i), this.formatters = r && r.formatters || Mf(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 = mf, 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 Of(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 At = {}, Bf = (t, e, n) => n && (e in At || (At[e] = {}), t in At[e] || (At[e][t] = n), n), pl = (t, e) => {
  if (e == null)
    return;
  if (e in At && t in At[e])
    return At[e][t];
  const n = Bi(e);
  for (let i = 0; i < n.length; i++) {
    const r = n[i], a = If(r, t);
    if (a)
      return Bf(t, e, a);
  }
};
let oa;
const Yn = Wn({});
function Nf(t) {
  return oa[t] || null;
}
function bl(t) {
  return t in oa;
}
function If(t, e) {
  if (!bl(t))
    return null;
  const n = Nf(t);
  return Of(n, e);
}
function Hf(t) {
  if (t == null)
    return;
  const e = Bi(t);
  for (let n = 0; n < e.length; n++) {
    const i = e[n];
    if (bl(i))
      return i;
  }
}
function Rf(t, ...e) {
  delete At[t], Yn.update((n) => (n[t] = Uu.all([n[t] || {}, ...e]), n));
}
kn(
  [Yn],
  ([t]) => Object.keys(t)
);
Yn.subscribe((t) => oa = t);
const _i = {};
function Lf(t, e) {
  _i[t].delete(e), _i[t].size === 0 && delete _i[t];
}
function vl(t) {
  return _i[t];
}
function Pf(t) {
  return Bi(t).map((e) => {
    const n = vl(e);
    return [e, n ? [...n] : []];
  }).filter(([, e]) => e.length > 0);
}
function Ir(t) {
  return t == null ? !1 : Bi(t).some(
    (e) => {
      var n;
      return (n = vl(e)) == null ? void 0 : n.size;
    }
  );
}
function Uf(t, e) {
  return Promise.all(
    e.map((i) => (Lf(t, i), i().then((r) => r.default || r)))
  ).then((i) => Rf(t, ...i));
}
const Bn = {};
function wl(t) {
  if (!Ir(t))
    return t in Bn ? Bn[t] : Promise.resolve();
  const e = Pf(t);
  return Bn[t] = Promise.all(
    e.map(
      ([n, i]) => Uf(n, i)
    )
  ).then(() => {
    if (Ir(t))
      return wl(t);
    delete Bn[t];
  }), Bn[t];
}
const Ff = {
  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"
    }
  }
}, zf = {
  fallbackLocale: null,
  loadingDelay: 200,
  formats: Ff,
  warnOnMissingMessages: !0,
  handleMissingMessage: void 0,
  ignoreTag: !0
}, Gf = zf;
function bn() {
  return Gf;
}
const Yi = Wn(!1);
var jf = Object.defineProperty, qf = Object.defineProperties, xf = Object.getOwnPropertyDescriptors, Xa = Object.getOwnPropertySymbols, Xf = Object.prototype.hasOwnProperty, Vf = Object.prototype.propertyIsEnumerable, Va = (t, e, n) => e in t ? jf(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, Wf = (t, e) => {
  for (var n in e || (e = {}))
    Xf.call(e, n) && Va(t, n, e[n]);
  if (Xa)
    for (var n of Xa(e))
      Vf.call(e, n) && Va(t, n, e[n]);
  return t;
}, Yf = (t, e) => qf(t, xf(e));
let Hr;
const vi = Wn(null);
function Wa(t) {
  return t.split("-").map((e, n, i) => i.slice(0, n + 1).join("-")).reverse();
}
function Bi(t, e = bn().fallbackLocale) {
  const n = Wa(t);
  return e ? [.../* @__PURE__ */ new Set([...n, ...Wa(e)])] : n;
}
function Zt() {
  return Hr ?? void 0;
}
vi.subscribe((t) => {
  Hr = t ?? void 0, typeof window < "u" && t != null && document.documentElement.setAttribute("lang", t);
});
const Zf = (t) => {
  if (t && Hf(t) && Ir(t)) {
    const { loadingDelay: e } = bn();
    let n;
    return typeof window < "u" && Zt() != null && e ? n = window.setTimeout(
      () => Yi.set(!0),
      e
    ) : Yi.set(!0), wl(t).then(() => {
      vi.set(t);
    }).finally(() => {
      clearTimeout(n), Yi.set(!1);
    });
  }
  return vi.set(t);
}, Zn = Yf(Wf({}, vi), {
  set: Zf
}), Ni = (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 Jf = Object.defineProperty, wi = Object.getOwnPropertySymbols, yl = Object.prototype.hasOwnProperty, El = Object.prototype.propertyIsEnumerable, Ya = (t, e, n) => e in t ? Jf(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, la = (t, e) => {
  for (var n in e || (e = {}))
    yl.call(e, n) && Ya(t, n, e[n]);
  if (wi)
    for (var n of wi(e))
      El.call(e, n) && Ya(t, n, e[n]);
  return t;
}, Sn = (t, e) => {
  var n = {};
  for (var i in t)
    yl.call(t, i) && e.indexOf(i) < 0 && (n[i] = t[i]);
  if (t != null && wi)
    for (var i of wi(t))
      e.indexOf(i) < 0 && El.call(t, i) && (n[i] = t[i]);
  return n;
};
const qn = (t, e) => {
  const { formats: n } = bn();
  if (t in n && e in n[t])
    return n[t][e];
  throw new Error(`[svelte-i18n] Unknown "${e}" ${t} format.`);
}, Qf = Ni(
  (t) => {
    var e = t, { locale: n, format: i } = e, r = Sn(e, ["locale", "format"]);
    if (n == null)
      throw new Error('[svelte-i18n] A "locale" must be set to format numbers');
    return i && (r = qn("number", i)), new Intl.NumberFormat(n, r);
  }
), Kf = Ni(
  (t) => {
    var e = t, { locale: n, format: i } = e, r = Sn(e, ["locale", "format"]);
    if (n == null)
      throw new Error('[svelte-i18n] A "locale" must be set to format dates');
    return i ? r = qn("date", i) : Object.keys(r).length === 0 && (r = qn("date", "short")), new Intl.DateTimeFormat(n, r);
  }
), $f = Ni(
  (t) => {
    var e = t, { locale: n, format: i } = e, r = Sn(e, ["locale", "format"]);
    if (n == null)
      throw new Error(
        '[svelte-i18n] A "locale" must be set to format time values'
      );
    return i ? r = qn("time", i) : Object.keys(r).length === 0 && (r = qn("time", "short")), new Intl.DateTimeFormat(n, r);
  }
), ec = (t = {}) => {
  var e = t, {
    locale: n = Zt()
  } = e, i = Sn(e, [
    "locale"
  ]);
  return Qf(la({ locale: n }, i));
}, tc = (t = {}) => {
  var e = t, {
    locale: n = Zt()
  } = e, i = Sn(e, [
    "locale"
  ]);
  return Kf(la({ locale: n }, i));
}, nc = (t = {}) => {
  var e = t, {
    locale: n = Zt()
  } = e, i = Sn(e, [
    "locale"
  ]);
  return $f(la({ locale: n }, i));
}, ic = Ni(
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
  (t, e = Zt()) => new Df(t, e, bn().formats, {
    ignoreTag: bn().ignoreTag
  })
), rc = (t, e = {}) => {
  var n, i, r, a;
  let s = e;
  typeof t == "object" && (s = t, t = s.id);
  const {
    values: l,
    locale: o = Zt(),
    default: u
  } = s;
  if (o == null)
    throw new Error(
      "[svelte-i18n] Cannot format a message without first setting the initial locale."
    );
  let f = pl(t, o);
  if (!f)
    f = (a = (r = (i = (n = bn()).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 c = f;
  try {
    c = ic(f, o).format(l);
  } catch (h) {
    h instanceof Error && console.warn(
      `[svelte-i18n] Message "${t}" has syntax error:`,
      h.message
    );
  }
  return c;
}, ac = (t, e) => nc(e).format(t), sc = (t, e) => tc(e).format(t), oc = (t, e) => ec(e).format(t), lc = (t, e = Zt()) => pl(t, e), uc = kn([Zn, Yn], () => rc);
kn([Zn], () => ac);
kn([Zn], () => sc);
kn([Zn], () => oc);
kn([Zn, Yn], () => lc);
function fc(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 mi extends Error {
  constructor(e) {
    super(e), this.name = "ShareError";
  }
}
async function cc(t, e) {
  if (window.__gradio_space__ == null)
    throw new mi("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 = hc(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 (fc([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 mi(`Upload failed: ${o.error}`);
    }
    throw new mi("Upload failed.");
  }
  return await s.text();
}
function hc(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 });
}
wu(uc);
const {
  SvelteComponent: dc,
  assign: _c,
  create_slot: mc,
  detach: gc,
  element: pc,
  get_all_dirty_from_scope: bc,
  get_slot_changes: vc,
  get_spread_update: wc,
  init: yc,
  insert: Ec,
  safe_not_equal: kc,
  set_dynamic_element_data: Za,
  set_style: He,
  toggle_class: yt,
  transition_in: kl,
  transition_out: Sl,
  update_slot_base: Sc
} = window.__gradio__svelte__internal;
function Tc(t) {
  let e, n, i;
  const r = (
    /*#slots*/
    t[17].default
  ), a = mc(
    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 = _c(l, s[o]);
  return {
    c() {
      e = pc(
        /*tag*/
        t[14]
      ), a && a.c(), Za(
        /*tag*/
        t[14]
      )(e, l), yt(
        e,
        "hidden",
        /*visible*/
        t[10] === !1
      ), yt(
        e,
        "padded",
        /*padding*/
        t[6]
      ), yt(
        e,
        "border_focus",
        /*border_mode*/
        t[5] === "focus"
      ), yt(e, "hide-container", !/*explicit_call*/
      t[8] && !/*container*/
      t[9]), He(e, "height", typeof /*height*/
      t[0] == "number" ? (
        /*height*/
        t[0] + "px"
      ) : void 0), He(e, "width", typeof /*width*/
      t[1] == "number" ? `calc(min(${/*width*/
      t[1]}px, 100%))` : void 0), He(
        e,
        "border-style",
        /*variant*/
        t[4]
      ), He(
        e,
        "overflow",
        /*allow_overflow*/
        t[11] ? "visible" : "hidden"
      ), He(
        e,
        "flex-grow",
        /*scale*/
        t[12]
      ), He(e, "min-width", `calc(min(${/*min_width*/
      t[13]}px, 100%))`), He(e, "border-width", "var(--block-border-width)");
    },
    m(o, u) {
      Ec(o, e, u), a && a.m(e, null), i = !0;
    },
    p(o, u) {
      a && a.p && (!i || u & /*$$scope*/
      65536) && Sc(
        a,
        r,
        o,
        /*$$scope*/
        o[16],
        i ? vc(
          r,
          /*$$scope*/
          o[16],
          u,
          null
        ) : bc(
          /*$$scope*/
          o[16]
        ),
        null
      ), Za(
        /*tag*/
        o[14]
      )(e, l = wc(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 }
      ])), yt(
        e,
        "hidden",
        /*visible*/
        o[10] === !1
      ), yt(
        e,
        "padded",
        /*padding*/
        o[6]
      ), yt(
        e,
        "border_focus",
        /*border_mode*/
        o[5] === "focus"
      ), yt(e, "hide-container", !/*explicit_call*/
      o[8] && !/*container*/
      o[9]), u & /*height*/
      1 && He(e, "height", typeof /*height*/
      o[0] == "number" ? (
        /*height*/
        o[0] + "px"
      ) : void 0), u & /*width*/
      2 && He(e, "width", typeof /*width*/
      o[1] == "number" ? `calc(min(${/*width*/
      o[1]}px, 100%))` : void 0), u & /*variant*/
      16 && He(
        e,
        "border-style",
        /*variant*/
        o[4]
      ), u & /*allow_overflow*/
      2048 && He(
        e,
        "overflow",
        /*allow_overflow*/
        o[11] ? "visible" : "hidden"
      ), u & /*scale*/
      4096 && He(
        e,
        "flex-grow",
        /*scale*/
        o[12]
      ), u & /*min_width*/
      8192 && He(e, "min-width", `calc(min(${/*min_width*/
      o[13]}px, 100%))`);
    },
    i(o) {
      i || (kl(a, o), i = !0);
    },
    o(o) {
      Sl(a, o), i = !1;
    },
    d(o) {
      o && gc(e), a && a.d(o);
    }
  };
}
function Cc(t) {
  let e, n = (
    /*tag*/
    t[14] && Tc(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 || (kl(n, i), e = !0);
    },
    o(i) {
      Sl(n, i), e = !1;
    },
    d(i) {
      n && n.d(i);
    }
  };
}
function Ac(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: c = !0 } = e, { type: h = "normal" } = e, { test_id: d = void 0 } = e, { explicit_call: _ = !1 } = e, { container: g = !0 } = e, { visible: v = !0 } = e, { allow_overflow: k = !0 } = e, { scale: T = null } = e, { min_width: E = 0 } = e, S = h === "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, c = p.padding), "type" in p && n(15, h = 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, g = p.container), "visible" in p && n(10, v = p.visible), "allow_overflow" in p && n(11, k = p.allow_overflow), "scale" in p && n(12, T = p.scale), "min_width" in p && n(13, E = p.min_width), "$$scope" in p && n(16, r = p.$$scope);
  }, [
    a,
    s,
    l,
    o,
    u,
    f,
    c,
    d,
    _,
    g,
    v,
    k,
    T,
    E,
    S,
    h,
    r,
    i
  ];
}
class Tl extends dc {
  constructor(e) {
    super(), yc(this, e, Ac, Cc, kc, {
      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: Mc,
  append: Zi,
  attr: ii,
  create_component: Dc,
  destroy_component: Oc,
  detach: Bc,
  element: Ja,
  init: Nc,
  insert: Ic,
  mount_component: Hc,
  safe_not_equal: Rc,
  set_data: Lc,
  space: Pc,
  text: Uc,
  toggle_class: Et,
  transition_in: Fc,
  transition_out: zc
} = window.__gradio__svelte__internal;
function Gc(t) {
  let e, n, i, r, a, s;
  return i = new /*Icon*/
  t[1]({}), {
    c() {
      e = Ja("label"), n = Ja("span"), Dc(i.$$.fragment), r = Pc(), a = Uc(
        /*label*/
        t[0]
      ), ii(n, "class", "svelte-9gxdi0"), ii(e, "for", ""), ii(e, "data-testid", "block-label"), ii(e, "class", "svelte-9gxdi0"), Et(e, "hide", !/*show_label*/
      t[2]), Et(e, "sr-only", !/*show_label*/
      t[2]), Et(
        e,
        "float",
        /*float*/
        t[4]
      ), Et(
        e,
        "hide-label",
        /*disable*/
        t[3]
      );
    },
    m(l, o) {
      Ic(l, e, o), Zi(e, n), Hc(i, n, null), Zi(e, r), Zi(e, a), s = !0;
    },
    p(l, [o]) {
      (!s || o & /*label*/
      1) && Lc(
        a,
        /*label*/
        l[0]
      ), (!s || o & /*show_label*/
      4) && Et(e, "hide", !/*show_label*/
      l[2]), (!s || o & /*show_label*/
      4) && Et(e, "sr-only", !/*show_label*/
      l[2]), (!s || o & /*float*/
      16) && Et(
        e,
        "float",
        /*float*/
        l[4]
      ), (!s || o & /*disable*/
      8) && Et(
        e,
        "hide-label",
        /*disable*/
        l[3]
      );
    },
    i(l) {
      s || (Fc(i.$$.fragment, l), s = !0);
    },
    o(l) {
      zc(i.$$.fragment, l), s = !1;
    },
    d(l) {
      l && Bc(e), Oc(i);
    }
  };
}
function jc(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 Cl extends Mc {
  constructor(e) {
    super(), Nc(this, e, jc, Gc, Rc, {
      label: 0,
      Icon: 1,
      show_label: 2,
      disable: 3,
      float: 4
    });
  }
}
const {
  SvelteComponent: qc,
  append: Rr,
  attr: Gt,
  bubble: xc,
  create_component: Xc,
  destroy_component: Vc,
  detach: Al,
  element: Lr,
  init: Wc,
  insert: Ml,
  listen: Yc,
  mount_component: Zc,
  safe_not_equal: Jc,
  set_data: Qc,
  space: Kc,
  text: $c,
  toggle_class: Qa,
  transition_in: eh,
  transition_out: th
} = window.__gradio__svelte__internal;
function Ka(t) {
  let e, n;
  return {
    c() {
      e = Lr("span"), n = $c(
        /*label*/
        t[1]
      ), Gt(e, "class", "svelte-lkmj4t");
    },
    m(i, r) {
      Ml(i, e, r), Rr(e, n);
    },
    p(i, r) {
      r & /*label*/
      2 && Qc(
        n,
        /*label*/
        i[1]
      );
    },
    d(i) {
      i && Al(e);
    }
  };
}
function nh(t) {
  let e, n, i, r, a, s, l, o = (
    /*show_label*/
    t[2] && Ka(t)
  );
  return r = new /*Icon*/
  t[0]({}), {
    c() {
      e = Lr("button"), o && o.c(), n = Kc(), i = Lr("div"), Xc(r.$$.fragment), Gt(i, "class", "svelte-lkmj4t"), Gt(
        e,
        "aria-label",
        /*label*/
        t[1]
      ), Gt(
        e,
        "title",
        /*label*/
        t[1]
      ), Gt(e, "class", "svelte-lkmj4t"), Qa(
        e,
        "pending",
        /*pending*/
        t[3]
      );
    },
    m(u, f) {
      Ml(u, e, f), o && o.m(e, null), Rr(e, n), Rr(e, i), Zc(r, i, null), a = !0, s || (l = Yc(
        e,
        "click",
        /*click_handler*/
        t[4]
      ), s = !0);
    },
    p(u, [f]) {
      /*show_label*/
      u[2] ? o ? o.p(u, f) : (o = Ka(u), o.c(), o.m(e, n)) : o && (o.d(1), o = null), (!a || f & /*label*/
      2) && Gt(
        e,
        "aria-label",
        /*label*/
        u[1]
      ), (!a || f & /*label*/
      2) && Gt(
        e,
        "title",
        /*label*/
        u[1]
      ), (!a || f & /*pending*/
      8) && Qa(
        e,
        "pending",
        /*pending*/
        u[3]
      );
    },
    i(u) {
      a || (eh(r.$$.fragment, u), a = !0);
    },
    o(u) {
      th(r.$$.fragment, u), a = !1;
    },
    d(u) {
      u && Al(e), o && o.d(), Vc(r), s = !1, l();
    }
  };
}
function ih(t, e, n) {
  let { Icon: i } = e, { label: r = "" } = e, { show_label: a = !1 } = e, { pending: s = !1 } = e;
  function l(o) {
    xc.call(this, t, o);
  }
  return t.$$set = (o) => {
    "Icon" in o && n(0, i = o.Icon), "label" in o && n(1, r = o.label), "show_label" in o && n(2, a = o.show_label), "pending" in o && n(3, s = o.pending);
  }, [i, r, a, s, l];
}
class ft extends qc {
  constructor(e) {
    super(), Wc(this, e, ih, nh, Jc, {
      Icon: 0,
      label: 1,
      show_label: 2,
      pending: 3
    });
  }
}
const {
  SvelteComponent: rh,
  append: ah,
  attr: Ji,
  binding_callbacks: sh,
  create_slot: oh,
  detach: lh,
  element: $a,
  get_all_dirty_from_scope: uh,
  get_slot_changes: fh,
  init: ch,
  insert: hh,
  safe_not_equal: dh,
  toggle_class: kt,
  transition_in: _h,
  transition_out: mh,
  update_slot_base: gh
} = window.__gradio__svelte__internal;
function ph(t) {
  let e, n, i;
  const r = (
    /*#slots*/
    t[5].default
  ), a = oh(
    r,
    t,
    /*$$scope*/
    t[4],
    null
  );
  return {
    c() {
      e = $a("div"), n = $a("div"), a && a.c(), Ji(n, "class", "icon svelte-3w3rth"), Ji(e, "class", "empty svelte-3w3rth"), Ji(e, "aria-label", "Empty value"), kt(
        e,
        "small",
        /*size*/
        t[0] === "small"
      ), kt(
        e,
        "large",
        /*size*/
        t[0] === "large"
      ), kt(
        e,
        "unpadded_box",
        /*unpadded_box*/
        t[1]
      ), kt(
        e,
        "small_parent",
        /*parent_height*/
        t[3]
      );
    },
    m(s, l) {
      hh(s, e, l), ah(e, n), a && a.m(n, null), t[6](e), i = !0;
    },
    p(s, [l]) {
      a && a.p && (!i || l & /*$$scope*/
      16) && gh(
        a,
        r,
        s,
        /*$$scope*/
        s[4],
        i ? fh(
          r,
          /*$$scope*/
          s[4],
          l,
          null
        ) : uh(
          /*$$scope*/
          s[4]
        ),
        null
      ), (!i || l & /*size*/
      1) && kt(
        e,
        "small",
        /*size*/
        s[0] === "small"
      ), (!i || l & /*size*/
      1) && kt(
        e,
        "large",
        /*size*/
        s[0] === "large"
      ), (!i || l & /*unpadded_box*/
      2) && kt(
        e,
        "unpadded_box",
        /*unpadded_box*/
        s[1]
      ), (!i || l & /*parent_height*/
      8) && kt(
        e,
        "small_parent",
        /*parent_height*/
        s[3]
      );
    },
    i(s) {
      i || (_h(a, s), i = !0);
    },
    o(s) {
      mh(a, s), i = !1;
    },
    d(s) {
      s && lh(e), a && a.d(s), t[6](null);
    }
  };
}
function bh(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 vh(t, e, n) {
  let i, { $$slots: r = {}, $$scope: a } = e, { size: s = "small" } = e, { unpadded_box: l = !1 } = e, o;
  function u(c) {
    if (!c)
      return !1;
    const { height: h } = c.getBoundingClientRect(), { height: d } = bh([
      c,
      "access",
      (_) => _.parentElement,
      "optionalAccess",
      (_) => _.getBoundingClientRect,
      "call",
      (_) => _()
    ]) || { height: h };
    return h > d + 2;
  }
  function f(c) {
    sh[c ? "unshift" : "push"](() => {
      o = c, n(2, o);
    });
  }
  return t.$$set = (c) => {
    "size" in c && n(0, s = c.size), "unpadded_box" in c && n(1, l = c.unpadded_box), "$$scope" in c && n(4, a = c.$$scope);
  }, t.$$.update = () => {
    t.$$.dirty & /*el*/
    4 && n(3, i = u(o));
  }, [s, l, o, i, a, r, f];
}
class wh extends rh {
  constructor(e) {
    super(), ch(this, e, vh, ph, dh, { size: 0, unpadded_box: 1 });
  }
}
const {
  SvelteComponent: yh,
  append: es,
  attr: Ht,
  detach: Eh,
  init: kh,
  insert: Sh,
  noop: Qi,
  safe_not_equal: Th,
  svg_element: Ki
} = window.__gradio__svelte__internal;
function Ch(t) {
  let e, n, i;
  return {
    c() {
      e = Ki("svg"), n = Ki("path"), i = Ki("path"), Ht(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"), Ht(n, "fill", "currentColor"), Ht(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"), Ht(i, "fill", "currentColor"), Ht(e, "width", "100%"), Ht(e, "height", "100%"), Ht(e, "viewBox", "0 0 32 32");
    },
    m(r, a) {
      Sh(r, e, a), es(e, n), es(e, i);
    },
    p: Qi,
    i: Qi,
    o: Qi,
    d(r) {
      r && Eh(e);
    }
  };
}
class Ah extends yh {
  constructor(e) {
    super(), kh(this, e, null, Ch, Th, {});
  }
}
const {
  SvelteComponent: Mh,
  append: ts,
  attr: Oe,
  detach: Dh,
  init: Oh,
  insert: Bh,
  noop: $i,
  safe_not_equal: Nh,
  svg_element: er
} = window.__gradio__svelte__internal;
function Ih(t) {
  let e, n, i;
  return {
    c() {
      e = er("svg"), n = er("path"), i = er("circle"), Oe(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"), Oe(i, "cx", "12"), Oe(i, "cy", "13"), Oe(i, "r", "4"), Oe(e, "xmlns", "http://www.w3.org/2000/svg"), Oe(e, "width", "100%"), Oe(e, "height", "100%"), Oe(e, "viewBox", "0 0 24 24"), Oe(e, "fill", "none"), Oe(e, "stroke", "currentColor"), Oe(e, "stroke-width", "1.5"), Oe(e, "stroke-linecap", "round"), Oe(e, "stroke-linejoin", "round"), Oe(e, "class", "feather feather-camera");
    },
    m(r, a) {
      Bh(r, e, a), ts(e, n), ts(e, i);
    },
    p: $i,
    i: $i,
    o: $i,
    d(r) {
      r && Dh(e);
    }
  };
}
class Hh extends Mh {
  constructor(e) {
    super(), Oh(this, e, null, Ih, Nh, {});
  }
}
const {
  SvelteComponent: Rh,
  append: Lh,
  attr: Re,
  detach: Ph,
  init: Uh,
  insert: Fh,
  noop: tr,
  safe_not_equal: zh,
  svg_element: ns
} = window.__gradio__svelte__internal;
function Gh(t) {
  let e, n;
  return {
    c() {
      e = ns("svg"), n = ns("circle"), Re(n, "cx", "12"), Re(n, "cy", "12"), Re(n, "r", "10"), Re(e, "xmlns", "http://www.w3.org/2000/svg"), Re(e, "width", "100%"), Re(e, "height", "100%"), Re(e, "viewBox", "0 0 24 24"), Re(e, "fill", "red"), Re(e, "stroke", "red"), Re(e, "stroke-width", "1.5"), Re(e, "stroke-linecap", "round"), Re(e, "stroke-linejoin", "round"), Re(e, "class", "feather feather-circle");
    },
    m(i, r) {
      Fh(i, e, r), Lh(e, n);
    },
    p: tr,
    i: tr,
    o: tr,
    d(i) {
      i && Ph(e);
    }
  };
}
class jh extends Rh {
  constructor(e) {
    super(), Uh(this, e, null, Gh, zh, {});
  }
}
const {
  SvelteComponent: qh,
  append: nr,
  attr: We,
  detach: xh,
  init: Xh,
  insert: Vh,
  noop: ir,
  safe_not_equal: Wh,
  set_style: it,
  svg_element: ri
} = window.__gradio__svelte__internal;
function Yh(t) {
  let e, n, i, r;
  return {
    c() {
      e = ri("svg"), n = ri("g"), i = ri("path"), r = ri("path"), We(i, "d", "M18,6L6.087,17.913"), it(i, "fill", "none"), it(i, "fill-rule", "nonzero"), it(i, "stroke-width", "2px"), We(n, "transform", "matrix(1.14096,-0.140958,-0.140958,1.14096,-0.0559523,0.0559523)"), We(r, "d", "M4.364,4.364L19.636,19.636"), it(r, "fill", "none"), it(r, "fill-rule", "nonzero"), it(r, "stroke-width", "2px"), We(e, "width", "100%"), We(e, "height", "100%"), We(e, "viewBox", "0 0 24 24"), We(e, "version", "1.1"), We(e, "xmlns", "http://www.w3.org/2000/svg"), We(e, "xmlns:xlink", "http://www.w3.org/1999/xlink"), We(e, "xml:space", "preserve"), We(e, "stroke", "currentColor"), it(e, "fill-rule", "evenodd"), it(e, "clip-rule", "evenodd"), it(e, "stroke-linecap", "round"), it(e, "stroke-linejoin", "round");
    },
    m(a, s) {
      Vh(a, e, s), nr(e, n), nr(n, i), nr(e, r);
    },
    p: ir,
    i: ir,
    o: ir,
    d(a) {
      a && xh(e);
    }
  };
}
class Dl extends qh {
  constructor(e) {
    super(), Xh(this, e, null, Yh, Wh, {});
  }
}
const {
  SvelteComponent: Zh,
  append: $t,
  attr: ie,
  detach: Jh,
  init: Qh,
  insert: Kh,
  noop: rr,
  safe_not_equal: $h,
  svg_element: Rt
} = window.__gradio__svelte__internal;
function ed(t) {
  let e, n, i, r, a, s, l;
  return {
    c() {
      e = Rt("svg"), n = Rt("circle"), i = Rt("circle"), r = Rt("circle"), a = Rt("circle"), s = Rt("circle"), l = Rt("path"), ie(n, "cx", "10"), ie(n, "cy", "12"), ie(n, "r", "2"), ie(n, "fill", "currentColor"), ie(i, "cx", "16"), ie(i, "cy", "9"), ie(i, "r", "2"), ie(i, "fill", "currentColor"), ie(r, "cx", "22"), ie(r, "cy", "12"), ie(r, "r", "2"), ie(r, "fill", "currentColor"), ie(a, "cx", "23"), ie(a, "cy", "18"), ie(a, "r", "2"), ie(a, "fill", "currentColor"), ie(s, "cx", "19"), ie(s, "cy", "23"), ie(s, "r", "2"), ie(s, "fill", "currentColor"), ie(l, "fill", "currentColor"), ie(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"), ie(e, "width", "100%"), ie(e, "height", "100%"), ie(e, "viewBox", "0 0 32 32");
    },
    m(o, u) {
      Kh(o, e, u), $t(e, n), $t(e, i), $t(e, r), $t(e, a), $t(e, s), $t(e, l);
    },
    p: rr,
    i: rr,
    o: rr,
    d(o) {
      o && Jh(e);
    }
  };
}
class td extends Zh {
  constructor(e) {
    super(), Qh(this, e, null, ed, $h, {});
  }
}
const {
  SvelteComponent: nd,
  append: id,
  attr: Nn,
  detach: rd,
  init: ad,
  insert: sd,
  noop: ar,
  safe_not_equal: od,
  svg_element: is
} = window.__gradio__svelte__internal;
function ld(t) {
  let e, n;
  return {
    c() {
      e = is("svg"), n = is("path"), Nn(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"), Nn(n, "fill", "currentColor"), Nn(e, "id", "icon"), Nn(e, "xmlns", "http://www.w3.org/2000/svg"), Nn(e, "viewBox", "0 0 32 32");
    },
    m(i, r) {
      sd(i, e, r), id(e, n);
    },
    p: ar,
    i: ar,
    o: ar,
    d(i) {
      i && rd(e);
    }
  };
}
class ud extends nd {
  constructor(e) {
    super(), ad(this, e, null, ld, od, {});
  }
}
const {
  SvelteComponent: fd,
  append: cd,
  attr: en,
  detach: hd,
  init: dd,
  insert: _d,
  noop: sr,
  safe_not_equal: md,
  svg_element: rs
} = window.__gradio__svelte__internal;
function gd(t) {
  let e, n;
  return {
    c() {
      e = rs("svg"), n = rs("path"), en(n, "fill", "currentColor"), en(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"), en(e, "xmlns", "http://www.w3.org/2000/svg"), en(e, "width", "100%"), en(e, "height", "100%"), en(e, "viewBox", "0 0 32 32");
    },
    m(i, r) {
      _d(i, e, r), cd(e, n);
    },
    p: sr,
    i: sr,
    o: sr,
    d(i) {
      i && hd(e);
    }
  };
}
class pd extends fd {
  constructor(e) {
    super(), dd(this, e, null, gd, md, {});
  }
}
const {
  SvelteComponent: bd,
  append: vd,
  attr: Ye,
  detach: wd,
  init: yd,
  insert: Ed,
  noop: or,
  safe_not_equal: kd,
  svg_element: as
} = window.__gradio__svelte__internal;
function Sd(t) {
  let e, n;
  return {
    c() {
      e = as("svg"), n = as("path"), Ye(n, "d", "M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"), 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-edit-2");
    },
    m(i, r) {
      Ed(i, e, r), vd(e, n);
    },
    p: or,
    i: or,
    o: or,
    d(i) {
      i && wd(e);
    }
  };
}
class Td extends bd {
  constructor(e) {
    super(), yd(this, e, null, Sd, kd, {});
  }
}
const {
  SvelteComponent: Cd,
  append: Ad,
  attr: tn,
  detach: Md,
  init: Dd,
  insert: Od,
  noop: lr,
  safe_not_equal: Bd,
  svg_element: ss
} = window.__gradio__svelte__internal;
function Nd(t) {
  let e, n;
  return {
    c() {
      e = ss("svg"), n = ss("path"), tn(n, "fill", "currentColor"), tn(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"), tn(e, "xmlns", "http://www.w3.org/2000/svg"), tn(e, "width", "100%"), tn(e, "height", "100%"), tn(e, "viewBox", "0 0 32 32");
    },
    m(i, r) {
      Od(i, e, r), Ad(e, n);
    },
    p: lr,
    i: lr,
    o: lr,
    d(i) {
      i && Md(e);
    }
  };
}
class Id extends Cd {
  constructor(e) {
    super(), Dd(this, e, null, Nd, Bd, {});
  }
}
const {
  SvelteComponent: Hd,
  append: ur,
  attr: _e,
  detach: Rd,
  init: Ld,
  insert: Pd,
  noop: fr,
  safe_not_equal: Ud,
  svg_element: ai
} = window.__gradio__svelte__internal;
function Fd(t) {
  let e, n, i, r;
  return {
    c() {
      e = ai("svg"), n = ai("rect"), i = ai("circle"), r = ai("polyline"), _e(n, "x", "3"), _e(n, "y", "3"), _e(n, "width", "18"), _e(n, "height", "18"), _e(n, "rx", "2"), _e(n, "ry", "2"), _e(i, "cx", "8.5"), _e(i, "cy", "8.5"), _e(i, "r", "1.5"), _e(r, "points", "21 15 16 10 5 21"), _e(e, "xmlns", "http://www.w3.org/2000/svg"), _e(e, "width", "100%"), _e(e, "height", "100%"), _e(e, "viewBox", "0 0 24 24"), _e(e, "fill", "none"), _e(e, "stroke", "currentColor"), _e(e, "stroke-width", "1.5"), _e(e, "stroke-linecap", "round"), _e(e, "stroke-linejoin", "round"), _e(e, "class", "feather feather-image");
    },
    m(a, s) {
      Pd(a, e, s), ur(e, n), ur(e, i), ur(e, r);
    },
    p: fr,
    i: fr,
    o: fr,
    d(a) {
      a && Rd(e);
    }
  };
}
class yi extends Hd {
  constructor(e) {
    super(), Ld(this, e, null, Fd, Ud, {});
  }
}
const {
  SvelteComponent: zd,
  append: Gd,
  attr: Ze,
  detach: jd,
  init: qd,
  insert: xd,
  noop: cr,
  safe_not_equal: Xd,
  svg_element: os
} = window.__gradio__svelte__internal;
function Vd(t) {
  let e, n;
  return {
    c() {
      e = os("svg"), n = os("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) {
      xd(i, e, r), Gd(e, n);
    },
    p: cr,
    i: cr,
    o: cr,
    d(i) {
      i && jd(e);
    }
  };
}
let ls = class extends zd {
  constructor(e) {
    super(), qd(this, e, null, Vd, Xd, {});
  }
};
const {
  SvelteComponent: Wd,
  append: Yd,
  attr: Te,
  detach: Zd,
  init: Jd,
  insert: Qd,
  noop: hr,
  safe_not_equal: Kd,
  svg_element: us
} = window.__gradio__svelte__internal;
function $d(t) {
  let e, n;
  return {
    c() {
      e = us("svg"), n = us("rect"), Te(n, "x", "3"), Te(n, "y", "3"), Te(n, "width", "18"), Te(n, "height", "18"), Te(n, "rx", "2"), Te(n, "ry", "2"), Te(e, "xmlns", "http://www.w3.org/2000/svg"), Te(e, "width", "100%"), Te(e, "height", "100%"), Te(e, "viewBox", "0 0 24 24"), Te(e, "fill", "red"), Te(e, "stroke", "red"), Te(e, "stroke-width", "1.5"), Te(e, "stroke-linecap", "round"), Te(e, "stroke-linejoin", "round"), Te(e, "class", "feather feather-square");
    },
    m(i, r) {
      Qd(i, e, r), Yd(e, n);
    },
    p: hr,
    i: hr,
    o: hr,
    d(i) {
      i && Zd(e);
    }
  };
}
class e0 extends Wd {
  constructor(e) {
    super(), Jd(this, e, null, $d, Kd, {});
  }
}
const {
  SvelteComponent: t0,
  append: fs,
  attr: Ge,
  detach: n0,
  init: i0,
  insert: r0,
  noop: dr,
  safe_not_equal: a0,
  svg_element: _r
} = window.__gradio__svelte__internal;
function s0(t) {
  let e, n, i;
  return {
    c() {
      e = _r("svg"), n = _r("polyline"), i = _r("path"), Ge(n, "points", "1 4 1 10 7 10"), Ge(i, "d", "M3.51 15a9 9 0 1 0 2.13-9.36L1 10"), 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-rotate-ccw");
    },
    m(r, a) {
      r0(r, e, a), fs(e, n), fs(e, i);
    },
    p: dr,
    i: dr,
    o: dr,
    d(r) {
      r && n0(e);
    }
  };
}
class Ol extends t0 {
  constructor(e) {
    super(), i0(this, e, null, s0, a0, {});
  }
}
const {
  SvelteComponent: o0,
  create_component: l0,
  destroy_component: u0,
  init: f0,
  mount_component: c0,
  safe_not_equal: h0,
  transition_in: d0,
  transition_out: _0
} = window.__gradio__svelte__internal, { createEventDispatcher: m0 } = window.__gradio__svelte__internal;
function g0(t) {
  let e, n;
  return e = new ft({
    props: {
      Icon: ud,
      label: (
        /*i18n*/
        t[2]("common.share")
      ),
      pending: (
        /*pending*/
        t[3]
      )
    }
  }), e.$on(
    "click",
    /*click_handler*/
    t[5]
  ), {
    c() {
      l0(e.$$.fragment);
    },
    m(i, r) {
      c0(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 || (d0(e.$$.fragment, i), n = !0);
    },
    o(i) {
      _0(e.$$.fragment, i), n = !1;
    },
    d(i) {
      u0(e, i);
    }
  };
}
function p0(t, e, n) {
  const i = m0();
  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 mi ? 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 b0 extends o0 {
  constructor(e) {
    super(), f0(this, e, p0, g0, h0, { formatter: 0, value: 1, i18n: 2 });
  }
}
const {
  SvelteComponent: v0,
  append: St,
  attr: cs,
  detach: w0,
  element: hs,
  init: y0,
  insert: E0,
  noop: ds,
  safe_not_equal: k0,
  set_data: mr,
  space: _s,
  text: In
} = window.__gradio__svelte__internal;
function S0(t) {
  let e, n = (
    /*i18n*/
    t[1](
      /*defs*/
      t[2][
        /*type*/
        t[0]
      ]
    ) + ""
  ), i, r, a, s, l = (
    /*i18n*/
    t[1]("common.or") + ""
  ), o, u, f, c = (
    /*i18n*/
    t[1]("upload_text.click_to_upload") + ""
  ), h;
  return {
    c() {
      e = hs("div"), i = In(n), r = _s(), a = hs("span"), s = In("- "), o = In(l), u = In(" -"), f = _s(), h = In(c), cs(a, "class", "or svelte-8ytugg"), cs(e, "class", "wrap svelte-8ytugg");
    },
    m(d, _) {
      E0(d, e, _), St(e, i), St(e, r), St(e, a), St(a, s), St(a, o), St(a, u), St(e, f), St(e, h);
    },
    p(d, [_]) {
      _ & /*i18n, type*/
      3 && n !== (n = /*i18n*/
      d[1](
        /*defs*/
        d[2][
          /*type*/
          d[0]
        ]
      ) + "") && mr(i, n), _ & /*i18n*/
      2 && l !== (l = /*i18n*/
      d[1]("common.or") + "") && mr(o, l), _ & /*i18n*/
      2 && c !== (c = /*i18n*/
      d[1]("upload_text.click_to_upload") + "") && mr(h, c);
    },
    i: ds,
    o: ds,
    d(d) {
      d && w0(e);
    }
  };
}
function T0(t, e, n) {
  let { type: i = "file" } = e, { i18n: r } = e;
  const a = {
    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 = (s) => {
    "type" in s && n(0, i = s.type), "i18n" in s && n(1, r = s.i18n);
  }, [i, r, a];
}
class C0 extends v0 {
  constructor(e) {
    super(), y0(this, e, T0, S0, k0, { type: 0, i18n: 1 });
  }
}
const Bl = (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];
};
function Ct(t, e, n) {
  if (t == null)
    return null;
  if (typeof t == "string")
    return {
      name: "file_data",
      data: t
    };
  if (Array.isArray(t)) {
    const i = [];
    for (const r of t)
      r === null ? i.push(null) : i.push(Ct(r, e, n));
    return i;
  } else
    t.is_file ? t.data = M0(t.name, e, n) : t.is_stream && (n == null ? t.data = e + "/stream/" + t.name : t.data = "/proxy=" + n + "stream/" + t.name);
  return t;
}
function A0(t) {
  try {
    const e = new URL(t);
    return e.protocol === "http:" || e.protocol === "https:";
  } catch {
    return !1;
  }
}
function M0(t, e, n) {
  return t == null ? n ? `/proxy=${n}file=` : `${e}/file=` : A0(t) ? t : n ? `/proxy=${n}file=${t}` : `${e}/file=${t}`;
}
const D0 = (t) => {
  const e = new FileReader();
  return e.readAsDataURL(t), new Promise((n) => {
    e.onloadend = () => {
      n(e.result);
    };
  });
};
var gr = new Intl.Collator(0, { numeric: 1 }).compare;
function ms(t, e, n) {
  return t = t.split("."), e = e.split("."), gr(t[0], e[0]) || gr(t[1], e[1]) || (e[2] = e.slice(2).join("."), n = /[.-]/.test(t[2] = t.slice(2).join(".")), n == /[.-]/.test(e[2]) ? gr(t[2], e[2]) : n ? -1 : 1);
}
function an(t, e, n) {
  return e.startsWith("http://") || e.startsWith("https://") ? n ? t : e : t + e;
}
function pr(t) {
  if (t.startsWith("http")) {
    const { protocol: e, host: n } = new URL(t);
    return n.endsWith("hf.space") ? {
      ws_protocol: "wss",
      host: n,
      http_protocol: e
    } : {
      ws_protocol: e === "https:" ? "wss" : "ws",
      http_protocol: e,
      host: n
    };
  }
  return {
    ws_protocol: "wss",
    http_protocol: "https:",
    host: t
  };
}
const Nl = /^[^\/]*\/[^\/]*$/, O0 = /.*hf\.space\/{0,1}$/;
async function B0(t, e) {
  const n = {};
  e && (n.Authorization = `Bearer ${e}`);
  const i = t.trim();
  if (Nl.test(i))
    try {
      const r = await fetch(
        `https://huggingface.co/api/spaces/${i}/host`,
        { headers: n }
      );
      if (r.status !== 200)
        throw new Error("Space metadata could not be loaded.");
      const a = (await r.json()).host;
      return {
        space_id: t,
        ...pr(a)
      };
    } catch (r) {
      throw new Error("Space metadata could not be loaded." + r.message);
    }
  if (O0.test(i)) {
    const { ws_protocol: r, http_protocol: a, host: s } = pr(i);
    return {
      space_id: s.replace(".hf.space", ""),
      ws_protocol: r,
      http_protocol: a,
      host: s
    };
  }
  return {
    space_id: !1,
    ...pr(i)
  };
}
function N0(t) {
  let e = {};
  return t.forEach(({ api_name: n }, i) => {
    n && (e[n] = i);
  }), e;
}
const I0 = /^(?=[^]*\b[dD]iscussions{0,1}\b)(?=[^]*\b[dD]isabled\b)[^]*$/;
async function gs(t) {
  try {
    const n = (await fetch(
      `https://huggingface.co/api/spaces/${t}/discussions`,
      {
        method: "HEAD"
      }
    )).headers.get("x-error-message");
    return !(n && I0.test(n));
  } catch {
    return !1;
  }
}
const H0 = "This application is too busy. Keep trying!", si = "Connection errored out.";
let Il;
function R0(t, e) {
  return { post_data: n, upload_files: i, client: r, handle_blob: a };
  async function n(s, l, o) {
    const u = { "Content-Type": "application/json" };
    o && (u.Authorization = `Bearer ${o}`);
    try {
      var f = await t(s, {
        method: "POST",
        body: JSON.stringify(l),
        headers: u
      });
    } catch {
      return [{ error: si }, 500];
    }
    return [await f.json(), f.status];
  }
  async function i(s, l, o) {
    const u = {};
    o && (u.Authorization = `Bearer ${o}`);
    const f = 1e3, c = [];
    for (let d = 0; d < l.length; d += f) {
      const _ = l.slice(d, d + f), g = new FormData();
      _.forEach((k) => {
        g.append("files", k);
      });
      try {
        var h = await t(`${s}/upload`, {
          method: "POST",
          body: g,
          headers: u
        });
      } catch {
        return { error: si };
      }
      const v = await h.json();
      c.push(...v);
    }
    return { files: c };
  }
  async function r(s, l = { normalise_files: !0 }) {
    return new Promise(async (o) => {
      const { status_callback: u, hf_token: f, normalise_files: c } = l, h = {
        predict: X,
        submit: Q,
        view_api: B,
        component_server: ne
        // duplicate
      }, d = c ?? !0;
      if ((typeof window > "u" || !("WebSocket" in window)) && !global.Websocket) {
        const b = await import("./wrapper-6f348d45-f837cf34.js");
        Il = (await import("./__vite-browser-external-2447137e.js")).Blob, global.WebSocket = b.WebSocket;
      }
      const { ws_protocol: _, http_protocol: g, host: v, space_id: k } = await B0(s, f), T = Math.random().toString(36).substring(2), E = {};
      let S, p = {}, m = !1;
      f && k && (m = await U0(k, f));
      async function D(b) {
        if (S = b, p = N0((b == null ? void 0 : b.dependencies) || []), S.auth_required)
          return {
            config: S,
            ...h
          };
        try {
          N = await B(S);
        } catch (O) {
          console.error(`Could not get api details: ${O.message}`);
        }
        return {
          config: S,
          ...h
        };
      }
      let N;
      async function z(b) {
        if (u && u(b), b.status === "running")
          try {
            S = await ws(
              t,
              `${g}//${v}`,
              f
            );
            const O = await D(S);
            o(O);
          } catch (O) {
            console.error(O), u && u({
              status: "error",
              message: "Could not load this space.",
              load_status: "error",
              detail: "NOT_FOUND"
            });
          }
      }
      try {
        S = await ws(
          t,
          `${g}//${v}`,
          f
        );
        const b = await D(S);
        o(b);
      } catch (b) {
        console.error(b), k ? Ur(
          k,
          Nl.test(k) ? "space_name" : "subdomain",
          z
        ) : u && u({
          status: "error",
          message: "Could not load this space.",
          load_status: "error",
          detail: "NOT_FOUND"
        });
      }
      function X(b, O, P) {
        let A = !1, G = !1, U;
        if (typeof b == "number")
          U = S.dependencies[b];
        else {
          const F = b.replace(/^\//, "");
          U = S.dependencies[p[F]];
        }
        if (U.types.continuous)
          throw new Error(
            "Cannot call predict on this function as it may run forever. Use submit instead"
          );
        return new Promise((F, ce) => {
          const K = Q(b, O, P);
          let M;
          K.on("data", (he) => {
            G && (K.destroy(), F(he)), A = !0, M = he;
          }).on("status", (he) => {
            he.stage === "error" && ce(he), he.stage === "complete" && (G = !0, A && (K.destroy(), F(M)));
          });
        });
      }
      function Q(b, O, P) {
        let A, G;
        if (typeof b == "number")
          A = b, G = N.unnamed_endpoints[A];
        else {
          const ue = b.replace(/^\//, "");
          A = p[ue], G = N.named_endpoints[b.trim()];
        }
        if (typeof A != "number")
          throw new Error(
            "There is no endpoint matching that name of fn_index matching that number."
          );
        let U;
        const F = typeof b == "number" ? "/predict" : b;
        let ce, K = !1;
        const M = {};
        let he = "";
        typeof window < "u" && (he = new URLSearchParams(
          window.location.search
        ).toString()), a(
          `${g}//${an(v, S.path, !0)}`,
          O,
          G,
          f
        ).then((ue) => {
          if (ce = { data: ue || [], event_data: P, fn_index: A }, z0(A, S))
            de({
              type: "status",
              endpoint: F,
              stage: "pending",
              queue: !1,
              fn_index: A,
              time: /* @__PURE__ */ new Date()
            }), n(
              `${g}//${an(v, S.path, !0)}/run${F.startsWith("/") ? F : `/${F}`}${he ? "?" + he : ""}`,
              {
                ...ce,
                session_hash: T
              },
              f
            ).then(([re, be]) => {
              const ve = d ? ps(
                re.data,
                G,
                S.root,
                S.root_url
              ) : re.data;
              be == 200 ? (de({
                type: "data",
                endpoint: F,
                fn_index: A,
                data: ve,
                time: /* @__PURE__ */ new Date()
              }), de({
                type: "status",
                endpoint: F,
                fn_index: A,
                stage: "complete",
                eta: re.average_duration,
                queue: !1,
                time: /* @__PURE__ */ new Date()
              })) : de({
                type: "status",
                stage: "error",
                endpoint: F,
                fn_index: A,
                message: re.error,
                queue: !1,
                time: /* @__PURE__ */ new Date()
              });
            }).catch((re) => {
              de({
                type: "status",
                stage: "error",
                message: re.message,
                endpoint: F,
                fn_index: A,
                queue: !1,
                time: /* @__PURE__ */ new Date()
              });
            });
          else {
            de({
              type: "status",
              stage: "pending",
              queue: !0,
              endpoint: F,
              fn_index: A,
              time: /* @__PURE__ */ new Date()
            });
            let re = new URL(`${_}://${an(
              v,
              S.path,
              !0
            )}
							/queue/join${he ? "?" + he : ""}`);
            m && re.searchParams.set("__sign", m), U = e(re), U.onclose = (be) => {
              be.wasClean || de({
                type: "status",
                stage: "error",
                broken: !0,
                message: si,
                queue: !0,
                endpoint: F,
                fn_index: A,
                time: /* @__PURE__ */ new Date()
              });
            }, U.onmessage = function(be) {
              const ve = JSON.parse(be.data), { type: Ie, status: Ae, data: nt } = G0(
                ve,
                E[A]
              );
              if (Ie === "update" && Ae && !K)
                de({
                  type: "status",
                  endpoint: F,
                  fn_index: A,
                  time: /* @__PURE__ */ new Date(),
                  ...Ae
                }), Ae.stage === "error" && U.close();
              else if (Ie === "hash") {
                U.send(JSON.stringify({ fn_index: A, session_hash: T }));
                return;
              } else
                Ie === "data" ? U.send(JSON.stringify({ ...ce, session_hash: T })) : Ie === "complete" ? K = Ae : Ie === "log" ? de({
                  type: "log",
                  log: nt.log,
                  level: nt.level,
                  endpoint: F,
                  fn_index: A
                }) : Ie === "generating" && de({
                  type: "status",
                  time: /* @__PURE__ */ new Date(),
                  ...Ae,
                  stage: Ae == null ? void 0 : Ae.stage,
                  queue: !0,
                  endpoint: F,
                  fn_index: A
                });
              nt && (de({
                type: "data",
                time: /* @__PURE__ */ new Date(),
                data: d ? ps(
                  nt.data,
                  G,
                  S.root,
                  S.root_url
                ) : nt.data,
                endpoint: F,
                fn_index: A
              }), K && (de({
                type: "status",
                time: /* @__PURE__ */ new Date(),
                ...K,
                stage: Ae == null ? void 0 : Ae.stage,
                queue: !0,
                endpoint: F,
                fn_index: A
              }), U.close()));
            }, ms(S.version || "2.0.0", "3.6") < 0 && addEventListener(
              "open",
              () => U.send(JSON.stringify({ hash: T }))
            );
          }
        });
        function de(ue) {
          const be = M[ue.type] || [];
          be == null || be.forEach((ve) => ve(ue));
        }
        function tt(ue, re) {
          const be = M, ve = be[ue] || [];
          return be[ue] = ve, ve == null || ve.push(re), { on: tt, off: C, cancel: vt, destroy: wt };
        }
        function C(ue, re) {
          const be = M;
          let ve = be[ue] || [];
          return ve = ve == null ? void 0 : ve.filter((Ie) => Ie !== re), be[ue] = ve, { on: tt, off: C, cancel: vt, destroy: wt };
        }
        async function vt() {
          const ue = {
            stage: "complete",
            queue: !1,
            time: /* @__PURE__ */ new Date()
          };
          K = ue, de({
            ...ue,
            type: "status",
            endpoint: F,
            fn_index: A
          }), U && U.readyState === 0 ? U.addEventListener("open", () => {
            U.close();
          }) : U.close();
          try {
            await t(
              `${g}//${an(
                v,
                S.path,
                !0
              )}/reset`,
              {
                headers: { "Content-Type": "application/json" },
                method: "POST",
                body: JSON.stringify({ fn_index: A, session_hash: T })
              }
            );
          } catch {
            console.warn(
              "The `/reset` endpoint could not be called. Subsequent endpoint results may be unreliable."
            );
          }
        }
        function wt() {
          for (const ue in M)
            M[ue].forEach((re) => {
              C(ue, re);
            });
        }
        return {
          on: tt,
          off: C,
          cancel: vt,
          destroy: wt
        };
      }
      async function ne(b, O, P) {
        var A;
        const G = { "Content-Type": "application/json" };
        f && (G.Authorization = `Bearer ${f}`);
        let U, F = S.components.find(
          (M) => M.id === b
        );
        (A = F == null ? void 0 : F.props) != null && A.root_url ? U = F.props.root_url : U = `${g}//${an(
          v,
          S.path,
          !0
        )}/`;
        const ce = await t(
          `${U}component_server/`,
          {
            method: "POST",
            body: JSON.stringify({
              data: P,
              component_id: b,
              fn_name: O,
              session_hash: T
            }),
            headers: G
          }
        );
        if (!ce.ok)
          throw new Error(
            "Could not connect to component server: " + ce.statusText
          );
        return await ce.json();
      }
      async function B(b) {
        if (N)
          return N;
        const O = { "Content-Type": "application/json" };
        f && (O.Authorization = `Bearer ${f}`);
        let P;
        if (ms(b.version || "2.0.0", "3.30") < 0 ? P = await t(
          "https://gradio-space-api-fetcher-v2.hf.space/api",
          {
            method: "POST",
            body: JSON.stringify({
              serialize: !1,
              config: JSON.stringify(b)
            }),
            headers: O
          }
        ) : P = await t(`${b.root}/info`, {
          headers: O
        }), !P.ok)
          throw new Error(si);
        let A = await P.json();
        return "api" in A && (A = A.api), A.named_endpoints["/predict"] && !A.unnamed_endpoints[0] && (A.unnamed_endpoints[0] = A.named_endpoints["/predict"]), P0(A, b, p);
      }
    });
  }
  async function a(s, l, o, u) {
    const f = await Pr(
      l,
      void 0,
      [],
      !0,
      o
    );
    return Promise.all(
      f.map(async ({ path: c, blob: h, data: d, type: _ }) => {
        if (h) {
          const g = (await i(s, [h], u)).files[0];
          return { path: c, file_url: g, type: _ };
        }
        return { path: c, base64: d, type: _ };
      })
    ).then((c) => (c.forEach(({ path: h, file_url: d, base64: _, type: g }) => {
      if (_)
        br(l, _, h);
      else if (g === "Gallery")
        br(l, d, h);
      else if (d) {
        const v = {
          is_file: !0,
          name: `${d}`,
          data: null
          // orig_name: "file.csv"
        };
        br(l, v, h);
      }
    }), l));
  }
}
const { post_data: D1, upload_files: L0, client: O1, handle_blob: B1 } = R0(
  fetch,
  (...t) => new WebSocket(...t)
);
function ps(t, e, n, i) {
  return t.map((r, a) => {
    var s, l, o, u;
    return ((l = (s = e == null ? void 0 : e.returns) == null ? void 0 : s[a]) == null ? void 0 : l.component) === "File" ? Un(r, n, i) : ((u = (o = e == null ? void 0 : e.returns) == null ? void 0 : o[a]) == null ? void 0 : u.component) === "Gallery" ? r.map((f) => Array.isArray(f) ? [Un(f[0], n, i), f[1]] : [Un(f, n, i), null]) : typeof r == "object" && (r != null && r.is_file) ? Un(r, n, i) : r;
  });
}
function Un(t, e, n) {
  if (t == null)
    return null;
  if (typeof t == "string")
    return {
      name: "file_data",
      data: t
    };
  if (Array.isArray(t)) {
    const i = [];
    for (const r of t)
      r === null ? i.push(null) : i.push(Un(r, e, n));
    return i;
  } else
    t.is_file && (n ? t.data = "/proxy=" + n + "file=" + t.name : t.data = e + "/file=" + t.name);
  return t;
}
function bs(t, e, n, i) {
  switch (t.type) {
    case "string":
      return "string";
    case "boolean":
      return "boolean";
    case "number":
      return "number";
  }
  if (n === "JSONSerializable" || n === "StringSerializable")
    return "any";
  if (n === "ListStringSerializable")
    return "string[]";
  if (e === "Image")
    return i === "parameter" ? "Blob | File | Buffer" : "string";
  if (n === "FileSerializable")
    return (t == null ? void 0 : t.type) === "array" ? i === "parameter" ? "(Blob | File | Buffer)[]" : "{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}[]" : i === "parameter" ? "Blob | File | Buffer" : "{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}";
  if (n === "GallerySerializable")
    return i === "parameter" ? "[(Blob | File | Buffer), (string | null)][]" : "[{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}, (string | null))][]";
}
function vs(t, e) {
  return e === "GallerySerializable" ? "array of [file, label] tuples" : e === "ListStringSerializable" ? "array of strings" : e === "FileSerializable" ? "array of files or single file" : t.description;
}
function P0(t, e, n) {
  const i = {
    named_endpoints: {},
    unnamed_endpoints: {}
  };
  for (const r in t) {
    const a = t[r];
    for (const s in a) {
      const l = e.dependencies[s] ? s : n[s.replace("/", "")], o = a[s];
      i[r][s] = {}, i[r][s].parameters = {}, i[r][s].returns = {}, i[r][s].type = e.dependencies[l].types, i[r][s].parameters = o.parameters.map(
        ({ label: u, component: f, type: c, serializer: h }) => ({
          label: u,
          component: f,
          type: bs(c, f, h, "parameter"),
          description: vs(c, h)
        })
      ), i[r][s].returns = o.returns.map(
        ({ label: u, component: f, type: c, serializer: h }) => ({
          label: u,
          component: f,
          type: bs(c, f, h, "return"),
          description: vs(c, h)
        })
      );
    }
  }
  return i;
}
async function U0(t, e) {
  try {
    return (await (await fetch(`https://huggingface.co/api/spaces/${t}/jwt`, {
      headers: {
        Authorization: `Bearer ${e}`
      }
    })).json()).token || !1;
  } catch (n) {
    return console.error(n), !1;
  }
}
function br(t, e, n) {
  for (; n.length > 1; )
    t = t[n.shift()];
  t[n.shift()] = e;
}
async function Pr(t, e = void 0, n = [], i = !1, r = void 0) {
  if (Array.isArray(t)) {
    let a = [];
    return await Promise.all(
      t.map(async (s, l) => {
        var o;
        let u = n.slice();
        u.push(l);
        const f = await Pr(
          t[l],
          i ? ((o = r == null ? void 0 : r.parameters[l]) == null ? void 0 : o.component) || void 0 : e,
          u,
          !1,
          r
        );
        a = a.concat(f);
      })
    ), a;
  } else if (globalThis.Buffer && t instanceof globalThis.Buffer) {
    const a = e === "Image";
    return [
      {
        path: n,
        blob: a ? !1 : new Il([t]),
        data: a ? `${t.toString("base64")}` : !1,
        type: e
      }
    ];
  } else if (t instanceof Blob || typeof window < "u" && t instanceof File) {
    if (e === "Image") {
      let a;
      if (typeof window < "u")
        a = await F0(t);
      else {
        const s = await t.arrayBuffer();
        a = Buffer.from(s).toString("base64");
      }
      return [{ path: n, data: a, type: e, blob: !1 }];
    }
    return [{ path: n, blob: t, type: e, data: !1 }];
  } else if (typeof t == "object") {
    let a = [];
    for (let s in t)
      if (t.hasOwnProperty(s)) {
        let l = n.slice();
        l.push(s), a = a.concat(
          await Pr(
            t[s],
            void 0,
            l,
            !1,
            r
          )
        );
      }
    return a;
  }
  return [];
}
function F0(t) {
  return new Promise((e, n) => {
    const i = new FileReader();
    i.onloadend = () => e(i.result), i.readAsDataURL(t);
  });
}
function z0(t, e) {
  var n, i, r, a;
  return !(((i = (n = e == null ? void 0 : e.dependencies) == null ? void 0 : n[t]) == null ? void 0 : i.queue) === null ? e.enable_queue : (a = (r = e == null ? void 0 : e.dependencies) == null ? void 0 : r[t]) != null && a.queue) || !1;
}
async function ws(t, e, n) {
  const i = {};
  if (n && (i.Authorization = `Bearer ${n}`), typeof window < "u" && window.gradio_config && location.origin !== "http://localhost:9876" && !window.gradio_config.dev_mode) {
    const r = window.gradio_config.root, a = window.gradio_config;
    return a.root = an(e, a.root, !1), { ...a, path: r };
  } else if (e) {
    let r = await t(`${e}/config`, {
      headers: i
    });
    if (r.status === 200) {
      const a = await r.json();
      return a.path = a.path ?? "", a.root = e, a;
    }
    throw new Error("Could not get config.");
  }
  throw new Error("No config or app endpoint found");
}
async function Ur(t, e, n) {
  let i = e === "subdomain" ? `https://huggingface.co/api/spaces/by-subdomain/${t}` : `https://huggingface.co/api/spaces/${t}`, r, a;
  try {
    if (r = await fetch(i), a = r.status, a !== 200)
      throw new Error();
    r = await r.json();
  } catch {
    n({
      status: "error",
      load_status: "error",
      message: "Could not get space status",
      detail: "NOT_FOUND"
    });
    return;
  }
  if (!r || a !== 200)
    return;
  const {
    runtime: { stage: s },
    id: l
  } = r;
  switch (s) {
    case "STOPPED":
    case "SLEEPING":
      n({
        status: "sleeping",
        load_status: "pending",
        message: "Space is asleep. Waking it up...",
        detail: s
      }), setTimeout(() => {
        Ur(t, e, n);
      }, 1e3);
      break;
    case "PAUSED":
      n({
        status: "paused",
        load_status: "error",
        message: "This space has been paused by the author. If you would like to try this demo, consider duplicating the space.",
        detail: s,
        discussions_enabled: await gs(l)
      });
      break;
    case "RUNNING":
    case "RUNNING_BUILDING":
      n({
        status: "running",
        load_status: "complete",
        message: "",
        detail: s
      });
      break;
    case "BUILDING":
      n({
        status: "building",
        load_status: "pending",
        message: "Space is building...",
        detail: s
      }), setTimeout(() => {
        Ur(t, e, n);
      }, 1e3);
      break;
    default:
      n({
        status: "space_error",
        load_status: "error",
        message: "This space is experiencing an issue.",
        detail: s,
        discussions_enabled: await gs(l)
      });
      break;
  }
}
function G0(t, e) {
  switch (t.msg) {
    case "send_data":
      return { type: "data" };
    case "send_hash":
      return { type: "hash" };
    case "queue_full":
      return {
        type: "update",
        status: {
          queue: !0,
          message: H0,
          stage: "error",
          code: t.code,
          success: t.success
        }
      };
    case "estimation":
      return {
        type: "update",
        status: {
          queue: !0,
          stage: e || "pending",
          code: t.code,
          size: t.queue_size,
          position: t.rank,
          eta: t.rank_eta,
          success: t.success
        }
      };
    case "progress":
      return {
        type: "update",
        status: {
          queue: !0,
          stage: "pending",
          code: t.code,
          progress_data: t.progress_data,
          success: t.success
        }
      };
    case "log":
      return { type: "log", data: t };
    case "process_generating":
      return {
        type: "generating",
        status: {
          queue: !0,
          message: t.success ? null : t.output.error,
          stage: t.success ? "generating" : "error",
          code: t.code,
          progress_data: t.progress_data,
          eta: t.average_duration
        },
        data: t.success ? t.output : null
      };
    case "process_completed":
      return "error" in t.output ? {
        type: "update",
        status: {
          queue: !0,
          message: t.output.error,
          stage: "error",
          code: t.code,
          success: t.success
        }
      } : {
        type: "complete",
        status: {
          queue: !0,
          message: t.success ? void 0 : t.output.error,
          stage: t.success ? "complete" : "error",
          code: t.code,
          progress_data: t.progress_data,
          eta: t.output.average_duration
        },
        data: t.success ? t.output : null
      };
    case "process_starts":
      return {
        type: "update",
        status: {
          queue: !0,
          stage: "pending",
          code: t.code,
          size: t.rank,
          position: 0,
          success: t.success
        }
      };
  }
  return { type: "none", status: { stage: "error", queue: !0 } };
}
const {
  SvelteComponent: j0,
  append: ys,
  attr: dt,
  binding_callbacks: q0,
  bubble: Lt,
  create_slot: x0,
  detach: X0,
  element: Es,
  get_all_dirty_from_scope: V0,
  get_slot_changes: W0,
  init: Y0,
  insert: Z0,
  listen: je,
  prevent_default: Pt,
  run_all: J0,
  safe_not_equal: Q0,
  space: K0,
  stop_propagation: Ut,
  toggle_class: nn,
  transition_in: $0,
  transition_out: e_,
  update_slot_base: t_
} = window.__gradio__svelte__internal, { createEventDispatcher: n_, tick: i_, getContext: r_ } = window.__gradio__svelte__internal;
function a_(t) {
  let e, n, i, r, a, s, l, o, u;
  const f = (
    /*#slots*/
    t[14].default
  ), c = x0(
    f,
    t,
    /*$$scope*/
    t[13],
    null
  );
  return {
    c() {
      e = Es("button"), c && c.c(), n = K0(), i = Es("input"), dt(i, "type", "file"), dt(
        i,
        "accept",
        /*filetype*/
        t[0]
      ), i.multiple = r = /*file_count*/
      t[4] === "multiple" || void 0, dt(i, "webkitdirectory", a = /*file_count*/
      t[4] === "directory" || void 0), dt(i, "mozdirectory", s = /*file_count*/
      t[4] === "directory" || void 0), dt(i, "class", "svelte-2w9i1r"), dt(e, "class", "svelte-2w9i1r"), nn(
        e,
        "center",
        /*center*/
        t[2]
      ), nn(
        e,
        "boundedheight",
        /*boundedheight*/
        t[1]
      ), nn(
        e,
        "flex",
        /*flex*/
        t[3]
      );
    },
    m(h, d) {
      Z0(h, e, d), c && c.m(e, null), ys(e, n), ys(e, i), t[22](i), l = !0, o || (u = [
        je(
          i,
          "change",
          /*loadFilesFromUpload*/
          t[8]
        ),
        je(e, "drag", Ut(Pt(
          /*drag_handler*/
          t[15]
        ))),
        je(e, "dragstart", Ut(Pt(
          /*dragstart_handler*/
          t[16]
        ))),
        je(e, "dragend", Ut(Pt(
          /*dragend_handler*/
          t[17]
        ))),
        je(e, "dragover", Ut(Pt(
          /*dragover_handler*/
          t[18]
        ))),
        je(e, "dragenter", Ut(Pt(
          /*dragenter_handler*/
          t[19]
        ))),
        je(e, "dragleave", Ut(Pt(
          /*dragleave_handler*/
          t[20]
        ))),
        je(e, "drop", Ut(Pt(
          /*drop_handler*/
          t[21]
        ))),
        je(
          e,
          "click",
          /*openFileUpload*/
          t[7]
        ),
        je(
          e,
          "drop",
          /*loadFilesFromDrop*/
          t[9]
        ),
        je(
          e,
          "dragenter",
          /*updateDragging*/
          t[6]
        ),
        je(
          e,
          "dragleave",
          /*updateDragging*/
          t[6]
        )
      ], o = !0);
    },
    p(h, [d]) {
      c && c.p && (!l || d & /*$$scope*/
      8192) && t_(
        c,
        f,
        h,
        /*$$scope*/
        h[13],
        l ? W0(
          f,
          /*$$scope*/
          h[13],
          d,
          null
        ) : V0(
          /*$$scope*/
          h[13]
        ),
        null
      ), (!l || d & /*filetype*/
      1) && dt(
        i,
        "accept",
        /*filetype*/
        h[0]
      ), (!l || d & /*file_count*/
      16 && r !== (r = /*file_count*/
      h[4] === "multiple" || void 0)) && (i.multiple = r), (!l || d & /*file_count*/
      16 && a !== (a = /*file_count*/
      h[4] === "directory" || void 0)) && dt(i, "webkitdirectory", a), (!l || d & /*file_count*/
      16 && s !== (s = /*file_count*/
      h[4] === "directory" || void 0)) && dt(i, "mozdirectory", s), (!l || d & /*center*/
      4) && nn(
        e,
        "center",
        /*center*/
        h[2]
      ), (!l || d & /*boundedheight*/
      2) && nn(
        e,
        "boundedheight",
        /*boundedheight*/
        h[1]
      ), (!l || d & /*flex*/
      8) && nn(
        e,
        "flex",
        /*flex*/
        h[3]
      );
    },
    i(h) {
      l || ($0(c, h), l = !0);
    },
    o(h) {
      e_(c, h), l = !1;
    },
    d(h) {
      h && X0(e), c && c.d(h), t[22](null), o = !1, J0(u);
    }
  };
}
function s_(t, e) {
  return t ?? e();
}
function o_(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 l_(t, e, n) {
  let { $$slots: i = {}, $$scope: r } = e;
  const a = s_(r_("upload_files"), () => L0);
  let { filetype: s = null } = e, { dragging: l = !1 } = e, { boundedheight: o = !0 } = e, { center: u = !0 } = e, { flex: f = !0 } = e, { file_count: c = "single" } = e, { disable_click: h = !1 } = e, { root: d } = e, _;
  const g = n_();
  function v() {
    n(10, l = !l);
  }
  function k() {
    h || (n(5, _.value = "", _), _.click());
  }
  async function T(b) {
    await i_();
    let O = (Array.isArray(b) ? b : [b]).map((P) => P.blob);
    await a(d, O).then(async (P) => {
      P.error ? (Array.isArray(b) ? b : [b]).forEach(async (A, G) => {
        A.data = await D0(A.blob), A.blob = void 0;
      }) : (Array.isArray(b) ? b : [b]).forEach((A, G) => {
        P.files && (A.orig_name = A.name, A.name = P.files[G], A.is_file = !0, A.blob = void 0, Ct(A, d, null));
      });
    }), g("load", c === "single" ? b[0] : b);
  }
  async function E(b) {
    let O = Array.from(b);
    if (b.length) {
      c === "single" && (O = [b[0]]);
      var P = [];
      O.forEach((A, G) => {
        P[G] = {
          name: A.name,
          size: A.size,
          data: "",
          blob: A
        };
      }), await T(P);
    }
  }
  async function S(b) {
    const O = b.target;
    O.files && await E(O.files);
  }
  async function p(b) {
    n(10, l = !1), o_([b, "access", (O) => O.dataTransfer, "optionalAccess", (O) => O.files]) && await E(b.dataTransfer.files);
  }
  function m(b) {
    Lt.call(this, t, b);
  }
  function D(b) {
    Lt.call(this, t, b);
  }
  function N(b) {
    Lt.call(this, t, b);
  }
  function z(b) {
    Lt.call(this, t, b);
  }
  function X(b) {
    Lt.call(this, t, b);
  }
  function Q(b) {
    Lt.call(this, t, b);
  }
  function ne(b) {
    Lt.call(this, t, b);
  }
  function B(b) {
    q0[b ? "unshift" : "push"](() => {
      _ = b, n(5, _);
    });
  }
  return t.$$set = (b) => {
    "filetype" in b && n(0, s = b.filetype), "dragging" in b && n(10, l = b.dragging), "boundedheight" in b && n(1, o = b.boundedheight), "center" in b && n(2, u = b.center), "flex" in b && n(3, f = b.flex), "file_count" in b && n(4, c = b.file_count), "disable_click" in b && n(11, h = b.disable_click), "root" in b && n(12, d = b.root), "$$scope" in b && n(13, r = b.$$scope);
  }, [
    s,
    o,
    u,
    f,
    c,
    _,
    v,
    k,
    S,
    p,
    l,
    h,
    d,
    r,
    i,
    m,
    D,
    N,
    z,
    X,
    Q,
    ne,
    B
  ];
}
class u_ extends j0 {
  constructor(e) {
    super(), Y0(this, e, l_, a_, Q0, {
      filetype: 0,
      dragging: 10,
      boundedheight: 1,
      center: 2,
      flex: 3,
      file_count: 4,
      disable_click: 11,
      root: 12
    });
  }
}
const {
  SvelteComponent: f_,
  append: ks,
  attr: c_,
  check_outros: Ss,
  create_component: ua,
  destroy_component: fa,
  detach: h_,
  element: d_,
  group_outros: Ts,
  init: __,
  insert: m_,
  mount_component: ca,
  safe_not_equal: g_,
  set_style: Cs,
  space: As,
  toggle_class: Ms,
  transition_in: _t,
  transition_out: jt
} = window.__gradio__svelte__internal, { createEventDispatcher: p_ } = window.__gradio__svelte__internal;
function Ds(t) {
  let e, n;
  return e = new ft({
    props: {
      Icon: Td,
      label: (
        /*i18n*/
        t[3]("common.edit")
      )
    }
  }), e.$on(
    "click",
    /*click_handler*/
    t[5]
  ), {
    c() {
      ua(e.$$.fragment);
    },
    m(i, r) {
      ca(e, i, r), n = !0;
    },
    p(i, r) {
      const a = {};
      r & /*i18n*/
      8 && (a.label = /*i18n*/
      i[3]("common.edit")), e.$set(a);
    },
    i(i) {
      n || (_t(e.$$.fragment, i), n = !0);
    },
    o(i) {
      jt(e.$$.fragment, i), n = !1;
    },
    d(i) {
      fa(e, i);
    }
  };
}
function Os(t) {
  let e, n;
  return e = new ft({
    props: {
      Icon: Ol,
      label: (
        /*i18n*/
        t[3]("common.undo")
      )
    }
  }), e.$on(
    "click",
    /*click_handler_1*/
    t[6]
  ), {
    c() {
      ua(e.$$.fragment);
    },
    m(i, r) {
      ca(e, i, r), n = !0;
    },
    p(i, r) {
      const a = {};
      r & /*i18n*/
      8 && (a.label = /*i18n*/
      i[3]("common.undo")), e.$set(a);
    },
    i(i) {
      n || (_t(e.$$.fragment, i), n = !0);
    },
    o(i) {
      jt(e.$$.fragment, i), n = !1;
    },
    d(i) {
      fa(e, i);
    }
  };
}
function b_(t) {
  let e, n, i, r, a, s = (
    /*editable*/
    t[0] && Ds(t)
  ), l = (
    /*undoable*/
    t[1] && Os(t)
  );
  return r = new ft({
    props: {
      Icon: Dl,
      label: (
        /*i18n*/
        t[3]("common.clear")
      )
    }
  }), r.$on(
    "click",
    /*click_handler_2*/
    t[7]
  ), {
    c() {
      e = d_("div"), s && s.c(), n = As(), l && l.c(), i = As(), ua(r.$$.fragment), c_(e, "class", "svelte-1wj0ocy"), Ms(e, "not-absolute", !/*absolute*/
      t[2]), Cs(
        e,
        "position",
        /*absolute*/
        t[2] ? "absolute" : "static"
      );
    },
    m(o, u) {
      m_(o, e, u), s && s.m(e, null), ks(e, n), l && l.m(e, null), ks(e, i), ca(r, e, null), a = !0;
    },
    p(o, [u]) {
      /*editable*/
      o[0] ? s ? (s.p(o, u), u & /*editable*/
      1 && _t(s, 1)) : (s = Ds(o), s.c(), _t(s, 1), s.m(e, n)) : s && (Ts(), jt(s, 1, 1, () => {
        s = null;
      }), Ss()), /*undoable*/
      o[1] ? l ? (l.p(o, u), u & /*undoable*/
      2 && _t(l, 1)) : (l = Os(o), l.c(), _t(l, 1), l.m(e, i)) : l && (Ts(), jt(l, 1, 1, () => {
        l = null;
      }), Ss());
      const f = {};
      u & /*i18n*/
      8 && (f.label = /*i18n*/
      o[3]("common.clear")), r.$set(f), (!a || u & /*absolute*/
      4) && Ms(e, "not-absolute", !/*absolute*/
      o[2]), u & /*absolute*/
      4 && Cs(
        e,
        "position",
        /*absolute*/
        o[2] ? "absolute" : "static"
      );
    },
    i(o) {
      a || (_t(s), _t(l), _t(r.$$.fragment, o), a = !0);
    },
    o(o) {
      jt(s), jt(l), jt(r.$$.fragment, o), a = !1;
    },
    d(o) {
      o && h_(e), s && s.d(), l && l.d(), fa(r);
    }
  };
}
function v_(t, e, n) {
  let { editable: i = !1 } = e, { undoable: r = !1 } = e, { absolute: a = !0 } = e, { i18n: s } = e;
  const l = p_(), o = () => l("edit"), u = () => l("undo"), f = (c) => {
    l("clear"), c.stopPropagation();
  };
  return t.$$set = (c) => {
    "editable" in c && n(0, i = c.editable), "undoable" in c && n(1, r = c.undoable), "absolute" in c && n(2, a = c.absolute), "i18n" in c && n(3, s = c.i18n);
  }, [
    i,
    r,
    a,
    s,
    l,
    o,
    u,
    f
  ];
}
class Ii extends f_ {
  constructor(e) {
    super(), __(this, e, v_, b_, g_, {
      editable: 0,
      undoable: 1,
      absolute: 2,
      i18n: 3
    });
  }
}
const {
  SvelteComponent: w_,
  append: Bs,
  attr: at,
  bubble: Ns,
  check_outros: Fr,
  create_component: Jn,
  destroy_component: Qn,
  detach: cn,
  element: gi,
  empty: y_,
  group_outros: zr,
  init: E_,
  insert: hn,
  listen: k_,
  mount_component: Kn,
  safe_not_equal: S_,
  space: Gr,
  src_url_equal: Is,
  toggle_class: Hs,
  transition_in: Pe,
  transition_out: $e
} = window.__gradio__svelte__internal, { createEventDispatcher: T_ } = window.__gradio__svelte__internal;
function C_(t) {
  let e, n, i, r, a, s, l, o, u, f = (
    /*show_download_button*/
    t[3] && Rs(t)
  ), c = (
    /*show_share_button*/
    t[5] && Ls(t)
  );
  return {
    c() {
      e = gi("div"), f && f.c(), n = Gr(), c && c.c(), i = Gr(), r = gi("button"), a = gi("img"), at(e, "class", "icon-buttons svelte-v9w493"), Is(a.src, s = /*value_*/
      t[7].data) || at(a, "src", s), at(a, "alt", ""), at(a, "loading", "lazy"), at(a, "class", "svelte-v9w493"), Hs(
        a,
        "selectable",
        /*selectable*/
        t[4]
      );
    },
    m(h, d) {
      hn(h, e, d), f && f.m(e, null), Bs(e, n), c && c.m(e, null), hn(h, i, d), hn(h, r, d), Bs(r, a), l = !0, o || (u = k_(
        r,
        "click",
        /*handle_click*/
        t[8]
      ), o = !0);
    },
    p(h, d) {
      /*show_download_button*/
      h[3] ? f ? (f.p(h, d), d & /*show_download_button*/
      8 && Pe(f, 1)) : (f = Rs(h), f.c(), Pe(f, 1), f.m(e, n)) : f && (zr(), $e(f, 1, 1, () => {
        f = null;
      }), Fr()), /*show_share_button*/
      h[5] ? c ? (c.p(h, d), d & /*show_share_button*/
      32 && Pe(c, 1)) : (c = Ls(h), c.c(), Pe(c, 1), c.m(e, null)) : c && (zr(), $e(c, 1, 1, () => {
        c = null;
      }), Fr()), (!l || d & /*value_*/
      128 && !Is(a.src, s = /*value_*/
      h[7].data)) && at(a, "src", s), (!l || d & /*selectable*/
      16) && Hs(
        a,
        "selectable",
        /*selectable*/
        h[4]
      );
    },
    i(h) {
      l || (Pe(f), Pe(c), l = !0);
    },
    o(h) {
      $e(f), $e(c), l = !1;
    },
    d(h) {
      h && (cn(e), cn(i), cn(r)), f && f.d(), c && c.d(), o = !1, u();
    }
  };
}
function A_(t) {
  let e, n;
  return e = new wh({
    props: {
      unpadded_box: !0,
      size: "large",
      $$slots: { default: [M_] },
      $$scope: { ctx: t }
    }
  }), {
    c() {
      Jn(e.$$.fragment);
    },
    m(i, r) {
      Kn(e, i, r), n = !0;
    },
    p(i, r) {
      const a = {};
      r & /*$$scope*/
      16384 && (a.$$scope = { dirty: r, ctx: i }), e.$set(a);
    },
    i(i) {
      n || (Pe(e.$$.fragment, i), n = !0);
    },
    o(i) {
      $e(e.$$.fragment, i), n = !1;
    },
    d(i) {
      Qn(e, i);
    }
  };
}
function Rs(t) {
  let e, n, i, r;
  return n = new ft({
    props: {
      Icon: pd,
      label: (
        /*i18n*/
        t[6]("common.download")
      )
    }
  }), {
    c() {
      e = gi("a"), Jn(n.$$.fragment), at(e, "href", i = /*value_*/
      t[7].data), at(e, "target", window.__is_colab__ ? "_blank" : null), at(e, "download", "image");
    },
    m(a, s) {
      hn(a, e, s), Kn(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_*/
      128 && i !== (i = /*value_*/
      a[7].data)) && at(e, "href", i);
    },
    i(a) {
      r || (Pe(n.$$.fragment, a), r = !0);
    },
    o(a) {
      $e(n.$$.fragment, a), r = !1;
    },
    d(a) {
      a && cn(e), Qn(n);
    }
  };
}
function Ls(t) {
  let e, n;
  return e = new b0({
    props: {
      i18n: (
        /*i18n*/
        t[6]
      ),
      formatter: (
        /*func*/
        t[10]
      ),
      value: (
        /*value*/
        t[0]
      )
    }
  }), e.$on(
    "share",
    /*share_handler*/
    t[11]
  ), e.$on(
    "error",
    /*error_handler*/
    t[12]
  ), {
    c() {
      Jn(e.$$.fragment);
    },
    m(i, r) {
      Kn(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 || (Pe(e.$$.fragment, i), n = !0);
    },
    o(i) {
      $e(e.$$.fragment, i), n = !1;
    },
    d(i) {
      Qn(e, i);
    }
  };
}
function M_(t) {
  let e, n;
  return e = new yi({}), {
    c() {
      Jn(e.$$.fragment);
    },
    m(i, r) {
      Kn(e, i, r), n = !0;
    },
    i(i) {
      n || (Pe(e.$$.fragment, i), n = !0);
    },
    o(i) {
      $e(e.$$.fragment, i), n = !1;
    },
    d(i) {
      Qn(e, i);
    }
  };
}
function D_(t) {
  let e, n, i, r, a, s;
  e = new Cl({
    props: {
      show_label: (
        /*show_label*/
        t[2]
      ),
      Icon: yi,
      label: (
        /*label*/
        t[1] || /*i18n*/
        t[6]("image.image")
      )
    }
  });
  const l = [A_, C_], o = [];
  function u(f, c) {
    return (
      /*value_*/
      f[7] === null ? 0 : 1
    );
  }
  return i = u(t), r = o[i] = l[i](t), {
    c() {
      Jn(e.$$.fragment), n = Gr(), r.c(), a = y_();
    },
    m(f, c) {
      Kn(e, f, c), hn(f, n, c), o[i].m(f, c), hn(f, a, c), s = !0;
    },
    p(f, [c]) {
      const h = {};
      c & /*show_label*/
      4 && (h.show_label = /*show_label*/
      f[2]), c & /*label, i18n*/
      66 && (h.label = /*label*/
      f[1] || /*i18n*/
      f[6]("image.image")), e.$set(h);
      let d = i;
      i = u(f), i === d ? o[i].p(f, c) : (zr(), $e(o[d], 1, 1, () => {
        o[d] = null;
      }), Fr(), r = o[i], r ? r.p(f, c) : (r = o[i] = l[i](f), r.c()), Pe(r, 1), r.m(a.parentNode, a));
    },
    i(f) {
      s || (Pe(e.$$.fragment, f), Pe(r), s = !0);
    },
    o(f) {
      $e(e.$$.fragment, f), $e(r), s = !1;
    },
    d(f) {
      f && (cn(n), cn(a)), Qn(e, f), o[i].d(f);
    }
  };
}
function O_(t, e, n) {
  let { value: i } = e, r, { label: a = void 0 } = e, { show_label: s } = e, { show_download_button: l = !0 } = e, { selectable: o = !1 } = e, { show_share_button: u = !1 } = e, { root: f } = e, { i18n: c } = e;
  const h = T_(), d = (k) => {
    let T = Bl(k);
    T && h("select", { index: T, value: null });
  }, _ = async (k) => k ? `<img src="${await cc(k, "base64")}" />` : "";
  function g(k) {
    Ns.call(this, t, k);
  }
  function v(k) {
    Ns.call(this, t, k);
  }
  return t.$$set = (k) => {
    "value" in k && n(0, i = k.value), "label" in k && n(1, a = k.label), "show_label" in k && n(2, s = k.show_label), "show_download_button" in k && n(3, l = k.show_download_button), "selectable" in k && n(4, o = k.selectable), "show_share_button" in k && n(5, u = k.show_share_button), "root" in k && n(9, f = k.root), "i18n" in k && n(6, c = k.i18n);
  }, t.$$.update = () => {
    t.$$.dirty & /*value*/
    1 && i && h("change", i.data), t.$$.dirty & /*value, value_, root*/
    641 && i !== r && (n(7, r = i), Ct(r, f, null));
  }, [
    i,
    a,
    s,
    l,
    o,
    u,
    c,
    r,
    d,
    f,
    _,
    g,
    v
  ];
}
class B_ extends w_ {
  constructor(e) {
    super(), E_(this, e, O_, D_, S_, {
      value: 0,
      label: 1,
      show_label: 2,
      show_download_button: 3,
      selectable: 4,
      show_share_button: 5,
      root: 9,
      i18n: 6
    });
  }
}
/*!
 * 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 Ps(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 Hl(t) {
  for (var e = 1; e < arguments.length; e++) {
    var n = arguments[e] != null ? arguments[e] : {};
    e % 2 ? Ps(Object(n), !0).forEach(function(i) {
      H_(t, i, n[i]);
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) : Ps(Object(n)).forEach(function(i) {
      Object.defineProperty(t, i, Object.getOwnPropertyDescriptor(n, i));
    });
  }
  return t;
}
function jr(t) {
  "@babel/helpers - typeof";
  return jr = 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;
  }, jr(t);
}
function N_(t, e) {
  if (!(t instanceof e))
    throw new TypeError("Cannot call a class as a function");
}
function Us(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, Ll(i.key), i);
  }
}
function I_(t, e, n) {
  return e && Us(t.prototype, e), n && Us(t, n), Object.defineProperty(t, "prototype", {
    writable: !1
  }), t;
}
function H_(t, e, n) {
  return e = Ll(e), e in t ? Object.defineProperty(t, e, {
    value: n,
    enumerable: !0,
    configurable: !0,
    writable: !0
  }) : t[e] = n, t;
}
function Rl(t) {
  return R_(t) || L_(t) || P_(t) || U_();
}
function R_(t) {
  if (Array.isArray(t))
    return qr(t);
}
function L_(t) {
  if (typeof Symbol < "u" && t[Symbol.iterator] != null || t["@@iterator"] != null)
    return Array.from(t);
}
function P_(t, e) {
  if (t) {
    if (typeof t == "string")
      return qr(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 qr(t, e);
  }
}
function qr(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 U_() {
  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 F_(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 Ll(t) {
  var e = F_(t, "string");
  return typeof e == "symbol" ? e : String(e);
}
var Hi = typeof window < "u" && typeof window.document < "u", ct = Hi ? window : {}, ha = Hi && ct.document.documentElement ? "ontouchstart" in ct.document.documentElement : !1, da = Hi ? "PointerEvent" in ct : !1, oe = "cropper", _a = "all", Pl = "crop", Ul = "move", Fl = "zoom", Ft = "e", zt = "w", rn = "s", Tt = "n", Hn = "ne", Rn = "nw", Ln = "se", Pn = "sw", xr = "".concat(oe, "-crop"), Fs = "".concat(oe, "-disabled"), Ne = "".concat(oe, "-hidden"), zs = "".concat(oe, "-hide"), z_ = "".concat(oe, "-invisible"), Ei = "".concat(oe, "-modal"), Xr = "".concat(oe, "-move"), xn = "".concat(oe, "Action"), oi = "".concat(oe, "Preview"), ma = "crop", zl = "move", Gl = "none", Vr = "crop", Wr = "cropend", Yr = "cropmove", Zr = "cropstart", Gs = "dblclick", G_ = ha ? "touchstart" : "mousedown", j_ = ha ? "touchmove" : "mousemove", q_ = ha ? "touchend touchcancel" : "mouseup", js = da ? "pointerdown" : G_, qs = da ? "pointermove" : j_, xs = da ? "pointerup pointercancel" : q_, Xs = "ready", Vs = "resize", Ws = "wheel", Jr = "zoom", Ys = "image/jpeg", x_ = /^e|w|s|n|se|sw|ne|nw|all|crop|move|zoom$/, X_ = /^data:/, V_ = /^data:image\/jpeg;base64,/, W_ = /^img|canvas$/i, jl = 200, ql = 100, Zs = {
  // Define the view mode of the cropper
  viewMode: 0,
  // 0, 1, 2, 3
  // Define the dragging mode of the cropper
  dragMode: ma,
  // '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: jl,
  minContainerHeight: ql,
  // Shortcuts of events
  ready: null,
  cropstart: null,
  cropmove: null,
  cropend: null,
  crop: null,
  zoom: null
}, Y_ = '<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>', Z_ = Number.isNaN || ct.isNaN;
function j(t) {
  return typeof t == "number" && !Z_(t);
}
var Js = function(e) {
  return e > 0 && e < 1 / 0;
};
function vr(t) {
  return typeof t > "u";
}
function Xt(t) {
  return jr(t) === "object" && t !== null;
}
var J_ = Object.prototype.hasOwnProperty;
function on(t) {
  if (!Xt(t))
    return !1;
  try {
    var e = t.constructor, n = e.prototype;
    return e && n && J_.call(n, "isPrototypeOf");
  } catch {
    return !1;
  }
}
function Be(t) {
  return typeof t == "function";
}
var Q_ = Array.prototype.slice;
function xl(t) {
  return Array.from ? Array.from(t) : Q_.call(t);
}
function ge(t, e) {
  return t && Be(e) && (Array.isArray(t) || j(t.length) ? xl(t).forEach(function(n, i) {
    e.call(t, n, i, t);
  }) : Xt(t) && Object.keys(t).forEach(function(n) {
    e.call(t, t[n], n, t);
  })), t;
}
var le = 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 Xt(e) && i.length > 0 && i.forEach(function(a) {
    Xt(a) && Object.keys(a).forEach(function(s) {
      e[s] = a[s];
    });
  }), e;
}, K_ = /\.\d*(?:0|9){12}\d*$/;
function dn(t) {
  var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1e11;
  return K_.test(t) ? Math.round(t * e) / e : t;
}
var $_ = /^width|height|left|top|marginLeft|marginTop$/;
function Mt(t, e) {
  var n = t.style;
  ge(e, function(i, r) {
    $_.test(r) && j(i) && (i = "".concat(i, "px")), n[r] = i;
  });
}
function em(t, e) {
  return t.classList ? t.classList.contains(e) : t.className.indexOf(e) > -1;
}
function ye(t, e) {
  if (e) {
    if (j(t.length)) {
      ge(t, function(i) {
        ye(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 lt(t, e) {
  if (e) {
    if (j(t.length)) {
      ge(t, function(n) {
        lt(n, e);
      });
      return;
    }
    if (t.classList) {
      t.classList.remove(e);
      return;
    }
    t.className.indexOf(e) >= 0 && (t.className = t.className.replace(e, ""));
  }
}
function ln(t, e, n) {
  if (e) {
    if (j(t.length)) {
      ge(t, function(i) {
        ln(i, e, n);
      });
      return;
    }
    n ? ye(t, e) : lt(t, e);
  }
}
var tm = /([a-z\d])([A-Z])/g;
function ga(t) {
  return t.replace(tm, "$1-$2").toLowerCase();
}
function Qr(t, e) {
  return Xt(t[e]) ? t[e] : t.dataset ? t.dataset[e] : t.getAttribute("data-".concat(ga(e)));
}
function Xn(t, e, n) {
  Xt(n) ? t[e] = n : t.dataset ? t.dataset[e] = n : t.setAttribute("data-".concat(ga(e)), n);
}
function nm(t, e) {
  if (Xt(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(ga(e)));
}
var Xl = /\s\s*/, Vl = function() {
  var t = !1;
  if (Hi) {
    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;
      }
    });
    ct.addEventListener("test", n, i), ct.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(Xl).forEach(function(a) {
    if (!Vl) {
      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 qe(t, e, n) {
  var i = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {}, r = n;
  e.trim().split(Xl).forEach(function(a) {
    if (i.once && !Vl) {
      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), c = 0; c < u; c++)
          f[c] = arguments[c];
        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 _n(t, e, n) {
  var i;
  return Be(Event) && Be(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 Wl(t) {
  var e = t.getBoundingClientRect();
  return {
    left: e.left + (window.pageXOffset - document.documentElement.clientLeft),
    top: e.top + (window.pageYOffset - document.documentElement.clientTop)
  };
}
var wr = ct.location, im = /^(\w+:)\/\/([^:/?#]*):?(\d*)/i;
function Qs(t) {
  var e = t.match(im);
  return e !== null && (e[1] !== wr.protocol || e[2] !== wr.hostname || e[3] !== wr.port);
}
function Ks(t) {
  var e = "timestamp=".concat((/* @__PURE__ */ new Date()).getTime());
  return t + (t.indexOf("?") === -1 ? "?" : "&") + e;
}
function Gn(t) {
  var e = t.rotate, n = t.scaleX, i = t.scaleY, r = t.translateX, a = t.translateY, s = [];
  j(r) && r !== 0 && s.push("translateX(".concat(r, "px)")), j(a) && a !== 0 && s.push("translateY(".concat(a, "px)")), j(e) && e !== 0 && s.push("rotate(".concat(e, "deg)")), j(n) && n !== 1 && s.push("scaleX(".concat(n, ")")), j(i) && i !== 1 && s.push("scaleY(".concat(i, ")"));
  var l = s.length ? s.join(" ") : "none";
  return {
    WebkitTransform: l,
    msTransform: l,
    transform: l
  };
}
function rm(t) {
  var e = Hl({}, t), n = 0;
  return ge(t, function(i, r) {
    delete e[r], ge(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), c = Math.sqrt(o * o + u * u), h = (c - f) / f;
      Math.abs(h) > Math.abs(n) && (n = h);
    });
  }), n;
}
function li(t, e) {
  var n = t.pageX, i = t.pageY, r = {
    endX: n,
    endY: i
  };
  return e ? r : Hl({
    startX: n,
    startY: i
  }, r);
}
function am(t) {
  var e = 0, n = 0, i = 0;
  return ge(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 Dt(t) {
  var e = t.aspectRatio, n = t.height, i = t.width, r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "contain", a = Js(i), s = Js(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 sm(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 om(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, c = e.scaleY, h = c === void 0 ? 1 : c, d = n.aspectRatio, _ = n.naturalWidth, g = n.naturalHeight, v = i.fillColor, k = v === void 0 ? "transparent" : v, T = i.imageSmoothingEnabled, E = T === void 0 ? !0 : T, S = i.imageSmoothingQuality, p = S === void 0 ? "low" : S, m = i.maxWidth, D = m === void 0 ? 1 / 0 : m, N = i.maxHeight, z = N === void 0 ? 1 / 0 : N, X = i.minWidth, Q = X === void 0 ? 0 : X, ne = i.minHeight, B = ne === void 0 ? 0 : ne, b = document.createElement("canvas"), O = b.getContext("2d"), P = Dt({
    aspectRatio: d,
    width: D,
    height: z
  }), A = Dt({
    aspectRatio: d,
    width: Q,
    height: B
  }, "cover"), G = Math.min(P.width, Math.max(A.width, _)), U = Math.min(P.height, Math.max(A.height, g)), F = Dt({
    aspectRatio: r,
    width: D,
    height: z
  }), ce = Dt({
    aspectRatio: r,
    width: Q,
    height: B
  }, "cover"), K = Math.min(F.width, Math.max(ce.width, a)), M = Math.min(F.height, Math.max(ce.height, s)), he = [-K / 2, -M / 2, K, M];
  return b.width = dn(G), b.height = dn(U), O.fillStyle = k, O.fillRect(0, 0, G, U), O.save(), O.translate(G / 2, U / 2), O.rotate(o * Math.PI / 180), O.scale(f, h), O.imageSmoothingEnabled = E, O.imageSmoothingQuality = p, O.drawImage.apply(O, [t].concat(Rl(he.map(function(de) {
    return Math.floor(dn(de));
  })))), O.restore(), b;
}
var Yl = String.fromCharCode;
function lm(t, e, n) {
  var i = "";
  n += e;
  for (var r = e; r < n; r += 1)
    i += Yl(t.getUint8(r));
  return i;
}
var um = /^data:.*,/;
function fm(t) {
  var e = t.replace(um, ""), n = atob(e), i = new ArrayBuffer(n.length), r = new Uint8Array(i);
  return ge(r, function(a, s) {
    r[s] = n.charCodeAt(s);
  }), i;
}
function cm(t, e) {
  for (var n = [], i = 8192, r = new Uint8Array(t); r.length > 0; )
    n.push(Yl.apply(null, xl(r.subarray(0, i)))), r = r.subarray(i);
  return "data:".concat(e, ";base64,").concat(btoa(n.join("")));
}
function hm(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 (lm(e, o, 4) === "Exif") {
        var f = e.getUint16(u);
        if (i = f === 18761, (i || f === 19789) && e.getUint16(u + 2, i) === 42) {
          var c = e.getUint32(u + 4, i);
          c >= 8 && (a = u + c);
        }
      }
    }
    if (a) {
      var h = e.getUint16(a, i), d, _;
      for (_ = 0; _ < h; _ += 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 dm(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 _m = {
  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);
    ye(r, Ne), lt(e, Ne);
    var l = {
      width: Math.max(i.offsetWidth, a >= 0 ? a : jl),
      height: Math.max(i.offsetHeight, s >= 0 ? s : ql)
    };
    this.containerData = l, Mt(r, {
      width: l.width,
      height: l.height
    }), ye(e, Ne), lt(r, Ne);
  },
  // 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 = le({}, 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, c = Number(i.minCanvasHeight) || 0;
      l > 1 ? (f = Math.max(f, r.width), c = Math.max(c, r.height), l === 3 && (c * o > f ? f = c * o : c = f / o)) : l > 0 && (f ? f = Math.max(f, u ? s.width : 0) : c ? c = Math.max(c, u ? s.height : 0) : u && (f = s.width, c = s.height, c * o > f ? f = c * o : c = f / o));
      var h = Dt({
        aspectRatio: o,
        width: f,
        height: c
      });
      f = h.width, c = h.height, a.minWidth = f, a.minHeight = c, 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 = sm({
        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, Mt(this.canvas, le({
      width: i.width,
      height: i.height
    }, Gn({
      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);
    le(i, {
      width: r,
      height: a,
      left: (n.width - r) / 2,
      top: (n.height - a) / 2
    }), Mt(this.image, le({
      width: i.width,
      height: i.height
    }, Gn(le({
      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 = le({}, 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, c = l ? Math.min(r.width, a.width, a.width + a.left, r.width - a.left) : r.width, h = 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), h * o > c ? h = c / o : c = h * o), s.minWidth = Math.min(u, c), s.minHeight = Math.min(f, h), s.maxWidth = c, s.maxHeight = h;
    }
    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 && Xn(this.face, xn, i.width >= n.width && i.height >= n.height ? Ul : _a), Mt(this.cropBox, le({
      width: i.width,
      height: i.height
    }, Gn({
      translateX: i.left,
      translateY: i.top
    }))), this.cropped && this.limited && this.limitCanvas(!0, !0), this.disabled || this.output();
  },
  output: function() {
    this.preview(), _n(this.element, Vr, this.getData());
  }
}, mm = {
  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, ge(l, function(o) {
        var u = document.createElement("img");
        Xn(o, oi, {
          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() {
    ge(this.previews, function(e) {
      var n = Qr(e, oi);
      Mt(e, {
        width: n.width,
        height: n.height
      }), e.innerHTML = n.html, nm(e, oi);
    });
  },
  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 || (Mt(this.viewBoxImage, le({
      width: s,
      height: l
    }, Gn(le({
      translateX: -o,
      translateY: -u
    }, e)))), ge(this.previews, function(f) {
      var c = Qr(f, oi), h = c.width, d = c.height, _ = h, g = d, v = 1;
      r && (v = h / r, g = a * v), a && g > d && (v = d / a, _ = r * v, g = d), Mt(f, {
        width: _,
        height: g
      }), Mt(f.getElementsByTagName("img")[0], le({
        width: s * v,
        height: l * v
      }, Gn(le({
        translateX: -o * v,
        translateY: -u * v
      }, e))));
    }));
  }
}, gm = {
  bind: function() {
    var e = this.element, n = this.options, i = this.cropper;
    Be(n.cropstart) && qe(e, Zr, n.cropstart), Be(n.cropmove) && qe(e, Yr, n.cropmove), Be(n.cropend) && qe(e, Wr, n.cropend), Be(n.crop) && qe(e, Vr, n.crop), Be(n.zoom) && qe(e, Jr, n.zoom), qe(i, js, this.onCropStart = this.cropStart.bind(this)), n.zoomable && n.zoomOnWheel && qe(i, Ws, this.onWheel = this.wheel.bind(this), {
      passive: !1,
      capture: !0
    }), n.toggleDragModeOnDblclick && qe(i, Gs, this.onDblclick = this.dblclick.bind(this)), qe(e.ownerDocument, qs, this.onCropMove = this.cropMove.bind(this)), qe(e.ownerDocument, xs, this.onCropEnd = this.cropEnd.bind(this)), n.responsive && qe(window, Vs, this.onResize = this.resize.bind(this));
  },
  unbind: function() {
    var e = this.element, n = this.options, i = this.cropper;
    Be(n.cropstart) && Je(e, Zr, n.cropstart), Be(n.cropmove) && Je(e, Yr, n.cropmove), Be(n.cropend) && Je(e, Wr, n.cropend), Be(n.crop) && Je(e, Vr, n.crop), Be(n.zoom) && Je(e, Jr, n.zoom), Je(i, js, this.onCropStart), n.zoomable && n.zoomOnWheel && Je(i, Ws, this.onWheel, {
      passive: !1,
      capture: !0
    }), n.toggleDragModeOnDblclick && Je(i, Gs, this.onDblclick), Je(e.ownerDocument, qs, this.onCropMove), Je(e.ownerDocument, xs, this.onCropEnd), n.responsive && Je(window, Vs, this.onResize);
  }
}, pm = {
  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(ge(l, function(u, f) {
          l[f] = u * s;
        })), this.setCropBoxData(ge(o, function(u, f) {
          o[f] = u * s;
        })));
      }
    }
  },
  dblclick: function() {
    this.disabled || this.options.dragMode === Gl || this.setDragMode(em(this.dragBox, xr) ? zl : ma);
  },
  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)
    (j(n) && n !== 1 || j(i) && i !== 0 || e.ctrlKey))) {
      var r = this.options, a = this.pointers, s;
      e.changedTouches ? ge(e.changedTouches, function(l) {
        a[l.identifier] = li(l);
      }) : a[e.pointerId || 0] = li(e), Object.keys(a).length > 1 && r.zoomable && r.zoomOnTouch ? s = Fl : s = Qr(e.target, xn), x_.test(s) && _n(this.element, Zr, {
        originalEvent: e,
        action: s
      }) !== !1 && (e.preventDefault(), this.action = s, this.cropping = !1, s === Pl && (this.cropping = !0, ye(this.dragBox, Ei)));
    }
  },
  cropMove: function(e) {
    var n = this.action;
    if (!(this.disabled || !n)) {
      var i = this.pointers;
      e.preventDefault(), _n(this.element, Yr, {
        originalEvent: e,
        action: n
      }) !== !1 && (e.changedTouches ? ge(e.changedTouches, function(r) {
        le(i[r.identifier] || {}, li(r, !0));
      }) : le(i[e.pointerId || 0] || {}, li(e, !0)), this.change(e));
    }
  },
  cropEnd: function(e) {
    if (!this.disabled) {
      var n = this.action, i = this.pointers;
      e.changedTouches ? ge(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, ln(this.dragBox, Ei, this.cropped && this.options.modal)), _n(this.element, Wr, {
        originalEvent: e,
        action: n
      }));
    }
  }
}, bm = {
  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, c = a.width, h = a.height, d = u + c, _ = f + h, g = 0, v = 0, k = r.width, T = r.height, E = !0, S;
    !o && e.shiftKey && (o = c && h ? c / h : 1), this.limited && (g = a.minLeft, v = a.minTop, k = g + Math.min(r.width, i.width, i.left + i.width), T = v + Math.min(r.height, i.height, i.top + i.height));
    var p = s[Object.keys(s)[0]], m = {
      x: p.endX - p.startX,
      y: p.endY - p.startY
    }, D = function(z) {
      switch (z) {
        case Ft:
          d + m.x > k && (m.x = k - d);
          break;
        case zt:
          u + m.x < g && (m.x = g - u);
          break;
        case Tt:
          f + m.y < v && (m.y = v - f);
          break;
        case rn:
          _ + m.y > T && (m.y = T - _);
          break;
      }
    };
    switch (l) {
      case _a:
        u += m.x, f += m.y;
        break;
      case Ft:
        if (m.x >= 0 && (d >= k || o && (f <= v || _ >= T))) {
          E = !1;
          break;
        }
        D(Ft), c += m.x, c < 0 && (l = zt, c = -c, u -= c), o && (h = c / o, f += (a.height - h) / 2);
        break;
      case Tt:
        if (m.y <= 0 && (f <= v || o && (u <= g || d >= k))) {
          E = !1;
          break;
        }
        D(Tt), h -= m.y, f += m.y, h < 0 && (l = rn, h = -h, f -= h), o && (c = h * o, u += (a.width - c) / 2);
        break;
      case zt:
        if (m.x <= 0 && (u <= g || o && (f <= v || _ >= T))) {
          E = !1;
          break;
        }
        D(zt), c -= m.x, u += m.x, c < 0 && (l = Ft, c = -c, u -= c), o && (h = c / o, f += (a.height - h) / 2);
        break;
      case rn:
        if (m.y >= 0 && (_ >= T || o && (u <= g || d >= k))) {
          E = !1;
          break;
        }
        D(rn), h += m.y, h < 0 && (l = Tt, h = -h, f -= h), o && (c = h * o, u += (a.width - c) / 2);
        break;
      case Hn:
        if (o) {
          if (m.y <= 0 && (f <= v || d >= k)) {
            E = !1;
            break;
          }
          D(Tt), h -= m.y, f += m.y, c = h * o;
        } else
          D(Tt), D(Ft), m.x >= 0 ? d < k ? c += m.x : m.y <= 0 && f <= v && (E = !1) : c += m.x, m.y <= 0 ? f > v && (h -= m.y, f += m.y) : (h -= m.y, f += m.y);
        c < 0 && h < 0 ? (l = Pn, h = -h, c = -c, f -= h, u -= c) : c < 0 ? (l = Rn, c = -c, u -= c) : h < 0 && (l = Ln, h = -h, f -= h);
        break;
      case Rn:
        if (o) {
          if (m.y <= 0 && (f <= v || u <= g)) {
            E = !1;
            break;
          }
          D(Tt), h -= m.y, f += m.y, c = h * o, u += a.width - c;
        } else
          D(Tt), D(zt), m.x <= 0 ? u > g ? (c -= m.x, u += m.x) : m.y <= 0 && f <= v && (E = !1) : (c -= m.x, u += m.x), m.y <= 0 ? f > v && (h -= m.y, f += m.y) : (h -= m.y, f += m.y);
        c < 0 && h < 0 ? (l = Ln, h = -h, c = -c, f -= h, u -= c) : c < 0 ? (l = Hn, c = -c, u -= c) : h < 0 && (l = Pn, h = -h, f -= h);
        break;
      case Pn:
        if (o) {
          if (m.x <= 0 && (u <= g || _ >= T)) {
            E = !1;
            break;
          }
          D(zt), c -= m.x, u += m.x, h = c / o;
        } else
          D(rn), D(zt), m.x <= 0 ? u > g ? (c -= m.x, u += m.x) : m.y >= 0 && _ >= T && (E = !1) : (c -= m.x, u += m.x), m.y >= 0 ? _ < T && (h += m.y) : h += m.y;
        c < 0 && h < 0 ? (l = Hn, h = -h, c = -c, f -= h, u -= c) : c < 0 ? (l = Ln, c = -c, u -= c) : h < 0 && (l = Rn, h = -h, f -= h);
        break;
      case Ln:
        if (o) {
          if (m.x >= 0 && (d >= k || _ >= T)) {
            E = !1;
            break;
          }
          D(Ft), c += m.x, h = c / o;
        } else
          D(rn), D(Ft), m.x >= 0 ? d < k ? c += m.x : m.y >= 0 && _ >= T && (E = !1) : c += m.x, m.y >= 0 ? _ < T && (h += m.y) : h += m.y;
        c < 0 && h < 0 ? (l = Rn, h = -h, c = -c, f -= h, u -= c) : c < 0 ? (l = Pn, c = -c, u -= c) : h < 0 && (l = Hn, h = -h, f -= h);
        break;
      case Ul:
        this.move(m.x, m.y), E = !1;
        break;
      case Fl:
        this.zoom(rm(s), e), E = !1;
        break;
      case Pl:
        if (!m.x || !m.y) {
          E = !1;
          break;
        }
        S = Wl(this.cropper), u = p.startX - S.left, f = p.startY - S.top, c = a.minWidth, h = a.minHeight, m.x > 0 ? l = m.y > 0 ? Ln : Hn : m.x < 0 && (u -= c, l = m.y > 0 ? Pn : Rn), m.y < 0 && (f -= h), this.cropped || (lt(this.cropBox, Ne), this.cropped = !0, this.limited && this.limitCropBox(!0, !0));
        break;
    }
    E && (a.width = c, a.height = h, a.left = u, a.top = f, this.action = l, this.renderCropBox()), ge(s, function(N) {
      N.startX = N.endX, N.startY = N.endY;
    });
  }
}, vm = {
  // Show the crop box manually
  crop: function() {
    return this.ready && !this.cropped && !this.disabled && (this.cropped = !0, this.limitCropBox(!0, !0), this.options.modal && ye(this.dragBox, Ei), lt(this.cropBox, Ne), this.setCropBoxData(this.initialCropBoxData)), this;
  },
  // Reset the image and crop box to their initial states
  reset: function() {
    return this.ready && !this.disabled && (this.imageData = le({}, this.initialImageData), this.canvasData = le({}, this.initialCanvasData), this.cropBoxData = le({}, this.initialCropBoxData), this.renderCanvas(), this.cropped && this.renderCropBox()), this;
  },
  // Clear the crop box
  clear: function() {
    return this.cropped && !this.disabled && (le(this.cropBoxData, {
      left: 0,
      top: 0,
      width: 0,
      height: 0
    }), this.cropped = !1, this.renderCropBox(), this.limitCanvas(!0, !0), this.renderCanvas(), lt(this.dragBox, Ei), ye(this.cropBox, Ne)), 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, ge(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, lt(this.cropper, Fs)), this;
  },
  // Disable (freeze) the cropper
  disable: function() {
    return this.ready && !this.disabled && (this.disabled = !0, ye(this.cropper, Fs)), this;
  },
  /**
   * Destroy the cropper and remove the instance from the image
   * @returns {Cropper} this
   */
  destroy: function() {
    var e = this.element;
    return e[oe] ? (e[oe] = 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(vr(e) ? e : r + Number(e), vr(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 && (j(e) && (i.left = e, r = !0), j(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, c = u * e;
      if (_n(this.element, Jr, {
        ratio: e,
        oldRatio: s / o,
        originalEvent: i
      }) === !1)
        return this;
      if (i) {
        var h = this.pointers, d = Wl(this.cropper), _ = h && Object.keys(h).length ? am(h) : {
          pageX: i.pageX,
          pageY: i.pageY
        };
        a.left -= (f - s) * ((_.pageX - d.left - a.left) / s), a.top -= (c - l) * ((_.pageY - d.top - a.top) / l);
      } else
        on(n) && j(n.x) && j(n.y) ? (a.left -= (f - s) * ((n.x - a.left) / s), a.top -= (c - l) * ((n.y - a.top) / l)) : (a.left -= (f - s) / 2, a.top -= (c - l) / 2);
      a.width = f, a.height = c, 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), j(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, j(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(j(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 && (j(e) && (i.scaleX = e, r = !0), j(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 (ge(s, function(f, c) {
        s[c] = 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 && on(e)) {
      var s = !1;
      n.rotatable && j(e.rotate) && e.rotate !== i.rotate && (i.rotate = e.rotate, s = !0), n.scalable && (j(e.scaleX) && e.scaleX !== i.scaleX && (i.scaleX = e.scaleX, s = !0), j(e.scaleY) && e.scaleY !== i.scaleY && (i.scaleY = e.scaleY, s = !0)), s && this.renderCanvas(!0, !0);
      var l = i.width / i.naturalWidth;
      j(e.x) && (a.left = e.x * l + r.left), j(e.y) && (a.top = e.y * l + r.top), j(e.width) && (a.width = e.width * l), j(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 ? le({}, this.containerData) : {};
  },
  /**
   * Get the image position and size data.
   * @returns {Object} The result image data.
   */
  getImageData: function() {
    return this.sized ? le({}, 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 && ge(["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 && on(e) && (j(e.left) && (n.left = e.left), j(e.top) && (n.top = e.top), j(e.width) ? (n.width = e.width, n.height = e.width / i) : j(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 && on(e) && (j(e.left) && (n.left = e.left), j(e.top) && (n.top = e.top), j(e.width) && e.width !== n.width && (r = !0, n.width = e.width), j(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 = om(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, c = Dt({
      aspectRatio: f,
      width: e.maxWidth || 1 / 0,
      height: e.maxHeight || 1 / 0
    }), h = Dt({
      aspectRatio: f,
      width: e.minWidth || 0,
      height: e.minHeight || 0
    }, "cover"), d = Dt({
      aspectRatio: f,
      width: e.width || (u !== 1 ? i.width : l),
      height: e.height || (u !== 1 ? i.height : o)
    }), _ = d.width, g = d.height;
    _ = Math.min(c.width, Math.max(h.width, _)), g = Math.min(c.height, Math.max(h.height, g));
    var v = document.createElement("canvas"), k = v.getContext("2d");
    v.width = dn(_), v.height = dn(g), k.fillStyle = e.fillColor || "transparent", k.fillRect(0, 0, _, g);
    var T = e.imageSmoothingEnabled, E = T === void 0 ? !0 : T, S = e.imageSmoothingQuality;
    k.imageSmoothingEnabled = E, S && (k.imageSmoothingQuality = S);
    var p = i.width, m = i.height, D = a, N = s, z, X, Q, ne, B, b;
    D <= -l || D > p ? (D = 0, z = 0, Q = 0, B = 0) : D <= 0 ? (Q = -D, D = 0, z = Math.min(p, l + D), B = z) : D <= p && (Q = 0, z = Math.min(l, p - D), B = z), z <= 0 || N <= -o || N > m ? (N = 0, X = 0, ne = 0, b = 0) : N <= 0 ? (ne = -N, N = 0, X = Math.min(m, o + N), b = X) : N <= m && (ne = 0, X = Math.min(o, m - N), b = X);
    var O = [D, N, z, X];
    if (B > 0 && b > 0) {
      var P = _ / l;
      O.push(Q * P, ne * P, B * P, b * P);
    }
    return k.drawImage.apply(k, [i].concat(Rl(O.map(function(A) {
      return Math.floor(dn(A));
    })))), v;
  },
  /**
   * 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 && !vr(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 === ma, s = n.movable && e === zl;
      e = a || s ? e : Gl, n.dragMode = e, Xn(i, xn, e), ln(i, xr, a), ln(i, Xr, s), n.cropBoxMovable || (Xn(r, xn, e), ln(r, xr, a), ln(r, Xr, s));
    }
    return this;
  }
}, wm = ct.Cropper, Zl = /* @__PURE__ */ function() {
  function t(e) {
    var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
    if (N_(this, t), !e || !W_.test(e.tagName))
      throw new Error("The first argument is required and must be an <img> or <canvas> element.");
    this.element = e, this.options = le({}, Zs, on(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 I_(t, [{
    key: "init",
    value: function() {
      var n = this.element, i = n.tagName.toLowerCase(), r;
      if (!n[oe]) {
        if (n[oe] = 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 (X_.test(n)) {
          V_.test(n) ? this.read(fm(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") !== Ys && s.abort();
        }, s.onload = function() {
          i.read(s.response);
        }, s.onloadend = function() {
          i.reloading = !1, i.xhr = null;
        }, a.checkCrossOrigin && Qs(n) && r.crossOrigin && (n = Ks(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 = hm(n), s = 0, l = 1, o = 1;
      if (a > 1) {
        this.url = cm(n, Ys);
        var u = dm(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 && Qs(i) && (r || (r = "anonymous"), a = Ks(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), ye(s, zs), 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 = ct.navigator && /(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(ct.navigator.userAgent), a = function(u, f) {
        le(n.imageData, {
          naturalWidth: u,
          naturalHeight: f,
          aspectRatio: u / f
        }), n.initialImageData = le({}, 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 = Y_;
        var l = s.querySelector(".".concat(oe, "-container")), o = l.querySelector(".".concat(oe, "-canvas")), u = l.querySelector(".".concat(oe, "-drag-box")), f = l.querySelector(".".concat(oe, "-crop-box")), c = f.querySelector(".".concat(oe, "-face"));
        this.container = a, this.cropper = l, this.canvas = o, this.dragBox = u, this.cropBox = f, this.viewBox = l.querySelector(".".concat(oe, "-view-box")), this.face = c, o.appendChild(r), ye(n, Ne), a.insertBefore(l, n.nextSibling), lt(r, zs), 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, ye(f, Ne), i.guides || ye(f.getElementsByClassName("".concat(oe, "-dashed")), Ne), i.center || ye(f.getElementsByClassName("".concat(oe, "-center")), Ne), i.background && ye(l, "".concat(oe, "-bg")), i.highlight || ye(c, z_), i.cropBoxMovable && (ye(c, Xr), Xn(c, xn, _a)), i.cropBoxResizable || (ye(f.getElementsByClassName("".concat(oe, "-line")), Ne), ye(f.getElementsByClassName("".concat(oe, "-point")), Ne)), this.render(), this.ready = !0, this.setDragMode(i.dragMode), i.autoCrop && this.crop(), this.setData(i.data), Be(i.ready) && qe(n, Xs, i.ready, {
          once: !0
        }), _n(n, Xs);
      }
    }
  }, {
    key: "unbuild",
    value: function() {
      if (this.ready) {
        this.ready = !1, this.unbind(), this.resetPreview();
        var n = this.cropper.parentNode;
        n && n.removeChild(this.cropper), lt(this.element, Ne);
      }
    }
  }, {
    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 = wm, t;
    }
    /**
     * Change the default options.
     * @param {Object} options - The new default options.
     */
  }, {
    key: "setDefaults",
    value: function(n) {
      le(Zs, on(n) && n);
    }
  }]), t;
}();
le(Zl.prototype, _m, mm, gm, pm, bm, vm);
const {
  SvelteComponent: ym,
  attr: yr,
  binding_callbacks: Em,
  detach: km,
  element: Sm,
  flush: Tm,
  init: Cm,
  insert: Am,
  noop: $s,
  safe_not_equal: Mm,
  src_url_equal: eo
} = window.__gradio__svelte__internal, { onMount: N1, createEventDispatcher: Dm } = window.__gradio__svelte__internal;
function Om(t) {
  let e, n;
  return {
    c() {
      e = Sm("img"), eo(e.src, n = /*image*/
      t[0]) || yr(e, "src", n), yr(e, "alt", "");
    },
    m(i, r) {
      Am(i, e, r), t[4](e);
    },
    p(i, [r]) {
      r & /*image*/
      1 && !eo(e.src, n = /*image*/
      i[0]) && yr(e, "src", n);
    },
    i: $s,
    o: $s,
    d(i) {
      i && km(e), t[4](null);
    }
  };
}
function Bm(t, e, n) {
  let { image: i } = e, r;
  const a = Dm();
  let s;
  function l() {
    s.destroy();
  }
  function o() {
    s && l(), s = new Zl(
      r,
      {
        autoCropArea: 1,
        cropend() {
          const f = s.getCroppedCanvas().toDataURL();
          a("crop", f);
        }
      }
    ), a("crop", i);
  }
  function u(f) {
    Em[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 Jl extends ym {
  constructor(e) {
    super(), Cm(this, e, Bm, Om, Mm, { image: 0, destroy: 2, create: 3 });
  }
  get image() {
    return this.$$.ctx[0];
  }
  set image(e) {
    this.$$set({ image: e }), Tm();
  }
  get destroy() {
    return this.$$.ctx[2];
  }
  get create() {
    return this.$$.ctx[3];
  }
}
class to {
  /**
   *
   * @param {number} x
   * @param {number} y
   */
  constructor(e, n) {
    this.x = e, this.y = n;
  }
}
class no extends to {
  /**
   * 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 to(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 Nm = 30;
class Im {
  /**
   * constructor
   *
   * @param {object} settings
   * @param {number} settings.radius The radius for the lazy area
   * @param {boolean} settings.enabled
   */
  constructor({ radius: e = Nm, enabled: n = !0, initialPoint: i = { x: 0, y: 0 } } = {}) {
    this.radius = e, this._isEnabled = n, this.pointer = new no(i.x, i.y), this.brush = new no(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 Ql = 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;
    }()
  );
}(), Kr = typeof window < "u" && typeof document < "u" && window.document === document, ki = 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")();
}(), Hm = function() {
  return typeof requestAnimationFrame == "function" ? requestAnimationFrame.bind(ki) : function(t) {
    return setTimeout(function() {
      return t(Date.now());
    }, 1e3 / 60);
  };
}(), Rm = 2;
function Lm(t, e) {
  var n = !1, i = !1, r = 0;
  function a() {
    n && (n = !1, t()), i && l();
  }
  function s() {
    Hm(a);
  }
  function l() {
    var o = Date.now();
    if (n) {
      if (o - r < Rm)
        return;
      i = !0;
    } else
      n = !0, i = !1, setTimeout(s, e);
    r = o;
  }
  return l;
}
var Pm = 20, Um = ["top", "right", "bottom", "left", "width", "height", "size", "weight"], Fm = typeof MutationObserver < "u", zm = (
  /** @class */
  function() {
    function t() {
      this.connected_ = !1, this.mutationEventsAdded_ = !1, this.mutationsObserver_ = null, this.observers_ = [], this.onTransitionEnd_ = this.onTransitionEnd_.bind(this), this.refresh = Lm(this.refresh.bind(this), Pm);
    }
    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() {
      !Kr || this.connected_ || (document.addEventListener("transitionend", this.onTransitionEnd_), window.addEventListener("resize", this.refresh), Fm ? (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() {
      !Kr || !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 = Um.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;
  }()
), Kl = 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;
}, vn = function(t) {
  var e = t && t.ownerDocument && t.ownerDocument.defaultView;
  return e || ki;
}, $l = Ri(0, 0, 0, 0);
function Si(t) {
  return parseFloat(t) || 0;
}
function io(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 + Si(a);
  }, 0);
}
function Gm(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] = Si(s);
  }
  return n;
}
function jm(t) {
  var e = t.getBBox();
  return Ri(0, 0, e.width, e.height);
}
function qm(t) {
  var e = t.clientWidth, n = t.clientHeight;
  if (!e && !n)
    return $l;
  var i = vn(t).getComputedStyle(t), r = Gm(i), a = r.left + r.right, s = r.top + r.bottom, l = Si(i.width), o = Si(i.height);
  if (i.boxSizing === "border-box" && (Math.round(l + a) !== e && (l -= io(i, "left", "right") + a), Math.round(o + s) !== n && (o -= io(i, "top", "bottom") + s)), !Xm(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 Ri(r.left, r.top, l, o);
}
var xm = function() {
  return typeof SVGGraphicsElement < "u" ? function(t) {
    return t instanceof vn(t).SVGGraphicsElement;
  } : function(t) {
    return t instanceof vn(t).SVGElement && typeof t.getBBox == "function";
  };
}();
function Xm(t) {
  return t === vn(t).document.documentElement;
}
function Vm(t) {
  return Kr ? xm(t) ? jm(t) : qm(t) : $l;
}
function Wm(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 Kl(s, {
    x: e,
    y: n,
    width: i,
    height: r,
    top: n,
    right: e + i,
    bottom: r + n,
    left: e
  }), s;
}
function Ri(t, e, n, i) {
  return { x: t, y: e, width: n, height: i };
}
var Ym = (
  /** @class */
  function() {
    function t(e) {
      this.broadcastWidth = 0, this.broadcastHeight = 0, this.contentRect_ = Ri(0, 0, 0, 0), this.target = e;
    }
    return t.prototype.isActive = function() {
      var e = Vm(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;
  }()
), Zm = (
  /** @class */
  function() {
    function t(e, n) {
      var i = Wm(n);
      Kl(this, { target: e, contentRect: i });
    }
    return t;
  }()
), Jm = (
  /** @class */
  function() {
    function t(e, n, i) {
      if (this.activeObservations_ = [], this.observations_ = new Ql(), 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 vn(e).Element))
          throw new TypeError('parameter 1 is not of type "Element".');
        var n = this.observations_;
        n.has(e) || (n.set(e, new Ym(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 vn(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 Zm(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;
  }()
), eu = typeof WeakMap < "u" ? /* @__PURE__ */ new WeakMap() : new Ql(), tu = (
  /** @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 = zm.getInstance(), i = new Jm(e, n, this);
      eu.set(this, i);
    }
    return t;
  }()
);
[
  "observe",
  "unobserve",
  "disconnect"
].forEach(function(t) {
  tu.prototype[t] = function() {
    var e;
    return (e = eu.get(this))[t].apply(e, arguments);
  };
});
var Qm = function() {
  return typeof ki.ResizeObserver < "u" ? ki.ResizeObserver : tu;
}();
const {
  SvelteComponent: Km,
  add_iframe_resize_listener: $m,
  add_render_callback: nu,
  append: eg,
  attr: Ti,
  binding_callbacks: ro,
  bubble: tg,
  check_outros: ng,
  create_bidirectional_transition: ao,
  destroy_each: ig,
  detach: pa,
  element: ba,
  ensure_array_like: so,
  group_outros: rg,
  init: ag,
  insert: va,
  listen: rt,
  run_all: sg,
  safe_not_equal: og,
  set_style: oo,
  space: lg,
  stop_propagation: ug,
  toggle_class: ui,
  transition_in: Er,
  transition_out: lo
} = window.__gradio__svelte__internal, { onMount: fg, onDestroy: cg, createEventDispatcher: hg, tick: kr } = window.__gradio__svelte__internal;
function uo(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 fo(t) {
  let e, n, i;
  return {
    c() {
      e = ba("div"), e.textContent = "Start drawing", Ti(e, "class", "start-prompt svelte-14l85k0");
    },
    m(r, a) {
      va(r, e, a), i = !0;
    },
    i(r) {
      i || (r && nu(() => {
        i && (n || (n = ao(e, Ia, { duration: 50 }, !0)), n.run(1));
      }), i = !0);
    },
    o(r) {
      r && (n || (n = ao(e, Ia, { duration: 50 }, !1)), n.run(0)), i = !1;
    },
    d(r) {
      r && pa(e), r && n && n.end();
    }
  };
}
function co(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 = ba("canvas"), Ti(
        e,
        "key",
        /*name*/
        t[61]
      ), oo(
        e,
        "z-index",
        /*zIndex*/
        t[62]
      ), Ti(e, "class", "svelte-14l85k0"), ui(
        e,
        "lr",
        /*add_lr_border*/
        t[5]
      ), ui(e, "tb", !/*add_lr_border*/
      t[5]), oo(
        e,
        "opacity",
        /*opacity*/
        t[63]
      );
    },
    m(l, o) {
      va(l, e, o), a(), i || (r = [
        rt(
          e,
          "mousedown",
          /*name*/
          t[61] === "interface" ? (
            /*handle_draw_start*/
            t[7]
          ) : void 0
        ),
        rt(
          e,
          "mousemove",
          /*name*/
          t[61] === "interface" ? (
            /*handle_draw_move*/
            t[8]
          ) : void 0
        ),
        rt(
          e,
          "mouseup",
          /*name*/
          t[61] === "interface" ? (
            /*handle_draw_end*/
            t[9]
          ) : void 0
        ),
        rt(
          e,
          "mouseout",
          /*name*/
          t[61] === "interface" ? (
            /*handle_draw_end*/
            t[9]
          ) : void 0
        ),
        rt(
          e,
          "blur",
          /*name*/
          t[61] === "interface" ? (
            /*handle_draw_end*/
            t[9]
          ) : void 0
        ),
        rt(
          e,
          "touchstart",
          /*name*/
          t[61] === "interface" ? (
            /*handle_draw_start*/
            t[7]
          ) : void 0
        ),
        rt(
          e,
          "touchmove",
          /*name*/
          t[61] === "interface" ? (
            /*handle_draw_move*/
            t[8]
          ) : void 0
        ),
        rt(
          e,
          "touchend",
          /*name*/
          t[61] === "interface" ? (
            /*handle_draw_end*/
            t[9]
          ) : void 0
        ),
        rt(
          e,
          "touchcancel",
          /*name*/
          t[61] === "interface" ? (
            /*handle_draw_end*/
            t[9]
          ) : void 0
        ),
        rt(e, "click", ug(
          /*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 && ui(
        e,
        "lr",
        /*add_lr_border*/
        t[5]
      ), o[0] & /*add_lr_border*/
      32 && ui(e, "tb", !/*add_lr_border*/
      t[5]);
    },
    d(l) {
      l && pa(e), s(), i = !1, sg(r);
    }
  };
}
function dg(t) {
  let e, n, i, r = (
    /*line_count*/
    t[4] === 0 && fo()
  ), a = so(
    /*canvas_types*/
    t[6]
  ), s = [];
  for (let l = 0; l < a.length; l += 1)
    s[l] = co(uo(t, a, l));
  return {
    c() {
      e = ba("div"), r && r.c(), n = lg();
      for (let l = 0; l < s.length; l += 1)
        s[l].c();
      Ti(e, "class", "wrap svelte-14l85k0"), nu(() => (
        /*div_elementresize_handler*/
        t[33].call(e)
      ));
    },
    m(l, o) {
      va(l, e, o), r && r.m(e, null), eg(e, n);
      for (let u = 0; u < s.length; u += 1)
        s[u] && s[u].m(e, null);
      t[32](e), i = $m(
        e,
        /*div_elementresize_handler*/
        t[33].bind(e)
      );
    },
    p(l, o) {
      if (/*line_count*/
      l[4] === 0 ? r ? o[0] & /*line_count*/
      16 && Er(r, 1) : (r = fo(), r.c(), Er(r, 1), r.m(e, n)) : r && (rg(), lo(r, 1, 1, () => {
        r = null;
      }), ng()), o[0] & /*canvas_types, canvas, add_lr_border, handle_draw_start, handle_draw_move, handle_draw_end*/
      993) {
        a = so(
          /*canvas_types*/
          l[6]
        );
        let u;
        for (u = 0; u < a.length; u += 1) {
          const f = uo(l, a, u);
          s[u] ? s[u].p(f, o) : (s[u] = co(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) {
      Er(r);
    },
    o(l) {
      lo(r);
    },
    d(l) {
      l && pa(e), r && r.d(), ig(s, l), t[32](null), i();
    }
  };
}
let _g = "#aaa";
function mg(t, e) {
  return {
    x: t.x + (e.x - t.x) / 2,
    y: t.y + (e.y - t.y) / 2
  };
}
function gg(t, e, n) {
  let i;
  const r = hg();
  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: c } = e, { width: h = 400 } = e, { height: d = 200 } = e, { container_height: _ = 200 } = e, { shape: g } = e, v, k = h, T = d, E;
  const S = [
    { name: "interface", zIndex: 15 },
    {
      name: "mask",
      zIndex: 13,
      opacity: f
    },
    { name: "drawing", zIndex: 11 },
    { name: "temp", zIndex: 12 }
  ];
  let p = {}, m = {}, D = [], N = [], z = !0, X = !0, Q = !1, ne = !1, B = null, b = null, O = null, P = 0;
  function A() {
    if (!g) {
      m.temp.drawImage(s, 0, 0, h, d);
      return;
    }
    let w = s.naturalWidth, I = s.naturalHeight;
    const Z = g[0] / g[1], we = w / I;
    let ae = 0, Me = 0;
    Z < we ? (w = g[1] * we, I = g[1], ae = (g[0] - w) / 2) : Z > we ? (w = g[0], I = g[0] / we, Me = (g[1] - I) / 2) : (ae = 0, Me = 0, w = g[0], I = g[1]), m.temp.drawImage(s, ae, Me, w, I);
  }
  fg(async () => {
    Object.keys(p).forEach((w) => {
      n(27, m[w] = p[w].getContext("2d"), m);
    }), await kr(), s && (s.addEventListener("load", (w) => {
      c === "webcam" ? (m.temp.save(), m.temp.translate(h, 0), m.temp.scale(-1, 1), m.temp.drawImage(s, 0, 0), m.temp.restore()) : A(), m.drawing.drawImage(p.temp, 0, 0, h, d), ht();
    }), setTimeout(
      () => {
        c === "webcam" ? (m.temp.save(), m.temp.translate(h, 0), m.temp.scale(-1, 1), m.temp.drawImage(s, 0, 0), m.temp.restore()) : A(), m.drawing.drawImage(p.temp, 0, 0, h, d), K({ lines: N.slice() }), ht();
      },
      100
    )), n(29, B = new Im({
      radius: u * 0.05,
      enabled: !0,
      initialPoint: { x: h / 2, y: d / 2 }
    })), O = new Qm((w, I, ...Z) => {
      ue();
    }), O.observe(b), On(), n(25, v = !0), requestAnimationFrame(() => {
      G(), requestAnimationFrame(() => {
        It();
      });
    });
  });
  function G() {
    const w = h / 2, I = d / 2;
    B.update({ x: w, y: I }, { both: !0 }), B.update({ x: w, y: I }, { both: !1 }), z = !0, X = !0;
  }
  cg(() => {
    n(25, v = !1), O.unobserve(b);
  });
  function U(w) {
    $n(), s && (c === "webcam" ? (m.temp.save(), m.temp.translate(h, 0), m.temp.scale(-1, 1), m.temp.drawImage(s, 0, 0), m.temp.restore()) : A(), (!N || !N.length) && m.drawing.drawImage(p.temp, 0, 0, h, d)), K({ lines: w }), n(4, P = w.length), n(28, N = w), m.drawing.drawImage(p.temp, 0, 0, h, d), N.length == 0 && r("clear");
  }
  function F() {
    U([]), ht();
  }
  function ce() {
    const w = N.slice(0, -1);
    U(w), ht();
  }
  let K = ({ lines: w }) => {
    w.forEach((I) => {
      const { points: Z, brush_color: we, brush_radius: ae } = I;
      Ie({
        points: Z,
        brush_color: we,
        brush_radius: ae,
        mask: l === "mask"
      });
    }), nt(), l === "mask" && Ae();
  }, M = (w) => {
    w.preventDefault(), ne = !0;
    const { x: I, y: Z } = be(w);
    w.touches && w.touches.length > 0 && B.update({ x: I, y: Z }, { both: !0 }), ve(I, Z), n(4, P += 1);
  }, he = (w) => {
    w.preventDefault();
    const { x: I, y: Z } = be(w);
    ve(I, Z);
  }, de = (w) => {
    w.preventDefault(), he(w), Q = !1, ne = !1, nt(), l === "mask" && Ae();
  }, tt = 0, C = 0, vt = 0, wt = !1, ue = async () => {
    if (g && b) {
      const Z = b == null ? void 0 : b.getBoundingClientRect(), we = g[0] / g[1], ae = Z.width / Z.height;
      n(5, wt = we < ae);
    }
    if (h === tt && d === C && vt === _)
      return;
    const w = { width: h, height: d }, I = {
      height: _,
      width: _ * (w.width / w.height)
    };
    await Promise.all([
      re(p.interface, w, I),
      re(p.drawing, w, I),
      re(p.temp, w, I),
      re(p.mask, w, I, !1)
    ]), u || n(10, u = 20 * (w.width / I.width)), On({ once: !0 }), setTimeout(
      () => {
        C = d, tt = h, vt = _;
      },
      10
    ), await kr(), It();
  }, re = async (w, I, Z, we = !0) => {
    if (!v)
      return;
    await kr();
    const ae = window.devicePixelRatio || 1;
    w.width = I.width * (we ? ae : 1), w.height = I.height * (we ? ae : 1);
    const Me = w.getContext("2d");
    we && Me.scale(ae, ae), w.style.width = `${Z.width}px`, w.style.height = `${Z.height}px`;
  }, be = (w) => {
    const I = p.interface.getBoundingClientRect();
    let Z = w.clientX, we = w.clientY;
    return w.changedTouches && w.changedTouches.length > 0 && (Z = w.changedTouches[0].clientX, we = w.changedTouches[0].clientY), {
      x: (Z - I.left) / I.width * h,
      y: (we - I.top) / I.height * d
    };
  }, ve = (w, I) => {
    B.update({ x: w, y: I });
    const Z = !B.isEnabled();
    (ne && !Q || Z && ne) && (Q = !0, D.push(B.brush.toObject())), Q && (D.push(B.brush.toObject()), Ie({
      points: D,
      brush_color: o,
      brush_radius: u,
      mask: l === "mask"
    })), z = !0;
  }, Ie = ({ points: w, brush_color: I, brush_radius: Z, mask: we }) => {
    if (!w || w.length < 2)
      return;
    let ae = we ? m.mask : m.temp;
    ae.lineJoin = "round", ae.lineCap = "round", ae.strokeStyle = I, ae.lineWidth = Z;
    let Me = w[0], Qt = w[1];
    ae.moveTo(Qt.x, Qt.y), ae.beginPath();
    for (var y = 1, De = w.length; y < De; y++) {
      var ti = mg(Me, Qt);
      ae.quadraticCurveTo(Me.x, Me.y, ti.x, ti.y), Me = w[y], Qt = w[y + 1];
    }
    ae.lineTo(Me.x, Me.y), ae.stroke();
  }, Ae = () => {
    D.length < 1 || (D.length = 0, ht());
  }, nt = () => {
    D.length < 1 || (N.push({
      points: D.slice(),
      brush_color: o,
      brush_radius: u
    }), l !== "mask" && (D.length = 0), m.drawing.drawImage(p.temp, 0, 0, h, d), ht());
  }, ht = () => {
    const w = ei();
    r("change", w);
  };
  function It() {
    return n(28, N = []), $n(), n(4, P = 0), !0;
  }
  function $n() {
    X = !0, m.temp.clearRect(0, 0, h, d), n(27, m.temp.fillStyle = l === "mask" ? "transparent" : "#FFFFFF", m), m.temp.fillRect(0, 0, h, d), l === "mask" && m.mask.clearRect(0, 0, p.mask.width, p.mask.height);
  }
  let On = ({ once: w = !1 } = {}) => {
    if (z || X) {
      const I = B.getPointerCoordinates(), Z = B.getBrushCoordinates();
      Ui(m.interface, I, Z), z = !1, X = !1;
    }
    w || window.requestAnimationFrame(() => {
      On();
    });
  }, Ui = (w, I, Z) => {
    w.clearRect(0, 0, h, d), w.beginPath(), w.fillStyle = o, w.arc(Z.x, Z.y, u / 2, 0, Math.PI * 2, !0), w.fill(), w.beginPath(), w.fillStyle = _g, w.arc(Z.x, Z.y, i, 0, Math.PI * 2, !0), w.fill();
  };
  function ei() {
    return l === "mask" ? p.mask.toDataURL("image/png") : p.drawing.toDataURL("image/jpg");
  }
  function Fi(w) {
    tg.call(this, t, w);
  }
  function zi(w, I) {
    ro[w ? "unshift" : "push"](() => {
      p[I] = w, n(0, p);
    });
  }
  function Gi(w) {
    ro[w ? "unshift" : "push"](() => {
      b = w, n(3, b);
    });
  }
  function ji() {
    k = this.offsetWidth, T = this.offsetHeight, n(1, k), n(2, T);
  }
  return t.$$set = (w) => {
    "value" in w && n(13, a = w.value), "value_img" in w && n(14, s = w.value_img), "mode" in w && n(15, l = w.mode), "brush_color" in w && n(16, o = w.brush_color), "brush_radius" in w && n(10, u = w.brush_radius), "mask_opacity" in w && n(17, f = w.mask_opacity), "source" in w && n(18, c = w.source), "width" in w && n(11, h = w.width), "height" in w && n(12, d = w.height), "container_height" in w && n(19, _ = w.container_height), "shape" in w && n(20, g = w.shape);
  }, t.$$.update = () => {
    t.$$.dirty[0] & /*shape, width, height*/
    1054720 && g && (h || d) && (n(11, h = g[0]), n(12, d = g[1])), t.$$.dirty[0] & /*mounted, value*/
    33562624 && v && !a && It(), t.$$.dirty[0] & /*mounted, value_img, last_value_img, source, ctx, width, canvas, height, lines*/
    503601153 && v && s !== E && (n(26, E = s), It(), setTimeout(
      () => {
        c === "webcam" ? (m.temp.save(), m.temp.translate(h, 0), m.temp.scale(-1, 1), m.temp.drawImage(s, 0, 0), m.temp.restore()) : A(), m.drawing.drawImage(p.temp, 0, 0, h, d), K({ lines: N.slice() }), ht();
      },
      50
    )), t.$$.dirty[0] & /*lazy, brush_radius*/
    536871936 && B && (G(), B.setRadius(u * 0.05)), t.$$.dirty[0] & /*width, height*/
    6144 && (h || d) && ue(), t.$$.dirty[0] & /*brush_radius*/
    1024 && (i = u * 0.075);
  }, [
    p,
    k,
    T,
    b,
    P,
    wt,
    S,
    M,
    he,
    de,
    u,
    h,
    d,
    a,
    s,
    l,
    o,
    f,
    c,
    _,
    g,
    F,
    ce,
    It,
    ei,
    v,
    E,
    m,
    N,
    B,
    Fi,
    zi,
    Gi,
    ji
  ];
}
class wa extends Km {
  constructor(e) {
    super(), ag(
      this,
      e,
      gg,
      dg,
      og,
      {
        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];
  }
}
const {
  SvelteComponent: pg,
  append: ho,
  attr: et,
  binding_callbacks: bg,
  check_outros: ya,
  create_component: Ea,
  destroy_component: ka,
  detach: Tn,
  element: wn,
  empty: vg,
  group_outros: Sa,
  init: wg,
  insert: Cn,
  is_function: yg,
  listen: Eg,
  mount_component: Ta,
  noop: kg,
  safe_not_equal: Sg,
  space: Tg,
  toggle_class: _o,
  transition_in: ut,
  transition_out: gt
} = window.__gradio__svelte__internal, { createEventDispatcher: Cg, onMount: Ag } = window.__gradio__svelte__internal;
function mo(t) {
  let e, n, i, r, a, s, l;
  const o = [Dg, Mg], u = [];
  function f(c, h) {
    return (
      /*mode*/
      c[1] === "video" ? 0 : 1
    );
  }
  return n = f(t), i = u[n] = o[n](t), {
    c() {
      e = wn("button"), i.c(), et(e, "aria-label", r = /*mode*/
      t[1] === "image" ? "capture photo" : "start recording"), et(e, "class", "svelte-ji57xm");
    },
    m(c, h) {
      Cn(c, e, h), u[n].m(e, null), a = !0, s || (l = Eg(e, "click", function() {
        yg(
          /*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);
      }), s = !0);
    },
    p(c, h) {
      t = c;
      let d = n;
      n = f(t), n === d ? u[n].p(t, h) : (Sa(), gt(u[d], 1, 1, () => {
        u[d] = null;
      }), ya(), i = u[n], i ? i.p(t, h) : (i = u[n] = o[n](t), i.c()), ut(i, 1), i.m(e, null)), (!a || h & /*mode*/
      2 && r !== (r = /*mode*/
      t[1] === "image" ? "capture photo" : "start recording")) && et(e, "aria-label", r);
    },
    i(c) {
      a || (ut(i), a = !0);
    },
    o(c) {
      gt(i), a = !1;
    },
    d(c) {
      c && Tn(e), u[n].d(), s = !1, l();
    }
  };
}
function Mg(t) {
  let e, n, i;
  return n = new Hh({}), {
    c() {
      e = wn("div"), Ea(n.$$.fragment), et(e, "class", "icon svelte-ji57xm"), et(e, "title", "capture photo");
    },
    m(r, a) {
      Cn(r, e, a), Ta(n, e, null), i = !0;
    },
    p: kg,
    i(r) {
      i || (ut(n.$$.fragment, r), i = !0);
    },
    o(r) {
      gt(n.$$.fragment, r), i = !1;
    },
    d(r) {
      r && Tn(e), ka(n);
    }
  };
}
function Dg(t) {
  let e, n, i, r;
  const a = [Bg, Og], 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 = vg();
    },
    m(o, u) {
      s[e].m(o, u), Cn(o, i, u), r = !0;
    },
    p(o, u) {
      let f = e;
      e = l(o), e !== f && (Sa(), gt(s[f], 1, 1, () => {
        s[f] = null;
      }), ya(), n = s[e], n || (n = s[e] = a[e](o), n.c()), ut(n, 1), n.m(i.parentNode, i));
    },
    i(o) {
      r || (ut(n), r = !0);
    },
    o(o) {
      gt(n), r = !1;
    },
    d(o) {
      o && Tn(i), s[e].d(o);
    }
  };
}
function Og(t) {
  let e, n, i;
  return n = new jh({}), {
    c() {
      e = wn("div"), Ea(n.$$.fragment), et(e, "class", "icon svelte-ji57xm"), et(e, "title", "start recording");
    },
    m(r, a) {
      Cn(r, e, a), Ta(n, e, null), i = !0;
    },
    i(r) {
      i || (ut(n.$$.fragment, r), i = !0);
    },
    o(r) {
      gt(n.$$.fragment, r), i = !1;
    },
    d(r) {
      r && Tn(e), ka(n);
    }
  };
}
function Bg(t) {
  let e, n, i;
  return n = new e0({}), {
    c() {
      e = wn("div"), Ea(n.$$.fragment), et(e, "class", "icon svelte-ji57xm"), et(e, "title", "stop recording");
    },
    m(r, a) {
      Cn(r, e, a), Ta(n, e, null), i = !0;
    },
    i(r) {
      i || (ut(n.$$.fragment, r), i = !0);
    },
    o(r) {
      gt(n.$$.fragment, r), i = !1;
    },
    d(r) {
      r && Tn(e), ka(n);
    }
  };
}
function Ng(t) {
  let e, n, i, r, a = !/*streaming*/
  t[0] && mo(t);
  return {
    c() {
      e = wn("div"), n = wn("video"), i = Tg(), a && a.c(), et(n, "class", "svelte-ji57xm"), _o(
        n,
        "flip",
        /*mirror_webcam*/
        t[2]
      ), et(e, "class", "wrap svelte-ji57xm");
    },
    m(s, l) {
      Cn(s, e, l), ho(e, n), t[10](n), ho(e, i), a && a.m(e, null), r = !0;
    },
    p(s, [l]) {
      (!r || l & /*mirror_webcam*/
      4) && _o(
        n,
        "flip",
        /*mirror_webcam*/
        s[2]
      ), /*streaming*/
      s[0] ? a && (Sa(), gt(a, 1, 1, () => {
        a = null;
      }), ya()) : a ? (a.p(s, l), l & /*streaming*/
      1 && ut(a, 1)) : (a = mo(s), a.c(), ut(a, 1), a.m(e, null));
    },
    i(s) {
      r || (ut(a), r = !0);
    },
    o(s) {
      gt(a), r = !1;
    },
    d(s) {
      s && Tn(e), t[10](null), a && a.d();
    }
  };
}
function Ig(t, e, n) {
  let i, r, { streaming: a = !1 } = e, { pending: s = !1 } = e, { mode: l = "image" } = e, { mirror_webcam: o } = e, { include_audio: u } = e, { i18n: f } = e;
  const c = Cg();
  Ag(() => r = document.createElement("canvas"));
  async function h() {
    try {
      v = await navigator.mediaDevices.getUserMedia({ video: !0, audio: u }), n(3, i.srcObject = v, i), n(3, i.muted = !0, i), i.play();
    } catch (p) {
      if (p instanceof DOMException && p.name == "NotAllowedError")
        c("error", f("image.allow_webcam_access"));
      else
        throw p;
    }
  }
  function d() {
    var p = r.getContext("2d");
    if (i.videoWidth && i.videoHeight) {
      r.width = i.videoWidth, r.height = i.videoHeight, p.drawImage(i, 0, 0, i.videoWidth, i.videoHeight);
      var m = r.toDataURL("image/png");
      c(a ? "stream" : "capture", m);
    }
  }
  let _ = !1, g = [], v, k, T;
  function E() {
    if (_) {
      T.stop();
      let p = new Blob(g, { type: k }), m = new FileReader();
      m.onload = function(D) {
        D.target && (c("capture", {
          data: D.target.result,
          name: "sample." + k.substring(6),
          is_example: !1,
          is_file: !1
        }), c("stop_recording"));
      }, m.readAsDataURL(p);
    } else {
      c("start_recording"), g = [];
      let p = ["video/webm", "video/mp4"];
      for (let m of p)
        if (MediaRecorder.isTypeSupported(m)) {
          k = m;
          break;
        }
      if (k === null) {
        console.error("No supported MediaRecorder mimeType");
        return;
      }
      T = new MediaRecorder(v, { mimeType: k }), T.addEventListener("dataavailable", function(m) {
        g.push(m.data);
      }), T.start(200);
    }
    n(4, _ = !_);
  }
  h(), a && l === "image" && window.setInterval(
    () => {
      i && !s && d();
    },
    500
  );
  function S(p) {
    bg[p ? "unshift" : "push"](() => {
      i = p, n(3, i);
    });
  }
  return t.$$set = (p) => {
    "streaming" in p && n(0, a = p.streaming), "pending" in p && n(7, s = p.pending), "mode" in p && n(1, l = p.mode), "mirror_webcam" in p && n(2, o = p.mirror_webcam), "include_audio" in p && n(8, u = p.include_audio), "i18n" in p && n(9, f = p.i18n);
  }, [
    a,
    l,
    o,
    i,
    _,
    d,
    E,
    s,
    u,
    f,
    S
  ];
}
class Hg extends pg {
  constructor(e) {
    super(), wg(this, e, Ig, Ng, Sg, {
      streaming: 0,
      pending: 7,
      mode: 1,
      mirror_webcam: 2,
      include_audio: 8,
      i18n: 9
    });
  }
}
const {
  SvelteComponent: Rg,
  append: go,
  attr: Lg,
  check_outros: Pg,
  create_component: $r,
  destroy_component: ea,
  detach: Ug,
  element: Fg,
  group_outros: zg,
  init: Gg,
  insert: jg,
  mount_component: ta,
  noop: qg,
  safe_not_equal: xg,
  space: po,
  transition_in: sn,
  transition_out: Fn
} = window.__gradio__svelte__internal, { createEventDispatcher: Xg } = window.__gradio__svelte__internal;
function bo(t) {
  let e, n;
  return e = new ft({ props: { Icon: Id, label: "Clear" } }), e.$on(
    "click",
    /*click_handler_1*/
    t[3]
  ), {
    c() {
      $r(e.$$.fragment);
    },
    m(i, r) {
      ta(e, i, r), n = !0;
    },
    p: qg,
    i(i) {
      n || (sn(e.$$.fragment, i), n = !0);
    },
    o(i) {
      Fn(e.$$.fragment, i), n = !1;
    },
    d(i) {
      ea(e, i);
    }
  };
}
function Vg(t) {
  let e, n, i, r, a, s;
  n = new ft({ props: { Icon: Ol, label: "Undo" } }), n.$on(
    "click",
    /*click_handler*/
    t[2]
  );
  let l = (
    /*show_eraser*/
    t[0] && bo(t)
  );
  return a = new ft({
    props: { Icon: Dl, label: "Remove Image" }
  }), a.$on(
    "click",
    /*click_handler_2*/
    t[4]
  ), {
    c() {
      e = Fg("div"), $r(n.$$.fragment), i = po(), l && l.c(), r = po(), $r(a.$$.fragment), Lg(e, "class", "svelte-1g74h68");
    },
    m(o, u) {
      jg(o, e, u), ta(n, e, null), go(e, i), l && l.m(e, null), go(e, r), ta(a, e, null), s = !0;
    },
    p(o, [u]) {
      /*show_eraser*/
      o[0] ? l ? (l.p(o, u), u & /*show_eraser*/
      1 && sn(l, 1)) : (l = bo(o), l.c(), sn(l, 1), l.m(e, r)) : l && (zg(), Fn(l, 1, 1, () => {
        l = null;
      }), Pg());
    },
    i(o) {
      s || (sn(n.$$.fragment, o), sn(l), sn(a.$$.fragment, o), s = !0);
    },
    o(o) {
      Fn(n.$$.fragment, o), Fn(l), Fn(a.$$.fragment, o), s = !1;
    },
    d(o) {
      o && Ug(e), ea(n), l && l.d(), ea(a);
    }
  };
}
function Wg(t, e, n) {
  const i = Xg();
  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 Ca extends Rg {
  constructor(e) {
    super(), Gg(this, e, Wg, Vg, xg, { show_eraser: 0 });
  }
}
const {
  SvelteComponent: Yg,
  append: pi,
  attr: Le,
  check_outros: Zg,
  create_component: iu,
  destroy_component: ru,
  detach: Li,
  element: Vn,
  group_outros: Jg,
  init: Qg,
  insert: Pi,
  listen: na,
  mount_component: au,
  run_all: Kg,
  safe_not_equal: $g,
  set_input_value: Ci,
  space: ia,
  to_number: ep,
  transition_in: zn,
  transition_out: bi
} = window.__gradio__svelte__internal;
function vo(t) {
  let e, n, i, r, a;
  return {
    c() {
      e = Vn("input"), Le(e, "aria-label", "Brush radius"), Le(e, "type", "range"), Le(e, "min", n = 0.5 * /*img_width*/
      (t[2] / /*width*/
      t[6])), Le(e, "max", i = 75 * /*img_width*/
      (t[2] / /*width*/
      t[6])), Le(e, "class", "svelte-1hdlygn");
    },
    m(s, l) {
      Pi(s, e, l), Ci(
        e,
        /*brush_radius*/
        t[0]
      ), r || (a = [
        na(
          e,
          "change",
          /*input_change_input_handler*/
          t[10]
        ),
        na(
          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])) && Le(e, "min", n), l & /*img_width, width*/
      68 && i !== (i = 75 * /*img_width*/
      (s[2] / /*width*/
      s[6])) && Le(e, "max", i), l & /*brush_radius*/
      1 && Ci(
        e,
        /*brush_radius*/
        s[0]
      );
    },
    d(s) {
      s && Li(e), r = !1, Kg(a);
    }
  };
}
function wo(t) {
  let e, n, i, r;
  n = new ft({
    props: { Icon: td, label: "Select brush color" }
  }), n.$on(
    "click",
    /*click_handler_1*/
    t[11]
  );
  let a = (
    /*show_col*/
    t[5] && yo(t)
  );
  return {
    c() {
      e = Vn("span"), iu(n.$$.fragment), i = ia(), a && a.c(), Le(e, "class", "col svelte-1hdlygn");
    },
    m(s, l) {
      Pi(s, e, l), au(n, e, null), pi(e, i), a && a.m(e, null), r = !0;
    },
    p(s, l) {
      /*show_col*/
      s[5] ? a ? a.p(s, l) : (a = yo(s), a.c(), a.m(e, null)) : a && (a.d(1), a = null);
    },
    i(s) {
      r || (zn(n.$$.fragment, s), r = !0);
    },
    o(s) {
      bi(n.$$.fragment, s), r = !1;
    },
    d(s) {
      s && Li(e), ru(n), a && a.d();
    }
  };
}
function yo(t) {
  let e, n, i;
  return {
    c() {
      e = Vn("input"), Le(e, "aria-label", "Brush color"), Le(e, "type", "color"), Le(e, "class", "svelte-1hdlygn");
    },
    m(r, a) {
      Pi(r, e, a), Ci(
        e,
        /*brush_color*/
        t[1]
      ), n || (i = na(
        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 && Li(e), n = !1, i();
    }
  };
}
function tp(t) {
  let e, n, i, r, a, s;
  i = new ft({
    props: { Icon: Ah, label: "Use brush" }
  }), i.$on(
    "click",
    /*click_handler*/
    t[9]
  );
  let l = (
    /*show_size*/
    t[4] && vo(t)
  ), o = (
    /*mode*/
    t[3] !== "mask" && wo(t)
  );
  return {
    c() {
      e = Vn("div"), n = Vn("span"), iu(i.$$.fragment), r = ia(), l && l.c(), a = ia(), o && o.c(), Le(n, "class", "brush svelte-1hdlygn"), Le(e, "class", "wrap svelte-1hdlygn");
    },
    m(u, f) {
      Pi(u, e, f), pi(e, n), au(i, n, null), pi(n, r), l && l.m(n, null), pi(e, a), o && o.m(e, null), s = !0;
    },
    p(u, [f]) {
      /*show_size*/
      u[4] ? l ? l.p(u, f) : (l = vo(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 && zn(o, 1)) : (o = wo(u), o.c(), zn(o, 1), o.m(e, null)) : o && (Jg(), bi(o, 1, 1, () => {
        o = null;
      }), Zg());
    },
    i(u) {
      s || (zn(i.$$.fragment, u), zn(o), s = !0);
    },
    o(u) {
      bi(i.$$.fragment, u), bi(o), s = !1;
    },
    d(u) {
      u && Li(e), ru(i), l && l.d(), o && o.d();
    }
  };
}
function np(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: c = "other" } = e;
  const h = () => n(4, r = !r);
  function d() {
    s = ep(this.value), n(0, s);
  }
  const _ = () => n(5, a = !a);
  function g() {
    l = this.value, n(1, l);
  }
  return t.$$set = (v) => {
    "brush_radius" in v && n(0, s = v.brush_radius), "brush_color" in v && n(1, l = v.brush_color), "container_height" in v && n(7, o = v.container_height), "img_width" in v && n(2, u = v.img_width), "img_height" in v && n(8, f = v.img_height), "mode" in v && n(3, c = v.mode);
  }, t.$$.update = () => {
    t.$$.dirty & /*container_height, img_width, img_height*/
    388 && n(6, i = o * (u / f));
  }, [
    s,
    l,
    u,
    c,
    r,
    a,
    i,
    o,
    f,
    h,
    d,
    _,
    g
  ];
}
class Aa extends Yg {
  constructor(e) {
    super(), Qg(this, e, np, tp, $g, {
      brush_radius: 0,
      brush_color: 1,
      container_height: 7,
      img_width: 2,
      img_height: 8,
      mode: 3
    });
  }
}
const {
  SvelteComponent: ip,
  add_flush_callback: Ue,
  add_iframe_resize_listener: rp,
  add_render_callback: ap,
  attr: Y,
  bind: Fe,
  binding_callbacks: me,
  bubble: sp,
  check_outros: Bt,
  create_component: Ee,
  create_slot: op,
  destroy_component: ke,
  detach: ee,
  element: Jt,
  empty: An,
  get_all_dirty_from_scope: lp,
  get_slot_changes: up,
  group_outros: Nt,
  init: fp,
  insert: te,
  listen: Mn,
  mount_component: Se,
  noop: Ai,
  safe_not_equal: Ma,
  space: ze,
  src_url_equal: Xe,
  toggle_class: pe,
  transition_in: H,
  transition_out: x,
  update_slot_base: cp
} = window.__gradio__svelte__internal, { createEventDispatcher: hp, tick: fi, onMount: dp } = window.__gradio__svelte__internal;
function _p(t) {
  let e, n, i, r;
  return {
    c() {
      e = Jt("img"), Xe(e.src, n = /*value_*/
      t[17].image || /*value_*/
      t[17].data) || Y(e, "src", n), Y(e, "alt", ""), Y(e, "loading", "lazy"), Y(e, "class", "svelte-14sn87y"), pe(
        e,
        "webcam",
        /*source*/
        t[6] === "webcam" && /*mirror_webcam*/
        t[10]
      ), pe(
        e,
        "selectable",
        /*selectable*/
        t[12]
      );
    },
    m(a, s) {
      te(a, e, s), i || (r = Mn(
        e,
        "click",
        /*handle_click*/
        t[33]
      ), i = !0);
    },
    p(a, s) {
      s[0] & /*value_*/
      131072 && !Xe(e.src, n = /*value_*/
      a[17].image || /*value_*/
      a[17].data) && Y(e, "src", n), s[0] & /*source, mirror_webcam*/
      1088 && pe(
        e,
        "webcam",
        /*source*/
        a[6] === "webcam" && /*mirror_webcam*/
        a[10]
      ), s[0] & /*selectable*/
      4096 && pe(
        e,
        "selectable",
        /*selectable*/
        a[12]
      );
    },
    i: Ai,
    o: Ai,
    d(a) {
      a && ee(e), i = !1, r();
    }
  };
}
function mp(t) {
  let e = (
    /*static_image*/
    t[26]
  ), n, i, r, a = Eo(t), s = (
    /*img_width*/
    t[20] > 0 && ko(t)
  );
  return {
    c() {
      a.c(), n = ze(), s && s.c(), i = An();
    },
    m(l, o) {
      a.m(l, o), te(l, n, o), s && s.m(l, o), te(l, i, o), r = !0;
    },
    p(l, o) {
      o[0] & /*static_image*/
      67108864 && Ma(e, e = /*static_image*/
      l[26]) ? (a.d(1), a = Eo(l), a.c(), a.m(n.parentNode, n)) : a.p(l, o), /*img_width*/
      l[20] > 0 ? s ? (s.p(l, o), o[0] & /*img_width*/
      1048576 && H(s, 1)) : (s = ko(l), s.c(), H(s, 1), s.m(i.parentNode, i)) : s && (Nt(), x(s, 1, 1, () => {
        s = null;
      }), Bt());
    },
    i(l) {
      r || (H(s), r = !0);
    },
    o(l) {
      x(s), r = !1;
    },
    d(l) {
      l && (ee(n), ee(i)), a.d(l), s && s.d(l);
    }
  };
}
function gp(t) {
  let e, n, i, r, a, s, l;
  return e = new Ii({
    props: { i18n: (
      /*i18n*/
      t[14]
    ), editable: !0 }
  }), e.$on(
    "edit",
    /*edit_handler_1*/
    t[56]
  ), e.$on(
    "clear",
    /*handle_clear*/
    t[28]
  ), {
    c() {
      Ee(e.$$.fragment), n = ze(), i = Jt("img"), Xe(i.src, r = /*value_*/
      t[17]) || Y(i, "src", r), Y(i, "alt", ""), Y(i, "loading", "lazy"), Y(i, "class", "svelte-14sn87y"), pe(
        i,
        "selectable",
        /*selectable*/
        t[12]
      ), pe(
        i,
        "webcam",
        /*source*/
        t[6] === "webcam" && /*mirror_webcam*/
        t[10]
      );
    },
    m(o, u) {
      Se(e, o, u), te(o, n, u), te(o, i, u), a = !0, s || (l = Mn(
        i,
        "click",
        /*handle_click*/
        t[33]
      ), s = !0);
    },
    p(o, u) {
      const f = {};
      u[0] & /*i18n*/
      16384 && (f.i18n = /*i18n*/
      o[14]), e.$set(f), (!a || u[0] & /*value_*/
      131072 && !Xe(i.src, r = /*value_*/
      o[17])) && Y(i, "src", r), (!a || u[0] & /*selectable*/
      4096) && pe(
        i,
        "selectable",
        /*selectable*/
        o[12]
      ), (!a || u[0] & /*source, mirror_webcam*/
      1088) && pe(
        i,
        "webcam",
        /*source*/
        o[6] === "webcam" && /*mirror_webcam*/
        o[10]
      );
    },
    i(o) {
      a || (H(e.$$.fragment, o), a = !0);
    },
    o(o) {
      x(e.$$.fragment, o), a = !1;
    },
    d(o) {
      o && (ee(n), ee(i)), ke(e, o), s = !1, l();
    }
  };
}
function pp(t) {
  let e, n, i, r, a = { image: (
    /*value*/
    t[0].data
  ) };
  return e = new Jl({ props: a }), t[54](e), e.$on(
    "crop",
    /*handle_save*/
    t[29]
  ), i = new Ii({ props: { i18n: (
    /*i18n*/
    t[14]
  ) } }), i.$on(
    "clear",
    /*clear_handler_1*/
    t[55]
  ), {
    c() {
      Ee(e.$$.fragment), n = ze(), Ee(i.$$.fragment);
    },
    m(s, l) {
      Se(e, s, l), te(s, n, l), Se(i, s, l), r = !0;
    },
    p(s, l) {
      const o = {};
      l[0] & /*value*/
      1 && (o.image = /*value*/
      s[0].data), 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) {
      x(e.$$.fragment, s), x(i.$$.fragment, s), r = !1;
    },
    d(s) {
      s && ee(n), t[54](null), ke(e, s), ke(i, s);
    }
  };
}
function bp(t) {
  let e, n, i = (
    /*source*/
    t[6] === "webcam" && !/*static_image*/
    t[26] && To(t)
  );
  return {
    c() {
      i && i.c(), e = An();
    },
    m(r, a) {
      i && i.m(r, a), te(r, e, a), n = !0;
    },
    p(r, a) {
      /*source*/
      r[6] === "webcam" && !/*static_image*/
      r[26] ? i ? (i.p(r, a), a[0] & /*source, static_image*/
      67108928 && H(i, 1)) : (i = To(r), i.c(), H(i, 1), i.m(e.parentNode, e)) : i && (Nt(), x(i, 1, 1, () => {
        i = null;
      }), Bt());
    },
    i(r) {
      n || (H(i), n = !0);
    },
    o(r) {
      x(i), n = !1;
    },
    d(r) {
      r && ee(e), i && i.d(r);
    }
  };
}
function vp(t) {
  let e, n, i, r, a, s, l;
  e = new Ca({}), e.$on(
    "undo",
    /*undo_handler_1*/
    t[46]
  ), e.$on(
    "remove_image",
    /*handle_sketch_clear*/
    t[31]
  );
  let o = (
    /*tool*/
    t[1] === "color-sketch" && Co(t)
  );
  function u(h) {
    t[49](h);
  }
  function f(h) {
    t[50](h);
  }
  let c = {
    value: (
      /*value*/
      t[0]
    ),
    mode: (
      /*mode*/
      t[22]
    ),
    width: (
      /*img_width*/
      t[20] || /*max_width*/
      t[25]
    ),
    height: (
      /*img_height*/
      t[19] || /*max_height*/
      t[24]
    ),
    container_height: (
      /*container_height*/
      t[21] || /*max_height*/
      t[24]
    ),
    shape: (
      /*shape*/
      t[7]
    )
  };
  return (
    /*brush_radius*/
    t[2] !== void 0 && (c.brush_radius = /*brush_radius*/
    t[2]), /*brush_color*/
    t[3] !== void 0 && (c.brush_color = /*brush_color*/
    t[3]), r = new wa({ props: c }), me.push(() => Fe(r, "brush_radius", u)), me.push(() => Fe(r, "brush_color", f)), t[51](r), r.$on(
      "change",
      /*handle_save*/
      t[29]
    ), r.$on(
      "clear",
      /*handle_sketch_clear*/
      t[31]
    ), {
      c() {
        Ee(e.$$.fragment), n = ze(), o && o.c(), i = ze(), Ee(r.$$.fragment);
      },
      m(h, d) {
        Se(e, h, d), te(h, n, d), o && o.m(h, d), te(h, i, d), Se(r, h, d), l = !0;
      },
      p(h, d) {
        /*tool*/
        h[1] === "color-sketch" ? o ? (o.p(h, d), d[0] & /*tool*/
        2 && H(o, 1)) : (o = Co(h), o.c(), H(o, 1), o.m(i.parentNode, i)) : o && (Nt(), x(o, 1, 1, () => {
          o = null;
        }), Bt());
        const _ = {};
        d[0] & /*value*/
        1 && (_.value = /*value*/
        h[0]), d[0] & /*mode*/
        4194304 && (_.mode = /*mode*/
        h[22]), d[0] & /*img_width, max_width*/
        34603008 && (_.width = /*img_width*/
        h[20] || /*max_width*/
        h[25]), d[0] & /*img_height, max_height*/
        17301504 && (_.height = /*img_height*/
        h[19] || /*max_height*/
        h[24]), d[0] & /*container_height, max_height*/
        18874368 && (_.container_height = /*container_height*/
        h[21] || /*max_height*/
        h[24]), d[0] & /*shape*/
        128 && (_.shape = /*shape*/
        h[7]), !a && d[0] & /*brush_radius*/
        4 && (a = !0, _.brush_radius = /*brush_radius*/
        h[2], Ue(() => a = !1)), !s && d[0] & /*brush_color*/
        8 && (s = !0, _.brush_color = /*brush_color*/
        h[3], Ue(() => s = !1)), r.$set(_);
      },
      i(h) {
        l || (H(e.$$.fragment, h), H(o), H(r.$$.fragment, h), l = !0);
      },
      o(h) {
        x(e.$$.fragment, h), x(o), x(r.$$.fragment, h), l = !1;
      },
      d(h) {
        h && (ee(n), ee(i)), ke(e, h), o && o.d(h), t[51](null), ke(r, h);
      }
    }
  );
}
function wp(t) {
  let e, n, i;
  function r(s) {
    t[45](s);
  }
  let a = {
    filetype: "image/*",
    include_file_metadata: !1,
    disable_click: !!/*value*/
    t[0],
    root: (
      /*root*/
      t[13]
    ),
    $$slots: { default: [Cp] },
    $$scope: { ctx: t }
  };
  return (
    /*dragging*/
    t[16] !== void 0 && (a.dragging = /*dragging*/
    t[16]), e = new u_({ props: a }), me.push(() => Fe(e, "dragging", r)), e.$on(
      "load",
      /*handle_upload*/
      t[27]
    ), {
      c() {
        Ee(e.$$.fragment);
      },
      m(s, l) {
        Se(e, s, l), i = !0;
      },
      p(s, l) {
        const o = {};
        l[0] & /*value*/
        1 && (o.disable_click = !!/*value*/
        s[0]), l[0] & /*root*/
        8192 && (o.root = /*root*/
        s[13]), l[0] & /*value, static_image, streaming, i18n, tool, value_, 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*/
        134143439 | l[2] & /*$$scope*/
        8 && (o.$$scope = { dirty: l, ctx: s }), !n && l[0] & /*dragging*/
        65536 && (n = !0, o.dragging = /*dragging*/
        s[16], Ue(() => n = !1)), e.$set(o);
      },
      i(s) {
        i || (H(e.$$.fragment, s), i = !0);
      },
      o(s) {
        x(e.$$.fragment, s), i = !1;
      },
      d(s) {
        ke(e, s);
      }
    }
  );
}
function Eo(t) {
  let e, n, i, r;
  return {
    c() {
      e = Jt("img"), Y(e, "class", "absolute-img svelte-14sn87y"), Xe(e.src, n = /*static_image*/
      t[26] || /*value_*/
      t[17]) || Y(e, "src", n), Y(e, "alt", ""), Y(e, "loading", "lazy"), pe(
        e,
        "webcam",
        /*source*/
        t[6] === "webcam" && /*mirror_webcam*/
        t[10]
      );
    },
    m(a, s) {
      te(a, e, s), t[57](e), i || (r = Mn(
        e,
        "load",
        /*handle_image_load*/
        t[30]
      ), i = !0);
    },
    p(a, s) {
      s[0] & /*static_image, value_*/
      67239936 && !Xe(e.src, n = /*static_image*/
      a[26] || /*value_*/
      a[17]) && Y(e, "src", n), s[0] & /*source, mirror_webcam*/
      1088 && pe(
        e,
        "webcam",
        /*source*/
        a[6] === "webcam" && /*mirror_webcam*/
        a[10]
      );
    },
    d(a) {
      a && ee(e), t[57](null), i = !1, r();
    }
  };
}
function ko(t) {
  let e, n, i, r, a, s, l, o;
  function u(d) {
    t[59](d);
  }
  function f(d) {
    t[60](d);
  }
  let c = {
    value: (
      /*value*/
      t[0]
    ),
    mode: (
      /*mode*/
      t[22]
    ),
    width: (
      /*img_width*/
      t[20] || /*max_width*/
      t[25]
    ),
    height: (
      /*img_height*/
      t[19] || /*max_height*/
      t[24]
    ),
    container_height: (
      /*container_height*/
      t[21] || /*max_height*/
      t[24]
    ),
    value_img: (
      /*value_img*/
      t[23]
    ),
    source: (
      /*source*/
      t[6]
    )
  };
  /*brush_radius*/
  t[2] !== void 0 && (c.brush_radius = /*brush_radius*/
  t[2]), /*brush_color*/
  t[3] !== void 0 && (c.brush_color = /*brush_color*/
  t[3]), e = new wa({ props: c }), t[58](e), me.push(() => Fe(e, "brush_radius", u)), me.push(() => Fe(e, "brush_color", f)), e.$on(
    "change",
    /*handle_save*/
    t[29]
  ), a = new Ca({}), a.$on(
    "undo",
    /*undo_handler_2*/
    t[61]
  ), a.$on(
    "remove_image",
    /*handle_sketch_clear*/
    t[31]
  );
  let h = (
    /*tool*/
    (t[1] === "color-sketch" || /*tool*/
    t[1] === "sketch") && So(t)
  );
  return {
    c() {
      Ee(e.$$.fragment), r = ze(), Ee(a.$$.fragment), s = ze(), h && h.c(), l = An();
    },
    m(d, _) {
      Se(e, d, _), te(d, r, _), Se(a, d, _), te(d, s, _), h && h.m(d, _), te(d, l, _), o = !0;
    },
    p(d, _) {
      const g = {};
      _[0] & /*value*/
      1 && (g.value = /*value*/
      d[0]), _[0] & /*mode*/
      4194304 && (g.mode = /*mode*/
      d[22]), _[0] & /*img_width, max_width*/
      34603008 && (g.width = /*img_width*/
      d[20] || /*max_width*/
      d[25]), _[0] & /*img_height, max_height*/
      17301504 && (g.height = /*img_height*/
      d[19] || /*max_height*/
      d[24]), _[0] & /*container_height, max_height*/
      18874368 && (g.container_height = /*container_height*/
      d[21] || /*max_height*/
      d[24]), _[0] & /*value_img*/
      8388608 && (g.value_img = /*value_img*/
      d[23]), _[0] & /*source*/
      64 && (g.source = /*source*/
      d[6]), !n && _[0] & /*brush_radius*/
      4 && (n = !0, g.brush_radius = /*brush_radius*/
      d[2], Ue(() => n = !1)), !i && _[0] & /*brush_color*/
      8 && (i = !0, g.brush_color = /*brush_color*/
      d[3], Ue(() => i = !1)), e.$set(g), /*tool*/
      d[1] === "color-sketch" || /*tool*/
      d[1] === "sketch" ? h ? (h.p(d, _), _[0] & /*tool*/
      2 && H(h, 1)) : (h = So(d), h.c(), H(h, 1), h.m(l.parentNode, l)) : h && (Nt(), x(h, 1, 1, () => {
        h = null;
      }), Bt());
    },
    i(d) {
      o || (H(e.$$.fragment, d), H(a.$$.fragment, d), H(h), o = !0);
    },
    o(d) {
      x(e.$$.fragment, d), x(a.$$.fragment, d), x(h), o = !1;
    },
    d(d) {
      d && (ee(r), ee(s), ee(l)), t[58](null), ke(e, d), ke(a, d), h && h.d(d);
    }
  };
}
function So(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[21] || /*max_height*/
      t[24]
    ),
    img_width: (
      /*img_width*/
      t[20] || /*max_width*/
      t[25]
    ),
    img_height: (
      /*img_height*/
      t[19] || /*max_height*/
      t[24]
    ),
    mode: (
      /*mode*/
      t[22]
    )
  };
  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 Aa({ props: l }), me.push(() => Fe(e, "brush_radius", a)), me.push(() => Fe(e, "brush_color", s)), {
      c() {
        Ee(e.$$.fragment);
      },
      m(o, u) {
        Se(e, o, u), r = !0;
      },
      p(o, u) {
        const f = {};
        u[0] & /*container_height, max_height*/
        18874368 && (f.container_height = /*container_height*/
        o[21] || /*max_height*/
        o[24]), u[0] & /*img_width, max_width*/
        34603008 && (f.img_width = /*img_width*/
        o[20] || /*max_width*/
        o[25]), u[0] & /*img_height, max_height*/
        17301504 && (f.img_height = /*img_height*/
        o[19] || /*max_height*/
        o[24]), u[0] & /*mode*/
        4194304 && (f.mode = /*mode*/
        o[22]), !n && u[0] & /*brush_radius*/
        4 && (n = !0, f.brush_radius = /*brush_radius*/
        o[2], Ue(() => n = !1)), !i && u[0] & /*brush_color*/
        8 && (i = !0, f.brush_color = /*brush_color*/
        o[3], Ue(() => i = !1)), e.$set(f);
      },
      i(o) {
        r || (H(e.$$.fragment, o), r = !0);
      },
      o(o) {
        x(e.$$.fragment, o), r = !1;
      },
      d(o) {
        ke(e, o);
      }
    }
  );
}
function To(t) {
  let e, n;
  return e = new Hg({
    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[29]
  ), e.$on(
    "error",
    /*error_handler*/
    t[53]
  ), {
    c() {
      Ee(e.$$.fragment);
    },
    m(i, r) {
      Se(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) {
      x(e.$$.fragment, i), n = !1;
    },
    d(i) {
      ke(e, i);
    }
  };
}
function Co(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[21] || /*max_height*/
      t[24]
    ),
    img_width: (
      /*img_width*/
      t[20] || /*max_width*/
      t[25]
    ),
    img_height: (
      /*img_height*/
      t[19] || /*max_height*/
      t[24]
    )
  };
  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 Aa({ props: l }), me.push(() => Fe(e, "brush_radius", a)), me.push(() => Fe(e, "brush_color", s)), {
      c() {
        Ee(e.$$.fragment);
      },
      m(o, u) {
        Se(e, o, u), r = !0;
      },
      p(o, u) {
        const f = {};
        u[0] & /*container_height, max_height*/
        18874368 && (f.container_height = /*container_height*/
        o[21] || /*max_height*/
        o[24]), u[0] & /*img_width, max_width*/
        34603008 && (f.img_width = /*img_width*/
        o[20] || /*max_width*/
        o[25]), u[0] & /*img_height, max_height*/
        17301504 && (f.img_height = /*img_height*/
        o[19] || /*max_height*/
        o[24]), !n && u[0] & /*brush_radius*/
        4 && (n = !0, f.brush_radius = /*brush_radius*/
        o[2], Ue(() => n = !1)), !i && u[0] & /*brush_color*/
        8 && (i = !0, f.brush_color = /*brush_color*/
        o[3], Ue(() => i = !1)), e.$set(f);
      },
      i(o) {
        r || (H(e.$$.fragment, o), r = !0);
      },
      o(o) {
        x(e.$$.fragment, o), r = !1;
      },
      d(o) {
        ke(e, o);
      }
    }
  );
}
function yp(t) {
  let e, n, i, r;
  return {
    c() {
      e = Jt("img"), Xe(e.src, n = /*value*/
      t[0].image || /*value*/
      t[0]) || Y(e, "src", n), Y(e, "alt", ""), Y(e, "loading", "lazy"), Y(e, "class", "svelte-14sn87y"), pe(
        e,
        "webcam",
        /*source*/
        t[6] === "webcam" && /*mirror_webcam*/
        t[10]
      ), pe(
        e,
        "selectable",
        /*selectable*/
        t[12]
      );
    },
    m(a, s) {
      te(a, e, s), i || (r = Mn(
        e,
        "click",
        /*handle_click*/
        t[33]
      ), i = !0);
    },
    p(a, s) {
      s[0] & /*value*/
      1 && !Xe(e.src, n = /*value*/
      a[0].image || /*value*/
      a[0]) && Y(e, "src", n), s[0] & /*source, mirror_webcam*/
      1088 && pe(
        e,
        "webcam",
        /*source*/
        a[6] === "webcam" && /*mirror_webcam*/
        a[10]
      ), s[0] & /*selectable*/
      4096 && pe(
        e,
        "selectable",
        /*selectable*/
        a[12]
      );
    },
    i: Ai,
    o: Ai,
    d(a) {
      a && ee(e), i = !1, r();
    }
  };
}
function Ep(t) {
  let e = (
    /*static_image*/
    t[26]
  ), n, i, r, a = Ao(t), s = (
    /*img_width*/
    t[20] > 0 && Mo(t)
  );
  return {
    c() {
      a.c(), n = ze(), s && s.c(), i = An();
    },
    m(l, o) {
      a.m(l, o), te(l, n, o), s && s.m(l, o), te(l, i, o), r = !0;
    },
    p(l, o) {
      o[0] & /*static_image*/
      67108864 && Ma(e, e = /*static_image*/
      l[26]) ? (a.d(1), a = Ao(l), a.c(), a.m(n.parentNode, n)) : a.p(l, o), /*img_width*/
      l[20] > 0 ? s ? (s.p(l, o), o[0] & /*img_width*/
      1048576 && H(s, 1)) : (s = Mo(l), s.c(), H(s, 1), s.m(i.parentNode, i)) : s && (Nt(), x(s, 1, 1, () => {
        s = null;
      }), Bt());
    },
    i(l) {
      r || (H(s), r = !0);
    },
    o(l) {
      x(s), r = !1;
    },
    d(l) {
      l && (ee(n), ee(i)), a.d(l), s && s.d(l);
    }
  };
}
function kp(t) {
  let e, n, i, r, a, s, l;
  return e = new Ii({
    props: { i18n: (
      /*i18n*/
      t[14]
    ), editable: !0 }
  }), e.$on(
    "edit",
    /*edit_handler*/
    t[37]
  ), e.$on(
    "clear",
    /*handle_clear*/
    t[28]
  ), {
    c() {
      Ee(e.$$.fragment), n = ze(), i = Jt("img"), Xe(i.src, r = /*value_*/
      t[17].data) || Y(i, "src", r), Y(i, "alt", ""), Y(i, "loading", "lazy"), Y(i, "class", "svelte-14sn87y"), pe(
        i,
        "scale-x-[-1]",
        /*source*/
        t[6] === "webcam" && /*mirror_webcam*/
        t[10]
      ), pe(
        i,
        "selectable",
        /*selectable*/
        t[12]
      );
    },
    m(o, u) {
      Se(e, o, u), te(o, n, u), te(o, i, u), a = !0, s || (l = Mn(
        i,
        "click",
        /*handle_click*/
        t[33]
      ), s = !0);
    },
    p(o, u) {
      const f = {};
      u[0] & /*i18n*/
      16384 && (f.i18n = /*i18n*/
      o[14]), e.$set(f), (!a || u[0] & /*value_*/
      131072 && !Xe(i.src, r = /*value_*/
      o[17].data)) && Y(i, "src", r), (!a || u[0] & /*source, mirror_webcam*/
      1088) && pe(
        i,
        "scale-x-[-1]",
        /*source*/
        o[6] === "webcam" && /*mirror_webcam*/
        o[10]
      ), (!a || u[0] & /*selectable*/
      4096) && pe(
        i,
        "selectable",
        /*selectable*/
        o[12]
      );
    },
    i(o) {
      a || (H(e.$$.fragment, o), a = !0);
    },
    o(o) {
      x(e.$$.fragment, o), a = !1;
    },
    d(o) {
      o && (ee(n), ee(i)), ke(e, o), s = !1, l();
    }
  };
}
function Sp(t) {
  let e, n, i, r, a = { image: (
    /*value_*/
    t[17].data
  ) };
  return e = new Jl({ props: a }), t[35](e), e.$on(
    "crop",
    /*handle_save*/
    t[29]
  ), i = new Ii({ props: { i18n: (
    /*i18n*/
    t[14]
  ) } }), i.$on(
    "clear",
    /*clear_handler*/
    t[36]
  ), {
    c() {
      Ee(e.$$.fragment), n = ze(), Ee(i.$$.fragment);
    },
    m(s, l) {
      Se(e, s, l), te(s, n, l), Se(i, s, l), r = !0;
    },
    p(s, l) {
      const o = {};
      l[0] & /*value_*/
      131072 && (o.image = /*value_*/
      s[17].data), 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) {
      x(e.$$.fragment, s), x(i.$$.fragment, s), r = !1;
    },
    d(s) {
      s && ee(n), t[35](null), ke(e, s), ke(i, s);
    }
  };
}
function Tp(t) {
  let e;
  const n = (
    /*#slots*/
    t[34].default
  ), i = op(
    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) && cp(
        i,
        n,
        r,
        /*$$scope*/
        r[65],
        e ? up(
          n,
          /*$$scope*/
          r[65],
          a,
          null
        ) : lp(
          /*$$scope*/
          r[65]
        ),
        null
      );
    },
    i(r) {
      e || (H(i, r), e = !0);
    },
    o(r) {
      x(i, r), e = !1;
    },
    d(r) {
      i && i.d(r);
    }
  };
}
function Ao(t) {
  let e, n, i, r;
  return {
    c() {
      var a, s, l;
      e = Jt("img"), Y(e, "class", "absolute-img svelte-14sn87y"), Xe(e.src, n = /*static_image*/
      t[26] || /*value*/
      ((s = (a = t[0]) == null ? void 0 : a.image) == null ? void 0 : s.data) || /*value*/
      ((l = t[0]) == null ? void 0 : l.data)) || Y(e, "src", n), Y(e, "alt", ""), Y(e, "loading", "lazy"), Y(e, "crossorigin", "anonymous"), pe(
        e,
        "webcam",
        /*source*/
        t[6] === "webcam" && /*mirror_webcam*/
        t[10]
      );
    },
    m(a, s) {
      te(a, e, s), t[38](e), i || (r = Mn(
        e,
        "load",
        /*handle_image_load*/
        t[30]
      ), i = !0);
    },
    p(a, s) {
      var l, o, u;
      s[0] & /*static_image, value*/
      67108865 && !Xe(e.src, n = /*static_image*/
      a[26] || /*value*/
      ((o = (l = a[0]) == null ? void 0 : l.image) == null ? void 0 : o.data) || /*value*/
      ((u = a[0]) == null ? void 0 : u.data)) && Y(e, "src", n), s[0] & /*source, mirror_webcam*/
      1088 && pe(
        e,
        "webcam",
        /*source*/
        a[6] === "webcam" && /*mirror_webcam*/
        a[10]
      );
    },
    d(a) {
      a && ee(e), t[38](null), i = !1, r();
    }
  };
}
function Mo(t) {
  let e, n, i, r, a, s, l, o;
  function u(d) {
    t[40](d);
  }
  function f(d) {
    t[41](d);
  }
  let c = {
    value: (
      /*value*/
      t[0]
    ),
    mask_opacity: (
      /*mask_opacity*/
      t[11]
    ),
    mode: (
      /*mode*/
      t[22]
    ),
    width: (
      /*img_width*/
      t[20] || /*max_width*/
      t[25]
    ),
    height: (
      /*img_height*/
      t[19] || /*max_height*/
      t[24]
    ),
    container_height: (
      /*container_height*/
      t[21] || /*max_height*/
      t[24]
    ),
    value_img: (
      /*value_img*/
      t[23]
    ),
    source: (
      /*source*/
      t[6]
    ),
    shape: (
      /*shape*/
      t[7]
    )
  };
  /*brush_radius*/
  t[2] !== void 0 && (c.brush_radius = /*brush_radius*/
  t[2]), /*brush_color*/
  t[3] !== void 0 && (c.brush_color = /*brush_color*/
  t[3]), e = new wa({ props: c }), t[39](e), me.push(() => Fe(e, "brush_radius", u)), me.push(() => Fe(e, "brush_color", f)), e.$on(
    "change",
    /*handle_save*/
    t[29]
  ), a = new Ca({
    props: { show_eraser: (
      /*value_img*/
      t[23]
    ) }
  }), a.$on(
    "undo",
    /*undo_handler*/
    t[42]
  ), a.$on(
    "clear_mask",
    /*handle_mask_clear*/
    t[32]
  ), a.$on(
    "remove_image",
    /*handle_sketch_clear*/
    t[31]
  );
  let h = (
    /*tool*/
    (t[1] === "color-sketch" || /*tool*/
    t[1] === "sketch") && Do(t)
  );
  return {
    c() {
      Ee(e.$$.fragment), r = ze(), Ee(a.$$.fragment), s = ze(), h && h.c(), l = An();
    },
    m(d, _) {
      Se(e, d, _), te(d, r, _), Se(a, d, _), te(d, s, _), h && h.m(d, _), te(d, l, _), o = !0;
    },
    p(d, _) {
      const g = {};
      _[0] & /*value*/
      1 && (g.value = /*value*/
      d[0]), _[0] & /*mask_opacity*/
      2048 && (g.mask_opacity = /*mask_opacity*/
      d[11]), _[0] & /*mode*/
      4194304 && (g.mode = /*mode*/
      d[22]), _[0] & /*img_width, max_width*/
      34603008 && (g.width = /*img_width*/
      d[20] || /*max_width*/
      d[25]), _[0] & /*img_height, max_height*/
      17301504 && (g.height = /*img_height*/
      d[19] || /*max_height*/
      d[24]), _[0] & /*container_height, max_height*/
      18874368 && (g.container_height = /*container_height*/
      d[21] || /*max_height*/
      d[24]), _[0] & /*value_img*/
      8388608 && (g.value_img = /*value_img*/
      d[23]), _[0] & /*source*/
      64 && (g.source = /*source*/
      d[6]), _[0] & /*shape*/
      128 && (g.shape = /*shape*/
      d[7]), !n && _[0] & /*brush_radius*/
      4 && (n = !0, g.brush_radius = /*brush_radius*/
      d[2], Ue(() => n = !1)), !i && _[0] & /*brush_color*/
      8 && (i = !0, g.brush_color = /*brush_color*/
      d[3], Ue(() => i = !1)), e.$set(g);
      const v = {};
      _[0] & /*value_img*/
      8388608 && (v.show_eraser = /*value_img*/
      d[23]), a.$set(v), /*tool*/
      d[1] === "color-sketch" || /*tool*/
      d[1] === "sketch" ? h ? (h.p(d, _), _[0] & /*tool*/
      2 && H(h, 1)) : (h = Do(d), h.c(), H(h, 1), h.m(l.parentNode, l)) : h && (Nt(), x(h, 1, 1, () => {
        h = null;
      }), Bt());
    },
    i(d) {
      o || (H(e.$$.fragment, d), H(a.$$.fragment, d), H(h), o = !0);
    },
    o(d) {
      x(e.$$.fragment, d), x(a.$$.fragment, d), x(h), o = !1;
    },
    d(d) {
      d && (ee(r), ee(s), ee(l)), t[39](null), ke(e, d), ke(a, d), h && h.d(d);
    }
  };
}
function Do(t) {
  let e, n, i, r;
  function a(o) {
    t[43](o);
  }
  function s(o) {
    t[44](o);
  }
  let l = {
    container_height: (
      /*container_height*/
      t[21] || /*max_height*/
      t[24]
    ),
    img_width: (
      /*img_width*/
      t[20] || /*max_width*/
      t[25]
    ),
    img_height: (
      /*img_height*/
      t[19] || /*max_height*/
      t[24]
    ),
    mode: (
      /*mode*/
      t[22]
    )
  };
  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 Aa({ props: l }), me.push(() => Fe(e, "brush_radius", a)), me.push(() => Fe(e, "brush_color", s)), {
      c() {
        Ee(e.$$.fragment);
      },
      m(o, u) {
        Se(e, o, u), r = !0;
      },
      p(o, u) {
        const f = {};
        u[0] & /*container_height, max_height*/
        18874368 && (f.container_height = /*container_height*/
        o[21] || /*max_height*/
        o[24]), u[0] & /*img_width, max_width*/
        34603008 && (f.img_width = /*img_width*/
        o[20] || /*max_width*/
        o[25]), u[0] & /*img_height, max_height*/
        17301504 && (f.img_height = /*img_height*/
        o[19] || /*max_height*/
        o[24]), u[0] & /*mode*/
        4194304 && (f.mode = /*mode*/
        o[22]), !n && u[0] & /*brush_radius*/
        4 && (n = !0, f.brush_radius = /*brush_radius*/
        o[2], Ue(() => n = !1)), !i && u[0] & /*brush_color*/
        8 && (i = !0, f.brush_color = /*brush_color*/
        o[3], Ue(() => i = !1)), e.$set(f);
      },
      i(o) {
        r || (H(e.$$.fragment, o), r = !0);
      },
      o(o) {
        x(e.$$.fragment, o), r = !1;
      },
      d(o) {
        ke(e, o);
      }
    }
  );
}
function Cp(t) {
  let e, n, i, r;
  const a = [
    Tp,
    Sp,
    kp,
    Ep,
    yp
  ], s = [];
  function l(o, u) {
    return (
      /*value*/
      o[0] === null && !/*static_image*/
      o[26] || /*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[26]) ? 3 : 4
          )
        )
      )
    );
  }
  return e = l(t), n = s[e] = a[e](t), {
    c() {
      n.c(), i = An();
    },
    m(o, u) {
      s[e].m(o, u), te(o, i, u), r = !0;
    },
    p(o, u) {
      let f = e;
      e = l(o), e === f ? s[e].p(o, u) : (Nt(), x(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) {
      x(n), r = !1;
    },
    d(o) {
      o && ee(i), s[e].d(o);
    }
  };
}
function Ap(t) {
  let e, n, i, r, a, s, l;
  e = new Cl({
    props: {
      show_label: (
        /*show_label*/
        t[5]
      ),
      Icon: (
        /*source*/
        t[6] === "canvas" ? ls : yi
      ),
      label: (
        /*label*/
        t[4] || /*source*/
        (t[6] === "canvas" ? "Sketch" : "Image")
      )
    }
  });
  const o = [
    wp,
    vp,
    bp,
    pp,
    gp,
    mp,
    _p
  ], u = [];
  function f(c, h) {
    return (
      /*source*/
      c[6] === "upload" ? 0 : (
        /*source*/
        c[6] === "canvas" ? 1 : (
          /*value*/
          c[0] === null && !/*static_image*/
          c[26] || /*streaming*/
          c[8] ? 2 : (
            /*tool*/
            c[1] === "select" ? 3 : (
              /*tool*/
              c[1] === "editor" ? 4 : (
                /*tool*/
                (c[1] === "sketch" || /*tool*/
                c[1] === "color-sketch") && /*value*/
                (c[0] !== null || /*static_image*/
                c[26]) ? 5 : 6
              )
            )
          )
        )
      )
    );
  }
  return r = f(t), a = u[r] = o[r](t), {
    c() {
      Ee(e.$$.fragment), n = ze(), i = Jt("div"), a.c(), Y(i, "data-testid", "image"), Y(i, "class", "image-container svelte-14sn87y"), ap(() => (
        /*div_elementresize_handler*/
        t[64].call(i)
      ));
    },
    m(c, h) {
      Se(e, c, h), te(c, n, h), te(c, i, h), u[r].m(i, null), s = rp(
        i,
        /*div_elementresize_handler*/
        t[64].bind(i)
      ), l = !0;
    },
    p(c, h) {
      const d = {};
      h[0] & /*show_label*/
      32 && (d.show_label = /*show_label*/
      c[5]), h[0] & /*source*/
      64 && (d.Icon = /*source*/
      c[6] === "canvas" ? ls : yi), h[0] & /*label, source*/
      80 && (d.label = /*label*/
      c[4] || /*source*/
      (c[6] === "canvas" ? "Sketch" : "Image")), e.$set(d);
      let _ = r;
      r = f(c), r === _ ? u[r].p(c, h) : (Nt(), x(u[_], 1, 1, () => {
        u[_] = null;
      }), Bt(), a = u[r], a ? a.p(c, h) : (a = u[r] = o[r](c), a.c()), H(a, 1), a.m(i, null));
    },
    i(c) {
      l || (H(e.$$.fragment, c), H(a), l = !0);
    },
    o(c) {
      x(e.$$.fragment, c), x(a), l = !1;
    },
    d(c) {
      c && (ee(n), ee(i)), ke(e, c), u[r].d(), s();
    }
  };
}
function Oo(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 Mp(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: c = !1 } = e, { pending: h = !1 } = e, { mirror_webcam: d } = e, { brush_radius: _ } = e, { brush_color: g = "#000000" } = e, { mask_opacity: v } = e, { selectable: k = !1 } = e, { root: T } = e, { i18n: E } = e, S, p;
  a && (o === "upload" || o === "webcam") && u === "sketch" && (a = { image: a, mask: null });
  function m({ detail: y }) {
    u === "color-sketch" ? n(26, K = Oo([
      Ct,
      "call",
      (De) => De(y, T, null),
      "optionalAccess",
      (De) => De.data
    ])) : n(0, a = (o === "upload" || o === "webcam") && u === "sketch" ? {
      image: Ct(y, T, null),
      mask: null
    } : Ct(y, T, null)), z("upload", Ct(y, T, null));
  }
  function D({ detail: y }) {
    n(0, a = null), n(26, K = void 0), z("clear");
  }
  async function N({ detail: y }, De) {
    G === "mask" ? o === "webcam" && De ? n(0, a = { image: y, mask: null }) : n(0, a = {
      image: typeof a == "string" ? a : Oo([a, "optionalAccess", (ti) => ti.image]) || null,
      mask: y
    }) : (o === "upload" || o === "webcam") && u === "sketch" ? n(0, a = { image: y, mask: null }) : n(0, a = y), await fi(), z(c ? "stream" : "edit");
  }
  const z = hp();
  let X = !1, Q = null;
  function ne(y) {
    const De = y.currentTarget;
    n(20, P = De.naturalWidth), n(19, O = De.naturalHeight), n(21, A = De.getBoundingClientRect().height);
  }
  async function B() {
    z("clear"), S.clear(), await fi(), n(0, a = null), n(26, K = void 0);
  }
  async function b() {
    S.clear_mask(), await fi();
  }
  let O = 0, P = 0, A = 0, G, U, F, ce, K;
  dp(async () => {
    u === "color-sketch" && a && typeof a == "string" && (n(26, K = a), await fi(), ne({ currentTarget: U }));
  });
  function M(y) {
    let De = Bl(y);
    De && z("select", { index: De, value: null });
  }
  function he(y) {
    me[y ? "unshift" : "push"](() => {
      p = y, n(15, p), n(0, a);
    });
  }
  const de = (y) => (D(y), n(1, u = "editor")), tt = () => n(1, u = "select");
  function C(y) {
    me[y ? "unshift" : "push"](() => {
      U = y, n(23, U);
    });
  }
  function vt(y) {
    me[y ? "unshift" : "push"](() => {
      S = y, n(18, S);
    });
  }
  function wt(y) {
    _ = y, n(2, _);
  }
  function ue(y) {
    g = y, n(3, g);
  }
  const re = () => S.undo();
  function be(y) {
    _ = y, n(2, _);
  }
  function ve(y) {
    g = y, n(3, g);
  }
  function Ie(y) {
    X = y, n(16, X);
  }
  const Ae = () => S.undo();
  function nt(y) {
    _ = y, n(2, _);
  }
  function ht(y) {
    g = y, n(3, g);
  }
  function It(y) {
    _ = y, n(2, _);
  }
  function $n(y) {
    g = y, n(3, g);
  }
  function On(y) {
    me[y ? "unshift" : "push"](() => {
      S = y, n(18, S);
    });
  }
  const Ui = (y) => u === "color-sketch" ? m(y) : N(y, !0);
  function ei(y) {
    sp.call(this, t, y);
  }
  function Fi(y) {
    me[y ? "unshift" : "push"](() => {
      p = y, n(15, p), n(0, a);
    });
  }
  const zi = (y) => (D(y), n(1, u = "editor")), Gi = () => n(1, u = "select");
  function ji(y) {
    me[y ? "unshift" : "push"](() => {
      U = y, n(23, U);
    });
  }
  function w(y) {
    me[y ? "unshift" : "push"](() => {
      S = y, n(18, S);
    });
  }
  function I(y) {
    _ = y, n(2, _);
  }
  function Z(y) {
    g = y, n(3, g);
  }
  const we = () => S.undo();
  function ae(y) {
    _ = y, n(2, _);
  }
  function Me(y) {
    g = y, n(3, g);
  }
  function Qt() {
    F = this.offsetHeight, ce = this.offsetWidth, n(24, F), n(25, ce);
  }
  return t.$$set = (y) => {
    "value" in y && n(0, a = y.value), "label" in y && n(4, s = y.label), "show_label" in y && n(5, l = y.show_label), "source" in y && n(6, o = y.source), "tool" in y && n(1, u = y.tool), "shape" in y && n(7, f = y.shape), "streaming" in y && n(8, c = y.streaming), "pending" in y && n(9, h = y.pending), "mirror_webcam" in y && n(10, d = y.mirror_webcam), "brush_radius" in y && n(2, _ = y.brush_radius), "brush_color" in y && n(3, g = y.brush_color), "mask_opacity" in y && n(11, v = y.mask_opacity), "selectable" in y && n(12, k = y.selectable), "root" in y && n(13, T = y.root), "i18n" in y && n(14, E = y.i18n), "$$scope" in y && n(65, r = y.$$scope);
  }, t.$$.update = () => {
    t.$$.dirty[0] & /*dragging*/
    65536 && z("drag", X), t.$$.dirty[0] & /*value, value_, root*/
    139265 && a !== Q && (n(17, Q = a), Ct(Q, T, null)), t.$$.dirty[0] & /*source, tool*/
    66 && (o === "canvas" && u === "sketch" ? n(22, G = "bw-sketch") : u === "color-sketch" ? n(22, G = "color-sketch") : (o === "upload" || o === "webcam") && u === "sketch" ? n(22, G = "mask") : n(22, G = "editor")), t.$$.dirty[0] & /*value*/
    1 && (a === null || a.image === null && a.mask === null) && n(26, K = void 0), t.$$.dirty[0] & /*cropper, value*/
    32769 && p && (a ? (n(15, p.image = a, p), p.create()) : p.destroy());
  }, [
    a,
    u,
    _,
    g,
    s,
    l,
    o,
    f,
    c,
    h,
    d,
    v,
    k,
    T,
    E,
    p,
    X,
    Q,
    S,
    O,
    P,
    A,
    G,
    U,
    F,
    ce,
    K,
    m,
    D,
    N,
    ne,
    B,
    b,
    M,
    i,
    he,
    de,
    tt,
    C,
    vt,
    wt,
    ue,
    re,
    be,
    ve,
    Ie,
    Ae,
    nt,
    ht,
    It,
    $n,
    On,
    Ui,
    ei,
    Fi,
    zi,
    Gi,
    ji,
    w,
    I,
    Z,
    we,
    ae,
    Me,
    Qt,
    r
  ];
}
class Dp extends ip {
  constructor(e) {
    super(), fp(
      this,
      e,
      Mp,
      Ap,
      Ma,
      {
        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]
    );
  }
}
function un(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: Op,
  append: Qe,
  attr: W,
  component_subscribe: Bo,
  detach: Bp,
  element: Np,
  init: Ip,
  insert: Hp,
  noop: No,
  safe_not_equal: Rp,
  set_style: ci,
  svg_element: Ke,
  toggle_class: Io
} = window.__gradio__svelte__internal, { onMount: Lp } = window.__gradio__svelte__internal;
function Pp(t) {
  let e, n, i, r, a, s, l, o, u, f, c, h;
  return {
    c() {
      e = Np("div"), n = Ke("svg"), i = Ke("g"), r = Ke("path"), a = Ke("path"), s = Ke("path"), l = Ke("path"), o = Ke("g"), u = Ke("path"), f = Ke("path"), c = Ke("path"), h = Ke("path"), W(r, "d", "M255.926 0.754768L509.702 139.936V221.027L255.926 81.8465V0.754768Z"), W(r, "fill", "#FF7C00"), W(r, "fill-opacity", "0.4"), W(r, "class", "svelte-43sxxs"), W(a, "d", "M509.69 139.936L254.981 279.641V361.255L509.69 221.55V139.936Z"), W(a, "fill", "#FF7C00"), W(a, "class", "svelte-43sxxs"), W(s, "d", "M0.250138 139.937L254.981 279.641V361.255L0.250138 221.55V139.937Z"), W(s, "fill", "#FF7C00"), W(s, "fill-opacity", "0.4"), W(s, "class", "svelte-43sxxs"), W(l, "d", "M255.923 0.232622L0.236328 139.936V221.55L255.923 81.8469V0.232622Z"), W(l, "fill", "#FF7C00"), W(l, "class", "svelte-43sxxs"), ci(i, "transform", "translate(" + /*$top*/
      t[1][0] + "px, " + /*$top*/
      t[1][1] + "px)"), W(u, "d", "M255.926 141.5L509.702 280.681V361.773L255.926 222.592V141.5Z"), W(u, "fill", "#FF7C00"), W(u, "fill-opacity", "0.4"), W(u, "class", "svelte-43sxxs"), W(f, "d", "M509.69 280.679L254.981 420.384V501.998L509.69 362.293V280.679Z"), W(f, "fill", "#FF7C00"), W(f, "class", "svelte-43sxxs"), W(c, "d", "M0.250138 280.681L254.981 420.386V502L0.250138 362.295V280.681Z"), W(c, "fill", "#FF7C00"), W(c, "fill-opacity", "0.4"), W(c, "class", "svelte-43sxxs"), W(h, "d", "M255.923 140.977L0.236328 280.68V362.294L255.923 222.591V140.977Z"), W(h, "fill", "#FF7C00"), W(h, "class", "svelte-43sxxs"), ci(o, "transform", "translate(" + /*$bottom*/
      t[2][0] + "px, " + /*$bottom*/
      t[2][1] + "px)"), W(n, "viewBox", "-1200 -1200 3000 3000"), W(n, "fill", "none"), W(n, "xmlns", "http://www.w3.org/2000/svg"), W(n, "class", "svelte-43sxxs"), W(e, "class", "svelte-43sxxs"), Io(
        e,
        "margin",
        /*margin*/
        t[0]
      );
    },
    m(d, _) {
      Hp(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, c), Qe(o, h);
    },
    p(d, [_]) {
      _ & /*$top*/
      2 && ci(i, "transform", "translate(" + /*$top*/
      d[1][0] + "px, " + /*$top*/
      d[1][1] + "px)"), _ & /*$bottom*/
      4 && ci(o, "transform", "translate(" + /*$bottom*/
      d[2][0] + "px, " + /*$bottom*/
      d[2][1] + "px)"), _ & /*margin*/
      1 && Io(
        e,
        "margin",
        /*margin*/
        d[0]
      );
    },
    i: No,
    o: No,
    d(d) {
      d && Bp(e);
    }
  };
}
function Up(t, e, n) {
  let i, r, { margin: a = !0 } = e;
  const s = Ra([0, 0]);
  Bo(t, s, (h) => n(1, i = h));
  const l = Ra([0, 0]);
  Bo(t, l, (h) => n(2, r = h));
  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 c() {
    await Promise.all([s.set([125, 0]), l.set([-125, 0])]), f();
  }
  return Lp(() => (c(), () => o = !0)), t.$$set = (h) => {
    "margin" in h && n(0, a = h.margin);
  }, [a, i, r, s, l];
}
class Fp extends Op {
  constructor(e) {
    super(), Ip(this, e, Up, Pp, Rp, { margin: 0 });
  }
}
const {
  SvelteComponent: zp,
  append: qt,
  attr: st,
  binding_callbacks: Ho,
  check_outros: su,
  create_component: Gp,
  create_slot: jp,
  destroy_component: qp,
  destroy_each: ou,
  detach: R,
  element: mt,
  empty: Dn,
  ensure_array_like: Mi,
  get_all_dirty_from_scope: xp,
  get_slot_changes: Xp,
  group_outros: lu,
  init: Vp,
  insert: L,
  mount_component: Wp,
  noop: ra,
  safe_not_equal: Yp,
  set_data: Ve,
  set_style: Ot,
  space: ot,
  text: fe,
  toggle_class: xe,
  transition_in: yn,
  transition_out: En,
  update_slot_base: Zp
} = window.__gradio__svelte__internal, { tick: Jp } = window.__gradio__svelte__internal, { onDestroy: Qp } = window.__gradio__svelte__internal, Kp = (t) => ({}), Ro = (t) => ({});
function Lo(t, e, n) {
  const i = t.slice();
  return i[38] = e[n], i[40] = n, i;
}
function Po(t, e, n) {
  const i = t.slice();
  return i[38] = e[n], i;
}
function $p(t) {
  let e, n = (
    /*i18n*/
    t[1]("common.error") + ""
  ), i, r, a;
  const s = (
    /*#slots*/
    t[29].error
  ), l = jp(
    s,
    t,
    /*$$scope*/
    t[28],
    Ro
  );
  return {
    c() {
      e = mt("span"), i = fe(n), r = ot(), l && l.c(), st(e, "class", "error svelte-14miwb5");
    },
    m(o, u) {
      L(o, e, u), qt(e, i), L(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") + "") && Ve(i, n), l && l.p && (!a || u[0] & /*$$scope*/
      268435456) && Zp(
        l,
        s,
        o,
        /*$$scope*/
        o[28],
        a ? Xp(
          s,
          /*$$scope*/
          o[28],
          u,
          Kp
        ) : xp(
          /*$$scope*/
          o[28]
        ),
        Ro
      );
    },
    i(o) {
      a || (yn(l, o), a = !0);
    },
    o(o) {
      En(l, o), a = !1;
    },
    d(o) {
      o && (R(e), R(r)), l && l.d(o);
    }
  };
}
function e1(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" && Uo(t)
  );
  function c(E, S) {
    if (
      /*progress*/
      E[7]
    )
      return i1;
    if (
      /*queue_position*/
      E[2] !== null && /*queue_size*/
      E[3] !== void 0 && /*queue_position*/
      E[2] >= 0
    )
      return n1;
    if (
      /*queue_position*/
      E[2] === 0
    )
      return t1;
  }
  let h = c(t), d = h && h(t), _ = (
    /*timer*/
    t[5] && Go(t)
  );
  const g = [o1, s1], v = [];
  function k(E, S) {
    return (
      /*last_progress_level*/
      E[15] != null ? 0 : (
        /*show_progress*/
        E[6] === "full" ? 1 : -1
      )
    );
  }
  ~(a = k(t)) && (s = v[a] = g[a](t));
  let T = !/*timer*/
  t[5] && Yo(t);
  return {
    c() {
      f && f.c(), e = ot(), n = mt("div"), d && d.c(), i = ot(), _ && _.c(), r = ot(), s && s.c(), l = ot(), T && T.c(), o = Dn(), st(n, "class", "progress-text svelte-14miwb5"), xe(
        n,
        "meta-text-center",
        /*variant*/
        t[8] === "center"
      ), xe(
        n,
        "meta-text",
        /*variant*/
        t[8] === "default"
      );
    },
    m(E, S) {
      f && f.m(E, S), L(E, e, S), L(E, n, S), d && d.m(n, null), qt(n, i), _ && _.m(n, null), L(E, r, S), ~a && v[a].m(E, S), L(E, l, S), T && T.m(E, S), L(E, o, S), u = !0;
    },
    p(E, S) {
      /*variant*/
      E[8] === "default" && /*show_eta_bar*/
      E[18] && /*show_progress*/
      E[6] === "full" ? f ? f.p(E, S) : (f = Uo(E), f.c(), f.m(e.parentNode, e)) : f && (f.d(1), f = null), h === (h = c(E)) && d ? d.p(E, S) : (d && d.d(1), d = h && h(E), d && (d.c(), d.m(n, i))), /*timer*/
      E[5] ? _ ? _.p(E, S) : (_ = Go(E), _.c(), _.m(n, null)) : _ && (_.d(1), _ = null), (!u || S[0] & /*variant*/
      256) && xe(
        n,
        "meta-text-center",
        /*variant*/
        E[8] === "center"
      ), (!u || S[0] & /*variant*/
      256) && xe(
        n,
        "meta-text",
        /*variant*/
        E[8] === "default"
      );
      let p = a;
      a = k(E), a === p ? ~a && v[a].p(E, S) : (s && (lu(), En(v[p], 1, 1, () => {
        v[p] = null;
      }), su()), ~a ? (s = v[a], s ? s.p(E, S) : (s = v[a] = g[a](E), s.c()), yn(s, 1), s.m(l.parentNode, l)) : s = null), /*timer*/
      E[5] ? T && (T.d(1), T = null) : T ? T.p(E, S) : (T = Yo(E), T.c(), T.m(o.parentNode, o));
    },
    i(E) {
      u || (yn(s), u = !0);
    },
    o(E) {
      En(s), u = !1;
    },
    d(E) {
      E && (R(e), R(n), R(r), R(l), R(o)), f && f.d(E), d && d.d(), _ && _.d(), ~a && v[a].d(E), T && T.d(E);
    }
  };
}
function Uo(t) {
  let e, n = `translateX(${/*eta_level*/
  (t[17] || 0) * 100 - 100}%)`;
  return {
    c() {
      e = mt("div"), st(e, "class", "eta-bar svelte-14miwb5"), Ot(e, "transform", n);
    },
    m(i, r) {
      L(i, e, r);
    },
    p(i, r) {
      r[0] & /*eta_level*/
      131072 && n !== (n = `translateX(${/*eta_level*/
      (i[17] || 0) * 100 - 100}%)`) && Ot(e, "transform", n);
    },
    d(i) {
      i && R(e);
    }
  };
}
function t1(t) {
  let e;
  return {
    c() {
      e = fe("processing |");
    },
    m(n, i) {
      L(n, e, i);
    },
    p: ra,
    d(n) {
      n && R(e);
    }
  };
}
function n1(t) {
  let e, n = (
    /*queue_position*/
    t[2] + 1 + ""
  ), i, r, a, s;
  return {
    c() {
      e = fe("queue: "), i = fe(n), r = fe("/"), a = fe(
        /*queue_size*/
        t[3]
      ), s = fe(" |");
    },
    m(l, o) {
      L(l, e, o), L(l, i, o), L(l, r, o), L(l, a, o), L(l, s, o);
    },
    p(l, o) {
      o[0] & /*queue_position*/
      4 && n !== (n = /*queue_position*/
      l[2] + 1 + "") && Ve(i, n), o[0] & /*queue_size*/
      8 && Ve(
        a,
        /*queue_size*/
        l[3]
      );
    },
    d(l) {
      l && (R(e), R(i), R(r), R(a), R(s));
    }
  };
}
function i1(t) {
  let e, n = Mi(
    /*progress*/
    t[7]
  ), i = [];
  for (let r = 0; r < n.length; r += 1)
    i[r] = zo(Po(t, n, r));
  return {
    c() {
      for (let r = 0; r < i.length; r += 1)
        i[r].c();
      e = Dn();
    },
    m(r, a) {
      for (let s = 0; s < i.length; s += 1)
        i[s] && i[s].m(r, a);
      L(r, e, a);
    },
    p(r, a) {
      if (a[0] & /*progress*/
      128) {
        n = Mi(
          /*progress*/
          r[7]
        );
        let s;
        for (s = 0; s < n.length; s += 1) {
          const l = Po(r, n, s);
          i[s] ? i[s].p(l, a) : (i[s] = zo(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 && R(e), ou(i, r);
    }
  };
}
function Fo(t) {
  let e, n = (
    /*p*/
    t[38].unit + ""
  ), i, r, a = " ", s;
  function l(f, c) {
    return (
      /*p*/
      f[38].length != null ? a1 : r1
    );
  }
  let o = l(t), u = o(t);
  return {
    c() {
      u.c(), e = ot(), i = fe(n), r = fe(" | "), s = fe(a);
    },
    m(f, c) {
      u.m(f, c), L(f, e, c), L(f, i, c), L(f, r, c), L(f, s, c);
    },
    p(f, c) {
      o === (o = l(f)) && u ? u.p(f, c) : (u.d(1), u = o(f), u && (u.c(), u.m(e.parentNode, e))), c[0] & /*progress*/
      128 && n !== (n = /*p*/
      f[38].unit + "") && Ve(i, n);
    },
    d(f) {
      f && (R(e), R(i), R(r), R(s)), u.d(f);
    }
  };
}
function r1(t) {
  let e = un(
    /*p*/
    t[38].index || 0
  ) + "", n;
  return {
    c() {
      n = fe(e);
    },
    m(i, r) {
      L(i, n, r);
    },
    p(i, r) {
      r[0] & /*progress*/
      128 && e !== (e = un(
        /*p*/
        i[38].index || 0
      ) + "") && Ve(n, e);
    },
    d(i) {
      i && R(n);
    }
  };
}
function a1(t) {
  let e = un(
    /*p*/
    t[38].index || 0
  ) + "", n, i, r = un(
    /*p*/
    t[38].length
  ) + "", a;
  return {
    c() {
      n = fe(e), i = fe("/"), a = fe(r);
    },
    m(s, l) {
      L(s, n, l), L(s, i, l), L(s, a, l);
    },
    p(s, l) {
      l[0] & /*progress*/
      128 && e !== (e = un(
        /*p*/
        s[38].index || 0
      ) + "") && Ve(n, e), l[0] & /*progress*/
      128 && r !== (r = un(
        /*p*/
        s[38].length
      ) + "") && Ve(a, r);
    },
    d(s) {
      s && (R(n), R(i), R(a));
    }
  };
}
function zo(t) {
  let e, n = (
    /*p*/
    t[38].index != null && Fo(t)
  );
  return {
    c() {
      n && n.c(), e = Dn();
    },
    m(i, r) {
      n && n.m(i, r), L(i, e, r);
    },
    p(i, r) {
      /*p*/
      i[38].index != null ? n ? n.p(i, r) : (n = Fo(i), n.c(), n.m(e.parentNode, e)) : n && (n.d(1), n = null);
    },
    d(i) {
      i && R(e), n && n.d(i);
    }
  };
}
function Go(t) {
  let e, n = (
    /*eta*/
    t[0] ? `/${/*formatted_eta*/
    t[19]}` : ""
  ), i, r;
  return {
    c() {
      e = fe(
        /*formatted_timer*/
        t[20]
      ), i = fe(n), r = fe("s");
    },
    m(a, s) {
      L(a, e, s), L(a, i, s), L(a, r, s);
    },
    p(a, s) {
      s[0] & /*formatted_timer*/
      1048576 && Ve(
        e,
        /*formatted_timer*/
        a[20]
      ), s[0] & /*eta, formatted_eta*/
      524289 && n !== (n = /*eta*/
      a[0] ? `/${/*formatted_eta*/
      a[19]}` : "") && Ve(i, n);
    },
    d(a) {
      a && (R(e), R(i), R(r));
    }
  };
}
function s1(t) {
  let e, n;
  return e = new Fp({
    props: { margin: (
      /*variant*/
      t[8] === "default"
    ) }
  }), {
    c() {
      Gp(e.$$.fragment);
    },
    m(i, r) {
      Wp(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 || (yn(e.$$.fragment, i), n = !0);
    },
    o(i) {
      En(e.$$.fragment, i), n = !1;
    },
    d(i) {
      qp(e, i);
    }
  };
}
function o1(t) {
  let e, n, i, r, a, s = `${/*last_progress_level*/
  t[15] * 100}%`, l = (
    /*progress*/
    t[7] != null && jo(t)
  );
  return {
    c() {
      e = mt("div"), n = mt("div"), l && l.c(), i = ot(), r = mt("div"), a = mt("div"), st(n, "class", "progress-level-inner svelte-14miwb5"), st(a, "class", "progress-bar svelte-14miwb5"), Ot(a, "width", s), st(r, "class", "progress-bar-wrap svelte-14miwb5"), st(e, "class", "progress-level svelte-14miwb5");
    },
    m(o, u) {
      L(o, e, u), qt(e, n), l && l.m(n, null), qt(e, i), qt(e, r), qt(r, a), t[30](a);
    },
    p(o, u) {
      /*progress*/
      o[7] != null ? l ? l.p(o, u) : (l = jo(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}%`) && Ot(a, "width", s);
    },
    i: ra,
    o: ra,
    d(o) {
      o && R(e), l && l.d(), t[30](null);
    }
  };
}
function jo(t) {
  let e, n = Mi(
    /*progress*/
    t[7]
  ), i = [];
  for (let r = 0; r < n.length; r += 1)
    i[r] = Wo(Lo(t, n, r));
  return {
    c() {
      for (let r = 0; r < i.length; r += 1)
        i[r].c();
      e = Dn();
    },
    m(r, a) {
      for (let s = 0; s < i.length; s += 1)
        i[s] && i[s].m(r, a);
      L(r, e, a);
    },
    p(r, a) {
      if (a[0] & /*progress_level, progress*/
      16512) {
        n = Mi(
          /*progress*/
          r[7]
        );
        let s;
        for (s = 0; s < n.length; s += 1) {
          const l = Lo(r, n, s);
          i[s] ? i[s].p(l, a) : (i[s] = Wo(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 && R(e), ou(i, r);
    }
  };
}
function qo(t) {
  let e, n, i, r, a = (
    /*i*/
    t[40] !== 0 && l1()
  ), s = (
    /*p*/
    t[38].desc != null && xo(t)
  ), l = (
    /*p*/
    t[38].desc != null && /*progress_level*/
    t[14] && /*progress_level*/
    t[14][
      /*i*/
      t[40]
    ] != null && Xo()
  ), o = (
    /*progress_level*/
    t[14] != null && Vo(t)
  );
  return {
    c() {
      a && a.c(), e = ot(), s && s.c(), n = ot(), l && l.c(), i = ot(), o && o.c(), r = Dn();
    },
    m(u, f) {
      a && a.m(u, f), L(u, e, f), s && s.m(u, f), L(u, n, f), l && l.m(u, f), L(u, i, f), o && o.m(u, f), L(u, r, f);
    },
    p(u, f) {
      /*p*/
      u[38].desc != null ? s ? s.p(u, f) : (s = xo(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 = Xo(), l.c(), l.m(i.parentNode, i)) : l && (l.d(1), l = null), /*progress_level*/
      u[14] != null ? o ? o.p(u, f) : (o = Vo(u), o.c(), o.m(r.parentNode, r)) : o && (o.d(1), o = null);
    },
    d(u) {
      u && (R(e), R(n), R(i), R(r)), a && a.d(u), s && s.d(u), l && l.d(u), o && o.d(u);
    }
  };
}
function l1(t) {
  let e;
  return {
    c() {
      e = fe(" /");
    },
    m(n, i) {
      L(n, e, i);
    },
    d(n) {
      n && R(e);
    }
  };
}
function xo(t) {
  let e = (
    /*p*/
    t[38].desc + ""
  ), n;
  return {
    c() {
      n = fe(e);
    },
    m(i, r) {
      L(i, n, r);
    },
    p(i, r) {
      r[0] & /*progress*/
      128 && e !== (e = /*p*/
      i[38].desc + "") && Ve(n, e);
    },
    d(i) {
      i && R(n);
    }
  };
}
function Xo(t) {
  let e;
  return {
    c() {
      e = fe("-");
    },
    m(n, i) {
      L(n, e, i);
    },
    d(n) {
      n && R(e);
    }
  };
}
function Vo(t) {
  let e = (100 * /*progress_level*/
  (t[14][
    /*i*/
    t[40]
  ] || 0)).toFixed(1) + "", n, i;
  return {
    c() {
      n = fe(e), i = fe("%");
    },
    m(r, a) {
      L(r, n, a), L(r, i, a);
    },
    p(r, a) {
      a[0] & /*progress_level*/
      16384 && e !== (e = (100 * /*progress_level*/
      (r[14][
        /*i*/
        r[40]
      ] || 0)).toFixed(1) + "") && Ve(n, e);
    },
    d(r) {
      r && (R(n), R(i));
    }
  };
}
function Wo(t) {
  let e, n = (
    /*p*/
    (t[38].desc != null || /*progress_level*/
    t[14] && /*progress_level*/
    t[14][
      /*i*/
      t[40]
    ] != null) && qo(t)
  );
  return {
    c() {
      n && n.c(), e = Dn();
    },
    m(i, r) {
      n && n.m(i, r), L(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 = qo(i), n.c(), n.m(e.parentNode, e)) : n && (n.d(1), n = null);
    },
    d(i) {
      i && R(e), n && n.d(i);
    }
  };
}
function Yo(t) {
  let e, n;
  return {
    c() {
      e = mt("p"), n = fe(
        /*loading_text*/
        t[9]
      ), st(e, "class", "loading svelte-14miwb5");
    },
    m(i, r) {
      L(i, e, r), qt(e, n);
    },
    p(i, r) {
      r[0] & /*loading_text*/
      512 && Ve(
        n,
        /*loading_text*/
        i[9]
      );
    },
    d(i) {
      i && R(e);
    }
  };
}
function u1(t) {
  let e, n, i, r, a;
  const s = [e1, $p], 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 = mt("div"), i && i.c(), st(e, "class", r = "wrap " + /*variant*/
      t[8] + " " + /*show_progress*/
      t[6] + " svelte-14miwb5"), xe(e, "hide", !/*status*/
      t[4] || /*status*/
      t[4] === "complete" || /*show_progress*/
      t[6] === "hidden"), xe(
        e,
        "translucent",
        /*variant*/
        t[8] === "center" && /*status*/
        (t[4] === "pending" || /*status*/
        t[4] === "error") || /*translucent*/
        t[11] || /*show_progress*/
        t[6] === "minimal"
      ), xe(
        e,
        "generating",
        /*status*/
        t[4] === "generating"
      ), xe(
        e,
        "border",
        /*border*/
        t[12]
      ), Ot(
        e,
        "position",
        /*absolute*/
        t[10] ? "absolute" : "static"
      ), Ot(
        e,
        "padding",
        /*absolute*/
        t[10] ? "0" : "var(--size-8) 0"
      );
    },
    m(u, f) {
      L(u, e, f), ~n && l[n].m(e, null), t[31](e), a = !0;
    },
    p(u, f) {
      let c = n;
      n = o(u), n === c ? ~n && l[n].p(u, f) : (i && (lu(), En(l[c], 1, 1, () => {
        l[c] = null;
      }), su()), ~n ? (i = l[n], i ? i.p(u, f) : (i = l[n] = s[n](u), i.c()), yn(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")) && st(e, "class", r), (!a || f[0] & /*variant, show_progress, status, show_progress*/
      336) && xe(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) && xe(
        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) && xe(
        e,
        "generating",
        /*status*/
        u[4] === "generating"
      ), (!a || f[0] & /*variant, show_progress, border*/
      4416) && xe(
        e,
        "border",
        /*border*/
        u[12]
      ), f[0] & /*absolute*/
      1024 && Ot(
        e,
        "position",
        /*absolute*/
        u[10] ? "absolute" : "static"
      ), f[0] & /*absolute*/
      1024 && Ot(
        e,
        "padding",
        /*absolute*/
        u[10] ? "0" : "var(--size-8) 0"
      );
    },
    i(u) {
      a || (yn(i), a = !0);
    },
    o(u) {
      En(i), a = !1;
    },
    d(u) {
      u && R(e), ~n && l[n].d(), t[31](null);
    }
  };
}
let hi = [], Sr = !1;
async function f1(t, e = !0) {
  if (!(window.__gradio_mode__ === "website" || window.__gradio_mode__ !== "app" && e !== !0)) {
    if (hi.push(t), !Sr)
      Sr = !0;
    else
      return;
    await Jp(), requestAnimationFrame(() => {
      let n = [0, 0];
      for (let i = 0; i < hi.length; i++) {
        const a = hi[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" }), Sr = !1, hi = [];
    });
  }
}
function c1(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: c } = e, { scroll_to_output: h = !1 } = e, { timer: d = !0 } = e, { show_progress: _ = "full" } = e, { message: g = null } = e, { progress: v = null } = e, { variant: k = "default" } = e, { loading_text: T = "Loading..." } = e, { absolute: E = !0 } = e, { translucent: S = !1 } = e, { border: p = !1 } = e, { autoscroll: m } = e, D, N = !1, z = 0, X = 0, Q = null, ne = 0, B = null, b, O = null, P = !0;
  const A = () => {
    n(25, z = performance.now()), n(26, X = 0), N = !0, G();
  };
  function G() {
    requestAnimationFrame(() => {
      n(26, X = (performance.now() - z) / 1e3), N && G();
    });
  }
  function U() {
    n(26, X = 0), N && (N = !1);
  }
  Qp(() => {
    N && U();
  });
  let F = null;
  function ce(M) {
    Ho[M ? "unshift" : "push"](() => {
      O = M, n(16, O), n(7, v), n(14, B), n(15, b);
    });
  }
  function K(M) {
    Ho[M ? "unshift" : "push"](() => {
      D = M, n(13, D);
    });
  }
  return t.$$set = (M) => {
    "i18n" in M && n(1, s = M.i18n), "eta" in M && n(0, l = M.eta), "queue" in M && n(21, o = M.queue), "queue_position" in M && n(2, u = M.queue_position), "queue_size" in M && n(3, f = M.queue_size), "status" in M && n(4, c = M.status), "scroll_to_output" in M && n(22, h = M.scroll_to_output), "timer" in M && n(5, d = M.timer), "show_progress" in M && n(6, _ = M.show_progress), "message" in M && n(23, g = M.message), "progress" in M && n(7, v = M.progress), "variant" in M && n(8, k = M.variant), "loading_text" in M && n(9, T = M.loading_text), "absolute" in M && n(10, E = M.absolute), "translucent" in M && n(11, S = M.translucent), "border" in M && n(12, p = M.border), "autoscroll" in M && n(24, m = M.autoscroll), "$$scope" in M && n(28, a = M.$$scope);
  }, t.$$.update = () => {
    t.$$.dirty[0] & /*eta, old_eta, queue, timer_start*/
    169869313 && (l === null ? n(0, l = Q) : o && n(0, l = (performance.now() - z) / 1e3 + l), l != null && (n(19, F = l.toFixed(1)), n(27, Q = l))), t.$$.dirty[0] & /*eta, timer_diff*/
    67108865 && n(17, ne = l === null || l <= 0 || !X ? null : Math.min(X / l, 1)), t.$$.dirty[0] & /*progress*/
    128 && v != null && n(18, P = !1), t.$$.dirty[0] & /*progress, progress_level, progress_bar, last_progress_level*/
    114816 && (v != null ? n(14, B = v.map((M) => {
      if (M.index != null && M.length != null)
        return M.index / M.length;
      if (M.progress != null)
        return M.progress;
    })) : n(14, B = null), B ? (n(15, b = B[B.length - 1]), O && (b === 0 ? n(16, O.style.transition = "0", O) : n(16, O.style.transition = "150ms", O))) : n(15, b = void 0)), t.$$.dirty[0] & /*status*/
    16 && (c === "pending" ? A() : U()), t.$$.dirty[0] & /*el, scroll_to_output, status, autoscroll*/
    20979728 && D && h && (c === "pending" || c === "complete") && f1(D, m), t.$$.dirty[0] & /*status, message*/
    8388624, t.$$.dirty[0] & /*timer_diff*/
    67108864 && n(20, i = X.toFixed(1));
  }, [
    l,
    s,
    u,
    f,
    c,
    d,
    _,
    v,
    k,
    T,
    E,
    S,
    p,
    D,
    B,
    b,
    O,
    ne,
    P,
    F,
    i,
    o,
    h,
    g,
    m,
    z,
    X,
    Q,
    a,
    r,
    ce,
    K
  ];
}
class uu extends zp {
  constructor(e) {
    super(), Vp(
      this,
      e,
      c1,
      u1,
      Yp,
      {
        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: h1,
  add_flush_callback: d1,
  assign: fu,
  bind: _1,
  binding_callbacks: m1,
  check_outros: g1,
  create_component: Vt,
  destroy_component: Wt,
  detach: Da,
  empty: p1,
  flush: $,
  get_spread_object: cu,
  get_spread_update: hu,
  group_outros: b1,
  init: v1,
  insert: Oa,
  mount_component: Yt,
  safe_not_equal: w1,
  space: du,
  transition_in: pt,
  transition_out: bt
} = window.__gradio__svelte__internal;
function y1(t) {
  let e, n;
  return e = new Tl({
    props: {
      visible: (
        /*visible*/
        t[4]
      ),
      variant: (
        /*value*/
        t[0] === null && /*source*/
        t[17] === "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[9] || /*source*/
        (t[17] === "webcam" ? void 0 : Zo)
      ),
      width: (
        /*width*/
        t[10]
      ),
      allow_overflow: !1,
      container: (
        /*container*/
        t[12]
      ),
      scale: (
        /*scale*/
        t[13]
      ),
      min_width: (
        /*min_width*/
        t[14]
      ),
      $$slots: { default: [S1] },
      $$scope: { ctx: t }
    }
  }), {
    c() {
      Vt(e.$$.fragment);
    },
    m(i, r) {
      Yt(e, i, r), n = !0;
    },
    p(i, r) {
      const a = {};
      r[0] & /*visible*/
      16 && (a.visible = /*visible*/
      i[4]), r[0] & /*value, source*/
      131073 && (a.variant = /*value*/
      i[0] === null && /*source*/
      i[17] === "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*/
      131584 && (a.height = /*height*/
      i[9] || /*source*/
      (i[17] === "webcam" ? void 0 : Zo)), r[0] & /*width*/
      1024 && (a.width = /*width*/
      i[10]), r[0] & /*container*/
      4096 && (a.container = /*container*/
      i[12]), r[0] & /*scale*/
      8192 && (a.scale = /*scale*/
      i[13]), r[0] & /*min_width*/
      16384 && (a.min_width = /*min_width*/
      i[14]), r[0] & /*brush_radius, brush_color, shape, source, tool, selectable, mask_opacity, root, label, show_label, pending, streaming, mirror_webcam, gradio, value, dragging, loading_status*/
      268306787 | r[1] & /*$$scope*/
      512 && (a.$$scope = { dirty: r, ctx: i }), e.$set(a);
    },
    i(i) {
      n || (pt(e.$$.fragment, i), n = !0);
    },
    o(i) {
      bt(e.$$.fragment, i), n = !1;
    },
    d(i) {
      Wt(e, i);
    }
  };
}
function E1(t) {
  let e, n;
  return e = new Tl({
    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[9] || void 0
      ),
      width: (
        /*width*/
        t[10]
      ),
      allow_overflow: !1,
      container: (
        /*container*/
        t[12]
      ),
      scale: (
        /*scale*/
        t[13]
      ),
      min_width: (
        /*min_width*/
        t[14]
      ),
      $$slots: { default: [T1] },
      $$scope: { ctx: t }
    }
  }), {
    c() {
      Vt(e.$$.fragment);
    },
    m(i, r) {
      Yt(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*/
      512 && (a.height = /*height*/
      i[9] || void 0), r[0] & /*width*/
      1024 && (a.width = /*width*/
      i[10]), r[0] & /*container*/
      4096 && (a.container = /*container*/
      i[12]), r[0] & /*scale*/
      8192 && (a.scale = /*scale*/
      i[13]), r[0] & /*min_width*/
      16384 && (a.min_width = /*min_width*/
      i[14]), r[0] & /*root, value, label, show_label, show_download_button, selectable, show_share_button, gradio, loading_status*/
      67144163 | r[1] & /*$$scope*/
      512 && (a.$$scope = { dirty: r, ctx: i }), e.$set(a);
    },
    i(i) {
      n || (pt(e.$$.fragment, i), n = !0);
    },
    o(i) {
      bt(e.$$.fragment, i), n = !1;
    },
    d(i) {
      Wt(e, i);
    }
  };
}
function k1(t) {
  let e, n;
  return e = new C0({
    props: {
      i18n: (
        /*gradio*/
        t[26].i18n
      ),
      type: "image"
    }
  }), {
    c() {
      Vt(e.$$.fragment);
    },
    m(i, r) {
      Yt(e, i, r), n = !0;
    },
    p(i, r) {
      const a = {};
      r[0] & /*gradio*/
      67108864 && (a.i18n = /*gradio*/
      i[26].i18n), e.$set(a);
    },
    i(i) {
      n || (pt(e.$$.fragment, i), n = !0);
    },
    o(i) {
      bt(e.$$.fragment, i), n = !1;
    },
    d(i) {
      Wt(e, i);
    }
  };
}
function S1(t) {
  let e, n, i, r, a;
  const s = [
    {
      autoscroll: (
        /*gradio*/
        t[26].autoscroll
      )
    },
    { i18n: (
      /*gradio*/
      t[26].i18n
    ) },
    /*loading_status*/
    t[1]
  ];
  let l = {};
  for (let f = 0; f < s.length; f += 1)
    l = fu(l, s[f]);
  e = new uu({ props: l });
  function o(f) {
    t[31](f);
  }
  let u = {
    brush_radius: (
      /*brush_radius*/
      t[23]
    ),
    brush_color: (
      /*brush_color*/
      t[24]
    ),
    shape: (
      /*shape*/
      t[22]
    ),
    source: (
      /*source*/
      t[17]
    ),
    tool: (
      /*tool*/
      t[18]
    ),
    selectable: (
      /*selectable*/
      t[11]
    ),
    mask_opacity: (
      /*mask_opacity*/
      t[25]
    ),
    root: (
      /*root*/
      t[8]
    ),
    label: (
      /*label*/
      t[5]
    ),
    show_label: (
      /*show_label*/
      t[6]
    ),
    pending: (
      /*pending*/
      t[20]
    ),
    streaming: (
      /*streaming*/
      t[19]
    ),
    mirror_webcam: (
      /*mirror_webcam*/
      t[21]
    ),
    i18n: (
      /*gradio*/
      t[26].i18n
    ),
    $$slots: { default: [k1] },
    $$scope: { ctx: t }
  };
  return (
    /*value*/
    t[0] !== void 0 && (u.value = /*value*/
    t[0]), i = new Dp({ props: u }), m1.push(() => _1(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() {
        Vt(e.$$.fragment), n = du(), Vt(i.$$.fragment);
      },
      m(f, c) {
        Yt(e, f, c), Oa(f, n, c), Yt(i, f, c), a = !0;
      },
      p(f, c) {
        const h = c[0] & /*gradio, loading_status*/
        67108866 ? hu(s, [
          c[0] & /*gradio*/
          67108864 && {
            autoscroll: (
              /*gradio*/
              f[26].autoscroll
            )
          },
          c[0] & /*gradio*/
          67108864 && { i18n: (
            /*gradio*/
            f[26].i18n
          ) },
          c[0] & /*loading_status*/
          2 && cu(
            /*loading_status*/
            f[1]
          )
        ]) : {};
        e.$set(h);
        const d = {};
        c[0] & /*brush_radius*/
        8388608 && (d.brush_radius = /*brush_radius*/
        f[23]), c[0] & /*brush_color*/
        16777216 && (d.brush_color = /*brush_color*/
        f[24]), c[0] & /*shape*/
        4194304 && (d.shape = /*shape*/
        f[22]), c[0] & /*source*/
        131072 && (d.source = /*source*/
        f[17]), c[0] & /*tool*/
        262144 && (d.tool = /*tool*/
        f[18]), c[0] & /*selectable*/
        2048 && (d.selectable = /*selectable*/
        f[11]), c[0] & /*mask_opacity*/
        33554432 && (d.mask_opacity = /*mask_opacity*/
        f[25]), c[0] & /*root*/
        256 && (d.root = /*root*/
        f[8]), c[0] & /*label*/
        32 && (d.label = /*label*/
        f[5]), c[0] & /*show_label*/
        64 && (d.show_label = /*show_label*/
        f[6]), c[0] & /*pending*/
        1048576 && (d.pending = /*pending*/
        f[20]), c[0] & /*streaming*/
        524288 && (d.streaming = /*streaming*/
        f[19]), c[0] & /*mirror_webcam*/
        2097152 && (d.mirror_webcam = /*mirror_webcam*/
        f[21]), c[0] & /*gradio*/
        67108864 && (d.i18n = /*gradio*/
        f[26].i18n), c[0] & /*gradio*/
        67108864 | c[1] & /*$$scope*/
        512 && (d.$$scope = { dirty: c, ctx: f }), !r && c[0] & /*value*/
        1 && (r = !0, d.value = /*value*/
        f[0], d1(() => r = !1)), i.$set(d);
      },
      i(f) {
        a || (pt(e.$$.fragment, f), pt(i.$$.fragment, f), a = !0);
      },
      o(f) {
        bt(e.$$.fragment, f), bt(i.$$.fragment, f), a = !1;
      },
      d(f) {
        f && Da(n), Wt(e, f), Wt(i, f);
      }
    }
  );
}
function T1(t) {
  let e, n, i, r;
  const a = [
    {
      autoscroll: (
        /*gradio*/
        t[26].autoscroll
      )
    },
    { i18n: (
      /*gradio*/
      t[26].i18n
    ) },
    /*loading_status*/
    t[1]
  ];
  let s = {};
  for (let l = 0; l < a.length; l += 1)
    s = fu(s, a[l]);
  return e = new uu({ props: s }), i = new B_({
    props: {
      root: (
        /*root*/
        t[8]
      ),
      value: (
        /*value*/
        t[0]
      ),
      label: (
        /*label*/
        t[5]
      ),
      show_label: (
        /*show_label*/
        t[6]
      ),
      show_download_button: (
        /*show_download_button*/
        t[7]
      ),
      selectable: (
        /*selectable*/
        t[11]
      ),
      show_share_button: (
        /*show_share_button*/
        t[15]
      ),
      i18n: (
        /*gradio*/
        t[26].i18n
      )
    }
  }), i.$on(
    "select",
    /*select_handler*/
    t[28]
  ), i.$on(
    "share",
    /*share_handler*/
    t[29]
  ), i.$on(
    "error",
    /*error_handler*/
    t[30]
  ), {
    c() {
      Vt(e.$$.fragment), n = du(), Vt(i.$$.fragment);
    },
    m(l, o) {
      Yt(e, l, o), Oa(l, n, o), Yt(i, l, o), r = !0;
    },
    p(l, o) {
      const u = o[0] & /*gradio, loading_status*/
      67108866 ? hu(a, [
        o[0] & /*gradio*/
        67108864 && {
          autoscroll: (
            /*gradio*/
            l[26].autoscroll
          )
        },
        o[0] & /*gradio*/
        67108864 && { i18n: (
          /*gradio*/
          l[26].i18n
        ) },
        o[0] & /*loading_status*/
        2 && cu(
          /*loading_status*/
          l[1]
        )
      ]) : {};
      e.$set(u);
      const f = {};
      o[0] & /*root*/
      256 && (f.root = /*root*/
      l[8]), 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*/
      128 && (f.show_download_button = /*show_download_button*/
      l[7]), o[0] & /*selectable*/
      2048 && (f.selectable = /*selectable*/
      l[11]), o[0] & /*show_share_button*/
      32768 && (f.show_share_button = /*show_share_button*/
      l[15]), o[0] & /*gradio*/
      67108864 && (f.i18n = /*gradio*/
      l[26].i18n), i.$set(f);
    },
    i(l) {
      r || (pt(e.$$.fragment, l), pt(i.$$.fragment, l), r = !0);
    },
    o(l) {
      bt(e.$$.fragment, l), bt(i.$$.fragment, l), r = !1;
    },
    d(l) {
      l && Da(n), Wt(e, l), Wt(i, l);
    }
  };
}
function C1(t) {
  let e, n, i, r;
  const a = [E1, y1], s = [];
  function l(o, u) {
    return (
      /*mode*/
      o[16] === "static" ? 0 : 1
    );
  }
  return e = l(t), n = s[e] = a[e](t), {
    c() {
      n.c(), i = p1();
    },
    m(o, u) {
      s[e].m(o, u), Oa(o, i, u), r = !0;
    },
    p(o, u) {
      let f = e;
      e = l(o), e === f ? s[e].p(o, u) : (b1(), bt(s[f], 1, 1, () => {
        s[f] = null;
      }), g1(), n = s[e], n ? n.p(o, u) : (n = s[e] = a[e](o), n.c()), pt(n, 1), n.m(i.parentNode, i));
    },
    i(o) {
      r || (pt(n), r = !0);
    },
    o(o) {
      bt(n), r = !1;
    },
    d(o) {
      o && Da(i), s[e].d(o);
    }
  };
}
const Zo = 240;
function A1(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, { show_download_button: u } = e, { root: f } = e, { height: c } = e, { width: h } = e, { selectable: d = !1 } = e, { container: _ = !0 } = e, { scale: g = null } = e, { min_width: v = void 0 } = e, { loading_status: k } = e, { show_share_button: T = !1 } = e, { mode: E } = e, { source: S = "upload" } = e, { tool: p = "editor" } = e, { streaming: m } = e, { pending: D } = e, { mirror_webcam: N } = e, { shape: z } = e, { brush_radius: X } = e, { brush_color: Q } = e, { mask_opacity: ne } = e, { gradio: B } = e, b;
  const O = ({ detail: C }) => B.dispatch("select", C), P = ({ detail: C }) => B.dispatch("share", C), A = ({ detail: C }) => B.dispatch("error", C);
  function G(C) {
    s = C, n(0, s);
  }
  const U = () => B.dispatch("edit"), F = () => B.dispatch("clear"), ce = () => B.dispatch("stream"), K = ({ detail: C }) => n(27, b = C), M = () => B.dispatch("upload"), he = ({ detail: C }) => B.dispatch("select", C), de = ({ detail: C }) => B.dispatch("share", C), tt = ({ detail: C }) => {
    n(1, k = k || {}), n(1, k.status = "error", k), B.dispatch("error", C);
  };
  return t.$$set = (C) => {
    "elem_id" in C && n(2, i = C.elem_id), "elem_classes" in C && n(3, r = C.elem_classes), "visible" in C && n(4, a = C.visible), "value" in C && n(0, s = C.value), "label" in C && n(5, l = C.label), "show_label" in C && n(6, o = C.show_label), "show_download_button" in C && n(7, u = C.show_download_button), "root" in C && n(8, f = C.root), "height" in C && n(9, c = C.height), "width" in C && n(10, h = C.width), "selectable" in C && n(11, d = C.selectable), "container" in C && n(12, _ = C.container), "scale" in C && n(13, g = C.scale), "min_width" in C && n(14, v = C.min_width), "loading_status" in C && n(1, k = C.loading_status), "show_share_button" in C && n(15, T = C.show_share_button), "mode" in C && n(16, E = C.mode), "source" in C && n(17, S = C.source), "tool" in C && n(18, p = C.tool), "streaming" in C && n(19, m = C.streaming), "pending" in C && n(20, D = C.pending), "mirror_webcam" in C && n(21, N = C.mirror_webcam), "shape" in C && n(22, z = C.shape), "brush_radius" in C && n(23, X = C.brush_radius), "brush_color" in C && n(24, Q = C.brush_color), "mask_opacity" in C && n(25, ne = C.mask_opacity), "gradio" in C && n(26, B = C.gradio);
  }, t.$$.update = () => {
    t.$$.dirty[0] & /*value*/
    1 && n(0, s = s || null), t.$$.dirty[0] & /*value, gradio*/
    67108865 && B.dispatch("change");
  }, [
    s,
    k,
    i,
    r,
    a,
    l,
    o,
    u,
    f,
    c,
    h,
    d,
    _,
    g,
    v,
    T,
    E,
    S,
    p,
    m,
    D,
    N,
    z,
    X,
    Q,
    ne,
    B,
    b,
    O,
    P,
    A,
    G,
    U,
    F,
    ce,
    K,
    M,
    he,
    de,
    tt
  ];
}
class I1 extends h1 {
  constructor(e) {
    super(), v1(
      this,
      e,
      A1,
      C1,
      w1,
      {
        elem_id: 2,
        elem_classes: 3,
        visible: 4,
        value: 0,
        label: 5,
        show_label: 6,
        show_download_button: 7,
        root: 8,
        height: 9,
        width: 10,
        selectable: 11,
        container: 12,
        scale: 13,
        min_width: 14,
        loading_status: 1,
        show_share_button: 15,
        mode: 16,
        source: 17,
        tool: 18,
        streaming: 19,
        pending: 20,
        mirror_webcam: 21,
        shape: 22,
        brush_radius: 23,
        brush_color: 24,
        mask_opacity: 25,
        gradio: 26
      },
      null,
      [-1, -1]
    );
  }
  get elem_id() {
    return this.$$.ctx[2];
  }
  set elem_id(e) {
    this.$$set({ elem_id: e }), $();
  }
  get elem_classes() {
    return this.$$.ctx[3];
  }
  set elem_classes(e) {
    this.$$set({ elem_classes: e }), $();
  }
  get visible() {
    return this.$$.ctx[4];
  }
  set visible(e) {
    this.$$set({ visible: e }), $();
  }
  get value() {
    return this.$$.ctx[0];
  }
  set value(e) {
    this.$$set({ value: e }), $();
  }
  get label() {
    return this.$$.ctx[5];
  }
  set label(e) {
    this.$$set({ label: e }), $();
  }
  get show_label() {
    return this.$$.ctx[6];
  }
  set show_label(e) {
    this.$$set({ show_label: e }), $();
  }
  get show_download_button() {
    return this.$$.ctx[7];
  }
  set show_download_button(e) {
    this.$$set({ show_download_button: e }), $();
  }
  get root() {
    return this.$$.ctx[8];
  }
  set root(e) {
    this.$$set({ root: e }), $();
  }
  get height() {
    return this.$$.ctx[9];
  }
  set height(e) {
    this.$$set({ height: e }), $();
  }
  get width() {
    return this.$$.ctx[10];
  }
  set width(e) {
    this.$$set({ width: e }), $();
  }
  get selectable() {
    return this.$$.ctx[11];
  }
  set selectable(e) {
    this.$$set({ selectable: e }), $();
  }
  get container() {
    return this.$$.ctx[12];
  }
  set container(e) {
    this.$$set({ container: e }), $();
  }
  get scale() {
    return this.$$.ctx[13];
  }
  set scale(e) {
    this.$$set({ scale: e }), $();
  }
  get min_width() {
    return this.$$.ctx[14];
  }
  set min_width(e) {
    this.$$set({ min_width: e }), $();
  }
  get loading_status() {
    return this.$$.ctx[1];
  }
  set loading_status(e) {
    this.$$set({ loading_status: e }), $();
  }
  get show_share_button() {
    return this.$$.ctx[15];
  }
  set show_share_button(e) {
    this.$$set({ show_share_button: e }), $();
  }
  get mode() {
    return this.$$.ctx[16];
  }
  set mode(e) {
    this.$$set({ mode: e }), $();
  }
  get source() {
    return this.$$.ctx[17];
  }
  set source(e) {
    this.$$set({ source: e }), $();
  }
  get tool() {
    return this.$$.ctx[18];
  }
  set tool(e) {
    this.$$set({ tool: e }), $();
  }
  get streaming() {
    return this.$$.ctx[19];
  }
  set streaming(e) {
    this.$$set({ streaming: e }), $();
  }
  get pending() {
    return this.$$.ctx[20];
  }
  set pending(e) {
    this.$$set({ pending: e }), $();
  }
  get mirror_webcam() {
    return this.$$.ctx[21];
  }
  set mirror_webcam(e) {
    this.$$set({ mirror_webcam: e }), $();
  }
  get shape() {
    return this.$$.ctx[22];
  }
  set shape(e) {
    this.$$set({ shape: e }), $();
  }
  get brush_radius() {
    return this.$$.ctx[23];
  }
  set brush_radius(e) {
    this.$$set({ brush_radius: e }), $();
  }
  get brush_color() {
    return this.$$.ctx[24];
  }
  set brush_color(e) {
    this.$$set({ brush_color: e }), $();
  }
  get mask_opacity() {
    return this.$$.ctx[25];
  }
  set mask_opacity(e) {
    this.$$set({ mask_opacity: e }), $();
  }
  get gradio() {
    return this.$$.ctx[26];
  }
  set gradio(e) {
    this.$$set({ gradio: e }), $();
  }
}
export {
  Hg as Webcam,
  I1 as default
};
