@nice2dev/ui-ai 1.0.5 → 1.0.8
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/NiceDataLabeler.d.ts +6 -0
- package/dist/NiceDataLabeler.d.ts.map +1 -0
- package/dist/NiceMLStudio.d.ts +6 -0
- package/dist/NiceMLStudio.d.ts.map +1 -0
- package/dist/NiceModelInference.d.ts +6 -0
- package/dist/NiceModelInference.d.ts.map +1 -0
- package/dist/index.cjs +15 -10
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +2298 -562
- package/dist/ml-types.d.ts +363 -0
- package/dist/ml-types.d.ts.map +1 -0
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useRef as
|
|
3
|
-
class
|
|
4
|
-
constructor(e = {},
|
|
1
|
+
import { jsx as t, jsxs as i, Fragment as ne } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as Q, useCallback as X, useMemo as B, useContext as ve, createContext as ye, useState as p, useEffect as Z, forwardRef as ce } from "react";
|
|
3
|
+
class Ne {
|
|
4
|
+
constructor(e = {}, a) {
|
|
5
5
|
this.timestamps = [], this.tokenCount = 0, this.warningEmitted = !1, this.config = {
|
|
6
6
|
maxRequestsPerMinute: e.maxRequestsPerMinute ?? 30,
|
|
7
7
|
maxTokensPerSession: e.maxTokensPerSession ?? 1e4,
|
|
8
8
|
warnThresholdPercent: e.warnThresholdPercent ?? 80
|
|
9
|
-
}, this.onWarning =
|
|
9
|
+
}, this.onWarning = a;
|
|
10
10
|
}
|
|
11
11
|
/** Check whether a new request is allowed. */
|
|
12
12
|
canRequest() {
|
|
@@ -23,12 +23,12 @@ class ee {
|
|
|
23
23
|
/** Get current rate limit status. */
|
|
24
24
|
getStatus() {
|
|
25
25
|
this.pruneOldTimestamps();
|
|
26
|
-
const e = this.config.maxTokensPerSession > 0 ? this.tokenCount / this.config.maxTokensPerSession * 100 : 0,
|
|
26
|
+
const e = this.config.maxTokensPerSession > 0 ? this.tokenCount / this.config.maxTokensPerSession * 100 : 0, a = this.config.maxRequestsPerMinute > 0 ? this.timestamps.length / this.config.maxRequestsPerMinute * 100 : 0;
|
|
27
27
|
return {
|
|
28
28
|
requestsThisMinute: this.timestamps.length,
|
|
29
29
|
tokensThisSession: this.tokenCount,
|
|
30
30
|
isLimited: !this.canRequest(),
|
|
31
|
-
isWarning: e >= this.config.warnThresholdPercent ||
|
|
31
|
+
isWarning: e >= this.config.warnThresholdPercent || a >= this.config.warnThresholdPercent
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
/** Reset all counters. */
|
|
@@ -37,105 +37,105 @@ class ee {
|
|
|
37
37
|
}
|
|
38
38
|
pruneOldTimestamps() {
|
|
39
39
|
const e = Date.now() - 6e4;
|
|
40
|
-
this.timestamps = this.timestamps.filter((
|
|
40
|
+
this.timestamps = this.timestamps.filter((a) => a > e);
|
|
41
41
|
}
|
|
42
42
|
checkWarning() {
|
|
43
|
-
var
|
|
43
|
+
var a;
|
|
44
44
|
if (this.warningEmitted) return;
|
|
45
|
-
this.getStatus().isWarning && (this.warningEmitted = !0, (
|
|
45
|
+
this.getStatus().isWarning && (this.warningEmitted = !0, (a = this.onWarning) == null || a.call(this));
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
const
|
|
49
|
-
function
|
|
50
|
-
config:
|
|
48
|
+
const de = ye(null);
|
|
49
|
+
function je({
|
|
50
|
+
config: n,
|
|
51
51
|
rateLimits: e,
|
|
52
|
-
enabled:
|
|
53
|
-
onRateLimitWarning:
|
|
54
|
-
children:
|
|
52
|
+
enabled: a = !0,
|
|
53
|
+
onRateLimitWarning: c,
|
|
54
|
+
children: d
|
|
55
55
|
}) {
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
const
|
|
56
|
+
const r = Q(null);
|
|
57
|
+
r.current || (r.current = new Ne(e, c));
|
|
58
|
+
const x = X(() => r.current.getStatus(), []), C = B(
|
|
59
59
|
() => ({
|
|
60
|
-
config:
|
|
61
|
-
enabled:
|
|
62
|
-
rateLimiter:
|
|
63
|
-
getRateLimitStatus:
|
|
60
|
+
config: n,
|
|
61
|
+
enabled: a,
|
|
62
|
+
rateLimiter: r.current,
|
|
63
|
+
getRateLimitStatus: x
|
|
64
64
|
}),
|
|
65
|
-
[
|
|
65
|
+
[n, a, x]
|
|
66
66
|
);
|
|
67
|
-
return /* @__PURE__ */
|
|
67
|
+
return /* @__PURE__ */ t(de.Provider, { value: C, children: d });
|
|
68
68
|
}
|
|
69
|
-
function
|
|
70
|
-
return
|
|
69
|
+
function oe() {
|
|
70
|
+
return ve(de);
|
|
71
71
|
}
|
|
72
|
-
async function*
|
|
73
|
-
var
|
|
74
|
-
const
|
|
75
|
-
if (!
|
|
72
|
+
async function* xe(n, e) {
|
|
73
|
+
var r, x, C, S, b, I, E, R, $;
|
|
74
|
+
const a = (r = n.body) == null ? void 0 : r.getReader();
|
|
75
|
+
if (!a)
|
|
76
76
|
throw new Error("Response body is not readable");
|
|
77
|
-
const
|
|
78
|
-
let
|
|
77
|
+
const c = new TextDecoder();
|
|
78
|
+
let d = "";
|
|
79
79
|
try {
|
|
80
80
|
for (; !(e != null && e.aborted); ) {
|
|
81
|
-
const { done:
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
const
|
|
81
|
+
const { done: O, value: N } = await a.read();
|
|
82
|
+
if (O) break;
|
|
83
|
+
d += c.decode(N, { stream: !0 });
|
|
84
|
+
const U = d.split(`
|
|
85
85
|
`);
|
|
86
|
-
|
|
87
|
-
for (const
|
|
88
|
-
const
|
|
89
|
-
if (!(!
|
|
90
|
-
if (
|
|
91
|
-
const f =
|
|
86
|
+
d = U.pop() ?? "";
|
|
87
|
+
for (const h of U) {
|
|
88
|
+
const v = h.trim();
|
|
89
|
+
if (!(!v || v === ":")) {
|
|
90
|
+
if (v.startsWith("data:")) {
|
|
91
|
+
const f = v.slice(5).trim();
|
|
92
92
|
if (f === "[DONE]") {
|
|
93
93
|
yield { token: "", done: !0 };
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
96
|
try {
|
|
97
|
-
const
|
|
98
|
-
(
|
|
97
|
+
const D = JSON.parse(f), L = ((S = (C = (x = D.choices) == null ? void 0 : x[0]) == null ? void 0 : C.delta) == null ? void 0 : S.content) ?? "", P = ((I = (b = D.choices) == null ? void 0 : b[0]) == null ? void 0 : I.finish_reason) === "stop";
|
|
98
|
+
(L || P) && (yield { token: L, done: P, usage: D.usage });
|
|
99
99
|
} catch {
|
|
100
100
|
f && (yield { token: f, done: !1 });
|
|
101
101
|
}
|
|
102
102
|
continue;
|
|
103
103
|
}
|
|
104
104
|
try {
|
|
105
|
-
const f = JSON.parse(
|
|
106
|
-
|
|
105
|
+
const f = JSON.parse(v), D = f.text ?? f.content ?? f.token ?? "";
|
|
106
|
+
D && (yield { token: D, done: !1 });
|
|
107
107
|
} catch {
|
|
108
|
-
|
|
108
|
+
v && (yield { token: v, done: !1 });
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
-
if (
|
|
114
|
-
const
|
|
115
|
-
if (
|
|
116
|
-
const
|
|
117
|
-
if (
|
|
113
|
+
if (d.trim()) {
|
|
114
|
+
const O = d.trim();
|
|
115
|
+
if (O.startsWith("data:")) {
|
|
116
|
+
const N = O.slice(5).trim();
|
|
117
|
+
if (N && N !== "[DONE]")
|
|
118
118
|
try {
|
|
119
|
-
const
|
|
120
|
-
|
|
119
|
+
const h = (($ = (R = (E = JSON.parse(N).choices) == null ? void 0 : E[0]) == null ? void 0 : R.delta) == null ? void 0 : $.content) ?? "";
|
|
120
|
+
h && (yield { token: h, done: !0 });
|
|
121
121
|
} catch {
|
|
122
|
-
yield { token:
|
|
122
|
+
yield { token: N, done: !0 };
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
} finally {
|
|
127
|
-
|
|
127
|
+
a.releaseLock();
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
-
async function
|
|
131
|
-
var
|
|
132
|
-
const e = await
|
|
133
|
-
if ((
|
|
130
|
+
async function pe(n) {
|
|
131
|
+
var a, c, d, r;
|
|
132
|
+
const e = await n.json();
|
|
133
|
+
if ((d = (c = (a = e.choices) == null ? void 0 : a[0]) == null ? void 0 : c.message) != null && d.content)
|
|
134
134
|
return {
|
|
135
135
|
text: e.choices[0].message.content,
|
|
136
136
|
usage: e.usage
|
|
137
137
|
};
|
|
138
|
-
if ((
|
|
138
|
+
if ((r = e.message) != null && r.content)
|
|
139
139
|
return { text: e.message.content };
|
|
140
140
|
if (typeof e.text == "string")
|
|
141
141
|
return { text: e.text };
|
|
@@ -145,116 +145,116 @@ async function re(r) {
|
|
|
145
145
|
return { text: e.response };
|
|
146
146
|
throw new Error("Unrecognized AI response format");
|
|
147
147
|
}
|
|
148
|
-
const
|
|
149
|
-
function
|
|
150
|
-
const
|
|
151
|
-
return JSON.stringify(
|
|
148
|
+
const ae = /* @__PURE__ */ new Map();
|
|
149
|
+
function ie(n, e) {
|
|
150
|
+
const a = e ? { ...n, fieldValue: void 0, formContext: void 0 } : n;
|
|
151
|
+
return JSON.stringify(a);
|
|
152
152
|
}
|
|
153
|
-
function
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
const
|
|
157
|
-
if (
|
|
158
|
-
const
|
|
159
|
-
|
|
153
|
+
function Ce(n, e) {
|
|
154
|
+
const a = [], c = e.systemPrompt ?? "You are a helpful assistant providing concise contextual hints for form fields. Keep responses short (1-3 sentences). Be specific and actionable.";
|
|
155
|
+
a.push({ role: "system", content: c });
|
|
156
|
+
const d = [];
|
|
157
|
+
if (n.fieldLabel && d.push(`Field: "${n.fieldLabel}"`), n.fieldType && d.push(`Type: ${n.fieldType}`), !e.privacyMode && n.fieldValue !== void 0) {
|
|
158
|
+
const x = typeof n.fieldValue == "string" ? n.fieldValue : JSON.stringify(n.fieldValue);
|
|
159
|
+
d.push(`Current value: ${x}`);
|
|
160
160
|
}
|
|
161
|
-
|
|
162
|
-
const
|
|
163
|
-
${
|
|
161
|
+
n.validationRules && Object.keys(n.validationRules).length > 0 && d.push(`Validation: ${JSON.stringify(n.validationRules)}`), n.schema && Object.keys(n.schema).length > 0 && d.push(`Schema: ${JSON.stringify(n.schema)}`), !e.privacyMode && n.formContext && Object.keys(n.formContext).length > 0 && d.push(`Form context: ${JSON.stringify(n.formContext)}`), n.customPrompt && d.push(n.customPrompt);
|
|
162
|
+
const r = d.length > 0 ? `Provide a helpful hint for this field:
|
|
163
|
+
${d.join(`
|
|
164
164
|
`)}` : "Provide a helpful suggestion.";
|
|
165
|
-
return
|
|
165
|
+
return a.push({ role: "user", content: r }), a;
|
|
166
166
|
}
|
|
167
|
-
function
|
|
168
|
-
|
|
169
|
-
const { debounceMs:
|
|
170
|
-
var
|
|
171
|
-
if (!
|
|
172
|
-
const { config:
|
|
167
|
+
function F(n = {}, e = {}) {
|
|
168
|
+
n = n ?? {}, e = e ?? {};
|
|
169
|
+
const { debounceMs: a = 500, disabled: c = !1 } = e, d = oe(), [r, x] = p(""), [C, S] = p(!1), [b, I] = p(null), [E, R] = p(!1), $ = Q(null), O = Q(0), N = X(async () => {
|
|
170
|
+
var V, G, y;
|
|
171
|
+
if (!d || !d.enabled || c) return;
|
|
172
|
+
const { config: v, rateLimiter: f } = d;
|
|
173
173
|
if (!f.recordRequest()) {
|
|
174
|
-
|
|
174
|
+
I("Rate limit exceeded. Please wait before requesting another hint.");
|
|
175
175
|
return;
|
|
176
176
|
}
|
|
177
|
-
const
|
|
178
|
-
if (
|
|
179
|
-
|
|
177
|
+
const D = ie(n, v.privacyMode ?? !1), L = ae.get(D);
|
|
178
|
+
if (L) {
|
|
179
|
+
x(L), S(!1), I(null), R(!1);
|
|
180
180
|
return;
|
|
181
181
|
}
|
|
182
|
-
(
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
const
|
|
182
|
+
(V = $.current) == null || V.abort();
|
|
183
|
+
const P = new AbortController();
|
|
184
|
+
$.current = P, S(!0), I(null), x(""), R(!1);
|
|
185
|
+
const j = Ce(n, v), _ = v.stream !== !1;
|
|
186
186
|
try {
|
|
187
|
-
const
|
|
187
|
+
const l = {
|
|
188
188
|
"Content-Type": "application/json",
|
|
189
|
-
...
|
|
189
|
+
...v.headers
|
|
190
190
|
};
|
|
191
|
-
|
|
192
|
-
const
|
|
193
|
-
model:
|
|
194
|
-
messages:
|
|
195
|
-
temperature:
|
|
196
|
-
max_tokens:
|
|
197
|
-
stream:
|
|
198
|
-
}),
|
|
191
|
+
v.apiKey && (l.Authorization = `Bearer ${v.apiKey}`);
|
|
192
|
+
const m = JSON.stringify({
|
|
193
|
+
model: v.model ?? "gpt-3.5-turbo",
|
|
194
|
+
messages: j,
|
|
195
|
+
temperature: v.temperature ?? 0.7,
|
|
196
|
+
max_tokens: v.maxTokens ?? 256,
|
|
197
|
+
stream: _
|
|
198
|
+
}), T = await fetch(v.endpoint, {
|
|
199
199
|
method: "POST",
|
|
200
|
-
headers:
|
|
201
|
-
body:
|
|
202
|
-
signal:
|
|
200
|
+
headers: l,
|
|
201
|
+
body: m,
|
|
202
|
+
signal: P.signal
|
|
203
203
|
});
|
|
204
|
-
if (!
|
|
205
|
-
const
|
|
206
|
-
throw new Error(`AI request failed (${
|
|
204
|
+
if (!T.ok) {
|
|
205
|
+
const w = await T.text().catch(() => T.statusText);
|
|
206
|
+
throw new Error(`AI request failed (${T.status}): ${w}`);
|
|
207
207
|
}
|
|
208
|
-
if (
|
|
209
|
-
|
|
210
|
-
let
|
|
211
|
-
for await (const
|
|
212
|
-
if (
|
|
213
|
-
if (
|
|
214
|
-
const
|
|
215
|
-
f.recordTokens(
|
|
208
|
+
if (_) {
|
|
209
|
+
R(!0);
|
|
210
|
+
let w = "";
|
|
211
|
+
for await (const z of xe(T, P.signal))
|
|
212
|
+
if (P.signal.aborted || (w += z.token, x(w), (G = z.usage) != null && G.completion_tokens && f.recordTokens(z.usage.completion_tokens), z.done)) break;
|
|
213
|
+
if (w.length > 0) {
|
|
214
|
+
const z = Math.ceil(w.length / 4);
|
|
215
|
+
f.recordTokens(z);
|
|
216
216
|
}
|
|
217
|
-
|
|
217
|
+
ae.set(D, w);
|
|
218
218
|
} else {
|
|
219
|
-
const
|
|
220
|
-
|
|
219
|
+
const w = await pe(T);
|
|
220
|
+
x(w.text), ae.set(D, w.text), (y = w.usage) != null && y.completion_tokens ? f.recordTokens(w.usage.completion_tokens) : f.recordTokens(Math.ceil(w.text.length / 4));
|
|
221
221
|
}
|
|
222
|
-
} catch (
|
|
223
|
-
if (
|
|
224
|
-
|
|
222
|
+
} catch (l) {
|
|
223
|
+
if (l instanceof DOMException && l.name === "AbortError") return;
|
|
224
|
+
I(l instanceof Error ? l.message : "AI hint request failed");
|
|
225
225
|
} finally {
|
|
226
|
-
|
|
226
|
+
P.signal.aborted || (S(!1), R(!1));
|
|
227
227
|
}
|
|
228
|
-
}, [
|
|
229
|
-
|
|
230
|
-
if (!
|
|
231
|
-
const
|
|
232
|
-
return () => clearTimeout(
|
|
228
|
+
}, [d, n, c]);
|
|
229
|
+
Z(() => {
|
|
230
|
+
if (!d || !d.enabled || c) return;
|
|
231
|
+
const v = setTimeout(N, a);
|
|
232
|
+
return () => clearTimeout(v);
|
|
233
233
|
}, [
|
|
234
234
|
// Only re-trigger on meaningful context changes
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
]),
|
|
244
|
-
var
|
|
245
|
-
(
|
|
235
|
+
n == null ? void 0 : n.fieldLabel,
|
|
236
|
+
n == null ? void 0 : n.fieldType,
|
|
237
|
+
n == null ? void 0 : n.fieldValue,
|
|
238
|
+
n == null ? void 0 : n.customPrompt,
|
|
239
|
+
a,
|
|
240
|
+
c,
|
|
241
|
+
d == null ? void 0 : d.enabled,
|
|
242
|
+
O.current
|
|
243
|
+
]), Z(() => () => {
|
|
244
|
+
var v;
|
|
245
|
+
(v = $.current) == null || v.abort();
|
|
246
246
|
}, []);
|
|
247
|
-
const
|
|
248
|
-
var
|
|
249
|
-
(
|
|
250
|
-
}, []),
|
|
251
|
-
if (
|
|
252
|
-
const
|
|
253
|
-
|
|
247
|
+
const U = X(() => {
|
|
248
|
+
var v;
|
|
249
|
+
(v = $.current) == null || v.abort(), S(!1), R(!1);
|
|
250
|
+
}, []), h = X(() => {
|
|
251
|
+
if (d) {
|
|
252
|
+
const v = ie(n, d.config.privacyMode ?? !1);
|
|
253
|
+
ae.delete(v);
|
|
254
254
|
}
|
|
255
|
-
|
|
256
|
-
}, [
|
|
257
|
-
return !
|
|
255
|
+
O.current += 1, N();
|
|
256
|
+
}, [d, n, N]);
|
|
257
|
+
return !d || !d.enabled ? {
|
|
258
258
|
text: "",
|
|
259
259
|
loading: !1,
|
|
260
260
|
error: null,
|
|
@@ -266,12 +266,12 @@ function g(r = {}, e = {}) {
|
|
|
266
266
|
hint: null,
|
|
267
267
|
fetchHint: async () => {
|
|
268
268
|
}
|
|
269
|
-
} : { text:
|
|
270
|
-
await
|
|
269
|
+
} : { text: r, loading: C, error: b, streaming: E, abort: U, refresh: h, hint: r ? { content: r } : null, fetchHint: async () => {
|
|
270
|
+
await N();
|
|
271
271
|
} };
|
|
272
272
|
}
|
|
273
|
-
function
|
|
274
|
-
return /* @__PURE__ */
|
|
273
|
+
function Se() {
|
|
274
|
+
return /* @__PURE__ */ i(
|
|
275
275
|
"svg",
|
|
276
276
|
{
|
|
277
277
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -285,19 +285,19 @@ function te() {
|
|
|
285
285
|
strokeLinejoin: "round",
|
|
286
286
|
"aria-hidden": !0,
|
|
287
287
|
children: [
|
|
288
|
-
/* @__PURE__ */
|
|
289
|
-
/* @__PURE__ */
|
|
290
|
-
/* @__PURE__ */
|
|
288
|
+
/* @__PURE__ */ t("path", { d: "M12 3l1.5 5.5L19 10l-5.5 1.5L12 17l-1.5-5.5L5 10l5.5-1.5z" }),
|
|
289
|
+
/* @__PURE__ */ t("path", { d: "M19 15l.5 2 2 .5-2 .5-.5 2-.5-2-2-.5 2-.5z" }),
|
|
290
|
+
/* @__PURE__ */ t("path", { d: "M5 19l.5 1.5 1.5.5-1.5.5-.5 1.5-.5-1.5-1.5-.5 1.5-.5z" })
|
|
291
291
|
]
|
|
292
292
|
}
|
|
293
293
|
);
|
|
294
294
|
}
|
|
295
|
-
function
|
|
296
|
-
if (
|
|
297
|
-
const
|
|
298
|
-
return
|
|
295
|
+
function we(n, e) {
|
|
296
|
+
if (n !== "auto" || !e) return n === "auto" ? "top" : n;
|
|
297
|
+
const a = e.top, c = window.innerHeight - e.bottom, d = e.left, r = window.innerWidth - e.right, x = Math.max(a, c, d, r);
|
|
298
|
+
return x === a ? "top" : x === c ? "bottom" : x === r ? "right" : "left";
|
|
299
299
|
}
|
|
300
|
-
function
|
|
300
|
+
function ke(n) {
|
|
301
301
|
const e = {
|
|
302
302
|
position: "absolute",
|
|
303
303
|
zIndex: 9999,
|
|
@@ -313,7 +313,7 @@ function le(r) {
|
|
|
313
313
|
boxShadow: "0 4px 16px rgba(0,0,0,0.25)",
|
|
314
314
|
wordWrap: "break-word"
|
|
315
315
|
};
|
|
316
|
-
switch (
|
|
316
|
+
switch (n) {
|
|
317
317
|
case "top":
|
|
318
318
|
return { ...e, bottom: "100%", left: "50%", transform: "translateX(-50%)", marginBottom: 6 };
|
|
319
319
|
case "bottom":
|
|
@@ -326,74 +326,74 @@ function le(r) {
|
|
|
326
326
|
return { ...e, bottom: "100%", left: "50%", transform: "translateX(-50%)", marginBottom: 6 };
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
|
-
const
|
|
329
|
+
const ue = ce(
|
|
330
330
|
({
|
|
331
|
-
context:
|
|
331
|
+
context: n,
|
|
332
332
|
position: e = "auto",
|
|
333
|
-
debounceMs:
|
|
334
|
-
showOnHover:
|
|
335
|
-
triggerIcon:
|
|
336
|
-
className:
|
|
337
|
-
style:
|
|
338
|
-
},
|
|
339
|
-
var
|
|
340
|
-
const
|
|
341
|
-
debounceMs:
|
|
342
|
-
disabled: !
|
|
333
|
+
debounceMs: a = 500,
|
|
334
|
+
showOnHover: c = !1,
|
|
335
|
+
triggerIcon: d,
|
|
336
|
+
className: r,
|
|
337
|
+
style: x
|
|
338
|
+
}, C) => {
|
|
339
|
+
var D;
|
|
340
|
+
const S = oe(), [b, I] = p(!1), [E, R] = p(!1), $ = Q(null), O = Q(null), N = F(n, {
|
|
341
|
+
debounceMs: a,
|
|
342
|
+
disabled: !E
|
|
343
343
|
});
|
|
344
|
-
|
|
345
|
-
if (!
|
|
346
|
-
const
|
|
347
|
-
var
|
|
348
|
-
const
|
|
349
|
-
(
|
|
344
|
+
Z(() => {
|
|
345
|
+
if (!b) return;
|
|
346
|
+
const L = (P) => {
|
|
347
|
+
var _, V;
|
|
348
|
+
const j = P.target;
|
|
349
|
+
(_ = $.current) != null && _.contains(j) || (V = O.current) != null && V.contains(j) || (I(!1), R(!1));
|
|
350
350
|
};
|
|
351
|
-
return document.addEventListener("mousedown",
|
|
352
|
-
}, [
|
|
353
|
-
if (!
|
|
354
|
-
const
|
|
355
|
-
|
|
351
|
+
return document.addEventListener("mousedown", L), () => document.removeEventListener("mousedown", L);
|
|
352
|
+
}, [b]), Z(() => {
|
|
353
|
+
if (!b) return;
|
|
354
|
+
const L = (P) => {
|
|
355
|
+
P.key === "Escape" && (I(!1), R(!1), N.abort());
|
|
356
356
|
};
|
|
357
|
-
return document.addEventListener("keydown",
|
|
358
|
-
}, [
|
|
359
|
-
const
|
|
360
|
-
(
|
|
361
|
-
if (
|
|
362
|
-
const
|
|
363
|
-
|
|
357
|
+
return document.addEventListener("keydown", L), () => document.removeEventListener("keydown", L);
|
|
358
|
+
}, [b, N]);
|
|
359
|
+
const U = X(
|
|
360
|
+
(L) => {
|
|
361
|
+
if (L.stopPropagation(), c) return;
|
|
362
|
+
const P = !b;
|
|
363
|
+
I(P), R(P);
|
|
364
364
|
},
|
|
365
|
-
[
|
|
366
|
-
),
|
|
367
|
-
|
|
368
|
-
}, [
|
|
369
|
-
|
|
370
|
-
}, [
|
|
371
|
-
if (!
|
|
372
|
-
const f =
|
|
365
|
+
[b, c]
|
|
366
|
+
), h = X(() => {
|
|
367
|
+
c && (I(!0), R(!0));
|
|
368
|
+
}, [c]), v = X(() => {
|
|
369
|
+
c && (I(!1), R(!1));
|
|
370
|
+
}, [c]);
|
|
371
|
+
if (!S || !S.enabled) return null;
|
|
372
|
+
const f = we(
|
|
373
373
|
e,
|
|
374
|
-
((
|
|
374
|
+
((D = $.current) == null ? void 0 : D.getBoundingClientRect()) ?? null
|
|
375
375
|
);
|
|
376
|
-
return /* @__PURE__ */
|
|
376
|
+
return /* @__PURE__ */ i(
|
|
377
377
|
"span",
|
|
378
378
|
{
|
|
379
|
-
ref:
|
|
380
|
-
className:
|
|
379
|
+
ref: C,
|
|
380
|
+
className: r,
|
|
381
381
|
style: {
|
|
382
382
|
position: "relative",
|
|
383
383
|
display: "inline-flex",
|
|
384
|
-
...
|
|
384
|
+
...x
|
|
385
385
|
},
|
|
386
|
-
onMouseEnter:
|
|
387
|
-
onMouseLeave:
|
|
386
|
+
onMouseEnter: h,
|
|
387
|
+
onMouseLeave: v,
|
|
388
388
|
children: [
|
|
389
|
-
/* @__PURE__ */
|
|
389
|
+
/* @__PURE__ */ t(
|
|
390
390
|
"button",
|
|
391
391
|
{
|
|
392
|
-
ref:
|
|
392
|
+
ref: $,
|
|
393
393
|
type: "button",
|
|
394
|
-
onClick:
|
|
394
|
+
onClick: U,
|
|
395
395
|
"aria-label": "AI hint",
|
|
396
|
-
"aria-expanded":
|
|
396
|
+
"aria-expanded": b,
|
|
397
397
|
className: "ntd-ai-trigger",
|
|
398
398
|
style: {
|
|
399
399
|
display: "inline-flex",
|
|
@@ -408,19 +408,19 @@ const G = j(
|
|
|
408
408
|
opacity: 0.7,
|
|
409
409
|
transition: "opacity 0.2s, transform 0.2s"
|
|
410
410
|
},
|
|
411
|
-
children:
|
|
411
|
+
children: d ?? /* @__PURE__ */ t(Se, {})
|
|
412
412
|
}
|
|
413
413
|
),
|
|
414
|
-
|
|
414
|
+
b && /* @__PURE__ */ i(
|
|
415
415
|
"div",
|
|
416
416
|
{
|
|
417
|
-
ref:
|
|
417
|
+
ref: O,
|
|
418
418
|
role: "tooltip",
|
|
419
419
|
className: "ntd-ai-popover",
|
|
420
|
-
style:
|
|
420
|
+
style: ke(f),
|
|
421
421
|
children: [
|
|
422
|
-
|
|
423
|
-
/* @__PURE__ */
|
|
422
|
+
N.loading && !N.text && /* @__PURE__ */ i("div", { className: "ntd-ai-loading", style: { display: "flex", alignItems: "center", gap: 6 }, children: [
|
|
423
|
+
/* @__PURE__ */ t(
|
|
424
424
|
"span",
|
|
425
425
|
{
|
|
426
426
|
style: {
|
|
@@ -434,11 +434,11 @@ const G = j(
|
|
|
434
434
|
}
|
|
435
435
|
}
|
|
436
436
|
),
|
|
437
|
-
/* @__PURE__ */
|
|
437
|
+
/* @__PURE__ */ t("span", { style: { opacity: 0.6 }, children: "Thinking..." })
|
|
438
438
|
] }),
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
439
|
+
N.text && /* @__PURE__ */ i("div", { className: "ntd-ai-content", children: [
|
|
440
|
+
N.text,
|
|
441
|
+
N.streaming && /* @__PURE__ */ t(
|
|
442
442
|
"span",
|
|
443
443
|
{
|
|
444
444
|
className: "ntd-ai-cursor",
|
|
@@ -454,8 +454,8 @@ const G = j(
|
|
|
454
454
|
}
|
|
455
455
|
)
|
|
456
456
|
] }),
|
|
457
|
-
|
|
458
|
-
|
|
457
|
+
N.error && /* @__PURE__ */ t("div", { className: "ntd-ai-error", style: { color: "var(--ntd-ai-error, #f38ba8)" }, children: N.error }),
|
|
458
|
+
N.text && !N.streaming && /* @__PURE__ */ i(
|
|
459
459
|
"div",
|
|
460
460
|
{
|
|
461
461
|
style: {
|
|
@@ -467,11 +467,11 @@ const G = j(
|
|
|
467
467
|
borderTop: "1px solid var(--ntd-ai-border, #45475a)"
|
|
468
468
|
},
|
|
469
469
|
children: [
|
|
470
|
-
/* @__PURE__ */
|
|
470
|
+
/* @__PURE__ */ t(
|
|
471
471
|
"button",
|
|
472
472
|
{
|
|
473
473
|
type: "button",
|
|
474
|
-
onClick: () =>
|
|
474
|
+
onClick: () => N.refresh(),
|
|
475
475
|
className: "ntd-ai-action",
|
|
476
476
|
style: {
|
|
477
477
|
fontSize: 11,
|
|
@@ -485,13 +485,13 @@ const G = j(
|
|
|
485
485
|
children: "↻ Refresh"
|
|
486
486
|
}
|
|
487
487
|
),
|
|
488
|
-
/* @__PURE__ */
|
|
488
|
+
/* @__PURE__ */ t(
|
|
489
489
|
"button",
|
|
490
490
|
{
|
|
491
491
|
type: "button",
|
|
492
492
|
onClick: () => {
|
|
493
|
-
var
|
|
494
|
-
(
|
|
493
|
+
var L;
|
|
494
|
+
(L = navigator.clipboard) == null || L.writeText(N.text);
|
|
495
495
|
},
|
|
496
496
|
className: "ntd-ai-action",
|
|
497
497
|
style: {
|
|
@@ -517,67 +517,67 @@ const G = j(
|
|
|
517
517
|
);
|
|
518
518
|
}
|
|
519
519
|
);
|
|
520
|
-
|
|
521
|
-
function
|
|
520
|
+
ue.displayName = "NiceAIHintBubble";
|
|
521
|
+
function me(n, e, a) {
|
|
522
522
|
return {
|
|
523
|
-
fieldLabel:
|
|
523
|
+
fieldLabel: n,
|
|
524
524
|
fieldType: "text",
|
|
525
525
|
fieldValue: e,
|
|
526
526
|
validationRules: {
|
|
527
|
-
...(
|
|
528
|
-
...
|
|
527
|
+
...(a == null ? void 0 : a.maxLength) != null ? { maxLength: a.maxLength } : {},
|
|
528
|
+
...a != null && a.pattern ? { pattern: a.pattern } : {}
|
|
529
529
|
},
|
|
530
|
-
customPrompt:
|
|
530
|
+
customPrompt: a != null && a.placeholder ? `Placeholder: "${a.placeholder}". Suggest content or correct grammar.` : "Suggest content, correct grammar, or auto-complete the text."
|
|
531
531
|
};
|
|
532
532
|
}
|
|
533
|
-
function
|
|
533
|
+
function he(n, e, a) {
|
|
534
534
|
return {
|
|
535
|
-
fieldLabel:
|
|
535
|
+
fieldLabel: n,
|
|
536
536
|
fieldType: "number",
|
|
537
537
|
fieldValue: e,
|
|
538
538
|
validationRules: {
|
|
539
|
-
...(
|
|
540
|
-
...(
|
|
541
|
-
...(
|
|
539
|
+
...(a == null ? void 0 : a.min) != null ? { min: a.min } : {},
|
|
540
|
+
...(a == null ? void 0 : a.max) != null ? { max: a.max } : {},
|
|
541
|
+
...(a == null ? void 0 : a.step) != null ? { step: a.step } : {}
|
|
542
542
|
},
|
|
543
|
-
customPrompt:
|
|
543
|
+
customPrompt: a != null && a.unit ? `Unit: ${a.unit}. Suggest a reasonable value or range for this field.` : "Suggest a reasonable value or range for this field based on the label and constraints."
|
|
544
544
|
};
|
|
545
545
|
}
|
|
546
|
-
function
|
|
546
|
+
function ge(n, e, a) {
|
|
547
547
|
return {
|
|
548
|
-
fieldLabel:
|
|
549
|
-
fieldType:
|
|
548
|
+
fieldLabel: n,
|
|
549
|
+
fieldType: a != null && a.multiple ? "multi-select" : "select",
|
|
550
550
|
fieldValue: e,
|
|
551
|
-
schema:
|
|
551
|
+
schema: a != null && a.options ? { availableOptions: a.options.slice(0, 20).map((c) => c.label) } : {},
|
|
552
552
|
customPrompt: "Suggest the most likely selection. Explain why this option is recommended."
|
|
553
553
|
};
|
|
554
554
|
}
|
|
555
|
-
function
|
|
556
|
-
const
|
|
555
|
+
function fe(n, e, a) {
|
|
556
|
+
const c = e instanceof Date ? e.toISOString().split("T")[0] : e;
|
|
557
557
|
return {
|
|
558
|
-
fieldLabel:
|
|
558
|
+
fieldLabel: n,
|
|
559
559
|
fieldType: "date",
|
|
560
|
-
fieldValue:
|
|
560
|
+
fieldValue: c,
|
|
561
561
|
validationRules: {
|
|
562
|
-
...
|
|
563
|
-
...
|
|
564
|
-
...
|
|
562
|
+
...a != null && a.min ? { min: a.min } : {},
|
|
563
|
+
...a != null && a.max ? { max: a.max } : {},
|
|
564
|
+
...a != null && a.disableWeekends ? { noWeekends: !0 } : {}
|
|
565
565
|
},
|
|
566
566
|
customPrompt: 'Suggest a date. For example: "next business day", "end of month", "in 2 weeks". Explain your suggestion briefly.'
|
|
567
567
|
};
|
|
568
568
|
}
|
|
569
|
-
function
|
|
569
|
+
function be(n, e, a) {
|
|
570
570
|
return {
|
|
571
|
-
fieldLabel:
|
|
571
|
+
fieldLabel: n,
|
|
572
572
|
fieldType: "color",
|
|
573
573
|
fieldValue: e,
|
|
574
|
-
schema:
|
|
575
|
-
customPrompt:
|
|
574
|
+
schema: a != null && a.palette ? { currentPalette: a.palette } : {},
|
|
575
|
+
customPrompt: a != null && a.industry ? `Industry: ${a.industry}. Suggest a color palette (3-5 hex colors) suitable for this context.` : "Suggest a color or palette of colors that works well for this context. Provide hex values."
|
|
576
576
|
};
|
|
577
577
|
}
|
|
578
|
-
function
|
|
578
|
+
function _e(n, e) {
|
|
579
579
|
return {
|
|
580
|
-
fieldLabel:
|
|
580
|
+
fieldLabel: n,
|
|
581
581
|
fieldType: "data-grid",
|
|
582
582
|
schema: {
|
|
583
583
|
...e != null && e.columns ? { columns: e.columns } : {},
|
|
@@ -590,9 +590,9 @@ function ve(r, e) {
|
|
|
590
590
|
customPrompt: "Suggest column configuration, useful filters, or highlight potential data anomalies."
|
|
591
591
|
};
|
|
592
592
|
}
|
|
593
|
-
function
|
|
593
|
+
function Ve(n, e) {
|
|
594
594
|
return {
|
|
595
|
-
fieldLabel:
|
|
595
|
+
fieldLabel: n,
|
|
596
596
|
fieldType: "chart",
|
|
597
597
|
schema: {
|
|
598
598
|
...e != null && e.currentType ? { chartType: e.currentType } : {},
|
|
@@ -602,338 +602,338 @@ function we(r, e) {
|
|
|
602
602
|
customPrompt: e != null && e.dataDescription ? `Data: ${e.dataDescription}. Suggest the best chart type and labeling strategy.` : "Suggest the most effective chart type for this data. Explain your recommendation."
|
|
603
603
|
};
|
|
604
604
|
}
|
|
605
|
-
function
|
|
605
|
+
function Te(n, e) {
|
|
606
606
|
return {
|
|
607
607
|
fieldLabel: "Form auto-fill",
|
|
608
608
|
fieldType: "form",
|
|
609
609
|
schema: { fields: e },
|
|
610
|
-
customPrompt: `User description: "${
|
|
611
|
-
Parse this description and return suggested values for each field as JSON: { ${e.map((
|
|
610
|
+
customPrompt: `User description: "${n}"
|
|
611
|
+
Parse this description and return suggested values for each field as JSON: { ${e.map((a) => `"${a.label}": "value"`).join(", ")} }`
|
|
612
612
|
};
|
|
613
613
|
}
|
|
614
|
-
function
|
|
614
|
+
function $e(n, e, a, c, d) {
|
|
615
615
|
return {
|
|
616
|
-
fieldLabel:
|
|
616
|
+
fieldLabel: n,
|
|
617
617
|
fieldType: e,
|
|
618
|
-
fieldValue:
|
|
619
|
-
validationRules:
|
|
620
|
-
customPrompt: `Current validation error: "${
|
|
618
|
+
fieldValue: a,
|
|
619
|
+
validationRules: d == null ? void 0 : d.rules,
|
|
620
|
+
customPrompt: `Current validation error: "${c}". Provide a friendly, specific error message with an example of a valid value. Do NOT say "field is required" — instead explain what the user should enter.`
|
|
621
621
|
};
|
|
622
622
|
}
|
|
623
|
-
function
|
|
624
|
-
const
|
|
625
|
-
() =>
|
|
626
|
-
[
|
|
623
|
+
function He(n, e, a) {
|
|
624
|
+
const c = B(
|
|
625
|
+
() => me(n, e, a),
|
|
626
|
+
[n, e, a == null ? void 0 : a.placeholder, a == null ? void 0 : a.maxLength, a == null ? void 0 : a.pattern]
|
|
627
627
|
);
|
|
628
|
-
return
|
|
628
|
+
return F(c, a);
|
|
629
629
|
}
|
|
630
|
-
function
|
|
631
|
-
const
|
|
632
|
-
() =>
|
|
633
|
-
[
|
|
630
|
+
function Ke(n, e, a) {
|
|
631
|
+
const c = B(
|
|
632
|
+
() => he(n, e, a),
|
|
633
|
+
[n, e, a == null ? void 0 : a.min, a == null ? void 0 : a.max, a == null ? void 0 : a.step, a == null ? void 0 : a.unit]
|
|
634
634
|
);
|
|
635
|
-
return
|
|
635
|
+
return F(c, a);
|
|
636
636
|
}
|
|
637
|
-
function
|
|
638
|
-
const
|
|
639
|
-
() =>
|
|
640
|
-
[
|
|
637
|
+
function Ge(n, e, a) {
|
|
638
|
+
const c = B(
|
|
639
|
+
() => ge(n, e, a),
|
|
640
|
+
[n, e, a == null ? void 0 : a.multiple]
|
|
641
641
|
);
|
|
642
|
-
return
|
|
642
|
+
return F(c, a);
|
|
643
643
|
}
|
|
644
|
-
function
|
|
645
|
-
const
|
|
646
|
-
() =>
|
|
647
|
-
[
|
|
644
|
+
function We(n, e, a) {
|
|
645
|
+
const c = B(
|
|
646
|
+
() => fe(n, e, a),
|
|
647
|
+
[n, e, a == null ? void 0 : a.min, a == null ? void 0 : a.max, a == null ? void 0 : a.disableWeekends]
|
|
648
648
|
);
|
|
649
|
-
return
|
|
649
|
+
return F(c, a);
|
|
650
650
|
}
|
|
651
|
-
function
|
|
652
|
-
const
|
|
653
|
-
() =>
|
|
654
|
-
[
|
|
651
|
+
function Ye(n, e, a) {
|
|
652
|
+
const c = B(
|
|
653
|
+
() => be(n, e, a),
|
|
654
|
+
[n, e, a == null ? void 0 : a.industry]
|
|
655
655
|
);
|
|
656
|
-
return
|
|
656
|
+
return F(c, a);
|
|
657
657
|
}
|
|
658
|
-
function
|
|
659
|
-
const
|
|
660
|
-
() =>
|
|
661
|
-
[
|
|
658
|
+
function Xe(n, e, a, c, d) {
|
|
659
|
+
const r = B(
|
|
660
|
+
() => c ? $e(n, e, a, c, d) : { fieldLabel: n, fieldType: e },
|
|
661
|
+
[n, e, a, c]
|
|
662
662
|
);
|
|
663
|
-
return
|
|
663
|
+
return F(r, { ...d, disabled: !c || (d == null ? void 0 : d.disabled) });
|
|
664
664
|
}
|
|
665
|
-
function
|
|
666
|
-
const
|
|
667
|
-
() =>
|
|
668
|
-
[
|
|
665
|
+
function Qe(n, e, a) {
|
|
666
|
+
const c = B(
|
|
667
|
+
() => n ? Te(n, e) : { fieldLabel: "Form" },
|
|
668
|
+
[n, e]
|
|
669
669
|
);
|
|
670
|
-
return
|
|
671
|
-
...
|
|
672
|
-
disabled: !
|
|
670
|
+
return F(c, {
|
|
671
|
+
...a,
|
|
672
|
+
disabled: !n || (a == null ? void 0 : a.disabled)
|
|
673
673
|
});
|
|
674
674
|
}
|
|
675
|
-
function
|
|
676
|
-
const
|
|
677
|
-
`)) ?? [],
|
|
678
|
-
`) :
|
|
675
|
+
function Ie(n, e, a) {
|
|
676
|
+
const d = (e == null ? void 0 : e.split(`
|
|
677
|
+
`)) ?? [], r = (a == null ? void 0 : a.cursorLine) != null ? d.slice(Math.max(0, a.cursorLine - 8), a.cursorLine + 3).join(`
|
|
678
|
+
`) : d.slice(0, 8 * 2).join(`
|
|
679
679
|
`);
|
|
680
680
|
return {
|
|
681
|
-
fieldLabel: `Code editor (${
|
|
681
|
+
fieldLabel: `Code editor (${n})`,
|
|
682
682
|
fieldType: "code-editor",
|
|
683
|
-
fieldValue:
|
|
683
|
+
fieldValue: r || e,
|
|
684
684
|
schema: {
|
|
685
|
-
language:
|
|
686
|
-
...
|
|
687
|
-
...(
|
|
685
|
+
language: n,
|
|
686
|
+
...a != null && a.framework ? { framework: a.framework } : {},
|
|
687
|
+
...(a == null ? void 0 : a.cursorLine) != null ? { cursorLine: a.cursorLine, cursorCol: a.cursorCol } : {}
|
|
688
688
|
},
|
|
689
|
-
customPrompt: `Language: ${
|
|
690
|
-
Provide a concise inline completion or improvement hint for the code near the cursor. Limit response to ${(
|
|
689
|
+
customPrompt: `Language: ${n}${a != null && a.framework ? `, framework: ${a.framework}` : ""}.
|
|
690
|
+
Provide a concise inline completion or improvement hint for the code near the cursor. Limit response to ${(a == null ? void 0 : a.maxSuggestLines) ?? 5} lines of code. If unsure, suggest the most idiomatic approach for this language/framework.`
|
|
691
691
|
};
|
|
692
692
|
}
|
|
693
|
-
function
|
|
694
|
-
var
|
|
695
|
-
const
|
|
693
|
+
function Re(n, e, a) {
|
|
694
|
+
var r;
|
|
695
|
+
const c = (a == null ? void 0 : a.mode) ?? "grammar", d = {
|
|
696
696
|
seo: "Analyze this HTML for SEO: missing meta tags, heading hierarchy (h1→h2→h3), keyword density, image alt attributes. Return a prioritized list of improvements.",
|
|
697
697
|
accessibility: "Audit this HTML for WCAG 2.1 AA issues: missing aria labels, alt text, heading structure, color contrast hints, keyboard navigation. List specific fixes.",
|
|
698
698
|
grammar: "Fix grammar, punctuation, and writing style in the visible text content. Return the corrected text only (no HTML tags in response).",
|
|
699
699
|
cleanup: "Clean up malformed, redundant, or overly nested HTML. Simplify structure while preserving semantics and content."
|
|
700
700
|
};
|
|
701
701
|
return {
|
|
702
|
-
fieldLabel:
|
|
702
|
+
fieldLabel: n,
|
|
703
703
|
fieldType: "html-editor",
|
|
704
704
|
fieldValue: e == null ? void 0 : e.slice(0, 2e3),
|
|
705
705
|
schema: {
|
|
706
|
-
mode:
|
|
707
|
-
...(
|
|
708
|
-
...
|
|
706
|
+
mode: c,
|
|
707
|
+
...(r = a == null ? void 0 : a.targetKeywords) != null && r.length ? { targetKeywords: a.targetKeywords } : {},
|
|
708
|
+
...a != null && a.locale ? { locale: a.locale } : {}
|
|
709
709
|
},
|
|
710
|
-
customPrompt:
|
|
710
|
+
customPrompt: d[c]
|
|
711
711
|
};
|
|
712
712
|
}
|
|
713
|
-
function
|
|
714
|
-
const
|
|
715
|
-
tag: `Audio: ${
|
|
716
|
-
bpm: `Audio: ${
|
|
717
|
-
mix: `Track: ${
|
|
713
|
+
function Pe(n, e) {
|
|
714
|
+
const a = (e == null ? void 0 : e.mode) ?? "tag", c = `"${n}"` + ((e == null ? void 0 : e.bpm) != null ? `, BPM: ${e.bpm}` : "") + (e != null && e.key ? `, Key: ${e.key}` : "") + (e != null && e.genre ? `, Genre: ${e.genre}` : "") + ((e == null ? void 0 : e.duration) != null ? `, Duration: ${e.duration}s` : ""), d = {
|
|
715
|
+
tag: `Audio: ${c}. Suggest genre tags, mood descriptors and playlist categories. Return as JSON array of strings.`,
|
|
716
|
+
bpm: `Audio: ${c}. Suggest likely BPM range and musical key based on metadata. Return as JSON: { bpm: number, key: string }.`,
|
|
717
|
+
mix: `Track: ${c}. Suggest EQ curve (JSON array of {freq, gain, q}), compression settings, and 2-3 compatible tracks for mixing.`,
|
|
718
718
|
transcribe: "Return a transcription of the spoken audio content as JSON: { transcript: string, language: string, confidence: number }."
|
|
719
719
|
};
|
|
720
720
|
return {
|
|
721
|
-
fieldLabel: `Audio: ${
|
|
721
|
+
fieldLabel: `Audio: ${n}`,
|
|
722
722
|
fieldType: "audio",
|
|
723
723
|
schema: {
|
|
724
|
-
mode:
|
|
724
|
+
mode: a,
|
|
725
725
|
...(e == null ? void 0 : e.bpm) != null ? { bpm: e.bpm } : {},
|
|
726
726
|
...e != null && e.key ? { key: e.key } : {},
|
|
727
727
|
...(e == null ? void 0 : e.duration) != null ? { duration: e.duration } : {},
|
|
728
728
|
...e != null && e.genre ? { genre: e.genre } : {}
|
|
729
729
|
},
|
|
730
|
-
customPrompt:
|
|
730
|
+
customPrompt: d[a]
|
|
731
731
|
};
|
|
732
732
|
}
|
|
733
|
-
function
|
|
734
|
-
var
|
|
735
|
-
const
|
|
736
|
-
material: `Scene "${
|
|
737
|
-
optimize: `Scene "${
|
|
738
|
-
lighting: `Scene "${
|
|
739
|
-
animation: `Rig in scene "${
|
|
733
|
+
function Le(n, e) {
|
|
734
|
+
var r;
|
|
735
|
+
const a = (e == null ? void 0 : e.mode) ?? "material", c = (e == null ? void 0 : e.targetDevice) ?? "web", d = {
|
|
736
|
+
material: `Scene "${n}", ${(e == null ? void 0 : e.meshCount) ?? "?"} meshes. Materials: ${((r = e == null ? void 0 : e.materials) == null ? void 0 : r.join(", ")) || "none"}. Suggest PBR properties (roughness, metalness, baseColor) and texture maps for each material.`,
|
|
737
|
+
optimize: `Scene "${n}", triangles: ${(e == null ? void 0 : e.triangleCount) ?? "?"}, target: ${c}. Identify budget issues and suggest LOD levels, mesh merging, and texture atlas strategy.`,
|
|
738
|
+
lighting: `Scene "${n}", target: ${c}. Suggest a complete lighting setup (types, intensity, color, shadow settings) for realistic rendering.`,
|
|
739
|
+
animation: `Rig in scene "${n}". Suggest animation approach (FK/IK, bone count), keyframe timing and easing curves for natural movement.`
|
|
740
740
|
};
|
|
741
741
|
return {
|
|
742
|
-
fieldLabel: `3D scene: ${
|
|
742
|
+
fieldLabel: `3D scene: ${n}`,
|
|
743
743
|
fieldType: "3d-scene",
|
|
744
744
|
schema: {
|
|
745
|
-
mode:
|
|
745
|
+
mode: a,
|
|
746
746
|
...(e == null ? void 0 : e.meshCount) != null ? { meshes: e.meshCount } : {},
|
|
747
747
|
...(e == null ? void 0 : e.triangleCount) != null ? { triangles: e.triangleCount } : {},
|
|
748
748
|
...e != null && e.targetDevice ? { target: e.targetDevice } : {}
|
|
749
749
|
},
|
|
750
|
-
customPrompt:
|
|
750
|
+
customPrompt: d[a]
|
|
751
751
|
};
|
|
752
752
|
}
|
|
753
|
-
function
|
|
754
|
-
const
|
|
755
|
-
filter: `Image "${
|
|
756
|
-
palette: `Image "${
|
|
757
|
-
upscale: `Image "${
|
|
758
|
-
"style-transfer": `Image "${
|
|
753
|
+
function Ae(n, e) {
|
|
754
|
+
const a = (e == null ? void 0 : e.mode) ?? "palette", c = (e == null ? void 0 : e.width) != null ? `${e.width}×${e.height ?? "?"}px` : "unknown dimensions", d = {
|
|
755
|
+
filter: `Image "${n}" (${c}). Suggest CSS/SVG filter parameters (brightness, contrast, saturate, hue-rotate, blur) as JSON: { brightness, contrast, saturate, hueRotate, blur }.`,
|
|
756
|
+
palette: `Image "${n}". Extract or suggest a harmonious 5-color palette as JSON: { primary, secondary, accent, background, text }.`,
|
|
757
|
+
upscale: `Image "${n}" at ${c}. Recommend upscaling strategy: model (ESRGAN/RealSR/SRCNN), scale factor, and expected quality gain.`,
|
|
758
|
+
"style-transfer": `Image "${n}", target style: "${(e == null ? void 0 : e.targetStyle) ?? "artistic"}". Suggest style-transfer settings as JSON: { contentWeight, styleWeight, iterations, patchSize }.`
|
|
759
759
|
};
|
|
760
760
|
return {
|
|
761
|
-
fieldLabel: `Graphics: ${
|
|
761
|
+
fieldLabel: `Graphics: ${n}`,
|
|
762
762
|
fieldType: "graphics",
|
|
763
763
|
schema: {
|
|
764
|
-
mode:
|
|
764
|
+
mode: a,
|
|
765
765
|
...(e == null ? void 0 : e.width) != null ? { width: e.width, height: e.height } : {},
|
|
766
766
|
...e != null && e.targetStyle ? { targetStyle: e.targetStyle } : {}
|
|
767
767
|
},
|
|
768
|
-
customPrompt:
|
|
768
|
+
customPrompt: d[a]
|
|
769
769
|
};
|
|
770
770
|
}
|
|
771
|
-
function
|
|
772
|
-
var
|
|
771
|
+
function Me(n, e) {
|
|
772
|
+
var a;
|
|
773
773
|
return {
|
|
774
774
|
fieldLabel: "Icon search",
|
|
775
775
|
fieldType: "icon-picker",
|
|
776
|
-
fieldValue:
|
|
776
|
+
fieldValue: n,
|
|
777
777
|
schema: {
|
|
778
778
|
...e != null && e.style ? { iconStyle: e.style } : {},
|
|
779
779
|
...(e == null ? void 0 : e.limit) != null ? { maxResults: e.limit } : {},
|
|
780
|
-
...(
|
|
780
|
+
...(a = e == null ? void 0 : e.availableIcons) != null && a.length ? { sampleIcons: e.availableIcons.slice(0, 30) } : {}
|
|
781
781
|
},
|
|
782
|
-
customPrompt: `User query: "${
|
|
782
|
+
customPrompt: `User query: "${n}"
|
|
783
783
|
Return the ${(e == null ? void 0 : e.limit) ?? 5} most semantically relevant icon names from the available set as a JSON array of strings, ordered by relevance. Prefer specific over generic names.`
|
|
784
784
|
};
|
|
785
785
|
}
|
|
786
|
-
function
|
|
787
|
-
const
|
|
788
|
-
() =>
|
|
786
|
+
function Ze(n, e, a) {
|
|
787
|
+
const c = B(
|
|
788
|
+
() => Ie(n, e, a),
|
|
789
789
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
790
|
-
[
|
|
790
|
+
[n, e, a == null ? void 0 : a.cursorLine, a == null ? void 0 : a.cursorCol, a == null ? void 0 : a.framework]
|
|
791
791
|
);
|
|
792
|
-
return
|
|
792
|
+
return F(c, a);
|
|
793
793
|
}
|
|
794
|
-
function
|
|
795
|
-
const
|
|
796
|
-
() =>
|
|
794
|
+
function ea(n, e, a) {
|
|
795
|
+
const c = B(
|
|
796
|
+
() => Re(n, e, a),
|
|
797
797
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
798
|
-
[
|
|
798
|
+
[n, e, a == null ? void 0 : a.mode, a == null ? void 0 : a.locale]
|
|
799
799
|
);
|
|
800
|
-
return
|
|
800
|
+
return F(c, a);
|
|
801
801
|
}
|
|
802
|
-
function
|
|
803
|
-
const
|
|
804
|
-
() =>
|
|
802
|
+
function aa(n, e) {
|
|
803
|
+
const a = B(
|
|
804
|
+
() => Pe(n, e),
|
|
805
805
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
806
|
-
[
|
|
806
|
+
[n, e == null ? void 0 : e.bpm, e == null ? void 0 : e.key, e == null ? void 0 : e.duration, e == null ? void 0 : e.mode]
|
|
807
807
|
);
|
|
808
|
-
return
|
|
808
|
+
return F(a, e);
|
|
809
809
|
}
|
|
810
|
-
function
|
|
811
|
-
const
|
|
812
|
-
() =>
|
|
810
|
+
function ta(n, e) {
|
|
811
|
+
const a = B(
|
|
812
|
+
() => Le(n, e),
|
|
813
813
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
814
|
-
[
|
|
814
|
+
[n, e == null ? void 0 : e.meshCount, e == null ? void 0 : e.triangleCount, e == null ? void 0 : e.targetDevice, e == null ? void 0 : e.mode]
|
|
815
815
|
);
|
|
816
|
-
return
|
|
816
|
+
return F(a, e);
|
|
817
817
|
}
|
|
818
|
-
function
|
|
819
|
-
const
|
|
820
|
-
() =>
|
|
818
|
+
function na(n, e) {
|
|
819
|
+
const a = B(
|
|
820
|
+
() => Ae(n, e),
|
|
821
821
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
822
|
-
[
|
|
822
|
+
[n, e == null ? void 0 : e.width, e == null ? void 0 : e.height, e == null ? void 0 : e.mode, e == null ? void 0 : e.targetStyle]
|
|
823
823
|
);
|
|
824
|
-
return
|
|
824
|
+
return F(a, e);
|
|
825
825
|
}
|
|
826
|
-
function
|
|
827
|
-
const
|
|
828
|
-
() =>
|
|
826
|
+
function ia(n, e) {
|
|
827
|
+
const a = B(
|
|
828
|
+
() => Me(n, e),
|
|
829
829
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
830
|
-
[
|
|
830
|
+
[n, e == null ? void 0 : e.limit, e == null ? void 0 : e.style]
|
|
831
831
|
);
|
|
832
|
-
return
|
|
832
|
+
return F(a, { ...e, disabled: !n || (e == null ? void 0 : e.disabled) });
|
|
833
833
|
}
|
|
834
|
-
function
|
|
835
|
-
var
|
|
836
|
-
const
|
|
837
|
-
"npc-decision": `You are an AI game director. The NPC "${
|
|
838
|
-
dialogue: `You are a ${
|
|
839
|
-
"procedural-level": `You are a ${
|
|
840
|
-
"quest-description": `You are a ${
|
|
841
|
-
"item-description": `You are a ${
|
|
834
|
+
function Oe(n, e) {
|
|
835
|
+
var r;
|
|
836
|
+
const a = (e == null ? void 0 : e.mode) ?? "npc-decision", c = (e == null ? void 0 : e.genre) ?? "fantasy", d = {
|
|
837
|
+
"npc-decision": `You are an AI game director. The NPC "${n}" must make a decision. Available BT nodes: ${JSON.stringify((e == null ? void 0 : e.btStatus) ?? [])}. Game state: ${JSON.stringify((e == null ? void 0 : e.gameState) ?? {})}. Return the name of the BT node to activate next, and one sentence of reasoning.`,
|
|
838
|
+
dialogue: `You are a ${c} RPG writer. Write a short in-character dialogue line for NPC "${n}". Game state: ${JSON.stringify((e == null ? void 0 : e.gameState) ?? {})}. Max 2 sentences, no narrative descriptions.`,
|
|
839
|
+
"procedural-level": `You are a ${c} game designer. Suggest a procedural level layout for a zone containing "${n}". Describe room count, enemy placement, loot, and one unique mechanic. Keep it under 150 words.`,
|
|
840
|
+
"quest-description": `You are a ${c} quest designer. Write a compelling quest description involving "${n}". Include: objective, giver NPC, rewards, and a short flavour paragraph. Keep it under 120 words.`,
|
|
841
|
+
"item-description": `You are a ${c} lore writer. Write a short item description for an item related to "${n}". Include: item name, rarity, flavour text, and one special property. Keep it under 80 words.`
|
|
842
842
|
};
|
|
843
843
|
return {
|
|
844
|
-
fieldLabel:
|
|
845
|
-
fieldType: `game-engine:${
|
|
844
|
+
fieldLabel: n,
|
|
845
|
+
fieldType: `game-engine:${a}`,
|
|
846
846
|
fieldValue: e == null ? void 0 : e.gameState,
|
|
847
|
-
customPrompt:
|
|
847
|
+
customPrompt: d[a],
|
|
848
848
|
schema: {
|
|
849
|
-
genre:
|
|
850
|
-
mode:
|
|
851
|
-
btNodes: (
|
|
849
|
+
genre: c,
|
|
850
|
+
mode: a,
|
|
851
|
+
btNodes: (r = e == null ? void 0 : e.btStatus) == null ? void 0 : r.map((x) => x.node)
|
|
852
852
|
}
|
|
853
853
|
};
|
|
854
854
|
}
|
|
855
|
-
function
|
|
856
|
-
const
|
|
857
|
-
() =>
|
|
855
|
+
function ra(n, e) {
|
|
856
|
+
const a = B(
|
|
857
|
+
() => Oe(n, e),
|
|
858
858
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
859
|
-
[
|
|
859
|
+
[n, e == null ? void 0 : e.mode, e == null ? void 0 : e.genre, JSON.stringify(e == null ? void 0 : e.btStatus), JSON.stringify(e == null ? void 0 : e.gameState)]
|
|
860
860
|
);
|
|
861
|
-
return
|
|
861
|
+
return F(a, e);
|
|
862
862
|
}
|
|
863
|
-
function
|
|
864
|
-
const
|
|
865
|
-
layout: `You are a diagram layout optimizer. Given this ${
|
|
866
|
-
structure: `You are a diagram analyst. Analyze this ${
|
|
867
|
-
simplify: `You are a diagram simplifier. Suggest how to simplify this ${
|
|
868
|
-
group: `You are a diagram organizer. Suggest logical groupings for nodes in this ${
|
|
869
|
-
},
|
|
870
|
-
var
|
|
863
|
+
function De(n, e, a) {
|
|
864
|
+
const c = (a == null ? void 0 : a.mode) ?? "layout", d = (a == null ? void 0 : a.diagramType) ?? "flowchart", r = {
|
|
865
|
+
layout: `You are a diagram layout optimizer. Given this ${d} with ${n.length} nodes and ${e.length} edges, suggest optimal positions for each node to minimize edge crossings and improve readability. Return JSON: { suggestions: [{ id: string, x: number, y: number, reason: string }] }. Consider flow direction (top-to-bottom or left-to-right) and grouping related nodes.`,
|
|
866
|
+
structure: `You are a diagram analyst. Analyze this ${d} structure. Identify: 1) Missing connections, 2) Potential bottlenecks, 3) Orphan nodes, 4) Cycles or loops. Return JSON: { issues: [{ type: string, description: string, nodeIds: string[] }], score: number }`,
|
|
867
|
+
simplify: `You are a diagram simplifier. Suggest how to simplify this ${d} while preserving meaning. Identify: nodes that could be merged, redundant edges, or overly complex branches. Return JSON: { simplifications: [{ action: 'merge'|'remove'|'group', ids: string[], reason: string }] }`,
|
|
868
|
+
group: `You are a diagram organizer. Suggest logical groupings for nodes in this ${d}. Consider semantic relationships, data flow patterns, and visual clustering. Return JSON: { groups: [{ name: string, nodeIds: string[], color?: string }] }`
|
|
869
|
+
}, x = n.map((S) => {
|
|
870
|
+
var b;
|
|
871
871
|
return {
|
|
872
|
-
id:
|
|
873
|
-
type:
|
|
874
|
-
label: (
|
|
875
|
-
pos: [Math.round(
|
|
872
|
+
id: S.id,
|
|
873
|
+
type: S.type,
|
|
874
|
+
label: (b = S.label) == null ? void 0 : b.slice(0, 30),
|
|
875
|
+
pos: [Math.round(S.x), Math.round(S.y)]
|
|
876
876
|
};
|
|
877
|
-
}),
|
|
878
|
-
id:
|
|
879
|
-
src:
|
|
880
|
-
tgt:
|
|
877
|
+
}), C = e.map((S) => ({
|
|
878
|
+
id: S.id,
|
|
879
|
+
src: S.source,
|
|
880
|
+
tgt: S.target
|
|
881
881
|
}));
|
|
882
882
|
return {
|
|
883
|
-
fieldLabel: `Diagram (${
|
|
884
|
-
fieldType: `diagram:${
|
|
885
|
-
fieldValue: JSON.stringify({ nodes:
|
|
883
|
+
fieldLabel: `Diagram (${d})`,
|
|
884
|
+
fieldType: `diagram:${c}`,
|
|
885
|
+
fieldValue: JSON.stringify({ nodes: x, edges: C }),
|
|
886
886
|
schema: {
|
|
887
|
-
diagramType:
|
|
888
|
-
mode:
|
|
889
|
-
nodeCount:
|
|
887
|
+
diagramType: d,
|
|
888
|
+
mode: c,
|
|
889
|
+
nodeCount: n.length,
|
|
890
890
|
edgeCount: e.length,
|
|
891
|
-
containerSize:
|
|
891
|
+
containerSize: a == null ? void 0 : a.containerSize
|
|
892
892
|
},
|
|
893
|
-
customPrompt:
|
|
893
|
+
customPrompt: r[c]
|
|
894
894
|
};
|
|
895
895
|
}
|
|
896
|
-
function
|
|
897
|
-
const
|
|
898
|
-
() =>
|
|
896
|
+
function la(n, e, a) {
|
|
897
|
+
const c = B(
|
|
898
|
+
() => De(n, e, a),
|
|
899
899
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
900
|
-
[JSON.stringify(
|
|
900
|
+
[JSON.stringify(n), JSON.stringify(e), a == null ? void 0 : a.mode, a == null ? void 0 : a.diagramType]
|
|
901
901
|
);
|
|
902
|
-
return
|
|
902
|
+
return F(c, { ...a, disabled: n.length === 0 || (a == null ? void 0 : a.disabled) });
|
|
903
903
|
}
|
|
904
|
-
function
|
|
905
|
-
const
|
|
906
|
-
generate: `You are a presentation designer. Create a ${
|
|
907
|
-
summarize: `You are a presentation optimizer. Summarize this presentation to be more concise: "${
|
|
908
|
-
expand: `You are a presentation expert. Expand this brief outline into a detailed presentation: "${
|
|
909
|
-
improve: `You are a presentation coach. Review and improve this presentation structure: "${
|
|
904
|
+
function Ee(n, e) {
|
|
905
|
+
const a = (e == null ? void 0 : e.mode) ?? "generate", c = (e == null ? void 0 : e.presentationType) ?? "business", d = (e == null ? void 0 : e.duration) ?? 15, r = Math.ceil(d / 2), x = {
|
|
906
|
+
generate: `You are a presentation designer. Create a ${c} presentation outline based on: "${n}". Target audience: ${(e == null ? void 0 : e.audience) ?? "general"}. Duration: ${d} minutes (~${r} slides). Return JSON: { title: string, slides: [{ title: string, layout: 'title'|'content'|'two-column'|'chart'|'image', bullets?: string[], chartType?: string, speakerNotes?: string }] }. Include: clear slide titles, 3-5 bullet points per content slide, and brief speaker notes.`,
|
|
907
|
+
summarize: `You are a presentation optimizer. Summarize this presentation to be more concise: "${n}". Reduce slide count by 30% while preserving key messages. Return JSON: { summary: string, reducedSlides: [{ title: string, keyPoints: string[] }] }`,
|
|
908
|
+
expand: `You are a presentation expert. Expand this brief outline into a detailed presentation: "${n}". Add supporting details, examples, and transitions. Target: ${r} slides. Return JSON: { slides: [{ title: string, content: string, transitions?: string, animations?: string[] }] }`,
|
|
909
|
+
improve: `You are a presentation coach. Review and improve this presentation structure: "${n}". Suggest: better flow, stronger opening/closing, clearer data visualization. Return JSON: { improvements: [{ slide: number, issue: string, suggestion: string }], score: number }`
|
|
910
910
|
};
|
|
911
911
|
return {
|
|
912
|
-
fieldLabel: `Presentation (${
|
|
913
|
-
fieldType: `presentation:${
|
|
914
|
-
fieldValue:
|
|
912
|
+
fieldLabel: `Presentation (${c})`,
|
|
913
|
+
fieldType: `presentation:${a}`,
|
|
914
|
+
fieldValue: n,
|
|
915
915
|
schema: {
|
|
916
|
-
presentationType:
|
|
917
|
-
mode:
|
|
918
|
-
duration:
|
|
919
|
-
slideCount:
|
|
916
|
+
presentationType: c,
|
|
917
|
+
mode: a,
|
|
918
|
+
duration: d,
|
|
919
|
+
slideCount: r,
|
|
920
920
|
audience: e == null ? void 0 : e.audience,
|
|
921
921
|
hasData: (e == null ? void 0 : e.dataContext) != null
|
|
922
922
|
},
|
|
923
|
-
customPrompt:
|
|
923
|
+
customPrompt: x[a]
|
|
924
924
|
};
|
|
925
925
|
}
|
|
926
|
-
function
|
|
927
|
-
const
|
|
928
|
-
() =>
|
|
926
|
+
function sa(n, e) {
|
|
927
|
+
const a = B(
|
|
928
|
+
() => Ee(n, e),
|
|
929
929
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
930
|
-
[
|
|
930
|
+
[n, e == null ? void 0 : e.mode, e == null ? void 0 : e.presentationType, e == null ? void 0 : e.duration, e == null ? void 0 : e.audience]
|
|
931
931
|
);
|
|
932
|
-
return
|
|
932
|
+
return F(a, { ...e, disabled: !n || (e == null ? void 0 : e.disabled) });
|
|
933
933
|
}
|
|
934
|
-
function
|
|
935
|
-
var
|
|
936
|
-
const
|
|
934
|
+
function Je(n, e) {
|
|
935
|
+
var d;
|
|
936
|
+
const a = (e == null ? void 0 : e.mode) ?? "all", c = {
|
|
937
937
|
alignment: "Analyze element alignment on this slide. Suggest adjustments to create visual harmony. Return JSON: { suggestions: [{ elementIndex: number, issue: string, fixX?: number, fixY?: number }] }",
|
|
938
938
|
contrast: "Analyze color contrast and readability. Suggest improvements for accessibility (WCAG AA). Return JSON: { suggestions: [{ area: string, currentContrast: number, suggestedFix: string }] }",
|
|
939
939
|
spacing: "Analyze whitespace and element spacing. Apply the rule of thirds and consistent margins. Return JSON: { suggestions: [{ elementIndex: number, issue: string, suggestedMargin: number }] }",
|
|
@@ -941,138 +941,1874 @@ function xe(r, e) {
|
|
|
941
941
|
all: "Perform a complete design review of this slide. Check alignment, contrast, spacing, and typography. Return JSON: { score: number, suggestions: [{ category: string, issue: string, fix: string }] }. Prioritize issues by impact on visual clarity."
|
|
942
942
|
};
|
|
943
943
|
return {
|
|
944
|
-
fieldLabel:
|
|
945
|
-
fieldType: `slide-design:${
|
|
946
|
-
fieldValue: JSON.stringify(
|
|
944
|
+
fieldLabel: n.title ?? "Slide Design",
|
|
945
|
+
fieldType: `slide-design:${a}`,
|
|
946
|
+
fieldValue: JSON.stringify(n),
|
|
947
947
|
schema: {
|
|
948
|
-
mode:
|
|
949
|
-
hasElements: (((
|
|
950
|
-
layout:
|
|
948
|
+
mode: a,
|
|
949
|
+
hasElements: (((d = n.elements) == null ? void 0 : d.length) ?? 0) > 0,
|
|
950
|
+
layout: n.layout,
|
|
951
951
|
brandColors: e == null ? void 0 : e.brandColors
|
|
952
952
|
},
|
|
953
|
-
customPrompt:
|
|
953
|
+
customPrompt: c[a]
|
|
954
954
|
};
|
|
955
955
|
}
|
|
956
|
-
function
|
|
957
|
-
const
|
|
958
|
-
() =>
|
|
956
|
+
function ca(n, e) {
|
|
957
|
+
const a = B(
|
|
958
|
+
() => Je(n, e),
|
|
959
959
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
960
|
-
[JSON.stringify(
|
|
960
|
+
[JSON.stringify(n), e == null ? void 0 : e.mode, JSON.stringify(e == null ? void 0 : e.brandColors)]
|
|
961
961
|
);
|
|
962
|
-
return
|
|
962
|
+
return F(a, e);
|
|
963
963
|
}
|
|
964
|
-
function
|
|
965
|
-
const
|
|
964
|
+
function da(n, e, a) {
|
|
965
|
+
const c = ce((d, r) => {
|
|
966
966
|
const {
|
|
967
|
-
aiEnabled:
|
|
968
|
-
aiPosition:
|
|
969
|
-
aiPrompt:
|
|
970
|
-
aiDebounceMs:
|
|
971
|
-
aiShowOnHover:
|
|
972
|
-
aiTriggerIcon:
|
|
973
|
-
...
|
|
974
|
-
} =
|
|
975
|
-
const
|
|
976
|
-
return
|
|
977
|
-
}, [
|
|
978
|
-
return /* @__PURE__ */
|
|
979
|
-
/* @__PURE__ */
|
|
980
|
-
|
|
981
|
-
|
|
967
|
+
aiEnabled: x = !0,
|
|
968
|
+
aiPosition: C = "right",
|
|
969
|
+
aiPrompt: S,
|
|
970
|
+
aiDebounceMs: b = 500,
|
|
971
|
+
aiShowOnHover: I = !1,
|
|
972
|
+
aiTriggerIcon: E,
|
|
973
|
+
...R
|
|
974
|
+
} = d, $ = B(() => {
|
|
975
|
+
const O = e(R);
|
|
976
|
+
return S && (O.customPrompt = S), O;
|
|
977
|
+
}, [R, S]);
|
|
978
|
+
return /* @__PURE__ */ i("span", { style: { display: "inline-flex", alignItems: "center", gap: 4 }, children: [
|
|
979
|
+
/* @__PURE__ */ t(n, { ...R, ref: r }),
|
|
980
|
+
x && /* @__PURE__ */ t(
|
|
981
|
+
ue,
|
|
982
982
|
{
|
|
983
|
-
context:
|
|
984
|
-
position:
|
|
985
|
-
debounceMs:
|
|
986
|
-
showOnHover:
|
|
987
|
-
triggerIcon:
|
|
983
|
+
context: $,
|
|
984
|
+
position: C,
|
|
985
|
+
debounceMs: b,
|
|
986
|
+
showOnHover: I,
|
|
987
|
+
triggerIcon: E
|
|
988
988
|
}
|
|
989
989
|
)
|
|
990
990
|
] });
|
|
991
991
|
});
|
|
992
|
-
return
|
|
992
|
+
return c.displayName = a ?? `withAIHint(${n.displayName ?? n.name ?? "Component"})`, c;
|
|
993
993
|
}
|
|
994
|
-
function
|
|
995
|
-
return
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
{ placeholder:
|
|
994
|
+
function oa(n) {
|
|
995
|
+
return me(
|
|
996
|
+
n.label ?? "Text",
|
|
997
|
+
n.value,
|
|
998
|
+
{ placeholder: n.placeholder, maxLength: n.maxLength }
|
|
999
999
|
);
|
|
1000
1000
|
}
|
|
1001
|
-
function
|
|
1002
|
-
return
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
{ min:
|
|
1001
|
+
function ua(n) {
|
|
1002
|
+
return he(
|
|
1003
|
+
n.label ?? "Number",
|
|
1004
|
+
n.value,
|
|
1005
|
+
{ min: n.min, max: n.max, step: n.step }
|
|
1006
1006
|
);
|
|
1007
1007
|
}
|
|
1008
|
-
function
|
|
1009
|
-
return
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
{ options:
|
|
1008
|
+
function ma(n) {
|
|
1009
|
+
return ge(
|
|
1010
|
+
n.label ?? "Select",
|
|
1011
|
+
n.value,
|
|
1012
|
+
{ options: n.options, multiple: n.multiple }
|
|
1013
1013
|
);
|
|
1014
1014
|
}
|
|
1015
|
-
function
|
|
1016
|
-
return
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
{ min:
|
|
1015
|
+
function ha(n) {
|
|
1016
|
+
return fe(
|
|
1017
|
+
n.label ?? "Date",
|
|
1018
|
+
n.value,
|
|
1019
|
+
{ min: n.min, max: n.max }
|
|
1020
1020
|
);
|
|
1021
1021
|
}
|
|
1022
|
-
function
|
|
1023
|
-
return
|
|
1024
|
-
|
|
1025
|
-
|
|
1022
|
+
function ga(n) {
|
|
1023
|
+
return be(
|
|
1024
|
+
n.label ?? "Color",
|
|
1025
|
+
n.value
|
|
1026
1026
|
);
|
|
1027
1027
|
}
|
|
1028
|
+
const ze = {
|
|
1029
|
+
id: crypto.randomUUID(),
|
|
1030
|
+
name: "New ML Project",
|
|
1031
|
+
type: "classification",
|
|
1032
|
+
status: "draft",
|
|
1033
|
+
datasets: [],
|
|
1034
|
+
experiments: [],
|
|
1035
|
+
models: [],
|
|
1036
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
1037
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
1038
|
+
}, re = {
|
|
1039
|
+
classification: [
|
|
1040
|
+
{ id: "logistic-regression", name: "Logistic Regression" },
|
|
1041
|
+
{ id: "random-forest", name: "Random Forest" },
|
|
1042
|
+
{ id: "gradient-boosting", name: "Gradient Boosting" },
|
|
1043
|
+
{ id: "svm", name: "Support Vector Machine" },
|
|
1044
|
+
{ id: "neural-network", name: "Neural Network" },
|
|
1045
|
+
{ id: "xgboost", name: "XGBoost" }
|
|
1046
|
+
],
|
|
1047
|
+
regression: [
|
|
1048
|
+
{ id: "linear-regression", name: "Linear Regression" },
|
|
1049
|
+
{ id: "ridge", name: "Ridge Regression" },
|
|
1050
|
+
{ id: "lasso", name: "Lasso Regression" },
|
|
1051
|
+
{ id: "random-forest-reg", name: "Random Forest" },
|
|
1052
|
+
{ id: "gradient-boosting-reg", name: "Gradient Boosting" }
|
|
1053
|
+
],
|
|
1054
|
+
clustering: [
|
|
1055
|
+
{ id: "kmeans", name: "K-Means" },
|
|
1056
|
+
{ id: "dbscan", name: "DBSCAN" },
|
|
1057
|
+
{ id: "hierarchical", name: "Hierarchical Clustering" }
|
|
1058
|
+
]
|
|
1059
|
+
}, le = {
|
|
1060
|
+
classification: ["accuracy", "precision", "recall", "f1-score", "auc-roc"],
|
|
1061
|
+
regression: ["mse", "rmse", "mae", "r2"],
|
|
1062
|
+
clustering: ["silhouette", "calinski-harabasz", "davies-bouldin"]
|
|
1063
|
+
}, fa = ({
|
|
1064
|
+
project: n,
|
|
1065
|
+
onProjectChange: e,
|
|
1066
|
+
onExperimentRun: a,
|
|
1067
|
+
onModelDeploy: c,
|
|
1068
|
+
className: d = ""
|
|
1069
|
+
}) => {
|
|
1070
|
+
var y;
|
|
1071
|
+
const [r, x] = p(n || ze), [C, S] = p("data"), [b, I] = p(null), [E, R] = p(null), [$, O] = p(null), [N, U] = p(!1), [h, v] = p({
|
|
1072
|
+
algorithm: "",
|
|
1073
|
+
hyperparameters: {},
|
|
1074
|
+
preprocessing: []
|
|
1075
|
+
}), f = X(
|
|
1076
|
+
(l) => {
|
|
1077
|
+
const m = { ...r, ...l, updatedAt: /* @__PURE__ */ new Date() };
|
|
1078
|
+
x(m), e == null || e(m);
|
|
1079
|
+
},
|
|
1080
|
+
[r, e]
|
|
1081
|
+
), D = async (l) => {
|
|
1082
|
+
for (const m of Array.from(l)) {
|
|
1083
|
+
const T = {
|
|
1084
|
+
id: crypto.randomUUID(),
|
|
1085
|
+
name: m.name.replace(/\.[^.]+$/, ""),
|
|
1086
|
+
type: "tabular",
|
|
1087
|
+
source: { type: "file", uri: m.name },
|
|
1088
|
+
size: m.size,
|
|
1089
|
+
rowCount: 0,
|
|
1090
|
+
columns: [],
|
|
1091
|
+
splits: [
|
|
1092
|
+
{ name: "train", ratio: 0.8, rowCount: 0 },
|
|
1093
|
+
{ name: "validation", ratio: 0.1, rowCount: 0 },
|
|
1094
|
+
{ name: "test", ratio: 0.1, rowCount: 0 }
|
|
1095
|
+
],
|
|
1096
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
1097
|
+
};
|
|
1098
|
+
if (m.name.endsWith(".csv")) {
|
|
1099
|
+
const z = (await m.text()).split(`
|
|
1100
|
+
`), W = z[0].split(",").map((Y) => Y.trim());
|
|
1101
|
+
T.rowCount = z.length - 1, T.columns = W.map((Y) => ({
|
|
1102
|
+
name: Y,
|
|
1103
|
+
type: "text",
|
|
1104
|
+
nullable: !0,
|
|
1105
|
+
unique: 0,
|
|
1106
|
+
missing: 0
|
|
1107
|
+
})), T.splits = T.splits.map((Y) => ({
|
|
1108
|
+
...Y,
|
|
1109
|
+
rowCount: Math.floor(T.rowCount * Y.ratio)
|
|
1110
|
+
}));
|
|
1111
|
+
}
|
|
1112
|
+
f({ datasets: [...r.datasets, T] });
|
|
1113
|
+
}
|
|
1114
|
+
}, L = (l) => {
|
|
1115
|
+
f({ datasets: r.datasets.filter((m) => m.id !== l) }), b === l && I(null);
|
|
1116
|
+
}, P = async () => {
|
|
1117
|
+
if (!h.algorithm || !b) return;
|
|
1118
|
+
const l = {
|
|
1119
|
+
id: crypto.randomUUID(),
|
|
1120
|
+
name: `Experiment ${r.experiments.length + 1}`,
|
|
1121
|
+
status: "pending",
|
|
1122
|
+
config: h,
|
|
1123
|
+
metrics: [],
|
|
1124
|
+
artifacts: [],
|
|
1125
|
+
logs: []
|
|
1126
|
+
};
|
|
1127
|
+
if (f({ experiments: [...r.experiments, l] }), U(!1), a) {
|
|
1128
|
+
f({
|
|
1129
|
+
experiments: r.experiments.map(
|
|
1130
|
+
(m) => m.id === l.id ? { ...m, status: "running", startedAt: /* @__PURE__ */ new Date() } : m
|
|
1131
|
+
)
|
|
1132
|
+
});
|
|
1133
|
+
try {
|
|
1134
|
+
await a(l);
|
|
1135
|
+
const m = (le[r.type] || le.classification).map((T) => ({
|
|
1136
|
+
name: T,
|
|
1137
|
+
value: Math.random() * 0.3 + 0.7,
|
|
1138
|
+
split: "validation"
|
|
1139
|
+
}));
|
|
1140
|
+
f({
|
|
1141
|
+
experiments: r.experiments.map(
|
|
1142
|
+
(T) => T.id === l.id ? { ...T, status: "completed", completedAt: /* @__PURE__ */ new Date(), metrics: m } : T
|
|
1143
|
+
)
|
|
1144
|
+
});
|
|
1145
|
+
} catch {
|
|
1146
|
+
f({
|
|
1147
|
+
experiments: r.experiments.map(
|
|
1148
|
+
(m) => m.id === l.id ? { ...m, status: "failed" } : m
|
|
1149
|
+
)
|
|
1150
|
+
});
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
}, j = (l) => {
|
|
1154
|
+
const m = r.experiments.find((w) => w.id === l);
|
|
1155
|
+
if (!m) return;
|
|
1156
|
+
const T = {
|
|
1157
|
+
id: crypto.randomUUID(),
|
|
1158
|
+
name: `Model from ${m.name}`,
|
|
1159
|
+
version: "1.0.0",
|
|
1160
|
+
algorithm: m.config.algorithm,
|
|
1161
|
+
experimentId: l,
|
|
1162
|
+
status: "registered",
|
|
1163
|
+
metrics: m.metrics,
|
|
1164
|
+
size: Math.floor(Math.random() * 100) * 1024 * 1024,
|
|
1165
|
+
artifacts: [],
|
|
1166
|
+
deployments: [],
|
|
1167
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
1168
|
+
};
|
|
1169
|
+
f({ models: [...r.models, T] });
|
|
1170
|
+
}, _ = async (l) => {
|
|
1171
|
+
const m = r.models.find((w) => w.id === l);
|
|
1172
|
+
if (!m || !c) return;
|
|
1173
|
+
const T = await c(m);
|
|
1174
|
+
f({
|
|
1175
|
+
models: r.models.map(
|
|
1176
|
+
(w) => w.id === l ? { ...w, status: "production", deployments: [...w.deployments, T] } : w
|
|
1177
|
+
)
|
|
1178
|
+
});
|
|
1179
|
+
}, V = (l) => l < 1024 ? `${l} B` : l < 1024 * 1024 ? `${(l / 1024).toFixed(1)} KB` : l < 1024 * 1024 * 1024 ? `${(l / 1024 / 1024).toFixed(1)} MB` : `${(l / 1024 / 1024 / 1024).toFixed(1)} GB`, G = (l) => {
|
|
1180
|
+
switch (l) {
|
|
1181
|
+
case "completed":
|
|
1182
|
+
case "production":
|
|
1183
|
+
case "running":
|
|
1184
|
+
return "status-badge--success";
|
|
1185
|
+
case "pending":
|
|
1186
|
+
case "staging":
|
|
1187
|
+
return "status-badge--warning";
|
|
1188
|
+
case "failed":
|
|
1189
|
+
return "status-badge--error";
|
|
1190
|
+
default:
|
|
1191
|
+
return "";
|
|
1192
|
+
}
|
|
1193
|
+
};
|
|
1194
|
+
return /* @__PURE__ */ i("div", { className: `nice-ml-studio ${d}`, children: [
|
|
1195
|
+
/* @__PURE__ */ i("header", { className: "ml-studio__header", children: [
|
|
1196
|
+
/* @__PURE__ */ i("div", { className: "header__info", children: [
|
|
1197
|
+
/* @__PURE__ */ t(
|
|
1198
|
+
"input",
|
|
1199
|
+
{
|
|
1200
|
+
type: "text",
|
|
1201
|
+
value: r.name,
|
|
1202
|
+
onChange: (l) => f({ name: l.target.value }),
|
|
1203
|
+
className: "project-name-input"
|
|
1204
|
+
}
|
|
1205
|
+
),
|
|
1206
|
+
/* @__PURE__ */ i(
|
|
1207
|
+
"select",
|
|
1208
|
+
{
|
|
1209
|
+
value: r.type,
|
|
1210
|
+
onChange: (l) => f({ type: l.target.value }),
|
|
1211
|
+
className: "project-type-select",
|
|
1212
|
+
children: [
|
|
1213
|
+
/* @__PURE__ */ t("option", { value: "classification", children: "Classification" }),
|
|
1214
|
+
/* @__PURE__ */ t("option", { value: "regression", children: "Regression" }),
|
|
1215
|
+
/* @__PURE__ */ t("option", { value: "clustering", children: "Clustering" }),
|
|
1216
|
+
/* @__PURE__ */ t("option", { value: "object-detection", children: "Object Detection" }),
|
|
1217
|
+
/* @__PURE__ */ t("option", { value: "nlp", children: "NLP" }),
|
|
1218
|
+
/* @__PURE__ */ t("option", { value: "time-series", children: "Time Series" })
|
|
1219
|
+
]
|
|
1220
|
+
}
|
|
1221
|
+
)
|
|
1222
|
+
] }),
|
|
1223
|
+
/* @__PURE__ */ t("div", { className: "header__tabs", children: ["data", "experiments", "models", "deploy"].map((l) => /* @__PURE__ */ t(
|
|
1224
|
+
"button",
|
|
1225
|
+
{
|
|
1226
|
+
className: `tab-button ${C === l ? "tab-button--active" : ""}`,
|
|
1227
|
+
onClick: () => S(l),
|
|
1228
|
+
children: l.charAt(0).toUpperCase() + l.slice(1)
|
|
1229
|
+
},
|
|
1230
|
+
l
|
|
1231
|
+
)) })
|
|
1232
|
+
] }),
|
|
1233
|
+
/* @__PURE__ */ i("div", { className: "ml-studio__content", children: [
|
|
1234
|
+
C === "data" && /* @__PURE__ */ i("div", { className: "data-panel", children: [
|
|
1235
|
+
/* @__PURE__ */ i("div", { className: "panel-header", children: [
|
|
1236
|
+
/* @__PURE__ */ t("h2", { children: "Datasets" }),
|
|
1237
|
+
/* @__PURE__ */ i("label", { className: "upload-button", children: [
|
|
1238
|
+
/* @__PURE__ */ t(
|
|
1239
|
+
"input",
|
|
1240
|
+
{
|
|
1241
|
+
type: "file",
|
|
1242
|
+
multiple: !0,
|
|
1243
|
+
accept: ".csv,.json,.parquet",
|
|
1244
|
+
onChange: (l) => l.target.files && D(l.target.files),
|
|
1245
|
+
hidden: !0
|
|
1246
|
+
}
|
|
1247
|
+
),
|
|
1248
|
+
"+ Upload Dataset"
|
|
1249
|
+
] })
|
|
1250
|
+
] }),
|
|
1251
|
+
/* @__PURE__ */ t("div", { className: "datasets-grid", children: r.datasets.length === 0 ? /* @__PURE__ */ i("div", { className: "empty-state", children: [
|
|
1252
|
+
/* @__PURE__ */ t("span", { className: "icon", children: "📊" }),
|
|
1253
|
+
/* @__PURE__ */ t("p", { children: "No datasets uploaded yet" }),
|
|
1254
|
+
/* @__PURE__ */ t("p", { className: "hint", children: "Upload CSV, JSON, or Parquet files to get started" })
|
|
1255
|
+
] }) : r.datasets.map((l) => /* @__PURE__ */ i(
|
|
1256
|
+
"div",
|
|
1257
|
+
{
|
|
1258
|
+
className: `dataset-card ${b === l.id ? "dataset-card--selected" : ""}`,
|
|
1259
|
+
onClick: () => I(l.id),
|
|
1260
|
+
children: [
|
|
1261
|
+
/* @__PURE__ */ i("div", { className: "card-header", children: [
|
|
1262
|
+
/* @__PURE__ */ t("span", { className: "dataset-icon", children: "📁" }),
|
|
1263
|
+
/* @__PURE__ */ t("h3", { children: l.name }),
|
|
1264
|
+
/* @__PURE__ */ t(
|
|
1265
|
+
"button",
|
|
1266
|
+
{
|
|
1267
|
+
className: "remove-button",
|
|
1268
|
+
onClick: (m) => {
|
|
1269
|
+
m.stopPropagation(), L(l.id);
|
|
1270
|
+
},
|
|
1271
|
+
children: "×"
|
|
1272
|
+
}
|
|
1273
|
+
)
|
|
1274
|
+
] }),
|
|
1275
|
+
/* @__PURE__ */ i("div", { className: "card-stats", children: [
|
|
1276
|
+
/* @__PURE__ */ i("span", { children: [
|
|
1277
|
+
l.rowCount.toLocaleString(),
|
|
1278
|
+
" rows"
|
|
1279
|
+
] }),
|
|
1280
|
+
/* @__PURE__ */ i("span", { children: [
|
|
1281
|
+
l.columns.length,
|
|
1282
|
+
" columns"
|
|
1283
|
+
] }),
|
|
1284
|
+
/* @__PURE__ */ t("span", { children: V(l.size) })
|
|
1285
|
+
] }),
|
|
1286
|
+
/* @__PURE__ */ t("div", { className: "splits-bar", children: l.splits.map((m) => /* @__PURE__ */ t(
|
|
1287
|
+
"div",
|
|
1288
|
+
{
|
|
1289
|
+
className: `split split--${m.name}`,
|
|
1290
|
+
style: { width: `${m.ratio * 100}%` },
|
|
1291
|
+
title: `${m.name}: ${(m.ratio * 100).toFixed(0)}%`
|
|
1292
|
+
},
|
|
1293
|
+
m.name
|
|
1294
|
+
)) })
|
|
1295
|
+
]
|
|
1296
|
+
},
|
|
1297
|
+
l.id
|
|
1298
|
+
)) }),
|
|
1299
|
+
b && /* @__PURE__ */ t("div", { className: "dataset-details", children: (() => {
|
|
1300
|
+
const l = r.datasets.find((m) => m.id === b);
|
|
1301
|
+
return l ? /* @__PURE__ */ i(ne, { children: [
|
|
1302
|
+
/* @__PURE__ */ t("h3", { children: "Columns" }),
|
|
1303
|
+
/* @__PURE__ */ i("table", { className: "columns-table", children: [
|
|
1304
|
+
/* @__PURE__ */ t("thead", { children: /* @__PURE__ */ i("tr", { children: [
|
|
1305
|
+
/* @__PURE__ */ t("th", { children: "Name" }),
|
|
1306
|
+
/* @__PURE__ */ t("th", { children: "Type" }),
|
|
1307
|
+
/* @__PURE__ */ t("th", { children: "Missing" }),
|
|
1308
|
+
/* @__PURE__ */ t("th", { children: "Unique" })
|
|
1309
|
+
] }) }),
|
|
1310
|
+
/* @__PURE__ */ t("tbody", { children: l.columns.map((m) => /* @__PURE__ */ i("tr", { children: [
|
|
1311
|
+
/* @__PURE__ */ t("td", { children: m.name }),
|
|
1312
|
+
/* @__PURE__ */ t("td", { children: /* @__PURE__ */ i(
|
|
1313
|
+
"select",
|
|
1314
|
+
{
|
|
1315
|
+
value: m.type,
|
|
1316
|
+
onChange: (T) => {
|
|
1317
|
+
f({
|
|
1318
|
+
datasets: r.datasets.map(
|
|
1319
|
+
(w) => w.id === l.id ? {
|
|
1320
|
+
...w,
|
|
1321
|
+
columns: w.columns.map(
|
|
1322
|
+
(z) => z.name === m.name ? {
|
|
1323
|
+
...z,
|
|
1324
|
+
type: T.target.value
|
|
1325
|
+
} : z
|
|
1326
|
+
)
|
|
1327
|
+
} : w
|
|
1328
|
+
)
|
|
1329
|
+
});
|
|
1330
|
+
},
|
|
1331
|
+
children: [
|
|
1332
|
+
/* @__PURE__ */ t("option", { value: "numeric", children: "Numeric" }),
|
|
1333
|
+
/* @__PURE__ */ t("option", { value: "categorical", children: "Categorical" }),
|
|
1334
|
+
/* @__PURE__ */ t("option", { value: "text", children: "Text" }),
|
|
1335
|
+
/* @__PURE__ */ t("option", { value: "datetime", children: "DateTime" }),
|
|
1336
|
+
/* @__PURE__ */ t("option", { value: "boolean", children: "Boolean" })
|
|
1337
|
+
]
|
|
1338
|
+
}
|
|
1339
|
+
) }),
|
|
1340
|
+
/* @__PURE__ */ t("td", { children: m.missing }),
|
|
1341
|
+
/* @__PURE__ */ t("td", { children: m.unique })
|
|
1342
|
+
] }, m.name)) })
|
|
1343
|
+
] })
|
|
1344
|
+
] }) : null;
|
|
1345
|
+
})() })
|
|
1346
|
+
] }),
|
|
1347
|
+
C === "experiments" && /* @__PURE__ */ i("div", { className: "experiments-panel", children: [
|
|
1348
|
+
/* @__PURE__ */ i("div", { className: "panel-header", children: [
|
|
1349
|
+
/* @__PURE__ */ t("h2", { children: "Experiments" }),
|
|
1350
|
+
/* @__PURE__ */ t(
|
|
1351
|
+
"button",
|
|
1352
|
+
{
|
|
1353
|
+
className: "primary-button",
|
|
1354
|
+
onClick: () => U(!0),
|
|
1355
|
+
disabled: r.datasets.length === 0,
|
|
1356
|
+
children: "+ New Experiment"
|
|
1357
|
+
}
|
|
1358
|
+
)
|
|
1359
|
+
] }),
|
|
1360
|
+
N && /* @__PURE__ */ i("div", { className: "new-experiment-form", children: [
|
|
1361
|
+
/* @__PURE__ */ t("h3", { children: "Configure Experiment" }),
|
|
1362
|
+
/* @__PURE__ */ i("div", { className: "form-grid", children: [
|
|
1363
|
+
/* @__PURE__ */ i("label", { children: [
|
|
1364
|
+
"Dataset",
|
|
1365
|
+
/* @__PURE__ */ i(
|
|
1366
|
+
"select",
|
|
1367
|
+
{
|
|
1368
|
+
value: b || "",
|
|
1369
|
+
onChange: (l) => I(l.target.value),
|
|
1370
|
+
children: [
|
|
1371
|
+
/* @__PURE__ */ t("option", { value: "", children: "Select dataset..." }),
|
|
1372
|
+
r.datasets.map((l) => /* @__PURE__ */ t("option", { value: l.id, children: l.name }, l.id))
|
|
1373
|
+
]
|
|
1374
|
+
}
|
|
1375
|
+
)
|
|
1376
|
+
] }),
|
|
1377
|
+
/* @__PURE__ */ i("label", { children: [
|
|
1378
|
+
"Algorithm",
|
|
1379
|
+
/* @__PURE__ */ i(
|
|
1380
|
+
"select",
|
|
1381
|
+
{
|
|
1382
|
+
value: h.algorithm,
|
|
1383
|
+
onChange: (l) => v({ ...h, algorithm: l.target.value }),
|
|
1384
|
+
children: [
|
|
1385
|
+
/* @__PURE__ */ t("option", { value: "", children: "Select algorithm..." }),
|
|
1386
|
+
(re[r.type] || re.classification).map((l) => /* @__PURE__ */ t("option", { value: l.id, children: l.name }, l.id))
|
|
1387
|
+
]
|
|
1388
|
+
}
|
|
1389
|
+
)
|
|
1390
|
+
] }),
|
|
1391
|
+
b && /* @__PURE__ */ i("label", { children: [
|
|
1392
|
+
"Target Column",
|
|
1393
|
+
/* @__PURE__ */ i(
|
|
1394
|
+
"select",
|
|
1395
|
+
{
|
|
1396
|
+
value: h.targetColumn || "",
|
|
1397
|
+
onChange: (l) => v({ ...h, targetColumn: l.target.value }),
|
|
1398
|
+
children: [
|
|
1399
|
+
/* @__PURE__ */ t("option", { value: "", children: "Select target..." }),
|
|
1400
|
+
(y = r.datasets.find((l) => l.id === b)) == null ? void 0 : y.columns.map((l) => /* @__PURE__ */ t("option", { value: l.name, children: l.name }, l.name))
|
|
1401
|
+
]
|
|
1402
|
+
}
|
|
1403
|
+
)
|
|
1404
|
+
] })
|
|
1405
|
+
] }),
|
|
1406
|
+
/* @__PURE__ */ i("div", { className: "form-actions", children: [
|
|
1407
|
+
/* @__PURE__ */ t("button", { className: "secondary-button", onClick: () => U(!1), children: "Cancel" }),
|
|
1408
|
+
/* @__PURE__ */ t(
|
|
1409
|
+
"button",
|
|
1410
|
+
{
|
|
1411
|
+
className: "primary-button",
|
|
1412
|
+
onClick: P,
|
|
1413
|
+
disabled: !h.algorithm || !b,
|
|
1414
|
+
children: "Run Experiment"
|
|
1415
|
+
}
|
|
1416
|
+
)
|
|
1417
|
+
] })
|
|
1418
|
+
] }),
|
|
1419
|
+
/* @__PURE__ */ t("div", { className: "experiments-list", children: r.experiments.length === 0 ? /* @__PURE__ */ i("div", { className: "empty-state", children: [
|
|
1420
|
+
/* @__PURE__ */ t("span", { className: "icon", children: "🧪" }),
|
|
1421
|
+
/* @__PURE__ */ t("p", { children: "No experiments yet" }),
|
|
1422
|
+
/* @__PURE__ */ t("p", { className: "hint", children: "Create an experiment to train and evaluate models" })
|
|
1423
|
+
] }) : r.experiments.map((l) => /* @__PURE__ */ i(
|
|
1424
|
+
"div",
|
|
1425
|
+
{
|
|
1426
|
+
className: `experiment-card ${E === l.id ? "experiment-card--selected" : ""}`,
|
|
1427
|
+
onClick: () => R(l.id),
|
|
1428
|
+
children: [
|
|
1429
|
+
/* @__PURE__ */ i("div", { className: "card-header", children: [
|
|
1430
|
+
/* @__PURE__ */ t("h3", { children: l.name }),
|
|
1431
|
+
/* @__PURE__ */ t("span", { className: `status-badge ${G(l.status)}`, children: l.status })
|
|
1432
|
+
] }),
|
|
1433
|
+
/* @__PURE__ */ i("div", { className: "card-meta", children: [
|
|
1434
|
+
/* @__PURE__ */ i("span", { children: [
|
|
1435
|
+
"Algorithm: ",
|
|
1436
|
+
l.config.algorithm
|
|
1437
|
+
] }),
|
|
1438
|
+
l.duration && /* @__PURE__ */ i("span", { children: [
|
|
1439
|
+
"Duration: ",
|
|
1440
|
+
Math.round(l.duration),
|
|
1441
|
+
"s"
|
|
1442
|
+
] })
|
|
1443
|
+
] }),
|
|
1444
|
+
l.metrics.length > 0 && /* @__PURE__ */ t("div", { className: "metrics-row", children: l.metrics.slice(0, 3).map((m) => /* @__PURE__ */ i("div", { className: "metric-item", children: [
|
|
1445
|
+
/* @__PURE__ */ t("span", { className: "metric-name", children: m.name }),
|
|
1446
|
+
/* @__PURE__ */ i("span", { className: "metric-value", children: [
|
|
1447
|
+
(m.value * 100).toFixed(1),
|
|
1448
|
+
"%"
|
|
1449
|
+
] })
|
|
1450
|
+
] }, m.name)) }),
|
|
1451
|
+
l.status === "completed" && /* @__PURE__ */ t(
|
|
1452
|
+
"button",
|
|
1453
|
+
{
|
|
1454
|
+
className: "action-button",
|
|
1455
|
+
onClick: (m) => {
|
|
1456
|
+
m.stopPropagation(), j(l.id);
|
|
1457
|
+
},
|
|
1458
|
+
children: "Register Model"
|
|
1459
|
+
}
|
|
1460
|
+
)
|
|
1461
|
+
]
|
|
1462
|
+
},
|
|
1463
|
+
l.id
|
|
1464
|
+
)) })
|
|
1465
|
+
] }),
|
|
1466
|
+
C === "models" && /* @__PURE__ */ i("div", { className: "models-panel", children: [
|
|
1467
|
+
/* @__PURE__ */ t("div", { className: "panel-header", children: /* @__PURE__ */ t("h2", { children: "Models" }) }),
|
|
1468
|
+
/* @__PURE__ */ t("div", { className: "models-list", children: r.models.length === 0 ? /* @__PURE__ */ i("div", { className: "empty-state", children: [
|
|
1469
|
+
/* @__PURE__ */ t("span", { className: "icon", children: "🤖" }),
|
|
1470
|
+
/* @__PURE__ */ t("p", { children: "No models registered yet" }),
|
|
1471
|
+
/* @__PURE__ */ t("p", { className: "hint", children: "Complete experiments and register models" })
|
|
1472
|
+
] }) : r.models.map((l) => /* @__PURE__ */ i(
|
|
1473
|
+
"div",
|
|
1474
|
+
{
|
|
1475
|
+
className: `model-card ${$ === l.id ? "model-card--selected" : ""}`,
|
|
1476
|
+
onClick: () => O(l.id),
|
|
1477
|
+
children: [
|
|
1478
|
+
/* @__PURE__ */ i("div", { className: "card-header", children: [
|
|
1479
|
+
/* @__PURE__ */ t("h3", { children: l.name }),
|
|
1480
|
+
/* @__PURE__ */ t("span", { className: `status-badge ${G(l.status)}`, children: l.status })
|
|
1481
|
+
] }),
|
|
1482
|
+
/* @__PURE__ */ i("div", { className: "card-meta", children: [
|
|
1483
|
+
/* @__PURE__ */ i("span", { children: [
|
|
1484
|
+
"Algorithm: ",
|
|
1485
|
+
l.algorithm
|
|
1486
|
+
] }),
|
|
1487
|
+
/* @__PURE__ */ i("span", { children: [
|
|
1488
|
+
"Version: ",
|
|
1489
|
+
l.version
|
|
1490
|
+
] }),
|
|
1491
|
+
/* @__PURE__ */ i("span", { children: [
|
|
1492
|
+
"Size: ",
|
|
1493
|
+
V(l.size)
|
|
1494
|
+
] })
|
|
1495
|
+
] }),
|
|
1496
|
+
l.metrics.length > 0 && /* @__PURE__ */ t("div", { className: "metrics-row", children: l.metrics.slice(0, 3).map((m) => /* @__PURE__ */ i("div", { className: "metric-item", children: [
|
|
1497
|
+
/* @__PURE__ */ t("span", { className: "metric-name", children: m.name }),
|
|
1498
|
+
/* @__PURE__ */ i("span", { className: "metric-value", children: [
|
|
1499
|
+
(m.value * 100).toFixed(1),
|
|
1500
|
+
"%"
|
|
1501
|
+
] })
|
|
1502
|
+
] }, m.name)) }),
|
|
1503
|
+
/* @__PURE__ */ i("div", { className: "card-actions", children: [
|
|
1504
|
+
/* @__PURE__ */ t("button", { className: "action-button", children: "Download" }),
|
|
1505
|
+
/* @__PURE__ */ t(
|
|
1506
|
+
"button",
|
|
1507
|
+
{
|
|
1508
|
+
className: "action-button action-button--primary",
|
|
1509
|
+
onClick: (m) => {
|
|
1510
|
+
m.stopPropagation(), _(l.id);
|
|
1511
|
+
},
|
|
1512
|
+
disabled: l.status === "production",
|
|
1513
|
+
children: l.status === "production" ? "Deployed" : "Deploy"
|
|
1514
|
+
}
|
|
1515
|
+
)
|
|
1516
|
+
] })
|
|
1517
|
+
]
|
|
1518
|
+
},
|
|
1519
|
+
l.id
|
|
1520
|
+
)) })
|
|
1521
|
+
] }),
|
|
1522
|
+
C === "deploy" && /* @__PURE__ */ i("div", { className: "deploy-panel", children: [
|
|
1523
|
+
/* @__PURE__ */ t("div", { className: "panel-header", children: /* @__PURE__ */ t("h2", { children: "Deployments" }) }),
|
|
1524
|
+
/* @__PURE__ */ t("div", { className: "deployments-list", children: r.models.filter((l) => l.deployments.length > 0).length === 0 ? /* @__PURE__ */ i("div", { className: "empty-state", children: [
|
|
1525
|
+
/* @__PURE__ */ t("span", { className: "icon", children: "🚀" }),
|
|
1526
|
+
/* @__PURE__ */ t("p", { children: "No deployments yet" }),
|
|
1527
|
+
/* @__PURE__ */ t("p", { className: "hint", children: "Deploy a model to create inference endpoints" })
|
|
1528
|
+
] }) : r.models.filter((l) => l.deployments.length > 0).flatMap((l) => l.deployments.map((m) => ({ model: l, deployment: m }))).map(({ model: l, deployment: m }) => /* @__PURE__ */ i("div", { className: "deployment-card", children: [
|
|
1529
|
+
/* @__PURE__ */ i("div", { className: "card-header", children: [
|
|
1530
|
+
/* @__PURE__ */ t("h3", { children: m.name }),
|
|
1531
|
+
/* @__PURE__ */ t("span", { className: `status-badge ${G(m.status)}`, children: m.status })
|
|
1532
|
+
] }),
|
|
1533
|
+
/* @__PURE__ */ i("div", { className: "card-meta", children: [
|
|
1534
|
+
/* @__PURE__ */ i("span", { children: [
|
|
1535
|
+
"Model: ",
|
|
1536
|
+
l.name
|
|
1537
|
+
] }),
|
|
1538
|
+
/* @__PURE__ */ i("span", { children: [
|
|
1539
|
+
"Endpoint: ",
|
|
1540
|
+
m.endpoint
|
|
1541
|
+
] })
|
|
1542
|
+
] }),
|
|
1543
|
+
/* @__PURE__ */ i("div", { className: "resources-info", children: [
|
|
1544
|
+
/* @__PURE__ */ i("span", { children: [
|
|
1545
|
+
"CPU: ",
|
|
1546
|
+
m.resources.cpu,
|
|
1547
|
+
" cores"
|
|
1548
|
+
] }),
|
|
1549
|
+
/* @__PURE__ */ i("span", { children: [
|
|
1550
|
+
"Memory: ",
|
|
1551
|
+
m.resources.memory,
|
|
1552
|
+
" GB"
|
|
1553
|
+
] }),
|
|
1554
|
+
/* @__PURE__ */ i("span", { children: [
|
|
1555
|
+
"Replicas: ",
|
|
1556
|
+
m.resources.replicas
|
|
1557
|
+
] })
|
|
1558
|
+
] })
|
|
1559
|
+
] }, m.id)) })
|
|
1560
|
+
] })
|
|
1561
|
+
] })
|
|
1562
|
+
] });
|
|
1563
|
+
}, qe = {
|
|
1564
|
+
id: crypto.randomUUID(),
|
|
1565
|
+
name: "New Labeling Project",
|
|
1566
|
+
type: "classification",
|
|
1567
|
+
dataType: "image",
|
|
1568
|
+
status: "setup",
|
|
1569
|
+
labelSchema: {
|
|
1570
|
+
classes: [],
|
|
1571
|
+
attributes: []
|
|
1572
|
+
},
|
|
1573
|
+
items: [],
|
|
1574
|
+
collaborators: [],
|
|
1575
|
+
statistics: {
|
|
1576
|
+
totalItems: 0,
|
|
1577
|
+
labeled: 0,
|
|
1578
|
+
reviewed: 0,
|
|
1579
|
+
approved: 0,
|
|
1580
|
+
byClass: []
|
|
1581
|
+
},
|
|
1582
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
1583
|
+
}, se = [
|
|
1584
|
+
"#ef4444",
|
|
1585
|
+
"#f97316",
|
|
1586
|
+
"#f59e0b",
|
|
1587
|
+
"#84cc16",
|
|
1588
|
+
"#22c55e",
|
|
1589
|
+
"#14b8a6",
|
|
1590
|
+
"#06b6d4",
|
|
1591
|
+
"#3b82f6",
|
|
1592
|
+
"#6366f1",
|
|
1593
|
+
"#8b5cf6",
|
|
1594
|
+
"#a855f7",
|
|
1595
|
+
"#d946ef",
|
|
1596
|
+
"#ec4899",
|
|
1597
|
+
"#f43f5e"
|
|
1598
|
+
], ba = ({
|
|
1599
|
+
project: n,
|
|
1600
|
+
onProjectChange: e,
|
|
1601
|
+
onLabelSave: a,
|
|
1602
|
+
onExport: c,
|
|
1603
|
+
className: d = ""
|
|
1604
|
+
}) => {
|
|
1605
|
+
var ee;
|
|
1606
|
+
const [r, x] = p(n || qe), [C, S] = p("label"), [b, I] = p(0), [E, R] = p(null), [$, O] = p("select"), [N, U] = p(!1), [h, v] = p(null), [f, D] = p(1), [L, P] = p(!1), [j, _] = p("all"), V = Q(null), G = Q(null), y = r.items[b];
|
|
1607
|
+
Z(() => {
|
|
1608
|
+
n && x(n);
|
|
1609
|
+
}, [n]);
|
|
1610
|
+
const l = X(
|
|
1611
|
+
(s) => {
|
|
1612
|
+
const u = { ...r, ...s };
|
|
1613
|
+
u.statistics = {
|
|
1614
|
+
totalItems: u.items.length,
|
|
1615
|
+
labeled: u.items.filter((g) => g.status !== "pending").length,
|
|
1616
|
+
reviewed: u.items.filter((g) => g.status === "review" || g.status === "approved").length,
|
|
1617
|
+
approved: u.items.filter((g) => g.status === "approved").length,
|
|
1618
|
+
byClass: u.labelSchema.classes.map((g) => ({
|
|
1619
|
+
classId: g.id,
|
|
1620
|
+
count: u.items.flatMap((A) => A.labels).filter((A) => A.classId === g.id).length
|
|
1621
|
+
}))
|
|
1622
|
+
}, x(u), e == null || e(u);
|
|
1623
|
+
},
|
|
1624
|
+
[r, e]
|
|
1625
|
+
), m = () => {
|
|
1626
|
+
const s = {
|
|
1627
|
+
id: crypto.randomUUID(),
|
|
1628
|
+
name: `Class ${r.labelSchema.classes.length + 1}`,
|
|
1629
|
+
color: se[r.labelSchema.classes.length % se.length],
|
|
1630
|
+
shortcut: String(r.labelSchema.classes.length + 1)
|
|
1631
|
+
};
|
|
1632
|
+
l({
|
|
1633
|
+
labelSchema: {
|
|
1634
|
+
...r.labelSchema,
|
|
1635
|
+
classes: [...r.labelSchema.classes, s]
|
|
1636
|
+
}
|
|
1637
|
+
});
|
|
1638
|
+
}, T = (s) => {
|
|
1639
|
+
l({
|
|
1640
|
+
labelSchema: {
|
|
1641
|
+
...r.labelSchema,
|
|
1642
|
+
classes: r.labelSchema.classes.filter((u) => u.id !== s)
|
|
1643
|
+
},
|
|
1644
|
+
items: r.items.map((u) => ({
|
|
1645
|
+
...u,
|
|
1646
|
+
labels: u.labels.filter((g) => g.classId !== s)
|
|
1647
|
+
}))
|
|
1648
|
+
});
|
|
1649
|
+
}, w = (s, u) => {
|
|
1650
|
+
l({
|
|
1651
|
+
labelSchema: {
|
|
1652
|
+
...r.labelSchema,
|
|
1653
|
+
classes: r.labelSchema.classes.map(
|
|
1654
|
+
(g) => g.id === s ? { ...g, ...u } : g
|
|
1655
|
+
)
|
|
1656
|
+
}
|
|
1657
|
+
});
|
|
1658
|
+
}, z = (s, u) => {
|
|
1659
|
+
if (!y) return;
|
|
1660
|
+
const g = {
|
|
1661
|
+
id: crypto.randomUUID(),
|
|
1662
|
+
classId: s,
|
|
1663
|
+
type: r.type === "classification" ? "class" : r.type === "bounding-box" ? "bbox" : "class",
|
|
1664
|
+
data: u || {},
|
|
1665
|
+
createdBy: "current-user",
|
|
1666
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
1667
|
+
}, A = {
|
|
1668
|
+
...y,
|
|
1669
|
+
labels: [...y.labels, g],
|
|
1670
|
+
status: "labeled"
|
|
1671
|
+
};
|
|
1672
|
+
l({
|
|
1673
|
+
items: r.items.map((H) => H.id === y.id ? A : H)
|
|
1674
|
+
}), a == null || a(A);
|
|
1675
|
+
}, W = (s) => {
|
|
1676
|
+
if (!y) return;
|
|
1677
|
+
const u = {
|
|
1678
|
+
...y,
|
|
1679
|
+
labels: y.labels.filter((g) => g.id !== s),
|
|
1680
|
+
status: y.labels.length <= 1 ? "pending" : "labeled"
|
|
1681
|
+
};
|
|
1682
|
+
l({
|
|
1683
|
+
items: r.items.map((g) => g.id === y.id ? u : g)
|
|
1684
|
+
});
|
|
1685
|
+
}, Y = (s) => {
|
|
1686
|
+
var H;
|
|
1687
|
+
if ($ !== "bbox" || !E) return;
|
|
1688
|
+
const u = (H = V.current) == null ? void 0 : H.getBoundingClientRect();
|
|
1689
|
+
if (!u) return;
|
|
1690
|
+
const g = (s.clientX - u.left) / f, A = (s.clientY - u.top) / f;
|
|
1691
|
+
U(!0), v({ x: g, y: A, width: 0, height: 0 });
|
|
1692
|
+
}, te = (s) => {
|
|
1693
|
+
var H;
|
|
1694
|
+
if (!N || !h) return;
|
|
1695
|
+
const u = (H = V.current) == null ? void 0 : H.getBoundingClientRect();
|
|
1696
|
+
if (!u) return;
|
|
1697
|
+
const g = (s.clientX - u.left) / f, A = (s.clientY - u.top) / f;
|
|
1698
|
+
v({
|
|
1699
|
+
...h,
|
|
1700
|
+
width: g - h.x,
|
|
1701
|
+
height: A - h.y
|
|
1702
|
+
});
|
|
1703
|
+
}, o = () => {
|
|
1704
|
+
!N || !h || !E || (U(!1), Math.abs(h.width) > 10 && Math.abs(h.height) > 10 && z(E, {
|
|
1705
|
+
x: h.width < 0 ? h.x + h.width : h.x,
|
|
1706
|
+
y: h.height < 0 ? h.y + h.height : h.y,
|
|
1707
|
+
width: Math.abs(h.width),
|
|
1708
|
+
height: Math.abs(h.height)
|
|
1709
|
+
}), v(null));
|
|
1710
|
+
}, k = (s) => {
|
|
1711
|
+
const u = j === "all" ? r.items : r.items.filter((A) => A.status === j), g = u.findIndex((A) => A.id === (y == null ? void 0 : y.id));
|
|
1712
|
+
if (s === "prev" && g > 0) {
|
|
1713
|
+
const A = u[g - 1];
|
|
1714
|
+
I(r.items.findIndex((H) => H.id === A.id));
|
|
1715
|
+
} else if (s === "next" && g < u.length - 1) {
|
|
1716
|
+
const A = u[g + 1];
|
|
1717
|
+
I(r.items.findIndex((H) => H.id === A.id));
|
|
1718
|
+
}
|
|
1719
|
+
}, q = () => {
|
|
1720
|
+
if (!y) return;
|
|
1721
|
+
const s = {
|
|
1722
|
+
...y,
|
|
1723
|
+
status: "approved"
|
|
1724
|
+
};
|
|
1725
|
+
l({
|
|
1726
|
+
items: r.items.map((u) => u.id === y.id ? s : u)
|
|
1727
|
+
}), k("next");
|
|
1728
|
+
}, J = () => {
|
|
1729
|
+
if (!y) return;
|
|
1730
|
+
const s = {
|
|
1731
|
+
...y,
|
|
1732
|
+
status: "rejected"
|
|
1733
|
+
};
|
|
1734
|
+
l({
|
|
1735
|
+
items: r.items.map((u) => u.id === y.id ? s : u)
|
|
1736
|
+
}), k("next");
|
|
1737
|
+
}, M = async (s) => {
|
|
1738
|
+
c && await c(s);
|
|
1739
|
+
};
|
|
1740
|
+
Z(() => {
|
|
1741
|
+
const s = (u) => {
|
|
1742
|
+
const g = u.key, A = r.labelSchema.classes.find((H) => H.shortcut === g);
|
|
1743
|
+
A && (r.type === "classification" ? (z(A.id), k("next")) : R(A.id)), u.key === "ArrowLeft" || u.key === "a" ? k("prev") : (u.key === "ArrowRight" || u.key === "d") && k("next"), u.key === "Enter" ? q() : u.key === "Backspace" && J();
|
|
1744
|
+
};
|
|
1745
|
+
return window.addEventListener("keydown", s), () => window.removeEventListener("keydown", s);
|
|
1746
|
+
}, [y, r.labelSchema.classes, r.type]);
|
|
1747
|
+
const K = (s) => {
|
|
1748
|
+
switch (s) {
|
|
1749
|
+
case "approved":
|
|
1750
|
+
return "#22c55e";
|
|
1751
|
+
case "labeled":
|
|
1752
|
+
return "#3b82f6";
|
|
1753
|
+
case "review":
|
|
1754
|
+
return "#f59e0b";
|
|
1755
|
+
case "rejected":
|
|
1756
|
+
return "#ef4444";
|
|
1757
|
+
default:
|
|
1758
|
+
return "#6b7280";
|
|
1759
|
+
}
|
|
1760
|
+
};
|
|
1761
|
+
return /* @__PURE__ */ i("div", { className: `nice-data-labeler ${d}`, children: [
|
|
1762
|
+
/* @__PURE__ */ i("header", { className: "labeler__header", children: [
|
|
1763
|
+
/* @__PURE__ */ i("div", { className: "header__info", children: [
|
|
1764
|
+
/* @__PURE__ */ t(
|
|
1765
|
+
"input",
|
|
1766
|
+
{
|
|
1767
|
+
type: "text",
|
|
1768
|
+
value: r.name,
|
|
1769
|
+
onChange: (s) => l({ name: s.target.value }),
|
|
1770
|
+
className: "project-name-input"
|
|
1771
|
+
}
|
|
1772
|
+
),
|
|
1773
|
+
/* @__PURE__ */ i("div", { className: "progress-bar", children: [
|
|
1774
|
+
/* @__PURE__ */ t(
|
|
1775
|
+
"div",
|
|
1776
|
+
{
|
|
1777
|
+
className: "progress-fill",
|
|
1778
|
+
style: {
|
|
1779
|
+
width: `${r.statistics.labeled / Math.max(r.statistics.totalItems, 1) * 100}%`
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
),
|
|
1783
|
+
/* @__PURE__ */ i("span", { className: "progress-text", children: [
|
|
1784
|
+
r.statistics.labeled,
|
|
1785
|
+
" / ",
|
|
1786
|
+
r.statistics.totalItems,
|
|
1787
|
+
" labeled"
|
|
1788
|
+
] })
|
|
1789
|
+
] })
|
|
1790
|
+
] }),
|
|
1791
|
+
/* @__PURE__ */ t("div", { className: "header__tabs", children: ["label", "schema", "review", "export"].map((s) => /* @__PURE__ */ t(
|
|
1792
|
+
"button",
|
|
1793
|
+
{
|
|
1794
|
+
className: `tab-button ${C === s ? "tab-button--active" : ""}`,
|
|
1795
|
+
onClick: () => S(s),
|
|
1796
|
+
children: s.charAt(0).toUpperCase() + s.slice(1)
|
|
1797
|
+
},
|
|
1798
|
+
s
|
|
1799
|
+
)) }),
|
|
1800
|
+
/* @__PURE__ */ t("button", { className: "shortcuts-button", onClick: () => P(!L), children: "⌨️ Shortcuts" })
|
|
1801
|
+
] }),
|
|
1802
|
+
/* @__PURE__ */ i("div", { className: "labeler__content", children: [
|
|
1803
|
+
C === "label" && /* @__PURE__ */ i("div", { className: "label-panel", children: [
|
|
1804
|
+
/* @__PURE__ */ i("div", { className: "label-toolbar", children: [
|
|
1805
|
+
/* @__PURE__ */ i("div", { className: "tool-group", children: [
|
|
1806
|
+
/* @__PURE__ */ t(
|
|
1807
|
+
"button",
|
|
1808
|
+
{
|
|
1809
|
+
className: `tool-button ${$ === "select" ? "tool-button--active" : ""}`,
|
|
1810
|
+
onClick: () => O("select"),
|
|
1811
|
+
children: "↖️ Select"
|
|
1812
|
+
}
|
|
1813
|
+
),
|
|
1814
|
+
(r.type === "bounding-box" || r.type === "multi-label") && /* @__PURE__ */ t(
|
|
1815
|
+
"button",
|
|
1816
|
+
{
|
|
1817
|
+
className: `tool-button ${$ === "bbox" ? "tool-button--active" : ""}`,
|
|
1818
|
+
onClick: () => O("bbox"),
|
|
1819
|
+
children: "⬜ Box"
|
|
1820
|
+
}
|
|
1821
|
+
),
|
|
1822
|
+
r.type === "polygon" && /* @__PURE__ */ t(
|
|
1823
|
+
"button",
|
|
1824
|
+
{
|
|
1825
|
+
className: `tool-button ${$ === "polygon" ? "tool-button--active" : ""}`,
|
|
1826
|
+
onClick: () => O("polygon"),
|
|
1827
|
+
children: "⬡ Polygon"
|
|
1828
|
+
}
|
|
1829
|
+
)
|
|
1830
|
+
] }),
|
|
1831
|
+
/* @__PURE__ */ i("div", { className: "zoom-group", children: [
|
|
1832
|
+
/* @__PURE__ */ t("button", { onClick: () => D(Math.max(0.25, f - 0.25)), children: "-" }),
|
|
1833
|
+
/* @__PURE__ */ i("span", { children: [
|
|
1834
|
+
Math.round(f * 100),
|
|
1835
|
+
"%"
|
|
1836
|
+
] }),
|
|
1837
|
+
/* @__PURE__ */ t("button", { onClick: () => D(Math.min(4, f + 0.25)), children: "+" })
|
|
1838
|
+
] }),
|
|
1839
|
+
/* @__PURE__ */ i("div", { className: "navigation-group", children: [
|
|
1840
|
+
/* @__PURE__ */ t("button", { onClick: () => k("prev"), disabled: b === 0, children: "← Prev" }),
|
|
1841
|
+
/* @__PURE__ */ i("span", { children: [
|
|
1842
|
+
b + 1,
|
|
1843
|
+
" / ",
|
|
1844
|
+
r.items.length
|
|
1845
|
+
] }),
|
|
1846
|
+
/* @__PURE__ */ t(
|
|
1847
|
+
"button",
|
|
1848
|
+
{
|
|
1849
|
+
onClick: () => k("next"),
|
|
1850
|
+
disabled: b >= r.items.length - 1,
|
|
1851
|
+
children: "Next →"
|
|
1852
|
+
}
|
|
1853
|
+
)
|
|
1854
|
+
] })
|
|
1855
|
+
] }),
|
|
1856
|
+
/* @__PURE__ */ i("div", { className: "label-workspace", children: [
|
|
1857
|
+
/* @__PURE__ */ t("div", { className: "canvas-container", ref: G, children: y ? /* @__PURE__ */ i(ne, { children: [
|
|
1858
|
+
y.data.type === "image" && /* @__PURE__ */ i(ne, { children: [
|
|
1859
|
+
/* @__PURE__ */ t(
|
|
1860
|
+
"img",
|
|
1861
|
+
{
|
|
1862
|
+
src: y.data.url,
|
|
1863
|
+
alt: "Labeling item",
|
|
1864
|
+
className: "labeling-image",
|
|
1865
|
+
style: { transform: `scale(${f})` }
|
|
1866
|
+
}
|
|
1867
|
+
),
|
|
1868
|
+
/* @__PURE__ */ t(
|
|
1869
|
+
"canvas",
|
|
1870
|
+
{
|
|
1871
|
+
ref: V,
|
|
1872
|
+
className: "labeling-canvas",
|
|
1873
|
+
onMouseDown: Y,
|
|
1874
|
+
onMouseMove: te,
|
|
1875
|
+
onMouseUp: o,
|
|
1876
|
+
onMouseLeave: o,
|
|
1877
|
+
style: {
|
|
1878
|
+
transform: `scale(${f})`,
|
|
1879
|
+
cursor: $ === "bbox" ? "crosshair" : "default"
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
),
|
|
1883
|
+
/* @__PURE__ */ i(
|
|
1884
|
+
"div",
|
|
1885
|
+
{
|
|
1886
|
+
className: "annotations-overlay",
|
|
1887
|
+
style: { transform: `scale(${f})` },
|
|
1888
|
+
children: [
|
|
1889
|
+
y.labels.filter((s) => s.type === "bbox" && s.data.x !== void 0).map((s) => {
|
|
1890
|
+
const u = r.labelSchema.classes.find(
|
|
1891
|
+
(g) => g.id === s.classId
|
|
1892
|
+
);
|
|
1893
|
+
return /* @__PURE__ */ i(
|
|
1894
|
+
"div",
|
|
1895
|
+
{
|
|
1896
|
+
className: "bbox-annotation",
|
|
1897
|
+
style: {
|
|
1898
|
+
left: s.data.x,
|
|
1899
|
+
top: s.data.y,
|
|
1900
|
+
width: s.data.width,
|
|
1901
|
+
height: s.data.height,
|
|
1902
|
+
borderColor: (u == null ? void 0 : u.color) || "#ff0000"
|
|
1903
|
+
},
|
|
1904
|
+
children: [
|
|
1905
|
+
/* @__PURE__ */ t(
|
|
1906
|
+
"span",
|
|
1907
|
+
{
|
|
1908
|
+
className: "bbox-label",
|
|
1909
|
+
style: { backgroundColor: (u == null ? void 0 : u.color) || "#ff0000" },
|
|
1910
|
+
children: u == null ? void 0 : u.name
|
|
1911
|
+
}
|
|
1912
|
+
),
|
|
1913
|
+
/* @__PURE__ */ t(
|
|
1914
|
+
"button",
|
|
1915
|
+
{
|
|
1916
|
+
className: "bbox-remove",
|
|
1917
|
+
onClick: () => W(s.id),
|
|
1918
|
+
children: "×"
|
|
1919
|
+
}
|
|
1920
|
+
)
|
|
1921
|
+
]
|
|
1922
|
+
},
|
|
1923
|
+
s.id
|
|
1924
|
+
);
|
|
1925
|
+
}),
|
|
1926
|
+
h && /* @__PURE__ */ t(
|
|
1927
|
+
"div",
|
|
1928
|
+
{
|
|
1929
|
+
className: "bbox-drawing",
|
|
1930
|
+
style: {
|
|
1931
|
+
left: h.width < 0 ? h.x + h.width : h.x,
|
|
1932
|
+
top: h.height < 0 ? h.y + h.height : h.y,
|
|
1933
|
+
width: Math.abs(h.width),
|
|
1934
|
+
height: Math.abs(h.height),
|
|
1935
|
+
borderColor: (ee = r.labelSchema.classes.find(
|
|
1936
|
+
(s) => s.id === E
|
|
1937
|
+
)) == null ? void 0 : ee.color
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
)
|
|
1941
|
+
]
|
|
1942
|
+
}
|
|
1943
|
+
)
|
|
1944
|
+
] }),
|
|
1945
|
+
y.data.type === "text" && /* @__PURE__ */ t("div", { className: "text-labeling", children: /* @__PURE__ */ t("p", { className: "text-content", children: y.data.text }) })
|
|
1946
|
+
] }) : /* @__PURE__ */ i("div", { className: "empty-state", children: [
|
|
1947
|
+
/* @__PURE__ */ t("span", { className: "icon", children: "📋" }),
|
|
1948
|
+
/* @__PURE__ */ t("p", { children: "No items to label" })
|
|
1949
|
+
] }) }),
|
|
1950
|
+
/* @__PURE__ */ i("aside", { className: "class-sidebar", children: [
|
|
1951
|
+
/* @__PURE__ */ t("h3", { children: "Classes" }),
|
|
1952
|
+
/* @__PURE__ */ t("div", { className: "class-list", children: r.labelSchema.classes.map((s) => /* @__PURE__ */ i(
|
|
1953
|
+
"button",
|
|
1954
|
+
{
|
|
1955
|
+
className: `class-button ${E === s.id ? "class-button--active" : ""}`,
|
|
1956
|
+
style: { borderLeftColor: s.color },
|
|
1957
|
+
onClick: () => {
|
|
1958
|
+
r.type === "classification" ? (z(s.id), k("next")) : R(s.id);
|
|
1959
|
+
},
|
|
1960
|
+
children: [
|
|
1961
|
+
/* @__PURE__ */ t("span", { className: "class-color", style: { backgroundColor: s.color } }),
|
|
1962
|
+
/* @__PURE__ */ t("span", { className: "class-name", children: s.name }),
|
|
1963
|
+
s.shortcut && /* @__PURE__ */ t("span", { className: "class-shortcut", children: s.shortcut })
|
|
1964
|
+
]
|
|
1965
|
+
},
|
|
1966
|
+
s.id
|
|
1967
|
+
)) }),
|
|
1968
|
+
y && y.labels.length > 0 && /* @__PURE__ */ i("div", { className: "current-labels", children: [
|
|
1969
|
+
/* @__PURE__ */ t("h4", { children: "Labels" }),
|
|
1970
|
+
y.labels.map((s) => {
|
|
1971
|
+
const u = r.labelSchema.classes.find((g) => g.id === s.classId);
|
|
1972
|
+
return /* @__PURE__ */ i("div", { className: "label-item", children: [
|
|
1973
|
+
/* @__PURE__ */ t("span", { className: "label-color", style: { backgroundColor: u == null ? void 0 : u.color } }),
|
|
1974
|
+
/* @__PURE__ */ t("span", { className: "label-name", children: u == null ? void 0 : u.name }),
|
|
1975
|
+
/* @__PURE__ */ t("button", { onClick: () => W(s.id), children: "×" })
|
|
1976
|
+
] }, s.id);
|
|
1977
|
+
})
|
|
1978
|
+
] }),
|
|
1979
|
+
C === "label" && y && /* @__PURE__ */ i("div", { className: "label-actions", children: [
|
|
1980
|
+
/* @__PURE__ */ t("button", { className: "approve-button", onClick: q, children: "✓ Approve" }),
|
|
1981
|
+
/* @__PURE__ */ t("button", { className: "reject-button", onClick: J, children: "✗ Reject" })
|
|
1982
|
+
] })
|
|
1983
|
+
] })
|
|
1984
|
+
] })
|
|
1985
|
+
] }),
|
|
1986
|
+
C === "schema" && /* @__PURE__ */ i("div", { className: "schema-panel", children: [
|
|
1987
|
+
/* @__PURE__ */ i("div", { className: "panel-header", children: [
|
|
1988
|
+
/* @__PURE__ */ t("h2", { children: "Label Schema" }),
|
|
1989
|
+
/* @__PURE__ */ t("button", { className: "primary-button", onClick: m, children: "+ Add Class" })
|
|
1990
|
+
] }),
|
|
1991
|
+
/* @__PURE__ */ i("div", { className: "schema-settings", children: [
|
|
1992
|
+
/* @__PURE__ */ i("label", { children: [
|
|
1993
|
+
"Labeling Type",
|
|
1994
|
+
/* @__PURE__ */ i(
|
|
1995
|
+
"select",
|
|
1996
|
+
{
|
|
1997
|
+
value: r.type,
|
|
1998
|
+
onChange: (s) => l({ type: s.target.value }),
|
|
1999
|
+
children: [
|
|
2000
|
+
/* @__PURE__ */ t("option", { value: "classification", children: "Single Classification" }),
|
|
2001
|
+
/* @__PURE__ */ t("option", { value: "multi-label", children: "Multi-Label Classification" }),
|
|
2002
|
+
/* @__PURE__ */ t("option", { value: "bounding-box", children: "Bounding Box" }),
|
|
2003
|
+
/* @__PURE__ */ t("option", { value: "polygon", children: "Polygon" }),
|
|
2004
|
+
/* @__PURE__ */ t("option", { value: "segmentation", children: "Segmentation" }),
|
|
2005
|
+
/* @__PURE__ */ t("option", { value: "ner", children: "Named Entity Recognition" })
|
|
2006
|
+
]
|
|
2007
|
+
}
|
|
2008
|
+
)
|
|
2009
|
+
] }),
|
|
2010
|
+
/* @__PURE__ */ i("label", { children: [
|
|
2011
|
+
"Data Type",
|
|
2012
|
+
/* @__PURE__ */ i(
|
|
2013
|
+
"select",
|
|
2014
|
+
{
|
|
2015
|
+
value: r.dataType,
|
|
2016
|
+
onChange: (s) => l({ dataType: s.target.value }),
|
|
2017
|
+
children: [
|
|
2018
|
+
/* @__PURE__ */ t("option", { value: "image", children: "Image" }),
|
|
2019
|
+
/* @__PURE__ */ t("option", { value: "text", children: "Text" }),
|
|
2020
|
+
/* @__PURE__ */ t("option", { value: "audio", children: "Audio" }),
|
|
2021
|
+
/* @__PURE__ */ t("option", { value: "video", children: "Video" })
|
|
2022
|
+
]
|
|
2023
|
+
}
|
|
2024
|
+
)
|
|
2025
|
+
] })
|
|
2026
|
+
] }),
|
|
2027
|
+
/* @__PURE__ */ t("div", { className: "classes-list", children: r.labelSchema.classes.map((s, u) => /* @__PURE__ */ i("div", { className: "class-editor", children: [
|
|
2028
|
+
/* @__PURE__ */ t(
|
|
2029
|
+
"input",
|
|
2030
|
+
{
|
|
2031
|
+
type: "color",
|
|
2032
|
+
value: s.color,
|
|
2033
|
+
onChange: (g) => w(s.id, { color: g.target.value }),
|
|
2034
|
+
className: "color-picker"
|
|
2035
|
+
}
|
|
2036
|
+
),
|
|
2037
|
+
/* @__PURE__ */ t(
|
|
2038
|
+
"input",
|
|
2039
|
+
{
|
|
2040
|
+
type: "text",
|
|
2041
|
+
value: s.name,
|
|
2042
|
+
onChange: (g) => w(s.id, { name: g.target.value }),
|
|
2043
|
+
className: "class-name-input",
|
|
2044
|
+
placeholder: "Class name"
|
|
2045
|
+
}
|
|
2046
|
+
),
|
|
2047
|
+
/* @__PURE__ */ t(
|
|
2048
|
+
"input",
|
|
2049
|
+
{
|
|
2050
|
+
type: "text",
|
|
2051
|
+
value: s.shortcut || "",
|
|
2052
|
+
onChange: (g) => w(s.id, { shortcut: g.target.value }),
|
|
2053
|
+
className: "shortcut-input",
|
|
2054
|
+
placeholder: "Key",
|
|
2055
|
+
maxLength: 1
|
|
2056
|
+
}
|
|
2057
|
+
),
|
|
2058
|
+
/* @__PURE__ */ t("button", { className: "remove-class-button", onClick: () => T(s.id), children: "🗑️" })
|
|
2059
|
+
] }, s.id)) }),
|
|
2060
|
+
/* @__PURE__ */ i("div", { className: "guidelines-section", children: [
|
|
2061
|
+
/* @__PURE__ */ t("h3", { children: "Labeling Guidelines" }),
|
|
2062
|
+
/* @__PURE__ */ t(
|
|
2063
|
+
"textarea",
|
|
2064
|
+
{
|
|
2065
|
+
value: r.guidelines || "",
|
|
2066
|
+
onChange: (s) => l({ guidelines: s.target.value }),
|
|
2067
|
+
placeholder: "Enter labeling guidelines for annotators...",
|
|
2068
|
+
rows: 6
|
|
2069
|
+
}
|
|
2070
|
+
)
|
|
2071
|
+
] })
|
|
2072
|
+
] }),
|
|
2073
|
+
C === "review" && /* @__PURE__ */ i("div", { className: "review-panel", children: [
|
|
2074
|
+
/* @__PURE__ */ i("div", { className: "panel-header", children: [
|
|
2075
|
+
/* @__PURE__ */ t("h2", { children: "Review Labels" }),
|
|
2076
|
+
/* @__PURE__ */ t("div", { className: "filter-group", children: /* @__PURE__ */ i(
|
|
2077
|
+
"select",
|
|
2078
|
+
{
|
|
2079
|
+
value: j,
|
|
2080
|
+
onChange: (s) => _(s.target.value),
|
|
2081
|
+
children: [
|
|
2082
|
+
/* @__PURE__ */ t("option", { value: "all", children: "All Items" }),
|
|
2083
|
+
/* @__PURE__ */ t("option", { value: "labeled", children: "Labeled" }),
|
|
2084
|
+
/* @__PURE__ */ t("option", { value: "review", children: "Needs Review" }),
|
|
2085
|
+
/* @__PURE__ */ t("option", { value: "approved", children: "Approved" }),
|
|
2086
|
+
/* @__PURE__ */ t("option", { value: "rejected", children: "Rejected" })
|
|
2087
|
+
]
|
|
2088
|
+
}
|
|
2089
|
+
) })
|
|
2090
|
+
] }),
|
|
2091
|
+
/* @__PURE__ */ t("div", { className: "items-grid", children: r.items.filter((s) => j === "all" || s.status === j).map((s, u) => {
|
|
2092
|
+
var g;
|
|
2093
|
+
return /* @__PURE__ */ i(
|
|
2094
|
+
"div",
|
|
2095
|
+
{
|
|
2096
|
+
className: `item-card ${b === r.items.indexOf(s) ? "item-card--active" : ""}`,
|
|
2097
|
+
onClick: () => {
|
|
2098
|
+
I(r.items.indexOf(s)), S("label");
|
|
2099
|
+
},
|
|
2100
|
+
children: [
|
|
2101
|
+
s.data.type === "image" && /* @__PURE__ */ t(
|
|
2102
|
+
"img",
|
|
2103
|
+
{
|
|
2104
|
+
src: s.data.url,
|
|
2105
|
+
alt: `Item ${u + 1}`,
|
|
2106
|
+
className: "item-thumbnail"
|
|
2107
|
+
}
|
|
2108
|
+
),
|
|
2109
|
+
s.data.type === "text" && /* @__PURE__ */ i("p", { className: "item-text-preview", children: [
|
|
2110
|
+
(g = s.data.text) == null ? void 0 : g.slice(0, 100),
|
|
2111
|
+
"..."
|
|
2112
|
+
] }),
|
|
2113
|
+
/* @__PURE__ */ i("div", { className: "item-footer", children: [
|
|
2114
|
+
/* @__PURE__ */ t(
|
|
2115
|
+
"span",
|
|
2116
|
+
{
|
|
2117
|
+
className: "status-dot",
|
|
2118
|
+
style: { backgroundColor: K(s.status) }
|
|
2119
|
+
}
|
|
2120
|
+
),
|
|
2121
|
+
/* @__PURE__ */ i("span", { children: [
|
|
2122
|
+
s.labels.length,
|
|
2123
|
+
" labels"
|
|
2124
|
+
] })
|
|
2125
|
+
] })
|
|
2126
|
+
]
|
|
2127
|
+
},
|
|
2128
|
+
s.id
|
|
2129
|
+
);
|
|
2130
|
+
}) })
|
|
2131
|
+
] }),
|
|
2132
|
+
C === "export" && /* @__PURE__ */ i("div", { className: "export-panel", children: [
|
|
2133
|
+
/* @__PURE__ */ t("div", { className: "panel-header", children: /* @__PURE__ */ t("h2", { children: "Export Labels" }) }),
|
|
2134
|
+
/* @__PURE__ */ i("div", { className: "export-stats", children: [
|
|
2135
|
+
/* @__PURE__ */ i("div", { className: "stat-card", children: [
|
|
2136
|
+
/* @__PURE__ */ t("span", { className: "stat-value", children: r.statistics.totalItems }),
|
|
2137
|
+
/* @__PURE__ */ t("span", { className: "stat-label", children: "Total Items" })
|
|
2138
|
+
] }),
|
|
2139
|
+
/* @__PURE__ */ i("div", { className: "stat-card", children: [
|
|
2140
|
+
/* @__PURE__ */ t("span", { className: "stat-value", children: r.statistics.labeled }),
|
|
2141
|
+
/* @__PURE__ */ t("span", { className: "stat-label", children: "Labeled" })
|
|
2142
|
+
] }),
|
|
2143
|
+
/* @__PURE__ */ i("div", { className: "stat-card", children: [
|
|
2144
|
+
/* @__PURE__ */ t("span", { className: "stat-value", children: r.statistics.approved }),
|
|
2145
|
+
/* @__PURE__ */ t("span", { className: "stat-label", children: "Approved" })
|
|
2146
|
+
] }),
|
|
2147
|
+
/* @__PURE__ */ i("div", { className: "stat-card", children: [
|
|
2148
|
+
/* @__PURE__ */ t("span", { className: "stat-value", children: r.labelSchema.classes.length }),
|
|
2149
|
+
/* @__PURE__ */ t("span", { className: "stat-label", children: "Classes" })
|
|
2150
|
+
] })
|
|
2151
|
+
] }),
|
|
2152
|
+
/* @__PURE__ */ i("div", { className: "export-formats", children: [
|
|
2153
|
+
/* @__PURE__ */ t("h3", { children: "Export Format" }),
|
|
2154
|
+
/* @__PURE__ */ i("div", { className: "format-grid", children: [
|
|
2155
|
+
/* @__PURE__ */ i("button", { className: "format-button", onClick: () => M("coco"), children: [
|
|
2156
|
+
/* @__PURE__ */ t("span", { className: "format-icon", children: "📦" }),
|
|
2157
|
+
/* @__PURE__ */ t("span", { className: "format-name", children: "COCO JSON" }),
|
|
2158
|
+
/* @__PURE__ */ t("span", { className: "format-desc", children: "Common format for object detection" })
|
|
2159
|
+
] }),
|
|
2160
|
+
/* @__PURE__ */ i("button", { className: "format-button", onClick: () => M("voc"), children: [
|
|
2161
|
+
/* @__PURE__ */ t("span", { className: "format-icon", children: "📄" }),
|
|
2162
|
+
/* @__PURE__ */ t("span", { className: "format-name", children: "Pascal VOC" }),
|
|
2163
|
+
/* @__PURE__ */ t("span", { className: "format-desc", children: "XML format for bounding boxes" })
|
|
2164
|
+
] }),
|
|
2165
|
+
/* @__PURE__ */ i("button", { className: "format-button", onClick: () => M("yolo"), children: [
|
|
2166
|
+
/* @__PURE__ */ t("span", { className: "format-icon", children: "⚡" }),
|
|
2167
|
+
/* @__PURE__ */ t("span", { className: "format-name", children: "YOLO" }),
|
|
2168
|
+
/* @__PURE__ */ t("span", { className: "format-desc", children: "Text format for YOLO models" })
|
|
2169
|
+
] }),
|
|
2170
|
+
/* @__PURE__ */ i("button", { className: "format-button", onClick: () => M("csv"), children: [
|
|
2171
|
+
/* @__PURE__ */ t("span", { className: "format-icon", children: "📊" }),
|
|
2172
|
+
/* @__PURE__ */ t("span", { className: "format-name", children: "CSV" }),
|
|
2173
|
+
/* @__PURE__ */ t("span", { className: "format-desc", children: "Tabular format for classification" })
|
|
2174
|
+
] })
|
|
2175
|
+
] })
|
|
2176
|
+
] }),
|
|
2177
|
+
/* @__PURE__ */ i("div", { className: "class-distribution", children: [
|
|
2178
|
+
/* @__PURE__ */ t("h3", { children: "Class Distribution" }),
|
|
2179
|
+
/* @__PURE__ */ t("div", { className: "distribution-bars", children: r.statistics.byClass.map((s) => {
|
|
2180
|
+
const u = r.labelSchema.classes.find((A) => A.id === s.classId), g = s.count / Math.max(r.statistics.labeled, 1) * 100;
|
|
2181
|
+
return /* @__PURE__ */ i("div", { className: "distribution-row", children: [
|
|
2182
|
+
/* @__PURE__ */ t("span", { className: "class-name", style: { color: u == null ? void 0 : u.color }, children: u == null ? void 0 : u.name }),
|
|
2183
|
+
/* @__PURE__ */ t("div", { className: "bar-container", children: /* @__PURE__ */ t(
|
|
2184
|
+
"div",
|
|
2185
|
+
{
|
|
2186
|
+
className: "bar-fill",
|
|
2187
|
+
style: { width: `${g}%`, backgroundColor: u == null ? void 0 : u.color }
|
|
2188
|
+
}
|
|
2189
|
+
) }),
|
|
2190
|
+
/* @__PURE__ */ t("span", { className: "count", children: s.count })
|
|
2191
|
+
] }, s.classId);
|
|
2192
|
+
}) })
|
|
2193
|
+
] })
|
|
2194
|
+
] })
|
|
2195
|
+
] }),
|
|
2196
|
+
L && /* @__PURE__ */ t("div", { className: "shortcuts-modal", children: /* @__PURE__ */ i("div", { className: "modal-content", children: [
|
|
2197
|
+
/* @__PURE__ */ i("div", { className: "modal-header", children: [
|
|
2198
|
+
/* @__PURE__ */ t("h3", { children: "Keyboard Shortcuts" }),
|
|
2199
|
+
/* @__PURE__ */ t("button", { onClick: () => P(!1), children: "×" })
|
|
2200
|
+
] }),
|
|
2201
|
+
/* @__PURE__ */ i("div", { className: "shortcuts-list", children: [
|
|
2202
|
+
/* @__PURE__ */ i("div", { className: "shortcut-item", children: [
|
|
2203
|
+
/* @__PURE__ */ t("span", { className: "keys", children: "← / A" }),
|
|
2204
|
+
/* @__PURE__ */ t("span", { className: "description", children: "Previous item" })
|
|
2205
|
+
] }),
|
|
2206
|
+
/* @__PURE__ */ i("div", { className: "shortcut-item", children: [
|
|
2207
|
+
/* @__PURE__ */ t("span", { className: "keys", children: "→ / D" }),
|
|
2208
|
+
/* @__PURE__ */ t("span", { className: "description", children: "Next item" })
|
|
2209
|
+
] }),
|
|
2210
|
+
/* @__PURE__ */ i("div", { className: "shortcut-item", children: [
|
|
2211
|
+
/* @__PURE__ */ t("span", { className: "keys", children: "Enter" }),
|
|
2212
|
+
/* @__PURE__ */ t("span", { className: "description", children: "Approve item" })
|
|
2213
|
+
] }),
|
|
2214
|
+
/* @__PURE__ */ i("div", { className: "shortcut-item", children: [
|
|
2215
|
+
/* @__PURE__ */ t("span", { className: "keys", children: "Backspace" }),
|
|
2216
|
+
/* @__PURE__ */ t("span", { className: "description", children: "Reject item" })
|
|
2217
|
+
] }),
|
|
2218
|
+
r.labelSchema.classes.map(
|
|
2219
|
+
(s) => s.shortcut && /* @__PURE__ */ i("div", { className: "shortcut-item", children: [
|
|
2220
|
+
/* @__PURE__ */ t("span", { className: "keys", children: s.shortcut }),
|
|
2221
|
+
/* @__PURE__ */ i("span", { className: "description", children: [
|
|
2222
|
+
"Label as ",
|
|
2223
|
+
s.name
|
|
2224
|
+
] })
|
|
2225
|
+
] }, s.id)
|
|
2226
|
+
)
|
|
2227
|
+
] })
|
|
2228
|
+
] }) })
|
|
2229
|
+
] });
|
|
2230
|
+
}, Be = {
|
|
2231
|
+
id: crypto.randomUUID(),
|
|
2232
|
+
name: "Model Endpoint",
|
|
2233
|
+
modelId: "",
|
|
2234
|
+
modelVersion: "1.0.0",
|
|
2235
|
+
status: "stopped",
|
|
2236
|
+
url: "",
|
|
2237
|
+
authentication: { type: "api-key" },
|
|
2238
|
+
metrics: {
|
|
2239
|
+
requestsTotal: 0,
|
|
2240
|
+
requestsPerSecond: 0,
|
|
2241
|
+
latencyP50: 0,
|
|
2242
|
+
latencyP95: 0,
|
|
2243
|
+
latencyP99: 0,
|
|
2244
|
+
errorRate: 0,
|
|
2245
|
+
successRate: 100
|
|
2246
|
+
},
|
|
2247
|
+
logs: []
|
|
2248
|
+
}, va = ({
|
|
2249
|
+
endpoint: n,
|
|
2250
|
+
onInference: e,
|
|
2251
|
+
showMetrics: a = !0,
|
|
2252
|
+
showLogs: c = !0,
|
|
2253
|
+
className: d = ""
|
|
2254
|
+
}) => {
|
|
2255
|
+
const [r, x] = p(n || Be), [C, S] = p("test"), [b, I] = p("text"), [E, R] = p(""), [$, O] = p("{}"), [N, U] = p(null), [h, v] = p({
|
|
2256
|
+
temperature: 0.7,
|
|
2257
|
+
topK: 50,
|
|
2258
|
+
topP: 0.9,
|
|
2259
|
+
maxTokens: 256,
|
|
2260
|
+
threshold: 0.5
|
|
2261
|
+
}), [f, D] = p(null), [L, P] = p(!1), [j, _] = p(null), [V, G] = p([]), [y, l] = p(null), m = Q(null), T = (o) => {
|
|
2262
|
+
var q;
|
|
2263
|
+
const k = (q = o.target.files) == null ? void 0 : q[0];
|
|
2264
|
+
if (k) {
|
|
2265
|
+
const J = new FileReader();
|
|
2266
|
+
J.onload = (M) => {
|
|
2267
|
+
var K;
|
|
2268
|
+
U((K = M.target) == null ? void 0 : K.result);
|
|
2269
|
+
}, J.readAsDataURL(k);
|
|
2270
|
+
}
|
|
2271
|
+
}, w = async () => {
|
|
2272
|
+
if (!e) {
|
|
2273
|
+
_("No inference handler provided");
|
|
2274
|
+
return;
|
|
2275
|
+
}
|
|
2276
|
+
P(!0), _(null), D(null);
|
|
2277
|
+
const o = [];
|
|
2278
|
+
switch (b) {
|
|
2279
|
+
case "text":
|
|
2280
|
+
o.push({ type: "text", data: E });
|
|
2281
|
+
break;
|
|
2282
|
+
case "image":
|
|
2283
|
+
N && o.push({ type: "image", data: N });
|
|
2284
|
+
break;
|
|
2285
|
+
case "json":
|
|
2286
|
+
try {
|
|
2287
|
+
o.push({ type: "json", data: JSON.parse($) });
|
|
2288
|
+
} catch {
|
|
2289
|
+
_("Invalid JSON input"), P(!1);
|
|
2290
|
+
return;
|
|
2291
|
+
}
|
|
2292
|
+
break;
|
|
2293
|
+
case "tabular":
|
|
2294
|
+
try {
|
|
2295
|
+
o.push({ type: "tabular", data: JSON.parse($) });
|
|
2296
|
+
} catch {
|
|
2297
|
+
_("Invalid tabular data"), P(!1);
|
|
2298
|
+
return;
|
|
2299
|
+
}
|
|
2300
|
+
break;
|
|
2301
|
+
}
|
|
2302
|
+
const k = {
|
|
2303
|
+
inputs: o,
|
|
2304
|
+
parameters: h
|
|
2305
|
+
};
|
|
2306
|
+
try {
|
|
2307
|
+
const q = Date.now(), J = await e(k), M = Date.now() - q;
|
|
2308
|
+
D(J), x((K) => ({
|
|
2309
|
+
...K,
|
|
2310
|
+
metrics: {
|
|
2311
|
+
...K.metrics,
|
|
2312
|
+
requestsTotal: K.metrics.requestsTotal + 1,
|
|
2313
|
+
latencyP50: (K.metrics.latencyP50 + M) / 2
|
|
2314
|
+
},
|
|
2315
|
+
logs: [
|
|
2316
|
+
{
|
|
2317
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
2318
|
+
requestId: J.requestId,
|
|
2319
|
+
duration: M,
|
|
2320
|
+
status: "success",
|
|
2321
|
+
inputSize: JSON.stringify(o).length,
|
|
2322
|
+
outputSize: JSON.stringify(J.predictions).length
|
|
2323
|
+
},
|
|
2324
|
+
...K.logs.slice(0, 99)
|
|
2325
|
+
]
|
|
2326
|
+
}));
|
|
2327
|
+
} catch (q) {
|
|
2328
|
+
const J = q instanceof Error ? q.message : "Inference failed";
|
|
2329
|
+
_(J), x((M) => ({
|
|
2330
|
+
...M,
|
|
2331
|
+
metrics: {
|
|
2332
|
+
...M.metrics,
|
|
2333
|
+
requestsTotal: M.metrics.requestsTotal + 1,
|
|
2334
|
+
errorRate: (M.metrics.errorRate * M.metrics.requestsTotal + 1) / (M.metrics.requestsTotal + 1)
|
|
2335
|
+
},
|
|
2336
|
+
logs: [
|
|
2337
|
+
{
|
|
2338
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
2339
|
+
requestId: crypto.randomUUID(),
|
|
2340
|
+
duration: 0,
|
|
2341
|
+
status: "error",
|
|
2342
|
+
inputSize: JSON.stringify(o).length,
|
|
2343
|
+
outputSize: 0,
|
|
2344
|
+
error: J
|
|
2345
|
+
},
|
|
2346
|
+
...M.logs.slice(0, 99)
|
|
2347
|
+
]
|
|
2348
|
+
}));
|
|
2349
|
+
} finally {
|
|
2350
|
+
P(!1);
|
|
2351
|
+
}
|
|
2352
|
+
}, z = async (o) => {
|
|
2353
|
+
if (e) {
|
|
2354
|
+
l(0), G([]);
|
|
2355
|
+
for (let k = 0; k < o.length; k++) {
|
|
2356
|
+
const q = {
|
|
2357
|
+
inputs: [o[k]],
|
|
2358
|
+
parameters: h
|
|
2359
|
+
};
|
|
2360
|
+
try {
|
|
2361
|
+
const J = await e(q);
|
|
2362
|
+
G((M) => [...M, J]);
|
|
2363
|
+
} catch (J) {
|
|
2364
|
+
console.error("Batch item failed:", J);
|
|
2365
|
+
}
|
|
2366
|
+
l((k + 1) / o.length * 100);
|
|
2367
|
+
}
|
|
2368
|
+
l(null);
|
|
2369
|
+
}
|
|
2370
|
+
}, W = (o) => o < 1e3 ? `${o.toFixed(0)}ms` : `${(o / 1e3).toFixed(2)}s`, Y = (o) => o.toLocaleTimeString(), te = (o, k) => /* @__PURE__ */ i("div", { className: "prediction-item", children: [
|
|
2371
|
+
o.label && /* @__PURE__ */ i("div", { className: "prediction-label", children: [
|
|
2372
|
+
/* @__PURE__ */ t("span", { className: "label-name", children: o.label }),
|
|
2373
|
+
o.confidence !== void 0 && /* @__PURE__ */ i(
|
|
2374
|
+
"span",
|
|
2375
|
+
{
|
|
2376
|
+
className: "confidence-badge",
|
|
2377
|
+
style: {
|
|
2378
|
+
backgroundColor: `hsl(${o.confidence * 120}, 70%, 40%)`
|
|
2379
|
+
},
|
|
2380
|
+
children: [
|
|
2381
|
+
(o.confidence * 100).toFixed(1),
|
|
2382
|
+
"%"
|
|
2383
|
+
]
|
|
2384
|
+
}
|
|
2385
|
+
)
|
|
2386
|
+
] }),
|
|
2387
|
+
o.score !== void 0 && /* @__PURE__ */ i("div", { className: "prediction-score", children: [
|
|
2388
|
+
/* @__PURE__ */ t("span", { className: "score-label", children: "Score:" }),
|
|
2389
|
+
/* @__PURE__ */ t("span", { className: "score-value", children: o.score.toFixed(4) })
|
|
2390
|
+
] }),
|
|
2391
|
+
o.text && /* @__PURE__ */ t("div", { className: "prediction-text", children: /* @__PURE__ */ t("pre", { children: o.text }) }),
|
|
2392
|
+
o.bbox && /* @__PURE__ */ t("div", { className: "prediction-bbox", children: /* @__PURE__ */ i("span", { children: [
|
|
2393
|
+
"Box: (",
|
|
2394
|
+
o.bbox.x,
|
|
2395
|
+
", ",
|
|
2396
|
+
o.bbox.y,
|
|
2397
|
+
") - ",
|
|
2398
|
+
o.bbox.width,
|
|
2399
|
+
"×",
|
|
2400
|
+
o.bbox.height
|
|
2401
|
+
] }) }),
|
|
2402
|
+
o.raw !== void 0 && o.raw !== null && /* @__PURE__ */ i("details", { className: "raw-output", children: [
|
|
2403
|
+
/* @__PURE__ */ t("summary", { children: "Raw Output" }),
|
|
2404
|
+
/* @__PURE__ */ t("pre", { children: JSON.stringify(o.raw, null, 2) })
|
|
2405
|
+
] })
|
|
2406
|
+
] }, k);
|
|
2407
|
+
return /* @__PURE__ */ i("div", { className: `nice-model-inference ${d}`, children: [
|
|
2408
|
+
/* @__PURE__ */ i("header", { className: "inference__header", children: [
|
|
2409
|
+
/* @__PURE__ */ i("div", { className: "header__info", children: [
|
|
2410
|
+
/* @__PURE__ */ t("h2", { children: r.name }),
|
|
2411
|
+
/* @__PURE__ */ t("span", { className: `status-badge status-badge--${r.status}`, children: r.status })
|
|
2412
|
+
] }),
|
|
2413
|
+
/* @__PURE__ */ i("div", { className: "header__tabs", children: [
|
|
2414
|
+
/* @__PURE__ */ t(
|
|
2415
|
+
"button",
|
|
2416
|
+
{
|
|
2417
|
+
className: `tab-button ${C === "test" ? "tab-button--active" : ""}`,
|
|
2418
|
+
onClick: () => S("test"),
|
|
2419
|
+
children: "Test"
|
|
2420
|
+
}
|
|
2421
|
+
),
|
|
2422
|
+
/* @__PURE__ */ t(
|
|
2423
|
+
"button",
|
|
2424
|
+
{
|
|
2425
|
+
className: `tab-button ${C === "batch" ? "tab-button--active" : ""}`,
|
|
2426
|
+
onClick: () => S("batch"),
|
|
2427
|
+
children: "Batch"
|
|
2428
|
+
}
|
|
2429
|
+
),
|
|
2430
|
+
a && /* @__PURE__ */ t(
|
|
2431
|
+
"button",
|
|
2432
|
+
{
|
|
2433
|
+
className: `tab-button ${C === "metrics" ? "tab-button--active" : ""}`,
|
|
2434
|
+
onClick: () => S("metrics"),
|
|
2435
|
+
children: "Metrics"
|
|
2436
|
+
}
|
|
2437
|
+
),
|
|
2438
|
+
c && /* @__PURE__ */ t(
|
|
2439
|
+
"button",
|
|
2440
|
+
{
|
|
2441
|
+
className: `tab-button ${C === "logs" ? "tab-button--active" : ""}`,
|
|
2442
|
+
onClick: () => S("logs"),
|
|
2443
|
+
children: "Logs"
|
|
2444
|
+
}
|
|
2445
|
+
)
|
|
2446
|
+
] })
|
|
2447
|
+
] }),
|
|
2448
|
+
/* @__PURE__ */ i("div", { className: "inference__content", children: [
|
|
2449
|
+
C === "test" && /* @__PURE__ */ i("div", { className: "test-panel", children: [
|
|
2450
|
+
/* @__PURE__ */ i("div", { className: "input-section", children: [
|
|
2451
|
+
/* @__PURE__ */ t("div", { className: "input-type-selector", children: ["text", "image", "json", "tabular"].map((o) => /* @__PURE__ */ t(
|
|
2452
|
+
"button",
|
|
2453
|
+
{
|
|
2454
|
+
className: `type-button ${b === o ? "type-button--active" : ""}`,
|
|
2455
|
+
onClick: () => I(o),
|
|
2456
|
+
children: o.charAt(0).toUpperCase() + o.slice(1)
|
|
2457
|
+
},
|
|
2458
|
+
o
|
|
2459
|
+
)) }),
|
|
2460
|
+
/* @__PURE__ */ i("div", { className: "input-area", children: [
|
|
2461
|
+
b === "text" && /* @__PURE__ */ t(
|
|
2462
|
+
"textarea",
|
|
2463
|
+
{
|
|
2464
|
+
value: E,
|
|
2465
|
+
onChange: (o) => R(o.target.value),
|
|
2466
|
+
placeholder: "Enter text input...",
|
|
2467
|
+
rows: 6,
|
|
2468
|
+
className: "text-input"
|
|
2469
|
+
}
|
|
2470
|
+
),
|
|
2471
|
+
b === "image" && /* @__PURE__ */ t("div", { className: "image-input", children: N ? /* @__PURE__ */ i("div", { className: "image-preview", children: [
|
|
2472
|
+
/* @__PURE__ */ t("img", { src: N, alt: "Input preview" }),
|
|
2473
|
+
/* @__PURE__ */ t("button", { className: "clear-button", onClick: () => U(null), children: "Clear" })
|
|
2474
|
+
] }) : /* @__PURE__ */ i("label", { className: "upload-zone", children: [
|
|
2475
|
+
/* @__PURE__ */ t(
|
|
2476
|
+
"input",
|
|
2477
|
+
{
|
|
2478
|
+
ref: m,
|
|
2479
|
+
type: "file",
|
|
2480
|
+
accept: "image/*",
|
|
2481
|
+
onChange: T,
|
|
2482
|
+
hidden: !0
|
|
2483
|
+
}
|
|
2484
|
+
),
|
|
2485
|
+
/* @__PURE__ */ t("span", { className: "upload-icon", children: "🖼️" }),
|
|
2486
|
+
/* @__PURE__ */ t("span", { children: "Click or drag to upload image" })
|
|
2487
|
+
] }) }),
|
|
2488
|
+
(b === "json" || b === "tabular") && /* @__PURE__ */ t(
|
|
2489
|
+
"textarea",
|
|
2490
|
+
{
|
|
2491
|
+
value: $,
|
|
2492
|
+
onChange: (o) => O(o.target.value),
|
|
2493
|
+
placeholder: b === "json" ? `{
|
|
2494
|
+
"key": "value"
|
|
2495
|
+
}` : `[
|
|
2496
|
+
{"col1": "value1", "col2": "value2"}
|
|
2497
|
+
]`,
|
|
2498
|
+
rows: 10,
|
|
2499
|
+
className: "json-input"
|
|
2500
|
+
}
|
|
2501
|
+
)
|
|
2502
|
+
] }),
|
|
2503
|
+
/* @__PURE__ */ i("div", { className: "parameters-section", children: [
|
|
2504
|
+
/* @__PURE__ */ t("h4", { children: "Parameters" }),
|
|
2505
|
+
/* @__PURE__ */ i("div", { className: "parameters-grid", children: [
|
|
2506
|
+
/* @__PURE__ */ i("label", { children: [
|
|
2507
|
+
"Temperature",
|
|
2508
|
+
/* @__PURE__ */ t(
|
|
2509
|
+
"input",
|
|
2510
|
+
{
|
|
2511
|
+
type: "number",
|
|
2512
|
+
value: h.temperature,
|
|
2513
|
+
onChange: (o) => v({ ...h, temperature: parseFloat(o.target.value) }),
|
|
2514
|
+
min: "0",
|
|
2515
|
+
max: "2",
|
|
2516
|
+
step: "0.1"
|
|
2517
|
+
}
|
|
2518
|
+
)
|
|
2519
|
+
] }),
|
|
2520
|
+
/* @__PURE__ */ i("label", { children: [
|
|
2521
|
+
"Top K",
|
|
2522
|
+
/* @__PURE__ */ t(
|
|
2523
|
+
"input",
|
|
2524
|
+
{
|
|
2525
|
+
type: "number",
|
|
2526
|
+
value: h.topK,
|
|
2527
|
+
onChange: (o) => v({ ...h, topK: parseInt(o.target.value) }),
|
|
2528
|
+
min: "1",
|
|
2529
|
+
max: "100"
|
|
2530
|
+
}
|
|
2531
|
+
)
|
|
2532
|
+
] }),
|
|
2533
|
+
/* @__PURE__ */ i("label", { children: [
|
|
2534
|
+
"Top P",
|
|
2535
|
+
/* @__PURE__ */ t(
|
|
2536
|
+
"input",
|
|
2537
|
+
{
|
|
2538
|
+
type: "number",
|
|
2539
|
+
value: h.topP,
|
|
2540
|
+
onChange: (o) => v({ ...h, topP: parseFloat(o.target.value) }),
|
|
2541
|
+
min: "0",
|
|
2542
|
+
max: "1",
|
|
2543
|
+
step: "0.05"
|
|
2544
|
+
}
|
|
2545
|
+
)
|
|
2546
|
+
] }),
|
|
2547
|
+
/* @__PURE__ */ i("label", { children: [
|
|
2548
|
+
"Threshold",
|
|
2549
|
+
/* @__PURE__ */ t(
|
|
2550
|
+
"input",
|
|
2551
|
+
{
|
|
2552
|
+
type: "number",
|
|
2553
|
+
value: h.threshold,
|
|
2554
|
+
onChange: (o) => v({ ...h, threshold: parseFloat(o.target.value) }),
|
|
2555
|
+
min: "0",
|
|
2556
|
+
max: "1",
|
|
2557
|
+
step: "0.05"
|
|
2558
|
+
}
|
|
2559
|
+
)
|
|
2560
|
+
] })
|
|
2561
|
+
] })
|
|
2562
|
+
] }),
|
|
2563
|
+
/* @__PURE__ */ t(
|
|
2564
|
+
"button",
|
|
2565
|
+
{
|
|
2566
|
+
className: "run-button",
|
|
2567
|
+
onClick: w,
|
|
2568
|
+
disabled: L || !E && !N && $ === "{}",
|
|
2569
|
+
children: L ? "Running..." : "Run Inference"
|
|
2570
|
+
}
|
|
2571
|
+
)
|
|
2572
|
+
] }),
|
|
2573
|
+
/* @__PURE__ */ i("div", { className: "output-section", children: [
|
|
2574
|
+
/* @__PURE__ */ t("h3", { children: "Output" }),
|
|
2575
|
+
j && /* @__PURE__ */ i("div", { className: "error-message", children: [
|
|
2576
|
+
/* @__PURE__ */ t("span", { className: "error-icon", children: "⚠️" }),
|
|
2577
|
+
j
|
|
2578
|
+
] }),
|
|
2579
|
+
f && /* @__PURE__ */ i("div", { className: "result-container", children: [
|
|
2580
|
+
/* @__PURE__ */ i("div", { className: "result-meta", children: [
|
|
2581
|
+
/* @__PURE__ */ i("span", { children: [
|
|
2582
|
+
"Request ID: ",
|
|
2583
|
+
f.requestId
|
|
2584
|
+
] }),
|
|
2585
|
+
/* @__PURE__ */ i("span", { children: [
|
|
2586
|
+
"Latency: ",
|
|
2587
|
+
W(f.latency)
|
|
2588
|
+
] }),
|
|
2589
|
+
/* @__PURE__ */ i("span", { children: [
|
|
2590
|
+
"Model: ",
|
|
2591
|
+
f.modelVersion
|
|
2592
|
+
] })
|
|
2593
|
+
] }),
|
|
2594
|
+
/* @__PURE__ */ t("div", { className: "predictions-list", children: f.predictions.map((o, k) => te(o, k)) })
|
|
2595
|
+
] }),
|
|
2596
|
+
!j && !f && /* @__PURE__ */ i("div", { className: "empty-output", children: [
|
|
2597
|
+
/* @__PURE__ */ t("span", { className: "icon", children: "📤" }),
|
|
2598
|
+
/* @__PURE__ */ t("p", { children: "Run inference to see results" })
|
|
2599
|
+
] })
|
|
2600
|
+
] })
|
|
2601
|
+
] }),
|
|
2602
|
+
C === "batch" && /* @__PURE__ */ i("div", { className: "batch-panel", children: [
|
|
2603
|
+
/* @__PURE__ */ i("div", { className: "batch-upload", children: [
|
|
2604
|
+
/* @__PURE__ */ t("h3", { children: "Batch Inference" }),
|
|
2605
|
+
/* @__PURE__ */ t("p", { className: "hint", children: "Upload a file with multiple inputs for batch processing" }),
|
|
2606
|
+
/* @__PURE__ */ i("label", { className: "upload-zone", children: [
|
|
2607
|
+
/* @__PURE__ */ t(
|
|
2608
|
+
"input",
|
|
2609
|
+
{
|
|
2610
|
+
type: "file",
|
|
2611
|
+
accept: ".json,.csv,.txt",
|
|
2612
|
+
onChange: async (o) => {
|
|
2613
|
+
var q;
|
|
2614
|
+
const k = (q = o.target.files) == null ? void 0 : q[0];
|
|
2615
|
+
if (k) {
|
|
2616
|
+
const J = await k.text();
|
|
2617
|
+
try {
|
|
2618
|
+
const M = JSON.parse(J);
|
|
2619
|
+
if (Array.isArray(M)) {
|
|
2620
|
+
const K = M.map((ee) => ({
|
|
2621
|
+
type: "json",
|
|
2622
|
+
data: ee
|
|
2623
|
+
}));
|
|
2624
|
+
z(K);
|
|
2625
|
+
}
|
|
2626
|
+
} catch {
|
|
2627
|
+
_("Invalid batch file format");
|
|
2628
|
+
}
|
|
2629
|
+
}
|
|
2630
|
+
},
|
|
2631
|
+
hidden: !0
|
|
2632
|
+
}
|
|
2633
|
+
),
|
|
2634
|
+
/* @__PURE__ */ t("span", { className: "upload-icon", children: "📁" }),
|
|
2635
|
+
/* @__PURE__ */ t("span", { children: "Upload JSON array file" })
|
|
2636
|
+
] })
|
|
2637
|
+
] }),
|
|
2638
|
+
y !== null && /* @__PURE__ */ i("div", { className: "batch-progress", children: [
|
|
2639
|
+
/* @__PURE__ */ t("div", { className: "progress-bar", children: /* @__PURE__ */ t("div", { className: "progress-fill", style: { width: `${y}%` } }) }),
|
|
2640
|
+
/* @__PURE__ */ i("span", { children: [
|
|
2641
|
+
Math.round(y),
|
|
2642
|
+
"%"
|
|
2643
|
+
] })
|
|
2644
|
+
] }),
|
|
2645
|
+
V.length > 0 && /* @__PURE__ */ i("div", { className: "batch-results", children: [
|
|
2646
|
+
/* @__PURE__ */ i("h3", { children: [
|
|
2647
|
+
"Results (",
|
|
2648
|
+
V.length,
|
|
2649
|
+
")"
|
|
2650
|
+
] }),
|
|
2651
|
+
/* @__PURE__ */ t("div", { className: "results-list", children: V.map((o, k) => /* @__PURE__ */ i("div", { className: "batch-result-item", children: [
|
|
2652
|
+
/* @__PURE__ */ i("span", { className: "result-index", children: [
|
|
2653
|
+
"#",
|
|
2654
|
+
k + 1
|
|
2655
|
+
] }),
|
|
2656
|
+
o.predictions.map((q, J) => /* @__PURE__ */ i("span", { className: "result-prediction", children: [
|
|
2657
|
+
q.label,
|
|
2658
|
+
": ",
|
|
2659
|
+
(q.confidence || q.score || 0 * 100).toFixed(1),
|
|
2660
|
+
"%"
|
|
2661
|
+
] }, J))
|
|
2662
|
+
] }, k)) })
|
|
2663
|
+
] })
|
|
2664
|
+
] }),
|
|
2665
|
+
C === "metrics" && a && /* @__PURE__ */ i("div", { className: "metrics-panel", children: [
|
|
2666
|
+
/* @__PURE__ */ i("div", { className: "metrics-grid", children: [
|
|
2667
|
+
/* @__PURE__ */ i("div", { className: "metric-card", children: [
|
|
2668
|
+
/* @__PURE__ */ t("span", { className: "metric-value", children: r.metrics.requestsTotal }),
|
|
2669
|
+
/* @__PURE__ */ t("span", { className: "metric-label", children: "Total Requests" })
|
|
2670
|
+
] }),
|
|
2671
|
+
/* @__PURE__ */ i("div", { className: "metric-card", children: [
|
|
2672
|
+
/* @__PURE__ */ t("span", { className: "metric-value", children: r.metrics.requestsPerSecond.toFixed(1) }),
|
|
2673
|
+
/* @__PURE__ */ t("span", { className: "metric-label", children: "Requests/sec" })
|
|
2674
|
+
] }),
|
|
2675
|
+
/* @__PURE__ */ i("div", { className: "metric-card", children: [
|
|
2676
|
+
/* @__PURE__ */ t("span", { className: "metric-value", children: W(r.metrics.latencyP50) }),
|
|
2677
|
+
/* @__PURE__ */ t("span", { className: "metric-label", children: "P50 Latency" })
|
|
2678
|
+
] }),
|
|
2679
|
+
/* @__PURE__ */ i("div", { className: "metric-card", children: [
|
|
2680
|
+
/* @__PURE__ */ t("span", { className: "metric-value", children: W(r.metrics.latencyP95) }),
|
|
2681
|
+
/* @__PURE__ */ t("span", { className: "metric-label", children: "P95 Latency" })
|
|
2682
|
+
] }),
|
|
2683
|
+
/* @__PURE__ */ i("div", { className: "metric-card", children: [
|
|
2684
|
+
/* @__PURE__ */ t("span", { className: "metric-value", children: W(r.metrics.latencyP99) }),
|
|
2685
|
+
/* @__PURE__ */ t("span", { className: "metric-label", children: "P99 Latency" })
|
|
2686
|
+
] }),
|
|
2687
|
+
/* @__PURE__ */ i("div", { className: "metric-card", children: [
|
|
2688
|
+
/* @__PURE__ */ i("span", { className: "metric-value", children: [
|
|
2689
|
+
r.metrics.successRate.toFixed(1),
|
|
2690
|
+
"%"
|
|
2691
|
+
] }),
|
|
2692
|
+
/* @__PURE__ */ t("span", { className: "metric-label", children: "Success Rate" })
|
|
2693
|
+
] }),
|
|
2694
|
+
/* @__PURE__ */ i("div", { className: "metric-card", children: [
|
|
2695
|
+
/* @__PURE__ */ i("span", { className: "metric-value", children: [
|
|
2696
|
+
(r.metrics.errorRate * 100).toFixed(2),
|
|
2697
|
+
"%"
|
|
2698
|
+
] }),
|
|
2699
|
+
/* @__PURE__ */ t("span", { className: "metric-label", children: "Error Rate" })
|
|
2700
|
+
] })
|
|
2701
|
+
] }),
|
|
2702
|
+
/* @__PURE__ */ i("div", { className: "latency-histogram", children: [
|
|
2703
|
+
/* @__PURE__ */ t("h3", { children: "Latency Distribution" }),
|
|
2704
|
+
/* @__PURE__ */ t("div", { className: "histogram-bars", children: [10, 25, 50, 75, 90, 95, 99].map((o) => /* @__PURE__ */ i("div", { className: "histogram-bar", children: [
|
|
2705
|
+
/* @__PURE__ */ t(
|
|
2706
|
+
"div",
|
|
2707
|
+
{
|
|
2708
|
+
className: "bar-fill",
|
|
2709
|
+
style: {
|
|
2710
|
+
height: `${Math.min(100, r.metrics.latencyP50 * o / 100)}px`
|
|
2711
|
+
}
|
|
2712
|
+
}
|
|
2713
|
+
),
|
|
2714
|
+
/* @__PURE__ */ i("span", { className: "percentile-label", children: [
|
|
2715
|
+
"P",
|
|
2716
|
+
o
|
|
2717
|
+
] })
|
|
2718
|
+
] }, o)) })
|
|
2719
|
+
] })
|
|
2720
|
+
] }),
|
|
2721
|
+
C === "logs" && c && /* @__PURE__ */ i("div", { className: "logs-panel", children: [
|
|
2722
|
+
/* @__PURE__ */ i("div", { className: "logs-header", children: [
|
|
2723
|
+
/* @__PURE__ */ t("h3", { children: "Request Logs" }),
|
|
2724
|
+
/* @__PURE__ */ t(
|
|
2725
|
+
"button",
|
|
2726
|
+
{
|
|
2727
|
+
className: "clear-logs-button",
|
|
2728
|
+
onClick: () => x((o) => ({ ...o, logs: [] })),
|
|
2729
|
+
children: "Clear Logs"
|
|
2730
|
+
}
|
|
2731
|
+
)
|
|
2732
|
+
] }),
|
|
2733
|
+
/* @__PURE__ */ t("div", { className: "logs-table", children: /* @__PURE__ */ i("table", { children: [
|
|
2734
|
+
/* @__PURE__ */ t("thead", { children: /* @__PURE__ */ i("tr", { children: [
|
|
2735
|
+
/* @__PURE__ */ t("th", { children: "Time" }),
|
|
2736
|
+
/* @__PURE__ */ t("th", { children: "Request ID" }),
|
|
2737
|
+
/* @__PURE__ */ t("th", { children: "Duration" }),
|
|
2738
|
+
/* @__PURE__ */ t("th", { children: "Status" }),
|
|
2739
|
+
/* @__PURE__ */ t("th", { children: "Input Size" }),
|
|
2740
|
+
/* @__PURE__ */ t("th", { children: "Output Size" })
|
|
2741
|
+
] }) }),
|
|
2742
|
+
/* @__PURE__ */ t("tbody", { children: r.logs.length === 0 ? /* @__PURE__ */ t("tr", { children: /* @__PURE__ */ t("td", { colSpan: 6, className: "empty-logs", children: "No logs yet" }) }) : r.logs.map((o, k) => /* @__PURE__ */ i("tr", { className: `log-row log-row--${o.status}`, children: [
|
|
2743
|
+
/* @__PURE__ */ t("td", { children: Y(o.timestamp) }),
|
|
2744
|
+
/* @__PURE__ */ t("td", { className: "request-id", children: o.requestId.slice(0, 8) }),
|
|
2745
|
+
/* @__PURE__ */ t("td", { children: W(o.duration) }),
|
|
2746
|
+
/* @__PURE__ */ t("td", { children: /* @__PURE__ */ t("span", { className: `status-badge status-badge--${o.status}`, children: o.status }) }),
|
|
2747
|
+
/* @__PURE__ */ i("td", { children: [
|
|
2748
|
+
o.inputSize,
|
|
2749
|
+
" B"
|
|
2750
|
+
] }),
|
|
2751
|
+
/* @__PURE__ */ i("td", { children: [
|
|
2752
|
+
o.outputSize,
|
|
2753
|
+
" B"
|
|
2754
|
+
] })
|
|
2755
|
+
] }, k)) })
|
|
2756
|
+
] }) })
|
|
2757
|
+
] })
|
|
2758
|
+
] })
|
|
2759
|
+
] });
|
|
2760
|
+
};
|
|
1028
2761
|
export {
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
2762
|
+
ue as NiceAIHintBubble,
|
|
2763
|
+
je as NiceAIProvider,
|
|
2764
|
+
ba as NiceDataLabeler,
|
|
2765
|
+
fa as NiceMLStudio,
|
|
2766
|
+
va as NiceModelInference,
|
|
2767
|
+
Ne as RateLimiter,
|
|
2768
|
+
Le as build3DSceneContext,
|
|
2769
|
+
Pe as buildAudioContext,
|
|
2770
|
+
Ve as buildChartContext,
|
|
2771
|
+
Ie as buildCodeEditorContext,
|
|
2772
|
+
be as buildColorPickerContext,
|
|
2773
|
+
_e as buildDataGridContext,
|
|
2774
|
+
fe as buildDatePickerContext,
|
|
2775
|
+
De as buildDiagramLayoutContext,
|
|
2776
|
+
Te as buildFormFillContext,
|
|
2777
|
+
Oe as buildGameEngineContext,
|
|
2778
|
+
Ae as buildGraphicsContext,
|
|
2779
|
+
Re as buildHtmlEditorContext,
|
|
2780
|
+
Me as buildIconSearchContext,
|
|
2781
|
+
he as buildNumberInputContext,
|
|
2782
|
+
Ee as buildPresentationGenerateContext,
|
|
2783
|
+
ge as buildSelectContext,
|
|
2784
|
+
Je as buildSlideDesignContext,
|
|
2785
|
+
me as buildTextInputContext,
|
|
2786
|
+
$e as buildValidationContext,
|
|
2787
|
+
ga as colorControlContext,
|
|
2788
|
+
ha as dateControlContext,
|
|
2789
|
+
ua as numberControlContext,
|
|
2790
|
+
pe as parseJSONResponse,
|
|
2791
|
+
xe as parseSSEStream,
|
|
2792
|
+
ma as selectControlContext,
|
|
2793
|
+
oa as textControlContext,
|
|
2794
|
+
ta as useAI3DHint,
|
|
2795
|
+
aa as useAIAudioHint,
|
|
2796
|
+
Ze as useAICodeHint,
|
|
2797
|
+
Ye as useAIColorHint,
|
|
2798
|
+
oe as useAIContext,
|
|
2799
|
+
We as useAIDateHint,
|
|
2800
|
+
la as useAIDiagramLayout,
|
|
2801
|
+
Qe as useAIFormFill,
|
|
2802
|
+
na as useAIGraphicsHint,
|
|
2803
|
+
ea as useAIHtmlHint,
|
|
2804
|
+
ia as useAIIconSearch,
|
|
2805
|
+
ra as useAINpcHint,
|
|
2806
|
+
Ke as useAINumberHint,
|
|
2807
|
+
sa as useAIPresentationGenerate,
|
|
2808
|
+
Ge as useAISelectHint,
|
|
2809
|
+
ca as useAISlideDesign,
|
|
2810
|
+
He as useAITextHint,
|
|
2811
|
+
Xe as useAIValidation,
|
|
2812
|
+
F as useNiceAIHint,
|
|
2813
|
+
da as withAIHint
|
|
1078
2814
|
};
|