@gradio/client 2.0.2 → 2.0.3

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.
package/dist/browser.js CHANGED
@@ -1,5 +1,5 @@
1
- const We = "host", Te = "queue/data", Ze = "queue/join", ye = "upload", Ke = "login", K = "config", Ve = "info", Ye = "runtime", Qe = "sleeptime", Xe = "heartbeat", et = "component_server", tt = "reset", st = "cancel", nt = "app_id", Ae = "This application is currently busy. Please try again. ", M = "Connection errored out. ", N = "Could not resolve app config. ", ot = "Could not get space status. ", it = "Could not get API info. ", ue = "Space metadata could not be loaded. ", rt = "Invalid URL. A full URL path is required.", at = "Not authorized to access this space. ", xe = "Invalid credentials. Could not login. ", ct = "Login credentials are required to access this space.", ut = "File system access is only available in Node.js environments", Ce = "Root URL not found in client config", lt = "Error uploading file";
2
- async function be(e, s, t) {
1
+ const Je = "host", Re = "queue/data", We = "queue/join", ge = "upload", Ze = "login", we = "config", Ke = "info", Ve = "runtime", Ye = "sleeptime", Qe = "heartbeat", Xe = "component_server", et = "reset", tt = "cancel", st = "app_id", Oe = "This application is currently busy. Please try again. ", M = "Connection errored out. ", I = "Could not resolve app config. ", nt = "Could not get space status. ", ot = "Could not get API info. ", ae = "Space metadata could not be loaded. ", it = "Invalid URL. A full URL path is required.", rt = "Not authorized to access this space. ", Te = "Invalid credentials. Could not login. ", at = "Login credentials are required to access this space.", ct = "File system access is only available in Node.js environments", Ae = "Root URL not found in client config", ut = "Error uploading file";
2
+ async function ye(e, s, t) {
3
3
  try {
4
4
  return (await (await fetch(`https://huggingface.co/api/spaces/${e}/jwt`, {
5
5
  headers: {
@@ -11,70 +11,48 @@ async function be(e, s, t) {
11
11
  return !1;
12
12
  }
13
13
  }
14
- function pt(e) {
14
+ function lt(e) {
15
15
  let s = {};
16
16
  return e.forEach(({ api_name: t, id: n }) => {
17
17
  t && (s[t] = n);
18
18
  }), s;
19
19
  }
20
- async function dt(e) {
20
+ async function pt(e) {
21
21
  const s = this.options.token ? { Authorization: `Bearer ${this.options.token}` } : {};
22
- if (s["Content-Type"] = "application/json", typeof window < "u" && window.gradio_config && location.origin !== "http://localhost:9876") {
23
- if (window.gradio_config.current_page && (e = e.substring(0, e.lastIndexOf("/"))), window.gradio_config.dev_mode) {
24
- let t = ae(
25
- e,
26
- this.deep_link ? K + "?deep_link=" + this.deep_link : K
27
- );
28
- const n = await this.fetch(t, {
29
- headers: s,
30
- credentials: "include"
31
- }), o = await ve(
32
- n,
33
- e,
34
- !!this.options.auth
35
- );
36
- window.gradio_config = {
37
- ...o,
38
- current_page: window.gradio_config.current_page
39
- };
40
- }
41
- return window.gradio_config.root = e, { ...window.gradio_config };
42
- } else if (e) {
43
- let t = ae(
44
- e,
45
- this.deep_link ? K + "?deep_link=" + this.deep_link : K
46
- );
47
- const n = await this.fetch(t, {
48
- headers: s,
49
- credentials: "include"
50
- });
51
- return ve(n, e, !!this.options.auth);
52
- }
53
- throw new Error(N);
22
+ s["Content-Type"] = "application/json", typeof window < "u" && window?.gradio_config?.current_page && (e = e.substring(0, e.lastIndexOf("/")));
23
+ let t = De(
24
+ e,
25
+ this.deep_link ? we + "?deep_link=" + this.deep_link : we
26
+ );
27
+ const n = await this.fetch(t, {
28
+ headers: s,
29
+ credentials: "include"
30
+ }), o = await dt(n, !!this.options.auth);
31
+ return typeof window < "u" && window?.BUILD_MODE === "dev" && (o.root = e || o.root), o;
54
32
  }
55
- async function ve(e, s, t) {
56
- if (e?.status === 401 && !t) {
57
- const o = (await e.json())?.detail?.auth_message;
58
- throw new Error(o || ct);
59
- } else if (e?.status === 401 && t)
60
- throw new Error(xe);
33
+ async function dt(e, s) {
34
+ if (e?.status === 401 && !s) {
35
+ const n = (await e.json())?.detail?.auth_message;
36
+ throw new Error(n || at);
37
+ } else if (e?.status === 401 && s)
38
+ throw new Error(Te);
61
39
  if (e?.status === 200) {
62
- let n = await e.json();
63
- return n.root = s, n.dependencies?.forEach((o, r) => {
64
- o.id === void 0 && (o.id = r);
65
- }), n;
40
+ let t = await e.json();
41
+ return t.dependencies?.forEach((n, o) => {
42
+ n.id === void 0 && (n.id = o);
43
+ }), t;
66
44
  } else if (e?.status === 401)
67
- throw new Error(at);
68
- throw new Error(N);
45
+ throw new Error(rt);
46
+ throw new Error(I);
69
47
  }
70
48
  async function ht() {
71
- const { http_protocol: e, host: s } = await pe(
49
+ const { http_protocol: e, host: s } = await ue(
72
50
  this.app_reference,
73
51
  this.options.token
74
52
  );
75
53
  try {
76
54
  if (this.options.auth) {
77
- const t = await Ne(
55
+ const t = await xe(
78
56
  e,
79
57
  s,
80
58
  this.options.auth,
@@ -87,12 +65,12 @@ async function ht() {
87
65
  throw Error(t.message);
88
66
  }
89
67
  }
90
- async function Ne(e, s, t, n, o) {
68
+ async function xe(e, s, t, n, o) {
91
69
  const r = new FormData();
92
70
  r.append("username", t?.[0]), r.append("password", t?.[1]);
93
71
  let i = {};
94
72
  o && (i.Authorization = `Bearer ${o}`);
95
- const a = await n(`${e}//${s}/${Ke}`, {
73
+ const a = await n(`${e}//${s}/${Ze}`, {
96
74
  headers: i,
97
75
  method: "POST",
98
76
  body: r,
@@ -100,9 +78,9 @@ async function Ne(e, s, t, n, o) {
100
78
  });
101
79
  if (a.status === 200)
102
80
  return a.headers.get("set-cookie");
103
- throw a.status === 401 ? new Error(xe) : new Error(ue);
81
+ throw a.status === 401 ? new Error(Te) : new Error(ae);
104
82
  }
105
- function re(e) {
83
+ function ie(e) {
106
84
  if (e.startsWith("http")) {
107
85
  const { protocol: s, host: t, pathname: n } = new URL(e);
108
86
  return {
@@ -117,32 +95,32 @@ function re(e) {
117
95
  host: new URL(e).host
118
96
  };
119
97
  }
120
- const De = (e) => {
98
+ const Ce = (e) => {
121
99
  let s = [];
122
100
  return e.split(/,(?=\s*[^\s=;]+=[^\s=;]+)/).forEach((n) => {
123
101
  const [o, r] = n.split(";")[0].split("=");
124
102
  o && r && s.push(`${o.trim()}=${r.trim()}`);
125
103
  }), s;
126
- }, le = /^[a-zA-Z0-9_\-\.]+\/[a-zA-Z0-9_\-\.]+$/, ft = /.*hf\.space\/{0,1}.*$/;
127
- async function pe(e, s) {
104
+ }, ce = /^[a-zA-Z0-9_\-\.]+\/[a-zA-Z0-9_\-\.]+$/, ft = /.*hf\.space\/{0,1}.*$/;
105
+ async function ue(e, s) {
128
106
  const t = {};
129
107
  s && (t.Authorization = `Bearer ${s}`);
130
108
  const n = e.trim().replace(/\/$/, "");
131
- if (le.test(n))
109
+ if (ce.test(n))
132
110
  try {
133
111
  const r = (await (await fetch(
134
- `https://huggingface.co/api/spaces/${n}/${We}`,
112
+ `https://huggingface.co/api/spaces/${n}/${Je}`,
135
113
  { headers: t }
136
114
  )).json()).host;
137
115
  return {
138
116
  space_id: e,
139
- ...re(r)
117
+ ...ie(r)
140
118
  };
141
119
  } catch {
142
- throw new Error(ue);
120
+ throw new Error(ae);
143
121
  }
144
122
  if (ft.test(n)) {
145
- const { ws_protocol: o, http_protocol: r, host: i } = re(n);
123
+ const { ws_protocol: o, http_protocol: r, host: i } = ie(n);
146
124
  return {
147
125
  space_id: i.split("/")[0].replace(".hf.space", ""),
148
126
  ws_protocol: o,
@@ -152,14 +130,14 @@ async function pe(e, s) {
152
130
  }
153
131
  return {
154
132
  space_id: !1,
155
- ...re(n)
133
+ ...ie(n)
156
134
  };
157
135
  }
158
- const ae = (...e) => {
136
+ const De = (...e) => {
159
137
  try {
160
138
  return e.reduce((s, t) => (s = s.replace(/\/+$/, ""), t = t.replace(/^\/+/, ""), new URL(t, s + "/").toString()));
161
139
  } catch {
162
- throw new Error(rt);
140
+ throw new Error(it);
163
141
  }
164
142
  };
165
143
  function _t(e, s, t) {
@@ -237,7 +215,7 @@ function mt(e, s, t, n) {
237
215
  function gt(e, s) {
238
216
  return s === "GallerySerializable" ? "array of [file, label] tuples" : s === "ListStringSerializable" ? "array of strings" : s === "FileSerializable" ? "array of files or single file" : e?.description;
239
217
  }
240
- function Ee(e, s) {
218
+ function be(e, s) {
241
219
  switch (e.msg) {
242
220
  case "send_data":
243
221
  return { type: "data" };
@@ -248,7 +226,7 @@ function Ee(e, s) {
248
226
  type: "update",
249
227
  status: {
250
228
  queue: !0,
251
- message: Ae,
229
+ message: Oe,
252
230
  stage: "error",
253
231
  code: e.code,
254
232
  success: e.success
@@ -410,7 +388,7 @@ async function yt() {
410
388
  if (typeof window < "u" && window.gradio_api_info)
411
389
  o = window.gradio_api_info;
412
390
  else {
413
- const r = ae(s.root, this.api_prefix, Ve);
391
+ const r = De(s.root, this.api_prefix, Ke);
414
392
  if (n = await this.fetch(r, {
415
393
  headers: t,
416
394
  credentials: "include"
@@ -434,7 +412,7 @@ async function bt(e, s, t) {
434
412
  l.append("files", c);
435
413
  });
436
414
  try {
437
- const c = t ? `${e}${this.api_prefix}/${ye}?upload_id=${t}` : `${e}${this.api_prefix}/${ye}`;
415
+ const c = t ? `${e}${this.api_prefix}/${ge}?upload_id=${t}` : `${e}${this.api_prefix}/${ge}`;
438
416
  i = await this.fetch(c, {
439
417
  method: "POST",
440
418
  body: l,
@@ -462,14 +440,14 @@ const vt = {
462
440
  }, St = {
463
441
  radix: 1024,
464
442
  unit: ["b", "Kb", "Mb", "Gb", "Tb", "Pb", "Eb", "Zb", "Yb"]
465
- }, Se = {
443
+ }, ve = {
466
444
  si: vt,
467
445
  iec: Et,
468
446
  jedec: St
469
447
  };
470
448
  function $t(e, s = 1, t = "jedec") {
471
449
  e = Math.abs(e);
472
- const { radix: n, unit: o } = Se[t] || Se.jedec;
450
+ const { radix: n, unit: o } = ve[t] || ve.jedec;
473
451
  let r = 0;
474
452
  for (; e >= n; )
475
453
  e /= n, ++r;
@@ -491,7 +469,7 @@ async function kt(e, s, t, n) {
491
469
  async (i) => {
492
470
  if (i.error)
493
471
  throw new Error(i.error);
494
- return i.files ? i.files.map((a, u) => new Q({
472
+ return i.files ? i.files.map((a, u) => new Y({
495
473
  ...e[u],
496
474
  path: a,
497
475
  url: `${s}${this.api_prefix}/file=${a}`
@@ -502,7 +480,7 @@ async function kt(e, s, t, n) {
502
480
  }
503
481
  async function Xt(e, s) {
504
482
  return e.map(
505
- (t) => new Q({
483
+ (t) => new Y({
506
484
  path: t.name,
507
485
  orig_name: t.name,
508
486
  blob: t,
@@ -512,7 +490,7 @@ async function Xt(e, s) {
512
490
  })
513
491
  );
514
492
  }
515
- class Q {
493
+ class Y {
516
494
  path;
517
495
  url;
518
496
  orig_name;
@@ -537,7 +515,7 @@ class Q {
537
515
  this.path = s, this.url = t, this.orig_name = n, this.size = o, this.blob = t ? void 0 : r, this.is_stream = i, this.mime_type = a, this.alt_text = u, this.b64 = l;
538
516
  }
539
517
  }
540
- class Pe {
518
+ class Ne {
541
519
  type;
542
520
  command;
543
521
  meta;
@@ -547,7 +525,7 @@ class Pe {
547
525
  }
548
526
  }
549
527
  const Rt = typeof process < "u" && process.versions && process.versions.node;
550
- function $e(e, s, t) {
528
+ function Ee(e, s, t) {
551
529
  for (; t.length > 1; ) {
552
530
  const o = t.shift();
553
531
  if (typeof o == "string" || typeof o == "number")
@@ -561,14 +539,14 @@ function $e(e, s, t) {
561
539
  else
562
540
  throw new Error("Invalid key type");
563
541
  }
564
- async function ce(e, s = void 0, t = [], n = !1, o = void 0) {
542
+ async function re(e, s = void 0, t = [], n = !1, o = void 0) {
565
543
  if (Array.isArray(e)) {
566
544
  let r = [];
567
545
  return await Promise.all(
568
546
  e.map(async (i, a) => {
569
547
  let u = t.slice();
570
548
  u.push(String(a));
571
- const l = await ce(
549
+ const l = await re(
572
550
  e[a],
573
551
  n ? o?.parameters[a]?.component || void 0 : s,
574
552
  u,
@@ -592,7 +570,7 @@ async function ce(e, s = void 0, t = [], n = !1, o = void 0) {
592
570
  for (const i of Object.keys(e)) {
593
571
  const a = [...t, i], u = e[i];
594
572
  r = r.concat(
595
- await ce(
573
+ await re(
596
574
  u,
597
575
  void 0,
598
576
  a,
@@ -628,7 +606,7 @@ function es(e) {
628
606
  meta: { _type: "gradio.FileData" }
629
607
  };
630
608
  if (Rt)
631
- return new Pe("upload_file", {
609
+ return new Ne("upload_file", {
632
610
  path: e,
633
611
  name: e,
634
612
  orig_path: e
@@ -645,7 +623,7 @@ function es(e) {
645
623
  "Invalid input: must be a URL, File, Blob, or Buffer object."
646
624
  );
647
625
  }
648
- function V(e, s, t, n, o = !1) {
626
+ function K(e, s, t, n, o = !1) {
649
627
  if (n === "input" && !o)
650
628
  throw new Error("Invalid code path. Cannot skip state inputs for input.");
651
629
  if (n === "output" && o)
@@ -676,7 +654,7 @@ function V(e, s, t, n, o = !1) {
676
654
  async function At(e, s, t) {
677
655
  const n = this;
678
656
  await xt(n, s);
679
- const o = await ce(
657
+ const o = await re(
680
658
  s,
681
659
  void 0,
682
660
  [],
@@ -696,49 +674,49 @@ async function At(e, s, t) {
696
674
  })
697
675
  )).forEach(({ path: i, file_url: a, type: u, name: l }) => {
698
676
  if (u === "Gallery")
699
- $e(s, a, i);
677
+ Ee(s, a, i);
700
678
  else if (a) {
701
- const p = new Q({ path: a, orig_name: l });
702
- $e(s, p, i);
679
+ const p = new Y({ path: a, orig_name: l });
680
+ Ee(s, p, i);
703
681
  }
704
682
  }), s;
705
683
  }
706
684
  async function xt(e, s) {
707
685
  if (!(e.config?.root || e.config?.root_url))
708
- throw new Error(Ce);
686
+ throw new Error(Ae);
709
687
  await Le(e, s);
710
688
  }
711
689
  async function Le(e, s, t = []) {
712
690
  for (const n in s)
713
- s[n] instanceof Pe ? await Ct(e, s, n) : typeof s[n] == "object" && s[n] !== null && await Le(e, s[n], [...t, n]);
691
+ s[n] instanceof Ne ? await Ct(e, s, n) : typeof s[n] == "object" && s[n] !== null && await Le(e, s[n], [...t, n]);
714
692
  }
715
693
  async function Ct(e, s, t) {
716
694
  let n = s[t];
717
695
  const o = e.config?.root || e.config?.root_url;
718
696
  if (!o)
719
- throw new Error(Ce);
697
+ throw new Error(Ae);
720
698
  try {
721
699
  let r, i;
722
700
  if (typeof process < "u" && process.versions && process.versions.node) {
723
701
  const p = await import("./__vite-browser-external-DYxpcVy9.js");
724
702
  i = (await import("./__vite-browser-external-DYxpcVy9.js")).resolve(process.cwd(), n.meta.path), r = await p.readFile(i);
725
703
  } else
726
- throw new Error(ut);
704
+ throw new Error(ct);
727
705
  const a = new Blob([r], {
728
706
  type: "application/octet-stream"
729
707
  }), u = await e.upload_files(o, [a]), l = u.files && u.files[0];
730
708
  if (l) {
731
- const p = new Q({
709
+ const p = new Y({
732
710
  path: l,
733
711
  orig_name: n.meta.name || ""
734
712
  });
735
713
  s[t] = p;
736
714
  }
737
715
  } catch (r) {
738
- console.error(lt, r);
716
+ console.error(ut, r);
739
717
  }
740
718
  }
741
- async function Nt(e, s, t) {
719
+ async function Dt(e, s, t) {
742
720
  const n = { "Content-Type": "application/json" };
743
721
  this.options.token && (n.Authorization = `Bearer ${this.options.token}`);
744
722
  try {
@@ -759,7 +737,7 @@ async function Nt(e, s, t) {
759
737
  }
760
738
  return [r, i];
761
739
  }
762
- async function Dt(e, s = {}) {
740
+ async function Nt(e, s = {}) {
763
741
  let t = !1, n = !1;
764
742
  if (!this.config)
765
743
  throw new Error("Could not resolve app config");
@@ -788,7 +766,7 @@ async function G(e, s, t) {
788
766
  t({
789
767
  status: "error",
790
768
  load_status: "error",
791
- message: ot,
769
+ message: nt,
792
770
  detail: "NOT_FOUND"
793
771
  });
794
772
  return;
@@ -816,7 +794,7 @@ async function G(e, s, t) {
816
794
  load_status: "error",
817
795
  message: "This space has been paused by the author. If you would like to try this demo, consider duplicating the space.",
818
796
  detail: i,
819
- discussions_enabled: await ke(a)
797
+ discussions_enabled: await Se(a)
820
798
  });
821
799
  break;
822
800
  case "RUNNING":
@@ -854,27 +832,27 @@ async function G(e, s, t) {
854
832
  load_status: "error",
855
833
  message: "This space is experiencing an issue.",
856
834
  detail: i,
857
- discussions_enabled: await ke(a)
835
+ discussions_enabled: await Se(a)
858
836
  });
859
837
  break;
860
838
  }
861
839
  }
862
- const je = async (e, s) => {
840
+ const Pe = async (e, s) => {
863
841
  let t = 0;
864
842
  const n = 12, o = 5e3;
865
843
  return new Promise((r) => {
866
844
  G(
867
845
  e,
868
- le.test(e) ? "space_name" : "subdomain",
846
+ ce.test(e) ? "space_name" : "subdomain",
869
847
  (i) => {
870
848
  s(i), i.status === "running" || i.status === "error" || i.status === "paused" || i.status === "space_error" ? r() : (i.status === "sleeping" || i.status === "building") && (t < n ? (t++, setTimeout(() => {
871
- je(e, s).then(r);
849
+ Pe(e, s).then(r);
872
850
  }, o)) : r());
873
851
  }
874
852
  );
875
853
  });
876
- }, Pt = /^(?=[^]*\b[dD]iscussions{0,1}\b)(?=[^]*\b[dD]isabled\b)[^]*$/;
877
- async function ke(e) {
854
+ }, Lt = /^(?=[^]*\b[dD]iscussions{0,1}\b)(?=[^]*\b[dD]isabled\b)[^]*$/;
855
+ async function Se(e) {
878
856
  try {
879
857
  const s = await fetch(
880
858
  `https://huggingface.co/api/spaces/${e}/discussions`,
@@ -882,17 +860,17 @@ async function ke(e) {
882
860
  method: "HEAD"
883
861
  }
884
862
  ), t = s.headers.get("x-error-message");
885
- return !(!s.ok || t && Pt.test(t));
863
+ return !(!s.ok || t && Lt.test(t));
886
864
  } catch {
887
865
  return !1;
888
866
  }
889
867
  }
890
- async function Lt(e, s) {
868
+ async function Pt(e, s) {
891
869
  const t = {};
892
870
  s && (t.Authorization = `Bearer ${s}`);
893
871
  try {
894
872
  const n = await fetch(
895
- `https://huggingface.co/api/spaces/${e}/${Ye}`,
873
+ `https://huggingface.co/api/spaces/${e}/${Ve}`,
896
874
  { headers: t }
897
875
  );
898
876
  if (n.status !== 200)
@@ -903,7 +881,7 @@ async function Lt(e, s) {
903
881
  throw new Error(n.message);
904
882
  }
905
883
  }
906
- async function jt(e, s, t) {
884
+ async function It(e, s, t) {
907
885
  const n = {};
908
886
  t && (n.Authorization = `Bearer ${t}`);
909
887
  const o = {
@@ -911,7 +889,7 @@ async function jt(e, s, t) {
911
889
  };
912
890
  try {
913
891
  const r = await fetch(
914
- `https://huggingface.co/api/spaces/${e}/${Qe}`,
892
+ `https://huggingface.co/api/spaces/${e}/${Ye}`,
915
893
  {
916
894
  method: "POST",
917
895
  headers: { "Content-Type": "application/json", ...n },
@@ -927,7 +905,7 @@ async function jt(e, s, t) {
927
905
  throw new Error(r.message);
928
906
  }
929
907
  }
930
- const Re = [
908
+ const $e = [
931
909
  "cpu-basic",
932
910
  "cpu-upgrade",
933
911
  "cpu-xl",
@@ -942,22 +920,22 @@ const Re = [
942
920
  "h100",
943
921
  "h100x8"
944
922
  ];
945
- async function It(e, s) {
923
+ async function jt(e, s) {
946
924
  const { token: t, private: n, hardware: o, timeout: r, auth: i } = s;
947
- if (o && !Re.includes(o))
925
+ if (o && !$e.includes(o))
948
926
  throw new Error(
949
- `Invalid hardware type provided. Valid types are: ${Re.map((g) => `"${g}"`).join(",")}.`
927
+ `Invalid hardware type provided. Valid types are: ${$e.map((g) => `"${g}"`).join(",")}.`
950
928
  );
951
- const { http_protocol: a, host: u } = await pe(e, t);
929
+ const { http_protocol: a, host: u } = await ue(e, t);
952
930
  let l = null;
953
931
  if (i) {
954
- const g = await Ne(
932
+ const g = await xe(
955
933
  a,
956
934
  u,
957
935
  i,
958
936
  fetch
959
937
  );
960
- g && (l = De(g));
938
+ g && (l = Ce(g));
961
939
  }
962
940
  const p = {
963
941
  Authorization: `Bearer ${t}`,
@@ -971,9 +949,9 @@ async function It(e, s) {
971
949
  n && (w.private = !0);
972
950
  let D;
973
951
  try {
974
- o || (D = await Lt(e, t));
952
+ o || (D = await Pt(e, t));
975
953
  } catch (g) {
976
- throw Error(ue + g.message);
954
+ throw Error(ae + g.message);
977
955
  }
978
956
  const f = o || D || "cpu-basic";
979
957
  w.hardware = f;
@@ -988,15 +966,15 @@ async function It(e, s) {
988
966
  );
989
967
  if (g.status === 409)
990
968
  try {
991
- return await Y.connect(`${c}/${m}`, s);
969
+ return await V.connect(`${c}/${m}`, s);
992
970
  } catch (q) {
993
971
  throw console.error("Failed to connect Client instance:", q), q;
994
972
  }
995
973
  else if (g.status !== 200)
996
974
  throw new Error(g.statusText);
997
- const J = await g.json();
998
- return await jt(`${c}/${m}`, r || 300, t), await Y.connect(
999
- Ut(J.url),
975
+ const H = await g.json();
976
+ return await It(`${c}/${m}`, r || 300, t), await V.connect(
977
+ Ut(H.url),
1000
978
  s
1001
979
  );
1002
980
  } catch (g) {
@@ -1049,7 +1027,7 @@ function Bt(e) {
1049
1027
  e.substring(n + t[0].length)
1050
1028
  ];
1051
1029
  }
1052
- function Oe(e, s, t) {
1030
+ function ke(e, s, t) {
1053
1031
  e.get(s) || e.set(s, t);
1054
1032
  }
1055
1033
  async function* Ft(e, s) {
@@ -1072,7 +1050,7 @@ async function* Ft(e, s) {
1072
1050
  }
1073
1051
  async function Gt(e, s) {
1074
1052
  let t = new Request(e, s);
1075
- Oe(t.headers, "Accept", "text/event-stream"), Oe(t.headers, "Content-Type", "application/json");
1053
+ ke(t.headers, "Accept", "text/event-stream"), ke(t.headers, "Content-Type", "application/json");
1076
1054
  let n = await fetch(t);
1077
1055
  if (!n.ok)
1078
1056
  throw n;
@@ -1093,7 +1071,7 @@ async function Mt() {
1093
1071
  n.open = !0;
1094
1072
  let a = null, u = new URLSearchParams({
1095
1073
  session_hash: this.session_hash
1096
- }).toString(), l = new URL(`${o.root}${this.api_prefix}/${Te}?${u}`);
1074
+ }).toString(), l = new URL(`${o.root}${this.api_prefix}/${Re}?${u}`);
1097
1075
  if (r && l.searchParams.set("__sign", r), a = this.stream(l), !a) {
1098
1076
  console.warn("Cannot connect to SSE endpoint: " + l.toString());
1099
1077
  return;
@@ -1101,7 +1079,7 @@ async function Mt() {
1101
1079
  a.onmessage = async function(p) {
1102
1080
  let c = JSON.parse(p.data);
1103
1081
  if (c.msg === "close_stream") {
1104
- de(n, i.abort_controller);
1082
+ le(n, i.abort_controller);
1105
1083
  return;
1106
1084
  }
1107
1085
  const m = c.event_id;
@@ -1130,18 +1108,18 @@ async function Mt() {
1130
1108
  );
1131
1109
  };
1132
1110
  }
1133
- function de(e, s) {
1111
+ function le(e, s) {
1134
1112
  e && (e.open = !1, s?.abort());
1135
1113
  }
1136
- function Jt(e, s, t) {
1114
+ function Ht(e, s, t) {
1137
1115
  !e[s] ? (e[s] = [], t.data.forEach((o, r) => {
1138
1116
  e[s][r] = o;
1139
1117
  })) : t.data.forEach((o, r) => {
1140
- let i = Ht(e[s][r], o);
1118
+ let i = Jt(e[s][r], o);
1141
1119
  e[s][r] = i, t.data[r] = i;
1142
1120
  });
1143
1121
  }
1144
- function Ht(e, s) {
1122
+ function Jt(e, s) {
1145
1123
  return s.forEach(([t, n, o]) => {
1146
1124
  e = Wt(e, n, t, o);
1147
1125
  }), e;
@@ -1216,66 +1194,66 @@ function Zt(e, s = {}) {
1216
1194
  function Kt(e, s = {}, t, n, o, r) {
1217
1195
  try {
1218
1196
  let i = function(h) {
1219
- (o || ze[h.type]) && p(h);
1197
+ (o || qe[h.type]) && p(h);
1220
1198
  }, a = function() {
1221
- for (Me = !0; F.length > 0; )
1199
+ for (Ge = !0; F.length > 0; )
1222
1200
  F.shift()({
1223
1201
  value: void 0,
1224
1202
  done: !0
1225
1203
  });
1226
1204
  }, u = function(h) {
1227
- F.length > 0 ? F.shift()(h) : oe.push(h);
1205
+ F.length > 0 ? F.shift()(h) : ne.push(h);
1228
1206
  }, l = function(h) {
1229
1207
  u(Vt(h)), a();
1230
1208
  }, p = function(h) {
1231
1209
  u({ value: h, done: !1 });
1232
1210
  }, c = function() {
1233
- return oe.length > 0 ? Promise.resolve(oe.shift()) : new Promise((h) => F.push(h));
1211
+ return ne.length > 0 ? Promise.resolve(ne.shift()) : new Promise((h) => F.push(h));
1234
1212
  };
1235
1213
  const { token: m } = this.options, {
1236
1214
  fetch: w,
1237
1215
  app_reference: D,
1238
1216
  config: f,
1239
1217
  session_hash: g,
1240
- api_info: J,
1218
+ api_info: H,
1241
1219
  api_map: q,
1242
- stream_status: X,
1243
- pending_stream_messages: ee,
1244
- pending_diff_streams: te,
1245
- event_callbacks: se,
1220
+ stream_status: Q,
1221
+ pending_stream_messages: X,
1222
+ pending_diff_streams: ee,
1223
+ event_callbacks: te,
1246
1224
  unclosed_events: Ie,
1247
- post_data: ne,
1248
- options: H,
1225
+ post_data: se,
1226
+ options: J,
1249
1227
  api_prefix: R
1250
- } = this, he = r || { "x-gradio-user": "api" }, Ue = this;
1251
- if (!J) throw new Error("No API found");
1228
+ } = this, pe = r || { "x-gradio-user": "api" }, je = this;
1229
+ if (!H) throw new Error("No API found");
1252
1230
  if (!f) throw new Error("Could not resolve app config");
1253
- let { fn_index: d, endpoint_info: fe, dependency: z } = Yt(
1254
- J,
1231
+ let { fn_index: d, endpoint_info: de, dependency: z } = Yt(
1232
+ H,
1255
1233
  e,
1256
1234
  q,
1257
1235
  f
1258
- ), qe = wt(s, fe), I, O = f.protocol ?? "ws";
1236
+ ), Ue = wt(s, de), j, O = f.protocol ?? "ws";
1259
1237
  if (O === "ws")
1260
1238
  throw new Error("WebSocket protocol is not supported in this version");
1261
1239
  let U = "", Qt = () => U;
1262
1240
  const _ = typeof e == "number" ? "/predict" : e;
1263
- let W, b = null, T = !1, _e = {}, B = typeof window < "u" && typeof document < "u" ? new URLSearchParams(window.location.search).toString() : "";
1264
- const ze = H?.events?.reduce(
1241
+ let W, b = null, T = !1, he = {}, B = typeof window < "u" && typeof document < "u" ? new URLSearchParams(window.location.search).toString() : "";
1242
+ const qe = J?.events?.reduce(
1265
1243
  (h, k) => (h[k] = !0, h),
1266
1244
  {}
1267
1245
  ) || {};
1268
- async function Be() {
1246
+ async function ze() {
1269
1247
  let h = {}, k = {};
1270
1248
  h = { event_id: b }, k = { event_id: b, session_hash: g, fn_index: d };
1271
1249
  try {
1272
1250
  if (!f)
1273
1251
  throw new Error("Could not resolve app config");
1274
- "event_id" in k && await w(`${f.root}${R}/${st}`, {
1252
+ "event_id" in k && await w(`${f.root}${R}/${tt}`, {
1275
1253
  headers: { "Content-Type": "application/json" },
1276
1254
  method: "POST",
1277
1255
  body: JSON.stringify(k)
1278
- }), await w(`${f.root}${R}/${tt}`, {
1256
+ }), await w(`${f.root}${R}/${et}`, {
1279
1257
  headers: { "Content-Type": "application/json" },
1280
1258
  method: "POST",
1281
1259
  body: JSON.stringify(h)
@@ -1286,10 +1264,10 @@ function Kt(e, s = {}, t, n, o, r) {
1286
1264
  );
1287
1265
  }
1288
1266
  }
1289
- const Fe = async (h) => {
1267
+ const Be = async (h) => {
1290
1268
  await this._resolve_heartbeat(h);
1291
1269
  };
1292
- async function me(h) {
1270
+ async function fe(h) {
1293
1271
  if (!f) return;
1294
1272
  let k = h.render_id;
1295
1273
  f.components = [
@@ -1300,22 +1278,22 @@ function Kt(e, s = {}, t, n, o, r) {
1300
1278
  ...h.dependencies
1301
1279
  ];
1302
1280
  const Z = f.components.some((v) => v.type === "state"), y = f.dependencies.some(
1303
- (v) => v.targets.some((P) => P[1] === "unload")
1281
+ (v) => v.targets.some((N) => N[1] === "unload")
1304
1282
  );
1305
- f.connect_heartbeat = Z || y, await Fe(f), i({
1283
+ f.connect_heartbeat = Z || y, await Be(f), i({
1306
1284
  type: "render",
1307
1285
  data: h,
1308
1286
  endpoint: _,
1309
1287
  fn_index: d
1310
1288
  });
1311
1289
  }
1312
- const Ge = this.handle_blob(
1290
+ const Fe = this.handle_blob(
1313
1291
  f.root,
1314
- qe,
1315
- fe
1292
+ Ue,
1293
+ de
1316
1294
  ).then(async (h) => {
1317
1295
  if (W = {
1318
- data: V(
1296
+ data: K(
1319
1297
  h,
1320
1298
  z,
1321
1299
  f.components,
@@ -1333,30 +1311,30 @@ function Kt(e, s = {}, t, n, o, r) {
1333
1311
  queue: !1,
1334
1312
  fn_index: d,
1335
1313
  time: /* @__PURE__ */ new Date()
1336
- }), ne(
1314
+ }), se(
1337
1315
  `${f.root}${R}/run${_.startsWith("/") ? _ : `/${_}`}${B ? "?" + B : ""}`,
1338
1316
  {
1339
1317
  ...W,
1340
1318
  session_hash: g
1341
1319
  },
1342
- he
1320
+ pe
1343
1321
  ).then(async ([y, v]) => {
1344
- const P = y.data;
1322
+ const N = y.data;
1345
1323
  v == 200 ? (i({
1346
1324
  type: "data",
1347
1325
  endpoint: _,
1348
1326
  fn_index: d,
1349
- data: V(
1350
- P,
1327
+ data: K(
1328
+ N,
1351
1329
  z,
1352
1330
  f.components,
1353
1331
  "output",
1354
- H.with_null_state
1332
+ J.with_null_state
1355
1333
  ),
1356
1334
  time: /* @__PURE__ */ new Date(),
1357
1335
  event_data: t,
1358
1336
  trigger_id: n
1359
- }), y.render_config && await me(y.render_config), i({
1337
+ }), y.render_config && await fe(y.render_config), i({
1360
1338
  type: "status",
1361
1339
  endpoint: _,
1362
1340
  fn_index: d,
@@ -1398,16 +1376,16 @@ function Kt(e, s = {}, t, n, o, r) {
1398
1376
  session_hash: g
1399
1377
  }).toString();
1400
1378
  let y = new URL(
1401
- `${f.root}${R}/${Te}?${B ? B + "&" : ""}${Z}`
1379
+ `${f.root}${R}/${Re}?${B ? B + "&" : ""}${Z}`
1402
1380
  );
1403
- if (this.jwt && y.searchParams.set("__sign", this.jwt), I = this.stream(y), !I)
1381
+ if (this.jwt && y.searchParams.set("__sign", this.jwt), j = this.stream(y), !j)
1404
1382
  return Promise.reject(
1405
1383
  new Error("Cannot connect to SSE endpoint: " + y.toString())
1406
1384
  );
1407
- I.onmessage = async function(v) {
1408
- const P = JSON.parse(v.data), { type: L, status: A, data: x } = Ee(
1409
- P,
1410
- _e[d]
1385
+ j.onmessage = async function(v) {
1386
+ const N = JSON.parse(v.data), { type: L, status: A, data: x } = be(
1387
+ N,
1388
+ he[d]
1411
1389
  );
1412
1390
  if (L === "update" && A && !T)
1413
1391
  i({
@@ -1416,9 +1394,9 @@ function Kt(e, s = {}, t, n, o, r) {
1416
1394
  fn_index: d,
1417
1395
  time: /* @__PURE__ */ new Date(),
1418
1396
  ...A
1419
- }), A.stage === "error" && (I?.close(), a());
1397
+ }), A.stage === "error" && (j?.close(), a());
1420
1398
  else if (L === "data") {
1421
- let [C, j] = await ne(
1399
+ let [C, P] = await se(
1422
1400
  `${f.root}${R}/queue/data`,
1423
1401
  {
1424
1402
  ...W,
@@ -1426,7 +1404,7 @@ function Kt(e, s = {}, t, n, o, r) {
1426
1404
  event_id: b
1427
1405
  }
1428
1406
  );
1429
- j !== 200 && (i({
1407
+ P !== 200 && (i({
1430
1408
  type: "status",
1431
1409
  stage: "error",
1432
1410
  message: M,
@@ -1434,7 +1412,7 @@ function Kt(e, s = {}, t, n, o, r) {
1434
1412
  endpoint: _,
1435
1413
  fn_index: d,
1436
1414
  time: /* @__PURE__ */ new Date()
1437
- }), I?.close(), a());
1415
+ }), j?.close(), a());
1438
1416
  } else L === "complete" ? T = A : L === "log" ? i({
1439
1417
  type: "log",
1440
1418
  title: x.title,
@@ -1456,12 +1434,12 @@ function Kt(e, s = {}, t, n, o, r) {
1456
1434
  x && (i({
1457
1435
  type: "data",
1458
1436
  time: /* @__PURE__ */ new Date(),
1459
- data: V(
1437
+ data: K(
1460
1438
  x.data,
1461
1439
  z,
1462
1440
  f.components,
1463
1441
  "output",
1464
- H.with_null_state
1442
+ J.with_null_state
1465
1443
  ),
1466
1444
  endpoint: _,
1467
1445
  fn_index: d,
@@ -1475,7 +1453,7 @@ function Kt(e, s = {}, t, n, o, r) {
1475
1453
  queue: !0,
1476
1454
  endpoint: _,
1477
1455
  fn_index: d
1478
- }), I?.close(), a()));
1456
+ }), j?.close(), a()));
1479
1457
  };
1480
1458
  } else if (O == "sse_v1" || O == "sse_v2" || O == "sse_v2.1" || O == "sse_v3") {
1481
1459
  i({
@@ -1488,30 +1466,30 @@ function Kt(e, s = {}, t, n, o, r) {
1488
1466
  });
1489
1467
  let y = "";
1490
1468
  typeof window < "u" && typeof document < "u" && (y = window?.location?.hostname);
1491
- const P = y.includes(".dev.") ? `https://moon-${y.split(".")[1]}.dev.spaces.huggingface.tech` : "https://huggingface.co";
1492
- return (typeof window < "u" && typeof document < "u" && window.parent != window && window.supports_zerogpu_headers ? Tt("zerogpu-headers", P) : Promise.resolve(null)).then((C) => {
1493
- const j = { ...he, ...C || {} };
1494
- return ne(
1495
- `${f.root}${R}/${Ze}?${B}`,
1469
+ const N = y.includes(".dev.") ? `https://moon-${y.split(".")[1]}.dev.spaces.huggingface.tech` : "https://huggingface.co";
1470
+ return (typeof window < "u" && typeof document < "u" && window.parent != window && window.supports_zerogpu_headers ? Tt("zerogpu-headers", N) : Promise.resolve(null)).then((C) => {
1471
+ const P = { ...pe, ...C || {} };
1472
+ return se(
1473
+ `${f.root}${R}/${We}?${B}`,
1496
1474
  {
1497
1475
  ...W,
1498
1476
  session_hash: g
1499
1477
  },
1500
- j
1478
+ P
1501
1479
  );
1502
- }).then(async ([C, j]) => {
1503
- if (C.event_id && (U = C.event_id), j === 503)
1480
+ }).then(async ([C, P]) => {
1481
+ if (C.event_id && (U = C.event_id), P === 503)
1504
1482
  i({
1505
1483
  type: "status",
1506
1484
  stage: "error",
1507
- message: Ae,
1485
+ message: Oe,
1508
1486
  queue: !0,
1509
1487
  endpoint: _,
1510
1488
  fn_index: d,
1511
1489
  time: /* @__PURE__ */ new Date(),
1512
1490
  visible: !0
1513
1491
  });
1514
- else if (j === 422)
1492
+ else if (P === 422)
1515
1493
  i({
1516
1494
  type: "status",
1517
1495
  stage: "error",
@@ -1523,7 +1501,7 @@ function Kt(e, s = {}, t, n, o, r) {
1523
1501
  time: /* @__PURE__ */ new Date(),
1524
1502
  visible: !0
1525
1503
  }), a();
1526
- else if (j !== 200)
1504
+ else if (P !== 200)
1527
1505
  i({
1528
1506
  type: "status",
1529
1507
  stage: "error",
@@ -1537,11 +1515,11 @@ function Kt(e, s = {}, t, n, o, r) {
1537
1515
  });
1538
1516
  else {
1539
1517
  b = C.event_id, U = b;
1540
- let we = async function(ie) {
1518
+ let me = async function(oe) {
1541
1519
  try {
1542
- const { type: E, status: S, data: $, original_msg: Je } = Ee(
1543
- ie,
1544
- _e[d]
1520
+ const { type: E, status: S, data: $, original_msg: Me } = be(
1521
+ oe,
1522
+ he[d]
1545
1523
  );
1546
1524
  if (E == "heartbeat")
1547
1525
  return;
@@ -1551,7 +1529,7 @@ function Kt(e, s = {}, t, n, o, r) {
1551
1529
  endpoint: _,
1552
1530
  fn_index: d,
1553
1531
  time: /* @__PURE__ */ new Date(),
1554
- original_msg: Je,
1532
+ original_msg: Me,
1555
1533
  ...S
1556
1534
  });
1557
1535
  else if (E === "complete")
@@ -1590,20 +1568,20 @@ function Kt(e, s = {}, t, n, o, r) {
1590
1568
  queue: !0,
1591
1569
  endpoint: _,
1592
1570
  fn_index: d
1593
- }), $ && z.connection !== "stream" && ["sse_v2", "sse_v2.1", "sse_v3"].includes(O) && Jt(te, b, $));
1571
+ }), $ && z.connection !== "stream" && ["sse_v2", "sse_v2.1", "sse_v3"].includes(O) && Ht(ee, b, $));
1594
1572
  $ && (i({
1595
1573
  type: "data",
1596
1574
  time: /* @__PURE__ */ new Date(),
1597
- data: V(
1575
+ data: K(
1598
1576
  $.data,
1599
1577
  z,
1600
1578
  f.components,
1601
1579
  "output",
1602
- H.with_null_state
1580
+ J.with_null_state
1603
1581
  ),
1604
1582
  endpoint: _,
1605
1583
  fn_index: d
1606
- }), $.render_config && await me($.render_config), T && (i({
1584
+ }), $.render_config && await fe($.render_config), T && (i({
1607
1585
  type: "status",
1608
1586
  time: /* @__PURE__ */ new Date(),
1609
1587
  ...T,
@@ -1611,7 +1589,7 @@ function Kt(e, s = {}, t, n, o, r) {
1611
1589
  queue: !0,
1612
1590
  endpoint: _,
1613
1591
  fn_index: d
1614
- }), a())), (S?.stage === "complete" || S?.stage === "error") && (se[b] && delete se[b], b in te && delete te[b]);
1592
+ }), a())), (S?.stage === "complete" || S?.stage === "error") && (te[b] && delete te[b], b in ee && delete ee[b]);
1615
1593
  } catch (E) {
1616
1594
  console.error("Unexpected client exception", E), i({
1617
1595
  type: "status",
@@ -1621,21 +1599,21 @@ function Kt(e, s = {}, t, n, o, r) {
1621
1599
  endpoint: _,
1622
1600
  fn_index: d,
1623
1601
  time: /* @__PURE__ */ new Date()
1624
- }), ["sse_v2", "sse_v2.1", "sse_v3"].includes(O) && (de(X, Ue.abort_controller), X.open = !1, a());
1602
+ }), ["sse_v2", "sse_v2.1", "sse_v3"].includes(O) && (le(Q, je.abort_controller), Q.open = !1, a());
1625
1603
  }
1626
1604
  };
1627
- b in ee && (ee[b].forEach((ie) => we(ie)), delete ee[b]), se[b] = we, Ie.add(b), X.open || await this.open_stream();
1605
+ b in X && (X[b].forEach((oe) => me(oe)), delete X[b]), te[b] = me, Ie.add(b), Q.open || await this.open_stream();
1628
1606
  }
1629
1607
  });
1630
1608
  }
1631
1609
  });
1632
- let Me = !1;
1633
- const oe = [], F = [], ge = {
1634
- [Symbol.asyncIterator]: () => ge,
1610
+ let Ge = !1;
1611
+ const ne = [], F = [], _e = {
1612
+ [Symbol.asyncIterator]: () => _e,
1635
1613
  next: c,
1636
1614
  throw: async (h) => (l(h), c()),
1637
1615
  return: async () => (a(), { value: void 0, done: !0 }),
1638
- cancel: Be,
1616
+ cancel: ze,
1639
1617
  send_chunk: (h) => {
1640
1618
  this.post_data(`${f.root}${R}/stream/${U}`, {
1641
1619
  ...h,
@@ -1649,9 +1627,9 @@ function Kt(e, s = {}, t, n, o, r) {
1649
1627
  ), a();
1650
1628
  },
1651
1629
  event_id: () => U,
1652
- wait_for_id: async () => (await Ge, b)
1630
+ wait_for_id: async () => (await Fe, b)
1653
1631
  };
1654
- return ge;
1632
+ return _e;
1655
1633
  } catch (i) {
1656
1634
  throw console.error("Submit function encountered an error:", i), i;
1657
1635
  }
@@ -1677,7 +1655,7 @@ function Yt(e, s, t, n) {
1677
1655
  );
1678
1656
  return { fn_index: o, endpoint_info: r, dependency: i };
1679
1657
  }
1680
- class Y {
1658
+ class V {
1681
1659
  app_reference;
1682
1660
  options;
1683
1661
  deep_link = null;
@@ -1702,7 +1680,7 @@ class Y {
1702
1680
  current_payload;
1703
1681
  get_url_config(s = null) {
1704
1682
  if (!this.config)
1705
- throw new Error(N);
1683
+ throw new Error(I);
1706
1684
  s === null && (s = window.location.href);
1707
1685
  const t = (i) => i.replace(/^\/+|\/+$/g, "");
1708
1686
  let n = t(new URL(this.config.root).pathname), o = t(new URL(s).pathname), r;
@@ -1710,7 +1688,7 @@ class Y {
1710
1688
  }
1711
1689
  get_page_config(s) {
1712
1690
  if (!this.config)
1713
- throw new Error(N);
1691
+ throw new Error(I);
1714
1692
  let t = this.config;
1715
1693
  return s in t.page || (s = ""), {
1716
1694
  ...t,
@@ -1726,17 +1704,15 @@ class Y {
1726
1704
  }
1727
1705
  fetch(s, t) {
1728
1706
  const n = new Headers(t?.headers || {});
1729
- if (this && this.cookies && n.append("Cookie", this.cookies), this && this.options.headers)
1730
- for (const o in this.options.headers)
1731
- n.append(o, this.options.headers[o]);
1732
- return fetch(s, { ...t, headers: n });
1707
+ return this && this.cookies && n.append("Cookie", this.cookies), this && this.options.headers && new Headers(this.options.headers).forEach((r, i) => {
1708
+ n.append(i, r);
1709
+ }), fetch(s, { ...t, headers: n });
1733
1710
  }
1734
1711
  stream(s) {
1735
1712
  const t = new Headers();
1736
- if (this && this.cookies && t.append("Cookie", this.cookies), this && this.options.headers)
1737
- for (const n in this.options.headers)
1738
- t.append(n, this.options.headers[n]);
1739
- return this && this.options.token && t.append("Authorization", `Bearer ${this.options.token}`), this.abort_controller = new AbortController(), this.stream_instance = Zt(s.toString(), {
1713
+ return this && this.cookies && t.append("Cookie", this.cookies), this && this.options.headers && new Headers(this.options.headers).forEach((o, r) => {
1714
+ t.append(r, o);
1715
+ }), this && this.options.token && t.append("Authorization", `Bearer ${this.options.token}`), this.abort_controller = new AbortController(), this.stream_instance = Zt(s.toString(), {
1740
1716
  credentials: "include",
1741
1717
  headers: t,
1742
1718
  signal: this.abort_controller.signal
@@ -1753,21 +1729,21 @@ class Y {
1753
1729
  resolve_config;
1754
1730
  resolve_cookies;
1755
1731
  constructor(s, t = { events: ["data"] }) {
1756
- this.app_reference = s, this.deep_link = t.query_params?.deep_link || null, t.events || (t.events = ["data"]), this.options = t, this.current_payload = {}, this.view_api = yt.bind(this), this.upload_files = bt.bind(this), this.handle_blob = At.bind(this), this.post_data = Nt.bind(this), this.submit = Kt.bind(this), this.predict = Dt.bind(this), this.open_stream = Mt.bind(this), this.resolve_config = dt.bind(this), this.resolve_cookies = ht.bind(this), this.upload = kt.bind(this), this.fetch = this.fetch.bind(this), this.handle_space_success = this.handle_space_success.bind(this), this.stream = this.stream.bind(this);
1732
+ this.app_reference = s, this.deep_link = t.query_params?.deep_link || null, t.events || (t.events = ["data"]), this.options = t, this.current_payload = {}, this.view_api = yt.bind(this), this.upload_files = bt.bind(this), this.handle_blob = At.bind(this), this.post_data = Dt.bind(this), this.submit = Kt.bind(this), this.predict = Nt.bind(this), this.open_stream = Mt.bind(this), this.resolve_config = pt.bind(this), this.resolve_cookies = ht.bind(this), this.upload = kt.bind(this), this.fetch = this.fetch.bind(this), this.handle_space_success = this.handle_space_success.bind(this), this.stream = this.stream.bind(this);
1757
1733
  }
1758
1734
  async init() {
1759
1735
  this.options.auth && await this.resolve_cookies(), await this._resolve_config().then(
1760
1736
  ({ config: s }) => this._resolve_heartbeat(s)
1761
- ), this.api_info = await this.view_api(), this.api_map = pt(this.config?.dependencies || []);
1737
+ ), this.api_info = await this.view_api(), this.api_map = lt(this.config?.dependencies || []);
1762
1738
  }
1763
1739
  async _resolve_heartbeat(s) {
1764
- if (s && (this.config = s, this.api_prefix = s.api_prefix || "", this.config && this.config.connect_heartbeat && this.config.space_id && this.options.token && (this.jwt = await be(
1740
+ if (s && (this.config = s, this.api_prefix = s.api_prefix || "", this.config && this.config.connect_heartbeat && this.config.space_id && this.options.token && (this.jwt = await ye(
1765
1741
  this.config.space_id,
1766
1742
  this.options.token,
1767
1743
  this.cookies
1768
- ))), s.space_id && this.options.token && (this.jwt = await be(s.space_id, this.options.token)), this.config && this.config.connect_heartbeat) {
1744
+ ))), s.space_id && this.options.token && (this.jwt = await ye(s.space_id, this.options.token)), this.config && this.config.connect_heartbeat) {
1769
1745
  const t = new URL(
1770
- `${this.config.root}${this.api_prefix}/${Xe}/${this.session_hash}`
1746
+ `${this.config.root}${this.api_prefix}/${Qe}/${this.session_hash}`
1771
1747
  );
1772
1748
  this.jwt && t.searchParams.set("__sign", this.jwt), this.heartbeat_event || (this.heartbeat_event = this.stream(t));
1773
1749
  }
@@ -1780,7 +1756,7 @@ class Y {
1780
1756
  }
1781
1757
  async reconnect() {
1782
1758
  const s = new URL(
1783
- `${this.config.root}${this.api_prefix}/${nt}`
1759
+ `${this.config.root}${this.api_prefix}/${st}`
1784
1760
  );
1785
1761
  let t;
1786
1762
  try {
@@ -1794,7 +1770,7 @@ class Y {
1794
1770
  return t !== this.config.app_id ? "changed" : "connected";
1795
1771
  }
1796
1772
  close() {
1797
- this.closed = !0, de(this.stream_status, this.abort_controller);
1773
+ this.closed = !0, le(this.stream_status, this.abort_controller);
1798
1774
  }
1799
1775
  set_current_payload(s) {
1800
1776
  this.current_payload = s;
@@ -1802,25 +1778,25 @@ class Y {
1802
1778
  static async duplicate(s, t = {
1803
1779
  events: ["data"]
1804
1780
  }) {
1805
- return It(s, t);
1781
+ return jt(s, t);
1806
1782
  }
1807
1783
  async _resolve_config() {
1808
- const { http_protocol: s, host: t, space_id: n } = await pe(
1784
+ const { http_protocol: s, host: t, space_id: n } = await ue(
1809
1785
  this.app_reference,
1810
1786
  this.options.token
1811
1787
  ), { status_callback: o } = this.options;
1812
- n && o && await je(n, o);
1788
+ n && o && await Pe(n, o);
1813
1789
  let r;
1814
1790
  try {
1815
1791
  let i = `${s}//${t}`;
1816
1792
  if (r = await this.resolve_config(i), !r)
1817
- throw new Error(N);
1793
+ throw new Error(I);
1818
1794
  return this.config_success(r);
1819
1795
  } catch (i) {
1820
1796
  if (n && o)
1821
1797
  G(
1822
1798
  n,
1823
- le.test(n) ? "space_name" : "subdomain",
1799
+ ce.test(n) ? "space_name" : "subdomain",
1824
1800
  this.handle_space_success
1825
1801
  );
1826
1802
  else
@@ -1838,18 +1814,18 @@ class Y {
1838
1814
  try {
1839
1815
  this.api_info = await this.view_api();
1840
1816
  } catch (t) {
1841
- console.error(it + t.message);
1817
+ console.error(ot + t.message);
1842
1818
  }
1843
1819
  return this.prepare_return_obj();
1844
1820
  }
1845
1821
  async handle_space_success(s) {
1846
1822
  if (!this)
1847
- throw new Error(N);
1823
+ throw new Error(I);
1848
1824
  const { status_callback: t } = this.options;
1849
1825
  if (t && t(s), s.status === "running")
1850
1826
  try {
1851
1827
  if (this.config = await this._resolve_config(), this.api_prefix = this?.config?.api_prefix || "", !this.config)
1852
- throw new Error(N);
1828
+ throw new Error(I);
1853
1829
  return await this.config_success(this.config);
1854
1830
  } catch (n) {
1855
1831
  throw t && t({
@@ -1862,7 +1838,7 @@ class Y {
1862
1838
  }
1863
1839
  async component_server(s, t, n) {
1864
1840
  if (!this.config)
1865
- throw new Error(N);
1841
+ throw new Error(I);
1866
1842
  const o = {}, { token: r } = this.options, { session_hash: i } = this;
1867
1843
  r && (o.Authorization = `Bearer ${this.options.token}`);
1868
1844
  let a, u = this.config.components.find(
@@ -1885,7 +1861,7 @@ class Y {
1885
1861
  r && (o.Authorization = `Bearer ${r}`);
1886
1862
  try {
1887
1863
  const p = await this.fetch(
1888
- `${a}${this.api_prefix}/${et}/`,
1864
+ `${a}${this.api_prefix}/${Xe}/`,
1889
1865
  {
1890
1866
  method: "POST",
1891
1867
  body: l,
@@ -1903,7 +1879,7 @@ class Y {
1903
1879
  }
1904
1880
  }
1905
1881
  set_cookies(s) {
1906
- this.cookies = De(s).join("; ");
1882
+ this.cookies = Ce(s).join("; ");
1907
1883
  }
1908
1884
  prepare_return_obj() {
1909
1885
  return {
@@ -1918,19 +1894,19 @@ class Y {
1918
1894
  async function ts(e, s = {
1919
1895
  events: ["data"]
1920
1896
  }) {
1921
- return await Y.connect(e, s);
1897
+ return await V.connect(e, s);
1922
1898
  }
1923
1899
  async function ss(e, s) {
1924
- return await Y.duplicate(e, s);
1900
+ return await V.duplicate(e, s);
1925
1901
  }
1926
1902
  export {
1927
- Y as Client,
1928
- Q as FileData,
1929
- ct as MISSING_CREDENTIALS_MSG,
1903
+ V as Client,
1904
+ Y as FileData,
1905
+ at as MISSING_CREDENTIALS_MSG,
1930
1906
  ts as client,
1931
1907
  ss as duplicate,
1932
1908
  es as handle_file,
1933
- Dt as predict,
1909
+ Nt as predict,
1934
1910
  Xt as prepare_files,
1935
1911
  Kt as submit,
1936
1912
  kt as upload,