@gradio/client 1.15.6 → 1.15.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,23 +1,23 @@
1
1
  var et = Object.defineProperty;
2
2
  var tt = (e, t, s) => t in e ? et(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
- var u = (e, t, s) => (tt(e, typeof t != "symbol" ? t + "" : t, s), s), $e = (e, t, s) => {
3
+ var u = (e, t, s) => (tt(e, typeof t != "symbol" ? t + "" : t, s), s), Se = (e, t, s) => {
4
4
  if (!t.has(e))
5
5
  throw TypeError("Cannot " + s);
6
6
  };
7
- var V = (e, t, s) => ($e(e, t, "read from private field"), s ? s.call(e) : t.get(e)), ke = (e, t, s) => {
7
+ var H = (e, t, s) => (Se(e, t, "read from private field"), s ? s.call(e) : t.get(e)), $e = (e, t, s) => {
8
8
  if (t.has(e))
9
9
  throw TypeError("Cannot add the same private member more than once");
10
10
  t instanceof WeakSet ? t.add(e) : t.set(e, s);
11
- }, Re = (e, t, s, n) => ($e(e, t, "write to private field"), n ? n.call(e, s) : t.set(e, s), s);
12
- var fe = new Intl.Collator(0, { numeric: 1 }).compare;
13
- function Pe(e, t, s) {
14
- return e = e.split("."), t = t.split("."), fe(e[0], t[0]) || fe(e[1], t[1]) || (t[2] = t.slice(2).join("."), s = /[.-]/.test(e[2] = e.slice(2).join(".")), s == /[.-]/.test(t[2]) ? fe(e[2], t[2]) : s ? -1 : 1);
11
+ }, ke = (e, t, s, n) => (Se(e, t, "write to private field"), n ? n.call(e, s) : t.set(e, s), s);
12
+ var pe = new Intl.Collator(0, { numeric: 1 }).compare;
13
+ function Le(e, t, s) {
14
+ return e = e.split("."), t = t.split("."), pe(e[0], t[0]) || pe(e[1], t[1]) || (t[2] = t.slice(2).join("."), s = /[.-]/.test(e[2] = e.slice(2).join(".")), s == /[.-]/.test(t[2]) ? pe(e[2], t[2]) : s ? -1 : 1);
15
15
  }
16
- const st = "host", je = "queue/data", nt = "queue/join", Oe = "upload", it = "login", Ne = "config", ot = "info", rt = "runtime", at = "sleeptime", ct = "heartbeat", lt = "component_server", ut = "reset", pt = "cancel", ft = "app_id", ht = "https://gradio-space-api-fetcher-v2.hf.space/api", xe = "This application is currently busy. Please try again. ", J = "Connection errored out. ", z = "Could not resolve app config. ", dt = "Could not get space status. ", _t = "Could not get API info. ", me = "Space metadata could not be loaded. ", mt = "Invalid URL. A full URL path is required.", gt = "Not authorized to access this space. ", Ie = "Invalid credentials. Could not login. ", wt = "Login credentials are required to access this space.", yt = "File system access is only available in Node.js environments", Ue = "Root URL not found in client config", bt = "Error uploading file";
16
+ const st = "host", Pe = "queue/data", nt = "queue/join", Re = "upload", it = "login", Oe = "config", ot = "info", rt = "runtime", at = "sleeptime", ct = "heartbeat", lt = "component_server", ut = "reset", pt = "cancel", ft = "app_id", ht = "https://gradio-space-api-fetcher-v2.hf.space/api", je = "This application is currently busy. Please try again. ", M = "Connection errored out. ", z = "Could not resolve app config. ", dt = "Could not get space status. ", _t = "Could not get API info. ", _e = "Space metadata could not be loaded. ", mt = "Invalid URL. A full URL path is required.", gt = "Not authorized to access this space. ", xe = "Invalid credentials. Could not login. ", wt = "Login credentials are required to access this space.", yt = "File system access is only available in Node.js environments", Ie = "Root URL not found in client config", bt = "Error uploading file";
17
17
  function vt(e, t, s) {
18
18
  return t.startsWith("http://") || t.startsWith("https://") ? s ? e : t : e + t;
19
19
  }
20
- async function Te(e, t, s) {
20
+ async function Ne(e, t, s) {
21
21
  try {
22
22
  return (await (await fetch(`https://huggingface.co/api/spaces/${e}/jwt`, {
23
23
  headers: {
@@ -40,9 +40,9 @@ async function St(e) {
40
40
  if (t["Content-Type"] = "application/json", typeof window < "u" && window.gradio_config && location.origin !== "http://localhost:9876" && !window.gradio_config.dev_mode)
41
41
  return window.gradio_config.current_page && (e = e.substring(0, e.lastIndexOf("/"))), window.gradio_config.root = e, { ...window.gradio_config };
42
42
  if (e) {
43
- let s = Be(
43
+ let s = ze(
44
44
  e,
45
- this.deep_link ? Ne + "?deep_link=" + this.deep_link : Ne
45
+ this.deep_link ? Oe + "?deep_link=" + this.deep_link : Oe
46
46
  );
47
47
  const n = await this.fetch(s, {
48
48
  headers: t,
@@ -58,7 +58,7 @@ async function $t(e, t, s) {
58
58
  const r = await e.json(), o = (n = r == null ? void 0 : r.detail) == null ? void 0 : n.auth_message;
59
59
  throw new Error(o || wt);
60
60
  } else if ((e == null ? void 0 : e.status) === 401 && s)
61
- throw new Error(Ie);
61
+ throw new Error(xe);
62
62
  if ((e == null ? void 0 : e.status) === 200) {
63
63
  let r = await e.json();
64
64
  return r.root = t, (i = r.dependencies) == null || i.forEach((o, a) => {
@@ -75,7 +75,7 @@ async function kt() {
75
75
  );
76
76
  try {
77
77
  if (this.options.auth) {
78
- const s = await qe(
78
+ const s = await Ue(
79
79
  e,
80
80
  t,
81
81
  this.options.auth,
@@ -88,7 +88,7 @@ async function kt() {
88
88
  throw Error(s.message);
89
89
  }
90
90
  }
91
- async function qe(e, t, s, n, i) {
91
+ async function Ue(e, t, s, n, i) {
92
92
  const r = new FormData();
93
93
  r.append("username", s == null ? void 0 : s[0]), r.append("password", s == null ? void 0 : s[1]);
94
94
  let o = {};
@@ -101,9 +101,9 @@ async function qe(e, t, s, n, i) {
101
101
  });
102
102
  if (a.status === 200)
103
103
  return a.headers.get("set-cookie");
104
- throw a.status === 401 ? new Error(Ie) : new Error(me);
104
+ throw a.status === 401 ? new Error(xe) : new Error(_e);
105
105
  }
106
- function he(e) {
106
+ function fe(e) {
107
107
  if (e.startsWith("http")) {
108
108
  const { protocol: t, host: s, pathname: n } = new URL(e);
109
109
  return {
@@ -124,18 +124,18 @@ function he(e) {
124
124
  host: new URL(e).host
125
125
  };
126
126
  }
127
- const ze = (e) => {
127
+ const qe = (e) => {
128
128
  let t = [];
129
129
  return e.split(/,(?=\s*[^\s=;]+=[^\s=;]+)/).forEach((n) => {
130
130
  const [i, r] = n.split(";")[0].split("=");
131
131
  i && r && t.push(`${i.trim()}=${r.trim()}`);
132
132
  }), t;
133
- }, ge = /^[a-zA-Z0-9_\-\.]+\/[a-zA-Z0-9_\-\.]+$/, Rt = /.*hf\.space\/{0,1}.*$/;
133
+ }, me = /^[a-zA-Z0-9_\-\.]+\/[a-zA-Z0-9_\-\.]+$/, Rt = /.*hf\.space\/{0,1}.*$/;
134
134
  async function te(e, t) {
135
135
  const s = {};
136
136
  t && (s.Authorization = `Bearer ${t}`);
137
137
  const n = e.trim().replace(/\/$/, "");
138
- if (ge.test(n))
138
+ if (me.test(n))
139
139
  try {
140
140
  const r = (await (await fetch(
141
141
  `https://huggingface.co/api/spaces/${n}/${st}`,
@@ -143,13 +143,13 @@ async function te(e, t) {
143
143
  )).json()).host;
144
144
  return {
145
145
  space_id: e,
146
- ...he(r)
146
+ ...fe(r)
147
147
  };
148
148
  } catch {
149
- throw new Error(me);
149
+ throw new Error(_e);
150
150
  }
151
151
  if (Rt.test(n)) {
152
- const { ws_protocol: i, http_protocol: r, host: o } = he(n);
152
+ const { ws_protocol: i, http_protocol: r, host: o } = fe(n);
153
153
  return {
154
154
  space_id: o.split("/")[0].replace(".hf.space", ""),
155
155
  ws_protocol: i,
@@ -159,10 +159,10 @@ async function te(e, t) {
159
159
  }
160
160
  return {
161
161
  space_id: !1,
162
- ...he(n)
162
+ ...fe(n)
163
163
  };
164
164
  }
165
- const Be = (...e) => {
165
+ const ze = (...e) => {
166
166
  try {
167
167
  return e.reduce((t, s) => (t = t.replace(/\/+$/, ""), s = s.replace(/^\/+/, ""), new URL(s, t + "/").toString()));
168
168
  } catch {
@@ -182,16 +182,16 @@ function Ot(e, t, s) {
182
182
  (c) => c.api_name === r || c.api_name === r.replace("/", "")
183
183
  )) == null ? void 0 : p.id) || s[r.replace("/", "")] || -1, h = l !== -1 ? (g = t.dependencies.find((c) => c.id == l)) == null ? void 0 : g.types : { generator: !1, cancel: !1 };
184
184
  if (l !== -1 && ((B = (E = t.dependencies.find((c) => c.id == l)) == null ? void 0 : E.inputs) == null ? void 0 : B.length) !== o.length) {
185
- const c = t.dependencies.find((_) => _.id == l).inputs.map(
186
- (_) => {
187
- var N;
188
- return (N = t.components.find((C) => C.id === _)) == null ? void 0 : N.type;
185
+ const c = t.dependencies.find((d) => d.id == l).inputs.map(
186
+ (d) => {
187
+ var O;
188
+ return (O = t.components.find((D) => D.id === d)) == null ? void 0 : O.type;
189
189
  }
190
190
  );
191
191
  try {
192
- c.forEach((_, N) => {
193
- if (_ === "state") {
194
- const C = {
192
+ c.forEach((d, O) => {
193
+ if (d === "state") {
194
+ const D = {
195
195
  component: "state",
196
196
  example: null,
197
197
  parameter_default: null,
@@ -199,17 +199,17 @@ function Ot(e, t, s) {
199
199
  parameter_name: null,
200
200
  hidden: !0
201
201
  };
202
- o.splice(N, 0, C);
202
+ o.splice(O, 0, D);
203
203
  }
204
204
  });
205
- } catch (_) {
206
- console.error(_);
205
+ } catch (d) {
206
+ console.error(d);
207
207
  }
208
208
  }
209
- const m = (c, _, N, C) => ({
209
+ const m = (c, d, O, D) => ({
210
210
  ...c,
211
- description: Tt(c == null ? void 0 : c.type, N),
212
- type: Nt(c == null ? void 0 : c.type, _, N, C) || ""
211
+ description: Tt(c == null ? void 0 : c.type, O),
212
+ type: Nt(c == null ? void 0 : c.type, d, O, D) || ""
213
213
  });
214
214
  n[i][r] = {
215
215
  parameters: o.map(
@@ -249,7 +249,7 @@ function Nt(e, t, s, n) {
249
249
  function Tt(e, t) {
250
250
  return t === "GallerySerializable" ? "array of [file, label] tuples" : t === "ListStringSerializable" ? "array of strings" : t === "FileSerializable" ? "array of files or single file" : e == null ? void 0 : e.description;
251
251
  }
252
- function de(e, t) {
252
+ function he(e, t) {
253
253
  switch (e.msg) {
254
254
  case "send_data":
255
255
  return { type: "data" };
@@ -260,7 +260,7 @@ function de(e, t) {
260
260
  type: "update",
261
261
  status: {
262
262
  queue: !0,
263
- message: xe,
263
+ message: je,
264
264
  stage: "error",
265
265
  code: e.code,
266
266
  success: e.success
@@ -387,7 +387,7 @@ function de(e, t) {
387
387
  }
388
388
  return { type: "none", status: { stage: "error", queue: !0 } };
389
389
  }
390
- const Dt = (e = [], t) => {
390
+ const Ct = (e = [], t) => {
391
391
  const s = t ? t.parameters : [];
392
392
  if (Array.isArray(e))
393
393
  return t && s.length > 0 && e.length > s.length && console.warn("Too many arguments provided for the endpoint."), e;
@@ -413,7 +413,7 @@ const Dt = (e = [], t) => {
413
413
  );
414
414
  }), n;
415
415
  };
416
- async function Ct() {
416
+ async function Dt() {
417
417
  if (this.api_info)
418
418
  return this.api_info;
419
419
  const { hf_token: e } = this.options, { config: t } = this, s = { "Content-Type": "application/json" };
@@ -423,7 +423,7 @@ async function Ct() {
423
423
  if (typeof window < "u" && window.gradio_api_info)
424
424
  i = window.gradio_api_info;
425
425
  else {
426
- if (Pe((t == null ? void 0 : t.version) || "2.0.0", "3.30") < 0)
426
+ if (Le((t == null ? void 0 : t.version) || "2.0.0", "3.30") < 0)
427
427
  n = await this.fetch(ht, {
428
428
  method: "POST",
429
429
  body: JSON.stringify({
@@ -434,14 +434,14 @@ async function Ct() {
434
434
  credentials: "include"
435
435
  });
436
436
  else {
437
- const r = Be(t.root, this.api_prefix, ot);
437
+ const r = ze(t.root, this.api_prefix, ot);
438
438
  n = await this.fetch(r, {
439
439
  headers: s,
440
440
  credentials: "include"
441
441
  });
442
442
  }
443
443
  if (!n.ok)
444
- throw new Error(J);
444
+ throw new Error(M);
445
445
  i = await n.json();
446
446
  }
447
447
  return "api" in i && (i = i.api), i.named_endpoints["/predict"] && !i.unnamed_endpoints[0] && (i.unnamed_endpoints[0] = i.named_endpoints["/predict"]), Ot(i, t, this.api_map);
@@ -461,7 +461,7 @@ async function At(e, t, s) {
461
461
  m.append("files", g);
462
462
  });
463
463
  try {
464
- const g = s ? `${e}${this.api_prefix}/${Oe}?upload_id=${s}` : `${e}${this.api_prefix}/${Oe}`;
464
+ const g = s ? `${e}${this.api_prefix}/${Re}?upload_id=${s}` : `${e}${this.api_prefix}/${Re}`;
465
465
  o = await this.fetch(g, {
466
466
  method: "POST",
467
467
  body: m,
@@ -469,7 +469,7 @@ async function At(e, t, s) {
469
469
  credentials: "include"
470
470
  });
471
471
  } catch (g) {
472
- throw new Error(J + g.message);
472
+ throw new Error(M + g.message);
473
473
  }
474
474
  if (!o.ok) {
475
475
  const g = await o.text();
@@ -542,7 +542,7 @@ class se {
542
542
  this.path = t, this.url = s, this.orig_name = n, this.size = i, this.blob = s ? void 0 : r, this.is_stream = o, this.mime_type = a, this.alt_text = l, this.b64 = h;
543
543
  }
544
544
  }
545
- class Fe {
545
+ class Be {
546
546
  constructor(t, s) {
547
547
  u(this, "type");
548
548
  u(this, "command");
@@ -552,7 +552,7 @@ class Fe {
552
552
  }
553
553
  }
554
554
  const Pt = typeof process < "u" && process.versions && process.versions.node;
555
- function De(e, t, s) {
555
+ function Te(e, t, s) {
556
556
  for (; s.length > 1; ) {
557
557
  const i = s.shift();
558
558
  if (typeof i == "string" || typeof i == "number")
@@ -566,7 +566,7 @@ function De(e, t, s) {
566
566
  else
567
567
  throw new Error("Invalid key type");
568
568
  }
569
- async function _e(e, t = void 0, s = [], n = !1, i = void 0) {
569
+ async function de(e, t = void 0, s = [], n = !1, i = void 0) {
570
570
  if (Array.isArray(e)) {
571
571
  let r = [];
572
572
  return await Promise.all(
@@ -574,7 +574,7 @@ async function _e(e, t = void 0, s = [], n = !1, i = void 0) {
574
574
  var m;
575
575
  let l = s.slice();
576
576
  l.push(String(a));
577
- const h = await _e(
577
+ const h = await de(
578
578
  e[a],
579
579
  n ? ((m = i == null ? void 0 : i.parameters[a]) == null ? void 0 : m.component) || void 0 : t,
580
580
  l,
@@ -598,7 +598,7 @@ async function _e(e, t = void 0, s = [], n = !1, i = void 0) {
598
598
  for (const o of Object.keys(e)) {
599
599
  const a = [...s, o], l = e[o];
600
600
  r = r.concat(
601
- await _e(
601
+ await de(
602
602
  l,
603
603
  void 0,
604
604
  a,
@@ -635,7 +635,7 @@ function cs(e) {
635
635
  meta: { _type: "gradio.FileData" }
636
636
  };
637
637
  if (Pt)
638
- return new Fe("upload_file", {
638
+ return new Be("upload_file", {
639
639
  path: e,
640
640
  name: e,
641
641
  orig_path: e
@@ -652,7 +652,7 @@ function cs(e) {
652
652
  "Invalid input: must be a URL, File, Blob, or Buffer object."
653
653
  );
654
654
  }
655
- function X(e, t, s, n, i = !1) {
655
+ function K(e, t, s, n, i = !1) {
656
656
  if (n === "input" && !i)
657
657
  throw new Error("Invalid code path. Cannot skip state inputs for input.");
658
658
  if (n === "output" && i)
@@ -683,7 +683,7 @@ function X(e, t, s, n, i = !1) {
683
683
  async function It(e, t, s) {
684
684
  const n = this;
685
685
  await Ut(n, t);
686
- const i = await _e(
686
+ const i = await de(
687
687
  t,
688
688
  void 0,
689
689
  [],
@@ -704,29 +704,29 @@ async function It(e, t, s) {
704
704
  })
705
705
  )).forEach(({ path: o, file_url: a, type: l, name: h }) => {
706
706
  if (l === "Gallery")
707
- De(t, a, o);
707
+ Te(t, a, o);
708
708
  else if (a) {
709
709
  const m = new se({ path: a, orig_name: h });
710
- De(t, m, o);
710
+ Te(t, m, o);
711
711
  }
712
712
  }), t;
713
713
  }
714
714
  async function Ut(e, t) {
715
715
  var n, i;
716
716
  if (!(((n = e.config) == null ? void 0 : n.root) || ((i = e.config) == null ? void 0 : i.root_url)))
717
- throw new Error(Ue);
718
- await Ge(e, t);
717
+ throw new Error(Ie);
718
+ await Fe(e, t);
719
719
  }
720
- async function Ge(e, t, s = []) {
720
+ async function Fe(e, t, s = []) {
721
721
  for (const n in t)
722
- t[n] instanceof Fe ? await qt(e, t, n) : typeof t[n] == "object" && t[n] !== null && await Ge(e, t[n], [...s, n]);
722
+ t[n] instanceof Be ? await qt(e, t, n) : typeof t[n] == "object" && t[n] !== null && await Fe(e, t[n], [...s, n]);
723
723
  }
724
724
  async function qt(e, t, s) {
725
725
  var r, o;
726
726
  let n = t[s];
727
727
  const i = ((r = e.config) == null ? void 0 : r.root) || ((o = e.config) == null ? void 0 : o.root_url);
728
728
  if (!i)
729
- throw new Error(Ue);
729
+ throw new Error(Ie);
730
730
  try {
731
731
  let a, l;
732
732
  if (typeof process < "u" && process.versions && process.versions.node) {
@@ -757,7 +757,7 @@ async function zt(e, t, s) {
757
757
  credentials: "include"
758
758
  });
759
759
  } catch {
760
- return [{ error: J }, 500];
760
+ return [{ error: M }, 500];
761
761
  }
762
762
  let r, o;
763
763
  try {
@@ -786,7 +786,7 @@ async function Bt(e, t = {}) {
786
786
  l.type === "data" && (n && i(a), s = !0, a = l), l.type === "status" && (l.stage === "error" && r(l), l.stage === "complete" && (n = !0, s && i(a)));
787
787
  });
788
788
  }
789
- async function Y(e, t, s) {
789
+ async function Q(e, t, s) {
790
790
  let n = t === "subdomain" ? `https://huggingface.co/api/spaces/by-subdomain/${e}` : `https://huggingface.co/api/spaces/${e}`, i, r;
791
791
  try {
792
792
  if (i = await fetch(n), r = i.status, r !== 200)
@@ -816,7 +816,7 @@ async function Y(e, t, s) {
816
816
  message: "Space is asleep. Waking it up...",
817
817
  detail: o
818
818
  }), setTimeout(() => {
819
- Y(e, t, s);
819
+ Q(e, t, s);
820
820
  }, 1e3);
821
821
  break;
822
822
  case "PAUSED":
@@ -844,7 +844,7 @@ async function Y(e, t, s) {
844
844
  message: "Space is building...",
845
845
  detail: o
846
846
  }), setTimeout(() => {
847
- Y(e, t, s);
847
+ Q(e, t, s);
848
848
  }, 1e3);
849
849
  break;
850
850
  case "APP_STARTING":
@@ -854,7 +854,7 @@ async function Y(e, t, s) {
854
854
  message: "Space is starting...",
855
855
  detail: o
856
856
  }), setTimeout(() => {
857
- Y(e, t, s);
857
+ Q(e, t, s);
858
858
  }, 1e3);
859
859
  break;
860
860
  default:
@@ -868,16 +868,16 @@ async function Y(e, t, s) {
868
868
  break;
869
869
  }
870
870
  }
871
- const Me = async (e, t) => {
871
+ const Ge = async (e, t) => {
872
872
  let s = 0;
873
873
  const n = 12, i = 5e3;
874
874
  return new Promise((r) => {
875
- Y(
875
+ Q(
876
876
  e,
877
- ge.test(e) ? "space_name" : "subdomain",
877
+ me.test(e) ? "space_name" : "subdomain",
878
878
  (o) => {
879
879
  t(o), o.status === "running" || o.status === "error" || o.status === "paused" || o.status === "space_error" ? r() : (o.status === "sleeping" || o.status === "building") && (s < n ? (s++, setTimeout(() => {
880
- Me(e, t).then(r);
880
+ Ge(e, t).then(r);
881
881
  }, i)) : r());
882
882
  }
883
883
  );
@@ -936,7 +936,7 @@ async function Mt(e, t, s) {
936
936
  throw new Error(r.message);
937
937
  }
938
938
  }
939
- const Ae = [
939
+ const De = [
940
940
  "cpu-basic",
941
941
  "cpu-upgrade",
942
942
  "cpu-xl",
@@ -953,9 +953,9 @@ const Ae = [
953
953
  ];
954
954
  async function Jt(e, t) {
955
955
  const { hf_token: s, private: n, hardware: i, timeout: r, auth: o } = t;
956
- if (i && !Ae.includes(i))
956
+ if (i && !De.includes(i))
957
957
  throw new Error(
958
- `Invalid hardware type provided. Valid types are: ${Ae.map((_) => `"${_}"`).join(",")}.`
958
+ `Invalid hardware type provided. Valid types are: ${De.map((d) => `"${d}"`).join(",")}.`
959
959
  );
960
960
  const { http_protocol: a, host: l } = await te(
961
961
  e,
@@ -963,13 +963,13 @@ async function Jt(e, t) {
963
963
  );
964
964
  let h = null;
965
965
  if (o) {
966
- const _ = await qe(
966
+ const d = await Ue(
967
967
  a,
968
968
  l,
969
969
  o,
970
970
  fetch
971
971
  );
972
- _ && (h = ze(_));
972
+ d && (h = qe(d));
973
973
  }
974
974
  const m = {
975
975
  Authorization: `Bearer ${s}`,
@@ -984,13 +984,13 @@ async function Jt(e, t) {
984
984
  let B;
985
985
  try {
986
986
  i || (B = await Gt(e, s));
987
- } catch (_) {
988
- throw Error(me + _.message);
987
+ } catch (d) {
988
+ throw Error(_e + d.message);
989
989
  }
990
990
  const c = i || B || "cpu-basic";
991
991
  E.hardware = c;
992
992
  try {
993
- const _ = await fetch(
993
+ const d = await fetch(
994
994
  `https://huggingface.co/api/spaces/${e}/duplicate`,
995
995
  {
996
996
  method: "POST",
@@ -998,21 +998,21 @@ async function Jt(e, t) {
998
998
  body: JSON.stringify(E)
999
999
  }
1000
1000
  );
1001
- if (_.status === 409)
1001
+ if (d.status === 409)
1002
1002
  try {
1003
1003
  return await ee.connect(`${p}/${g}`, t);
1004
- } catch (C) {
1005
- throw console.error("Failed to connect Client instance:", C), C;
1004
+ } catch (D) {
1005
+ throw console.error("Failed to connect Client instance:", D), D;
1006
1006
  }
1007
- else if (_.status !== 200)
1008
- throw new Error(_.statusText);
1009
- const N = await _.json();
1007
+ else if (d.status !== 200)
1008
+ throw new Error(d.statusText);
1009
+ const O = await d.json();
1010
1010
  return await Mt(`${p}/${g}`, r || 300, s), await ee.connect(
1011
- Wt(N.url),
1011
+ Wt(O.url),
1012
1012
  t
1013
1013
  );
1014
- } catch (_) {
1015
- throw new Error(_);
1014
+ } catch (d) {
1015
+ throw new Error(d);
1016
1016
  }
1017
1017
  }
1018
1018
  function Wt(e) {
@@ -1026,7 +1026,7 @@ class Ht extends TransformStream {
1026
1026
  constructor(s = { allowCR: !1 }) {
1027
1027
  super({
1028
1028
  transform: (n, i) => {
1029
- for (n = V(this, I) + n; ; ) {
1029
+ for (n = H(this, I) + n; ; ) {
1030
1030
  const r = n.indexOf(`
1031
1031
  `), o = s.allowCR ? n.indexOf("\r") : -1;
1032
1032
  if (o !== -1 && o !== n.length - 1 && (r === -1 || r - 1 > o)) {
@@ -1038,16 +1038,16 @@ class Ht extends TransformStream {
1038
1038
  const a = n[r - 1] === "\r" ? r - 1 : r;
1039
1039
  i.enqueue(n.slice(0, a)), n = n.slice(r + 1);
1040
1040
  }
1041
- Re(this, I, n);
1041
+ ke(this, I, n);
1042
1042
  },
1043
1043
  flush: (n) => {
1044
- if (V(this, I) === "")
1044
+ if (H(this, I) === "")
1045
1045
  return;
1046
- const i = s.allowCR && V(this, I).endsWith("\r") ? V(this, I).slice(0, -1) : V(this, I);
1046
+ const i = s.allowCR && H(this, I).endsWith("\r") ? H(this, I).slice(0, -1) : H(this, I);
1047
1047
  n.enqueue(i);
1048
1048
  }
1049
1049
  });
1050
- ke(this, I, "");
1050
+ $e(this, I, "");
1051
1051
  }
1052
1052
  }
1053
1053
  I = new WeakMap();
@@ -1063,7 +1063,7 @@ function Zt(e) {
1063
1063
  e.substring(n + s[0].length)
1064
1064
  ];
1065
1065
  }
1066
- function Le(e, t, s) {
1066
+ function Ae(e, t, s) {
1067
1067
  e.get(t) || e.set(t, s);
1068
1068
  }
1069
1069
  async function* Kt(e, t) {
@@ -1086,7 +1086,7 @@ async function* Kt(e, t) {
1086
1086
  }
1087
1087
  async function Qt(e, t) {
1088
1088
  let s = new Request(e, t);
1089
- Le(s.headers, "Accept", "text/event-stream"), Le(s.headers, "Content-Type", "application/json");
1089
+ Ae(s.headers, "Accept", "text/event-stream"), Ae(s.headers, "Content-Type", "application/json");
1090
1090
  let n = await fetch(s);
1091
1091
  if (!n.ok)
1092
1092
  throw n;
@@ -1107,7 +1107,7 @@ async function Xt() {
1107
1107
  n.open = !0;
1108
1108
  let a = null, l = new URLSearchParams({
1109
1109
  session_hash: this.session_hash
1110
- }).toString(), h = new URL(`${i.root}${this.api_prefix}/${je}?${l}`);
1110
+ }).toString(), h = new URL(`${i.root}${this.api_prefix}/${Pe}?${l}`);
1111
1111
  if (r && h.searchParams.set("__sign", r), a = this.stream(h), !a) {
1112
1112
  console.warn("Cannot connect to SSE endpoint: " + h.toString());
1113
1113
  return;
@@ -1115,7 +1115,7 @@ async function Xt() {
1115
1115
  a.onmessage = async function(m) {
1116
1116
  let p = JSON.parse(m.data);
1117
1117
  if (p.msg === "close_stream") {
1118
- we(n, o.abort_controller);
1118
+ ge(n, o.abort_controller);
1119
1119
  return;
1120
1120
  }
1121
1121
  const g = p.event_id;
@@ -1138,13 +1138,13 @@ async function Xt() {
1138
1138
  Object.keys(e).map(
1139
1139
  (p) => e[p]({
1140
1140
  msg: "broken_connection",
1141
- message: J
1141
+ message: M
1142
1142
  })
1143
1143
  )
1144
1144
  );
1145
1145
  };
1146
1146
  }
1147
- function we(e, t) {
1147
+ function ge(e, t) {
1148
1148
  e && (e.open = !1, t == null || t.abort());
1149
1149
  }
1150
1150
  function Yt(e, t, s) {
@@ -1231,81 +1231,70 @@ function ns(e, t = {}, s, n, i) {
1231
1231
  var r;
1232
1232
  try {
1233
1233
  let o = function(w) {
1234
- (i || Ze[w.type]) && m(w);
1234
+ (i || Ve[w.type]) && m(w);
1235
1235
  }, a = function() {
1236
- for (le = !0; K.length > 0; )
1237
- K.shift()({
1236
+ for (Qe = !0; Z.length > 0; )
1237
+ Z.shift()({
1238
1238
  value: void 0,
1239
1239
  done: !0
1240
1240
  });
1241
1241
  }, l = function(w) {
1242
- le || (K.length > 0 ? K.shift()(w) : ue.push(w));
1242
+ Z.length > 0 ? Z.shift()(w) : le.push(w);
1243
1243
  }, h = function(w) {
1244
1244
  l(is(w)), a();
1245
1245
  }, m = function(w) {
1246
1246
  l({ value: w, done: !1 });
1247
1247
  }, p = function() {
1248
- return ue.length > 0 ? Promise.resolve(ue.shift()) : le ? Promise.resolve({ value: void 0, done: !0 }) : new Promise((w) => K.push(w));
1248
+ return le.length > 0 ? Promise.resolve(le.shift()) : new Promise((w) => Z.push(w));
1249
1249
  };
1250
1250
  const { hf_token: g } = this.options, {
1251
1251
  fetch: E,
1252
1252
  app_reference: B,
1253
1253
  config: c,
1254
- session_hash: _,
1255
- api_info: N,
1256
- api_map: C,
1254
+ session_hash: d,
1255
+ api_info: O,
1256
+ api_map: D,
1257
1257
  stream_status: ne,
1258
1258
  pending_stream_messages: ie,
1259
1259
  pending_diff_streams: oe,
1260
1260
  event_callbacks: re,
1261
- unclosed_events: Je,
1261
+ unclosed_events: Me,
1262
1262
  post_data: ae,
1263
1263
  options: F,
1264
- api_prefix: W
1265
- } = this, We = this;
1266
- if (!N)
1264
+ api_prefix: J
1265
+ } = this, Je = this;
1266
+ if (!O)
1267
1267
  throw new Error("No API found");
1268
1268
  if (!c)
1269
1269
  throw new Error("Could not resolve app config");
1270
- let { fn_index: f, endpoint_info: ye, dependency: H } = os(
1271
- N,
1270
+ let { fn_index: f, endpoint_info: we, dependency: W } = os(
1271
+ O,
1272
1272
  e,
1273
- C,
1273
+ D,
1274
1274
  c
1275
- ), He = Dt(t, ye), R, T, j = c.protocol ?? "ws", be = "", Ve = () => be;
1276
- const d = typeof e == "number" ? "/predict" : e;
1277
- let Z, S = null, O = !1, ce = {}, G = typeof window < "u" && typeof document < "u" ? new URLSearchParams(window.location.search).toString() : "";
1278
- const Ze = ((r = F == null ? void 0 : F.events) == null ? void 0 : r.reduce(
1275
+ ), We = Ct(t, we), R, N, j = c.protocol ?? "ws", ye = "", He = () => ye;
1276
+ const _ = typeof e == "number" ? "/predict" : e;
1277
+ let V, S = null, T = !1, ce = {}, G = typeof window < "u" && typeof document < "u" ? new URLSearchParams(window.location.search).toString() : "";
1278
+ const Ve = ((r = F == null ? void 0 : F.events) == null ? void 0 : r.reduce(
1279
1279
  (w, x) => (w[x] = !0, w),
1280
1280
  {}
1281
1281
  )) || {};
1282
- async function Ke() {
1283
- const w = {
1284
- stage: "complete",
1285
- queue: !1,
1286
- time: /* @__PURE__ */ new Date()
1287
- };
1288
- O = w, o({
1289
- ...w,
1290
- type: "status",
1291
- endpoint: d,
1292
- fn_index: f
1293
- });
1294
- let x = {}, M = {};
1282
+ async function Ze() {
1283
+ let w = {}, x = {};
1295
1284
  j === "ws" ? (R && R.readyState === 0 ? R.addEventListener("open", () => {
1296
1285
  R.close();
1297
- }) : R.close(), x = { fn_index: f, session_hash: _ }) : (x = { event_id: S }, M = { event_id: S, session_hash: _, fn_index: f });
1286
+ }) : R.close(), w = { fn_index: f, session_hash: d }) : (w = { event_id: S }, x = { event_id: S, session_hash: d, fn_index: f });
1298
1287
  try {
1299
1288
  if (!c)
1300
1289
  throw new Error("Could not resolve app config");
1301
- "event_id" in M && await E(`${c.root}${W}/${pt}`, {
1290
+ "event_id" in x && await E(`${c.root}${J}/${pt}`, {
1302
1291
  headers: { "Content-Type": "application/json" },
1303
1292
  method: "POST",
1304
- body: JSON.stringify(M)
1305
- }), await E(`${c.root}${W}/${ut}`, {
1293
+ body: JSON.stringify(x)
1294
+ }), await E(`${c.root}${J}/${ut}`, {
1306
1295
  headers: { "Content-Type": "application/json" },
1307
1296
  method: "POST",
1308
- body: JSON.stringify(x)
1297
+ body: JSON.stringify(w)
1309
1298
  });
1310
1299
  } catch {
1311
1300
  console.warn(
@@ -1313,10 +1302,10 @@ function ns(e, t = {}, s, n, i) {
1313
1302
  );
1314
1303
  }
1315
1304
  }
1316
- const Qe = async (w) => {
1305
+ const Ke = async (w) => {
1317
1306
  await this._resolve_heartbeat(w);
1318
1307
  };
1319
- async function ve(w) {
1308
+ async function be(w) {
1320
1309
  if (!c)
1321
1310
  return;
1322
1311
  let x = w.render_id;
@@ -1327,23 +1316,23 @@ function ns(e, t = {}, s, n, i) {
1327
1316
  ...c.dependencies.filter((y) => y.rendered_in !== x),
1328
1317
  ...w.dependencies
1329
1318
  ];
1330
- const M = c.components.some((y) => y.type === "state"), Q = c.dependencies.some(
1319
+ const X = c.components.some((y) => y.type === "state"), Y = c.dependencies.some(
1331
1320
  (y) => y.targets.some((U) => U[1] === "unload")
1332
1321
  );
1333
- c.connect_heartbeat = M || Q, await Qe(c), o({
1322
+ c.connect_heartbeat = X || Y, await Ke(c), o({
1334
1323
  type: "render",
1335
1324
  data: w,
1336
- endpoint: d,
1325
+ endpoint: _,
1337
1326
  fn_index: f
1338
1327
  });
1339
1328
  }
1340
- this.handle_blob(c.root, He, ye).then(
1329
+ this.handle_blob(c.root, We, we).then(
1341
1330
  async (w) => {
1342
- var Q;
1343
- if (Z = {
1344
- data: X(
1331
+ var Y;
1332
+ if (V = {
1333
+ data: K(
1345
1334
  w,
1346
- H,
1335
+ W,
1347
1336
  c.components,
1348
1337
  "input",
1349
1338
  !0
@@ -1354,26 +1343,26 @@ function ns(e, t = {}, s, n, i) {
1354
1343
  }, jt(f, c))
1355
1344
  o({
1356
1345
  type: "status",
1357
- endpoint: d,
1346
+ endpoint: _,
1358
1347
  stage: "pending",
1359
1348
  queue: !1,
1360
1349
  fn_index: f,
1361
1350
  time: /* @__PURE__ */ new Date()
1362
1351
  }), ae(
1363
- `${c.root}${W}/run${d.startsWith("/") ? d : `/${d}`}${G ? "?" + G : ""}`,
1352
+ `${c.root}${J}/run${_.startsWith("/") ? _ : `/${_}`}${G ? "?" + G : ""}`,
1364
1353
  {
1365
- ...Z,
1366
- session_hash: _
1354
+ ...V,
1355
+ session_hash: d
1367
1356
  }
1368
1357
  ).then(([y, U]) => {
1369
1358
  const q = y.data;
1370
1359
  U == 200 ? (o({
1371
1360
  type: "data",
1372
- endpoint: d,
1361
+ endpoint: _,
1373
1362
  fn_index: f,
1374
- data: X(
1363
+ data: K(
1375
1364
  q,
1376
- H,
1365
+ W,
1377
1366
  c.components,
1378
1367
  "output",
1379
1368
  F.with_null_state
@@ -1381,9 +1370,9 @@ function ns(e, t = {}, s, n, i) {
1381
1370
  time: /* @__PURE__ */ new Date(),
1382
1371
  event_data: s,
1383
1372
  trigger_id: n
1384
- }), y.render_config && ve(y.render_config), o({
1373
+ }), y.render_config && be(y.render_config), o({
1385
1374
  type: "status",
1386
- endpoint: d,
1375
+ endpoint: _,
1387
1376
  fn_index: f,
1388
1377
  stage: "complete",
1389
1378
  eta: y.average_duration,
@@ -1392,7 +1381,7 @@ function ns(e, t = {}, s, n, i) {
1392
1381
  })) : o({
1393
1382
  type: "status",
1394
1383
  stage: "error",
1395
- endpoint: d,
1384
+ endpoint: _,
1396
1385
  fn_index: f,
1397
1386
  message: y.error,
1398
1387
  queue: !1,
@@ -1403,7 +1392,7 @@ function ns(e, t = {}, s, n, i) {
1403
1392
  type: "status",
1404
1393
  stage: "error",
1405
1394
  message: y.message,
1406
- endpoint: d,
1395
+ endpoint: _,
1407
1396
  fn_index: f,
1408
1397
  queue: !1,
1409
1398
  time: /* @__PURE__ */ new Date()
@@ -1418,7 +1407,7 @@ function ns(e, t = {}, s, n, i) {
1418
1407
  type: "status",
1419
1408
  stage: "pending",
1420
1409
  queue: !0,
1421
- endpoint: d,
1410
+ endpoint: _,
1422
1411
  fn_index: f,
1423
1412
  time: /* @__PURE__ */ new Date()
1424
1413
  });
@@ -1434,37 +1423,37 @@ function ns(e, t = {}, s, n, i) {
1434
1423
  type: "status",
1435
1424
  stage: "error",
1436
1425
  broken: !0,
1437
- message: J,
1426
+ message: M,
1438
1427
  queue: !0,
1439
- endpoint: d,
1428
+ endpoint: _,
1440
1429
  fn_index: f,
1441
1430
  time: /* @__PURE__ */ new Date()
1442
1431
  });
1443
1432
  }, R.onmessage = function(A) {
1444
- const k = JSON.parse(A.data), { type: $, status: v, data: D } = de(
1433
+ const k = JSON.parse(A.data), { type: $, status: v, data: C } = he(
1445
1434
  k,
1446
1435
  ce[f]
1447
1436
  );
1448
- if ($ === "update" && v && !O)
1437
+ if ($ === "update" && v && !T)
1449
1438
  o({
1450
1439
  type: "status",
1451
- endpoint: d,
1440
+ endpoint: _,
1452
1441
  fn_index: f,
1453
1442
  time: /* @__PURE__ */ new Date(),
1454
1443
  ...v
1455
1444
  }), v.stage === "error" && R.close();
1456
1445
  else if ($ === "hash") {
1457
- R.send(JSON.stringify({ fn_index: f, session_hash: _ }));
1446
+ R.send(JSON.stringify({ fn_index: f, session_hash: d }));
1458
1447
  return;
1459
1448
  } else
1460
- $ === "data" ? R.send(JSON.stringify({ ...Z, session_hash: _ })) : $ === "complete" ? O = v : $ === "log" ? o({
1449
+ $ === "data" ? R.send(JSON.stringify({ ...V, session_hash: d })) : $ === "complete" ? T = v : $ === "log" ? o({
1461
1450
  type: "log",
1462
- title: D.title,
1463
- log: D.log,
1464
- level: D.level,
1465
- endpoint: d,
1466
- duration: D.duration,
1467
- visible: D.visible,
1451
+ title: C.title,
1452
+ log: C.log,
1453
+ level: C.level,
1454
+ endpoint: _,
1455
+ duration: C.duration,
1456
+ visible: C.visible,
1468
1457
  fn_index: f
1469
1458
  }) : $ === "generating" && o({
1470
1459
  type: "status",
@@ -1472,94 +1461,94 @@ function ns(e, t = {}, s, n, i) {
1472
1461
  ...v,
1473
1462
  stage: v == null ? void 0 : v.stage,
1474
1463
  queue: !0,
1475
- endpoint: d,
1464
+ endpoint: _,
1476
1465
  fn_index: f
1477
1466
  });
1478
- D && (o({
1467
+ C && (o({
1479
1468
  type: "data",
1480
1469
  time: /* @__PURE__ */ new Date(),
1481
- data: X(
1482
- D.data,
1483
- H,
1470
+ data: K(
1471
+ C.data,
1472
+ W,
1484
1473
  c.components,
1485
1474
  "output",
1486
1475
  F.with_null_state
1487
1476
  ),
1488
- endpoint: d,
1477
+ endpoint: _,
1489
1478
  fn_index: f,
1490
1479
  event_data: s,
1491
1480
  trigger_id: n
1492
- }), O && (o({
1481
+ }), T && (o({
1493
1482
  type: "status",
1494
1483
  time: /* @__PURE__ */ new Date(),
1495
- ...O,
1484
+ ...T,
1496
1485
  stage: v == null ? void 0 : v.stage,
1497
1486
  queue: !0,
1498
- endpoint: d,
1487
+ endpoint: _,
1499
1488
  fn_index: f
1500
1489
  }), R.close()));
1501
- }, Pe(c.version || "2.0.0", "3.6") < 0 && addEventListener(
1490
+ }, Le(c.version || "2.0.0", "3.6") < 0 && addEventListener(
1502
1491
  "open",
1503
- () => R.send(JSON.stringify({ hash: _ }))
1492
+ () => R.send(JSON.stringify({ hash: d }))
1504
1493
  );
1505
1494
  } else if (j == "sse") {
1506
1495
  o({
1507
1496
  type: "status",
1508
1497
  stage: "pending",
1509
1498
  queue: !0,
1510
- endpoint: d,
1499
+ endpoint: _,
1511
1500
  fn_index: f,
1512
1501
  time: /* @__PURE__ */ new Date()
1513
1502
  });
1514
- var M = new URLSearchParams({
1503
+ var X = new URLSearchParams({
1515
1504
  fn_index: f.toString(),
1516
- session_hash: _
1505
+ session_hash: d
1517
1506
  }).toString();
1518
1507
  let y = new URL(
1519
- `${c.root}${W}/${je}?${G ? G + "&" : ""}${M}`
1508
+ `${c.root}${J}/${Pe}?${G ? G + "&" : ""}${X}`
1520
1509
  );
1521
- if (this.jwt && y.searchParams.set("__sign", this.jwt), T = this.stream(y), !T)
1510
+ if (this.jwt && y.searchParams.set("__sign", this.jwt), N = this.stream(y), !N)
1522
1511
  return Promise.reject(
1523
1512
  new Error("Cannot connect to SSE endpoint: " + y.toString())
1524
1513
  );
1525
- T.onmessage = async function(U) {
1526
- const q = JSON.parse(U.data), { type: A, status: k, data: $ } = de(
1514
+ N.onmessage = async function(U) {
1515
+ const q = JSON.parse(U.data), { type: A, status: k, data: $ } = he(
1527
1516
  q,
1528
1517
  ce[f]
1529
1518
  );
1530
- if (A === "update" && k && !O)
1519
+ if (A === "update" && k && !T)
1531
1520
  o({
1532
1521
  type: "status",
1533
- endpoint: d,
1522
+ endpoint: _,
1534
1523
  fn_index: f,
1535
1524
  time: /* @__PURE__ */ new Date(),
1536
1525
  ...k
1537
- }), k.stage === "error" && (T == null || T.close(), a());
1526
+ }), k.stage === "error" && (N == null || N.close(), a());
1538
1527
  else if (A === "data") {
1539
- let [v, D] = await ae(
1540
- `${c.root}${W}/queue/data`,
1528
+ let [v, C] = await ae(
1529
+ `${c.root}${J}/queue/data`,
1541
1530
  {
1542
- ...Z,
1543
- session_hash: _,
1531
+ ...V,
1532
+ session_hash: d,
1544
1533
  event_id: S
1545
1534
  }
1546
1535
  );
1547
- D !== 200 && (o({
1536
+ C !== 200 && (o({
1548
1537
  type: "status",
1549
1538
  stage: "error",
1550
- message: J,
1539
+ message: M,
1551
1540
  queue: !0,
1552
- endpoint: d,
1541
+ endpoint: _,
1553
1542
  fn_index: f,
1554
1543
  time: /* @__PURE__ */ new Date()
1555
- }), T == null || T.close(), a());
1544
+ }), N == null || N.close(), a());
1556
1545
  } else
1557
- A === "complete" ? O = k : A === "log" ? o({
1546
+ A === "complete" ? T = k : A === "log" ? o({
1558
1547
  type: "log",
1559
1548
  title: $.title,
1560
1549
  log: $.log,
1561
1550
  level: $.level,
1562
- endpoint: d,
1551
+ endpoint: _,
1563
1552
  duration: $.duration,
1564
1553
  visible: $.visible,
1565
1554
  fn_index: f
@@ -1569,95 +1558,95 @@ function ns(e, t = {}, s, n, i) {
1569
1558
  ...k,
1570
1559
  stage: k == null ? void 0 : k.stage,
1571
1560
  queue: !0,
1572
- endpoint: d,
1561
+ endpoint: _,
1573
1562
  fn_index: f
1574
1563
  });
1575
1564
  $ && (o({
1576
1565
  type: "data",
1577
1566
  time: /* @__PURE__ */ new Date(),
1578
- data: X(
1567
+ data: K(
1579
1568
  $.data,
1580
- H,
1569
+ W,
1581
1570
  c.components,
1582
1571
  "output",
1583
1572
  F.with_null_state
1584
1573
  ),
1585
- endpoint: d,
1574
+ endpoint: _,
1586
1575
  fn_index: f,
1587
1576
  event_data: s,
1588
1577
  trigger_id: n
1589
- }), O && (o({
1578
+ }), T && (o({
1590
1579
  type: "status",
1591
1580
  time: /* @__PURE__ */ new Date(),
1592
- ...O,
1581
+ ...T,
1593
1582
  stage: k == null ? void 0 : k.stage,
1594
1583
  queue: !0,
1595
- endpoint: d,
1584
+ endpoint: _,
1596
1585
  fn_index: f
1597
- }), T == null || T.close(), a()));
1586
+ }), N == null || N.close(), a()));
1598
1587
  };
1599
1588
  } else if (j == "sse_v1" || j == "sse_v2" || j == "sse_v2.1" || j == "sse_v3") {
1600
1589
  o({
1601
1590
  type: "status",
1602
1591
  stage: "pending",
1603
1592
  queue: !0,
1604
- endpoint: d,
1593
+ endpoint: _,
1605
1594
  fn_index: f,
1606
1595
  time: /* @__PURE__ */ new Date()
1607
1596
  });
1608
1597
  let y = "";
1609
- typeof window < "u" && typeof document < "u" && (y = (Q = window == null ? void 0 : window.location) == null ? void 0 : Q.hostname);
1598
+ typeof window < "u" && typeof document < "u" && (y = (Y = window == null ? void 0 : window.location) == null ? void 0 : Y.hostname);
1610
1599
  const q = y.includes(".dev.") ? `https://moon-${y.split(".")[1]}.dev.spaces.huggingface.tech` : "https://huggingface.co";
1611
1600
  (typeof window < "u" && typeof document < "u" && window.parent != window && window.supports_zerogpu_headers ? xt("zerogpu-headers", q) : Promise.resolve(null)).then((v) => ae(
1612
- `${c.root}${W}/${nt}?${G}`,
1601
+ `${c.root}${J}/${nt}?${G}`,
1613
1602
  {
1614
- ...Z,
1615
- session_hash: _
1603
+ ...V,
1604
+ session_hash: d
1616
1605
  },
1617
1606
  v
1618
- )).then(async ([v, D]) => {
1619
- if (D === 503)
1607
+ )).then(async ([v, C]) => {
1608
+ if (C === 503)
1620
1609
  o({
1621
1610
  type: "status",
1622
1611
  stage: "error",
1623
- message: xe,
1612
+ message: je,
1624
1613
  queue: !0,
1625
- endpoint: d,
1614
+ endpoint: _,
1626
1615
  fn_index: f,
1627
1616
  time: /* @__PURE__ */ new Date()
1628
1617
  });
1629
- else if (D !== 200)
1618
+ else if (C !== 200)
1630
1619
  o({
1631
1620
  type: "status",
1632
1621
  stage: "error",
1633
1622
  broken: !0,
1634
- message: J,
1623
+ message: M,
1635
1624
  queue: !0,
1636
- endpoint: d,
1625
+ endpoint: _,
1637
1626
  fn_index: f,
1638
1627
  time: /* @__PURE__ */ new Date()
1639
1628
  });
1640
1629
  else {
1641
- S = v.event_id, be = S;
1642
- let Se = async function(pe) {
1630
+ S = v.event_id, ye = S;
1631
+ let Ee = async function(ue) {
1643
1632
  try {
1644
- const { type: L, status: b, data: P, original_msg: Xe } = de(
1645
- pe,
1633
+ const { type: L, status: b, data: P, original_msg: Xe } = he(
1634
+ ue,
1646
1635
  ce[f]
1647
1636
  );
1648
1637
  if (L == "heartbeat")
1649
1638
  return;
1650
- if (L === "update" && b && !O)
1639
+ if (L === "update" && b && !T)
1651
1640
  o({
1652
1641
  type: "status",
1653
- endpoint: d,
1642
+ endpoint: _,
1654
1643
  fn_index: f,
1655
1644
  time: /* @__PURE__ */ new Date(),
1656
1645
  original_msg: Xe,
1657
1646
  ...b
1658
1647
  });
1659
1648
  else if (L === "complete")
1660
- O = b;
1649
+ T = b;
1661
1650
  else if (L == "unexpected_error" || L == "broken_connection") {
1662
1651
  console.error("Unexpected error", b == null ? void 0 : b.message);
1663
1652
  const Ye = L === "broken_connection";
@@ -1666,7 +1655,7 @@ function ns(e, t = {}, s, n, i) {
1666
1655
  stage: "error",
1667
1656
  message: (b == null ? void 0 : b.message) || "An Unexpected Error Occurred!",
1668
1657
  queue: !0,
1669
- endpoint: d,
1658
+ endpoint: _,
1670
1659
  broken: Ye,
1671
1660
  session_not_found: b == null ? void 0 : b.session_not_found,
1672
1661
  fn_index: f,
@@ -1678,7 +1667,7 @@ function ns(e, t = {}, s, n, i) {
1678
1667
  title: P.title,
1679
1668
  log: P.log,
1680
1669
  level: P.level,
1681
- endpoint: d,
1670
+ endpoint: _,
1682
1671
  duration: P.duration,
1683
1672
  visible: P.visible,
1684
1673
  fn_index: f
@@ -1691,28 +1680,28 @@ function ns(e, t = {}, s, n, i) {
1691
1680
  ...b,
1692
1681
  stage: b == null ? void 0 : b.stage,
1693
1682
  queue: !0,
1694
- endpoint: d,
1683
+ endpoint: _,
1695
1684
  fn_index: f
1696
- }), P && H.connection !== "stream" && ["sse_v2", "sse_v2.1", "sse_v3"].includes(j) && Yt(oe, S, P));
1685
+ }), P && W.connection !== "stream" && ["sse_v2", "sse_v2.1", "sse_v3"].includes(j) && Yt(oe, S, P));
1697
1686
  P && (o({
1698
1687
  type: "data",
1699
1688
  time: /* @__PURE__ */ new Date(),
1700
- data: X(
1689
+ data: K(
1701
1690
  P.data,
1702
- H,
1691
+ W,
1703
1692
  c.components,
1704
1693
  "output",
1705
1694
  F.with_null_state
1706
1695
  ),
1707
- endpoint: d,
1696
+ endpoint: _,
1708
1697
  fn_index: f
1709
- }), P.render_config && await ve(P.render_config), O && (o({
1698
+ }), P.render_config && await be(P.render_config), T && (o({
1710
1699
  type: "status",
1711
1700
  time: /* @__PURE__ */ new Date(),
1712
- ...O,
1701
+ ...T,
1713
1702
  stage: b == null ? void 0 : b.stage,
1714
1703
  queue: !0,
1715
- endpoint: d,
1704
+ endpoint: _,
1716
1705
  fn_index: f
1717
1706
  }), a())), ((b == null ? void 0 : b.stage) === "complete" || (b == null ? void 0 : b.stage) === "error") && (re[S] && delete re[S], S in oe && delete oe[S]);
1718
1707
  } catch (L) {
@@ -1721,30 +1710,30 @@ function ns(e, t = {}, s, n, i) {
1721
1710
  stage: "error",
1722
1711
  message: "An Unexpected Error Occurred!",
1723
1712
  queue: !0,
1724
- endpoint: d,
1713
+ endpoint: _,
1725
1714
  fn_index: f,
1726
1715
  time: /* @__PURE__ */ new Date()
1727
- }), ["sse_v2", "sse_v2.1", "sse_v3"].includes(j) && (we(ne, We.abort_controller), ne.open = !1, a());
1716
+ }), ["sse_v2", "sse_v2.1", "sse_v3"].includes(j) && (ge(ne, Je.abort_controller), ne.open = !1, a());
1728
1717
  }
1729
1718
  };
1730
1719
  S in ie && (ie[S].forEach(
1731
- (pe) => Se(pe)
1732
- ), delete ie[S]), re[S] = Se, Je.add(S), ne.open || await this.open_stream();
1720
+ (ue) => Ee(ue)
1721
+ ), delete ie[S]), re[S] = Ee, Me.add(S), ne.open || await this.open_stream();
1733
1722
  }
1734
1723
  });
1735
1724
  }
1736
1725
  }
1737
1726
  );
1738
- let le = !1;
1739
- const ue = [], K = [], Ee = {
1740
- [Symbol.asyncIterator]: () => Ee,
1727
+ let Qe = !1;
1728
+ const le = [], Z = [], ve = {
1729
+ [Symbol.asyncIterator]: () => ve,
1741
1730
  next: p,
1742
1731
  throw: async (w) => (h(w), p()),
1743
1732
  return: async () => (a(), p()),
1744
- cancel: Ke,
1745
- event_id: Ve
1733
+ cancel: Ze,
1734
+ event_id: He
1746
1735
  };
1747
- return Ee;
1736
+ return ve;
1748
1737
  } catch (o) {
1749
1738
  throw console.error("Submit function encountered an error:", o), o;
1750
1739
  }
@@ -1806,7 +1795,7 @@ class ee {
1806
1795
  u(this, "resolve_config");
1807
1796
  u(this, "resolve_cookies");
1808
1797
  var n;
1809
- this.app_reference = t, this.deep_link = ((n = s.query_params) == null ? void 0 : n.deep_link) || null, s.events || (s.events = ["data"]), this.options = s, this.current_payload = {}, this.view_api = Ct.bind(this), this.upload_files = At.bind(this), this.handle_blob = It.bind(this), this.post_data = zt.bind(this), this.submit = ns.bind(this), this.predict = Bt.bind(this), this.open_stream = Xt.bind(this), this.resolve_config = St.bind(this), this.resolve_cookies = kt.bind(this), this.upload = Lt.bind(this), this.fetch = this.fetch.bind(this), this.handle_space_success = this.handle_space_success.bind(this), this.stream = this.stream.bind(this);
1798
+ this.app_reference = t, this.deep_link = ((n = s.query_params) == null ? void 0 : n.deep_link) || null, s.events || (s.events = ["data"]), this.options = s, this.current_payload = {}, this.view_api = Dt.bind(this), this.upload_files = At.bind(this), this.handle_blob = It.bind(this), this.post_data = zt.bind(this), this.submit = ns.bind(this), this.predict = Bt.bind(this), this.open_stream = Xt.bind(this), this.resolve_config = St.bind(this), this.resolve_cookies = kt.bind(this), this.upload = Lt.bind(this), this.fetch = this.fetch.bind(this), this.handle_space_success = this.handle_space_success.bind(this), this.stream = this.stream.bind(this);
1810
1799
  }
1811
1800
  get_url_config(t = null) {
1812
1801
  if (!this.config)
@@ -1857,11 +1846,11 @@ class ee {
1857
1846
  ), this.api_info = await this.view_api(), this.api_map = Et(((t = this.config) == null ? void 0 : t.dependencies) || []);
1858
1847
  }
1859
1848
  async _resolve_heartbeat(t) {
1860
- if (t && (this.config = t, this.api_prefix = t.api_prefix || "", this.config && this.config.connect_heartbeat && this.config.space_id && this.options.hf_token && (this.jwt = await Te(
1849
+ if (t && (this.config = t, this.api_prefix = t.api_prefix || "", this.config && this.config.connect_heartbeat && this.config.space_id && this.options.hf_token && (this.jwt = await Ne(
1861
1850
  this.config.space_id,
1862
1851
  this.options.hf_token,
1863
1852
  this.cookies
1864
- ))), t.space_id && this.options.hf_token && (this.jwt = await Te(t.space_id, this.options.hf_token)), this.config && this.config.connect_heartbeat) {
1853
+ ))), t.space_id && this.options.hf_token && (this.jwt = await Ne(t.space_id, this.options.hf_token)), this.config && this.config.connect_heartbeat) {
1865
1854
  const s = new URL(
1866
1855
  `${this.config.root}${this.api_prefix}/${ct}/${this.session_hash}`
1867
1856
  );
@@ -1890,7 +1879,7 @@ class ee {
1890
1879
  return s !== this.config.app_id ? "changed" : "connected";
1891
1880
  }
1892
1881
  close() {
1893
- this.closed = !0, we(this.stream_status, this.abort_controller);
1882
+ this.closed = !0, ge(this.stream_status, this.abort_controller);
1894
1883
  }
1895
1884
  set_current_payload(t) {
1896
1885
  this.current_payload = t;
@@ -1905,7 +1894,7 @@ class ee {
1905
1894
  this.app_reference,
1906
1895
  this.options.hf_token
1907
1896
  ), { status_callback: i } = this.options;
1908
- n && i && await Me(n, i);
1897
+ n && i && await Ge(n, i);
1909
1898
  let r;
1910
1899
  try {
1911
1900
  let o = `${t}//${s}`;
@@ -1914,9 +1903,9 @@ class ee {
1914
1903
  return this.config_success(r);
1915
1904
  } catch (o) {
1916
1905
  if (n && i)
1917
- Y(
1906
+ Q(
1918
1907
  n,
1919
- ge.test(n) ? "space_name" : "subdomain",
1908
+ me.test(n) ? "space_name" : "subdomain",
1920
1909
  this.handle_space_success
1921
1910
  );
1922
1911
  else
@@ -2001,7 +1990,7 @@ class ee {
2001
1990
  }
2002
1991
  }
2003
1992
  set_cookies(t) {
2004
- this.cookies = ze(t).join("; ");
1993
+ this.cookies = qe(t).join("; ");
2005
1994
  }
2006
1995
  prepare_return_obj() {
2007
1996
  return {