@epam/ai-dial-toolset-editor 1.2.0-dev.99 → 1.3.0-dev.5

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/index.js CHANGED
@@ -1,62 +1,83 @@
1
- import { AvatarPickerModal as e, DeploymentCreationFieldErrorCode as t, DeploymentCreationForm as n, EditorLayout as r, EditorSection as i, validateDeploymentCreationFields as a } from "@epam/ai-dial-builder-form";
2
- import { ToolsetAuthTypes as o, ToolsetCredentialsLevel as s, WithLogin as c, dialFileToAttachment as l, getApiErrorDetails as u } from "@epam/ai-dial-chat-hooks";
3
- import { CopyButton as d, TAG_INPUT_TAG_CLASS_NAME as f, mergeClasses as p, useCodeCopy as m } from "@epam/ai-dial-chat-shared";
4
- import { ConfirmationPopup as h, ConfirmationPopupVariant as g, DIAL_ICON_SIZE as _, DIAL_KIT_ICON_STROKE as v, Input as y, NeutralButton as b, PasswordInput as x, PrimaryButton as S, Radio as C, RadioGroup as w, SegmentedControl as ee, Select as T, TagInput as E } from "@epam/ai-dial-ui-kit";
5
- import { memo as D, useCallback as O, useEffect as k, useMemo as A, useRef as j, useState as M } from "react";
6
- import { IconBrandOauth as N, IconKey as P, IconLockOff as F, IconLogin as te, IconLogout as I } from "@tabler/icons-react";
7
- import { Fragment as ne, jsx as L, jsxs as R } from "react/jsx-runtime";
1
+ import { DeploymentCreationFieldErrorCode as e, EntityEditor as t, MetadataField as n, MetadataForm as r, SEMVER_VERSION_PATTERN as i, useMetadataForm as a, validateDeploymentCreationFields as o } from "@epam/ai-dial-builder-form";
2
+ import { ToolsetAuthTypes as s, ToolsetCredentialsLevel as c, WithLogin as l, dialFileToAttachment as u, getApiErrorDetails as d } from "@epam/ai-dial-chat-hooks";
3
+ import { CopyButton as f, ENTITY_DESCRIPTION_MAX_LENGTH as p, ENTITY_NAME_MAX_LENGTH as m, TAG_INPUT_TAG_CLASS_NAME as h, TextRefinementField as g, mergeClasses as _, useCodeCopy as v, useTextRefinement as y } from "@epam/ai-dial-chat-shared";
4
+ import { memo as b, useCallback as x, useEffect as S, useMemo as C, useRef as ee, useState as w } from "react";
5
+ import { IconBrandOauth as T, IconKey as te, IconLockOff as ne, IconLogin as E, IconLogout as re } from "@tabler/icons-react";
6
+ import { jsx as D, jsxs as O } from "react/jsx-runtime";
7
+ import { ConfirmationPopup as ie, ConfirmationPopupVariant as ae, DIAL_ICON_SIZE as k, DIAL_KIT_ICON_STROKE as A, Input as j, NeutralButton as M, PasswordInput as N, Radio as P, RadioGroup as F, SegmentedControl as I, Select as L, TagInput as oe } from "@epam/ai-dial-ui-kit";
8
8
  //#region src/constants/public-class-names.ts
