@uipath/apollo-wind 2.94.1 → 2.95.1

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.
@@ -0,0 +1,1297 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ ByoModelDialog: ()=>ByoModelDialog
28
+ });
29
+ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
30
+ const external_lucide_react_namespaceObject = require("lucide-react");
31
+ const external_react_namespaceObject = require("react");
32
+ const external_alert_cjs_namespaceObject = require("../alert.cjs");
33
+ const external_button_cjs_namespaceObject = require("../button.cjs");
34
+ const external_collapsible_cjs_namespaceObject = require("../collapsible.cjs");
35
+ const external_command_cjs_namespaceObject = require("../command.cjs");
36
+ const external_dialog_cjs_namespaceObject = require("../dialog.cjs");
37
+ const external_input_cjs_namespaceObject = require("../input.cjs");
38
+ const external_label_cjs_namespaceObject = require("../label.cjs");
39
+ const external_popover_cjs_namespaceObject = require("../popover.cjs");
40
+ const external_radio_group_cjs_namespaceObject = require("../radio-group.cjs");
41
+ const external_select_cjs_namespaceObject = require("../select.cjs");
42
+ const external_spinner_cjs_namespaceObject = require("../spinner.cjs");
43
+ const index_cjs_namespaceObject = require("../../../lib/index.cjs");
44
+ const external_labels_cjs_namespaceObject = require("./labels.cjs");
45
+ function ByoModelDialog({ open, onOpenChange, ...rest }) {
46
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_dialog_cjs_namespaceObject.Dialog, {
47
+ open: open,
48
+ onOpenChange: onOpenChange,
49
+ children: open && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(DialogBody, {
50
+ ...rest,
51
+ onClose: ()=>onOpenChange(false)
52
+ })
53
+ });
54
+ }
55
+ const NEW = '__new__';
56
+ const NO_FORM = {
57
+ status: 'idle',
58
+ form: {
59
+ authTypes: [],
60
+ defaultAuthType: null,
61
+ fields: []
62
+ }
63
+ };
64
+ const NO_MODELS = {
65
+ status: 'idle',
66
+ models: {
67
+ compatible: [],
68
+ incompatible: []
69
+ }
70
+ };
71
+ function defaultConnectionName(providerName, connections) {
72
+ const base = `${providerName} – personal`;
73
+ const taken = new Set(connections.map((c)=>c.name.toLowerCase()));
74
+ if (!taken.has(base.toLowerCase())) return base;
75
+ let n = 2;
76
+ while(taken.has(`${base} ${n}`.toLowerCase()))n += 1;
77
+ return `${base} ${n}`;
78
+ }
79
+ const shownFields = (form, authType)=>form.fields.filter((f)=>!f.group || f.group === authType);
80
+ const defaultsOf = (form)=>Object.fromEntries(form.fields.filter((f)=>f.defaultValue).map((f)=>[
81
+ f.key,
82
+ f.defaultValue
83
+ ]));
84
+ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, container, onClose }) {
85
+ const labels = (0, external_labels_cjs_namespaceObject.resolveByoModelDialogLabels)(labelOverrides);
86
+ const [api] = external_react_namespaceObject.useState(apiProp);
87
+ const [editTarget] = external_react_namespaceObject.useState(editing);
88
+ const generation = external_react_namespaceObject.useRef(0);
89
+ const formLoad = external_react_namespaceObject.useRef(0);
90
+ external_react_namespaceObject.useEffect(()=>()=>{
91
+ generation.current += 1;
92
+ formLoad.current += 1;
93
+ }, []);
94
+ const [context, setContext] = external_react_namespaceObject.useState({
95
+ status: 'running'
96
+ });
97
+ const [connections, setConnections] = external_react_namespaceObject.useState([]);
98
+ const [modelToEdit, setModelToEdit] = external_react_namespaceObject.useState(null);
99
+ const [providerId, setProviderId] = external_react_namespaceObject.useState('');
100
+ const [connectionChoice, setConnectionChoice] = external_react_namespaceObject.useState(NEW);
101
+ const [connName, setConnName] = external_react_namespaceObject.useState('');
102
+ const [folderId, setFolderId] = external_react_namespaceObject.useState('');
103
+ const [formState, setFormState] = external_react_namespaceObject.useState(NO_FORM);
104
+ const [authType, setAuthType] = external_react_namespaceObject.useState(null);
105
+ const [savedAuthType, setSavedAuthType] = external_react_namespaceObject.useState(null);
106
+ const [values, setValues] = external_react_namespaceObject.useState({});
107
+ const [moreOpen, setMoreOpen] = external_react_namespaceObject.useState(false);
108
+ const [editingConnection, setEditingConnection] = external_react_namespaceObject.useState(false);
109
+ const [loadingConnectionValues, setLoadingConnectionValues] = external_react_namespaceObject.useState(false);
110
+ const [connect, setConnect] = external_react_namespaceObject.useState({
111
+ status: 'idle'
112
+ });
113
+ const [modelsState, setModelsState] = external_react_namespaceObject.useState(NO_MODELS);
114
+ const [modelId, setModelId] = external_react_namespaceObject.useState('');
115
+ const [modelQuery, setModelQuery] = external_react_namespaceObject.useState('');
116
+ const [modelListOpen, setModelListOpen] = external_react_namespaceObject.useState(false);
117
+ const [name, setName] = external_react_namespaceObject.useState('');
118
+ const [nameTouched, setNameTouched] = external_react_namespaceObject.useState(false);
119
+ const [useAs, setUseAs] = external_react_namespaceObject.useState('own');
120
+ const [replaces, setReplaces] = external_react_namespaceObject.useState('');
121
+ const [apiType, setApiType] = external_react_namespaceObject.useState('');
122
+ const [test, setTest] = external_react_namespaceObject.useState({
123
+ status: 'idle'
124
+ });
125
+ const ctx = 'ok' === context.status ? context.value : null;
126
+ const providers = ctx?.providers ?? [];
127
+ const folders = ctx?.folders ?? [];
128
+ const folderLabel = (id)=>folders.find((f)=>f.id === id)?.label ?? id;
129
+ const provider = providers.find((p)=>p.id === providerId);
130
+ const providerName = provider?.name ?? '';
131
+ const providerConnections = connections.filter((c)=>c.providerId === providerId);
132
+ const form = formState.form;
133
+ const isNew = connectionChoice === NEW;
134
+ const connection = connections.find((c)=>c.id === connectionChoice) ?? null;
135
+ const connectOutcome = 'ok' === connect.status ? connect.value : null;
136
+ const connected = Boolean(connection) && !editingConnection;
137
+ const loadModels = async (pid, conn, gen)=>{
138
+ if (!conn) return void setModelsState(NO_MODELS);
139
+ setModelsState({
140
+ ...NO_MODELS,
141
+ status: 'loading'
142
+ });
143
+ try {
144
+ const result = await api.listModels(pid, conn);
145
+ if (gen !== generation.current) return;
146
+ result.ok ? setModelsState({
147
+ status: 'ok',
148
+ models: result.value
149
+ }) : setModelsState({
150
+ ...NO_MODELS,
151
+ status: 'error',
152
+ failure: result.failure
153
+ });
154
+ } catch (err) {
155
+ if (gen === generation.current) setModelsState({
156
+ ...NO_MODELS,
157
+ status: 'error',
158
+ failure: unexpected(err)
159
+ });
160
+ }
161
+ };
162
+ const loadForm = async (pid, folder)=>{
163
+ formLoad.current += 1;
164
+ const load = formLoad.current;
165
+ setFormState({
166
+ ...NO_FORM,
167
+ status: 'loading'
168
+ });
169
+ setValues({});
170
+ try {
171
+ const result = await api.loadForm(pid, folder || null);
172
+ if (load !== formLoad.current) return;
173
+ if (!result.ok) return void setFormState({
174
+ ...NO_FORM,
175
+ status: 'error',
176
+ failure: result.failure
177
+ });
178
+ setFormState({
179
+ status: 'ok',
180
+ form: result.value
181
+ });
182
+ setAuthType(result.value.defaultAuthType);
183
+ setValues(defaultsOf(result.value));
184
+ } catch (err) {
185
+ if (load === formLoad.current) setFormState({
186
+ ...NO_FORM,
187
+ status: 'error',
188
+ failure: unexpected(err)
189
+ });
190
+ }
191
+ };
192
+ const resetFormValues = ()=>{
193
+ setAuthType(form.defaultAuthType);
194
+ setValues(defaultsOf(form));
195
+ };
196
+ const startFromSavedModel = (model, loaded, defaultFolder)=>{
197
+ const gen = generation.current;
198
+ const savedConnection = loaded.connections.find((c)=>c.id === model.connectionId) ?? null;
199
+ const savedProvider = loaded.providers.find((p)=>p.id === model.providerId);
200
+ setModelToEdit(model);
201
+ setProviderId(model.providerId);
202
+ setConnectionChoice(savedConnection ? savedConnection.id : NEW);
203
+ setConnName(defaultConnectionName(savedProvider?.name ?? model.providerId, loaded.connections));
204
+ setModelId(model.modelId);
205
+ setName(model.replaces ? '' : model.name);
206
+ setNameTouched(true);
207
+ setUseAs(model.replaces ? 'replacement' : 'own');
208
+ setReplaces(model.replaces ?? '');
209
+ setApiType(model.apiType ?? '');
210
+ loadModels(model.providerId, savedConnection, gen);
211
+ loadForm(model.providerId, savedConnection?.folderId ?? defaultFolder);
212
+ };
213
+ external_react_namespaceObject.useEffect(()=>{
214
+ const gen = generation.current;
215
+ const load = async ()=>{
216
+ const contextResult = await api.loadContext();
217
+ if (gen !== generation.current) return;
218
+ if (!contextResult.ok) return void setContext({
219
+ status: 'error',
220
+ failure: contextResult.failure
221
+ });
222
+ const loaded = contextResult.value;
223
+ let savedModel = null;
224
+ if (editTarget) {
225
+ const modelResult = await api.loadModel(editTarget);
226
+ if (gen !== generation.current) return;
227
+ if (!modelResult.ok) return void setContext({
228
+ status: 'error',
229
+ failure: modelResult.failure
230
+ });
231
+ savedModel = modelResult.value;
232
+ }
233
+ const defaultFolder = loaded.defaultFolderId ?? loaded.folders[0]?.id ?? '';
234
+ setContext({
235
+ status: 'ok',
236
+ value: loaded
237
+ });
238
+ setConnections(loaded.connections);
239
+ setFolderId(defaultFolder);
240
+ if (!loaded.allowsNewNames) setUseAs('replacement');
241
+ if (savedModel) startFromSavedModel(savedModel, loaded, defaultFolder);
242
+ };
243
+ load().catch((err)=>{
244
+ if (gen === generation.current) setContext({
245
+ status: 'error',
246
+ failure: unexpected(err)
247
+ });
248
+ });
249
+ }, [
250
+ api,
251
+ editTarget
252
+ ]);
253
+ const resetDownstream = ()=>{
254
+ setModelQuery('');
255
+ setModelListOpen(false);
256
+ setModelId('');
257
+ setName('');
258
+ setNameTouched(false);
259
+ setTest({
260
+ status: 'idle'
261
+ });
262
+ };
263
+ const chooseProvider = (id)=>{
264
+ if (id === providerId) return;
265
+ generation.current += 1;
266
+ const gen = generation.current;
267
+ const p = providers.find((candidate)=>candidate.id === id);
268
+ const existing = connections.filter((c)=>c.providerId === id);
269
+ setProviderId(id);
270
+ setConnectionChoice(existing[0]?.id ?? NEW);
271
+ setConnName(defaultConnectionName(p?.name ?? id, connections));
272
+ setMoreOpen(false);
273
+ setEditingConnection(false);
274
+ setConnect({
275
+ status: 'idle'
276
+ });
277
+ resetDownstream();
278
+ setUseAs(ctx?.allowsNewNames === false ? 'replacement' : 'own');
279
+ setReplaces('');
280
+ setApiType('');
281
+ loadModels(id, existing[0] ?? null, gen);
282
+ loadForm(id, folderId);
283
+ };
284
+ const chooseConnection = (id)=>{
285
+ generation.current += 1;
286
+ setConnectionChoice(id);
287
+ if (id === NEW) setConnName(defaultConnectionName(providerName, connections));
288
+ setEditingConnection(false);
289
+ setConnect({
290
+ status: 'idle'
291
+ });
292
+ resetFormValues();
293
+ resetDownstream();
294
+ loadModels(providerId, connections.find((c)=>c.id === id) ?? null, generation.current);
295
+ };
296
+ const failConnectionEdit = (failure)=>{
297
+ setEditingConnection(false);
298
+ resetFormValues();
299
+ setConnect({
300
+ status: 'error',
301
+ failure
302
+ });
303
+ loadModels(providerId, connection, generation.current);
304
+ };
305
+ const startConnectionEdit = async ()=>{
306
+ if (!connection) return;
307
+ generation.current += 1;
308
+ const gen = generation.current;
309
+ setEditingConnection(true);
310
+ setConnName(connection.name);
311
+ setMoreOpen(false);
312
+ setConnect({
313
+ status: 'idle'
314
+ });
315
+ setTest({
316
+ status: 'idle'
317
+ });
318
+ resetFormValues();
319
+ setLoadingConnectionValues(true);
320
+ try {
321
+ const result = await api.loadConnectionValues(providerId, connection);
322
+ if (gen !== generation.current) return;
323
+ if (!result.ok) return void failConnectionEdit(result.failure);
324
+ const saved = result.value.authType ?? form.defaultAuthType;
325
+ setSavedAuthType(saved);
326
+ setAuthType(saved);
327
+ setValues({
328
+ ...defaultsOf(form),
329
+ ...result.value.values
330
+ });
331
+ } catch (err) {
332
+ if (gen === generation.current) failConnectionEdit(unexpected(err));
333
+ } finally{
334
+ if (gen === generation.current) setLoadingConnectionValues(false);
335
+ }
336
+ };
337
+ const cancelConnectionEdit = ()=>{
338
+ generation.current += 1;
339
+ setEditingConnection(false);
340
+ setLoadingConnectionValues(false);
341
+ setConnect({
342
+ status: 'idle'
343
+ });
344
+ resetFormValues();
345
+ loadModels(providerId, connection, generation.current);
346
+ };
347
+ const setValue = (key, v)=>{
348
+ setValues((prev)=>({
349
+ ...prev,
350
+ [key]: v
351
+ }));
352
+ if ('error' === connect.status) setConnect({
353
+ status: 'idle'
354
+ });
355
+ };
356
+ const showConnectionForm = Boolean(provider) && (isNew || editingConnection);
357
+ const formFolderId = editingConnection && connection ? connection.folderId : folderId;
358
+ const keepsCurrentValue = (f)=>editingConnection && f.secret && (!f.group || f.group === savedAuthType);
359
+ const isRequired = (f)=>f.required && !keepsCurrentValue(f);
360
+ const fields = shownFields(form, authType);
361
+ const mainFields = fields.filter((f)=>!f.advanced);
362
+ const advancedFields = fields.filter((f)=>f.advanced);
363
+ const requiredFilled = 'ok' === formState.status && fields.filter(isRequired).every((f)=>(values[f.key] ?? '').trim());
364
+ const otherConnections = editingConnection ? connections.filter((c)=>c.id !== connection?.id) : connections;
365
+ const connNameClash = showConnectionForm && otherConnections.some((c)=>c.name.toLowerCase() === connName.trim().toLowerCase());
366
+ const keyLocked = 'running' === connect.status || loadingConnectionValues;
367
+ const canConnect = showConnectionForm && requiredFilled && Boolean(connName.trim()) && Boolean(formFolderId) && !connNameClash && !keyLocked;
368
+ const runConnect = async ()=>{
369
+ if (!canConnect) return;
370
+ const gen = generation.current;
371
+ const existing = editingConnection && connection ? connection : void 0;
372
+ setConnect({
373
+ status: 'running'
374
+ });
375
+ let result;
376
+ try {
377
+ result = await api.connect({
378
+ providerId,
379
+ form,
380
+ authType,
381
+ values,
382
+ name: connName.trim(),
383
+ folderId: formFolderId,
384
+ existing
385
+ });
386
+ } catch (err) {
387
+ result = {
388
+ ok: false,
389
+ failure: unexpected(err)
390
+ };
391
+ }
392
+ if (gen !== generation.current) return;
393
+ if (!result.ok) return void setConnect({
394
+ status: 'error',
395
+ failure: result.failure
396
+ });
397
+ const saved = result.value;
398
+ existing ? setConnections((prev)=>prev.map((c)=>c.id === saved.id ? saved : c)) : setConnections((prev)=>[
399
+ ...prev,
400
+ saved
401
+ ]);
402
+ setConnectionChoice(saved.id);
403
+ setEditingConnection(false);
404
+ resetFormValues();
405
+ setConnect({
406
+ status: 'ok',
407
+ value: {
408
+ connection: saved,
409
+ updated: Boolean(existing)
410
+ }
411
+ });
412
+ loadModels(providerId, saved, gen);
413
+ };
414
+ const pickModel = (id)=>{
415
+ setModelId(id);
416
+ if (!nameTouched) setName(id);
417
+ setTest({
418
+ status: 'idle'
419
+ });
420
+ };
421
+ const takenNames = new Set((ctx?.takenModelNames ?? []).map((n)=>n.toLowerCase()));
422
+ if (editTarget) takenNames.delete(editTarget.name.toLowerCase());
423
+ const reservedNames = new Set((ctx?.reservedModelNames ?? []).map((n)=>n.toLowerCase()));
424
+ const ownName = name.trim();
425
+ let nameProblem = null;
426
+ if (ownName && takenNames.has(ownName.toLowerCase())) nameProblem = labels.nameTaken(ownName);
427
+ else if (ownName && reservedNames.has(ownName.toLowerCase())) nameProblem = labels.nameReserved(ownName);
428
+ const replacementOptions = (ctx?.replaceableModels ?? []).filter((m)=>(!m.replaced || m.name === modelToEdit?.replaces) && Boolean(provider) && api.apiTypes(providerId, m.name).length > 0);
429
+ const canUseOwnName = ctx?.allowsNewNames ?? false;
430
+ const replacing = 'replacement' === useAs;
431
+ const replacement = replacementOptions.find((m)=>m.name === replaces) ?? null;
432
+ const chosenName = replacing ? replacement?.name ?? '' : ownName;
433
+ const nameReady = replacing ? Boolean(replacement) : Boolean(ownName) && !nameProblem;
434
+ const apiTypeOptions = provider && (!replacing || replacement) ? api.apiTypes(providerId, replacing ? replacement?.name ?? null : null) : [];
435
+ const apiTypeKey = apiTypeOptions.map((t)=>t.value).join('|');
436
+ external_react_namespaceObject.useEffect(()=>{
437
+ if (apiTypeOptions.some((t)=>t.value === apiType)) return;
438
+ const first = apiTypeOptions[0]?.value ?? '';
439
+ setApiType(replacing || 1 === apiTypeOptions.length ? first : '');
440
+ }, [
441
+ apiTypeKey,
442
+ replacing,
443
+ apiType
444
+ ]);
445
+ const apiTypeReady = apiTypeOptions.some((t)=>t.value === apiType);
446
+ const busy = keyLocked || 'running' === test.status || 'ok' === test.status;
447
+ const hasModel = Boolean(modelId.trim());
448
+ const readyToSave = connected && hasModel && nameReady && apiTypeReady;
449
+ const runTest = async ()=>{
450
+ if (!connection || !readyToSave || busy) return;
451
+ const gen = generation.current;
452
+ setTest({
453
+ status: 'running'
454
+ });
455
+ let result;
456
+ try {
457
+ result = await api.testAndSave({
458
+ providerId,
459
+ connection,
460
+ modelId: modelId.trim(),
461
+ name: chosenName,
462
+ replaces: replacing ? chosenName : null,
463
+ apiType,
464
+ editing: modelToEdit ?? void 0
465
+ });
466
+ } catch (err) {
467
+ result = {
468
+ ok: false,
469
+ failure: unexpected(err)
470
+ };
471
+ }
472
+ const stillOpen = gen === generation.current;
473
+ if (!result.ok) {
474
+ if (stillOpen) setTest({
475
+ status: 'error',
476
+ failure: result.failure
477
+ });
478
+ return;
479
+ }
480
+ if (stillOpen) onClose();
481
+ try {
482
+ await onSaved(result.value);
483
+ } catch (err) {
484
+ console.error('ByoModelDialog: onSaved failed after the model was saved', err);
485
+ }
486
+ };
487
+ const models = modelsState.models;
488
+ const q = modelQuery.trim().toLowerCase();
489
+ const shownCompatible = models.compatible.filter((m)=>m.id.toLowerCase().includes(q));
490
+ const shownIncompatible = models.incompatible.filter((m)=>m.id.toLowerCase().includes(q));
491
+ const freeTextModel = 'ok' === modelsState.status && models.compatible.length + models.incompatible.length === 0;
492
+ const modelTriggerRef = external_react_namespaceObject.useRef(null);
493
+ const modelSearchRef = external_react_namespaceObject.useRef(null);
494
+ external_react_namespaceObject.useEffect(()=>{
495
+ if ('ok' === connect.status && 'ok' === modelsState.status) modelTriggerRef.current?.focus();
496
+ }, [
497
+ connect.status,
498
+ modelsState.status
499
+ ]);
500
+ const fieldInput = (f, main)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Field, {
501
+ id: `byo-${f.key}`,
502
+ label: f.label,
503
+ hint: keepsCurrentValue(f) ? labels.secretKeepHint : f.hint,
504
+ required: isRequired(f),
505
+ children: f.options?.length ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_select_cjs_namespaceObject.Select, {
506
+ value: values[f.key] || void 0,
507
+ onValueChange: (v)=>setValue(f.key, v),
508
+ disabled: keyLocked,
509
+ children: [
510
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectTrigger, {
511
+ id: `byo-${f.key}`,
512
+ className: "w-full",
513
+ "aria-required": isRequired(f) || void 0,
514
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectValue, {
515
+ placeholder: f.placeholder || void 0
516
+ })
517
+ }),
518
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectContent, {
519
+ container: container,
520
+ children: f.options.map((o)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectItem, {
521
+ value: o.value,
522
+ children: o.label
523
+ }, o.value))
524
+ })
525
+ ]
526
+ }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_cjs_namespaceObject.Input, {
527
+ id: `byo-${f.key}`,
528
+ type: f.secret ? 'password' : 'text',
529
+ autoComplete: "off",
530
+ spellCheck: false,
531
+ placeholder: f.placeholder,
532
+ value: values[f.key] ?? '',
533
+ disabled: keyLocked,
534
+ "aria-required": isRequired(f) || void 0,
535
+ onChange: (e)=>setValue(f.key, e.target.value),
536
+ onKeyDown: main ? (e)=>{
537
+ if ('Enter' === e.key) runConnect();
538
+ } : void 0,
539
+ className: f.secret ? 'font-mono' : void 0
540
+ })
541
+ }, f.key);
542
+ const modelTriggerText = (()=>{
543
+ if (!connected) return labels.modelNeedsConnection(providerName);
544
+ if ('loading' === modelsState.status) return labels.modelsLoading(providerName);
545
+ if ('error' === modelsState.status) return labels.modelsFailed(providerName);
546
+ return labels.modelSelect(models.compatible.length);
547
+ })();
548
+ const connectMessage = (()=>{
549
+ if (!connectOutcome || editingConnection) return null;
550
+ if (connectionChoice !== connectOutcome.connection.id) return null;
551
+ if (connectOutcome.updated) return labels.connectionUpdated;
552
+ return labels.connectedIn(folderLabel(connectOutcome.connection.folderId));
553
+ })();
554
+ let failure = null;
555
+ if ('error' === connect.status) failure = connect.failure;
556
+ else if ('error' === test.status) failure = test.failure;
557
+ else if ('error' === modelsState.status) failure = modelsState.failure ?? null;
558
+ const title = editTarget ? labels.editTitle : labels.title;
559
+ const description = editTarget ? labels.editDescription : labels.description;
560
+ const saveLabel = editTarget ? labels.testAndSave : labels.testAndAdd;
561
+ const saveHint = editTarget ? labels.testAndSaveHint : labels.testAndAddHint;
562
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_dialog_cjs_namespaceObject.DialogContent, {
563
+ container: container,
564
+ strings: {
565
+ close: labels.close
566
+ },
567
+ className: "!flex h-[min(780px,90vh)] !max-w-[600px] flex-col gap-0 overflow-hidden p-0",
568
+ children: [
569
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_dialog_cjs_namespaceObject.DialogHeader, {
570
+ className: "shrink-0 px-6 pt-6 pb-4",
571
+ children: [
572
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_dialog_cjs_namespaceObject.DialogTitle, {
573
+ children: title
574
+ }),
575
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_dialog_cjs_namespaceObject.DialogDescription, {
576
+ children: description
577
+ })
578
+ ]
579
+ }),
580
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
581
+ className: "flex min-h-0 min-w-0 flex-1 flex-col gap-6 overflow-y-auto overflow-x-hidden px-6 pb-4",
582
+ children: [
583
+ 'running' === context.status && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
584
+ className: "flex items-center gap-2 text-xs text-foreground-muted",
585
+ children: [
586
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_spinner_cjs_namespaceObject.Spinner, {
587
+ size: "sm"
588
+ }),
589
+ " ",
590
+ editTarget ? labels.loadingModel : labels.loadingContext
591
+ ]
592
+ }),
593
+ 'error' === context.status && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(FailureAlert, {
594
+ failure: context.failure,
595
+ labels: labels
596
+ }),
597
+ ctx && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
598
+ children: [
599
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Step, {
600
+ n: 1,
601
+ title: labels.providerStep,
602
+ done: Boolean(provider),
603
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_select_cjs_namespaceObject.Select, {
604
+ value: providerId || void 0,
605
+ onValueChange: chooseProvider,
606
+ disabled: busy,
607
+ children: [
608
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectTrigger, {
609
+ className: "w-full",
610
+ "aria-label": labels.providerStep,
611
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectValue, {
612
+ placeholder: labels.providerPlaceholder
613
+ })
614
+ }),
615
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectContent, {
616
+ container: container,
617
+ children: providers.map((p)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectItem, {
618
+ value: p.id,
619
+ children: p.name
620
+ }, p.id))
621
+ })
622
+ ]
623
+ })
624
+ }),
625
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Step, {
626
+ n: 2,
627
+ title: labels.connectionStep,
628
+ done: connected,
629
+ disabled: !provider,
630
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
631
+ className: "flex flex-col gap-3",
632
+ children: [
633
+ !provider && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_cjs_namespaceObject.Input, {
634
+ disabled: true,
635
+ "aria-label": labels.connectionStep,
636
+ placeholder: labels.connectionNeedsProvider
637
+ }),
638
+ provider && providerConnections.length > 0 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_select_cjs_namespaceObject.Select, {
639
+ value: connectionChoice,
640
+ onValueChange: chooseConnection,
641
+ disabled: busy,
642
+ children: [
643
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectTrigger, {
644
+ className: "w-full",
645
+ "aria-label": labels.connectionStep,
646
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectValue, {})
647
+ }),
648
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_select_cjs_namespaceObject.SelectContent, {
649
+ container: container,
650
+ children: [
651
+ providerConnections.map((c)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectItem, {
652
+ value: c.id,
653
+ children: labels.savedConnection(c.name, folderLabel(c.folderId))
654
+ }, c.id)),
655
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectItem, {
656
+ value: NEW,
657
+ children: labels.newConnection
658
+ })
659
+ ]
660
+ })
661
+ ]
662
+ }),
663
+ connectMessage && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("p", {
664
+ className: "flex items-center gap-1.5 text-xs text-success",
665
+ children: [
666
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.CircleCheck, {
667
+ size: 14,
668
+ className: "shrink-0"
669
+ }),
670
+ connectMessage
671
+ ]
672
+ }),
673
+ connection && !editingConnection && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
674
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_button_cjs_namespaceObject.Button, {
675
+ variant: "link",
676
+ size: "2xs",
677
+ className: "h-auto p-0 text-xs",
678
+ disabled: busy || 'ok' !== formState.status,
679
+ onClick: startConnectionEdit,
680
+ children: labels.editConnection
681
+ })
682
+ }),
683
+ showConnectionForm && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
684
+ children: [
685
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(Group, {
686
+ icon: external_lucide_react_namespaceObject.KeyRound,
687
+ title: labels.credentialsTitle(providerName),
688
+ caption: labels.credentialsCaption(providerName),
689
+ children: [
690
+ 'loading' === formState.status && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
691
+ className: "flex items-center gap-2 text-xs text-foreground-muted",
692
+ children: [
693
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_spinner_cjs_namespaceObject.Spinner, {
694
+ size: "sm"
695
+ }),
696
+ " ",
697
+ labels.loadingForm(providerName)
698
+ ]
699
+ }),
700
+ 'error' === formState.status && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(FailureAlert, {
701
+ failure: formState.failure,
702
+ labels: labels
703
+ }),
704
+ loadingConnectionValues && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
705
+ className: "flex items-center gap-2 text-xs text-foreground-muted",
706
+ children: [
707
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_spinner_cjs_namespaceObject.Spinner, {
708
+ size: "sm"
709
+ }),
710
+ " ",
711
+ labels.loadingConnection
712
+ ]
713
+ }),
714
+ form.authTypes.length > 1 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Field, {
715
+ id: "byo-auth-type",
716
+ label: labels.authType,
717
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_select_cjs_namespaceObject.Select, {
718
+ value: authType ?? void 0,
719
+ onValueChange: setAuthType,
720
+ disabled: keyLocked,
721
+ children: [
722
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectTrigger, {
723
+ id: "byo-auth-type",
724
+ className: "w-full",
725
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectValue, {})
726
+ }),
727
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectContent, {
728
+ container: container,
729
+ children: form.authTypes.map((t)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectItem, {
730
+ value: t.value,
731
+ children: t.label
732
+ }, t.value))
733
+ })
734
+ ]
735
+ })
736
+ }),
737
+ mainFields.map((f)=>fieldInput(f, true)),
738
+ advancedFields.length > 0 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_collapsible_cjs_namespaceObject.Collapsible, {
739
+ open: moreOpen,
740
+ onOpenChange: setMoreOpen,
741
+ children: [
742
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_collapsible_cjs_namespaceObject.CollapsibleTrigger, {
743
+ className: "flex items-center gap-1 text-xs font-medium text-foreground-muted hover:text-foreground",
744
+ children: [
745
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.ChevronRight, {
746
+ size: 14,
747
+ className: (0, index_cjs_namespaceObject.cn)('transition-transform', moreOpen && 'rotate-90')
748
+ }),
749
+ labels.moreSettings(providerName),
750
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("span", {
751
+ className: "font-normal text-foreground-subtle",
752
+ children: [
753
+ "\xb7 ",
754
+ labels.optional
755
+ ]
756
+ })
757
+ ]
758
+ }),
759
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_collapsible_cjs_namespaceObject.CollapsibleContent, {
760
+ className: "mt-3 flex flex-col gap-3",
761
+ children: advancedFields.map((f)=>fieldInput(f, false))
762
+ })
763
+ ]
764
+ })
765
+ ]
766
+ }),
767
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(Group, {
768
+ icon: external_lucide_react_namespaceObject.Building2,
769
+ title: labels.inUiPathTitle,
770
+ caption: labels.inUiPathCaption(providerName),
771
+ children: [
772
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
773
+ className: "grid min-w-0 grid-cols-2 gap-3",
774
+ children: [
775
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Field, {
776
+ id: "byo-conn-name",
777
+ label: labels.connectionName,
778
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_cjs_namespaceObject.Input, {
779
+ id: "byo-conn-name",
780
+ value: connName,
781
+ disabled: keyLocked,
782
+ onChange: (e)=>setConnName(e.target.value),
783
+ "aria-invalid": connNameClash
784
+ })
785
+ }),
786
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Field, {
787
+ id: "byo-folder",
788
+ label: labels.folder,
789
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_select_cjs_namespaceObject.Select, {
790
+ value: formFolderId || void 0,
791
+ onValueChange: setFolderId,
792
+ disabled: keyLocked || editingConnection,
793
+ children: [
794
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectTrigger, {
795
+ id: "byo-folder",
796
+ className: "w-full",
797
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectValue, {})
798
+ }),
799
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectContent, {
800
+ container: container,
801
+ children: folders.map((f)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectItem, {
802
+ value: f.id,
803
+ children: f.label
804
+ }, f.id))
805
+ })
806
+ ]
807
+ })
808
+ })
809
+ ]
810
+ }),
811
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
812
+ className: (0, index_cjs_namespaceObject.cn)('text-xs', connNameClash ? 'text-error' : 'text-foreground-muted'),
813
+ children: connNameClash ? labels.connectionNameTaken : labels.folderHint
814
+ })
815
+ ]
816
+ }),
817
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
818
+ className: "flex items-center gap-2",
819
+ children: [
820
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_button_cjs_namespaceObject.Button, {
821
+ variant: "secondary",
822
+ size: "sm",
823
+ disabled: !canConnect,
824
+ onClick: runConnect,
825
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ConnectButtonText, {
826
+ running: 'running' === connect.status,
827
+ editing: editingConnection,
828
+ labels: labels
829
+ })
830
+ }),
831
+ editingConnection && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_button_cjs_namespaceObject.Button, {
832
+ variant: "ghost",
833
+ size: "sm",
834
+ disabled: 'running' === connect.status,
835
+ onClick: cancelConnectionEdit,
836
+ children: labels.cancelConnectionEdit
837
+ })
838
+ ]
839
+ })
840
+ ]
841
+ })
842
+ ]
843
+ })
844
+ }),
845
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Step, {
846
+ n: 3,
847
+ title: labels.modelStep,
848
+ done: hasModel,
849
+ disabled: !connected,
850
+ children: freeTextModel ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_cjs_namespaceObject.Input, {
851
+ ref: modelTriggerRef,
852
+ "aria-label": labels.modelIdLabel,
853
+ placeholder: labels.modelIdPlaceholder,
854
+ value: modelId,
855
+ disabled: busy,
856
+ onChange: (e)=>pickModel(e.target.value)
857
+ }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_popover_cjs_namespaceObject.Popover, {
858
+ open: modelListOpen,
859
+ onOpenChange: (next)=>{
860
+ setModelListOpen(next);
861
+ if (!next) setModelQuery('');
862
+ },
863
+ modal: true,
864
+ children: [
865
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverTrigger, {
866
+ asChild: true,
867
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_button_cjs_namespaceObject.Button, {
868
+ ref: modelTriggerRef,
869
+ variant: "outline",
870
+ role: "combobox",
871
+ "aria-expanded": modelListOpen,
872
+ "aria-label": labels.modelStep,
873
+ disabled: !connected || busy || 'ok' !== modelsState.status,
874
+ className: "w-full justify-between font-normal",
875
+ children: [
876
+ modelId ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
877
+ className: "truncate font-mono text-xs",
878
+ children: modelId
879
+ }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
880
+ className: "truncate text-foreground-muted",
881
+ children: modelTriggerText
882
+ }),
883
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.ChevronDown, {
884
+ className: "shrink-0 opacity-50"
885
+ })
886
+ ]
887
+ })
888
+ }),
889
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverContent, {
890
+ container: container,
891
+ align: "start",
892
+ className: "w-[var(--radix-popover-trigger-width)] overflow-hidden p-0",
893
+ onOpenAutoFocus: (e)=>{
894
+ e.preventDefault();
895
+ modelSearchRef.current?.focus();
896
+ },
897
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_command_cjs_namespaceObject.Command, {
898
+ shouldFilter: false,
899
+ children: [
900
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_command_cjs_namespaceObject.CommandInput, {
901
+ ref: modelSearchRef,
902
+ "aria-label": labels.modelStep,
903
+ placeholder: labels.modelSearch(models.compatible.length + models.incompatible.length),
904
+ value: modelQuery,
905
+ onValueChange: setModelQuery
906
+ }),
907
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_command_cjs_namespaceObject.CommandList, {
908
+ className: "max-h-[280px]",
909
+ children: [
910
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_command_cjs_namespaceObject.CommandEmpty, {
911
+ children: labels.modelNoMatch(modelQuery)
912
+ }),
913
+ shownCompatible.length > 0 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_command_cjs_namespaceObject.CommandGroup, {
914
+ heading: labels.compatibleGroup(shownCompatible.length),
915
+ children: shownCompatible.map((m)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ModelRow, {
916
+ model: m,
917
+ selected: m.id === modelId,
918
+ onSelect: ()=>{
919
+ pickModel(m.id);
920
+ setModelListOpen(false);
921
+ setModelQuery('');
922
+ }
923
+ }, m.id))
924
+ }),
925
+ shownIncompatible.length > 0 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_command_cjs_namespaceObject.CommandGroup, {
926
+ heading: labels.incompatibleGroup(shownIncompatible.length),
927
+ children: shownIncompatible.map((m)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ModelRow, {
928
+ model: m,
929
+ disabled: true
930
+ }, m.id))
931
+ })
932
+ ]
933
+ })
934
+ ]
935
+ })
936
+ })
937
+ ]
938
+ })
939
+ }),
940
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Step, {
941
+ n: 4,
942
+ title: labels.nameStep,
943
+ done: hasModel && nameReady,
944
+ disabled: !hasModel,
945
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
946
+ className: "flex flex-col gap-3",
947
+ children: [
948
+ canUseOwnName && replacementOptions.length > 0 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_radio_group_cjs_namespaceObject.RadioGroup, {
949
+ value: useAs,
950
+ onValueChange: (v)=>{
951
+ setUseAs(v);
952
+ setTest({
953
+ status: 'idle'
954
+ });
955
+ },
956
+ disabled: busy,
957
+ "aria-label": labels.nameStep,
958
+ className: "flex flex-wrap gap-4",
959
+ children: [
960
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
961
+ className: "flex items-center gap-2",
962
+ children: [
963
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_radio_group_cjs_namespaceObject.RadioGroupItem, {
964
+ value: "own",
965
+ id: "byo-use-own"
966
+ }),
967
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_label_cjs_namespaceObject.Label, {
968
+ htmlFor: "byo-use-own",
969
+ className: "text-xs font-normal",
970
+ children: labels.useOwnName
971
+ })
972
+ ]
973
+ }),
974
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
975
+ className: "flex items-center gap-2",
976
+ children: [
977
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_radio_group_cjs_namespaceObject.RadioGroupItem, {
978
+ value: "replacement",
979
+ id: "byo-use-replacement"
980
+ }),
981
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_label_cjs_namespaceObject.Label, {
982
+ htmlFor: "byo-use-replacement",
983
+ className: "text-xs font-normal",
984
+ children: labels.useReplacement
985
+ })
986
+ ]
987
+ })
988
+ ]
989
+ }),
990
+ replacing ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
991
+ className: "flex flex-col gap-1.5",
992
+ children: [
993
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_select_cjs_namespaceObject.Select, {
994
+ value: replacement?.name,
995
+ onValueChange: (v)=>{
996
+ setReplaces(v);
997
+ setTest({
998
+ status: 'idle'
999
+ });
1000
+ },
1001
+ disabled: busy,
1002
+ children: [
1003
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectTrigger, {
1004
+ className: "w-full",
1005
+ "aria-label": labels.useReplacement,
1006
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectValue, {
1007
+ placeholder: labels.replacementPlaceholder
1008
+ })
1009
+ }),
1010
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectContent, {
1011
+ container: container,
1012
+ children: replacementOptions.map((m)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_select_cjs_namespaceObject.SelectItem, {
1013
+ value: m.name,
1014
+ children: [
1015
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
1016
+ className: "font-mono text-xs",
1017
+ children: m.name
1018
+ }),
1019
+ m.retiresOn && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
1020
+ className: "ml-2 text-xs text-foreground-muted",
1021
+ children: labels.deprecated
1022
+ })
1023
+ ]
1024
+ }, m.name))
1025
+ })
1026
+ ]
1027
+ }),
1028
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
1029
+ className: (0, index_cjs_namespaceObject.cn)('text-xs', replacement?.retiresOn ? 'text-warning' : 'text-foreground-muted'),
1030
+ children: replacement?.retiresOn ? labels.retiresOn(replacement.retiresOn) : labels.replacementHint
1031
+ })
1032
+ ]
1033
+ }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1034
+ className: "flex flex-col gap-1.5",
1035
+ children: [
1036
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_cjs_namespaceObject.Input, {
1037
+ "aria-label": labels.nameStep,
1038
+ value: name,
1039
+ disabled: busy,
1040
+ onChange: (e)=>{
1041
+ setName(e.target.value);
1042
+ setNameTouched(true);
1043
+ setTest({
1044
+ status: 'idle'
1045
+ });
1046
+ },
1047
+ "aria-invalid": Boolean(nameProblem)
1048
+ }),
1049
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
1050
+ className: (0, index_cjs_namespaceObject.cn)('text-xs', nameProblem ? 'text-error' : 'text-foreground-muted'),
1051
+ children: nameProblem ?? labels.nameHint
1052
+ })
1053
+ ]
1054
+ })
1055
+ ]
1056
+ })
1057
+ }),
1058
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Step, {
1059
+ n: 5,
1060
+ title: labels.apiTypeStep,
1061
+ done: readyToSave,
1062
+ disabled: !hasModel || !nameReady,
1063
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1064
+ className: "flex flex-col gap-1.5",
1065
+ children: [
1066
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_select_cjs_namespaceObject.Select, {
1067
+ value: apiTypeReady ? apiType : void 0,
1068
+ onValueChange: (v)=>{
1069
+ setApiType(v);
1070
+ setTest({
1071
+ status: 'idle'
1072
+ });
1073
+ },
1074
+ disabled: busy || 0 === apiTypeOptions.length,
1075
+ children: [
1076
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectTrigger, {
1077
+ className: "w-full",
1078
+ "aria-label": labels.apiTypeStep,
1079
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectValue, {
1080
+ placeholder: labels.apiTypePlaceholder
1081
+ })
1082
+ }),
1083
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectContent, {
1084
+ container: container,
1085
+ children: apiTypeOptions.map((t)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectItem, {
1086
+ value: t.value,
1087
+ children: t.label
1088
+ }, t.value))
1089
+ })
1090
+ ]
1091
+ }),
1092
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
1093
+ className: "text-xs text-foreground-muted",
1094
+ children: hasModel && nameReady && 0 === apiTypeOptions.length ? labels.apiTypeNone(providerName) : labels.apiTypeHint
1095
+ })
1096
+ ]
1097
+ })
1098
+ })
1099
+ ]
1100
+ })
1101
+ ]
1102
+ }),
1103
+ failure && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
1104
+ className: "max-h-[40%] shrink-0 overflow-y-auto border-t border-border-subtle px-6 py-3",
1105
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(FailureAlert, {
1106
+ failure: failure,
1107
+ labels: labels
1108
+ })
1109
+ }),
1110
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_dialog_cjs_namespaceObject.DialogFooter, {
1111
+ className: "shrink-0 items-center border-t border-border-subtle px-6 py-4",
1112
+ children: [
1113
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_button_cjs_namespaceObject.Button, {
1114
+ variant: "secondary",
1115
+ onClick: onClose,
1116
+ children: labels.cancel
1117
+ }),
1118
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
1119
+ title: provider ? saveHint(providerName) : void 0,
1120
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_button_cjs_namespaceObject.Button, {
1121
+ onClick: runTest,
1122
+ disabled: !readyToSave || busy,
1123
+ children: 'running' === test.status ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
1124
+ children: [
1125
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_spinner_cjs_namespaceObject.Spinner, {
1126
+ size: "sm"
1127
+ }),
1128
+ " ",
1129
+ labels.testing
1130
+ ]
1131
+ }) : saveLabel
1132
+ })
1133
+ })
1134
+ ]
1135
+ })
1136
+ ]
1137
+ });
1138
+ }
1139
+ function ConnectButtonText({ running, editing, labels }) {
1140
+ if (running) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
1141
+ children: [
1142
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_spinner_cjs_namespaceObject.Spinner, {
1143
+ size: "sm"
1144
+ }),
1145
+ " ",
1146
+ editing ? labels.savingConnection : labels.connecting
1147
+ ]
1148
+ });
1149
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(jsx_runtime_namespaceObject.Fragment, {
1150
+ children: editing ? labels.saveConnection : labels.connect
1151
+ });
1152
+ }
1153
+ const unexpected = (err)=>({
1154
+ title: err instanceof Error ? err.message : String(err)
1155
+ });
1156
+ function Step({ n, title, done, disabled, children }) {
1157
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("fieldset", {
1158
+ disabled: disabled,
1159
+ className: (0, index_cjs_namespaceObject.cn)('m-0 min-w-0 border-0 p-0', disabled && 'opacity-40'),
1160
+ children: [
1161
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("legend", {
1162
+ className: "mb-2 flex items-center gap-2 p-0",
1163
+ children: [
1164
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
1165
+ className: (0, index_cjs_namespaceObject.cn)('grid size-5 shrink-0 place-items-center rounded-full text-xs font-semibold', done ? 'bg-brand text-foreground-on-accent' : 'border border-border text-foreground-muted'),
1166
+ children: done ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Check, {
1167
+ size: 12
1168
+ }) : n
1169
+ }),
1170
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
1171
+ className: "text-sm font-medium text-foreground",
1172
+ children: title
1173
+ })
1174
+ ]
1175
+ }),
1176
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
1177
+ className: "min-w-0 pl-7",
1178
+ children: children
1179
+ })
1180
+ ]
1181
+ });
1182
+ }
1183
+ function Group({ icon: Icon, title, caption, children }) {
1184
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1185
+ className: "flex min-w-0 flex-col gap-3 rounded-xl border border-border-subtle p-3",
1186
+ children: [
1187
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1188
+ className: "flex items-center gap-1.5 text-xs",
1189
+ children: [
1190
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Icon, {
1191
+ size: 13,
1192
+ className: "shrink-0 text-foreground-muted"
1193
+ }),
1194
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
1195
+ className: "font-semibold text-foreground",
1196
+ children: title
1197
+ }),
1198
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("span", {
1199
+ className: "truncate text-foreground-muted",
1200
+ children: [
1201
+ "\xb7 ",
1202
+ caption
1203
+ ]
1204
+ })
1205
+ ]
1206
+ }),
1207
+ children
1208
+ ]
1209
+ });
1210
+ }
1211
+ function Field({ id, label, hint, required, children }) {
1212
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1213
+ className: "flex flex-col gap-1.5",
1214
+ children: [
1215
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_label_cjs_namespaceObject.Label, {
1216
+ htmlFor: id,
1217
+ className: "text-xs",
1218
+ children: [
1219
+ label,
1220
+ required && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
1221
+ "aria-hidden": true,
1222
+ className: "text-error",
1223
+ children: ' *'
1224
+ })
1225
+ ]
1226
+ }),
1227
+ children,
1228
+ hint && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
1229
+ className: "text-xs text-foreground-muted",
1230
+ children: hint
1231
+ })
1232
+ ]
1233
+ });
1234
+ }
1235
+ function FailureAlert({ failure, labels }) {
1236
+ const [showRaw, setShowRaw] = external_react_namespaceObject.useState(false);
1237
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_alert_cjs_namespaceObject.Alert, {
1238
+ variant: "destructive",
1239
+ className: "min-w-0",
1240
+ children: [
1241
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.AlertCircle, {}),
1242
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_alert_cjs_namespaceObject.AlertTitle, {
1243
+ children: failure.title
1244
+ }),
1245
+ failure.detail && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_alert_cjs_namespaceObject.AlertDescription, {
1246
+ className: "break-words",
1247
+ children: [
1248
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_button_cjs_namespaceObject.Button, {
1249
+ variant: "link",
1250
+ size: "2xs",
1251
+ className: "mt-1 block h-auto p-0 text-xs",
1252
+ onClick: ()=>setShowRaw((v)=>!v),
1253
+ children: showRaw ? labels.hideResponse : labels.showResponse
1254
+ }),
1255
+ showRaw && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("pre", {
1256
+ className: "mt-2 max-h-40 overflow-y-auto whitespace-pre-wrap break-words rounded-md bg-surface p-2 font-mono text-xs leading-4 text-foreground-muted",
1257
+ children: failure.detail
1258
+ })
1259
+ ]
1260
+ }),
1261
+ !failure.detail && failure.message && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_alert_cjs_namespaceObject.AlertDescription, {
1262
+ className: "break-words",
1263
+ children: failure.message
1264
+ })
1265
+ ]
1266
+ });
1267
+ }
1268
+ function ModelRow({ model, selected, disabled, onSelect }) {
1269
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_command_cjs_namespaceObject.CommandItem, {
1270
+ value: model.id,
1271
+ onSelect: onSelect,
1272
+ disabled: disabled,
1273
+ title: model.reason,
1274
+ className: "gap-2 py-1.5 data-[disabled=true]:pointer-events-auto data-[disabled=true]:cursor-default",
1275
+ children: [
1276
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Check, {
1277
+ size: 14,
1278
+ className: (0, index_cjs_namespaceObject.cn)('shrink-0', selected ? 'text-foreground-accent' : 'opacity-0')
1279
+ }),
1280
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
1281
+ className: "min-w-0 truncate font-mono text-xs text-foreground",
1282
+ children: model.id
1283
+ }),
1284
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
1285
+ className: "ml-auto min-w-0 shrink truncate pl-2 text-right text-xs text-foreground-muted",
1286
+ children: model.short ?? model.note
1287
+ })
1288
+ ]
1289
+ });
1290
+ }
1291
+ exports.ByoModelDialog = __webpack_exports__.ByoModelDialog;
1292
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
1293
+ "ByoModelDialog"
1294
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
1295
+ Object.defineProperty(exports, '__esModule', {
1296
+ value: true
1297
+ });