@epam/ai-dial-toolset-editor 1.2.0-dev.28 → 1.2.0-dev.282

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