9
- var z = {
9
+ var se = {
10
10
  metadataSection: "dial-toolset-editor-metadata-section",
11
11
  setupSection: "dial-toolset-editor-setup-section"
12
- }, B = /* @__PURE__ */ function(e) {
12
+ }, R = /* @__PURE__ */ function(e) {
13
13
  return e.Http = "HTTP", e.Sse = "SSE", e;
14
- }({}), V = "New toolset", H = "0.0.1", U = {
15
- [o.OAuth]: N,
16
- [o.ApiKey]: P,
17
- [o.None]: F
18
- }, W = ({ defaultName: e = V, existingNames: t }) => {
14
+ }({}), z = "New toolset", B = "1.0.0", ce = { validateVersionPattern: i }, V = {
15
+ [s.OAuth]: T,
16
+ [s.ApiKey]: te,
17
+ [s.None]: ne
18
+ }, H = ({ defaultName: e = z, existingNames: t }) => {
19
19
  let n = new Set(t);
20
20
  if (!n.has(e)) return e;
21
21
  let r = 1;
22
22
  for (; n.has(`${e} ${r}`);) r += 1;
23
23
  return `${e} ${r}`;
24
- }, G = () => ({
25
- authenticationType: o.None,
26
- withLogin: c.WithoutLogin,
24
+ }, le = () => ({
25
+ authenticationType: s.None,
26
+ withLogin: l.WithoutLogin,
27
27
  isLoggedIn: !1
28
- }), K = (e = []) => ({
29
- name: W({ existingNames: e }),
30
- version: H,
28
+ }), U = (e = []) => ({
29
+ name: H({ existingNames: e }),
30
+ version: B,
31
31
  iconUrl: "",
32
32
  description: "",
33
33
  topics: [],
34
34
  otherLocales: [],
35
35
  endpoint: "",
36
- protocol: B.Http,
36
+ protocol: R.Http,
37
37
  allowedTools: [],
38
- auth: G()
39
- }), q = (e) => {
38
+ auth: le()
39
+ }), W = (e) => {
40
40
  if (!/^https?:\/\//.test(e) || e.endsWith(".") || e.endsWith("//")) return !1;
41
41
  try {
42
42
  return !!new URL(e);
43
43
  } catch {
44
44
  return !1;
45
45
  }
46
- }, J = (e) => q(e.trim()), Y = (e) => e.replace(/^(https?):\/([^/])/, "$1://$2"), X = (e) => {
46
+ }, G = (e) => W(e.trim()), K = (e) => e.replace(/^(https?):\/([^/])/, "$1://$2"), q = (e) => {
47
47
  let t = e?.trim() ?? "";
48
- if (!t || q(t)) return t;
48
+ if (!t || W(t)) return t;
49
49
  let n = [t];
50
50
  try {
51
51
  let e = decodeURIComponent(t);
52
52
  e !== t && n.push(e);
53
53
  } catch {}
54
54
  for (let e of n) {
55
- let t = Y(e);
56
- if (q(t)) return t;
55
+ let t = K(e);
56
+ if (W(t)) return t;
57
57
  }
58
58
  return t;
59
- }, Z = (e) => !e?.trim() || J(e), Q = (e, t = !1) => e.isLoggedIn ? !0 : e.authenticationType === o.ApiKey ? e.keyHeader?.trim() ? e.withLogin === c.WithoutLogin ? !0 : !!(e.keyHeader?.trim() && e.apiKey?.trim()) : !1 : e.authenticationType === o.OAuth && e.withLogin === c.WithConfig ? !!e.clientId?.trim() && (t || !!e.clientSecret?.trim()) && Z(e.authorizationEndpoint) && Z(e.tokenEndpoint) : !0, re = (e, t = !1) => Object.keys(a(e, { validateVersionPattern: !0 })).length === 0 && J(e.endpoint) && Q(e.auth, t), ie = {
59
+ }, J = (e) => !e?.trim() || G(e), Y = (e, t = !1) => e.isLoggedIn ? !0 : e.authenticationType === s.ApiKey ? e.keyHeader?.trim() ? e.withLogin === l.WithoutLogin ? !0 : !!(e.keyHeader?.trim() && e.apiKey?.trim()) : !1 : e.authenticationType === s.OAuth && e.withLogin === l.WithConfig ? !!e.clientId?.trim() && (t || !!e.clientSecret?.trim()) && J(e.authorizationEndpoint) && J(e.tokenEndpoint) : !0, ue = (e, t = !1) => Object.keys(o(e, ce)).length === 0 && G(e.endpoint) && Y(e.auth, t), de = new Set([
60
+ "name",
61
+ "description",
62
+ "iconUrl",
63
+ "version",
64
+ "topics",
65
+ "otherLocales"
66
+ ]), fe = (e) => ({
67
+ name: e.name,
68
+ description: e.description,
69
+ iconUrl: e.iconUrl,
70
+ version: e.version,
71
+ topics: e.topics,
72
+ otherLocales: e.otherLocales
73
+ }), pe = (e) => {
74
+ let t = {}, n = {};
75
+ for (let [r, i] of Object.entries(e)) (de.has(r) ? t : n)[r] = i;
76
+ return {
77
+ metadata: t,
78
+ setup: n
79
+ };
80
+ }, X = {
60
81
  name: {
61
82
  label: "Name",
62
83
  placeholder: "Enter name"
@@ -95,381 +116,356 @@ var z = {
95
116
  saveLabel: "Save"
96
117
  },
97
118
  ariaLabel: "General"
98
- }, ae = {
99
- title: "Add avatar",
100
- attachLabel: "Attach",
101
- emptyTitle: "This folder is empty",
102
- emptyDescription: "",
103
- errorMessage: "Failed to load files",
104
- retryLabel: "Retry",
105
- hiddenFilesLabel: "Hidden files",
106
- showHiddenFilesLabel: "Show hidden files",
107
- hideHiddenFilesLabel: "Hide hidden files",
108
- getSelectionLabel: (e) => e === 1 ? `${e} item selected` : `${e} items selected`,
109
- uploadFilesLabel: "Upload files",
110
- newFolderLabel: "New folder",
111
- downloadLabel: "Download",
112
- downloadingLabel: "Preparing download…",
113
- deleteLabel: "Delete",
114
- deletingLabel: "Deleting…",
115
- deleteConfirmTitleSingle: "Confirm deleting",
116
- deleteConfirmTitleMultiple: "Confirm deleting items",
117
- deleteConfirmSingleText: "Are you sure you want to delete",
118
- deleteConfirmMultipleText: "Do you want to delete following",
119
- deleteConfirmItemsLabel: "items?",
120
- deleteConfirmLabel: "Delete",
121
- deleteCancelLabel: "Cancel",
122
- uploadProgressTitle: "Uploading files",
123
- cancelLabel: "Cancel"
124
- }, oe = ({ form: t, errors: r, bucket: i, FileManagerModal: a, resolveIconUrl: o, allowedMimeTypes: s, maxFileSizeBytes: c, availableLocaleOptions: u, onChange: d, onNameBlur: f, onVersionBlur: p, labels: m }) => {
125
- let [h, g] = M(!1), _ = m?.form ?? ie, v = m?.avatarPicker ?? ae, y = A(() => o(t.iconUrl), [t.iconUrl, o]);
126
- return /* @__PURE__ */ R(ne, { children: [/* @__PURE__ */ L(n, {
127
- values: {
128
- name: t.name,
129
- description: t.description,
130
- iconUrl: t.iconUrl,
131
- version: t.version,
132
- topics: t.topics,
133
- otherLocales: t.otherLocales
134
- },
135
- errors: r,
136
- onChange: d,
137
- onNameBlur: f,
138
- onVersionBlur: p,
139
- iconPreviewUrl: y,
140
- onAddAvatarClick: () => g(!0),
141
- labels: _,
142
- availableLocaleOptions: u
143
- }), /* @__PURE__ */ L(e, {
144
- isOpen: h,
145
- onClose: () => g(!1),
146
- onAttach: (e) => {
147
- let [t] = e.files, n = t ? l(t, i, { resolvePreviewUrl: o }) : null;
148
- n?.url && d({ iconUrl: n.url }), g(!1);
149
- },
150
- bucket: i,
151
- FileManagerModal: a,
152
- allowedMimeTypes: s,
153
- maxFileSizeBytes: c,
154
- labels: v
155
- })] });
156
- }, $ = /* @__PURE__ */ function(e) {
119
+ }, me = ({ form: e, errors: t, bucket: n, FileManagerModal: i, resolveIconUrl: a, allowedMimeTypes: o, maxFileSizeBytes: s, availableLocaleOptions: c, onChange: l, onNameBlur: d, onVersionBlur: f, renderDescription: p, labels: m }) => {
120
+ let h = x((e) => {
121
+ let [t] = e.files;
122
+ return (t ? u(t, n, { resolvePreviewUrl: a }) : null)?.url;
123
+ }, [n, a]);
124
+ return /* @__PURE__ */ D(r, {
125
+ values: e,
126
+ errors: t,
127
+ onChange: l,
128
+ onNameBlur: d,
129
+ onVersionBlur: f,
130
+ avatarPicker: C(() => ({
131
+ bucket: n,
132
+ FileManagerModal: i,
133
+ resolveIconUrl: a,
134
+ resolveAttachedIconUrl: h,
135
+ allowedMimeTypes: o,
136
+ maxFileSizeBytes: s
137
+ }), [
138
+ n,
139
+ i,
140
+ a,
141
+ h,
142
+ o,
143
+ s
144
+ ]),
145
+ availableLocaleOptions: c,
146
+ renderDescription: p,
147
+ labels: C(() => ({
148
+ form: m?.form ?? X,
149
+ avatarPicker: m?.avatarPicker
150
+ }), [m?.form, m?.avatarPicker])
151
+ });
152
+ }, Z = /* @__PURE__ */ function(e) {
157
153
  return e.Success = "success", e.Cancelled = "cancelled", e.PopupBlocked = "popup-blocked", e.InvalidConfig = "invalid-config", e.Failed = "failed", e;
158
- }({}), se = (e, t) => e === o.None ? c.WithoutLogin : e === o.OAuth && !t ? c.WithConfig : c.WithLogin, ce = (e, t) => e === o.None ? t?.typeNone ?? "Open access" : e === o.OAuth ? t?.typeOAuth ?? "OAuth" : t?.typeApiKey ?? "API Key", le = ({ auth: e, errors: t, isSaving: n, toolsetId: r, isEditMode: i, endpoint: a, authActions: l, onOAuthLogin: d, onNotifySuccess: p, onNotifyError: m, onAuthChange: S, onEnsureSaved: w, labels: T }) => {
159
- let [D, O] = M(!1), [k, A] = M(!1), j = e.isLoggedIn || n || D, N = J(a) && Q(e, i) && !j, P = (t) => {
160
- j || t === e.authenticationType || S({
154
+ }({}), Q = (e) => e === s.None ? l.WithoutLogin : l.WithLogin, he = (e, t) => e === s.None ? t?.typeNone ?? "Open access" : e === s.OAuth ? t?.typeOAuth ?? "OAuth" : t?.typeApiKey ?? "API Key", ge = ({ auth: e, errors: t, isSaving: n, toolsetId: r, isEditMode: i, endpoint: a, authActions: o, onOAuthLogin: u, onNotifySuccess: f, onNotifyError: p, onAuthChange: m, onEnsureSaved: g, labels: _ }) => {
155
+ let [v, y] = w(!1), [b, x] = w(!1), S = e.isLoggedIn || n || v, C = G(a) && Y(e, i) && !S, ee = (t) => {
156
+ S || t === e.authenticationType || m({
161
157
  authenticationType: t,
162
- withLogin: se(t, !!e.clientId?.trim())
158
+ withLogin: Q(t)
163
159
  });
164
- }, F = (e) => {
165
- S({ withLogin: e });
166
- }, ne = (e) => {
167
- switch (e.auth != null && S(e.auth), e.status) {
168
- case $.Success:
169
- S({ isLoggedIn: !0 }), p(T?.loginSuccessMessage ?? "Successfully logged in.");
160
+ }, T = (e) => {
161
+ m({ withLogin: e });
162
+ }, te = (e) => {
163
+ switch (e.auth != null && m(e.auth), e.status) {
164
+ case Z.Success:
165
+ m({ isLoggedIn: !0 }), f(_?.loginSuccessMessage ?? "Successfully logged in.");
170
166
  return;
171
- case $.PopupBlocked:
172
- m(T?.errorPopupBlocked ?? "The login popup was blocked by your browser. Please allow popups for this site and try again.");
167
+ case Z.PopupBlocked:
168
+ p(_?.errorPopupBlocked ?? "The login popup was blocked by your browser. Please allow popups for this site and try again.");
173
169
  return;
174
- case $.InvalidConfig:
175
- m(T?.errorOAuthConfigMissing ?? "The OAuth provider did not return a valid client configuration. Please check the endpoint or contact your administrator.");
170
+ case Z.InvalidConfig:
171
+ p(_?.errorOAuthConfigMissing ?? "The OAuth provider did not return a valid client configuration. Please check the endpoint or contact your administrator.");
176
172
  return;
177
- case $.Failed:
178
- m(T?.errorLoginFailed ?? "Failed to log in. Please check your credentials and try again.", e.traceId);
173
+ case Z.Failed:
174
+ p(_?.errorLoginFailed ?? "Failed to log in. Please check your credentials and try again.", e.traceId);
179
175
  return;
180
- case $.Cancelled: return;
176
+ case Z.Cancelled: return;
181
177
  }
182
- }, z = async () => {
183
- if (!N) return;
184
- if (e.authenticationType === o.OAuth) {
185
- O(!0);
178
+ }, ne = async () => {
179
+ if (!C) return;
180
+ if (e.authenticationType === s.OAuth) {
181
+ y(!0);
186
182
  try {
187
- ne(await d({
183
+ te(await u({
188
184
  auth: e,
189
- ensureSaved: w
185
+ ensureSaved: g
190
186
  }));
191
187
  } finally {
192
- O(!1);
188
+ y(!1);
193
189
  }
194
190
  return;
195
191
  }
196
- let t = await w();
192
+ let t = await g();
197
193
  if (t) {
198
- O(!0);
194
+ y(!0);
199
195
  try {
200
196
  let n = {
201
197
  url: t,
202
- credentialsLevel: s.User,
198
+ credentialsLevel: c.User,
203
199
  authenticationType: e.authenticationType,
204
200
  apiKey: e.apiKey?.trim()
205
201
  };
206
- await l.login(t, n), S({ isLoggedIn: !0 }), p(T?.loginSuccessMessage ?? "Successfully logged in.");
202
+ await o.login(t, n), m({ isLoggedIn: !0 }), f(_?.loginSuccessMessage ?? "Successfully logged in.");
207
203
  } catch (e) {
208
- let { traceId: t } = await u(e);
209
- m(T?.errorLoginFailed ?? "Failed to log in. Please check your credentials and try again.", t);
204
+ let { traceId: t } = await d(e);
205
+ p(_?.errorLoginFailed ?? "Failed to log in. Please check your credentials and try again.", t);
210
206
  } finally {
211
- O(!1);
207
+ y(!1);
212
208
  }
213
209
  }
214
- }, B = async () => {
215
- O(!0);
210
+ }, F = async () => {
211
+ y(!0);
216
212
  try {
217
213
  let t = {
218
214
  url: r,
219
- credentialsLevel: s.User,
215
+ credentialsLevel: c.User,
220
216
  authenticationType: e.authenticationType
221
217
  };
222
- await l.logout(r, t), S({ isLoggedIn: !1 }), A(!1), p(T?.logoutSuccessMessage ?? "Successfully logged out.");
218
+ await o.logout(r, t), m({ isLoggedIn: !1 }), x(!1), f(_?.logoutSuccessMessage ?? "Successfully logged out.");
223
219
  } catch (e) {
224
- let { traceId: t } = await u(e);
225
- m(T?.errorLogoutFailed ?? "Failed to log out. Please try again.", t);
220
+ let { traceId: t } = await d(e);
221
+ p(_?.errorLogoutFailed ?? "Failed to log out. Please try again.", t);
226
222
  } finally {
227
- O(!1);
223
+ y(!1);
228
224
  }
229
- }, V = () => e.isLoggedIn ? /* @__PURE__ */ L("div", {
225
+ }, L = () => e.isLoggedIn ? /* @__PURE__ */ D("div", {
230
226
  className: "flex",
231
- children: /* @__PURE__ */ L(b, {
232
- label: T?.logOutLabel ?? "Log out",
233
- iconBefore: /* @__PURE__ */ L(I, {
234
- size: _.MD,
235
- stroke: v
227
+ children: /* @__PURE__ */ D(M, {
228
+ label: _?.logOutLabel ?? "Log out",
229
+ iconBefore: /* @__PURE__ */ D(re, {
230
+ size: k.MD,
231
+ stroke: A
236
232
  }),
237
- onClick: () => A(!0),
238
- disabled: n || D
233
+ onClick: () => x(!0),
234
+ disabled: n || v
239
235
  })
240
- }) : /* @__PURE__ */ L("div", {
236
+ }) : /* @__PURE__ */ D("div", {
241
237
  className: "flex",
242
- children: /* @__PURE__ */ L(b, {
243
- label: T?.logInLabel ?? "Log in",
244
- iconBefore: /* @__PURE__ */ L(te, {
245
- size: _.MD,
246
- stroke: v
238
+ children: /* @__PURE__ */ D(M, {
239
+ label: _?.logInLabel ?? "Log in",
240
+ iconBefore: /* @__PURE__ */ D(E, {
241
+ size: k.MD,
242
+ stroke: A
247
243
  }),
248
- onClick: z,
249
- disabled: !N
244
+ onClick: ne,
245
+ disabled: !C
250
246
  })
251
247
  });
252
- return /* @__PURE__ */ R("section", {
248
+ return /* @__PURE__ */ O("section", {
253
249
  className: "flex flex-col gap-2",
254
250
  children: [
255
- /* @__PURE__ */ L("h3", {
251
+ /* @__PURE__ */ D("h3", {
256
252
  className: "dial-h3-text",
257
- children: T?.sectionTitle ?? "Authentication"
253
+ children: _?.sectionTitle ?? "Authentication"
258
254
  }),
259
- /* @__PURE__ */ L(ee, {
260
- "aria-label": T?.sectionTitle ?? "Authentication",
255
+ /* @__PURE__ */ D(I, {
256
+ "aria-label": _?.sectionTitle ?? "Authentication",
261
257
  value: e.authenticationType,
262
- onChange: (e) => P(e),
258
+ onChange: (e) => ee(e),
263
259
  segmentClassName: "px-2",
264
260
  items: [
265
- o.None,
266
- o.OAuth,
267
- o.ApiKey
261
+ s.None,
262
+ s.OAuth,
263
+ s.ApiKey
268
264
  ].map((t) => {
269
- let n = U[t];
265
+ let n = V[t];
270
266
  return {
271
267
  value: t,
272
- label: /* @__PURE__ */ R("div", {
268
+ label: /* @__PURE__ */ O("div", {
273
269
  className: "flex items-center gap-2",
274
- children: [/* @__PURE__ */ L(n, {
270
+ children: [/* @__PURE__ */ D(n, {
275
271
  className: "shrink-0",
276
- size: _.SM,
277
- stroke: v,
272
+ size: k.SM,
273
+ stroke: A,
278
274
  "aria-hidden": !0
279
- }), /* @__PURE__ */ L("span", {
275
+ }), /* @__PURE__ */ D("span", {
280
276
  className: "sr-only desktop:not-sr-only",
281
- children: ce(t, T)
277
+ children: he(t, _)
282
278
  })]
283
279
  }),
284
- disabled: j && e.authenticationType !== t
280
+ disabled: S && e.authenticationType !== t
285
281
  };
286
282
  })
287
283
  }),
288
- e.authenticationType === o.None && /* @__PURE__ */ L("p", {
284
+ e.authenticationType === s.None && /* @__PURE__ */ D("p", {
289
285
  className: "dial-small-text pt-2 text-secondary",
290
- children: T?.openAccessDescription ?? "Open endpoint, no credentials"
286
+ children: _?.openAccessDescription ?? "Open endpoint, no credentials"
291
287
  }),
292
- e.authenticationType === o.OAuth && /* @__PURE__ */ R("div", {
288
+ e.authenticationType === s.OAuth && /* @__PURE__ */ O("div", {
293
289
  className: "flex flex-col gap-3 pt-2",
294
290
  children: [
295
- /* @__PURE__ */ R("div", {
291
+ /* @__PURE__ */ O("div", {
296
292
  className: "flex flex-col gap-2",
297
- children: [/* @__PURE__ */ L(C, {
293
+ children: [/* @__PURE__ */ D(P, {
298
294
  name: "oauth-login-mode",
299
295
  id: "oauth-with-login",
300
- value: c.WithLogin,
301
- labelProps: { label: T?.withLoginOAuthLabel ?? "Standard login" },
302
- isSelected: e.withLogin === c.WithLogin,
303
- disabled: j,
304
- onChange: F
305
- }), /* @__PURE__ */ L(C, {
296
+ value: l.WithLogin,
297
+ labelProps: { label: _?.withLoginOAuthLabel ?? "Standard login" },
298
+ isSelected: e.withLogin === l.WithLogin,
299
+ disabled: S,
300
+ onChange: T
301
+ }), /* @__PURE__ */ D(P, {
306
302
  name: "oauth-login-mode",
307
303
  id: "oauth-with-config",
308
- value: c.WithConfig,
309
- labelProps: { label: T?.withConfigOAuthLabel ?? "Custom login" },
310
- isSelected: e.withLogin === c.WithConfig,
311
- disabled: j,
312
- onChange: F
304
+ value: l.WithConfig,
305
+ labelProps: { label: _?.withConfigOAuthLabel ?? "Custom login" },
306
+ isSelected: e.withLogin === l.WithConfig,
307
+ disabled: S,
308
+ onChange: T
313
309
  })]
314
310
  }),
315
- e.withLogin === c.WithConfig && /* @__PURE__ */ R("div", {
311
+ e.withLogin === l.WithConfig && /* @__PURE__ */ O("div", {
316
312
  className: "flex flex-col gap-3",
317
313
  children: [
318
- /* @__PURE__ */ L(y, {
314
+ /* @__PURE__ */ D(j, {
319
315
  id: "toolset-client-id",
320
316
  value: e.clientId ?? "",
321
- onChange: (e) => S({ clientId: e ?? "" }),
317
+ onChange: (e) => m({ clientId: e ?? "" }),
322
318
  labelProps: {
323
- label: T?.clientIdLabel ?? "Client ID",
319
+ label: _?.clientIdLabel ?? "Client ID",
324
320
  required: !0
325
321
  },
326
- placeholder: T?.clientIdPlaceholder ?? "Enter client ID",
322
+ placeholder: _?.clientIdPlaceholder ?? "Enter client ID",
327
323
  error: t.clientId || void 0,
328
324
  invalid: !!t.clientId,
329
- disabled: j
325
+ disabled: S
330
326
  }),
331
- /* @__PURE__ */ L(x, {
327
+ /* @__PURE__ */ D(N, {
332
328
  id: "toolset-client-secret",
333
329
  value: e.clientSecret ?? "",
334
- onChange: (e) => S({ clientSecret: e ?? "" }),
330
+ onChange: (e) => m({ clientSecret: e ?? "" }),
335
331
  labelProps: {
336
- label: T?.clientSecretLabel ?? "Client secret",
332
+ label: _?.clientSecretLabel ?? "Client secret",
337
333
  required: !i
338
334
  },
339
- placeholder: T?.clientSecretPlaceholder ?? "Enter client secret",
340
- showPasswordLabel: T?.showClientSecretLabel ?? "Show client secret",
341
- hidePasswordLabel: T?.hideClientSecretLabel ?? "Hide client secret",
335
+ placeholder: _?.clientSecretPlaceholder ?? "Enter client secret",
336
+ showPasswordLabel: _?.showClientSecretLabel ?? "Show client secret",
337
+ hidePasswordLabel: _?.hideClientSecretLabel ?? "Hide client secret",
342
338
  error: t.clientSecret || void 0,
343
339
  invalid: !!t.clientSecret,
344
- disabled: j
340
+ disabled: S
345
341
  }),
346
- /* @__PURE__ */ L(y, {
342
+ /* @__PURE__ */ D(j, {
347
343
  id: "toolset-authorization-endpoint",
348
344
  value: e.authorizationEndpoint ?? "",
349
- onChange: (e) => S({ authorizationEndpoint: e ?? "" }),
350
- labelProps: { label: T?.authorizationEndpointLabel ?? "Authorization endpoint" },
351
- placeholder: T?.authorizationEndpointPlaceholder ?? "Enter authorization endpoint",
345
+ onChange: (e) => m({ authorizationEndpoint: e ?? "" }),
346
+ labelProps: { label: _?.authorizationEndpointLabel ?? "Authorization endpoint" },
347
+ placeholder: _?.authorizationEndpointPlaceholder ?? "Enter authorization endpoint",
352
348
  error: t.authorizationEndpoint || void 0,
353
349
  invalid: !!t.authorizationEndpoint,
354
- disabled: j
350
+ disabled: S
355
351
  }),
356
- /* @__PURE__ */ L(y, {
352
+ /* @__PURE__ */ D(j, {
357
353
  id: "toolset-token-endpoint",
358
354
  value: e.tokenEndpoint ?? "",
359
- onChange: (e) => S({ tokenEndpoint: e ?? "" }),
360
- labelProps: { label: T?.tokenEndpointLabel ?? "Token endpoint" },
361
- placeholder: T?.tokenEndpointPlaceholder ?? "Enter token endpoint",
355
+ onChange: (e) => m({ tokenEndpoint: e ?? "" }),
356
+ labelProps: { label: _?.tokenEndpointLabel ?? "Token endpoint" },
357
+ placeholder: _?.tokenEndpointPlaceholder ?? "Enter token endpoint",
362
358
  error: t.tokenEndpoint || void 0,
363
359
  invalid: !!t.tokenEndpoint,
364
- disabled: j
360
+ disabled: S
365
361
  }),
366
- /* @__PURE__ */ L(E, {
362
+ /* @__PURE__ */ D(oe, {
367
363
  id: "toolset-scopes",
368
- labelProps: { label: T?.scopesLabel ?? "Scopes" },
369
- placeholder: T?.scopesPlaceholder ?? "Enter scopes",
364
+ labelProps: { label: _?.scopesLabel ?? "Scopes" },
365
+ placeholder: _?.scopesPlaceholder ?? "Enter scopes",
370
366
  value: e.scopes ?? [],
371
- onChange: (e) => S({ scopes: e }),
372
- disabled: j,
373
- tagClassName: f
367
+ onChange: (e) => m({ scopes: e }),
368
+ disabled: S,
369
+ tagClassName: h
374
370
  })
375
371
  ]
376
372
  }),
377
- V()
373
+ L()
378
374
  ]
379
375
  }),
380
- e.authenticationType === o.ApiKey && /* @__PURE__ */ R("div", {
376
+ e.authenticationType === s.ApiKey && /* @__PURE__ */ O("div", {
381
377
  className: "flex flex-col gap-3 pt-2",
382
378
  children: [
383
- /* @__PURE__ */ R("div", {
379
+ /* @__PURE__ */ O("div", {
384
380
  className: "flex flex-col gap-2",
385
- children: [/* @__PURE__ */ L(C, {
381
+ children: [/* @__PURE__ */ D(P, {
386
382
  name: "apikey-login-mode",
387
383
  id: "apikey-with-login",
388
- value: c.WithLogin,
389
- labelProps: { label: T?.withLoginLabel ?? "With login" },
390
- isSelected: e.withLogin === c.WithLogin,
391
- disabled: j,
392
- onChange: F
393
- }), /* @__PURE__ */ L(C, {
384
+ value: l.WithLogin,
385
+ labelProps: { label: _?.withLoginLabel ?? "With login" },
386
+ isSelected: e.withLogin === l.WithLogin,
387
+ disabled: S,
388
+ onChange: T
389
+ }), /* @__PURE__ */ D(P, {
394
390
  name: "apikey-login-mode",
395
391
  id: "apikey-without-login",
396
- value: c.WithoutLogin,
397
- labelProps: { label: T?.withoutLoginLabel ?? "Without login" },
398
- isSelected: e.withLogin === c.WithoutLogin,
399
- disabled: j,
400
- onChange: F
392
+ value: l.WithoutLogin,
393
+ labelProps: { label: _?.withoutLoginLabel ?? "Without login" },
394
+ isSelected: e.withLogin === l.WithoutLogin,
395
+ disabled: S,
396
+ onChange: T
401
397
  })]
402
398
  }),
403
- /* @__PURE__ */ R("div", {
399
+ /* @__PURE__ */ O("div", {
404
400
  className: "flex flex-col gap-3",
405
- children: [/* @__PURE__ */ L(y, {
401
+ children: [/* @__PURE__ */ D(j, {
406
402
  id: "toolset-key-header",
407
403
  value: e.keyHeader ?? "",
408
- onChange: (e) => S({ keyHeader: e ?? "" }),
404
+ onChange: (e) => m({ keyHeader: e ?? "" }),
409
405
  labelProps: {
410
- label: T?.keyHeaderLabel ?? "API Key parameter name",
406
+ label: _?.keyHeaderLabel ?? "API Key parameter name",
411
407
  required: !0
412
408
  },
413
- placeholder: T?.keyHeaderPlaceholder ?? "Enter API key parameter name",
409
+ placeholder: _?.keyHeaderPlaceholder ?? "Enter API key parameter name",
414
410
  error: t.keyHeader || void 0,
415
411
  invalid: !!t.keyHeader,
416
- disabled: j
417
- }), e.withLogin === c.WithLogin && /* @__PURE__ */ L(x, {
412
+ disabled: S
413
+ }), e.withLogin === l.WithLogin && /* @__PURE__ */ D(N, {
418
414
  id: "toolset-api-key",
419
415
  value: e.apiKey ?? "",
420
- onChange: (e) => S({ apiKey: e ?? "" }),
416
+ onChange: (e) => m({ apiKey: e ?? "" }),
421
417
  labelProps: {
422
- label: T?.apiKeyLabel ?? "API key",
418
+ label: _?.apiKeyLabel ?? "API key",
423
419
  required: !0
424
420
  },
425
- placeholder: T?.apiKeyPlaceholder ?? "Enter API key",
426
- showPasswordLabel: T?.showApiKeyLabel ?? "Show API key",
427
- hidePasswordLabel: T?.hideApiKeyLabel ?? "Hide API key",
421
+ placeholder: _?.apiKeyPlaceholder ?? "Enter API key",
422
+ showPasswordLabel: _?.showApiKeyLabel ?? "Show API key",
423
+ hidePasswordLabel: _?.hideApiKeyLabel ?? "Hide API key",
428
424
  error: t.apiKey || void 0,
429
425
  invalid: !!t.apiKey,
430
- disabled: j
426
+ disabled: S
431
427
  })]
432
428
  }),
433
- e.withLogin !== c.WithoutLogin && V()
429
+ e.withLogin !== l.WithoutLogin && L()
434
430
  ]
435
431
  }),
436
- k && /* @__PURE__ */ L(h, {
437
- open: k,
438
- header: T?.logoutConfirmTitle ?? "Log out?",
439
- description: T?.logoutConfirmDescription ?? "Are you sure you want to log out? You will need to re-enter your credentials to use this toolset again.",
440
- confirmLabel: T?.logOutLabel ?? "Log out",
441
- cancelLabel: T?.cancelLabel ?? "Cancel",
442
- variant: g.Danger,
443
- isLoading: D,
444
- disableConfirmButton: D,
445
- onConfirm: B,
446
- onCancel: () => A(!1),
447
- onClose: () => A(!1)
432
+ b && /* @__PURE__ */ D(ie, {
433
+ open: b,
434
+ header: _?.logoutConfirmTitle ?? "Log out?",
435
+ description: _?.logoutConfirmDescription ?? "Are you sure you want to log out? You will need to re-enter your credentials to use this toolset again.",
436
+ confirmLabel: _?.logOutLabel ?? "Log out",
437
+ cancelLabel: _?.cancelLabel ?? "Cancel",
438
+ variant: ae.Danger,
439
+ isLoading: v,
440
+ disableConfirmButton: v,
441
+ onConfirm: F,
442
+ onCancel: () => x(!1),
443
+ onClose: () => x(!1)
448
444
  })
449
445
  ]
450
446
  });
451
- }, ue = D(({ url: e, className: t, labels: n }) => {
452
- let { isCopied: r, copy: i } = m(e), a = n?.copiedLabel ?? "Copied!";
453
- return /* @__PURE__ */ R("div", {
454
- className: p("flex flex-col gap-3", t),
447
+ }, _e = b(({ url: e, className: t, labels: n }) => {
448
+ let { isCopied: r, copy: i } = v(e), a = n?.copiedLabel ?? "Copied!";
449
+ return /* @__PURE__ */ O("div", {
450
+ className: _("flex flex-col gap-3", t),
455
451
  children: [
456
- /* @__PURE__ */ R("div", {
452
+ /* @__PURE__ */ O("div", {
457
453
  className: "flex flex-col gap-1",
458
- children: [/* @__PURE__ */ L("p", {
454
+ children: [/* @__PURE__ */ D("p", {
459
455
  className: "dial-body-semi-text text-start text-primary",
460
456
  children: n?.title ?? "Connect toolset"
461
- }), /* @__PURE__ */ L("p", {
457
+ }), /* @__PURE__ */ D("p", {
462
458
  className: "dial-small-text text-start text-secondary",
463
459
  children: n?.description ?? "Copy endpoint URL to easily integrate toolset into your workflows"
464
460
  })]
465
461
  }),
466
- /* @__PURE__ */ L("div", { children: /* @__PURE__ */ L(d, {
462
+ /* @__PURE__ */ D("div", { children: /* @__PURE__ */ D(f, {
467
463
  copiedLabel: a,
468
464
  copyLabel: n?.copyLabel ?? "Copy URL",
469
465
  isCopied: r,
470
466
  onClick: i
471
467
  }) }),
472
- /* @__PURE__ */ L("span", {
468
+ /* @__PURE__ */ D("span", {
473
469
  role: "status",
474
470
  "aria-live": "polite",
475
471
  className: "sr-only",
@@ -477,16 +473,16 @@ var z = {
477
473
  })
478
474
  ]
479
475
  });
480
- }), de = ({ form: e, errors: t, isSaving: n, toolsetId: r, isEditMode: i, connectUrl: a, listToolNames: o, authActions: s, onOAuthLogin: c, onNotifySuccess: l, onNotifyError: u, onChange: d, onAuthChange: p, onEnsureSaved: m, labels: h }) => {
481
- let [g, _] = M(null), v = !!a && !!r, b = A(() => [{
482
- value: B.Http,
476
+ }), ve = ({ form: e, errors: t, isSaving: n, toolsetId: r, isEditMode: i, connectUrl: a, listToolNames: o, authActions: s, onOAuthLogin: c, onNotifySuccess: l, onNotifyError: u, onChange: d, onAuthChange: f, onEnsureSaved: p, labels: m }) => {
477
+ let [g, _] = w(null), v = !!a && !!r, y = C(() => [{
478
+ value: R.Http,
483
479
  label: "HTTP"
484
480
  }, {
485
- value: B.Sse,
481
+ value: R.Sse,
486
482
  label: "SSE"
487
483
  }], []);
488
- return k(() => {
489
- if (!r || !o || !Q(e.auth, i)) {
484
+ return S(() => {
485
+ if (!r || !o || !Y(e.auth, i)) {
490
486
  _(null);
491
487
  return;
492
488
  }
@@ -507,56 +503,56 @@ var z = {
507
503
  e.auth,
508
504
  e.endpoint,
509
505
  o
510
- ]), /* @__PURE__ */ R("div", {
506
+ ]), /* @__PURE__ */ O("div", {
511
507
  className: "flex max-w-[1060px] flex-col gap-4",
512
508
  children: [
513
- /* @__PURE__ */ L(y, {
509
+ /* @__PURE__ */ D(j, {
514
510
  id: "toolset-endpoint",
515
511
  value: e.endpoint,
516
512
  onChange: (e) => d({ endpoint: e ?? "" }),
517
513
  labelProps: {
518
- label: h?.endpointLabel ?? "Endpoint",
514
+ label: m?.endpointLabel ?? "Endpoint",
519
515
  required: !0
520
516
  },
521
- placeholder: h?.endpointPlaceholder ?? "https://...",
522
- caption: h?.endpointCaption ?? "The HTTPS address where the server accepts MCP requests. Choose the transport under Protocol below.",
517
+ placeholder: m?.endpointPlaceholder ?? "https://...",
518
+ caption: m?.endpointCaption ?? "The HTTPS address where the server accepts MCP requests. Choose the transport under Protocol below.",
523
519
  error: t.endpoint || void 0,
524
520
  invalid: !!t.endpoint
525
521
  }),
526
- /* @__PURE__ */ L(w, {
522
+ /* @__PURE__ */ D(F, {
527
523
  labelProps: {
528
- label: h?.protocolLabel ?? "Protocol",
524
+ label: m?.protocolLabel ?? "Protocol",
529
525
  required: !0
530
526
  },
531
527
  id: "toolset-protocol",
532
- items: b,
528
+ items: y,
533
529
  value: e.protocol,
534
530
  onChange: (e) => {
535
531
  d({ protocol: e });
536
532
  }
537
533
  }),
538
- g ? /* @__PURE__ */ L(T, {
534
+ g ? /* @__PURE__ */ D(L, {
539
535
  id: "toolset-allowed-tools",
540
536
  multiple: !0,
541
537
  searchable: !0,
542
538
  selectAll: !0,
543
- labelProps: { label: h?.allowedToolsLabel ?? "Allowed tools" },
544
- placeholder: h?.allowedToolsSelectPlaceholder ?? "Select allowed tools",
539
+ labelProps: { label: m?.allowedToolsLabel ?? "Allowed tools" },
540
+ placeholder: m?.allowedToolsSelectPlaceholder ?? "Select allowed tools",
545
541
  options: g.map((e) => ({
546
542
  value: e,
547
543
  label: e
548
544
  })),
549
545
  value: e.allowedTools,
550
546
  onChange: (e) => d({ allowedTools: e })
551
- }) : /* @__PURE__ */ L(E, {
547
+ }) : /* @__PURE__ */ D(oe, {
552
548
  id: "toolset-allowed-tools",
553
- labelProps: { label: h?.allowedToolsLabel ?? "Allowed tools" },
554
- placeholder: h?.allowedToolsPlaceholder ?? "Add tools, comma separated",
549
+ labelProps: { label: m?.allowedToolsLabel ?? "Allowed tools" },
550
+ placeholder: m?.allowedToolsPlaceholder ?? "Add tools, comma separated",
555
551
  value: e.allowedTools,
556
552
  onChange: (e) => d({ allowedTools: e }),
557
- tagClassName: f
553
+ tagClassName: h
558
554
  }),
559
- /* @__PURE__ */ L(le, {
555
+ /* @__PURE__ */ D(ge, {
560
556
  auth: e.auth,
561
557
  errors: t,
562
558
  isSaving: n,
@@ -567,182 +563,206 @@ var z = {
567
563
  onOAuthLogin: c,
568
564
  onNotifySuccess: l,
569
565
  onNotifyError: u,
570
- onAuthChange: p,
571
- onEnsureSaved: m,
572
- labels: h?.auth
566
+ onAuthChange: f,
567
+ onEnsureSaved: p,
568
+ labels: m?.auth
573
569
  }),
574
- v && /* @__PURE__ */ L(ue, {
570
+ v && /* @__PURE__ */ D(_e, {
575
571
  url: a ?? "",
576
- labels: h?.connect,
572
+ labels: m?.connect,
577
573
  className: "border-t border-tertiary pt-4"
578
574
  })
579
575
  ]
580
576
  });
581
- }, fe = [
577
+ }, ye = [
582
578
  "keyHeader",
583
579
  "apiKey",
584
580
  "clientId",
585
581
  "clientSecret",
586
582
  "authorizationEndpoint",
587
583
  "tokenEndpoint"
588
- ], pe = [
589
- "name",
590
- "version",
591
- "endpoint",
592
- ...fe
593
- ], me = new Set(pe), he = (e) => {
584
+ ], be = ["endpoint", ...ye], $ = new Set(be), xe = (e) => {
594
585
  let t = {};
595
- for (let n of Object.keys(e)) me.has(n) && (t[n] = !0);
586
+ for (let n of Object.keys(e)) $.has(n) && (t[n] = !0);
596
587
  return t;
597
- }, ge = ({ initialForm: e, toolsetId: n, onPersist: s, onPostSaveLogin: l, onToolsetsChanged: d, onSaveSuccess: f, onSaveComplete: m, onBack: h, buildMcpUrl: g, listToolNames: _, authActions: v, onOAuthLogin: y, onNotifySuccess: x, onNotifyError: C, bucket: w, FileManagerModal: ee, resolveIconUrl: T, allowedMimeTypes: E, maxFileSizeBytes: D, availableLocaleOptions: N, labels: P }) => {
598
- let F = !!n, [te, I] = M(""), B = n || te, [V, H] = M(e), [U, W] = M(!1), [G, K] = M({}), [q, Y] = M({}), X = j(null);
599
- k(() => {
600
- H(e), X.current = e, K({}), Y({}), I("");
601
- }, [e]);
602
- let Z = O((e) => {
603
- H((t) => ({
604
- ...t,
605
- ...e
606
- })), Y((t) => ({
607
- ...t,
608
- ...he(e)
609
- })), K((t) => {
610
- let n = { ...t };
611
- for (let t of Object.keys(e)) delete n[t];
612
- return n;
613
- });
614
- }, []), Q = O((e) => {
615
- H((t) => ({
588
+ }, Se = ({ initialForm: r, toolsetId: i, onPersist: o, onPostSaveLogin: c, onToolsetsChanged: u, onSaveSuccess: f, onSaveComplete: h, onBack: _, buildMcpUrl: v, listToolNames: b, authActions: T, onOAuthLogin: te, onNotifySuccess: ne, onNotifyError: E, bucket: re, FileManagerModal: O, resolveIconUrl: ie, allowedMimeTypes: ae, maxFileSizeBytes: k, availableLocaleOptions: A, onRefineDescription: j, labels: M }) => {
589
+ let N = !!i, [P, F] = w(""), I = i || P, [L, oe] = w({
590
+ initialForm: r,
591
+ key: 0
592
+ });
593
+ L.initialForm !== r && oe({
594
+ initialForm: r,
595
+ key: L.key + 1
596
+ });
597
+ let { values: R, setValues: z, markTouched: B, visibleErrorCodes: V, attemptSubmit: H } = a({
598
+ initialValues: C(() => fe(r), [r]),
599
+ validationOptions: ce,
600
+ reseedKey: L.key
601
+ }), [le, U] = w(r), W = C(() => ({
602
+ ...le,
603
+ ...R
604
+ }), [le, R]), [K, q] = w(!1), [J, Y] = w({}), [de, X] = w({}), Z = ee(null);
605
+ S(() => {
606
+ U(r), Z.current = r, Y({}), X({}), F("");
607
+ }, [r]);
608
+ let Q = x((e) => {
609
+ let { metadata: t, setup: r } = pe(e);
610
+ Object.keys(t).length > 0 && (z(t), "name" in t && B(n.Name), "version" in t && B(n.Version)), Object.keys(r).length !== 0 && (U((e) => ({
611
+ ...e,
612
+ ...r
613
+ })), X((e) => ({
614
+ ...e,
615
+ ...xe(r)
616
+ })), Y((e) => {
617
+ let t = { ...e };
618
+ for (let e of Object.keys(r)) delete t[e];
619
+ return t;
620
+ }));
621
+ }, [z, B]), he = x((e) => {
622
+ U((t) => ({
616
623
  ...t,
617
624
  auth: {
618
625
  ...t.auth,
619
626
  ...e
620
627
  }
621
- })), Y((t) => ({
628
+ })), X((t) => ({
622
629
  ...t,
623
- ...he(e)
624
- })), K((t) => {
630
+ ...xe(e)
631
+ })), Y((t) => {
625
632
  let n = { ...t };
626
- if ("authenticationType" in e || "withLogin" in e || "isLoggedIn" in e) for (let e of fe) delete n[e];
633
+ if ("authenticationType" in e || "withLogin" in e || "isLoggedIn" in e) for (let e of ye) delete n[e];
627
634
  else for (let t of Object.keys(e)) delete n[t];
628
635
  return n;
629
- }), "isLoggedIn" in e && d();
630
- }, [d]), ie = O(async () => {
631
- if (B && X.current != null && JSON.stringify(X.current) === JSON.stringify(V)) return B;
632
- W(!0);
636
+ }), "isLoggedIn" in e && u();
637
+ }, [u]), ge = x(async () => {
638
+ if (I && Z.current != null && JSON.stringify(Z.current) === JSON.stringify(W)) return I;
639
+ q(!0);
633
640
  try {
634
- let e = await s(V, B);
635
- return e ? (B || I(e), X.current = V, await d(), e) : null;
641
+ let e = await o(W, I);
642
+ return e ? (I || F(e), Z.current = W, await u(), e) : null;
636
643
  } catch {
637
644
  return null;
638
645
  } finally {
639
- W(!1);
646
+ q(!1);
640
647
  }
641
648
  }, [
642
- V,
643
- B,
644
- s,
645
- d
646
- ]), ae = O(async () => await ie() ?? !1, [ie]), $ = O((e) => {
647
- let n = P?.validation, r = {}, i = a(e, { validateVersionPattern: !0 });
648
- return i.name === t.Required && (r.name = n?.nameRequired ?? "Name is required"), i.version === t.InvalidFormat && (r.version = n?.versionInvalid ?? "Version may only contain letters, digits, dots, underscores, and dashes"), e.endpoint.trim() ? J(e.endpoint) || (r.endpoint = n?.endpointInvalid ?? "Enter a valid http(s) URL") : r.endpoint = n?.endpointRequired ?? "Endpoint is required", e.auth.isLoggedIn || (e.auth.authenticationType === o.ApiKey && (e.auth.keyHeader?.trim() || (r.keyHeader = n?.keyHeaderRequired ?? "Key name is required"), e.auth.withLogin === c.WithLogin && !e.auth.apiKey?.trim() && (r.apiKey = n?.apiKeyRequired ?? "API key is required")), e.auth.authenticationType === o.OAuth && e.auth.withLogin === c.WithConfig && (e.auth.clientId?.trim() || (r.clientId = n?.clientIdRequired ?? "Client ID is required"), !F && !e.auth.clientSecret?.trim() && (r.clientSecret = n?.clientSecretRequired ?? "Client secret is required"), e.auth.authorizationEndpoint?.trim() && !J(e.auth.authorizationEndpoint) && (r.authorizationEndpoint = n?.endpointInvalid ?? "Enter a valid http(s) URL"), e.auth.tokenEndpoint?.trim() && !J(e.auth.tokenEndpoint) && (r.tokenEndpoint = n?.endpointInvalid ?? "Enter a valid http(s) URL"))), r;
649
- }, [P, F]), se = O(async () => {
650
- let e = $(V);
651
- if (Object.keys(e).length > 0) {
652
- K(e);
649
+ W,
650
+ I,
651
+ o,
652
+ u
653
+ ]), _e = x(async () => await ge() ?? !1, [ge]), $ = x((e) => {
654
+ let t = M?.validation, n = {};
655
+ return e.endpoint.trim() ? G(e.endpoint) || (n.endpoint = t?.endpointInvalid ?? "Enter a valid http(s) URL") : n.endpoint = t?.endpointRequired ?? "Endpoint is required", e.auth.isLoggedIn || (e.auth.authenticationType === s.ApiKey && (e.auth.keyHeader?.trim() || (n.keyHeader = t?.keyHeaderRequired ?? "Key name is required"), e.auth.withLogin === l.WithLogin && !e.auth.apiKey?.trim() && (n.apiKey = t?.apiKeyRequired ?? "API key is required")), e.auth.authenticationType === s.OAuth && e.auth.withLogin === l.WithConfig && (e.auth.clientId?.trim() || (n.clientId = t?.clientIdRequired ?? "Client ID is required"), !N && !e.auth.clientSecret?.trim() && (n.clientSecret = t?.clientSecretRequired ?? "Client secret is required"), e.auth.authorizationEndpoint?.trim() && !G(e.auth.authorizationEndpoint) && (n.authorizationEndpoint = t?.endpointInvalid ?? "Enter a valid http(s) URL"), e.auth.tokenEndpoint?.trim() && !G(e.auth.tokenEndpoint) && (n.tokenEndpoint = t?.endpointInvalid ?? "Enter a valid http(s) URL"))), n;
656
+ }, [M, N]), Se = x(async () => {
657
+ let e = H(), t = $(W);
658
+ if (!e || Object.keys(t).length > 0) {
659
+ Y(t);
653
660
  return;
654
661
  }
655
- K({}), W(!0);
662
+ Y({}), q(!0);
656
663
  try {
657
- let e = await s(V, B);
664
+ let e = await o(W, I);
658
665
  if (!e) return;
659
- await d(), f(V);
666
+ await u(), f(W);
660
667
  try {
661
- await l(e, V.auth), m();
668
+ await c(e, W.auth), h();
662
669
  } catch (e) {
663
- let { traceId: t } = await u(e);
664
- C(P?.settings?.auth?.errorLoginFailed ?? "Failed to log in. Please check your credentials and try again.", t);
670
+ let { traceId: t } = await d(e);
671
+ E(M?.settings?.auth?.errorLoginFailed ?? "Failed to log in. Please check your credentials and try again.", t);
665
672
  }
666
673
  } catch {} finally {
667
- W(!1);
674
+ q(!1);
668
675
  }
669
676
  }, [
670
- V,
677
+ H,
678
+ W,
671
679
  $,
672
- B,
673
- s,
674
- d,
680
+ I,
681
+ o,
682
+ u,
675
683
  f,
676
- m,
677
- l,
678
- C,
679
- P
680
- ]), ce = A(() => !re(V, F), [V, F]), le = A(() => {
681
- let e = $(V), t = { ...G };
682
- for (let n of pe) {
683
- if (!q[n]) continue;
684
- let r = e[n];
685
- r ? t[n] = r : delete t[n];
684
+ h,
685
+ c,
686
+ E,
687
+ M
688
+ ]), Ce = y({
689
+ value: R.description,
690
+ onChange: (e) => Q({ description: e }),
691
+ onRefine: j,
692
+ disabled: K,
693
+ resetKey: L.key
694
+ }), we = j ? (e, t) => /* @__PURE__ */ D(g, {
695
+ isEnabled: !0,
696
+ fieldId: t,
697
+ label: M?.general?.form?.description.label ?? "Description",
698
+ labels: M?.refinement,
699
+ refinement: Ce,
700
+ disabled: Ce.isPending || K,
701
+ children: e
702
+ }) : void 0, Te = C(() => !ue(W, N), [W, N]), Ee = C(() => {
703
+ let t = M?.validation, n = $(W), r = { ...J };
704
+ for (let e of be) {
705
+ if (!de[e]) continue;
706
+ let t = n[e];
707
+ t ? r[e] = t : delete r[e];
686
708
  }
687
- return t;
709
+ return V.name === e.Required ? r.name = t?.nameRequired ?? "Name is required" : V.name === e.TooLong ? r.name = t?.nameTooLong ?? `Use ${m} characters or fewer.` : V.name === e.ControlCharacters && (r.name = t?.nameControlCharacters ?? "Remove line breaks, tabs and other control characters."), V.description === e.TooLong && (r.description = t?.descriptionTooLong ?? `Use ${p} characters or fewer.`), V.version === e.InvalidFormat && (r.version = t?.versionInvalid ?? "Version must follow semantic versioning (e.g., 1.0.0)"), r;
688
710
  }, [
689
- q,
690
- G,
711
+ de,
712
+ J,
713
+ W,
714
+ M,
691
715
  V,
692
716
  $
693
- ]), ue = g && B ? g(B) : void 0;
694
- return /* @__PURE__ */ L(r, {
695
- title: F ? P?.layout?.editTitle ?? "Edit toolset" : P?.layout?.createTitle ?? "Create toolset",
696
- onBack: h,
697
- backAriaLabel: P?.layout?.backAriaLabel ?? "Back to catalog",
698
- isSaving: U,
699
- labels: { savingStatusLabel: P?.layout?.savingStatusLabel ?? "Saving" },
700
- actions: /* @__PURE__ */ R(ne, { children: [/* @__PURE__ */ L(b, {
701
- label: P?.layout?.cancelLabel ?? "Cancel",
702
- onClick: h
703
- }), /* @__PURE__ */ L(S, {
704
- label: F ? P?.layout?.saveLabel ?? "Save" : P?.layout?.createLabel ?? "Create",
705
- disabled: ce,
706
- onClick: se
707
- })] }),
708
- leftContent: /* @__PURE__ */ L(i, {
709
- title: P?.layout?.metadataSectionTitle ?? "Metadata",
710
- className: p("border-0 p-4 desktop:p-6", z.metadataSection),
711
- children: /* @__PURE__ */ L(oe, {
712
- form: V,
713
- errors: le,
714
- bucket: w,
715
- FileManagerModal: ee,
716
- resolveIconUrl: T,
717
- allowedMimeTypes: E,
718
- maxFileSizeBytes: D,
719
- availableLocaleOptions: N,
720
- onChange: Z,
721
- labels: P?.general
722
- })
717
+ ]), De = v && I ? v(I) : void 0;
718
+ return /* @__PURE__ */ D(t, {
719
+ title: N ? M?.layout?.editTitle ?? "Edit toolset" : M?.layout?.createTitle ?? "Create toolset",
720
+ onBack: _,
721
+ onCancel: _,
722
+ onSubmit: Se,
723
+ submitLabel: N ? M?.layout?.saveLabel ?? "Save" : M?.layout?.createLabel ?? "Create",
724
+ isSubmitting: K,
725
+ isSubmitDisabled: Te || Ce.isPending,
726
+ metadataSectionClassName: se.metadataSection,
727
+ setupSectionClassName: se.setupSection,
728
+ labels: {
729
+ backAriaLabel: M?.layout?.backAriaLabel ?? "Back to catalog",
730
+ savingStatusLabel: M?.layout?.savingStatusLabel ?? "Saving",
731
+ metadataTitle: M?.layout?.metadataSectionTitle ?? "Metadata",
732
+ setupTitle: M?.layout?.setupSectionTitle ?? "Setup",
733
+ cancelLabel: M?.layout?.cancelLabel ?? "Cancel"
734
+ },
735
+ metadata: /* @__PURE__ */ D(me, {
736
+ form: W,
737
+ errors: Ee,
738
+ bucket: re,
739
+ FileManagerModal: O,
740
+ resolveIconUrl: ie,
741
+ allowedMimeTypes: ae,
742
+ maxFileSizeBytes: k,
743
+ availableLocaleOptions: A,
744
+ onChange: Q,
745
+ renderDescription: we,
746
+ labels: M?.general
723
747
  }),
724
- rightContent: /* @__PURE__ */ L(i, {
725
- title: P?.layout?.setupSectionTitle ?? "Setup",
726
- className: p("border-0 p-4 desktop:p-6", z.setupSection),
727
- children: /* @__PURE__ */ L(de, {
728
- form: V,
729
- errors: le,
730
- isSaving: U,
731
- toolsetId: B,
732
- isEditMode: F,
733
- connectUrl: ue,
734
- listToolNames: _,
735
- authActions: v,
736
- onOAuthLogin: y,
737
- onNotifySuccess: x,
738
- onNotifyError: C,
739
- onChange: Z,
740
- onAuthChange: Q,
741
- onEnsureSaved: ae,
742
- labels: P?.settings
743
- })
748
+ setup: /* @__PURE__ */ D(ve, {
749
+ form: W,
750
+ errors: Ee,
751
+ isSaving: K,
752
+ toolsetId: I,
753
+ isEditMode: N,
754
+ connectUrl: De,
755
+ listToolNames: b,
756
+ authActions: T,
757
+ onOAuthLogin: te,
758
+ onNotifySuccess: ne,
759
+ onNotifyError: E,
760
+ onChange: Q,
761
+ onAuthChange: he,
762
+ onEnsureSaved: _e,
763
+ labels: M?.settings
744
764
  })
745
765
  });
746
766
  };
747
767
  //#endregion
748
- export { U as AUTH_TYPE_ICONS, V as DEFAULT_TOOLSET_NAME, H as DEFAULT_TOOLSET_VERSION, oe as GeneralForm, z as TOOLSET_EDITOR_CLASS, ge as ToolsetEditor, $ as ToolsetOAuthLoginStatus, B as ToolsetTransportType, K as getDefaultToolsetForm, W as getStorageSafeUniqueToolsetName, Q as isToolsetAuthValid, re as isToolsetFormValid, J as isValidEndpointUrl, X as normalizeReturnedEndpointUrl };
768
+ export { V as AUTH_TYPE_ICONS, z as DEFAULT_TOOLSET_NAME, B as DEFAULT_TOOLSET_VERSION, me as GeneralForm, se as TOOLSET_EDITOR_CLASS, Se as ToolsetEditor, Z as ToolsetOAuthLoginStatus, R as ToolsetTransportType, U as getDefaultToolsetForm, H as getStorageSafeUniqueToolsetName, Y as isToolsetAuthValid, ue as isToolsetFormValid, G as isValidEndpointUrl, q as normalizeReturnedEndpointUrl };