swerasty_editor 0.2.4 → 0.2.6
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/style.css +1 -1
- package/dist/swerasty-editor.js +719 -689
- package/dist/swerasty-editor.umd.cjs +30 -30
- package/package.json +1 -1
package/dist/swerasty-editor.js
CHANGED
|
@@ -1,116 +1,116 @@
|
|
|
1
|
-
import { jsx as g, jsxs as
|
|
2
|
-
import oo, { forwardRef as be, useRef as j, useState as V, useCallback as
|
|
1
|
+
import { jsx as g, jsxs as M } from "react/jsx-runtime";
|
|
2
|
+
import oo, { forwardRef as be, useRef as j, useState as V, useCallback as le, useEffect as he, useImperativeHandle as io, createElement as Ye, useMemo as ni } from "react";
|
|
3
3
|
const so = be(({ onHistoryChange: t }, e) => {
|
|
4
|
-
const n = j(null), o = j(null), [s, l] = V(!1), [a, u] = V(!1), c = j(null), [d, f] = V([]), [p, h] = V(-1), m =
|
|
5
|
-
const
|
|
6
|
-
if (!
|
|
7
|
-
const
|
|
8
|
-
f([...
|
|
4
|
+
const n = j(null), o = j(null), [s, l] = V(!1), [a, u] = V(!1), c = j(null), [d, f] = V([]), [p, h] = V(-1), m = le(() => {
|
|
5
|
+
const E = n.current, C = c.current;
|
|
6
|
+
if (!E || !C || E.width === 0 || E.height === 0) return;
|
|
7
|
+
const S = C.getImageData(0, 0, E.width, E.height), v = d.slice(0, p + 1);
|
|
8
|
+
f([...v, S]), h(v.length);
|
|
9
9
|
}, [d, p]);
|
|
10
|
-
|
|
10
|
+
he(() => {
|
|
11
11
|
t == null || t({
|
|
12
12
|
canUndo: p > 0,
|
|
13
13
|
canRedo: p < d.length - 1
|
|
14
14
|
});
|
|
15
|
-
}, [d, p, t]),
|
|
15
|
+
}, [d, p, t]), he(() => {
|
|
16
16
|
if (typeof window > "u") return;
|
|
17
|
-
const
|
|
18
|
-
if (!
|
|
19
|
-
c.current =
|
|
20
|
-
const
|
|
17
|
+
const E = n.current, C = o.current;
|
|
18
|
+
if (!E || !C) return;
|
|
19
|
+
c.current = E.getContext("2d");
|
|
20
|
+
const S = new ResizeObserver((v) => {
|
|
21
21
|
var P;
|
|
22
|
-
const { width:
|
|
23
|
-
if (
|
|
22
|
+
const { width: R, height: w } = v[0].contentRect;
|
|
23
|
+
if (R === 0 || w === 0) return;
|
|
24
24
|
let U = null;
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
28
|
-
const L =
|
|
25
|
+
E.width > 0 && E.height > 0 && (U = ((P = c.current) == null ? void 0 : P.getImageData(0, 0, E.width, E.height)) || null), E.width = R, E.height = w;
|
|
26
|
+
const x = c.current;
|
|
27
|
+
if (x && (x.lineCap = "round", x.strokeStyle = "#000", x.lineWidth = 2, U && x.putImageData(U, 0, 0)), d.length === 0) {
|
|
28
|
+
const L = x == null ? void 0 : x.getImageData(0, 0, R, w);
|
|
29
29
|
L && (f([L]), h(0));
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
|
-
return
|
|
33
|
-
|
|
32
|
+
return S.observe(C), () => {
|
|
33
|
+
S.disconnect();
|
|
34
34
|
};
|
|
35
35
|
}, []);
|
|
36
|
-
const y = (
|
|
37
|
-
const
|
|
38
|
-
if (!
|
|
39
|
-
const
|
|
36
|
+
const y = (E) => {
|
|
37
|
+
const C = n.current;
|
|
38
|
+
if (!C) return { offsetX: 0, offsetY: 0 };
|
|
39
|
+
const S = C.getBoundingClientRect(), v = "touches" in E ? E.touches[0].clientX : E.clientX, R = "touches" in E ? E.touches[0].clientY : E.clientY;
|
|
40
40
|
return {
|
|
41
|
-
offsetX:
|
|
42
|
-
offsetY:
|
|
41
|
+
offsetX: v - S.left,
|
|
42
|
+
offsetY: R - S.top
|
|
43
43
|
};
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
if (!
|
|
48
|
-
const { offsetX:
|
|
49
|
-
|
|
44
|
+
}, _ = (E) => {
|
|
45
|
+
E.preventDefault();
|
|
46
|
+
const C = c.current;
|
|
47
|
+
if (!C) return;
|
|
48
|
+
const { offsetX: S, offsetY: v } = y(E);
|
|
49
|
+
C.beginPath(), C.moveTo(S, v), l(!0), u(!0);
|
|
50
50
|
}, T = () => {
|
|
51
|
-
const
|
|
52
|
-
!
|
|
53
|
-
},
|
|
51
|
+
const E = c.current;
|
|
52
|
+
!E || !s || (E.closePath(), l(!1), m());
|
|
53
|
+
}, I = (E) => {
|
|
54
54
|
if (!s || !c.current) return;
|
|
55
|
-
|
|
56
|
-
const { offsetX:
|
|
57
|
-
c.current.lineTo(
|
|
55
|
+
E.preventDefault();
|
|
56
|
+
const { offsetX: C, offsetY: S } = y(E);
|
|
57
|
+
c.current.lineTo(C, S), c.current.stroke();
|
|
58
58
|
};
|
|
59
59
|
return io(e, () => ({
|
|
60
60
|
clear() {
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
f([
|
|
61
|
+
const E = c.current, C = n.current;
|
|
62
|
+
if (E && C && C.width > 0 && C.height > 0) {
|
|
63
|
+
E.clearRect(0, 0, C.width, C.height), u(!1);
|
|
64
|
+
const S = E.getImageData(0, 0, C.width, C.height);
|
|
65
|
+
f([S]), h(0);
|
|
66
66
|
}
|
|
67
67
|
},
|
|
68
68
|
undo() {
|
|
69
|
-
var
|
|
69
|
+
var E;
|
|
70
70
|
if (p > 0) {
|
|
71
|
-
const
|
|
72
|
-
h(
|
|
73
|
-
const
|
|
74
|
-
(
|
|
71
|
+
const C = p - 1;
|
|
72
|
+
h(C);
|
|
73
|
+
const S = d[C];
|
|
74
|
+
(E = c.current) == null || E.putImageData(S, 0, 0), u(C > 0);
|
|
75
75
|
}
|
|
76
76
|
},
|
|
77
77
|
redo() {
|
|
78
|
-
var
|
|
78
|
+
var E;
|
|
79
79
|
if (p < d.length - 1) {
|
|
80
|
-
const
|
|
81
|
-
h(
|
|
82
|
-
const
|
|
83
|
-
(
|
|
80
|
+
const C = p + 1;
|
|
81
|
+
h(C);
|
|
82
|
+
const S = d[C];
|
|
83
|
+
(E = c.current) == null || E.putImageData(S, 0, 0), u(!0);
|
|
84
84
|
}
|
|
85
85
|
},
|
|
86
86
|
getTrimmedImageData() {
|
|
87
|
-
const
|
|
88
|
-
if (!a || !
|
|
89
|
-
const
|
|
90
|
-
let U =
|
|
91
|
-
for (let H = 0; H <
|
|
92
|
-
for (let K = 0; K <
|
|
93
|
-
|
|
94
|
-
if (U ===
|
|
87
|
+
const E = n.current, C = c.current;
|
|
88
|
+
if (!a || !E || !C || E.width === 0 || E.height === 0) return null;
|
|
89
|
+
const S = E.width, v = E.height, w = C.getImageData(0, 0, S, v).data;
|
|
90
|
+
let U = S, x = v, P = 0, L = 0;
|
|
91
|
+
for (let H = 0; H < v; H++)
|
|
92
|
+
for (let K = 0; K < S; K++)
|
|
93
|
+
w[(S * H + K) * 4 + 3] > 0 && (U = Math.min(U, K), x = Math.min(x, H), P = Math.max(P, K), L = Math.max(L, H));
|
|
94
|
+
if (U === S)
|
|
95
95
|
return null;
|
|
96
96
|
const k = 15;
|
|
97
|
-
U = Math.max(0, U - k),
|
|
98
|
-
const b = P - U, q = L -
|
|
99
|
-
|
|
100
|
-
const G =
|
|
101
|
-
return G ? (G.drawImage(
|
|
97
|
+
U = Math.max(0, U - k), x = Math.max(0, x - k), P = Math.min(S, P + k), L = Math.min(v, L + k);
|
|
98
|
+
const b = P - U, q = L - x, N = document.createElement("canvas");
|
|
99
|
+
N.width = b, N.height = q;
|
|
100
|
+
const G = N.getContext("2d");
|
|
101
|
+
return G ? (G.drawImage(E, U, x, b, q, 0, 0, b, q), N.toDataURL("image/png")) : null;
|
|
102
102
|
}
|
|
103
103
|
})), /* @__PURE__ */ g("div", { ref: o, className: "absolute inset-0 w-full h-full", children: /* @__PURE__ */ g(
|
|
104
104
|
"canvas",
|
|
105
105
|
{
|
|
106
106
|
ref: n,
|
|
107
|
-
onMouseDown:
|
|
107
|
+
onMouseDown: _,
|
|
108
108
|
onMouseUp: T,
|
|
109
|
-
onMouseMove:
|
|
109
|
+
onMouseMove: I,
|
|
110
110
|
onMouseLeave: T,
|
|
111
|
-
onTouchStart:
|
|
111
|
+
onTouchStart: _,
|
|
112
112
|
onTouchEnd: T,
|
|
113
|
-
onTouchMove:
|
|
113
|
+
onTouchMove: I,
|
|
114
114
|
className: "w-full h-full",
|
|
115
115
|
style: { cursor: "crosshair", touchAction: "none" }
|
|
116
116
|
}
|
|
@@ -144,7 +144,7 @@ function ri(t, e, n, o) {
|
|
|
144
144
|
*/
|
|
145
145
|
class te {
|
|
146
146
|
}
|
|
147
|
-
function
|
|
147
|
+
function A(t, e) {
|
|
148
148
|
const n = /\{([^}]+)\}/g;
|
|
149
149
|
return t.replace(n, (o, s) => {
|
|
150
150
|
if (Object.prototype.hasOwnProperty.call(e, s)) {
|
|
@@ -655,10 +655,10 @@ var Tn;
|
|
|
655
655
|
(function(t) {
|
|
656
656
|
t.MUSIC_GENERATION_MODE_UNSPECIFIED = "MUSIC_GENERATION_MODE_UNSPECIFIED", t.QUALITY = "QUALITY", t.DIVERSITY = "DIVERSITY", t.VOCALIZATION = "VOCALIZATION";
|
|
657
657
|
})(Tn || (Tn = {}));
|
|
658
|
-
var
|
|
658
|
+
var de;
|
|
659
659
|
(function(t) {
|
|
660
660
|
t.PLAYBACK_CONTROL_UNSPECIFIED = "PLAYBACK_CONTROL_UNSPECIFIED", t.PLAY = "PLAY", t.PAUSE = "PAUSE", t.STOP = "STOP", t.RESET_CONTEXT = "RESET_CONTEXT";
|
|
661
|
-
})(
|
|
661
|
+
})(de || (de = {}));
|
|
662
662
|
class Oe {
|
|
663
663
|
constructor(e) {
|
|
664
664
|
const n = {};
|
|
@@ -670,7 +670,7 @@ class Oe {
|
|
|
670
670
|
return this.responseInternal.json();
|
|
671
671
|
}
|
|
672
672
|
}
|
|
673
|
-
class
|
|
673
|
+
class _e {
|
|
674
674
|
/**
|
|
675
675
|
* Returns the concatenation of all text parts from the first candidate in the response.
|
|
676
676
|
*
|
|
@@ -1108,7 +1108,7 @@ function bi(t, e) {
|
|
|
1108
1108
|
});
|
|
1109
1109
|
}
|
|
1110
1110
|
}
|
|
1111
|
-
function
|
|
1111
|
+
function fe(t) {
|
|
1112
1112
|
const e = {}, n = ["items"], o = ["anyOf"], s = ["properties"];
|
|
1113
1113
|
if (t.type && t.anyOf)
|
|
1114
1114
|
throw new Error("type and anyOf cannot be both populated.");
|
|
@@ -1123,7 +1123,7 @@ function ce(t) {
|
|
|
1123
1123
|
continue;
|
|
1124
1124
|
e.type = Object.values(oe).includes(u.toUpperCase()) ? u.toUpperCase() : oe.TYPE_UNSPECIFIED;
|
|
1125
1125
|
} else if (n.includes(a))
|
|
1126
|
-
e[a] =
|
|
1126
|
+
e[a] = fe(u);
|
|
1127
1127
|
else if (o.includes(a)) {
|
|
1128
1128
|
const c = [];
|
|
1129
1129
|
for (const d of u) {
|
|
@@ -1131,13 +1131,13 @@ function ce(t) {
|
|
|
1131
1131
|
e.nullable = !0;
|
|
1132
1132
|
continue;
|
|
1133
1133
|
}
|
|
1134
|
-
c.push(
|
|
1134
|
+
c.push(fe(d));
|
|
1135
1135
|
}
|
|
1136
1136
|
e[a] = c;
|
|
1137
1137
|
} else if (s.includes(a)) {
|
|
1138
1138
|
const c = {};
|
|
1139
1139
|
for (const [d, f] of Object.entries(u))
|
|
1140
|
-
c[d] =
|
|
1140
|
+
c[d] = fe(f);
|
|
1141
1141
|
e[a] = c;
|
|
1142
1142
|
} else {
|
|
1143
1143
|
if (a === "additionalProperties")
|
|
@@ -1147,7 +1147,7 @@ function ce(t) {
|
|
|
1147
1147
|
return e;
|
|
1148
1148
|
}
|
|
1149
1149
|
function ct(t) {
|
|
1150
|
-
return
|
|
1150
|
+
return fe(t);
|
|
1151
1151
|
}
|
|
1152
1152
|
function ft(t) {
|
|
1153
1153
|
if (typeof t == "object")
|
|
@@ -1167,13 +1167,13 @@ function pt(t) {
|
|
|
1167
1167
|
throw new Error("multiSpeakerVoiceConfig is not supported in the live API.");
|
|
1168
1168
|
return t;
|
|
1169
1169
|
}
|
|
1170
|
-
function
|
|
1170
|
+
function me(t) {
|
|
1171
1171
|
if (t.functionDeclarations)
|
|
1172
1172
|
for (const e of t.functionDeclarations)
|
|
1173
|
-
e.parameters && (Object.keys(e.parameters).includes("$schema") ? e.parametersJsonSchema || (e.parametersJsonSchema = e.parameters, delete e.parameters) : e.parameters =
|
|
1173
|
+
e.parameters && (Object.keys(e.parameters).includes("$schema") ? e.parametersJsonSchema || (e.parametersJsonSchema = e.parameters, delete e.parameters) : e.parameters = fe(e.parameters)), e.response && (Object.keys(e.response).includes("$schema") ? e.responseJsonSchema || (e.responseJsonSchema = e.response, delete e.response) : e.response = fe(e.response));
|
|
1174
1174
|
return t;
|
|
1175
1175
|
}
|
|
1176
|
-
function
|
|
1176
|
+
function ge(t) {
|
|
1177
1177
|
if (t == null)
|
|
1178
1178
|
throw new Error("tools is required");
|
|
1179
1179
|
if (!Array.isArray(t))
|
|
@@ -1340,7 +1340,7 @@ function To(t) {
|
|
|
1340
1340
|
}
|
|
1341
1341
|
return l && (e.inlinedEmbedContentResponses = e.inlinedResponses, delete e.inlinedResponses), t;
|
|
1342
1342
|
}
|
|
1343
|
-
function
|
|
1343
|
+
function ye(t, e) {
|
|
1344
1344
|
const n = e;
|
|
1345
1345
|
if (!t.isVertexAI()) {
|
|
1346
1346
|
if (/batches\/[^/]+$/.test(n))
|
|
@@ -1520,11 +1520,11 @@ function Xi(t) {
|
|
|
1520
1520
|
}
|
|
1521
1521
|
function Qi(t, e) {
|
|
1522
1522
|
const n = {}, o = i(e, ["name"]);
|
|
1523
|
-
return o != null && r(n, ["_url", "name"],
|
|
1523
|
+
return o != null && r(n, ["_url", "name"], ye(t, o)), n;
|
|
1524
1524
|
}
|
|
1525
1525
|
function Zi(t, e) {
|
|
1526
1526
|
const n = {}, o = i(e, ["name"]);
|
|
1527
|
-
return o != null && r(n, ["_url", "name"],
|
|
1527
|
+
return o != null && r(n, ["_url", "name"], ye(t, o)), n;
|
|
1528
1528
|
}
|
|
1529
1529
|
function ji(t) {
|
|
1530
1530
|
const e = {}, n = i(t, ["content"]);
|
|
@@ -1620,11 +1620,11 @@ function ss(t, e) {
|
|
|
1620
1620
|
}
|
|
1621
1621
|
function rs(t, e) {
|
|
1622
1622
|
const n = {}, o = i(e, ["name"]);
|
|
1623
|
-
return o != null && r(n, ["_url", "name"],
|
|
1623
|
+
return o != null && r(n, ["_url", "name"], ye(t, o)), n;
|
|
1624
1624
|
}
|
|
1625
1625
|
function ls(t, e) {
|
|
1626
1626
|
const n = {}, o = i(e, ["name"]);
|
|
1627
|
-
return o != null && r(n, ["_url", "name"],
|
|
1627
|
+
return o != null && r(n, ["_url", "name"], ye(t, o)), n;
|
|
1628
1628
|
}
|
|
1629
1629
|
function as(t) {
|
|
1630
1630
|
const e = {}, n = i(t, [
|
|
@@ -1749,52 +1749,52 @@ function gs(t, e, n) {
|
|
|
1749
1749
|
"frequencyPenalty"
|
|
1750
1750
|
]);
|
|
1751
1751
|
y != null && r(o, ["frequencyPenalty"], y);
|
|
1752
|
-
const
|
|
1753
|
-
|
|
1752
|
+
const _ = i(e, ["seed"]);
|
|
1753
|
+
_ != null && r(o, ["seed"], _);
|
|
1754
1754
|
const T = i(e, [
|
|
1755
1755
|
"responseMimeType"
|
|
1756
1756
|
]);
|
|
1757
1757
|
T != null && r(o, ["responseMimeType"], T);
|
|
1758
|
-
const
|
|
1758
|
+
const I = i(e, [
|
|
1759
1759
|
"responseSchema"
|
|
1760
1760
|
]);
|
|
1761
|
-
|
|
1762
|
-
const
|
|
1761
|
+
I != null && r(o, ["responseSchema"], ct(I));
|
|
1762
|
+
const E = i(e, [
|
|
1763
1763
|
"responseJsonSchema"
|
|
1764
1764
|
]);
|
|
1765
|
-
if (
|
|
1765
|
+
if (E != null && r(o, ["responseJsonSchema"], E), i(e, ["routingConfig"]) !== void 0)
|
|
1766
1766
|
throw new Error("routingConfig parameter is not supported in Gemini API.");
|
|
1767
1767
|
if (i(e, ["modelSelectionConfig"]) !== void 0)
|
|
1768
1768
|
throw new Error("modelSelectionConfig parameter is not supported in Gemini API.");
|
|
1769
|
-
const
|
|
1769
|
+
const C = i(e, [
|
|
1770
1770
|
"safetySettings"
|
|
1771
1771
|
]);
|
|
1772
|
-
if (n !== void 0 &&
|
|
1773
|
-
let b =
|
|
1772
|
+
if (n !== void 0 && C != null) {
|
|
1773
|
+
let b = C;
|
|
1774
1774
|
Array.isArray(b) && (b = b.map((q) => ks(q))), r(n, ["safetySettings"], b);
|
|
1775
1775
|
}
|
|
1776
|
-
const
|
|
1777
|
-
if (n !== void 0 &&
|
|
1778
|
-
let b =
|
|
1779
|
-
Array.isArray(b) && (b = b.map((q) => Us(
|
|
1776
|
+
const S = i(e, ["tools"]);
|
|
1777
|
+
if (n !== void 0 && S != null) {
|
|
1778
|
+
let b = ge(S);
|
|
1779
|
+
Array.isArray(b) && (b = b.map((q) => Us(me(q)))), r(n, ["tools"], b);
|
|
1780
1780
|
}
|
|
1781
|
-
const
|
|
1782
|
-
if (n !== void 0 &&
|
|
1781
|
+
const v = i(e, ["toolConfig"]);
|
|
1782
|
+
if (n !== void 0 && v != null && r(n, ["toolConfig"], Ds(v)), i(e, ["labels"]) !== void 0)
|
|
1783
1783
|
throw new Error("labels parameter is not supported in Gemini API.");
|
|
1784
|
-
const
|
|
1784
|
+
const R = i(e, [
|
|
1785
1785
|
"cachedContent"
|
|
1786
1786
|
]);
|
|
1787
|
-
n !== void 0 &&
|
|
1788
|
-
const
|
|
1787
|
+
n !== void 0 && R != null && r(n, ["cachedContent"], ne(t, R));
|
|
1788
|
+
const w = i(e, [
|
|
1789
1789
|
"responseModalities"
|
|
1790
1790
|
]);
|
|
1791
|
-
|
|
1791
|
+
w != null && r(o, ["responseModalities"], w);
|
|
1792
1792
|
const U = i(e, [
|
|
1793
1793
|
"mediaResolution"
|
|
1794
1794
|
]);
|
|
1795
1795
|
U != null && r(o, ["mediaResolution"], U);
|
|
1796
|
-
const
|
|
1797
|
-
if (
|
|
1796
|
+
const x = i(e, ["speechConfig"]);
|
|
1797
|
+
if (x != null && r(o, ["speechConfig"], ft(x)), i(e, ["audioTimestamp"]) !== void 0)
|
|
1798
1798
|
throw new Error("audioTimestamp parameter is not supported in Gemini API.");
|
|
1799
1799
|
const P = i(e, [
|
|
1800
1800
|
"thinkingConfig"
|
|
@@ -1832,11 +1832,11 @@ function ys(t) {
|
|
|
1832
1832
|
}
|
|
1833
1833
|
function Ts(t, e) {
|
|
1834
1834
|
const n = {}, o = i(e, ["name"]);
|
|
1835
|
-
return o != null && r(n, ["_url", "name"],
|
|
1835
|
+
return o != null && r(n, ["_url", "name"], ye(t, o)), n;
|
|
1836
1836
|
}
|
|
1837
1837
|
function _s(t, e) {
|
|
1838
1838
|
const n = {}, o = i(e, ["name"]);
|
|
1839
|
-
return o != null && r(n, ["_url", "name"],
|
|
1839
|
+
return o != null && r(n, ["_url", "name"], ye(t, o)), n;
|
|
1840
1840
|
}
|
|
1841
1841
|
function Es(t) {
|
|
1842
1842
|
const e = {};
|
|
@@ -2035,7 +2035,7 @@ var ee;
|
|
|
2035
2035
|
(function(t) {
|
|
2036
2036
|
t.PAGED_ITEM_BATCH_JOBS = "batchJobs", t.PAGED_ITEM_MODELS = "models", t.PAGED_ITEM_TUNING_JOBS = "tuningJobs", t.PAGED_ITEM_FILES = "files", t.PAGED_ITEM_CACHED_CONTENTS = "cachedContents", t.PAGED_ITEM_FILE_SEARCH_STORES = "fileSearchStores", t.PAGED_ITEM_DOCUMENTS = "documents";
|
|
2037
2037
|
})(ee || (ee = {}));
|
|
2038
|
-
class
|
|
2038
|
+
class ae {
|
|
2039
2039
|
constructor(e, n, o, s) {
|
|
2040
2040
|
this.pageInternal = [], this.paramsInternal = {}, this.requestInternal = n, this.init(e, o, s);
|
|
2041
2041
|
}
|
|
@@ -2175,7 +2175,7 @@ class le {
|
|
|
2175
2175
|
*/
|
|
2176
2176
|
class bs extends te {
|
|
2177
2177
|
constructor(e) {
|
|
2178
|
-
super(), this.apiClient = e, this.list = async (n = {}) => new
|
|
2178
|
+
super(), this.apiClient = e, this.list = async (n = {}) => new ae(ee.PAGED_ITEM_BATCH_JOBS, (o) => this.listInternal(o), await this.listInternal(n), n), this.create = async (n) => (this.apiClient.isVertexAI() && (n.config = this.formatDestination(n.src, n.config)), this.createInternal(n)), this.createEmbeddings = async (n) => {
|
|
2179
2179
|
if (console.warn("batches.createEmbeddings() is experimental and may change without notice."), this.apiClient.isVertexAI())
|
|
2180
2180
|
throw new Error("Vertex AI does not support batches.createEmbeddings.");
|
|
2181
2181
|
return this.createEmbeddingsInternal(n);
|
|
@@ -2187,7 +2187,7 @@ class bs extends te {
|
|
|
2187
2187
|
this.apiClient,
|
|
2188
2188
|
// Use instance apiClient
|
|
2189
2189
|
e
|
|
2190
|
-
), o = n._url, s =
|
|
2190
|
+
), o = n._url, s = A("{model}:batchGenerateContent", o), u = n.batch.inputConfig.requests, c = u.requests, d = [];
|
|
2191
2191
|
for (const f of c) {
|
|
2192
2192
|
const p = Object.assign({}, f);
|
|
2193
2193
|
if (p.systemInstruction) {
|
|
@@ -2240,7 +2240,7 @@ class bs extends te {
|
|
|
2240
2240
|
let a, u = "", c = {};
|
|
2241
2241
|
if (this.apiClient.isVertexAI()) {
|
|
2242
2242
|
const d = os(this.apiClient, e);
|
|
2243
|
-
return u =
|
|
2243
|
+
return u = A("batchPredictionJobs", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
2244
2244
|
path: u,
|
|
2245
2245
|
queryParams: c,
|
|
2246
2246
|
body: JSON.stringify(d),
|
|
@@ -2250,7 +2250,7 @@ class bs extends te {
|
|
|
2250
2250
|
}).then((f) => f.json()), a.then((f) => Qe(f));
|
|
2251
2251
|
} else {
|
|
2252
2252
|
const d = kn(this.apiClient, e);
|
|
2253
|
-
return u =
|
|
2253
|
+
return u = A("{model}:batchGenerateContent", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
2254
2254
|
path: u,
|
|
2255
2255
|
queryParams: c,
|
|
2256
2256
|
body: JSON.stringify(d),
|
|
@@ -2274,7 +2274,7 @@ class bs extends te {
|
|
|
2274
2274
|
throw new Error("This method is only supported by the Gemini Developer API.");
|
|
2275
2275
|
{
|
|
2276
2276
|
const u = ss(this.apiClient, e);
|
|
2277
|
-
return l =
|
|
2277
|
+
return l = A("{model}:asyncBatchEmbedContent", u._url), a = u._query, delete u._url, delete u._query, s = this.apiClient.request({
|
|
2278
2278
|
path: l,
|
|
2279
2279
|
queryParams: a,
|
|
2280
2280
|
body: JSON.stringify(u),
|
|
@@ -2300,7 +2300,7 @@ class bs extends te {
|
|
|
2300
2300
|
let a, u = "", c = {};
|
|
2301
2301
|
if (this.apiClient.isVertexAI()) {
|
|
2302
2302
|
const d = _s(this.apiClient, e);
|
|
2303
|
-
return u =
|
|
2303
|
+
return u = A("batchPredictionJobs/{name}", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
2304
2304
|
path: u,
|
|
2305
2305
|
queryParams: c,
|
|
2306
2306
|
body: JSON.stringify(d),
|
|
@@ -2310,7 +2310,7 @@ class bs extends te {
|
|
|
2310
2310
|
}).then((f) => f.json()), a.then((f) => Qe(f));
|
|
2311
2311
|
} else {
|
|
2312
2312
|
const d = Ts(this.apiClient, e);
|
|
2313
|
-
return u =
|
|
2313
|
+
return u = A("batches/{name}", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
2314
2314
|
path: u,
|
|
2315
2315
|
queryParams: c,
|
|
2316
2316
|
body: JSON.stringify(d),
|
|
@@ -2336,7 +2336,7 @@ class bs extends te {
|
|
|
2336
2336
|
let a = "", u = {};
|
|
2337
2337
|
if (this.apiClient.isVertexAI()) {
|
|
2338
2338
|
const c = Zi(this.apiClient, e);
|
|
2339
|
-
a =
|
|
2339
|
+
a = A("batchPredictionJobs/{name}:cancel", c._url), u = c._query, delete c._url, delete c._query, await this.apiClient.request({
|
|
2340
2340
|
path: a,
|
|
2341
2341
|
queryParams: u,
|
|
2342
2342
|
body: JSON.stringify(c),
|
|
@@ -2346,7 +2346,7 @@ class bs extends te {
|
|
|
2346
2346
|
});
|
|
2347
2347
|
} else {
|
|
2348
2348
|
const c = Qi(this.apiClient, e);
|
|
2349
|
-
a =
|
|
2349
|
+
a = A("batches/{name}:cancel", c._url), u = c._query, delete c._url, delete c._query, await this.apiClient.request({
|
|
2350
2350
|
path: a,
|
|
2351
2351
|
queryParams: u,
|
|
2352
2352
|
body: JSON.stringify(c),
|
|
@@ -2361,7 +2361,7 @@ class bs extends te {
|
|
|
2361
2361
|
let a, u = "", c = {};
|
|
2362
2362
|
if (this.apiClient.isVertexAI()) {
|
|
2363
2363
|
const d = Rs(e);
|
|
2364
|
-
return u =
|
|
2364
|
+
return u = A("batchPredictionJobs", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
2365
2365
|
path: u,
|
|
2366
2366
|
queryParams: c,
|
|
2367
2367
|
body: JSON.stringify(d),
|
|
@@ -2379,7 +2379,7 @@ class bs extends te {
|
|
|
2379
2379
|
});
|
|
2380
2380
|
} else {
|
|
2381
2381
|
const d = ws(e);
|
|
2382
|
-
return u =
|
|
2382
|
+
return u = A("batches", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
2383
2383
|
path: u,
|
|
2384
2384
|
queryParams: c,
|
|
2385
2385
|
body: JSON.stringify(d),
|
|
@@ -2413,7 +2413,7 @@ class bs extends te {
|
|
|
2413
2413
|
let a, u = "", c = {};
|
|
2414
2414
|
if (this.apiClient.isVertexAI()) {
|
|
2415
2415
|
const d = ls(this.apiClient, e);
|
|
2416
|
-
return u =
|
|
2416
|
+
return u = A("batchPredictionJobs/{name}", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
2417
2417
|
path: u,
|
|
2418
2418
|
queryParams: c,
|
|
2419
2419
|
body: JSON.stringify(d),
|
|
@@ -2428,7 +2428,7 @@ class bs extends te {
|
|
|
2428
2428
|
})), a.then((f) => us(f));
|
|
2429
2429
|
} else {
|
|
2430
2430
|
const d = rs(this.apiClient, e);
|
|
2431
|
-
return u =
|
|
2431
|
+
return u = A("batches/{name}", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
2432
2432
|
path: u,
|
|
2433
2433
|
queryParams: c,
|
|
2434
2434
|
body: JSON.stringify(d),
|
|
@@ -2822,7 +2822,7 @@ function fr(t, e) {
|
|
|
2822
2822
|
*/
|
|
2823
2823
|
class pr extends te {
|
|
2824
2824
|
constructor(e) {
|
|
2825
|
-
super(), this.apiClient = e, this.list = async (n = {}) => new
|
|
2825
|
+
super(), this.apiClient = e, this.list = async (n = {}) => new ae(ee.PAGED_ITEM_CACHED_CONTENTS, (o) => this.listInternal(o), await this.listInternal(n), n);
|
|
2826
2826
|
}
|
|
2827
2827
|
/**
|
|
2828
2828
|
* Creates a cached contents resource.
|
|
@@ -2855,7 +2855,7 @@ class pr extends te {
|
|
|
2855
2855
|
let a, u = "", c = {};
|
|
2856
2856
|
if (this.apiClient.isVertexAI()) {
|
|
2857
2857
|
const d = qs(this.apiClient, e);
|
|
2858
|
-
return u =
|
|
2858
|
+
return u = A("cachedContents", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
2859
2859
|
path: u,
|
|
2860
2860
|
queryParams: c,
|
|
2861
2861
|
body: JSON.stringify(d),
|
|
@@ -2865,7 +2865,7 @@ class pr extends te {
|
|
|
2865
2865
|
}).then((f) => f.json()), a.then((f) => f);
|
|
2866
2866
|
} else {
|
|
2867
2867
|
const d = Vs(this.apiClient, e);
|
|
2868
|
-
return u =
|
|
2868
|
+
return u = A("cachedContents", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
2869
2869
|
path: u,
|
|
2870
2870
|
queryParams: c,
|
|
2871
2871
|
body: JSON.stringify(d),
|
|
@@ -2891,7 +2891,7 @@ class pr extends te {
|
|
|
2891
2891
|
let a, u = "", c = {};
|
|
2892
2892
|
if (this.apiClient.isVertexAI()) {
|
|
2893
2893
|
const d = Xs(this.apiClient, e);
|
|
2894
|
-
return u =
|
|
2894
|
+
return u = A("{name}", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
2895
2895
|
path: u,
|
|
2896
2896
|
queryParams: c,
|
|
2897
2897
|
body: JSON.stringify(d),
|
|
@@ -2901,7 +2901,7 @@ class pr extends te {
|
|
|
2901
2901
|
}).then((f) => f.json()), a.then((f) => f);
|
|
2902
2902
|
} else {
|
|
2903
2903
|
const d = Os(this.apiClient, e);
|
|
2904
|
-
return u =
|
|
2904
|
+
return u = A("{name}", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
2905
2905
|
path: u,
|
|
2906
2906
|
queryParams: c,
|
|
2907
2907
|
body: JSON.stringify(d),
|
|
@@ -2927,7 +2927,7 @@ class pr extends te {
|
|
|
2927
2927
|
let a, u = "", c = {};
|
|
2928
2928
|
if (this.apiClient.isVertexAI()) {
|
|
2929
2929
|
const d = Bs(this.apiClient, e);
|
|
2930
|
-
return u =
|
|
2930
|
+
return u = A("{name}", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
2931
2931
|
path: u,
|
|
2932
2932
|
queryParams: c,
|
|
2933
2933
|
body: JSON.stringify(d),
|
|
@@ -2945,7 +2945,7 @@ class pr extends te {
|
|
|
2945
2945
|
});
|
|
2946
2946
|
} else {
|
|
2947
2947
|
const d = Hs(this.apiClient, e);
|
|
2948
|
-
return u =
|
|
2948
|
+
return u = A("{name}", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
2949
2949
|
path: u,
|
|
2950
2950
|
queryParams: c,
|
|
2951
2951
|
body: JSON.stringify(d),
|
|
@@ -2982,7 +2982,7 @@ class pr extends te {
|
|
|
2982
2982
|
let a, u = "", c = {};
|
|
2983
2983
|
if (this.apiClient.isVertexAI()) {
|
|
2984
2984
|
const d = fr(this.apiClient, e);
|
|
2985
|
-
return u =
|
|
2985
|
+
return u = A("{name}", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
2986
2986
|
path: u,
|
|
2987
2987
|
queryParams: c,
|
|
2988
2988
|
body: JSON.stringify(d),
|
|
@@ -2992,7 +2992,7 @@ class pr extends te {
|
|
|
2992
2992
|
}).then((f) => f.json()), a.then((f) => f);
|
|
2993
2993
|
} else {
|
|
2994
2994
|
const d = cr(this.apiClient, e);
|
|
2995
|
-
return u =
|
|
2995
|
+
return u = A("{name}", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
2996
2996
|
path: u,
|
|
2997
2997
|
queryParams: c,
|
|
2998
2998
|
body: JSON.stringify(d),
|
|
@@ -3007,7 +3007,7 @@ class pr extends te {
|
|
|
3007
3007
|
let a, u = "", c = {};
|
|
3008
3008
|
if (this.apiClient.isVertexAI()) {
|
|
3009
3009
|
const d = nr(e);
|
|
3010
|
-
return u =
|
|
3010
|
+
return u = A("cachedContents", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
3011
3011
|
path: u,
|
|
3012
3012
|
queryParams: c,
|
|
3013
3013
|
body: JSON.stringify(d),
|
|
@@ -3025,7 +3025,7 @@ class pr extends te {
|
|
|
3025
3025
|
});
|
|
3026
3026
|
} else {
|
|
3027
3027
|
const d = tr(e);
|
|
3028
|
-
return u =
|
|
3028
|
+
return u = A("cachedContents", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
3029
3029
|
path: u,
|
|
3030
3030
|
queryParams: c,
|
|
3031
3031
|
body: JSON.stringify(d),
|
|
@@ -3077,17 +3077,17 @@ function X(t, e, n) {
|
|
|
3077
3077
|
};
|
|
3078
3078
|
}
|
|
3079
3079
|
function u(m, y) {
|
|
3080
|
-
o[m] && (s[m] = function(
|
|
3081
|
-
return new Promise(function(T,
|
|
3082
|
-
l.push([m,
|
|
3080
|
+
o[m] && (s[m] = function(_) {
|
|
3081
|
+
return new Promise(function(T, I) {
|
|
3082
|
+
l.push([m, _, T, I]) > 1 || c(m, _);
|
|
3083
3083
|
});
|
|
3084
3084
|
}, y && (s[m] = y(s[m])));
|
|
3085
3085
|
}
|
|
3086
3086
|
function c(m, y) {
|
|
3087
3087
|
try {
|
|
3088
3088
|
d(o[m](y));
|
|
3089
|
-
} catch (
|
|
3090
|
-
h(l[0][3],
|
|
3089
|
+
} catch (_) {
|
|
3090
|
+
h(l[0][3], _);
|
|
3091
3091
|
}
|
|
3092
3092
|
}
|
|
3093
3093
|
function d(m) {
|
|
@@ -3319,8 +3319,8 @@ class yr {
|
|
|
3319
3319
|
u = m.value, p = !1;
|
|
3320
3320
|
const y = u;
|
|
3321
3321
|
if (hr(y)) {
|
|
3322
|
-
const
|
|
3323
|
-
|
|
3322
|
+
const _ = (d = (c = y.candidates) === null || c === void 0 ? void 0 : c[0]) === null || d === void 0 ? void 0 : d.content;
|
|
3323
|
+
_ !== void 0 && f.push(_);
|
|
3324
3324
|
}
|
|
3325
3325
|
yield yield D(y);
|
|
3326
3326
|
}
|
|
@@ -3416,7 +3416,7 @@ function Ar(t) {
|
|
|
3416
3416
|
*/
|
|
3417
3417
|
class xr extends te {
|
|
3418
3418
|
constructor(e) {
|
|
3419
|
-
super(), this.apiClient = e, this.list = async (n = {}) => new
|
|
3419
|
+
super(), this.apiClient = e, this.list = async (n = {}) => new ae(ee.PAGED_ITEM_FILES, (o) => this.listInternal(o), await this.listInternal(n), n);
|
|
3420
3420
|
}
|
|
3421
3421
|
/**
|
|
3422
3422
|
* Uploads a file asynchronously to the Gemini API.
|
|
@@ -3492,7 +3492,7 @@ class xr extends te {
|
|
|
3492
3492
|
throw new Error("This method is only supported by the Gemini Developer API.");
|
|
3493
3493
|
{
|
|
3494
3494
|
const u = Sr(e);
|
|
3495
|
-
return l =
|
|
3495
|
+
return l = A("files", u._url), a = u._query, delete u._url, delete u._query, s = this.apiClient.request({
|
|
3496
3496
|
path: l,
|
|
3497
3497
|
queryParams: a,
|
|
3498
3498
|
body: JSON.stringify(u),
|
|
@@ -3517,7 +3517,7 @@ class xr extends te {
|
|
|
3517
3517
|
throw new Error("This method is only supported by the Gemini Developer API.");
|
|
3518
3518
|
{
|
|
3519
3519
|
const u = Tr(e);
|
|
3520
|
-
return l =
|
|
3520
|
+
return l = A("upload/v1beta/files", u._url), a = u._query, delete u._url, delete u._query, s = this.apiClient.request({
|
|
3521
3521
|
path: l,
|
|
3522
3522
|
queryParams: a,
|
|
3523
3523
|
body: JSON.stringify(u),
|
|
@@ -3552,7 +3552,7 @@ class xr extends te {
|
|
|
3552
3552
|
throw new Error("This method is only supported by the Gemini Developer API.");
|
|
3553
3553
|
{
|
|
3554
3554
|
const u = vr(e);
|
|
3555
|
-
return l =
|
|
3555
|
+
return l = A("files/{file}", u._url), a = u._query, delete u._url, delete u._query, s = this.apiClient.request({
|
|
3556
3556
|
path: l,
|
|
3557
3557
|
queryParams: a,
|
|
3558
3558
|
body: JSON.stringify(u),
|
|
@@ -3582,7 +3582,7 @@ class xr extends te {
|
|
|
3582
3582
|
throw new Error("This method is only supported by the Gemini Developer API.");
|
|
3583
3583
|
{
|
|
3584
3584
|
const u = Er(e);
|
|
3585
|
-
return l =
|
|
3585
|
+
return l = A("files/{file}", u._url), a = u._query, delete u._url, delete u._query, s = this.apiClient.request({
|
|
3586
3586
|
path: l,
|
|
3587
3587
|
queryParams: a,
|
|
3588
3588
|
body: JSON.stringify(u),
|
|
@@ -3715,32 +3715,32 @@ function Pr(t) {
|
|
|
3715
3715
|
"responseModalities"
|
|
3716
3716
|
]);
|
|
3717
3717
|
y != null && r(e, ["responseModalities"], y);
|
|
3718
|
-
const
|
|
3718
|
+
const _ = i(t, [
|
|
3719
3719
|
"responseSchema"
|
|
3720
3720
|
]);
|
|
3721
|
-
|
|
3721
|
+
_ != null && r(e, ["responseSchema"], _);
|
|
3722
3722
|
const T = i(t, [
|
|
3723
3723
|
"routingConfig"
|
|
3724
3724
|
]);
|
|
3725
3725
|
T != null && r(e, ["routingConfig"], T);
|
|
3726
|
-
const
|
|
3727
|
-
|
|
3728
|
-
const
|
|
3729
|
-
|
|
3730
|
-
const
|
|
3726
|
+
const I = i(t, ["seed"]);
|
|
3727
|
+
I != null && r(e, ["seed"], I);
|
|
3728
|
+
const E = i(t, ["speechConfig"]);
|
|
3729
|
+
E != null && r(e, ["speechConfig"], E);
|
|
3730
|
+
const C = i(t, [
|
|
3731
3731
|
"stopSequences"
|
|
3732
3732
|
]);
|
|
3733
|
-
|
|
3734
|
-
const
|
|
3735
|
-
|
|
3736
|
-
const
|
|
3733
|
+
C != null && r(e, ["stopSequences"], C);
|
|
3734
|
+
const S = i(t, ["temperature"]);
|
|
3735
|
+
S != null && r(e, ["temperature"], S);
|
|
3736
|
+
const v = i(t, [
|
|
3737
3737
|
"thinkingConfig"
|
|
3738
3738
|
]);
|
|
3739
|
-
|
|
3740
|
-
const
|
|
3741
|
-
|
|
3742
|
-
const
|
|
3743
|
-
if (
|
|
3739
|
+
v != null && r(e, ["thinkingConfig"], v);
|
|
3740
|
+
const R = i(t, ["topK"]);
|
|
3741
|
+
R != null && r(e, ["topK"], R);
|
|
3742
|
+
const w = i(t, ["topP"]);
|
|
3743
|
+
if (w != null && r(e, ["topP"], w), i(t, ["enableEnhancedCivicAnswers"]) !== void 0)
|
|
3744
3744
|
throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");
|
|
3745
3745
|
return e;
|
|
3746
3746
|
}
|
|
@@ -3801,33 +3801,33 @@ function Ur(t, e) {
|
|
|
3801
3801
|
"systemInstruction"
|
|
3802
3802
|
]);
|
|
3803
3803
|
e !== void 0 && y != null && r(e, ["setup", "systemInstruction"], wr(J(y)));
|
|
3804
|
-
const
|
|
3805
|
-
if (e !== void 0 &&
|
|
3806
|
-
let
|
|
3807
|
-
Array.isArray(
|
|
3804
|
+
const _ = i(t, ["tools"]);
|
|
3805
|
+
if (e !== void 0 && _ != null) {
|
|
3806
|
+
let R = ge(_);
|
|
3807
|
+
Array.isArray(R) && (R = R.map((w) => Wr(me(w)))), r(e, ["setup", "tools"], R);
|
|
3808
3808
|
}
|
|
3809
3809
|
const T = i(t, [
|
|
3810
3810
|
"sessionResumption"
|
|
3811
3811
|
]);
|
|
3812
3812
|
e !== void 0 && T != null && r(e, ["setup", "sessionResumption"], $r(T));
|
|
3813
|
-
const
|
|
3813
|
+
const I = i(t, [
|
|
3814
3814
|
"inputAudioTranscription"
|
|
3815
3815
|
]);
|
|
3816
|
-
e !== void 0 &&
|
|
3817
|
-
const
|
|
3816
|
+
e !== void 0 && I != null && r(e, ["setup", "inputAudioTranscription"], I);
|
|
3817
|
+
const E = i(t, [
|
|
3818
3818
|
"outputAudioTranscription"
|
|
3819
3819
|
]);
|
|
3820
|
-
e !== void 0 &&
|
|
3821
|
-
const
|
|
3820
|
+
e !== void 0 && E != null && r(e, ["setup", "outputAudioTranscription"], E);
|
|
3821
|
+
const C = i(t, [
|
|
3822
3822
|
"realtimeInputConfig"
|
|
3823
3823
|
]);
|
|
3824
|
-
e !== void 0 &&
|
|
3825
|
-
const
|
|
3824
|
+
e !== void 0 && C != null && r(e, ["setup", "realtimeInputConfig"], C);
|
|
3825
|
+
const S = i(t, [
|
|
3826
3826
|
"contextWindowCompression"
|
|
3827
3827
|
]);
|
|
3828
|
-
e !== void 0 &&
|
|
3829
|
-
const
|
|
3830
|
-
if (e !== void 0 &&
|
|
3828
|
+
e !== void 0 && S != null && r(e, ["setup", "contextWindowCompression"], S);
|
|
3829
|
+
const v = i(t, ["proactivity"]);
|
|
3830
|
+
if (e !== void 0 && v != null && r(e, ["setup", "proactivity"], v), i(t, ["explicitVadSignal"]) !== void 0)
|
|
3831
3831
|
throw new Error("explicitVadSignal parameter is not supported in Gemini API.");
|
|
3832
3832
|
return n;
|
|
3833
3833
|
}
|
|
@@ -3870,37 +3870,37 @@ function br(t, e) {
|
|
|
3870
3870
|
"systemInstruction"
|
|
3871
3871
|
]);
|
|
3872
3872
|
e !== void 0 && y != null && r(e, ["setup", "systemInstruction"], J(y));
|
|
3873
|
-
const
|
|
3874
|
-
if (e !== void 0 &&
|
|
3875
|
-
let
|
|
3876
|
-
Array.isArray(
|
|
3873
|
+
const _ = i(t, ["tools"]);
|
|
3874
|
+
if (e !== void 0 && _ != null) {
|
|
3875
|
+
let w = ge(_);
|
|
3876
|
+
Array.isArray(w) && (w = w.map((U) => Yr(me(U)))), r(e, ["setup", "tools"], w);
|
|
3877
3877
|
}
|
|
3878
3878
|
const T = i(t, [
|
|
3879
3879
|
"sessionResumption"
|
|
3880
3880
|
]);
|
|
3881
3881
|
e !== void 0 && T != null && r(e, ["setup", "sessionResumption"], T);
|
|
3882
|
-
const
|
|
3882
|
+
const I = i(t, [
|
|
3883
3883
|
"inputAudioTranscription"
|
|
3884
3884
|
]);
|
|
3885
|
-
e !== void 0 &&
|
|
3886
|
-
const
|
|
3885
|
+
e !== void 0 && I != null && r(e, ["setup", "inputAudioTranscription"], I);
|
|
3886
|
+
const E = i(t, [
|
|
3887
3887
|
"outputAudioTranscription"
|
|
3888
3888
|
]);
|
|
3889
|
-
e !== void 0 &&
|
|
3890
|
-
const
|
|
3889
|
+
e !== void 0 && E != null && r(e, ["setup", "outputAudioTranscription"], E);
|
|
3890
|
+
const C = i(t, [
|
|
3891
3891
|
"realtimeInputConfig"
|
|
3892
3892
|
]);
|
|
3893
|
-
e !== void 0 &&
|
|
3894
|
-
const
|
|
3893
|
+
e !== void 0 && C != null && r(e, ["setup", "realtimeInputConfig"], C);
|
|
3894
|
+
const S = i(t, [
|
|
3895
3895
|
"contextWindowCompression"
|
|
3896
3896
|
]);
|
|
3897
|
-
e !== void 0 &&
|
|
3898
|
-
const
|
|
3899
|
-
e !== void 0 &&
|
|
3900
|
-
const
|
|
3897
|
+
e !== void 0 && S != null && r(e, ["setup", "contextWindowCompression"], S);
|
|
3898
|
+
const v = i(t, ["proactivity"]);
|
|
3899
|
+
e !== void 0 && v != null && r(e, ["setup", "proactivity"], v);
|
|
3900
|
+
const R = i(t, [
|
|
3901
3901
|
"explicitVadSignal"
|
|
3902
3902
|
]);
|
|
3903
|
-
return e !== void 0 &&
|
|
3903
|
+
return e !== void 0 && R != null && r(e, ["setup", "explicitVadSignal"], R), n;
|
|
3904
3904
|
}
|
|
3905
3905
|
function Lr(t, e) {
|
|
3906
3906
|
const n = {}, o = i(e, ["model"]);
|
|
@@ -4400,18 +4400,18 @@ function fl(t, e) {
|
|
|
4400
4400
|
"outputMimeType"
|
|
4401
4401
|
]);
|
|
4402
4402
|
e !== void 0 && y != null && r(e, ["parameters", "outputOptions", "mimeType"], y);
|
|
4403
|
-
const
|
|
4403
|
+
const _ = i(t, [
|
|
4404
4404
|
"outputCompressionQuality"
|
|
4405
4405
|
]);
|
|
4406
|
-
e !== void 0 &&
|
|
4406
|
+
e !== void 0 && _ != null && r(e, ["parameters", "outputOptions", "compressionQuality"], _);
|
|
4407
4407
|
const T = i(t, ["addWatermark"]);
|
|
4408
4408
|
e !== void 0 && T != null && r(e, ["parameters", "addWatermark"], T);
|
|
4409
|
-
const
|
|
4410
|
-
e !== void 0 &&
|
|
4411
|
-
const
|
|
4412
|
-
e !== void 0 &&
|
|
4413
|
-
const
|
|
4414
|
-
return e !== void 0 &&
|
|
4409
|
+
const I = i(t, ["labels"]);
|
|
4410
|
+
e !== void 0 && I != null && r(e, ["labels"], I);
|
|
4411
|
+
const E = i(t, ["editMode"]);
|
|
4412
|
+
e !== void 0 && E != null && r(e, ["parameters", "editMode"], E);
|
|
4413
|
+
const C = i(t, ["baseSteps"]);
|
|
4414
|
+
return e !== void 0 && C != null && r(e, ["parameters", "editConfig", "baseSteps"], C), n;
|
|
4415
4415
|
}
|
|
4416
4416
|
function pl(t, e) {
|
|
4417
4417
|
const n = {}, o = i(e, ["model"]);
|
|
@@ -4620,52 +4620,52 @@ function xl(t, e, n) {
|
|
|
4620
4620
|
"frequencyPenalty"
|
|
4621
4621
|
]);
|
|
4622
4622
|
y != null && r(o, ["frequencyPenalty"], y);
|
|
4623
|
-
const
|
|
4624
|
-
|
|
4623
|
+
const _ = i(e, ["seed"]);
|
|
4624
|
+
_ != null && r(o, ["seed"], _);
|
|
4625
4625
|
const T = i(e, [
|
|
4626
4626
|
"responseMimeType"
|
|
4627
4627
|
]);
|
|
4628
4628
|
T != null && r(o, ["responseMimeType"], T);
|
|
4629
|
-
const
|
|
4629
|
+
const I = i(e, [
|
|
4630
4630
|
"responseSchema"
|
|
4631
4631
|
]);
|
|
4632
|
-
|
|
4633
|
-
const
|
|
4632
|
+
I != null && r(o, ["responseSchema"], ct(I));
|
|
4633
|
+
const E = i(e, [
|
|
4634
4634
|
"responseJsonSchema"
|
|
4635
4635
|
]);
|
|
4636
|
-
if (
|
|
4636
|
+
if (E != null && r(o, ["responseJsonSchema"], E), i(e, ["routingConfig"]) !== void 0)
|
|
4637
4637
|
throw new Error("routingConfig parameter is not supported in Gemini API.");
|
|
4638
4638
|
if (i(e, ["modelSelectionConfig"]) !== void 0)
|
|
4639
4639
|
throw new Error("modelSelectionConfig parameter is not supported in Gemini API.");
|
|
4640
|
-
const
|
|
4640
|
+
const C = i(e, [
|
|
4641
4641
|
"safetySettings"
|
|
4642
4642
|
]);
|
|
4643
|
-
if (n !== void 0 &&
|
|
4644
|
-
let b =
|
|
4643
|
+
if (n !== void 0 && C != null) {
|
|
4644
|
+
let b = C;
|
|
4645
4645
|
Array.isArray(b) && (b = b.map((q) => ga(q))), r(n, ["safetySettings"], b);
|
|
4646
4646
|
}
|
|
4647
|
-
const
|
|
4648
|
-
if (n !== void 0 &&
|
|
4649
|
-
let b =
|
|
4650
|
-
Array.isArray(b) && (b = b.map((q) => Ia(
|
|
4647
|
+
const S = i(e, ["tools"]);
|
|
4648
|
+
if (n !== void 0 && S != null) {
|
|
4649
|
+
let b = ge(S);
|
|
4650
|
+
Array.isArray(b) && (b = b.map((q) => Ia(me(q)))), r(n, ["tools"], b);
|
|
4651
4651
|
}
|
|
4652
|
-
const
|
|
4653
|
-
if (n !== void 0 &&
|
|
4652
|
+
const v = i(e, ["toolConfig"]);
|
|
4653
|
+
if (n !== void 0 && v != null && r(n, ["toolConfig"], va(v)), i(e, ["labels"]) !== void 0)
|
|
4654
4654
|
throw new Error("labels parameter is not supported in Gemini API.");
|
|
4655
|
-
const
|
|
4655
|
+
const R = i(e, [
|
|
4656
4656
|
"cachedContent"
|
|
4657
4657
|
]);
|
|
4658
|
-
n !== void 0 &&
|
|
4659
|
-
const
|
|
4658
|
+
n !== void 0 && R != null && r(n, ["cachedContent"], ne(t, R));
|
|
4659
|
+
const w = i(e, [
|
|
4660
4660
|
"responseModalities"
|
|
4661
4661
|
]);
|
|
4662
|
-
|
|
4662
|
+
w != null && r(o, ["responseModalities"], w);
|
|
4663
4663
|
const U = i(e, [
|
|
4664
4664
|
"mediaResolution"
|
|
4665
4665
|
]);
|
|
4666
4666
|
U != null && r(o, ["mediaResolution"], U);
|
|
4667
|
-
const
|
|
4668
|
-
if (
|
|
4667
|
+
const x = i(e, ["speechConfig"]);
|
|
4668
|
+
if (x != null && r(o, ["speechConfig"], ft(x)), i(e, ["audioTimestamp"]) !== void 0)
|
|
4669
4669
|
throw new Error("audioTimestamp parameter is not supported in Gemini API.");
|
|
4670
4670
|
const P = i(e, [
|
|
4671
4671
|
"thinkingConfig"
|
|
@@ -4715,48 +4715,48 @@ function wl(t, e, n) {
|
|
|
4715
4715
|
"frequencyPenalty"
|
|
4716
4716
|
]);
|
|
4717
4717
|
y != null && r(o, ["frequencyPenalty"], y);
|
|
4718
|
-
const
|
|
4719
|
-
|
|
4718
|
+
const _ = i(e, ["seed"]);
|
|
4719
|
+
_ != null && r(o, ["seed"], _);
|
|
4720
4720
|
const T = i(e, [
|
|
4721
4721
|
"responseMimeType"
|
|
4722
4722
|
]);
|
|
4723
4723
|
T != null && r(o, ["responseMimeType"], T);
|
|
4724
|
-
const
|
|
4724
|
+
const I = i(e, [
|
|
4725
4725
|
"responseSchema"
|
|
4726
4726
|
]);
|
|
4727
|
-
|
|
4728
|
-
const
|
|
4727
|
+
I != null && r(o, ["responseSchema"], ct(I));
|
|
4728
|
+
const E = i(e, [
|
|
4729
4729
|
"responseJsonSchema"
|
|
4730
4730
|
]);
|
|
4731
|
-
|
|
4732
|
-
const
|
|
4731
|
+
E != null && r(o, ["responseJsonSchema"], E);
|
|
4732
|
+
const C = i(e, [
|
|
4733
4733
|
"routingConfig"
|
|
4734
4734
|
]);
|
|
4735
|
-
|
|
4736
|
-
const
|
|
4735
|
+
C != null && r(o, ["routingConfig"], C);
|
|
4736
|
+
const S = i(e, [
|
|
4737
4737
|
"modelSelectionConfig"
|
|
4738
4738
|
]);
|
|
4739
|
-
|
|
4740
|
-
const
|
|
4739
|
+
S != null && r(o, ["modelConfig"], S);
|
|
4740
|
+
const v = i(e, [
|
|
4741
4741
|
"safetySettings"
|
|
4742
4742
|
]);
|
|
4743
|
-
if (n !== void 0 &&
|
|
4744
|
-
let G =
|
|
4743
|
+
if (n !== void 0 && v != null) {
|
|
4744
|
+
let G = v;
|
|
4745
4745
|
Array.isArray(G) && (G = G.map((H) => H)), r(n, ["safetySettings"], G);
|
|
4746
4746
|
}
|
|
4747
|
-
const
|
|
4748
|
-
if (n !== void 0 &&
|
|
4749
|
-
let G =
|
|
4750
|
-
Array.isArray(G) && (G = G.map((H) => Ao(
|
|
4747
|
+
const R = i(e, ["tools"]);
|
|
4748
|
+
if (n !== void 0 && R != null) {
|
|
4749
|
+
let G = ge(R);
|
|
4750
|
+
Array.isArray(G) && (G = G.map((H) => Ao(me(H)))), r(n, ["tools"], G);
|
|
4751
4751
|
}
|
|
4752
|
-
const
|
|
4753
|
-
n !== void 0 &&
|
|
4752
|
+
const w = i(e, ["toolConfig"]);
|
|
4753
|
+
n !== void 0 && w != null && r(n, ["toolConfig"], w);
|
|
4754
4754
|
const U = i(e, ["labels"]);
|
|
4755
4755
|
n !== void 0 && U != null && r(n, ["labels"], U);
|
|
4756
|
-
const
|
|
4756
|
+
const x = i(e, [
|
|
4757
4757
|
"cachedContent"
|
|
4758
4758
|
]);
|
|
4759
|
-
n !== void 0 &&
|
|
4759
|
+
n !== void 0 && x != null && r(n, ["cachedContent"], ne(t, x));
|
|
4760
4760
|
const P = i(e, [
|
|
4761
4761
|
"responseModalities"
|
|
4762
4762
|
]);
|
|
@@ -4775,8 +4775,8 @@ function wl(t, e, n) {
|
|
|
4775
4775
|
"thinkingConfig"
|
|
4776
4776
|
]);
|
|
4777
4777
|
q != null && r(o, ["thinkingConfig"], q);
|
|
4778
|
-
const
|
|
4779
|
-
if (
|
|
4778
|
+
const N = i(e, ["imageConfig"]);
|
|
4779
|
+
if (N != null && r(o, ["imageConfig"], ea(N)), i(e, ["enableEnhancedCivicAnswers"]) !== void 0)
|
|
4780
4780
|
throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");
|
|
4781
4781
|
return o;
|
|
4782
4782
|
}
|
|
@@ -4942,20 +4942,20 @@ function Nl(t, e) {
|
|
|
4942
4942
|
"outputMimeType"
|
|
4943
4943
|
]);
|
|
4944
4944
|
e !== void 0 && y != null && r(e, ["parameters", "outputOptions", "mimeType"], y);
|
|
4945
|
-
const
|
|
4945
|
+
const _ = i(t, [
|
|
4946
4946
|
"outputCompressionQuality"
|
|
4947
4947
|
]);
|
|
4948
|
-
e !== void 0 &&
|
|
4948
|
+
e !== void 0 && _ != null && r(e, ["parameters", "outputOptions", "compressionQuality"], _);
|
|
4949
4949
|
const T = i(t, ["addWatermark"]);
|
|
4950
4950
|
e !== void 0 && T != null && r(e, ["parameters", "addWatermark"], T);
|
|
4951
|
-
const
|
|
4952
|
-
e !== void 0 &&
|
|
4953
|
-
const
|
|
4954
|
-
e !== void 0 &&
|
|
4955
|
-
const
|
|
4951
|
+
const I = i(t, ["labels"]);
|
|
4952
|
+
e !== void 0 && I != null && r(e, ["labels"], I);
|
|
4953
|
+
const E = i(t, ["imageSize"]);
|
|
4954
|
+
e !== void 0 && E != null && r(e, ["parameters", "sampleImageSize"], E);
|
|
4955
|
+
const C = i(t, [
|
|
4956
4956
|
"enhancePrompt"
|
|
4957
4957
|
]);
|
|
4958
|
-
return e !== void 0 &&
|
|
4958
|
+
return e !== void 0 && C != null && r(e, ["parameters", "enhancePrompt"], C), n;
|
|
4959
4959
|
}
|
|
4960
4960
|
function Ml(t, e) {
|
|
4961
4961
|
const n = {}, o = i(e, ["model"]);
|
|
@@ -5090,21 +5090,21 @@ function bl(t, e) {
|
|
|
5090
5090
|
"generateAudio"
|
|
5091
5091
|
]);
|
|
5092
5092
|
e !== void 0 && y != null && r(e, ["parameters", "generateAudio"], y);
|
|
5093
|
-
const
|
|
5094
|
-
e !== void 0 &&
|
|
5093
|
+
const _ = i(t, ["lastFrame"]);
|
|
5094
|
+
e !== void 0 && _ != null && r(e, ["instances[0]", "lastFrame"], Z(_));
|
|
5095
5095
|
const T = i(t, [
|
|
5096
5096
|
"referenceImages"
|
|
5097
5097
|
]);
|
|
5098
5098
|
if (e !== void 0 && T != null) {
|
|
5099
|
-
let
|
|
5100
|
-
Array.isArray(
|
|
5099
|
+
let C = T;
|
|
5100
|
+
Array.isArray(C) && (C = C.map((S) => Fa(S))), r(e, ["instances[0]", "referenceImages"], C);
|
|
5101
5101
|
}
|
|
5102
|
-
const
|
|
5103
|
-
e !== void 0 &&
|
|
5104
|
-
const
|
|
5102
|
+
const I = i(t, ["mask"]);
|
|
5103
|
+
e !== void 0 && I != null && r(e, ["instances[0]", "mask"], ba(I));
|
|
5104
|
+
const E = i(t, [
|
|
5105
5105
|
"compressionQuality"
|
|
5106
5106
|
]);
|
|
5107
|
-
return e !== void 0 &&
|
|
5107
|
+
return e !== void 0 && E != null && r(e, ["parameters", "compressionQuality"], E), n;
|
|
5108
5108
|
}
|
|
5109
5109
|
function Ll(t) {
|
|
5110
5110
|
const e = {}, n = i(t, ["name"]);
|
|
@@ -5300,32 +5300,32 @@ function zl(t) {
|
|
|
5300
5300
|
"responseModalities"
|
|
5301
5301
|
]);
|
|
5302
5302
|
y != null && r(e, ["responseModalities"], y);
|
|
5303
|
-
const
|
|
5303
|
+
const _ = i(t, [
|
|
5304
5304
|
"responseSchema"
|
|
5305
5305
|
]);
|
|
5306
|
-
|
|
5306
|
+
_ != null && r(e, ["responseSchema"], _);
|
|
5307
5307
|
const T = i(t, [
|
|
5308
5308
|
"routingConfig"
|
|
5309
5309
|
]);
|
|
5310
5310
|
T != null && r(e, ["routingConfig"], T);
|
|
5311
|
-
const
|
|
5312
|
-
|
|
5313
|
-
const
|
|
5314
|
-
|
|
5315
|
-
const
|
|
5311
|
+
const I = i(t, ["seed"]);
|
|
5312
|
+
I != null && r(e, ["seed"], I);
|
|
5313
|
+
const E = i(t, ["speechConfig"]);
|
|
5314
|
+
E != null && r(e, ["speechConfig"], E);
|
|
5315
|
+
const C = i(t, [
|
|
5316
5316
|
"stopSequences"
|
|
5317
5317
|
]);
|
|
5318
|
-
|
|
5319
|
-
const
|
|
5320
|
-
|
|
5321
|
-
const
|
|
5318
|
+
C != null && r(e, ["stopSequences"], C);
|
|
5319
|
+
const S = i(t, ["temperature"]);
|
|
5320
|
+
S != null && r(e, ["temperature"], S);
|
|
5321
|
+
const v = i(t, [
|
|
5322
5322
|
"thinkingConfig"
|
|
5323
5323
|
]);
|
|
5324
|
-
|
|
5325
|
-
const
|
|
5326
|
-
|
|
5327
|
-
const
|
|
5328
|
-
if (
|
|
5324
|
+
v != null && r(e, ["thinkingConfig"], v);
|
|
5325
|
+
const R = i(t, ["topK"]);
|
|
5326
|
+
R != null && r(e, ["topK"], R);
|
|
5327
|
+
const w = i(t, ["topP"]);
|
|
5328
|
+
if (w != null && r(e, ["topP"], w), i(t, ["enableEnhancedCivicAnswers"]) !== void 0)
|
|
5329
5329
|
throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");
|
|
5330
5330
|
return e;
|
|
5331
5331
|
}
|
|
@@ -6319,11 +6319,11 @@ class su {
|
|
|
6319
6319
|
try {
|
|
6320
6320
|
const y = JSON.parse(p);
|
|
6321
6321
|
if ("error" in y) {
|
|
6322
|
-
const
|
|
6323
|
-
if (
|
|
6322
|
+
const _ = JSON.parse(JSON.stringify(y.error)), T = _.status, I = _.code, E = `got status: ${T}. ${JSON.stringify(y)}`;
|
|
6323
|
+
if (I >= 400 && I < 600)
|
|
6324
6324
|
throw new Le({
|
|
6325
|
-
message:
|
|
6326
|
-
status:
|
|
6325
|
+
message: E,
|
|
6326
|
+
status: I
|
|
6327
6327
|
});
|
|
6328
6328
|
}
|
|
6329
6329
|
} catch (y) {
|
|
@@ -6335,25 +6335,25 @@ class su {
|
|
|
6335
6335
|
for (; ; ) {
|
|
6336
6336
|
h = -1, m = 0;
|
|
6337
6337
|
for (const T of c) {
|
|
6338
|
-
const
|
|
6339
|
-
|
|
6338
|
+
const I = a.indexOf(T);
|
|
6339
|
+
I !== -1 && (h === -1 || I < h) && (h = I, m = T.length);
|
|
6340
6340
|
}
|
|
6341
6341
|
if (h === -1)
|
|
6342
6342
|
break;
|
|
6343
6343
|
const y = a.substring(0, h);
|
|
6344
6344
|
a = a.substring(h + m);
|
|
6345
|
-
const
|
|
6346
|
-
if (
|
|
6347
|
-
const T =
|
|
6345
|
+
const _ = y.trim();
|
|
6346
|
+
if (_.startsWith(u)) {
|
|
6347
|
+
const T = _.substring(u.length).trim();
|
|
6348
6348
|
try {
|
|
6349
|
-
const
|
|
6349
|
+
const I = new Response(T, {
|
|
6350
6350
|
headers: e == null ? void 0 : e.headers,
|
|
6351
6351
|
status: e == null ? void 0 : e.status,
|
|
6352
6352
|
statusText: e == null ? void 0 : e.statusText
|
|
6353
6353
|
});
|
|
6354
|
-
yield yield D(new Oe(
|
|
6355
|
-
} catch (
|
|
6356
|
-
throw new Error(`exception parsing stream chunk ${T}. ${
|
|
6354
|
+
yield yield D(new Oe(I));
|
|
6355
|
+
} catch (I) {
|
|
6356
|
+
throw new Error(`exception parsing stream chunk ${T}. ${I}`);
|
|
6357
6357
|
}
|
|
6358
6358
|
}
|
|
6359
6359
|
}
|
|
@@ -6409,7 +6409,7 @@ class su {
|
|
|
6409
6409
|
s.mimeType = u;
|
|
6410
6410
|
const c = {
|
|
6411
6411
|
file: s
|
|
6412
|
-
}, d = this.getFileName(e), f =
|
|
6412
|
+
}, d = this.getFileName(e), f = A("upload/v1beta/files", c._url), p = await this.fetchUploadUrl(f, s.sizeBytes, s.mimeType, d, c, n == null ? void 0 : n.httpOptions);
|
|
6413
6413
|
return l.upload(e, p, this);
|
|
6414
6414
|
}
|
|
6415
6415
|
/**
|
|
@@ -6682,23 +6682,23 @@ class fu {
|
|
|
6682
6682
|
const s = this.apiClient.getWebsocketBaseUrl(), l = this.apiClient.getApiVersion(), a = mu(this.apiClient.getDefaultHeaders()), u = this.apiClient.getApiKey(), c = `${s}/ws/google.ai.generativelanguage.${l}.GenerativeService.BidiGenerateMusic?key=${u}`;
|
|
6683
6683
|
let d = () => {
|
|
6684
6684
|
};
|
|
6685
|
-
const f = new Promise((
|
|
6686
|
-
d =
|
|
6685
|
+
const f = new Promise((C) => {
|
|
6686
|
+
d = C;
|
|
6687
6687
|
}), p = e.callbacks, h = function() {
|
|
6688
6688
|
d({});
|
|
6689
6689
|
}, m = this.apiClient, y = {
|
|
6690
6690
|
onopen: h,
|
|
6691
|
-
onmessage: (
|
|
6692
|
-
cu(m, p.onmessage,
|
|
6691
|
+
onmessage: (C) => {
|
|
6692
|
+
cu(m, p.onmessage, C);
|
|
6693
6693
|
},
|
|
6694
|
-
onerror: (n = p == null ? void 0 : p.onerror) !== null && n !== void 0 ? n : function(
|
|
6694
|
+
onerror: (n = p == null ? void 0 : p.onerror) !== null && n !== void 0 ? n : function(C) {
|
|
6695
6695
|
},
|
|
6696
|
-
onclose: (o = p == null ? void 0 : p.onclose) !== null && o !== void 0 ? o : function(
|
|
6696
|
+
onclose: (o = p == null ? void 0 : p.onclose) !== null && o !== void 0 ? o : function(C) {
|
|
6697
6697
|
}
|
|
6698
|
-
},
|
|
6699
|
-
|
|
6700
|
-
const
|
|
6701
|
-
return
|
|
6698
|
+
}, _ = this.webSocketFactory.create(c, hu(a), y);
|
|
6699
|
+
_.connect(), await f;
|
|
6700
|
+
const E = { setup: { model: F(this.apiClient, e.model) } };
|
|
6701
|
+
return _.send(JSON.stringify(E)), new pu(_, this.apiClient);
|
|
6702
6702
|
}
|
|
6703
6703
|
}
|
|
6704
6704
|
class pu {
|
|
@@ -6748,7 +6748,7 @@ class pu {
|
|
|
6748
6748
|
* @experimental
|
|
6749
6749
|
*/
|
|
6750
6750
|
play() {
|
|
6751
|
-
this.sendPlaybackControl(
|
|
6751
|
+
this.sendPlaybackControl(de.PLAY);
|
|
6752
6752
|
}
|
|
6753
6753
|
/**
|
|
6754
6754
|
* Temporarily halt the music stream. Use `play` to resume from the current
|
|
@@ -6757,7 +6757,7 @@ class pu {
|
|
|
6757
6757
|
* @experimental
|
|
6758
6758
|
*/
|
|
6759
6759
|
pause() {
|
|
6760
|
-
this.sendPlaybackControl(
|
|
6760
|
+
this.sendPlaybackControl(de.PAUSE);
|
|
6761
6761
|
}
|
|
6762
6762
|
/**
|
|
6763
6763
|
* Stop the music stream and reset the state. Retains the current prompts
|
|
@@ -6766,7 +6766,7 @@ class pu {
|
|
|
6766
6766
|
* @experimental
|
|
6767
6767
|
*/
|
|
6768
6768
|
stop() {
|
|
6769
|
-
this.sendPlaybackControl(
|
|
6769
|
+
this.sendPlaybackControl(de.STOP);
|
|
6770
6770
|
}
|
|
6771
6771
|
/**
|
|
6772
6772
|
* Resets the context of the music generation without stopping it.
|
|
@@ -6775,7 +6775,7 @@ class pu {
|
|
|
6775
6775
|
* @experimental
|
|
6776
6776
|
*/
|
|
6777
6777
|
resetContext() {
|
|
6778
|
-
this.sendPlaybackControl(
|
|
6778
|
+
this.sendPlaybackControl(de.RESET_CONTEXT);
|
|
6779
6779
|
}
|
|
6780
6780
|
/**
|
|
6781
6781
|
Terminates the WebSocket connection.
|
|
@@ -6874,49 +6874,49 @@ class Tu {
|
|
|
6874
6874
|
if (this.apiClient.isVertexAI())
|
|
6875
6875
|
f = `${c}/ws/google.cloud.aiplatform.${d}.LlmBidiService/BidiGenerateContent`, await this.auth.addAuthHeaders(h, f);
|
|
6876
6876
|
else {
|
|
6877
|
-
const
|
|
6877
|
+
const x = this.apiClient.getApiKey();
|
|
6878
6878
|
let P = "BidiGenerateContent", L = "key";
|
|
6879
|
-
|
|
6879
|
+
x != null && x.startsWith("auth_tokens/") && (console.warn("Warning: Ephemeral token support is experimental and may change in future versions."), d !== "v1alpha" && console.warn("Warning: The SDK's ephemeral token support is in v1alpha only. Please use const ai = new GoogleGenAI({apiKey: token.name, httpOptions: { apiVersion: 'v1alpha' }}); before session connection."), P = "BidiGenerateContentConstrained", L = "access_token"), f = `${c}/ws/google.ai.generativelanguage.${d}.GenerativeService.${P}?${L}=${x}`;
|
|
6880
6880
|
}
|
|
6881
6881
|
let m = () => {
|
|
6882
6882
|
};
|
|
6883
|
-
const y = new Promise((
|
|
6884
|
-
m =
|
|
6885
|
-
}),
|
|
6886
|
-
var
|
|
6887
|
-
(
|
|
6888
|
-
},
|
|
6883
|
+
const y = new Promise((x) => {
|
|
6884
|
+
m = x;
|
|
6885
|
+
}), _ = e.callbacks, T = function() {
|
|
6886
|
+
var x;
|
|
6887
|
+
(x = _ == null ? void 0 : _.onopen) === null || x === void 0 || x.call(_), m({});
|
|
6888
|
+
}, I = this.apiClient, E = {
|
|
6889
6889
|
onopen: T,
|
|
6890
|
-
onmessage: (
|
|
6891
|
-
yu(
|
|
6890
|
+
onmessage: (x) => {
|
|
6891
|
+
yu(I, _.onmessage, x);
|
|
6892
6892
|
},
|
|
6893
|
-
onerror: (n =
|
|
6893
|
+
onerror: (n = _ == null ? void 0 : _.onerror) !== null && n !== void 0 ? n : function(x) {
|
|
6894
6894
|
},
|
|
6895
|
-
onclose: (o =
|
|
6895
|
+
onclose: (o = _ == null ? void 0 : _.onclose) !== null && o !== void 0 ? o : function(x) {
|
|
6896
6896
|
}
|
|
6897
|
-
},
|
|
6898
|
-
|
|
6899
|
-
let
|
|
6900
|
-
if (this.apiClient.isVertexAI() &&
|
|
6901
|
-
const
|
|
6902
|
-
|
|
6897
|
+
}, C = this.webSocketFactory.create(f, Cu(h), E);
|
|
6898
|
+
C.connect(), await y;
|
|
6899
|
+
let S = F(this.apiClient, e.model);
|
|
6900
|
+
if (this.apiClient.isVertexAI() && S.startsWith("publishers/")) {
|
|
6901
|
+
const x = this.apiClient.getProject(), P = this.apiClient.getLocation();
|
|
6902
|
+
S = `projects/${x}/locations/${P}/` + S;
|
|
6903
6903
|
}
|
|
6904
|
-
let
|
|
6904
|
+
let v = {};
|
|
6905
6905
|
this.apiClient.isVertexAI() && ((s = e.config) === null || s === void 0 ? void 0 : s.responseModalities) === void 0 && (e.config === void 0 ? e.config = { responseModalities: [Ne.AUDIO] } : e.config.responseModalities = [Ne.AUDIO]), !((l = e.config) === null || l === void 0) && l.generationConfig && console.warn("Setting `LiveConnectConfig.generation_config` is deprecated, please set the fields on `LiveConnectConfig` directly. This will become an error in a future version (not before Q3 2025).");
|
|
6906
|
-
const
|
|
6907
|
-
for (const
|
|
6908
|
-
if (this.isCallableTool(
|
|
6909
|
-
const P =
|
|
6910
|
-
|
|
6906
|
+
const R = (u = (a = e.config) === null || a === void 0 ? void 0 : a.tools) !== null && u !== void 0 ? u : [], w = [];
|
|
6907
|
+
for (const x of R)
|
|
6908
|
+
if (this.isCallableTool(x)) {
|
|
6909
|
+
const P = x;
|
|
6910
|
+
w.push(await P.tool());
|
|
6911
6911
|
} else
|
|
6912
|
-
|
|
6913
|
-
|
|
6912
|
+
w.push(x);
|
|
6913
|
+
w.length > 0 && (e.config.tools = w);
|
|
6914
6914
|
const U = {
|
|
6915
|
-
model:
|
|
6915
|
+
model: S,
|
|
6916
6916
|
config: e.config,
|
|
6917
6917
|
callbacks: e.callbacks
|
|
6918
6918
|
};
|
|
6919
|
-
return this.apiClient.isVertexAI() ?
|
|
6919
|
+
return this.apiClient.isVertexAI() ? v = Fr(this.apiClient, U) : v = Lr(this.apiClient, U), delete v.config, C.send(JSON.stringify(v)), new Eu(C, this.apiClient);
|
|
6920
6920
|
}
|
|
6921
6921
|
// TODO: b/416041229 - Abstract this method to a common place.
|
|
6922
6922
|
isCallableTool(e) {
|
|
@@ -7117,7 +7117,7 @@ function Bn(t) {
|
|
|
7117
7117
|
return !0;
|
|
7118
7118
|
let s = !1;
|
|
7119
7119
|
for (const a of (n = t == null ? void 0 : t.tools) !== null && n !== void 0 ? n : [])
|
|
7120
|
-
if (
|
|
7120
|
+
if (pe(a)) {
|
|
7121
7121
|
s = !0;
|
|
7122
7122
|
break;
|
|
7123
7123
|
}
|
|
@@ -7126,18 +7126,18 @@ function Bn(t) {
|
|
|
7126
7126
|
const l = (o = t == null ? void 0 : t.automaticFunctionCalling) === null || o === void 0 ? void 0 : o.maximumRemoteCalls;
|
|
7127
7127
|
return l && (l < 0 || !Number.isInteger(l)) || l == 0 ? (console.warn("Invalid maximumRemoteCalls value provided for automatic function calling. Disabled automatic function calling. Please provide a valid integer value greater than 0. maximumRemoteCalls provided:", l), !0) : !1;
|
|
7128
7128
|
}
|
|
7129
|
-
function
|
|
7129
|
+
function pe(t) {
|
|
7130
7130
|
return "callTool" in t && typeof t.callTool == "function";
|
|
7131
7131
|
}
|
|
7132
7132
|
function Iu(t) {
|
|
7133
7133
|
var e, n, o;
|
|
7134
|
-
return (o = (n = (e = t.config) === null || e === void 0 ? void 0 : e.tools) === null || n === void 0 ? void 0 : n.some((s) =>
|
|
7134
|
+
return (o = (n = (e = t.config) === null || e === void 0 ? void 0 : e.tools) === null || n === void 0 ? void 0 : n.some((s) => pe(s))) !== null && o !== void 0 ? o : !1;
|
|
7135
7135
|
}
|
|
7136
7136
|
function Jn(t) {
|
|
7137
7137
|
var e;
|
|
7138
7138
|
const n = [];
|
|
7139
7139
|
return !((e = t == null ? void 0 : t.config) === null || e === void 0) && e.tools && t.config.tools.forEach((o, s) => {
|
|
7140
|
-
if (
|
|
7140
|
+
if (pe(o))
|
|
7141
7141
|
return;
|
|
7142
7142
|
const l = o;
|
|
7143
7143
|
l.functionDeclarations && l.functionDeclarations.length > 0 && n.push(s);
|
|
@@ -7161,23 +7161,23 @@ class Su extends te {
|
|
|
7161
7161
|
return await this.generateContentInternal(c);
|
|
7162
7162
|
const d = Jn(n);
|
|
7163
7163
|
if (d.length > 0) {
|
|
7164
|
-
const
|
|
7165
|
-
throw new Error(`Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations is not yet supported. Incompatible tools found at ${
|
|
7164
|
+
const _ = d.map((T) => `tools[${T}]`).join(", ");
|
|
7165
|
+
throw new Error(`Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations is not yet supported. Incompatible tools found at ${_}.`);
|
|
7166
7166
|
}
|
|
7167
7167
|
let f, p;
|
|
7168
7168
|
const h = z(c.contents), m = (l = (s = (o = c.config) === null || o === void 0 ? void 0 : o.automaticFunctionCalling) === null || s === void 0 ? void 0 : s.maximumRemoteCalls) !== null && l !== void 0 ? l : Hn;
|
|
7169
7169
|
let y = 0;
|
|
7170
7170
|
for (; y < m && (f = await this.generateContentInternal(c), !(!f.functionCalls || f.functionCalls.length === 0)); ) {
|
|
7171
|
-
const
|
|
7172
|
-
for (const
|
|
7173
|
-
if (
|
|
7174
|
-
const
|
|
7175
|
-
T.push(...
|
|
7171
|
+
const _ = f.candidates[0].content, T = [];
|
|
7172
|
+
for (const I of (u = (a = n.config) === null || a === void 0 ? void 0 : a.tools) !== null && u !== void 0 ? u : [])
|
|
7173
|
+
if (pe(I)) {
|
|
7174
|
+
const C = await I.callTool(f.functionCalls);
|
|
7175
|
+
T.push(...C);
|
|
7176
7176
|
}
|
|
7177
7177
|
y++, p = {
|
|
7178
7178
|
role: "user",
|
|
7179
7179
|
parts: T
|
|
7180
|
-
}, c.contents = z(c.contents), c.contents.push(
|
|
7180
|
+
}, c.contents = z(c.contents), c.contents.push(_), c.contents.push(p), $n(c.config) && (h.push(_), h.push(p));
|
|
7181
7181
|
}
|
|
7182
7182
|
return $n(c.config) && (f.automaticFunctionCallingHistory = h), f;
|
|
7183
7183
|
}, this.generateContentStream = async (n) => {
|
|
@@ -7223,7 +7223,7 @@ class Su extends te {
|
|
|
7223
7223
|
throw new Error("Filtering tuned models list for Vertex AI is not currently supported");
|
|
7224
7224
|
a.config.filter = "labels.tune-type:*";
|
|
7225
7225
|
}
|
|
7226
|
-
return new
|
|
7226
|
+
return new ae(ee.PAGED_ITEM_MODELS, (u) => this.listInternal(u), await this.listInternal(a), a);
|
|
7227
7227
|
}, this.editImage = async (n) => {
|
|
7228
7228
|
const o = {
|
|
7229
7229
|
model: n.model,
|
|
@@ -7279,7 +7279,7 @@ class Su extends te {
|
|
|
7279
7279
|
const l = (n = e.config) === null || n === void 0 ? void 0 : n.tools;
|
|
7280
7280
|
if (!l)
|
|
7281
7281
|
return e;
|
|
7282
|
-
const a = await Promise.all(l.map(async (c) =>
|
|
7282
|
+
const a = await Promise.all(l.map(async (c) => pe(c) ? await c.tool() : c)), u = {
|
|
7283
7283
|
model: e.model,
|
|
7284
7284
|
contents: e.contents,
|
|
7285
7285
|
config: Object.assign(Object.assign({}, e.config), { tools: a })
|
|
@@ -7295,7 +7295,7 @@ class Su extends te {
|
|
|
7295
7295
|
var n, o, s;
|
|
7296
7296
|
const l = /* @__PURE__ */ new Map();
|
|
7297
7297
|
for (const a of (o = (n = e.config) === null || n === void 0 ? void 0 : n.tools) !== null && o !== void 0 ? o : [])
|
|
7298
|
-
if (
|
|
7298
|
+
if (pe(a)) {
|
|
7299
7299
|
const u = a, c = await u.tool();
|
|
7300
7300
|
for (const d of (s = c.functionDeclarations) !== null && s !== void 0 ? s : []) {
|
|
7301
7301
|
if (!d.name)
|
|
@@ -7314,51 +7314,51 @@ class Su extends te {
|
|
|
7314
7314
|
const c = await this.initAfcToolsMap(e);
|
|
7315
7315
|
return function(d, f, p) {
|
|
7316
7316
|
return X(this, arguments, function* () {
|
|
7317
|
-
for (var h, m, y,
|
|
7317
|
+
for (var h, m, y, _, T, I; u < l; ) {
|
|
7318
7318
|
a && (u++, a = !1);
|
|
7319
|
-
const
|
|
7319
|
+
const v = yield D(d.processParamsMaybeAddMcpUsage(p)), R = yield D(d.generateContentStreamInternal(v)), w = [], U = [];
|
|
7320
7320
|
try {
|
|
7321
|
-
for (var
|
|
7322
|
-
|
|
7323
|
-
const
|
|
7324
|
-
if (yield yield D(
|
|
7325
|
-
U.push(
|
|
7326
|
-
for (const P of (
|
|
7321
|
+
for (var E = !0, C = (m = void 0, Q(R)), S; S = yield D(C.next()), h = S.done, !h; E = !0) {
|
|
7322
|
+
_ = S.value, E = !1;
|
|
7323
|
+
const x = _;
|
|
7324
|
+
if (yield yield D(x), x.candidates && (!((T = x.candidates[0]) === null || T === void 0) && T.content)) {
|
|
7325
|
+
U.push(x.candidates[0].content);
|
|
7326
|
+
for (const P of (I = x.candidates[0].content.parts) !== null && I !== void 0 ? I : [])
|
|
7327
7327
|
if (u < l && P.functionCall) {
|
|
7328
7328
|
if (!P.functionCall.name)
|
|
7329
7329
|
throw new Error("Function call name was not returned by the model.");
|
|
7330
7330
|
if (f.has(P.functionCall.name)) {
|
|
7331
7331
|
const L = yield D(f.get(P.functionCall.name).callTool([P.functionCall]));
|
|
7332
|
-
|
|
7332
|
+
w.push(...L);
|
|
7333
7333
|
} else
|
|
7334
7334
|
throw new Error(`Automatic function calling was requested, but not all the tools the model used implement the CallableTool interface. Available tools: ${f.keys()}, mising tool: ${P.functionCall.name}`);
|
|
7335
7335
|
}
|
|
7336
7336
|
}
|
|
7337
7337
|
}
|
|
7338
|
-
} catch (
|
|
7339
|
-
m = { error:
|
|
7338
|
+
} catch (x) {
|
|
7339
|
+
m = { error: x };
|
|
7340
7340
|
} finally {
|
|
7341
7341
|
try {
|
|
7342
|
-
!
|
|
7342
|
+
!E && !h && (y = C.return) && (yield D(y.call(C)));
|
|
7343
7343
|
} finally {
|
|
7344
7344
|
if (m) throw m.error;
|
|
7345
7345
|
}
|
|
7346
7346
|
}
|
|
7347
|
-
if (
|
|
7347
|
+
if (w.length > 0) {
|
|
7348
7348
|
a = !0;
|
|
7349
|
-
const
|
|
7350
|
-
|
|
7349
|
+
const x = new _e();
|
|
7350
|
+
x.candidates = [
|
|
7351
7351
|
{
|
|
7352
7352
|
content: {
|
|
7353
7353
|
role: "user",
|
|
7354
|
-
parts:
|
|
7354
|
+
parts: w
|
|
7355
7355
|
}
|
|
7356
7356
|
}
|
|
7357
|
-
], yield yield D(
|
|
7357
|
+
], yield yield D(x);
|
|
7358
7358
|
const P = [];
|
|
7359
7359
|
P.push(...U), P.push({
|
|
7360
7360
|
role: "user",
|
|
7361
|
-
parts:
|
|
7361
|
+
parts: w
|
|
7362
7362
|
});
|
|
7363
7363
|
const L = z(p.contents).concat(P);
|
|
7364
7364
|
p.contents = L;
|
|
@@ -7373,7 +7373,7 @@ class Su extends te {
|
|
|
7373
7373
|
let a, u = "", c = {};
|
|
7374
7374
|
if (this.apiClient.isVertexAI()) {
|
|
7375
7375
|
const d = Fn(this.apiClient, e);
|
|
7376
|
-
return u =
|
|
7376
|
+
return u = A("{model}:generateContent", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
7377
7377
|
path: u,
|
|
7378
7378
|
queryParams: c,
|
|
7379
7379
|
body: JSON.stringify(d),
|
|
@@ -7386,12 +7386,12 @@ class Su extends te {
|
|
|
7386
7386
|
headers: f.headers
|
|
7387
7387
|
}, h;
|
|
7388
7388
|
})), a.then((f) => {
|
|
7389
|
-
const p = Vn(f), h = new
|
|
7389
|
+
const p = Vn(f), h = new _e();
|
|
7390
7390
|
return Object.assign(h, p), h;
|
|
7391
7391
|
});
|
|
7392
7392
|
} else {
|
|
7393
7393
|
const d = Ln(this.apiClient, e);
|
|
7394
|
-
return u =
|
|
7394
|
+
return u = A("{model}:generateContent", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
7395
7395
|
path: u,
|
|
7396
7396
|
queryParams: c,
|
|
7397
7397
|
body: JSON.stringify(d),
|
|
@@ -7404,7 +7404,7 @@ class Su extends te {
|
|
|
7404
7404
|
headers: f.headers
|
|
7405
7405
|
}, h;
|
|
7406
7406
|
})), a.then((f) => {
|
|
7407
|
-
const p = Gn(f), h = new
|
|
7407
|
+
const p = Gn(f), h = new _e();
|
|
7408
7408
|
return Object.assign(h, p), h;
|
|
7409
7409
|
});
|
|
7410
7410
|
}
|
|
@@ -7414,7 +7414,7 @@ class Su extends te {
|
|
|
7414
7414
|
let a, u = "", c = {};
|
|
7415
7415
|
if (this.apiClient.isVertexAI()) {
|
|
7416
7416
|
const d = Fn(this.apiClient, e);
|
|
7417
|
-
return u =
|
|
7417
|
+
return u = A("{model}:streamGenerateContent?alt=sse", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.requestStream({
|
|
7418
7418
|
path: u,
|
|
7419
7419
|
queryParams: c,
|
|
7420
7420
|
body: JSON.stringify(d),
|
|
@@ -7423,22 +7423,22 @@ class Su extends te {
|
|
|
7423
7423
|
abortSignal: (o = e.config) === null || o === void 0 ? void 0 : o.abortSignal
|
|
7424
7424
|
}), a.then(function(p) {
|
|
7425
7425
|
return X(this, arguments, function* () {
|
|
7426
|
-
var h, m, y,
|
|
7426
|
+
var h, m, y, _;
|
|
7427
7427
|
try {
|
|
7428
|
-
for (var T = !0,
|
|
7429
|
-
|
|
7430
|
-
const
|
|
7431
|
-
|
|
7432
|
-
headers:
|
|
7428
|
+
for (var T = !0, I = Q(p), E; E = yield D(I.next()), h = E.done, !h; T = !0) {
|
|
7429
|
+
_ = E.value, T = !1;
|
|
7430
|
+
const C = _, S = Vn(yield D(C.json()));
|
|
7431
|
+
S.sdkHttpResponse = {
|
|
7432
|
+
headers: C.headers
|
|
7433
7433
|
};
|
|
7434
|
-
const
|
|
7435
|
-
Object.assign(
|
|
7434
|
+
const v = new _e();
|
|
7435
|
+
Object.assign(v, S), yield yield D(v);
|
|
7436
7436
|
}
|
|
7437
|
-
} catch (
|
|
7438
|
-
m = { error:
|
|
7437
|
+
} catch (C) {
|
|
7438
|
+
m = { error: C };
|
|
7439
7439
|
} finally {
|
|
7440
7440
|
try {
|
|
7441
|
-
!T && !h && (y =
|
|
7441
|
+
!T && !h && (y = I.return) && (yield D(y.call(I)));
|
|
7442
7442
|
} finally {
|
|
7443
7443
|
if (m) throw m.error;
|
|
7444
7444
|
}
|
|
@@ -7447,7 +7447,7 @@ class Su extends te {
|
|
|
7447
7447
|
});
|
|
7448
7448
|
} else {
|
|
7449
7449
|
const d = Ln(this.apiClient, e);
|
|
7450
|
-
return u =
|
|
7450
|
+
return u = A("{model}:streamGenerateContent?alt=sse", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.requestStream({
|
|
7451
7451
|
path: u,
|
|
7452
7452
|
queryParams: c,
|
|
7453
7453
|
body: JSON.stringify(d),
|
|
@@ -7456,22 +7456,22 @@ class Su extends te {
|
|
|
7456
7456
|
abortSignal: (l = e.config) === null || l === void 0 ? void 0 : l.abortSignal
|
|
7457
7457
|
}), a.then(function(p) {
|
|
7458
7458
|
return X(this, arguments, function* () {
|
|
7459
|
-
var h, m, y,
|
|
7459
|
+
var h, m, y, _;
|
|
7460
7460
|
try {
|
|
7461
|
-
for (var T = !0,
|
|
7462
|
-
|
|
7463
|
-
const
|
|
7464
|
-
|
|
7465
|
-
headers:
|
|
7461
|
+
for (var T = !0, I = Q(p), E; E = yield D(I.next()), h = E.done, !h; T = !0) {
|
|
7462
|
+
_ = E.value, T = !1;
|
|
7463
|
+
const C = _, S = Gn(yield D(C.json()));
|
|
7464
|
+
S.sdkHttpResponse = {
|
|
7465
|
+
headers: C.headers
|
|
7466
7466
|
};
|
|
7467
|
-
const
|
|
7468
|
-
Object.assign(
|
|
7467
|
+
const v = new _e();
|
|
7468
|
+
Object.assign(v, S), yield yield D(v);
|
|
7469
7469
|
}
|
|
7470
|
-
} catch (
|
|
7471
|
-
m = { error:
|
|
7470
|
+
} catch (C) {
|
|
7471
|
+
m = { error: C };
|
|
7472
7472
|
} finally {
|
|
7473
7473
|
try {
|
|
7474
|
-
!T && !h && (y =
|
|
7474
|
+
!T && !h && (y = I.return) && (yield D(y.call(I)));
|
|
7475
7475
|
} finally {
|
|
7476
7476
|
if (m) throw m.error;
|
|
7477
7477
|
}
|
|
@@ -7506,7 +7506,7 @@ class Su extends te {
|
|
|
7506
7506
|
let a, u = "", c = {};
|
|
7507
7507
|
if (this.apiClient.isVertexAI()) {
|
|
7508
7508
|
const d = Tl(this.apiClient, e);
|
|
7509
|
-
return u =
|
|
7509
|
+
return u = A("{model}:predict", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
7510
7510
|
path: u,
|
|
7511
7511
|
queryParams: c,
|
|
7512
7512
|
body: JSON.stringify(d),
|
|
@@ -7524,7 +7524,7 @@ class Su extends te {
|
|
|
7524
7524
|
});
|
|
7525
7525
|
} else {
|
|
7526
7526
|
const d = yl(this.apiClient, e);
|
|
7527
|
-
return u =
|
|
7527
|
+
return u = A("{model}:batchEmbedContents", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
7528
7528
|
path: u,
|
|
7529
7529
|
queryParams: c,
|
|
7530
7530
|
body: JSON.stringify(d),
|
|
@@ -7550,7 +7550,7 @@ class Su extends te {
|
|
|
7550
7550
|
let a, u = "", c = {};
|
|
7551
7551
|
if (this.apiClient.isVertexAI()) {
|
|
7552
7552
|
const d = Pl(this.apiClient, e);
|
|
7553
|
-
return u =
|
|
7553
|
+
return u = A("{model}:predict", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
7554
7554
|
path: u,
|
|
7555
7555
|
queryParams: c,
|
|
7556
7556
|
body: JSON.stringify(d),
|
|
@@ -7568,7 +7568,7 @@ class Su extends te {
|
|
|
7568
7568
|
});
|
|
7569
7569
|
} else {
|
|
7570
7570
|
const d = Ml(this.apiClient, e);
|
|
7571
|
-
return u =
|
|
7571
|
+
return u = A("{model}:predict", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
7572
7572
|
path: u,
|
|
7573
7573
|
queryParams: c,
|
|
7574
7574
|
body: JSON.stringify(d),
|
|
@@ -7594,7 +7594,7 @@ class Su extends te {
|
|
|
7594
7594
|
let s, l = "", a = {};
|
|
7595
7595
|
if (this.apiClient.isVertexAI()) {
|
|
7596
7596
|
const u = pl(this.apiClient, e);
|
|
7597
|
-
return l =
|
|
7597
|
+
return l = A("{model}:predict", u._url), a = u._query, delete u._url, delete u._query, s = this.apiClient.request({
|
|
7598
7598
|
path: l,
|
|
7599
7599
|
queryParams: a,
|
|
7600
7600
|
body: JSON.stringify(u),
|
|
@@ -7621,7 +7621,7 @@ class Su extends te {
|
|
|
7621
7621
|
let s, l = "", a = {};
|
|
7622
7622
|
if (this.apiClient.isVertexAI()) {
|
|
7623
7623
|
const u = Pa(this.apiClient, e);
|
|
7624
|
-
return l =
|
|
7624
|
+
return l = A("{model}:predict", u._url), a = u._query, delete u._url, delete u._query, s = this.apiClient.request({
|
|
7625
7625
|
path: l,
|
|
7626
7626
|
queryParams: a,
|
|
7627
7627
|
body: JSON.stringify(u),
|
|
@@ -7683,7 +7683,7 @@ class Su extends te {
|
|
|
7683
7683
|
let s, l = "", a = {};
|
|
7684
7684
|
if (this.apiClient.isVertexAI()) {
|
|
7685
7685
|
const u = fa(this.apiClient, e);
|
|
7686
|
-
return l =
|
|
7686
|
+
return l = A("{model}:predict", u._url), a = u._query, delete u._url, delete u._query, s = this.apiClient.request({
|
|
7687
7687
|
path: l,
|
|
7688
7688
|
queryParams: a,
|
|
7689
7689
|
body: JSON.stringify(u),
|
|
@@ -7722,7 +7722,7 @@ class Su extends te {
|
|
|
7722
7722
|
let s, l = "", a = {};
|
|
7723
7723
|
if (this.apiClient.isVertexAI()) {
|
|
7724
7724
|
const u = _a(this.apiClient, e);
|
|
7725
|
-
return l =
|
|
7725
|
+
return l = A("{model}:predict", u._url), a = u._query, delete u._url, delete u._query, s = this.apiClient.request({
|
|
7726
7726
|
path: l,
|
|
7727
7727
|
queryParams: a,
|
|
7728
7728
|
body: JSON.stringify(u),
|
|
@@ -7749,7 +7749,7 @@ class Su extends te {
|
|
|
7749
7749
|
let a, u = "", c = {};
|
|
7750
7750
|
if (this.apiClient.isVertexAI()) {
|
|
7751
7751
|
const d = Xl(this.apiClient, e);
|
|
7752
|
-
return u =
|
|
7752
|
+
return u = A("{name}", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
7753
7753
|
path: u,
|
|
7754
7754
|
queryParams: c,
|
|
7755
7755
|
body: JSON.stringify(d),
|
|
@@ -7759,7 +7759,7 @@ class Su extends te {
|
|
|
7759
7759
|
}).then((f) => f.json()), a.then((f) => je(f));
|
|
7760
7760
|
} else {
|
|
7761
7761
|
const d = Ol(this.apiClient, e);
|
|
7762
|
-
return u =
|
|
7762
|
+
return u = A("{name}", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
7763
7763
|
path: u,
|
|
7764
7764
|
queryParams: c,
|
|
7765
7765
|
body: JSON.stringify(d),
|
|
@@ -7774,7 +7774,7 @@ class Su extends te {
|
|
|
7774
7774
|
let a, u = "", c = {};
|
|
7775
7775
|
if (this.apiClient.isVertexAI()) {
|
|
7776
7776
|
const d = sa(this.apiClient, e);
|
|
7777
|
-
return u =
|
|
7777
|
+
return u = A("{models_url}", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
7778
7778
|
path: u,
|
|
7779
7779
|
queryParams: c,
|
|
7780
7780
|
body: JSON.stringify(d),
|
|
@@ -7792,7 +7792,7 @@ class Su extends te {
|
|
|
7792
7792
|
});
|
|
7793
7793
|
} else {
|
|
7794
7794
|
const d = ia(this.apiClient, e);
|
|
7795
|
-
return u =
|
|
7795
|
+
return u = A("{models_url}", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
7796
7796
|
path: u,
|
|
7797
7797
|
queryParams: c,
|
|
7798
7798
|
body: JSON.stringify(d),
|
|
@@ -7832,7 +7832,7 @@ class Su extends te {
|
|
|
7832
7832
|
let a, u = "", c = {};
|
|
7833
7833
|
if (this.apiClient.isVertexAI()) {
|
|
7834
7834
|
const d = Na(this.apiClient, e);
|
|
7835
|
-
return u =
|
|
7835
|
+
return u = A("{model}", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
7836
7836
|
path: u,
|
|
7837
7837
|
queryParams: c,
|
|
7838
7838
|
body: JSON.stringify(d),
|
|
@@ -7842,7 +7842,7 @@ class Su extends te {
|
|
|
7842
7842
|
}).then((f) => f.json()), a.then((f) => je(f));
|
|
7843
7843
|
} else {
|
|
7844
7844
|
const d = Ra(this.apiClient, e);
|
|
7845
|
-
return u =
|
|
7845
|
+
return u = A("{name}", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
7846
7846
|
path: u,
|
|
7847
7847
|
queryParams: c,
|
|
7848
7848
|
body: JSON.stringify(d),
|
|
@@ -7868,7 +7868,7 @@ class Su extends te {
|
|
|
7868
7868
|
let a, u = "", c = {};
|
|
7869
7869
|
if (this.apiClient.isVertexAI()) {
|
|
7870
7870
|
const d = ul(this.apiClient, e);
|
|
7871
|
-
return u =
|
|
7871
|
+
return u = A("{name}", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
7872
7872
|
path: u,
|
|
7873
7873
|
queryParams: c,
|
|
7874
7874
|
body: JSON.stringify(d),
|
|
@@ -7886,7 +7886,7 @@ class Su extends te {
|
|
|
7886
7886
|
});
|
|
7887
7887
|
} else {
|
|
7888
7888
|
const d = al(this.apiClient, e);
|
|
7889
|
-
return u =
|
|
7889
|
+
return u = A("{name}", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
7890
7890
|
path: u,
|
|
7891
7891
|
queryParams: c,
|
|
7892
7892
|
body: JSON.stringify(d),
|
|
@@ -7925,7 +7925,7 @@ class Su extends te {
|
|
|
7925
7925
|
let a, u = "", c = {};
|
|
7926
7926
|
if (this.apiClient.isVertexAI()) {
|
|
7927
7927
|
const d = sl(this.apiClient, e);
|
|
7928
|
-
return u =
|
|
7928
|
+
return u = A("{model}:countTokens", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
7929
7929
|
path: u,
|
|
7930
7930
|
queryParams: c,
|
|
7931
7931
|
body: JSON.stringify(d),
|
|
@@ -7943,7 +7943,7 @@ class Su extends te {
|
|
|
7943
7943
|
});
|
|
7944
7944
|
} else {
|
|
7945
7945
|
const d = il(this.apiClient, e);
|
|
7946
|
-
return u =
|
|
7946
|
+
return u = A("{model}:countTokens", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
7947
7947
|
path: u,
|
|
7948
7948
|
queryParams: c,
|
|
7949
7949
|
body: JSON.stringify(d),
|
|
@@ -7984,7 +7984,7 @@ class Su extends te {
|
|
|
7984
7984
|
let s, l = "", a = {};
|
|
7985
7985
|
if (this.apiClient.isVertexAI()) {
|
|
7986
7986
|
const u = Qr(this.apiClient, e);
|
|
7987
|
-
return l =
|
|
7987
|
+
return l = A("{model}:computeTokens", u._url), a = u._query, delete u._url, delete u._query, s = this.apiClient.request({
|
|
7988
7988
|
path: l,
|
|
7989
7989
|
queryParams: a,
|
|
7990
7990
|
body: JSON.stringify(u),
|
|
@@ -8011,7 +8011,7 @@ class Su extends te {
|
|
|
8011
8011
|
let a, u = "", c = {};
|
|
8012
8012
|
if (this.apiClient.isVertexAI()) {
|
|
8013
8013
|
const d = Vl(this.apiClient, e);
|
|
8014
|
-
return u =
|
|
8014
|
+
return u = A("{model}:predictLongRunning", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
8015
8015
|
path: u,
|
|
8016
8016
|
queryParams: c,
|
|
8017
8017
|
body: JSON.stringify(d),
|
|
@@ -8024,7 +8024,7 @@ class Su extends te {
|
|
|
8024
8024
|
});
|
|
8025
8025
|
} else {
|
|
8026
8026
|
const d = Gl(this.apiClient, e);
|
|
8027
|
-
return u =
|
|
8027
|
+
return u = A("{model}:predictLongRunning", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
8028
8028
|
path: u,
|
|
8029
8029
|
queryParams: c,
|
|
8030
8030
|
body: JSON.stringify(d),
|
|
@@ -8120,7 +8120,7 @@ class Au extends te {
|
|
|
8120
8120
|
let a, u = "", c = {};
|
|
8121
8121
|
if (this.apiClient.isVertexAI()) {
|
|
8122
8122
|
const d = gi(e);
|
|
8123
|
-
return u =
|
|
8123
|
+
return u = A("{operationName}", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
8124
8124
|
path: u,
|
|
8125
8125
|
queryParams: c,
|
|
8126
8126
|
body: JSON.stringify(d),
|
|
@@ -8130,7 +8130,7 @@ class Au extends te {
|
|
|
8130
8130
|
}).then((f) => f.json()), a;
|
|
8131
8131
|
} else {
|
|
8132
8132
|
const d = mi(e);
|
|
8133
|
-
return u =
|
|
8133
|
+
return u = A("{operationName}", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
8134
8134
|
path: u,
|
|
8135
8135
|
queryParams: c,
|
|
8136
8136
|
body: JSON.stringify(d),
|
|
@@ -8145,7 +8145,7 @@ class Au extends te {
|
|
|
8145
8145
|
let s, l = "", a = {};
|
|
8146
8146
|
if (this.apiClient.isVertexAI()) {
|
|
8147
8147
|
const u = ai(e);
|
|
8148
|
-
return l =
|
|
8148
|
+
return l = A("{resourceName}:fetchPredictOperation", u._url), a = u._query, delete u._url, delete u._query, s = this.apiClient.request({
|
|
8149
8149
|
path: l,
|
|
8150
8150
|
queryParams: a,
|
|
8151
8151
|
body: JSON.stringify(u),
|
|
@@ -8278,33 +8278,33 @@ function Uu(t, e) {
|
|
|
8278
8278
|
"systemInstruction"
|
|
8279
8279
|
]);
|
|
8280
8280
|
e !== void 0 && y != null && r(e, ["setup", "systemInstruction"], wu(J(y)));
|
|
8281
|
-
const
|
|
8282
|
-
if (e !== void 0 &&
|
|
8283
|
-
let
|
|
8284
|
-
Array.isArray(
|
|
8281
|
+
const _ = i(t, ["tools"]);
|
|
8282
|
+
if (e !== void 0 && _ != null) {
|
|
8283
|
+
let R = ge(_);
|
|
8284
|
+
Array.isArray(R) && (R = R.map((w) => Gu(me(w)))), r(e, ["setup", "tools"], R);
|
|
8285
8285
|
}
|
|
8286
8286
|
const T = i(t, [
|
|
8287
8287
|
"sessionResumption"
|
|
8288
8288
|
]);
|
|
8289
8289
|
e !== void 0 && T != null && r(e, ["setup", "sessionResumption"], Fu(T));
|
|
8290
|
-
const
|
|
8290
|
+
const I = i(t, [
|
|
8291
8291
|
"inputAudioTranscription"
|
|
8292
8292
|
]);
|
|
8293
|
-
e !== void 0 &&
|
|
8294
|
-
const
|
|
8293
|
+
e !== void 0 && I != null && r(e, ["setup", "inputAudioTranscription"], I);
|
|
8294
|
+
const E = i(t, [
|
|
8295
8295
|
"outputAudioTranscription"
|
|
8296
8296
|
]);
|
|
8297
|
-
e !== void 0 &&
|
|
8298
|
-
const
|
|
8297
|
+
e !== void 0 && E != null && r(e, ["setup", "outputAudioTranscription"], E);
|
|
8298
|
+
const C = i(t, [
|
|
8299
8299
|
"realtimeInputConfig"
|
|
8300
8300
|
]);
|
|
8301
|
-
e !== void 0 &&
|
|
8302
|
-
const
|
|
8301
|
+
e !== void 0 && C != null && r(e, ["setup", "realtimeInputConfig"], C);
|
|
8302
|
+
const S = i(t, [
|
|
8303
8303
|
"contextWindowCompression"
|
|
8304
8304
|
]);
|
|
8305
|
-
e !== void 0 &&
|
|
8306
|
-
const
|
|
8307
|
-
if (e !== void 0 &&
|
|
8305
|
+
e !== void 0 && S != null && r(e, ["setup", "contextWindowCompression"], S);
|
|
8306
|
+
const v = i(t, ["proactivity"]);
|
|
8307
|
+
if (e !== void 0 && v != null && r(e, ["setup", "proactivity"], v), i(t, ["explicitVadSignal"]) !== void 0)
|
|
8308
8308
|
throw new Error("explicitVadSignal parameter is not supported in Gemini API.");
|
|
8309
8309
|
return n;
|
|
8310
8310
|
}
|
|
@@ -8530,7 +8530,7 @@ class Hu extends te {
|
|
|
8530
8530
|
throw new Error("The client.tokens.create method is only supported by the Gemini Developer API.");
|
|
8531
8531
|
{
|
|
8532
8532
|
const u = Nu(this.apiClient, e);
|
|
8533
|
-
l =
|
|
8533
|
+
l = A("auth_tokens", u._url), a = u._query, delete u.config, delete u._url, delete u._query;
|
|
8534
8534
|
const c = qu(u, e.config);
|
|
8535
8535
|
return s = this.apiClient.request({
|
|
8536
8536
|
path: l,
|
|
@@ -8597,7 +8597,7 @@ function Ku(t) {
|
|
|
8597
8597
|
*/
|
|
8598
8598
|
class zu extends te {
|
|
8599
8599
|
constructor(e) {
|
|
8600
|
-
super(), this.apiClient = e, this.list = async (n) => new
|
|
8600
|
+
super(), this.apiClient = e, this.list = async (n) => new ae(ee.PAGED_ITEM_DOCUMENTS, (o) => this.listInternal({ parent: n.parent, config: o.config }), await this.listInternal(n), n);
|
|
8601
8601
|
}
|
|
8602
8602
|
/**
|
|
8603
8603
|
* Gets a Document.
|
|
@@ -8612,7 +8612,7 @@ class zu extends te {
|
|
|
8612
8612
|
throw new Error("This method is only supported by the Gemini Developer API.");
|
|
8613
8613
|
{
|
|
8614
8614
|
const u = $u(e);
|
|
8615
|
-
return l =
|
|
8615
|
+
return l = A("{name}", u._url), a = u._query, delete u._url, delete u._query, s = this.apiClient.request({
|
|
8616
8616
|
path: l,
|
|
8617
8617
|
queryParams: a,
|
|
8618
8618
|
body: JSON.stringify(u),
|
|
@@ -8634,7 +8634,7 @@ class zu extends te {
|
|
|
8634
8634
|
throw new Error("This method is only supported by the Gemini Developer API.");
|
|
8635
8635
|
{
|
|
8636
8636
|
const a = Ju(e);
|
|
8637
|
-
s =
|
|
8637
|
+
s = A("{name}", a._url), l = a._query, delete a._url, delete a._query, await this.apiClient.request({
|
|
8638
8638
|
path: s,
|
|
8639
8639
|
queryParams: l,
|
|
8640
8640
|
body: JSON.stringify(a),
|
|
@@ -8651,7 +8651,7 @@ class zu extends te {
|
|
|
8651
8651
|
throw new Error("This method is only supported by the Gemini Developer API.");
|
|
8652
8652
|
{
|
|
8653
8653
|
const u = Yu(e);
|
|
8654
|
-
return l =
|
|
8654
|
+
return l = A("{parent}/documents", u._url), a = u._query, delete u._url, delete u._query, s = this.apiClient.request({
|
|
8655
8655
|
path: l,
|
|
8656
8656
|
queryParams: a,
|
|
8657
8657
|
body: JSON.stringify(u),
|
|
@@ -8672,7 +8672,7 @@ class zu extends te {
|
|
|
8672
8672
|
*/
|
|
8673
8673
|
class Ou extends te {
|
|
8674
8674
|
constructor(e, n = new zu(e)) {
|
|
8675
|
-
super(), this.apiClient = e, this.documents = n, this.list = async (o = {}) => new
|
|
8675
|
+
super(), this.apiClient = e, this.documents = n, this.list = async (o = {}) => new ae(ee.PAGED_ITEM_FILE_SEARCH_STORES, (s) => this.listInternal(s), await this.listInternal(o), o);
|
|
8676
8676
|
}
|
|
8677
8677
|
/**
|
|
8678
8678
|
* Uploads a file asynchronously to a given File Search Store.
|
|
@@ -8728,7 +8728,7 @@ class Ou extends te {
|
|
|
8728
8728
|
throw new Error("This method is only supported by the Gemini Developer API.");
|
|
8729
8729
|
{
|
|
8730
8730
|
const u = Va(e);
|
|
8731
|
-
return l =
|
|
8731
|
+
return l = A("fileSearchStores", u._url), a = u._query, delete u._url, delete u._query, s = this.apiClient.request({
|
|
8732
8732
|
path: l,
|
|
8733
8733
|
queryParams: a,
|
|
8734
8734
|
body: JSON.stringify(u),
|
|
@@ -8751,7 +8751,7 @@ class Ou extends te {
|
|
|
8751
8751
|
throw new Error("This method is only supported by the Gemini Developer API.");
|
|
8752
8752
|
{
|
|
8753
8753
|
const u = Ba(e);
|
|
8754
|
-
return l =
|
|
8754
|
+
return l = A("{name}", u._url), a = u._query, delete u._url, delete u._query, s = this.apiClient.request({
|
|
8755
8755
|
path: l,
|
|
8756
8756
|
queryParams: a,
|
|
8757
8757
|
body: JSON.stringify(u),
|
|
@@ -8773,7 +8773,7 @@ class Ou extends te {
|
|
|
8773
8773
|
throw new Error("This method is only supported by the Gemini Developer API.");
|
|
8774
8774
|
{
|
|
8775
8775
|
const a = Ha(e);
|
|
8776
|
-
s =
|
|
8776
|
+
s = A("{name}", a._url), l = a._query, delete a._url, delete a._query, await this.apiClient.request({
|
|
8777
8777
|
path: s,
|
|
8778
8778
|
queryParams: l,
|
|
8779
8779
|
body: JSON.stringify(a),
|
|
@@ -8790,7 +8790,7 @@ class Ou extends te {
|
|
|
8790
8790
|
throw new Error("This method is only supported by the Gemini Developer API.");
|
|
8791
8791
|
{
|
|
8792
8792
|
const u = za(e);
|
|
8793
|
-
return l =
|
|
8793
|
+
return l = A("fileSearchStores", u._url), a = u._query, delete u._url, delete u._query, s = this.apiClient.request({
|
|
8794
8794
|
path: l,
|
|
8795
8795
|
queryParams: a,
|
|
8796
8796
|
body: JSON.stringify(u),
|
|
@@ -8810,7 +8810,7 @@ class Ou extends te {
|
|
|
8810
8810
|
throw new Error("This method is only supported by the Gemini Developer API.");
|
|
8811
8811
|
{
|
|
8812
8812
|
const u = Xa(e);
|
|
8813
|
-
return l =
|
|
8813
|
+
return l = A("upload/v1beta/{file_search_store_name}:uploadToFileSearchStore", u._url), a = u._query, delete u._url, delete u._query, s = this.apiClient.request({
|
|
8814
8814
|
path: l,
|
|
8815
8815
|
queryParams: a,
|
|
8816
8816
|
body: JSON.stringify(u),
|
|
@@ -8838,7 +8838,7 @@ class Ou extends te {
|
|
|
8838
8838
|
throw new Error("This method is only supported by the Gemini Developer API.");
|
|
8839
8839
|
{
|
|
8840
8840
|
const u = Wa(e);
|
|
8841
|
-
return l =
|
|
8841
|
+
return l = A("{file_search_store_name}:importFile", u._url), a = u._query, delete u._url, delete u._query, s = this.apiClient.request({
|
|
8842
8842
|
path: l,
|
|
8843
8843
|
queryParams: a,
|
|
8844
8844
|
body: JSON.stringify(u),
|
|
@@ -8990,7 +8990,7 @@ const sd = (t) => new Promise((e) => setTimeout(e, t));
|
|
|
8990
8990
|
* Copyright 2025 Google LLC
|
|
8991
8991
|
* SPDX-License-Identifier: Apache-2.0
|
|
8992
8992
|
*/
|
|
8993
|
-
const
|
|
8993
|
+
const ue = "0.0.1";
|
|
8994
8994
|
/**
|
|
8995
8995
|
* @license
|
|
8996
8996
|
* Copyright 2025 Google LLC
|
|
@@ -9005,7 +9005,7 @@ const ld = () => {
|
|
|
9005
9005
|
if (l === "deno")
|
|
9006
9006
|
return {
|
|
9007
9007
|
"X-Stainless-Lang": "js",
|
|
9008
|
-
"X-Stainless-Package-Version":
|
|
9008
|
+
"X-Stainless-Package-Version": ue,
|
|
9009
9009
|
"X-Stainless-OS": Kn(Deno.build.os),
|
|
9010
9010
|
"X-Stainless-Arch": Yn(Deno.build.arch),
|
|
9011
9011
|
"X-Stainless-Runtime": "deno",
|
|
@@ -9014,7 +9014,7 @@ const ld = () => {
|
|
|
9014
9014
|
if (typeof EdgeRuntime < "u")
|
|
9015
9015
|
return {
|
|
9016
9016
|
"X-Stainless-Lang": "js",
|
|
9017
|
-
"X-Stainless-Package-Version":
|
|
9017
|
+
"X-Stainless-Package-Version": ue,
|
|
9018
9018
|
"X-Stainless-OS": "Unknown",
|
|
9019
9019
|
"X-Stainless-Arch": `other:${EdgeRuntime}`,
|
|
9020
9020
|
"X-Stainless-Runtime": "edge",
|
|
@@ -9023,7 +9023,7 @@ const ld = () => {
|
|
|
9023
9023
|
if (l === "node")
|
|
9024
9024
|
return {
|
|
9025
9025
|
"X-Stainless-Lang": "js",
|
|
9026
|
-
"X-Stainless-Package-Version":
|
|
9026
|
+
"X-Stainless-Package-Version": ue,
|
|
9027
9027
|
"X-Stainless-OS": Kn((n = globalThis.process.platform) !== null && n !== void 0 ? n : "unknown"),
|
|
9028
9028
|
"X-Stainless-Arch": Yn((o = globalThis.process.arch) !== null && o !== void 0 ? o : "unknown"),
|
|
9029
9029
|
"X-Stainless-Runtime": "node",
|
|
@@ -9032,14 +9032,14 @@ const ld = () => {
|
|
|
9032
9032
|
const a = ad();
|
|
9033
9033
|
return a ? {
|
|
9034
9034
|
"X-Stainless-Lang": "js",
|
|
9035
|
-
"X-Stainless-Package-Version":
|
|
9035
|
+
"X-Stainless-Package-Version": ue,
|
|
9036
9036
|
"X-Stainless-OS": "Unknown",
|
|
9037
9037
|
"X-Stainless-Arch": "unknown",
|
|
9038
9038
|
"X-Stainless-Runtime": `browser:${a.browser}`,
|
|
9039
9039
|
"X-Stainless-Runtime-Version": a.version
|
|
9040
9040
|
} : {
|
|
9041
9041
|
"X-Stainless-Lang": "js",
|
|
9042
|
-
"X-Stainless-Package-Version":
|
|
9042
|
+
"X-Stainless-Package-Version": ue,
|
|
9043
9043
|
"X-Stainless-OS": "Unknown",
|
|
9044
9044
|
"X-Stainless-Arch": "unknown",
|
|
9045
9045
|
"X-Stainless-Runtime": "unknown",
|
|
@@ -9240,16 +9240,16 @@ const zn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null)), E
|
|
|
9240
9240
|
return n[0];
|
|
9241
9241
|
let s = !1;
|
|
9242
9242
|
const l = [], a = n.reduce((f, p, h) => {
|
|
9243
|
-
var m, y,
|
|
9243
|
+
var m, y, _;
|
|
9244
9244
|
/[?#]/.test(p) && (s = !0);
|
|
9245
9245
|
const T = o[h];
|
|
9246
|
-
let
|
|
9246
|
+
let I = (s ? encodeURIComponent : t)("" + T);
|
|
9247
9247
|
return h !== o.length && (T == null || typeof T == "object" && // handle values from other realms
|
|
9248
|
-
T.toString === ((
|
|
9248
|
+
T.toString === ((_ = Object.getPrototypeOf((y = Object.getPrototypeOf((m = T.hasOwnProperty) !== null && m !== void 0 ? m : zn)) !== null && y !== void 0 ? y : zn)) === null || _ === void 0 ? void 0 : _.toString)) && (I = T + "", l.push({
|
|
9249
9249
|
start: f.length + p.length,
|
|
9250
|
-
length:
|
|
9250
|
+
length: I.length,
|
|
9251
9251
|
error: `Value of type ${Object.prototype.toString.call(T).slice(8, -1)} is not a valid path parameter`
|
|
9252
|
-
})), f + p + (h === o.length ? "" :
|
|
9252
|
+
})), f + p + (h === o.length ? "" : I);
|
|
9253
9253
|
}, ""), u = a.split(/[?#]/, 1)[0], c = new RegExp("(?<=^|\\/)(?:\\.|%2e){1,2}(?=\\/|$)", "gi");
|
|
9254
9254
|
let d;
|
|
9255
9255
|
for (; (d = c.exec(u)) !== null; )
|
|
@@ -9261,8 +9261,8 @@ const zn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null)), E
|
|
|
9261
9261
|
if (l.sort((f, p) => f.start - p.start), l.length > 0) {
|
|
9262
9262
|
let f = 0;
|
|
9263
9263
|
const p = l.reduce((h, m) => {
|
|
9264
|
-
const y = " ".repeat(m.start - f),
|
|
9265
|
-
return f = m.start + m.length, h + y +
|
|
9264
|
+
const y = " ".repeat(m.start - f), _ = "^".repeat(m.length);
|
|
9265
|
+
return f = m.start + m.length, h + y + _;
|
|
9266
9266
|
}, "");
|
|
9267
9267
|
throw new O(`Path parameters result in path with invalid segments:
|
|
9268
9268
|
${l.map((h) => h.error).join(`
|
|
@@ -9419,16 +9419,16 @@ const De = {
|
|
|
9419
9419
|
$(n).warn(`${e} was set to ${JSON.stringify(t)}, expected one of ${JSON.stringify(Object.keys(De))}`);
|
|
9420
9420
|
}
|
|
9421
9421
|
};
|
|
9422
|
-
function
|
|
9422
|
+
function Ce() {
|
|
9423
9423
|
}
|
|
9424
9424
|
function xe(t, e, n) {
|
|
9425
|
-
return !e || De[t] > De[n] ?
|
|
9425
|
+
return !e || De[t] > De[n] ? Ce : e[t].bind(e);
|
|
9426
9426
|
}
|
|
9427
9427
|
const Sd = {
|
|
9428
|
-
error:
|
|
9429
|
-
warn:
|
|
9430
|
-
info:
|
|
9431
|
-
debug:
|
|
9428
|
+
error: Ce,
|
|
9429
|
+
warn: Ce,
|
|
9430
|
+
info: Ce,
|
|
9431
|
+
debug: Ce
|
|
9432
9432
|
};
|
|
9433
9433
|
let Qn = /* @__PURE__ */ new WeakMap();
|
|
9434
9434
|
function $(t) {
|
|
@@ -9456,7 +9456,7 @@ const re = (t) => (t.options && (t.options = Object.assign({}, t.options), delet
|
|
|
9456
9456
|
* Copyright 2025 Google LLC
|
|
9457
9457
|
* SPDX-License-Identifier: Apache-2.0
|
|
9458
9458
|
*/
|
|
9459
|
-
class
|
|
9459
|
+
class ce {
|
|
9460
9460
|
constructor(e, n, o) {
|
|
9461
9461
|
this.iterator = e, this.controller = n, this.client = o;
|
|
9462
9462
|
}
|
|
@@ -9472,8 +9472,8 @@ class de {
|
|
|
9472
9472
|
let h = !1;
|
|
9473
9473
|
try {
|
|
9474
9474
|
try {
|
|
9475
|
-
for (var m = !0, y = Q(Ad(e, n)),
|
|
9476
|
-
p =
|
|
9475
|
+
for (var m = !0, y = Q(Ad(e, n)), _; _ = yield D(y.next()), c = _.done, !c; m = !0) {
|
|
9476
|
+
p = _.value, m = !1;
|
|
9477
9477
|
const T = p;
|
|
9478
9478
|
if (!h)
|
|
9479
9479
|
if (T.data.startsWith("[DONE]")) {
|
|
@@ -9482,8 +9482,8 @@ class de {
|
|
|
9482
9482
|
} else
|
|
9483
9483
|
try {
|
|
9484
9484
|
yield yield D(JSON.parse(T.data));
|
|
9485
|
-
} catch (
|
|
9486
|
-
throw l.error("Could not parse message into JSON:", T.data), l.error("From chunk:", T.raw),
|
|
9485
|
+
} catch (I) {
|
|
9486
|
+
throw l.error("Could not parse message into JSON:", T.data), l.error("From chunk:", T.raw), I;
|
|
9487
9487
|
}
|
|
9488
9488
|
}
|
|
9489
9489
|
} catch (T) {
|
|
@@ -9505,7 +9505,7 @@ class de {
|
|
|
9505
9505
|
}
|
|
9506
9506
|
});
|
|
9507
9507
|
}
|
|
9508
|
-
return new
|
|
9508
|
+
return new ce(a, n, o);
|
|
9509
9509
|
}
|
|
9510
9510
|
/**
|
|
9511
9511
|
* Generates a Stream from a newline-separated ReadableStream
|
|
@@ -9518,23 +9518,23 @@ class de {
|
|
|
9518
9518
|
var c, d, f, p;
|
|
9519
9519
|
const h = new He(), m = Bo(e);
|
|
9520
9520
|
try {
|
|
9521
|
-
for (var y = !0,
|
|
9521
|
+
for (var y = !0, _ = Q(m), T; T = yield D(_.next()), c = T.done, !c; y = !0) {
|
|
9522
9522
|
p = T.value, y = !1;
|
|
9523
|
-
const
|
|
9524
|
-
for (const
|
|
9525
|
-
yield yield D(
|
|
9523
|
+
const I = p;
|
|
9524
|
+
for (const E of h.decode(I))
|
|
9525
|
+
yield yield D(E);
|
|
9526
9526
|
}
|
|
9527
|
-
} catch (
|
|
9528
|
-
d = { error:
|
|
9527
|
+
} catch (I) {
|
|
9528
|
+
d = { error: I };
|
|
9529
9529
|
} finally {
|
|
9530
9530
|
try {
|
|
9531
|
-
!y && !c && (f =
|
|
9531
|
+
!y && !c && (f = _.return) && (yield D(f.call(_)));
|
|
9532
9532
|
} finally {
|
|
9533
9533
|
if (d) throw d.error;
|
|
9534
9534
|
}
|
|
9535
9535
|
}
|
|
9536
|
-
for (const
|
|
9537
|
-
yield yield D(
|
|
9536
|
+
for (const I of h.flush())
|
|
9537
|
+
yield yield D(I);
|
|
9538
9538
|
});
|
|
9539
9539
|
}
|
|
9540
9540
|
function a() {
|
|
@@ -9546,8 +9546,8 @@ class de {
|
|
|
9546
9546
|
let h = !1;
|
|
9547
9547
|
try {
|
|
9548
9548
|
try {
|
|
9549
|
-
for (var m = !0, y = Q(l()),
|
|
9550
|
-
p =
|
|
9549
|
+
for (var m = !0, y = Q(l()), _; _ = yield D(y.next()), c = _.done, !c; m = !0) {
|
|
9550
|
+
p = _.value, m = !1;
|
|
9551
9551
|
const T = p;
|
|
9552
9552
|
h || T && (yield yield D(JSON.parse(T)));
|
|
9553
9553
|
}
|
|
@@ -9570,7 +9570,7 @@ class de {
|
|
|
9570
9570
|
}
|
|
9571
9571
|
});
|
|
9572
9572
|
}
|
|
9573
|
-
return new
|
|
9573
|
+
return new ce(a, n, o);
|
|
9574
9574
|
}
|
|
9575
9575
|
[Symbol.asyncIterator]() {
|
|
9576
9576
|
return this.iterator();
|
|
@@ -9590,8 +9590,8 @@ class de {
|
|
|
9590
9590
|
}
|
|
9591
9591
|
});
|
|
9592
9592
|
return [
|
|
9593
|
-
new
|
|
9594
|
-
new
|
|
9593
|
+
new ce(() => s(e), this.controller, this.client),
|
|
9594
|
+
new ce(() => s(n), this.controller, this.client)
|
|
9595
9595
|
];
|
|
9596
9596
|
}
|
|
9597
9597
|
/**
|
|
@@ -9636,8 +9636,8 @@ function Ad(t, e) {
|
|
|
9636
9636
|
a = h.value, f = !1;
|
|
9637
9637
|
const m = a;
|
|
9638
9638
|
for (const y of c.decode(m)) {
|
|
9639
|
-
const
|
|
9640
|
-
|
|
9639
|
+
const _ = u.decode(y);
|
|
9640
|
+
_ && (yield yield D(_));
|
|
9641
9641
|
}
|
|
9642
9642
|
}
|
|
9643
9643
|
} catch (m) {
|
|
@@ -9719,7 +9719,7 @@ async function Nd(t, e) {
|
|
|
9719
9719
|
const { response: n, requestLogID: o, retryOfRequestLogID: s, startTime: l } = e, a = await (async () => {
|
|
9720
9720
|
var u;
|
|
9721
9721
|
if (e.options.stream)
|
|
9722
|
-
return $(t).debug("response", n.status, n.url, n.headers, n.body), e.options.__streamClass ? e.options.__streamClass.fromSSEResponse(n, e.controller, t) :
|
|
9722
|
+
return $(t).debug("response", n.status, n.url, n.headers, n.body), e.options.__streamClass ? e.options.__streamClass.fromSSEResponse(n, e.controller, t) : ce.fromSSEResponse(n, e.controller, t);
|
|
9723
9723
|
if (n.status === 204)
|
|
9724
9724
|
return null;
|
|
9725
9725
|
if (e.options.__binaryResponse)
|
|
@@ -9818,7 +9818,7 @@ function* Md(t) {
|
|
|
9818
9818
|
u !== void 0 && (e && !a && (a = !0, yield [s, null]), yield [s, u]);
|
|
9819
9819
|
}
|
|
9820
9820
|
}
|
|
9821
|
-
const
|
|
9821
|
+
const Ee = (t) => {
|
|
9822
9822
|
const e = new Headers(), n = /* @__PURE__ */ new Set();
|
|
9823
9823
|
for (const o of t) {
|
|
9824
9824
|
const s = /* @__PURE__ */ new Set();
|
|
@@ -9891,12 +9891,12 @@ class Be {
|
|
|
9891
9891
|
throw new Error('Could not resolve authentication method. Expected the apiKey to be set. Or for the "x-goog-api-key" headers to be explicitly omitted');
|
|
9892
9892
|
}
|
|
9893
9893
|
async authHeaders(e) {
|
|
9894
|
-
const n =
|
|
9894
|
+
const n = Ee([e.headers]);
|
|
9895
9895
|
if (!(n.values.has("authorization") || n.values.has("x-goog-api-key"))) {
|
|
9896
9896
|
if (this.apiKey)
|
|
9897
|
-
return
|
|
9897
|
+
return Ee([{ "x-goog-api-key": this.apiKey }]);
|
|
9898
9898
|
if (this.clientAdapter.isVertexAI())
|
|
9899
|
-
return
|
|
9899
|
+
return Ee([await this.clientAdapter.getAuthHeaders()]);
|
|
9900
9900
|
}
|
|
9901
9901
|
}
|
|
9902
9902
|
/**
|
|
@@ -9912,7 +9912,7 @@ class Be {
|
|
|
9912
9912
|
}).join("&");
|
|
9913
9913
|
}
|
|
9914
9914
|
getUserAgent() {
|
|
9915
|
-
return `${this.constructor.name}/JS ${
|
|
9915
|
+
return `${this.constructor.name}/JS ${ue}`;
|
|
9916
9916
|
}
|
|
9917
9917
|
defaultIdempotencyKey() {
|
|
9918
9918
|
return `stainless-node-retry-${Xu()}`;
|
|
@@ -9980,58 +9980,58 @@ class Be {
|
|
|
9980
9980
|
headers: d.headers
|
|
9981
9981
|
})), !((l = u.signal) === null || l === void 0) && l.aborted)
|
|
9982
9982
|
throw new ot();
|
|
9983
|
-
const
|
|
9983
|
+
const _ = new AbortController(), T = await this.fetchWithTimeout(f, d, p, _).catch(nt), I = Date.now();
|
|
9984
9984
|
if (T instanceof globalThis.Error) {
|
|
9985
|
-
const
|
|
9985
|
+
const C = `retrying, ${n} attempts remaining`;
|
|
9986
9986
|
if (!((a = u.signal) === null || a === void 0) && a.aborted)
|
|
9987
9987
|
throw new ot();
|
|
9988
|
-
const
|
|
9988
|
+
const S = tt(T) || /timed? ?out/i.test(String(T) + ("cause" in T ? String(T.cause) : ""));
|
|
9989
9989
|
if (n)
|
|
9990
|
-
return $(this).info(`[${h}] connection ${
|
|
9990
|
+
return $(this).info(`[${h}] connection ${S ? "timed out" : "failed"} - ${C}`), $(this).debug(`[${h}] connection ${S ? "timed out" : "failed"} (${C})`, re({
|
|
9991
9991
|
retryOfRequestLogID: o,
|
|
9992
9992
|
url: f,
|
|
9993
|
-
durationMs:
|
|
9993
|
+
durationMs: I - y,
|
|
9994
9994
|
message: T.message
|
|
9995
9995
|
})), this.retryRequest(u, n, o ?? h);
|
|
9996
|
-
throw $(this).info(`[${h}] connection ${
|
|
9996
|
+
throw $(this).info(`[${h}] connection ${S ? "timed out" : "failed"} - error; no more retries left`), $(this).debug(`[${h}] connection ${S ? "timed out" : "failed"} (error; no more retries left)`, re({
|
|
9997
9997
|
retryOfRequestLogID: o,
|
|
9998
9998
|
url: f,
|
|
9999
|
-
durationMs:
|
|
9999
|
+
durationMs: I - y,
|
|
10000
10000
|
message: T.message
|
|
10001
|
-
})),
|
|
10001
|
+
})), S ? new ko() : new qe({ cause: T });
|
|
10002
10002
|
}
|
|
10003
|
-
const
|
|
10003
|
+
const E = `[${h}${m}] ${d.method} ${f} ${T.ok ? "succeeded" : "failed"} with status ${T.status} in ${I - y}ms`;
|
|
10004
10004
|
if (!T.ok) {
|
|
10005
|
-
const
|
|
10006
|
-
if (n &&
|
|
10007
|
-
const
|
|
10008
|
-
return await fd(T.body), $(this).info(`${
|
|
10005
|
+
const C = await this.shouldRetry(T);
|
|
10006
|
+
if (n && C) {
|
|
10007
|
+
const x = `retrying, ${n} attempts remaining`;
|
|
10008
|
+
return await fd(T.body), $(this).info(`${E} - ${x}`), $(this).debug(`[${h}] response error (${x})`, re({
|
|
10009
10009
|
retryOfRequestLogID: o,
|
|
10010
10010
|
url: T.url,
|
|
10011
10011
|
status: T.status,
|
|
10012
10012
|
headers: T.headers,
|
|
10013
|
-
durationMs:
|
|
10013
|
+
durationMs: I - y
|
|
10014
10014
|
})), this.retryRequest(u, n, o ?? h, T.headers);
|
|
10015
10015
|
}
|
|
10016
|
-
const
|
|
10017
|
-
$(this).info(`${
|
|
10018
|
-
const
|
|
10019
|
-
throw $(this).debug(`[${h}] response error (${
|
|
10016
|
+
const S = C ? "error; no more retries left" : "error; not retryable";
|
|
10017
|
+
$(this).info(`${E} - ${S}`);
|
|
10018
|
+
const v = await T.text().catch((x) => nt(x).message), R = id(v), w = R ? void 0 : v;
|
|
10019
|
+
throw $(this).debug(`[${h}] response error (${S})`, re({
|
|
10020
10020
|
retryOfRequestLogID: o,
|
|
10021
10021
|
url: T.url,
|
|
10022
10022
|
status: T.status,
|
|
10023
10023
|
headers: T.headers,
|
|
10024
|
-
message:
|
|
10024
|
+
message: w,
|
|
10025
10025
|
durationMs: Date.now() - y
|
|
10026
|
-
})), this.makeStatusError(T.status,
|
|
10026
|
+
})), this.makeStatusError(T.status, R, w, T.headers);
|
|
10027
10027
|
}
|
|
10028
|
-
return $(this).info(
|
|
10028
|
+
return $(this).info(E), $(this).debug(`[${h}] response start`, re({
|
|
10029
10029
|
retryOfRequestLogID: o,
|
|
10030
10030
|
url: T.url,
|
|
10031
10031
|
status: T.status,
|
|
10032
10032
|
headers: T.headers,
|
|
10033
|
-
durationMs:
|
|
10034
|
-
})), { response: T, options: u, controller:
|
|
10033
|
+
durationMs: I - y
|
|
10034
|
+
})), { response: T, options: u, controller: _, requestLogID: h, retryOfRequestLogID: o, startTime: y };
|
|
10035
10035
|
}
|
|
10036
10036
|
async fetchWithTimeout(e, n, o, s) {
|
|
10037
10037
|
const l = n || {}, { signal: a, method: u } = l, c = ke(l, ["signal", "method"]);
|
|
@@ -10082,7 +10082,7 @@ class Be {
|
|
|
10082
10082
|
let l = {};
|
|
10083
10083
|
this.idempotencyHeader && n !== "get" && (e.idempotencyKey || (e.idempotencyKey = this.defaultIdempotencyKey()), l[this.idempotencyHeader] = e.idempotencyKey);
|
|
10084
10084
|
const a = await this.authHeaders(e);
|
|
10085
|
-
let u =
|
|
10085
|
+
let u = Ee([
|
|
10086
10086
|
l,
|
|
10087
10087
|
Object.assign(Object.assign({ Accept: "application/json", "User-Agent": this.getUserAgent(), "X-Stainless-Retry-Count": String(s) }, e.timeout ? { "X-Stainless-Timeout": String(Math.trunc(e.timeout / 1e3)) } : {}), ud()),
|
|
10088
10088
|
this._options.defaultHeaders,
|
|
@@ -10095,7 +10095,7 @@ class Be {
|
|
|
10095
10095
|
buildBody({ options: { body: e, headers: n } }) {
|
|
10096
10096
|
if (!e)
|
|
10097
10097
|
return { bodyHeaders: void 0, body: void 0 };
|
|
10098
|
-
const o =
|
|
10098
|
+
const o = Ee([n]);
|
|
10099
10099
|
return (
|
|
10100
10100
|
// Pass raw type verbatim
|
|
10101
10101
|
ArrayBuffer.isView(e) || e instanceof ArrayBuffer || e instanceof DataView || typeof e == "string" && // Preserve legacy string encoding behavior for now
|
|
@@ -10471,42 +10471,42 @@ function rt(t, e) {
|
|
|
10471
10471
|
"preTunedModel"
|
|
10472
10472
|
]);
|
|
10473
10473
|
y != null && r(n, ["preTunedModel"], y);
|
|
10474
|
-
const
|
|
10474
|
+
const _ = i(t, [
|
|
10475
10475
|
"supervisedTuningSpec"
|
|
10476
10476
|
]);
|
|
10477
|
-
|
|
10477
|
+
_ != null && r(n, ["supervisedTuningSpec"], _);
|
|
10478
10478
|
const T = i(t, [
|
|
10479
10479
|
"preferenceOptimizationSpec"
|
|
10480
10480
|
]);
|
|
10481
10481
|
T != null && r(n, ["preferenceOptimizationSpec"], T);
|
|
10482
|
-
const
|
|
10482
|
+
const I = i(t, [
|
|
10483
10483
|
"tuningDataStats"
|
|
10484
10484
|
]);
|
|
10485
|
-
|
|
10486
|
-
const
|
|
10485
|
+
I != null && r(n, ["tuningDataStats"], I);
|
|
10486
|
+
const E = i(t, [
|
|
10487
10487
|
"encryptionSpec"
|
|
10488
10488
|
]);
|
|
10489
|
-
|
|
10490
|
-
const
|
|
10489
|
+
E != null && r(n, ["encryptionSpec"], E);
|
|
10490
|
+
const C = i(t, [
|
|
10491
10491
|
"partnerModelTuningSpec"
|
|
10492
10492
|
]);
|
|
10493
|
-
|
|
10494
|
-
const
|
|
10493
|
+
C != null && r(n, ["partnerModelTuningSpec"], C);
|
|
10494
|
+
const S = i(t, [
|
|
10495
10495
|
"customBaseModel"
|
|
10496
10496
|
]);
|
|
10497
|
-
|
|
10498
|
-
const
|
|
10499
|
-
|
|
10500
|
-
const
|
|
10501
|
-
|
|
10502
|
-
const
|
|
10503
|
-
|
|
10497
|
+
S != null && r(n, ["customBaseModel"], S);
|
|
10498
|
+
const v = i(t, ["experiment"]);
|
|
10499
|
+
v != null && r(n, ["experiment"], v);
|
|
10500
|
+
const R = i(t, ["labels"]);
|
|
10501
|
+
R != null && r(n, ["labels"], R);
|
|
10502
|
+
const w = i(t, ["outputUri"]);
|
|
10503
|
+
w != null && r(n, ["outputUri"], w);
|
|
10504
10504
|
const U = i(t, ["pipelineJob"]);
|
|
10505
10505
|
U != null && r(n, ["pipelineJob"], U);
|
|
10506
|
-
const
|
|
10506
|
+
const x = i(t, [
|
|
10507
10507
|
"serviceAccount"
|
|
10508
10508
|
]);
|
|
10509
|
-
|
|
10509
|
+
x != null && r(n, ["serviceAccount"], x);
|
|
10510
10510
|
const P = i(t, [
|
|
10511
10511
|
"tunedModelDisplayName"
|
|
10512
10512
|
]);
|
|
@@ -10545,7 +10545,7 @@ function Zn(t, e) {
|
|
|
10545
10545
|
*/
|
|
10546
10546
|
class Qd extends te {
|
|
10547
10547
|
constructor(e) {
|
|
10548
|
-
super(), this.apiClient = e, this.list = async (n = {}) => new
|
|
10548
|
+
super(), this.apiClient = e, this.list = async (n = {}) => new ae(ee.PAGED_ITEM_TUNING_JOBS, (o) => this.listInternal(o), await this.listInternal(n), n), this.get = async (n) => await this.getInternal(n), this.tune = async (n) => {
|
|
10549
10549
|
var o;
|
|
10550
10550
|
if (this.apiClient.isVertexAI())
|
|
10551
10551
|
if (n.baseModel.startsWith("projects/")) {
|
|
@@ -10574,7 +10574,7 @@ class Qd extends te {
|
|
|
10574
10574
|
let a, u = "", c = {};
|
|
10575
10575
|
if (this.apiClient.isVertexAI()) {
|
|
10576
10576
|
const d = qd(e);
|
|
10577
|
-
return u =
|
|
10577
|
+
return u = A("{name}", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
10578
10578
|
path: u,
|
|
10579
10579
|
queryParams: c,
|
|
10580
10580
|
body: JSON.stringify(d),
|
|
@@ -10589,7 +10589,7 @@ class Qd extends te {
|
|
|
10589
10589
|
})), a.then((f) => rt(f));
|
|
10590
10590
|
} else {
|
|
10591
10591
|
const d = Vd(e);
|
|
10592
|
-
return u =
|
|
10592
|
+
return u = A("{name}", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
10593
10593
|
path: u,
|
|
10594
10594
|
queryParams: c,
|
|
10595
10595
|
body: JSON.stringify(d),
|
|
@@ -10609,7 +10609,7 @@ class Qd extends te {
|
|
|
10609
10609
|
let a, u = "", c = {};
|
|
10610
10610
|
if (this.apiClient.isVertexAI()) {
|
|
10611
10611
|
const d = $d(e);
|
|
10612
|
-
return u =
|
|
10612
|
+
return u = A("tuningJobs", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
10613
10613
|
path: u,
|
|
10614
10614
|
queryParams: c,
|
|
10615
10615
|
body: JSON.stringify(d),
|
|
@@ -10627,7 +10627,7 @@ class Qd extends te {
|
|
|
10627
10627
|
});
|
|
10628
10628
|
} else {
|
|
10629
10629
|
const d = Jd(e);
|
|
10630
|
-
return u =
|
|
10630
|
+
return u = A("tunedModels", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
10631
10631
|
path: u,
|
|
10632
10632
|
queryParams: c,
|
|
10633
10633
|
body: JSON.stringify(d),
|
|
@@ -10661,7 +10661,7 @@ class Qd extends te {
|
|
|
10661
10661
|
let a, u = "", c = {};
|
|
10662
10662
|
if (this.apiClient.isVertexAI()) {
|
|
10663
10663
|
const d = kd(e);
|
|
10664
|
-
return u =
|
|
10664
|
+
return u = A("{name}:cancel", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
10665
10665
|
path: u,
|
|
10666
10666
|
queryParams: c,
|
|
10667
10667
|
body: JSON.stringify(d),
|
|
@@ -10679,7 +10679,7 @@ class Qd extends te {
|
|
|
10679
10679
|
});
|
|
10680
10680
|
} else {
|
|
10681
10681
|
const d = Pd(e);
|
|
10682
|
-
return u =
|
|
10682
|
+
return u = A("{name}:cancel", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
10683
10683
|
path: u,
|
|
10684
10684
|
queryParams: c,
|
|
10685
10685
|
body: JSON.stringify(d),
|
|
@@ -10702,7 +10702,7 @@ class Qd extends te {
|
|
|
10702
10702
|
let s, l = "", a = {};
|
|
10703
10703
|
if (this.apiClient.isVertexAI()) {
|
|
10704
10704
|
const u = Gd(e, e);
|
|
10705
|
-
return l =
|
|
10705
|
+
return l = A("tuningJobs", u._url), a = u._query, delete u._url, delete u._query, s = this.apiClient.request({
|
|
10706
10706
|
path: l,
|
|
10707
10707
|
queryParams: a,
|
|
10708
10708
|
body: JSON.stringify(u),
|
|
@@ -10725,7 +10725,7 @@ class Qd extends te {
|
|
|
10725
10725
|
throw new Error("This method is only supported by the Gemini Developer API.");
|
|
10726
10726
|
{
|
|
10727
10727
|
const u = Fd(e);
|
|
10728
|
-
return l =
|
|
10728
|
+
return l = A("tunedModels", u._url), a = u._query, delete u._url, delete u._query, s = this.apiClient.request({
|
|
10729
10729
|
path: l,
|
|
10730
10730
|
queryParams: a,
|
|
10731
10731
|
body: JSON.stringify(u),
|
|
@@ -10949,14 +10949,14 @@ Example: For an image showing 'x squared', your literal output must be: x^2` },
|
|
|
10949
10949
|
} catch (o) {
|
|
10950
10950
|
throw console.error("Error calling Gemini API:", o), o instanceof Error && (o.message.includes("API key not valid") || o.message.includes("400")) ? new Error("The API key is not valid. Please check your configuration.") : new Error("Failed to recognize handwriting. The model may be unavailable or the drawing is unclear.");
|
|
10951
10951
|
}
|
|
10952
|
-
}, jo = () => /* @__PURE__ */
|
|
10952
|
+
}, jo = () => /* @__PURE__ */ M("span", { className: "text-sm leading-tight flex flex-col items-center text-black -mt-0.5", children: [
|
|
10953
10953
|
/* @__PURE__ */ g("span", { children: "□" }),
|
|
10954
10954
|
/* @__PURE__ */ g("span", { className: "w-2 h-px bg-black my-[1px]" }),
|
|
10955
10955
|
/* @__PURE__ */ g("span", { children: "□" })
|
|
10956
|
-
] }), ei = () => /* @__PURE__ */
|
|
10956
|
+
] }), ei = () => /* @__PURE__ */ M("span", { className: "text-black text-lg", children: [
|
|
10957
10957
|
"√",
|
|
10958
10958
|
/* @__PURE__ */ g("span", { className: "border-t border-black -ml-1", children: "□" })
|
|
10959
|
-
] }), hc = () => /* @__PURE__ */
|
|
10959
|
+
] }), hc = () => /* @__PURE__ */ M("span", { className: "text-black text-lg", children: [
|
|
10960
10960
|
/* @__PURE__ */ g("sup", { className: "-mr-1", children: "□" }),
|
|
10961
10961
|
"√",
|
|
10962
10962
|
/* @__PURE__ */ g("span", { className: "border-t border-black -ml-1", children: "□" })
|
|
@@ -10977,7 +10977,7 @@ Example: For an image showing 'x squared', your literal output must be: x^2` },
|
|
|
10977
10977
|
children: n
|
|
10978
10978
|
}
|
|
10979
10979
|
), yc = [
|
|
10980
|
-
{ key: "layout", display: /* @__PURE__ */
|
|
10980
|
+
{ key: "layout", display: /* @__PURE__ */ M("div", { className: "flex items-center gap-1", children: [
|
|
10981
10981
|
/* @__PURE__ */ g(ei, {}),
|
|
10982
10982
|
" ",
|
|
10983
10983
|
/* @__PURE__ */ g(jo, {})
|
|
@@ -11128,8 +11128,8 @@ Example: For an image showing 'x squared', your literal output must be: x^2` },
|
|
|
11128
11128
|
products: []
|
|
11129
11129
|
}, Tc = ({ onInsert: t }) => {
|
|
11130
11130
|
const [e, n] = V("layout");
|
|
11131
|
-
return /* @__PURE__ */
|
|
11132
|
-
/* @__PURE__ */
|
|
11131
|
+
return /* @__PURE__ */ M("div", { className: "bg-[#e9eff1] px-2 py-1 flex flex-col space-y-1 shrink-0 border-b border-gray-300", children: [
|
|
11132
|
+
/* @__PURE__ */ M("div", { className: "flex flex-wrap gap-1 items-center", children: [
|
|
11133
11133
|
yc.map((o) => /* @__PURE__ */ g(
|
|
11134
11134
|
gc,
|
|
11135
11135
|
{
|
|
@@ -11143,13 +11143,13 @@ Example: For an image showing 'x squared', your literal output must be: x^2` },
|
|
|
11143
11143
|
/* @__PURE__ */ g("div", { className: "flex-grow" }),
|
|
11144
11144
|
/* @__PURE__ */ g("button", { title: "Help", className: "w-8 h-8 rounded-full bg-gray-400 hover:bg-gray-500 text-white flex items-center justify-center shadow-sm transition-all", children: /* @__PURE__ */ g("svg", { className: "w-5 h-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ g("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }) })
|
|
11145
11145
|
] }),
|
|
11146
|
-
/* @__PURE__ */
|
|
11147
|
-
/* @__PURE__ */ g("div", { className: "flex items-start", children: eo[e].map((o, s) => /* @__PURE__ */
|
|
11146
|
+
/* @__PURE__ */ M("div", { className: "flex items-start bg-white rounded border border-gray-300 min-h-[5rem] shadow-inner p-1 overflow-x-auto", children: [
|
|
11147
|
+
/* @__PURE__ */ g("div", { className: "flex items-start", children: eo[e].map((o, s) => /* @__PURE__ */ M(oo.Fragment, { children: [
|
|
11148
11148
|
/* @__PURE__ */ g("div", { className: "flex flex-col", children: o.map((l, a) => /* @__PURE__ */ g("div", { className: "flex", children: l.map((u, c) => /* @__PURE__ */ g(mc, { symbol: u, onInsert: t }, c)) }, a)) }),
|
|
11149
11149
|
s < eo[e].length - 1 && /* @__PURE__ */ g("div", { className: "w-px bg-gray-300 mx-1 self-stretch" })
|
|
11150
11150
|
] }, s)) }),
|
|
11151
11151
|
/* @__PURE__ */ g("div", { className: "flex-grow" }),
|
|
11152
|
-
/* @__PURE__ */ g("div", { className: "flex items-center space-x-2 shrink-0 self-center pr-2", children: /* @__PURE__ */
|
|
11152
|
+
/* @__PURE__ */ g("div", { className: "flex items-center space-x-2 shrink-0 self-center pr-2", children: /* @__PURE__ */ M("div", { className: "flex flex-col space-y-1", children: [
|
|
11153
11153
|
/* @__PURE__ */ g("select", { disabled: !0, className: "text-sm border border-gray-300 rounded h-6 w-32 px-1 text-black opacity-50", children: /* @__PURE__ */ g("option", { children: "Font..." }) }),
|
|
11154
11154
|
/* @__PURE__ */ g("select", { disabled: !0, className: "text-sm border border-gray-300 rounded h-6 w-32 px-1 text-black opacity-50", children: /* @__PURE__ */ g("option", { children: "Size..." }) })
|
|
11155
11155
|
] }) })
|
|
@@ -11196,11 +11196,11 @@ Example: For an image showing 'x squared', your literal output must be: x^2` },
|
|
|
11196
11196
|
[{ display: "↔", latex: "\\leftrightarrow " }]
|
|
11197
11197
|
],
|
|
11198
11198
|
[
|
|
11199
|
-
[{ display: /* @__PURE__ */
|
|
11199
|
+
[{ display: /* @__PURE__ */ M("span", { className: "text-lg", children: [
|
|
11200
11200
|
"→",
|
|
11201
11201
|
/* @__PURE__ */ g("sup", { className: "-top-1.5 text-[8px]", children: "□" })
|
|
11202
11202
|
] }), latex: "\\xrightarrow{}" }],
|
|
11203
|
-
[{ display: /* @__PURE__ */
|
|
11203
|
+
[{ display: /* @__PURE__ */ M("span", { className: "text-lg", children: [
|
|
11204
11204
|
"⇌",
|
|
11205
11205
|
/* @__PURE__ */ g("sup", { className: "-top-1.5 text-[8px]", children: "□" })
|
|
11206
11206
|
] }), latex: "\\xrightleftharpoons{}" }]
|
|
@@ -11280,8 +11280,8 @@ Example: For an image showing 'x squared', your literal output must be: x^2` },
|
|
|
11280
11280
|
]
|
|
11281
11281
|
}, vc = ({ onInsert: t }) => {
|
|
11282
11282
|
const [e, n] = V("chem");
|
|
11283
|
-
return /* @__PURE__ */
|
|
11284
|
-
/* @__PURE__ */
|
|
11283
|
+
return /* @__PURE__ */ M("div", { className: "bg-[#e9eff1] px-2 py-1 flex flex-col space-y-1 shrink-0 border-b border-gray-300", children: [
|
|
11284
|
+
/* @__PURE__ */ M("div", { className: "flex flex-wrap gap-1 items-center", children: [
|
|
11285
11285
|
Cc.map((o) => /* @__PURE__ */ g(
|
|
11286
11286
|
Ec,
|
|
11287
11287
|
{
|
|
@@ -11295,13 +11295,13 @@ Example: For an image showing 'x squared', your literal output must be: x^2` },
|
|
|
11295
11295
|
/* @__PURE__ */ g("div", { className: "flex-grow" }),
|
|
11296
11296
|
/* @__PURE__ */ g("button", { title: "Help", className: "w-8 h-8 rounded-full bg-gray-400 hover:bg-gray-500 text-white flex items-center justify-center shadow-sm transition-all", children: /* @__PURE__ */ g("svg", { className: "w-5 h-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ g("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }) })
|
|
11297
11297
|
] }),
|
|
11298
|
-
/* @__PURE__ */
|
|
11299
|
-
/* @__PURE__ */ g("div", { className: "flex items-start", children: to[e].map((o, s) => /* @__PURE__ */
|
|
11298
|
+
/* @__PURE__ */ M("div", { className: "flex items-start bg-white rounded border border-gray-300 min-h-[5rem] shadow-inner p-1 overflow-x-auto", children: [
|
|
11299
|
+
/* @__PURE__ */ g("div", { className: "flex items-start", children: to[e].map((o, s) => /* @__PURE__ */ M(oo.Fragment, { children: [
|
|
11300
11300
|
/* @__PURE__ */ g("div", { className: "flex flex-col", children: o.map((l, a) => /* @__PURE__ */ g("div", { className: "flex", children: l.map((u, c) => /* @__PURE__ */ g(_c, { symbol: u, onInsert: t }, c)) }, a)) }),
|
|
11301
11301
|
s < to[e].length - 1 && /* @__PURE__ */ g("div", { className: "w-px bg-gray-300 mx-1 self-stretch" })
|
|
11302
11302
|
] }, s)) }),
|
|
11303
11303
|
/* @__PURE__ */ g("div", { className: "flex-grow" }),
|
|
11304
|
-
/* @__PURE__ */ g("div", { className: "flex items-center space-x-2 shrink-0 self-center pr-2", children: /* @__PURE__ */
|
|
11304
|
+
/* @__PURE__ */ g("div", { className: "flex items-center space-x-2 shrink-0 self-center pr-2", children: /* @__PURE__ */ M("div", { className: "flex flex-col space-y-1", children: [
|
|
11305
11305
|
/* @__PURE__ */ g("select", { disabled: !0, className: "text-sm border border-gray-300 rounded h-6 w-32 px-1 text-black opacity-50", children: /* @__PURE__ */ g("option", { children: "Font..." }) }),
|
|
11306
11306
|
/* @__PURE__ */ g("select", { disabled: !0, className: "text-sm border border-gray-300 rounded h-6 w-32 px-1 text-black opacity-50", children: /* @__PURE__ */ g("option", { children: "Size..." }) })
|
|
11307
11307
|
] }) })
|
|
@@ -11561,8 +11561,8 @@ const Zc = [
|
|
|
11561
11561
|
["path", { d: "M18 6 6 18", key: "1bl5f8" }],
|
|
11562
11562
|
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
|
|
11563
11563
|
], jc = Y("x", Zc), ef = ({ isOpen: t, onClose: e, onInsert: n, apiKey: o = "" }) => {
|
|
11564
|
-
const s = j(null), l = j(null), [a, u] = V(!1), [c, d] = V(null), [f, p] = V(""), [h, m] = V("keyboard"), [y,
|
|
11565
|
-
|
|
11564
|
+
const s = j(null), l = j(null), [a, u] = V(!1), [c, d] = V(null), [f, p] = V(""), [h, m] = V("keyboard"), [y, _] = V("math"), [T, I] = V(!1), [E, C] = V(!1), [S, v] = V(""), [R, w] = V(!1);
|
|
11565
|
+
he(() => {
|
|
11566
11566
|
if (h === "keyboard" && f.trim() && window.katex)
|
|
11567
11567
|
try {
|
|
11568
11568
|
const k = window.katex.renderToString(f, {
|
|
@@ -11570,29 +11570,29 @@ const Zc = [
|
|
|
11570
11570
|
displayMode: !1,
|
|
11571
11571
|
output: "mathml"
|
|
11572
11572
|
});
|
|
11573
|
-
|
|
11573
|
+
console.log("previewHTML : ", S), v(k), w(!0);
|
|
11574
11574
|
} catch {
|
|
11575
|
-
|
|
11575
|
+
v('<span class="text-red-500 text-xs">Invalid formula syntax</span>'), w(!1);
|
|
11576
11576
|
}
|
|
11577
11577
|
else
|
|
11578
|
-
|
|
11578
|
+
v(""), w(!1);
|
|
11579
11579
|
}, [f, h]);
|
|
11580
11580
|
const U = (k) => {
|
|
11581
|
-
|
|
11582
|
-
},
|
|
11581
|
+
_(k), k === "chem" && m("keyboard");
|
|
11582
|
+
}, x = le(() => {
|
|
11583
11583
|
var k;
|
|
11584
11584
|
(k = s.current) == null || k.clear(), p(""), d(null), u(!1);
|
|
11585
|
-
}, []), P =
|
|
11585
|
+
}, []), P = le((k) => {
|
|
11586
11586
|
const b = l.current;
|
|
11587
11587
|
if (!b) {
|
|
11588
11588
|
p((H) => H + k);
|
|
11589
11589
|
return;
|
|
11590
11590
|
}
|
|
11591
|
-
const q = b.selectionStart,
|
|
11591
|
+
const q = b.selectionStart, N = b.selectionEnd, G = f.substring(0, q) + k + f.substring(N);
|
|
11592
11592
|
p(G), setTimeout(() => {
|
|
11593
11593
|
b.focus(), b.selectionStart = b.selectionEnd = q + k.length;
|
|
11594
11594
|
}, 0);
|
|
11595
|
-
}, [f]), L =
|
|
11595
|
+
}, [f]), L = le(async () => {
|
|
11596
11596
|
var b, q;
|
|
11597
11597
|
if (!o) {
|
|
11598
11598
|
d("Please configure your Gemini API key in the main editor.");
|
|
@@ -11605,33 +11605,33 @@ const Zc = [
|
|
|
11605
11605
|
}
|
|
11606
11606
|
u(!0), d(null);
|
|
11607
11607
|
try {
|
|
11608
|
-
const
|
|
11608
|
+
const N = k.split(",")[1], G = await pc(N, o);
|
|
11609
11609
|
P(G), m("keyboard"), (q = s.current) == null || q.clear();
|
|
11610
|
-
} catch (
|
|
11611
|
-
d(
|
|
11610
|
+
} catch (N) {
|
|
11611
|
+
d(N.message || "AI recognition failed.");
|
|
11612
11612
|
} finally {
|
|
11613
11613
|
u(!1);
|
|
11614
11614
|
}
|
|
11615
11615
|
}, [o, P]);
|
|
11616
|
-
return t ? /* @__PURE__ */ g("div", { className: "fixed inset-0 z-[100] flex items-center justify-center bg-slate-900/40 backdrop-blur-md p-4 animate-in fade-in duration-200", children: /* @__PURE__ */
|
|
11617
|
-
/* @__PURE__ */
|
|
11618
|
-
/* @__PURE__ */
|
|
11616
|
+
return t ? /* @__PURE__ */ g("div", { className: "fixed inset-0 z-[100] flex items-center justify-center bg-slate-900/40 backdrop-blur-md p-4 animate-in fade-in duration-200", children: /* @__PURE__ */ M("div", { className: "bg-white rounded-2xl shadow-2xl flex flex-col w-full max-w-4xl h-[600px] border border-slate-200 overflow-hidden", onClick: (k) => k.stopPropagation(), children: [
|
|
11617
|
+
/* @__PURE__ */ M("header", { className: "px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50/50", children: [
|
|
11618
|
+
/* @__PURE__ */ M("div", { className: "flex items-center gap-6", children: [
|
|
11619
11619
|
/* @__PURE__ */ g("h2", { className: "text-lg font-bold text-slate-900", children: "AI Formula Pad" }),
|
|
11620
|
-
/* @__PURE__ */
|
|
11620
|
+
/* @__PURE__ */ M("div", { className: "flex bg-slate-200 p-1 rounded-lg", children: [
|
|
11621
11621
|
/* @__PURE__ */ g("button", { onClick: () => U("math"), className: `px-4 py-1 text-xs font-semibold rounded-md transition-all ${y === "math" ? "bg-white shadow text-blue-600" : "text-slate-500"}`, children: "Math" }),
|
|
11622
11622
|
/* @__PURE__ */ g("button", { onClick: () => U("chem"), className: `px-4 py-1 text-xs font-semibold rounded-md transition-all ${y === "chem" ? "bg-white shadow text-blue-600" : "text-slate-500"}`, children: "Chemistry" })
|
|
11623
11623
|
] })
|
|
11624
11624
|
] }),
|
|
11625
11625
|
/* @__PURE__ */ g("button", { title: "Close", onClick: e, className: "p-2 hover:bg-slate-200 rounded-full text-slate-400 hover:text-slate-600 transition-colors", children: /* @__PURE__ */ g(jc, { size: 20 }) })
|
|
11626
11626
|
] }),
|
|
11627
|
-
/* @__PURE__ */
|
|
11628
|
-
/* @__PURE__ */
|
|
11627
|
+
/* @__PURE__ */ M("div", { className: "flex-1 flex overflow-hidden", children: [
|
|
11628
|
+
/* @__PURE__ */ M("div", { className: "w-16 border-r border-slate-100 flex flex-col items-center py-6 gap-4 bg-slate-50/30", children: [
|
|
11629
11629
|
/* @__PURE__ */ g("button", { onClick: () => m("keyboard"), className: `p-3 rounded-xl transition-all ${h === "keyboard" ? "bg-blue-600 text-white shadow-lg" : "text-slate-400 hover:text-slate-600"}`, children: /* @__PURE__ */ g(Dc, { size: 24 }) }),
|
|
11630
11630
|
y === "math" && /* @__PURE__ */ g("button", { onClick: () => m("handwriting"), className: `p-3 rounded-xl transition-all ${h === "handwriting" ? "bg-blue-600 text-white shadow-lg" : "text-slate-400 hover:text-slate-600"}`, children: /* @__PURE__ */ g(Jc, { size: 24 }) })
|
|
11631
11631
|
] }),
|
|
11632
|
-
/* @__PURE__ */
|
|
11632
|
+
/* @__PURE__ */ M("div", { className: "flex-1 flex flex-col overflow-hidden", children: [
|
|
11633
11633
|
/* @__PURE__ */ g("div", { className: "shrink-0", children: h === "keyboard" && (y === "math" ? /* @__PURE__ */ g(Tc, { onInsert: P }) : /* @__PURE__ */ g(vc, { onInsert: P })) }),
|
|
11634
|
-
/* @__PURE__ */ g("div", { className: "flex-1 p-6 relative bg-slate-50/20", children: h === "keyboard" ? /* @__PURE__ */
|
|
11634
|
+
/* @__PURE__ */ g("div", { className: "flex-1 p-6 relative bg-slate-50/20", children: h === "keyboard" ? /* @__PURE__ */ M("div", { className: "h-full flex flex-col gap-4", children: [
|
|
11635
11635
|
/* @__PURE__ */ g(
|
|
11636
11636
|
"textarea",
|
|
11637
11637
|
{
|
|
@@ -11642,12 +11642,12 @@ const Zc = [
|
|
|
11642
11642
|
placeholder: `Enter LaTeX for ${y}...`
|
|
11643
11643
|
}
|
|
11644
11644
|
),
|
|
11645
|
-
/* @__PURE__ */ g("div", { className: "h-20 bg-white border border-slate-100 rounded-xl flex items-center justify-center p-4 shadow-sm overflow-auto", children:
|
|
11646
|
-
] }) : /* @__PURE__ */
|
|
11645
|
+
/* @__PURE__ */ g("div", { className: "h-20 bg-white border border-slate-100 rounded-xl flex items-center justify-center p-4 shadow-sm overflow-auto", children: S ? /* @__PURE__ */ g("div", { dangerouslySetInnerHTML: { __html: S } }) : /* @__PURE__ */ g("span", { className: "text-slate-300 italic", children: "Preview will appear here" }) })
|
|
11646
|
+
] }) : /* @__PURE__ */ M("div", { className: "h-full border border-slate-200 bg-white rounded-2xl shadow-inner overflow-hidden relative", children: [
|
|
11647
11647
|
/* @__PURE__ */ g(so, { ref: s, onHistoryChange: (k) => {
|
|
11648
|
-
|
|
11648
|
+
I(k.canUndo), C(k.canRedo);
|
|
11649
11649
|
} }),
|
|
11650
|
-
/* @__PURE__ */
|
|
11650
|
+
/* @__PURE__ */ M("div", { className: "absolute top-4 right-4 flex flex-col gap-2", children: [
|
|
11651
11651
|
/* @__PURE__ */ g("button", { onClick: () => {
|
|
11652
11652
|
var k;
|
|
11653
11653
|
return (k = s.current) == null ? void 0 : k.undo();
|
|
@@ -11655,10 +11655,10 @@ const Zc = [
|
|
|
11655
11655
|
/* @__PURE__ */ g("button", { onClick: () => {
|
|
11656
11656
|
var k;
|
|
11657
11657
|
return (k = s.current) == null ? void 0 : k.redo();
|
|
11658
|
-
}, disabled: !
|
|
11659
|
-
/* @__PURE__ */ g("button", { onClick:
|
|
11658
|
+
}, disabled: !E, className: "p-2 bg-white border border-slate-200 rounded-lg shadow-sm disabled:opacity-30 hover:bg-slate-50", children: /* @__PURE__ */ g(Kc, { size: 18 }) }),
|
|
11659
|
+
/* @__PURE__ */ g("button", { onClick: x, className: "p-2 bg-white border border-slate-200 rounded-lg shadow-sm text-red-500 hover:bg-red-50", children: /* @__PURE__ */ g(Qc, { size: 18 }) })
|
|
11660
11660
|
] }),
|
|
11661
|
-
/* @__PURE__ */ g("div", { className: "absolute bottom-6 left-1/2 -translate-x-1/2 flex gap-4", children: /* @__PURE__ */
|
|
11661
|
+
/* @__PURE__ */ g("div", { className: "absolute bottom-6 left-1/2 -translate-x-1/2 flex gap-4", children: /* @__PURE__ */ M(
|
|
11662
11662
|
"button",
|
|
11663
11663
|
{
|
|
11664
11664
|
onClick: L,
|
|
@@ -11673,17 +11673,17 @@ const Zc = [
|
|
|
11673
11673
|
] }) })
|
|
11674
11674
|
] })
|
|
11675
11675
|
] }),
|
|
11676
|
-
/* @__PURE__ */
|
|
11676
|
+
/* @__PURE__ */ M("footer", { className: "px-6 py-4 border-t border-slate-100 flex justify-between items-center bg-slate-50/50", children: [
|
|
11677
11677
|
c && /* @__PURE__ */ g("span", { className: "text-sm font-medium text-red-500 animate-pulse", children: c }),
|
|
11678
|
-
/* @__PURE__ */
|
|
11678
|
+
/* @__PURE__ */ M("div", { className: "ml-auto flex gap-3", children: [
|
|
11679
11679
|
/* @__PURE__ */ g("button", { onClick: e, className: "px-6 py-2 text-slate-600 font-semibold hover:bg-slate-200 rounded-xl transition", children: "Cancel" }),
|
|
11680
11680
|
/* @__PURE__ */ g(
|
|
11681
11681
|
"button",
|
|
11682
11682
|
{
|
|
11683
11683
|
onClick: () => {
|
|
11684
|
-
n(
|
|
11684
|
+
n(S), e();
|
|
11685
11685
|
},
|
|
11686
|
-
disabled: !
|
|
11686
|
+
disabled: !R,
|
|
11687
11687
|
className: "px-8 py-2 bg-slate-900 text-white font-bold rounded-xl shadow-lg disabled:opacity-40 hover:bg-slate-800 transition",
|
|
11688
11688
|
children: "Insert Into Editor"
|
|
11689
11689
|
}
|
|
@@ -11693,10 +11693,10 @@ const Zc = [
|
|
|
11693
11693
|
] }) }) : null;
|
|
11694
11694
|
}, tf = ({ isOpen: t, onClose: e, onInsert: n }) => {
|
|
11695
11695
|
const [o, s] = V(3), [l, a] = V(3);
|
|
11696
|
-
return t ? /* @__PURE__ */ g("div", { className: "fixed inset-0 z-[60] flex items-center justify-center bg-black bg-opacity-50 backdrop-blur-sm", onClick: e, children: /* @__PURE__ */
|
|
11696
|
+
return t ? /* @__PURE__ */ g("div", { className: "fixed inset-0 z-[60] flex items-center justify-center bg-black bg-opacity-50 backdrop-blur-sm", onClick: e, children: /* @__PURE__ */ M("div", { className: "bg-white rounded-lg shadow-xl p-6 w-full max-w-sm", onClick: (c) => c.stopPropagation(), children: [
|
|
11697
11697
|
/* @__PURE__ */ g("h3", { className: "text-lg font-semibold text-gray-800 mb-4", children: "Insert Table" }),
|
|
11698
|
-
/* @__PURE__ */
|
|
11699
|
-
/* @__PURE__ */
|
|
11698
|
+
/* @__PURE__ */ M("div", { className: "space-y-4", children: [
|
|
11699
|
+
/* @__PURE__ */ M("div", { children: [
|
|
11700
11700
|
/* @__PURE__ */ g("label", { htmlFor: "rows", className: "block text-sm font-medium text-gray-700 mb-1", children: "Rows" }),
|
|
11701
11701
|
/* @__PURE__ */ g(
|
|
11702
11702
|
"input",
|
|
@@ -11709,7 +11709,7 @@ const Zc = [
|
|
|
11709
11709
|
}
|
|
11710
11710
|
)
|
|
11711
11711
|
] }),
|
|
11712
|
-
/* @__PURE__ */
|
|
11712
|
+
/* @__PURE__ */ M("div", { children: [
|
|
11713
11713
|
/* @__PURE__ */ g("label", { htmlFor: "cols", className: "block text-sm font-medium text-gray-700 mb-1", children: "Columns" }),
|
|
11714
11714
|
/* @__PURE__ */ g(
|
|
11715
11715
|
"input",
|
|
@@ -11723,7 +11723,7 @@ const Zc = [
|
|
|
11723
11723
|
)
|
|
11724
11724
|
] })
|
|
11725
11725
|
] }),
|
|
11726
|
-
/* @__PURE__ */
|
|
11726
|
+
/* @__PURE__ */ M("div", { className: "mt-6 flex justify-end space-x-3", children: [
|
|
11727
11727
|
/* @__PURE__ */ g("button", { title: "Cancel and discard", onClick: e, className: "px-4 py-2 bg-gray-200 text-gray-800 rounded-md hover:bg-gray-300 transition", children: "Cancel" }),
|
|
11728
11728
|
/* @__PURE__ */ g("button", { onClick: () => {
|
|
11729
11729
|
o > 0 && l > 0 && n(o, l);
|
|
@@ -11739,11 +11739,11 @@ const Zc = [
|
|
|
11739
11739
|
canRedo: l,
|
|
11740
11740
|
apiKey: a
|
|
11741
11741
|
}) => {
|
|
11742
|
-
const [u, c] = V(!1), [d, f] = V(!1), [p, h] = V(7), m = j(null), y = j([]),
|
|
11743
|
-
|
|
11744
|
-
a !== "" && a &&
|
|
11742
|
+
const [u, c] = V(!1), [d, f] = V(!1), [p, h] = V(7), m = j(null), y = j([]), _ = j(null), [T, I] = V(!1);
|
|
11743
|
+
he(() => {
|
|
11744
|
+
a !== "" && a && I(!0);
|
|
11745
11745
|
}, [a]);
|
|
11746
|
-
const
|
|
11746
|
+
const E = ni(() => [
|
|
11747
11747
|
{ id: "font", priority: 1 },
|
|
11748
11748
|
{ id: "history", priority: 2 },
|
|
11749
11749
|
{ id: "formatting", priority: 3 },
|
|
@@ -11752,97 +11752,97 @@ const Zc = [
|
|
|
11752
11752
|
{ id: "media", priority: 6 },
|
|
11753
11753
|
{ id: "handwriting", priority: 7 }
|
|
11754
11754
|
], []);
|
|
11755
|
-
|
|
11756
|
-
const
|
|
11757
|
-
if (!
|
|
11755
|
+
he(() => {
|
|
11756
|
+
const N = m.current;
|
|
11757
|
+
if (!N) return;
|
|
11758
11758
|
const G = new ResizeObserver((H) => {
|
|
11759
11759
|
const se = H[0].contentRect.width - 50;
|
|
11760
|
-
let
|
|
11760
|
+
let Te = 0, yt = 0;
|
|
11761
11761
|
for (let Je = 0; Je < y.current.length; Je++) {
|
|
11762
11762
|
const Tt = y.current[Je];
|
|
11763
11763
|
if (Tt) {
|
|
11764
11764
|
const _t = Tt.getBoundingClientRect().width + 8;
|
|
11765
|
-
if (
|
|
11766
|
-
|
|
11765
|
+
if (Te + _t <= se)
|
|
11766
|
+
Te += _t, yt++;
|
|
11767
11767
|
else
|
|
11768
11768
|
break;
|
|
11769
11769
|
}
|
|
11770
11770
|
}
|
|
11771
11771
|
h(Math.max(1, yt));
|
|
11772
11772
|
});
|
|
11773
|
-
return G.observe(
|
|
11773
|
+
return G.observe(N), () => G.disconnect();
|
|
11774
11774
|
}, []);
|
|
11775
|
-
const
|
|
11775
|
+
const C = (N) => {
|
|
11776
11776
|
var H;
|
|
11777
|
-
const G = (H =
|
|
11777
|
+
const G = (H = N.target.files) == null ? void 0 : H[0];
|
|
11778
11778
|
if (G) {
|
|
11779
11779
|
const K = new FileReader();
|
|
11780
11780
|
K.onload = (se) => {
|
|
11781
|
-
var
|
|
11782
|
-
return e("insertImage", (
|
|
11781
|
+
var Te;
|
|
11782
|
+
return e("insertImage", (Te = se.target) == null ? void 0 : Te.result);
|
|
11783
11783
|
}, K.readAsDataURL(G);
|
|
11784
11784
|
}
|
|
11785
|
-
|
|
11786
|
-
},
|
|
11785
|
+
N.target.value = "";
|
|
11786
|
+
}, S = (N, G) => {
|
|
11787
11787
|
let H = '<table style="width:100%; border-collapse: collapse; border: 1px solid black;"><tbody>';
|
|
11788
|
-
for (let K = 0; K <
|
|
11788
|
+
for (let K = 0; K < N; K++) {
|
|
11789
11789
|
H += "<tr>";
|
|
11790
11790
|
for (let se = 0; se < G; se++) H += '<td style="border: 1px solid black; padding: 5px;"><p><br></p></td>';
|
|
11791
11791
|
H += "</tr>";
|
|
11792
11792
|
}
|
|
11793
11793
|
H += "</tbody></table><p><br></p>", e("insertHTML", H), c(!1);
|
|
11794
|
-
},
|
|
11795
|
-
/* @__PURE__ */
|
|
11794
|
+
}, v = () => /* @__PURE__ */ M("div", { ref: (N) => y.current[0] = N, className: "flex items-center gap-2 shrink-0", children: [
|
|
11795
|
+
/* @__PURE__ */ M("select", { title: "Font Family", onMouseDown: (N) => N.stopPropagation(), onChange: (N) => e("fontName", N.target.value), defaultValue: "Arial", className: "bg-white border border-gray-300 rounded px-2 py-1 text-xs text-black outline-none focus:ring-1 focus:ring-blue-500 min-w-[80px]", children: [
|
|
11796
11796
|
/* @__PURE__ */ g("option", { value: "Arial", children: "Arial" }),
|
|
11797
11797
|
/* @__PURE__ */ g("option", { value: "Verdana", children: "Verdana" }),
|
|
11798
11798
|
/* @__PURE__ */ g("option", { value: "Georgia", children: "Georgia" })
|
|
11799
11799
|
] }),
|
|
11800
|
-
/* @__PURE__ */
|
|
11800
|
+
/* @__PURE__ */ M("select", { title: "Font Size", onMouseDown: (N) => N.stopPropagation(), onChange: (N) => e("fontSize", N.target.value), defaultValue: "3", className: "bg-white border border-gray-300 rounded px-2 py-1 text-xs text-black outline-none focus:ring-1 focus:ring-blue-500", children: [
|
|
11801
11801
|
/* @__PURE__ */ g("option", { value: "1", children: "S" }),
|
|
11802
11802
|
/* @__PURE__ */ g("option", { value: "3", children: "M" }),
|
|
11803
11803
|
/* @__PURE__ */ g("option", { value: "5", children: "L" })
|
|
11804
11804
|
] })
|
|
11805
|
-
] }),
|
|
11805
|
+
] }), R = () => /* @__PURE__ */ M("div", { ref: (N) => y.current[1] = N, className: "flex bg-white border border-gray-300 rounded overflow-hidden shrink-0", children: [
|
|
11806
11806
|
/* @__PURE__ */ g("button", { title: "Undo", onClick: n, disabled: !s, className: "p-1.5 hover:bg-gray-100 disabled:opacity-30 border-r border-gray-200", children: /* @__PURE__ */ g("svg", { className: "w-4 h-4 text-black", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ g("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M10 19l-7-7m0 0l7-7m-7 7h18" }) }) }),
|
|
11807
11807
|
/* @__PURE__ */ g("button", { title: "Redo", onClick: o, disabled: !l, className: "p-1.5 hover:bg-gray-100 disabled:opacity-30", children: /* @__PURE__ */ g("svg", { className: "w-4 h-4 text-black", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ g("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M14 5l7 7m0 0l-7 7m7-7H3" }) }) })
|
|
11808
|
-
] }),
|
|
11808
|
+
] }), w = () => /* @__PURE__ */ M("div", { ref: (N) => y.current[2] = N, className: "flex bg-white border border-gray-300 rounded overflow-hidden shrink-0", children: [
|
|
11809
11809
|
/* @__PURE__ */ g("button", { title: "Bold", onClick: () => e("bold"), className: "p-1.5 hover:bg-gray-100 border-r border-gray-200", children: /* @__PURE__ */ g("b", { className: "text-black", children: "B" }) }),
|
|
11810
11810
|
/* @__PURE__ */ g("button", { title: "Italic", onClick: () => e("italic"), className: "p-1.5 hover:bg-gray-100 border-r border-gray-200", children: /* @__PURE__ */ g("i", { className: "text-black", children: "I" }) }),
|
|
11811
11811
|
/* @__PURE__ */ g("button", { title: "Underline", onClick: () => e("underline"), className: "p-1.5 hover:bg-gray-100", children: /* @__PURE__ */ g("u", { className: "text-black", children: "U" }) })
|
|
11812
|
-
] }), U = () => /* @__PURE__ */
|
|
11813
|
-
/* @__PURE__ */
|
|
11812
|
+
] }), U = () => /* @__PURE__ */ M("div", { ref: (N) => y.current[3] = N, className: "flex bg-white border border-gray-300 rounded overflow-hidden shrink-0", children: [
|
|
11813
|
+
/* @__PURE__ */ M("label", { className: "p-2 hover:bg-slate-100 rounded-md cursor-pointer relative group", title: "Text Color", onMouseDown: (N) => N.preventDefault(), children: [
|
|
11814
11814
|
/* @__PURE__ */ g(Hc, { size: 18, className: "text-slate-600" }),
|
|
11815
|
-
/* @__PURE__ */ g("input", { type: "color", onInput: (
|
|
11815
|
+
/* @__PURE__ */ g("input", { type: "color", onInput: (N) => e("foreColor", N.target.value), className: "opacity-0 absolute inset-0 cursor-pointer" })
|
|
11816
11816
|
] }),
|
|
11817
|
-
/* @__PURE__ */
|
|
11817
|
+
/* @__PURE__ */ M("label", { className: "p-2 hover:bg-slate-100 rounded-md cursor-pointer relative group", title: "Highlight Color", onMouseDown: (N) => N.preventDefault(), children: [
|
|
11818
11818
|
/* @__PURE__ */ g(Nc, { size: 18, className: "text-slate-600" }),
|
|
11819
|
-
/* @__PURE__ */ g("input", { type: "color", onInput: (
|
|
11819
|
+
/* @__PURE__ */ g("input", { type: "color", onInput: (N) => e("backColor", N.target.value), className: "opacity-0 absolute inset-0 cursor-pointer" })
|
|
11820
11820
|
] })
|
|
11821
|
-
] }),
|
|
11821
|
+
] }), x = () => /* @__PURE__ */ M("div", { ref: (N) => y.current[4] = N, className: "flex bg-white border border-gray-300 rounded overflow-hidden shrink-0", children: [
|
|
11822
11822
|
/* @__PURE__ */ g("button", { title: "Ordered List", onClick: () => e("insertOrderedList"), className: "p-1.5 hover:bg-gray-100 border-r border-gray-200", children: /* @__PURE__ */ g(bc, { size: 18 }) }),
|
|
11823
11823
|
/* @__PURE__ */ g("button", { title: "Unordered List", onClick: () => e("insertUnorderedList"), className: "p-1.5 hover:bg-gray-100", children: /* @__PURE__ */ g(Fc, { size: 18 }) })
|
|
11824
|
-
] }), P = () => /* @__PURE__ */
|
|
11824
|
+
] }), P = () => /* @__PURE__ */ M("div", { ref: (N) => y.current[5] = N, className: "flex bg-white border border-gray-300 rounded overflow-hidden shrink-0", children: [
|
|
11825
11825
|
/* @__PURE__ */ g("button", { title: "Upload Image", onClick: () => {
|
|
11826
|
-
var
|
|
11827
|
-
return (
|
|
11826
|
+
var N;
|
|
11827
|
+
return (N = _.current) == null ? void 0 : N.click();
|
|
11828
11828
|
}, className: "p-1.5 hover:bg-gray-100 border-r border-gray-200", children: /* @__PURE__ */ g(Pc, { size: 18 }) }),
|
|
11829
11829
|
/* @__PURE__ */ g("button", { title: "Insert Table", onClick: () => c(!0), className: "p-1.5 hover:bg-gray-100", children: /* @__PURE__ */ g(Oc, { size: 18 }) })
|
|
11830
|
-
] }), L = () => /* @__PURE__ */ g("div", { ref: (
|
|
11830
|
+
] }), L = () => /* @__PURE__ */ g("div", { ref: (N) => y.current[6] = N, className: "shrink-0", children: /* @__PURE__ */ g("button", { title: "Handwriting Math Pad", onClick: t, onMouseDown: (N) => N.preventDefault(), className: "p-2 bg-blue-50 border border-blue-200 hover:bg-blue-100 text-blue-700 rounded flex items-center transition-colors shadow-sm", children: /* @__PURE__ */ M("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
11831
11831
|
/* @__PURE__ */ g("path", { d: "M3 12h2l4 8 4-16h6" }),
|
|
11832
11832
|
/* @__PURE__ */ g("path", { d: "m17 8 4 4" }),
|
|
11833
11833
|
/* @__PURE__ */ g("path", { d: "m21 8-4 4" })
|
|
11834
|
-
] }) }) }), k = (
|
|
11835
|
-
switch (
|
|
11834
|
+
] }) }) }), k = (N) => {
|
|
11835
|
+
switch (N) {
|
|
11836
11836
|
case "font":
|
|
11837
|
-
return /* @__PURE__ */ g(
|
|
11837
|
+
return /* @__PURE__ */ g(v, {}, "font");
|
|
11838
11838
|
case "history":
|
|
11839
|
-
return /* @__PURE__ */ g(
|
|
11839
|
+
return /* @__PURE__ */ g(R, {}, "history");
|
|
11840
11840
|
case "formatting":
|
|
11841
|
-
return /* @__PURE__ */ g(
|
|
11841
|
+
return /* @__PURE__ */ g(w, {}, "formatting");
|
|
11842
11842
|
case "colors":
|
|
11843
11843
|
return /* @__PURE__ */ g(U, {}, "colors");
|
|
11844
11844
|
case "lists":
|
|
11845
|
-
return /* @__PURE__ */ g(
|
|
11845
|
+
return /* @__PURE__ */ g(x, {}, "lists");
|
|
11846
11846
|
case "media":
|
|
11847
11847
|
return /* @__PURE__ */ g(P, {}, "media");
|
|
11848
11848
|
case "handwriting":
|
|
@@ -11850,20 +11850,20 @@ const Zc = [
|
|
|
11850
11850
|
default:
|
|
11851
11851
|
return null;
|
|
11852
11852
|
}
|
|
11853
|
-
}, b =
|
|
11854
|
-
return /* @__PURE__ */
|
|
11855
|
-
/* @__PURE__ */
|
|
11856
|
-
/* @__PURE__ */
|
|
11857
|
-
/* @__PURE__ */ g(
|
|
11858
|
-
/* @__PURE__ */ g(M, {}),
|
|
11853
|
+
}, b = E.slice(0, p), q = E.slice(p);
|
|
11854
|
+
return /* @__PURE__ */ M("div", { className: "relative", children: [
|
|
11855
|
+
/* @__PURE__ */ M("div", { ref: m, className: "bg-gray-50 p-2 flex items-center gap-3 border-b border-gray-200 rounded-t-lg flex-nowrap overflow-visible", children: [
|
|
11856
|
+
/* @__PURE__ */ M("div", { className: "absolute top-0 left-0 invisible pointer-events-none flex gap-3 whitespace-nowrap overflow-hidden", children: [
|
|
11857
|
+
/* @__PURE__ */ g(v, {}),
|
|
11859
11858
|
/* @__PURE__ */ g(R, {}),
|
|
11859
|
+
/* @__PURE__ */ g(w, {}),
|
|
11860
11860
|
/* @__PURE__ */ g(U, {}),
|
|
11861
|
-
/* @__PURE__ */ g(
|
|
11861
|
+
/* @__PURE__ */ g(x, {}),
|
|
11862
11862
|
/* @__PURE__ */ g(P, {}),
|
|
11863
11863
|
T && /* @__PURE__ */ g(L, {})
|
|
11864
11864
|
] }),
|
|
11865
|
-
/* @__PURE__ */ g("div", { className: "flex items-center gap-3 flex-nowrap overflow-hidden", children: b.map((
|
|
11866
|
-
q.length > 0 && /* @__PURE__ */
|
|
11865
|
+
/* @__PURE__ */ g("div", { className: "flex items-center gap-3 flex-nowrap overflow-hidden", children: b.map((N) => k(N.id)) }),
|
|
11866
|
+
q.length > 0 && /* @__PURE__ */ M("div", { className: "ml-auto relative shrink-0", children: [
|
|
11867
11867
|
/* @__PURE__ */ g(
|
|
11868
11868
|
"button",
|
|
11869
11869
|
{
|
|
@@ -11873,55 +11873,84 @@ const Zc = [
|
|
|
11873
11873
|
children: /* @__PURE__ */ g("svg", { className: "w-5 h-5 text-gray-600", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ g("path", { d: "M6 10a2 2 0 11-4 0 2 2 0 014 0zM12 10a2 2 0 11-4 0 2 2 0 014 0zM18 10a2 2 0 11-4 0 2 2 0 014 0z" }) })
|
|
11874
11874
|
}
|
|
11875
11875
|
),
|
|
11876
|
-
d && /* @__PURE__ */ g("div", { className: "absolute right-0 mt-2 bg-white border border-gray-200 shadow-2xl rounded-lg p-3 z-[100] flex flex-col gap-4 min-w-[200px] ring-1 ring-black ring-opacity-5", children: q.map((
|
|
11877
|
-
/* @__PURE__ */ g("span", { className: "text-[10px] font-bold text-gray-400 uppercase tracking-tighter", children:
|
|
11878
|
-
/* @__PURE__ */ g("div", { onClick: (G) => G.stopPropagation(), children: k(
|
|
11879
|
-
] },
|
|
11876
|
+
d && /* @__PURE__ */ g("div", { className: "absolute right-0 mt-2 bg-white border border-gray-200 shadow-2xl rounded-lg p-3 z-[100] flex flex-col gap-4 min-w-[200px] ring-1 ring-black ring-opacity-5", children: q.map((N) => /* @__PURE__ */ M("div", { className: "flex flex-col gap-1", children: [
|
|
11877
|
+
/* @__PURE__ */ g("span", { className: "text-[10px] font-bold text-gray-400 uppercase tracking-tighter", children: N.id }),
|
|
11878
|
+
/* @__PURE__ */ g("div", { onClick: (G) => G.stopPropagation(), children: k(N.id) })
|
|
11879
|
+
] }, N.id)) })
|
|
11880
11880
|
] })
|
|
11881
11881
|
] }),
|
|
11882
|
-
/* @__PURE__ */ g("input", { type: "file", ref:
|
|
11883
|
-
/* @__PURE__ */ g(tf, { isOpen: u, onClose: () => c(!1), onInsert:
|
|
11882
|
+
/* @__PURE__ */ g("input", { type: "file", ref: _, onChange: C, accept: "image/*", className: "hidden" }),
|
|
11883
|
+
/* @__PURE__ */ g(tf, { isOpen: u, onClose: () => c(!1), onInsert: S }),
|
|
11884
11884
|
d && /* @__PURE__ */ g("div", { className: "fixed inset-0 z-[90]", onClick: () => f(!1) })
|
|
11885
11885
|
] });
|
|
11886
11886
|
}, of = be(({ initialContent: t = "", onChange: e, apiKey: n }, o) => {
|
|
11887
|
-
const s = j(null), [l, a] = V(!1), [u, c] = V([t]), [d, f] = V(0), p = d > 0,
|
|
11888
|
-
if (
|
|
11889
|
-
const
|
|
11890
|
-
|
|
11891
|
-
}, [u, d, e])
|
|
11892
|
-
|
|
11887
|
+
const s = j(null), [l, a] = V(!1), [u, c] = V([t]), [d, f] = V(0), p = j(null), h = d > 0, m = d < u.length - 1, y = le((v) => {
|
|
11888
|
+
if (v === u[d]) return;
|
|
11889
|
+
const R = u.slice(0, d + 1);
|
|
11890
|
+
R.push(v), R.length > 50 && R.shift(), c(R), f(R.length - 1), e == null || e(v);
|
|
11891
|
+
}, [u, d, e]), _ = le(() => {
|
|
11892
|
+
var R;
|
|
11893
|
+
const v = window.getSelection();
|
|
11894
|
+
if (v && v.rangeCount > 0) {
|
|
11895
|
+
const w = v.getRangeAt(0);
|
|
11896
|
+
(R = s.current) != null && R.contains(w.commonAncestorContainer) && (p.current = w.cloneRange());
|
|
11897
|
+
}
|
|
11898
|
+
}, []), T = le(() => {
|
|
11899
|
+
if (p.current) {
|
|
11900
|
+
const v = window.getSelection();
|
|
11901
|
+
v && (v.removeAllRanges(), v.addRange(p.current));
|
|
11902
|
+
}
|
|
11903
|
+
}, []);
|
|
11904
|
+
io(o, () => ({
|
|
11893
11905
|
getContent: () => {
|
|
11894
|
-
var
|
|
11895
|
-
return ((
|
|
11906
|
+
var v;
|
|
11907
|
+
return ((v = s.current) == null ? void 0 : v.innerHTML) || "";
|
|
11896
11908
|
},
|
|
11897
|
-
setContent: (
|
|
11898
|
-
s.current && (s.current.innerHTML =
|
|
11909
|
+
setContent: (v) => {
|
|
11910
|
+
s.current && (s.current.innerHTML = v, y(v));
|
|
11911
|
+
}
|
|
11912
|
+
})), he(() => {
|
|
11913
|
+
s.current && (document.execCommand("defaultParagraphSeparator", !1, "p"), t && !s.current.innerHTML && (s.current.innerHTML = t));
|
|
11914
|
+
}, [t]);
|
|
11915
|
+
const I = (v, R) => {
|
|
11916
|
+
var w, U;
|
|
11917
|
+
(w = s.current) == null || w.focus(), T(), document.execCommand(v, !1, R), _(), y(((U = s.current) == null ? void 0 : U.innerHTML) || "");
|
|
11918
|
+
}, E = () => {
|
|
11919
|
+
if (h) {
|
|
11920
|
+
const v = d - 1;
|
|
11921
|
+
f(v), s.current && (s.current.innerHTML = u[v], e == null || e(u[v]));
|
|
11922
|
+
}
|
|
11923
|
+
}, C = () => {
|
|
11924
|
+
if (m) {
|
|
11925
|
+
const v = d + 1;
|
|
11926
|
+
f(v), s.current && (s.current.innerHTML = u[v], e == null || e(u[v]));
|
|
11927
|
+
}
|
|
11928
|
+
}, S = (v) => {
|
|
11929
|
+
var U, x, P;
|
|
11930
|
+
const R = window.getSelection();
|
|
11931
|
+
let w = p.current;
|
|
11932
|
+
if ((!w || !((U = s.current) != null && U.contains(w.commonAncestorContainer))) && (w = document.createRange(), w.selectNodeContents(s.current), w.collapse(!1)), R && w) {
|
|
11933
|
+
R.removeAllRanges(), R.addRange(w);
|
|
11934
|
+
const L = document.createElement("span");
|
|
11935
|
+
L.contentEditable = "false", L.className = "math-container inline-block mx-1 align-middle", L.innerHTML = v;
|
|
11936
|
+
const k = document.createTextNode(" ");
|
|
11937
|
+
w.deleteContents(), w.insertNode(k), w.insertNode(L);
|
|
11938
|
+
const b = document.createRange();
|
|
11939
|
+
b.setStartAfter(k), b.setEndAfter(k), R.removeAllRanges(), R.addRange(b), (x = s.current) == null || x.focus(), y(((P = s.current) == null ? void 0 : P.innerHTML) || ""), p.current = null;
|
|
11899
11940
|
}
|
|
11900
|
-
}
|
|
11901
|
-
|
|
11902
|
-
}, [t]), /* @__PURE__ */ N("div", { className: "w-full max-w-5xl bg-white shadow-xl border border-slate-200 flex flex-col transition-all duration-300", children: [
|
|
11941
|
+
};
|
|
11942
|
+
return /* @__PURE__ */ M("div", { className: "w-full max-w-5xl bg-white shadow-xl border border-slate-200 flex flex-col transition-all duration-300", children: [
|
|
11903
11943
|
/* @__PURE__ */ g("div", { className: "relative z-20", children: /* @__PURE__ */ g(
|
|
11904
11944
|
nf,
|
|
11905
11945
|
{
|
|
11906
|
-
onApplyStyle:
|
|
11907
|
-
|
|
11908
|
-
(
|
|
11909
|
-
},
|
|
11910
|
-
onOpenHandwritingModal: () => a(!0),
|
|
11911
|
-
onUndo: () => {
|
|
11912
|
-
if (p) {
|
|
11913
|
-
const E = d - 1;
|
|
11914
|
-
f(E), s.current && (s.current.innerHTML = u[E], e == null || e(u[E]));
|
|
11915
|
-
}
|
|
11916
|
-
},
|
|
11917
|
-
onRedo: () => {
|
|
11918
|
-
if (h) {
|
|
11919
|
-
const E = d + 1;
|
|
11920
|
-
f(E), s.current && (s.current.innerHTML = u[E], e == null || e(u[E]));
|
|
11921
|
-
}
|
|
11946
|
+
onApplyStyle: I,
|
|
11947
|
+
onOpenHandwritingModal: () => {
|
|
11948
|
+
_(), a(!0);
|
|
11922
11949
|
},
|
|
11923
|
-
|
|
11924
|
-
|
|
11950
|
+
onUndo: E,
|
|
11951
|
+
onRedo: C,
|
|
11952
|
+
canUndo: h,
|
|
11953
|
+
canRedo: m,
|
|
11925
11954
|
apiKey: n
|
|
11926
11955
|
}
|
|
11927
11956
|
) }),
|
|
@@ -11931,11 +11960,13 @@ const Zc = [
|
|
|
11931
11960
|
ref: s,
|
|
11932
11961
|
contentEditable: !0,
|
|
11933
11962
|
onInput: () => {
|
|
11934
|
-
var
|
|
11935
|
-
return
|
|
11963
|
+
var v;
|
|
11964
|
+
return y(((v = s.current) == null ? void 0 : v.innerHTML) || "");
|
|
11936
11965
|
},
|
|
11937
|
-
|
|
11938
|
-
|
|
11966
|
+
onKeyUp: _,
|
|
11967
|
+
onMouseUp: _,
|
|
11968
|
+
className: "flex-1 p-10 outline-none prose prose-slate prose-lg max-w-none prose-headings:font-bold prose-a:text-blue-600 prose-img:rounded-xl prose-table:border border-slate-100 bg-white",
|
|
11969
|
+
style: { minHeight: "600px", fontVariantLigatures: "common-ligatures" }
|
|
11939
11970
|
}
|
|
11940
11971
|
),
|
|
11941
11972
|
l && /* @__PURE__ */ g(
|
|
@@ -11943,9 +11974,8 @@ const Zc = [
|
|
|
11943
11974
|
{
|
|
11944
11975
|
isOpen: l,
|
|
11945
11976
|
onClose: () => a(!1),
|
|
11946
|
-
onInsert: (
|
|
11947
|
-
|
|
11948
|
-
(_ = s.current) == null || _.focus(), document.execCommand("insertHTML", !1, `<span contenteditable="false" class="mlx-formula-inline">${E}</span> `), m(((v = s.current) == null ? void 0 : v.innerHTML) || "");
|
|
11977
|
+
onInsert: (v) => {
|
|
11978
|
+
S(v);
|
|
11949
11979
|
},
|
|
11950
11980
|
apiKey: n
|
|
11951
11981
|
}
|