@bpinternal/integration-hub 0.2.0 → 0.3.0

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.
@@ -1,14 +1,14 @@
1
- import { jsx as v, jsxs as _ } from "react/jsx-runtime";
2
- import { Loader2 as wt } from "lucide-react";
3
- import { useState as O, useRef as dt, useEffect as st, useMemo as E, useCallback as G } from "react";
4
- import { I as Wt, c as ct, a as Rt, b as $t, d as Gt, e as Zt, f as Jt, g as Xt, h as Yt, i as mt, j as tn, k as nn } from "../chunks/index.js";
5
- import { StaticZuiForm as en } from "@bpinternal/static-zui-form";
6
- import { useQueryClient as It, useQuery as yt, useMutation as D } from "@tanstack/react-query";
1
+ import { jsx as v, jsxs as K } from "react/jsx-runtime";
2
+ import { Loader2 as It } from "lucide-react";
3
+ import { useState as P, useRef as ut, useEffect as ct, useMemo as E, useCallback as Z } from "react";
4
+ import { I as Rt, c as lt, a as $t, b as Gt, d as Zt, e as Jt, f as Xt, g as Yt, h as mt, i as tn, j as nn, k as en } from "../chunks/index.js";
5
+ import { StaticZuiForm as on } from "@bpinternal/static-zui-form";
6
+ import { useQueryClient as yt, useQuery as St, useMutation as D } from "@tanstack/react-query";
7
7
  import "framer-motion";
8
8
  import "clsx";
9
9
  import "tailwind-merge";
10
10
  import "@base-ui/react/menu";
11
- const on = "width=650,height=800,popup=true", an = 500, rn = 5 * 60 * 1e3, sn = (n) => {
11
+ const an = "width=650,height=800,popup=true", rn = 500, sn = 5 * 60 * 1e3, cn = (n) => {
12
12
  if (!n)
13
13
  return null;
14
14
  try {
@@ -16,7 +16,7 @@ const on = "width=650,height=800,popup=true", an = 500, rn = 5 * 60 * 1e3, sn =
16
16
  } catch {
17
17
  return n.split("/").filter(Boolean).at(-1) ?? null;
18
18
  }
19
- }, cn = async ({
19
+ }, ln = async ({
20
20
  client: n,
21
21
  linkTemplateScript: t,
22
22
  data: e
@@ -28,12 +28,12 @@ const on = "width=650,height=800,popup=true", an = 500, rn = 5 * 60 * 1e3, sn =
28
28
  if (typeof i != "string")
29
29
  throw new Error("Authorization URL is not a string");
30
30
  return i;
31
- }, ln = async ({
31
+ }, dn = async ({
32
32
  authorizationUrl: n,
33
33
  onClose: t,
34
- popupFeatures: e = on,
35
- pollIntervalMs: i = an,
36
- timeoutMs: o = rn
34
+ popupFeatures: e = an,
35
+ pollIntervalMs: i = rn,
36
+ timeoutMs: o = sn
37
37
  }) => {
38
38
  const r = window.open(n, "OAuth", e);
39
39
  if (!r)
@@ -57,136 +57,136 @@ const on = "width=650,height=800,popup=true", an = 500, rn = 5 * 60 * 1e3, sn =
57
57
  } catch {
58
58
  return "failed";
59
59
  }
60
- }, dn = (n) => n instanceof Error ? n : new Error("OAuth authorization failed"), un = ({
60
+ }, un = (n) => n instanceof Error ? n : new Error("OAuth authorization failed"), pn = ({
61
61
  client: n,
62
62
  integrationName: t,
63
63
  linkTemplateScript: e,
64
64
  webhookId: i,
65
65
  webhookUrl: o,
66
66
  oauthTemplateData: r,
67
- isAuthorized: c = !1,
67
+ isAuthorized: l = !1,
68
68
  disabled: a = !1,
69
69
  onAuthorized: u,
70
70
  onError: d
71
71
  }) => {
72
- const [l, b] = O(null), [p, S] = O(!1), [x, P] = O(!1), I = i ?? sn(o), g = !!(i || o), f = dt(d);
73
- st(() => {
72
+ const [s, g] = P(null), [b, S] = P(!1), [T, M] = P(!1), I = i ?? cn(o), p = !!(i || o), f = ut(d);
73
+ ct(() => {
74
74
  f.current = d;
75
75
  }, [d]);
76
- const C = E(() => {
76
+ const k = E(() => {
77
77
  try {
78
78
  return JSON.stringify(r ?? {});
79
79
  } catch {
80
80
  return "{}";
81
81
  }
82
82
  }, [r]);
83
- st(() => {
84
- if (!g) {
85
- b(null), S(!1);
83
+ ct(() => {
84
+ if (!p) {
85
+ g(null), S(!1);
86
86
  return;
87
87
  }
88
- let k = !1;
88
+ let U = !1;
89
89
  return (async () => {
90
- var K;
91
- let M = {};
90
+ var L;
91
+ let C = {};
92
92
  try {
93
- M = JSON.parse(C);
93
+ C = JSON.parse(k);
94
94
  } catch {
95
- M = {};
95
+ C = {};
96
96
  }
97
- const U = {
97
+ const x = {
98
98
  webhookUrl: o ?? null,
99
99
  webhookId: I,
100
- ...M
100
+ ...C
101
101
  };
102
102
  S(!0);
103
103
  try {
104
- const N = await cn({
104
+ const _ = await ln({
105
105
  client: n,
106
106
  linkTemplateScript: e,
107
- data: U
107
+ data: x
108
108
  });
109
- k || b(N);
110
- } catch (N) {
111
- k || (b(null), (K = f.current) == null || K.call(f, dn(N)));
109
+ U || g(_);
110
+ } catch (_) {
111
+ U || (g(null), (L = f.current) == null || L.call(f, un(_)));
112
112
  } finally {
113
- k || S(!1);
113
+ U || S(!1);
114
114
  }
115
115
  })(), () => {
116
- k = !0;
116
+ U = !0;
117
117
  };
118
- }, [n, g, e, C, o, I]);
119
- const L = g && !!l && !p && !a, H = async () => {
120
- var k, y, M;
121
- if (!(!l || x)) {
122
- P(!0);
118
+ }, [n, p, e, k, o, I]);
119
+ const y = p && !!s && !b && !a, N = async () => {
120
+ var U, V, C;
121
+ if (!(!s || T)) {
122
+ M(!0);
123
123
  try {
124
- const U = await ln({
125
- authorizationUrl: l,
124
+ const x = await dn({
125
+ authorizationUrl: s,
126
126
  onClose: u
127
127
  });
128
- if (U === "completed")
128
+ if (x === "completed")
129
129
  return;
130
- if (U === "blocked") {
131
- (k = f.current) == null || k.call(f, new Error("Please allow browser popups to authorize this integration."));
130
+ if (x === "blocked") {
131
+ (U = f.current) == null || U.call(f, new Error("Please allow browser popups to authorize this integration."));
132
132
  return;
133
133
  }
134
- if (U === "timeout") {
135
- (y = f.current) == null || y.call(f, new Error("OAuth popup did not close in time. Please close it and try again."));
134
+ if (x === "timeout") {
135
+ (V = f.current) == null || V.call(f, new Error("OAuth popup did not close in time. Please close it and try again."));
136
136
  return;
137
137
  }
138
- (M = f.current) == null || M.call(f, new Error("OAuth authorization finished but refresh failed."));
138
+ (C = f.current) == null || C.call(f, new Error("OAuth authorization finished but refresh failed."));
139
139
  } finally {
140
- P(!1);
140
+ M(!1);
141
141
  }
142
142
  }
143
143
  };
144
144
  return /* @__PURE__ */ v(
145
- Wt,
145
+ Rt,
146
146
  {
147
147
  integrationName: t,
148
- canAuthorize: L,
149
- isAuthorizing: x,
150
- isAuthorized: c,
148
+ canAuthorize: y,
149
+ isAuthorizing: T,
150
+ isAuthorized: l,
151
151
  disabled: a,
152
- showInstallHint: !g,
152
+ showInstallHint: !p,
153
153
  onClick: () => {
154
- H();
154
+ N();
155
155
  }
156
156
  }
157
157
  );
158
- }, St = ({
158
+ }, At = ({
159
159
  definition: n,
160
160
  selectedConnectionMethod: t
161
161
  }) => {
162
162
  var i, o, r;
163
163
  const e = t != null ? (o = (i = n.configurations) == null ? void 0 : i[t]) == null ? void 0 : o.schema : (r = n.configuration) == null ? void 0 : r.schema;
164
164
  return !e || typeof e != "object" ? null : e;
165
- }, At = (n) => {
165
+ }, Tt = (n) => {
166
166
  if (!n || typeof n != "object")
167
167
  return [];
168
168
  const t = n.properties;
169
169
  return !t || typeof t != "object" ? [] : Object.keys(t);
170
- }, it = (n) => !n || typeof n != "object" || Array.isArray(n) ? {} : n, Ct = (n, t) => {
170
+ }, ot = (n) => !n || typeof n != "object" || Array.isArray(n) ? {} : n, wt = (n, t) => {
171
171
  if (t.length === 0)
172
172
  return {};
173
173
  const e = t.filter((i) => Object.prototype.hasOwnProperty.call(n, i)).map((i) => [i, n[i]]);
174
174
  return Object.fromEntries(e);
175
- }, $ = (n) => !!n && typeof n == "object" && !Array.isArray(n), lt = (n, t) => {
175
+ }, G = (n) => !!n && typeof n == "object" && !Array.isArray(n), dt = (n, t) => {
176
176
  if (Object.is(n, t))
177
177
  return !0;
178
178
  if (Array.isArray(n) || Array.isArray(t))
179
- return !Array.isArray(n) || !Array.isArray(t) || n.length !== t.length ? !1 : n.every((e, i) => lt(e, t[i]));
180
- if ($(n) || $(t)) {
181
- if (!$(n) || !$(t))
179
+ return !Array.isArray(n) || !Array.isArray(t) || n.length !== t.length ? !1 : n.every((e, i) => dt(e, t[i]));
180
+ if (G(n) || G(t)) {
181
+ if (!G(n) || !G(t))
182
182
  return !1;
183
183
  const e = Object.keys(n), i = Object.keys(t);
184
184
  return e.length !== i.length ? !1 : e.every(
185
- (o) => Object.prototype.hasOwnProperty.call(t, o) && lt(n[o], t[o])
185
+ (o) => Object.prototype.hasOwnProperty.call(t, o) && dt(n[o], t[o])
186
186
  );
187
187
  }
188
188
  return !1;
189
- }, pn = ({
189
+ }, fn = ({
190
190
  definition: n,
191
191
  installedState: t,
192
192
  selectedConnectionMethod: e,
@@ -194,71 +194,71 @@ const on = "width=650,height=800,popup=true", an = 500, rn = 5 * 60 * 1e3, sn =
194
194
  isSaving: o,
195
195
  disabled: r = !1
196
196
  }) => {
197
- const c = E(
198
- () => St({ definition: n, selectedConnectionMethod: e }),
197
+ const l = E(
198
+ () => At({ definition: n, selectedConnectionMethod: e }),
199
199
  [n, e]
200
- ), a = E(() => At(c), [c]), u = E(
201
- () => Ct(it(t == null ? void 0 : t.configuration), a),
200
+ ), a = E(() => Tt(l), [l]), u = E(
201
+ () => wt(ot(t == null ? void 0 : t.configuration), a),
202
202
  [t == null ? void 0 : t.configuration, a]
203
- ), d = E(() => a.join("\0"), [a]), [l, b] = O({}), [p, S] = O(null), [x, P] = O(0), I = dt(null);
204
- return st(() => {
205
- const g = {
203
+ ), d = E(() => a.join("\0"), [a]), [s, g] = P({}), [b, S] = P(null), [T, M] = P(0), I = ut(null);
204
+ return ct(() => {
205
+ const p = {
206
206
  botIntegrationId: (t == null ? void 0 : t.botIntegrationId) ?? null,
207
207
  configurationType: (t == null ? void 0 : t.configurationType) ?? null,
208
208
  schemaKeySignature: d,
209
209
  configuration: u
210
210
  }, f = I.current;
211
- f && f.botIntegrationId === g.botIntegrationId && f.configurationType === g.configurationType && f.schemaKeySignature === g.schemaKeySignature && lt(f.configuration, g.configuration) || (I.current = g, b(u), S(null), P((C) => C + 1));
212
- }, [u, t == null ? void 0 : t.botIntegrationId, t == null ? void 0 : t.configurationType, d]), !c || a.length === 0 ? null : /* @__PURE__ */ _("div", { className: "flex flex-col gap-3", children: [
211
+ f && f.botIntegrationId === p.botIntegrationId && f.configurationType === p.configurationType && f.schemaKeySignature === p.schemaKeySignature && dt(f.configuration, p.configuration) || (I.current = p, g(u), S(null), M((k) => k + 1));
212
+ }, [u, t == null ? void 0 : t.botIntegrationId, t == null ? void 0 : t.configurationType, d]), !l || a.length === 0 ? null : /* @__PURE__ */ K("div", { className: "flex flex-col gap-3", children: [
213
213
  /* @__PURE__ */ v(
214
- en,
214
+ on,
215
215
  {
216
- schema: c,
217
- value: l,
218
- onChange: (g) => {
219
- const f = Ct(it(g), a);
220
- b(f);
216
+ schema: l,
217
+ value: s,
218
+ onChange: (p) => {
219
+ const f = wt(ot(p), a);
220
+ g(f);
221
221
  },
222
- onValidation: ({ formValid: g }) => {
223
- S(g);
222
+ onValidation: ({ formValid: p }) => {
223
+ S(p);
224
224
  }
225
225
  },
226
- x
226
+ T
227
227
  ),
228
- /* @__PURE__ */ _(
228
+ /* @__PURE__ */ K(
229
229
  "button",
230
230
  {
231
231
  type: "button",
232
- disabled: r || o || p !== !0,
232
+ disabled: r || o || b !== !0,
233
233
  onClick: () => {
234
- const g = it(t == null ? void 0 : t.configuration);
234
+ const p = ot(t == null ? void 0 : t.configuration);
235
235
  i({
236
- ...g,
237
- ...l
236
+ ...p,
237
+ ...s
238
238
  });
239
239
  },
240
- className: ct(
240
+ className: lt(
241
241
  "relative self-end rounded-lg bg-[var(--gray-12)] px-6 py-2 text-sm text-[var(--gray-1)] hover:opacity-90 cursor-pointer",
242
242
  "disabled:opacity-50 disabled:cursor-not-allowed"
243
243
  ),
244
244
  children: [
245
245
  /* @__PURE__ */ v("span", { className: o ? "invisible" : "", children: "Save Configuration" }),
246
- o && /* @__PURE__ */ v(wt, { className: "absolute inset-0 m-auto h-4 w-4 animate-spin" })
246
+ o && /* @__PURE__ */ v(It, { className: "absolute inset-0 m-auto h-4 w-4 animate-spin" })
247
247
  ]
248
248
  }
249
249
  )
250
250
  ] });
251
- }, Tt = "Other", fn = "team-cloud-services", ot = "sandbox", at = (n) => n.replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/[_.:/-]+/g, " ").replace(/\s+/g, " ").trim().replace(/\b\w/g, (t) => t.toUpperCase()), gn = (n) => n == null ? void 0 : n.replace(/\.$/, ""), Ot = (n) => {
251
+ }, Ot = "Other", gn = "team-cloud-services", at = "sandbox", rt = (n) => n.replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/[_.:/-]+/g, " ").replace(/\s+/g, " ").trim().replace(/\b\w/g, (t) => t.toUpperCase()), hn = (n) => n == null ? void 0 : n.replace(/\.$/, ""), Pt = (n) => {
252
252
  var t;
253
253
  return n && "meta" in n ? ((t = n.meta) == null ? void 0 : t.installs) ?? null : null;
254
- }, ut = (n) => n instanceof Error ? n : new Error("An unknown error occurred while loading integrations"), Pt = (n) => n === fn, Bt = (n, t) => {
254
+ }, pt = (n) => n instanceof Error ? n : new Error("An unknown error occurred while loading integrations"), Bt = (n) => n === gn, Mt = (n, t) => {
255
255
  var o;
256
256
  const e = t == null ? void 0 : t(n);
257
257
  if (e)
258
258
  return e;
259
259
  const i = (o = n.attributes) == null ? void 0 : o.category;
260
- return typeof i == "string" && i.length > 0 ? i : Tt;
261
- }, Z = (n) => n ? Object.entries(n).map(([t, e]) => {
260
+ return typeof i == "string" && i.length > 0 ? i : Ot;
261
+ }, J = (n) => n ? Object.entries(n).map(([t, e]) => {
262
262
  const i = e;
263
263
  return {
264
264
  ...i,
@@ -266,32 +266,32 @@ const on = "width=650,height=800,popup=true", an = 500, rn = 5 * 60 * 1e3, sn =
266
266
  name: typeof i.name == "string" && i.name.length > 0 ? i.name : t,
267
267
  botIntegrationId: t
268
268
  };
269
- }) : [], pt = ({
269
+ }) : [], ft = ({
270
270
  installedIntegrations: n,
271
271
  integrationId: t,
272
272
  integrationName: e
273
- }) => n.find((i) => i.id === t) ?? n.find((i) => i.botIntegrationId === t) ?? (e ? n.find((i) => i.name === e) : void 0), hn = ({
273
+ }) => n.find((i) => i.id === t) ?? n.find((i) => i.botIntegrationId === t) ?? (e ? n.find((i) => i.name === e) : void 0), bn = ({
274
274
  summary: n,
275
275
  installedByName: t,
276
276
  categoryResolver: e
277
277
  }) => {
278
- var u, d, l;
279
- const i = t.get(n.name), o = Pt((u = n.ownerWorkspace) == null ? void 0 : u.handle), r = (i == null ? void 0 : i.version) ?? null, c = n.version ?? null, a = r && c ? r !== c : !1;
278
+ var u, d, s;
279
+ const i = t.get(n.name), o = Bt((u = n.ownerWorkspace) == null ? void 0 : u.handle), r = (i == null ? void 0 : i.version) ?? null, l = n.version ?? null, a = r && l ? r !== l : !1;
280
280
  return {
281
281
  id: n.id,
282
282
  name: n.name,
283
283
  title: n.title,
284
284
  description: n.description,
285
285
  iconUrl: n.iconUrl,
286
- attributes: { category: Bt(n, e) },
286
+ attributes: { category: Mt(n, e) },
287
287
  meta: {
288
- installs: Ot(n)
288
+ installs: Pt(n)
289
289
  },
290
290
  installed: !!i,
291
291
  enabled: i == null ? void 0 : i.enabled,
292
292
  hasUpdate: a,
293
293
  deprecated: (i == null ? void 0 : i.lifecycleStatus) === "deprecated" || n.lifecycleStatus === "deprecated",
294
- author: ((d = n.ownerWorkspace) == null ? void 0 : d.handle) ?? ((l = n.ownerWorkspace) == null ? void 0 : l.name) ?? null,
294
+ author: ((d = n.ownerWorkspace) == null ? void 0 : d.handle) ?? ((s = n.ownerWorkspace) == null ? void 0 : s.name) ?? null,
295
295
  isOfficial: o,
296
296
  isVerified: n.verificationStatus === "approved",
297
297
  isPrivate: n.visibility === "private",
@@ -301,13 +301,13 @@ const on = "width=650,height=800,popup=true", an = 500, rn = 5 * 60 * 1e3, sn =
301
301
  version: n.version,
302
302
  updatedAt: n.updatedAt
303
303
  };
304
- }, bn = ({
304
+ }, vn = ({
305
305
  installedIntegration: n,
306
306
  summary: t,
307
307
  categoryResolver: e
308
308
  }) => {
309
- var r, c, a;
310
- const i = Pt((r = t == null ? void 0 : t.ownerWorkspace) == null ? void 0 : r.handle), o = n.version && (t != null && t.version) ? n.version !== (t == null ? void 0 : t.version) : !1;
309
+ var r, l, a;
310
+ const i = Bt((r = t == null ? void 0 : t.ownerWorkspace) == null ? void 0 : r.handle), o = n.version && (t != null && t.version) ? n.version !== (t == null ? void 0 : t.version) : !1;
311
311
  return {
312
312
  id: (t == null ? void 0 : t.id) ?? n.id,
313
313
  name: (t == null ? void 0 : t.name) ?? n.name,
@@ -315,16 +315,16 @@ const on = "width=650,height=800,popup=true", an = 500, rn = 5 * 60 * 1e3, sn =
315
315
  description: (t == null ? void 0 : t.description) ?? null,
316
316
  iconUrl: t == null ? void 0 : t.iconUrl,
317
317
  attributes: {
318
- category: t ? Bt(t, e) : Tt
318
+ category: t ? Mt(t, e) : Ot
319
319
  },
320
320
  meta: {
321
- installs: Ot(t)
321
+ installs: Pt(t)
322
322
  },
323
323
  installed: !0,
324
324
  enabled: n.enabled,
325
325
  hasUpdate: o,
326
326
  deprecated: n.lifecycleStatus === "deprecated",
327
- author: ((c = t == null ? void 0 : t.ownerWorkspace) == null ? void 0 : c.handle) ?? ((a = t == null ? void 0 : t.ownerWorkspace) == null ? void 0 : a.name) ?? null,
327
+ author: ((l = t == null ? void 0 : t.ownerWorkspace) == null ? void 0 : l.handle) ?? ((a = t == null ? void 0 : t.ownerWorkspace) == null ? void 0 : a.name) ?? null,
328
328
  isOfficial: i,
329
329
  isVerified: (t == null ? void 0 : t.verificationStatus) === "approved",
330
330
  isPrivate: (t == null ? void 0 : t.visibility) === "private",
@@ -334,7 +334,7 @@ const on = "width=650,height=800,popup=true", an = 500, rn = 5 * 60 * 1e3, sn =
334
334
  version: (t == null ? void 0 : t.version) ?? n.version,
335
335
  updatedAt: t == null ? void 0 : t.updatedAt
336
336
  };
337
- }, vn = (n) => {
337
+ }, Cn = (n) => {
338
338
  if (!n)
339
339
  return {
340
340
  actionCards: [],
@@ -345,23 +345,23 @@ const on = "width=650,height=800,popup=true", an = 500, rn = 5 * 60 * 1e3, sn =
345
345
  var r;
346
346
  return ((r = o.attributes) == null ? void 0 : r.bpActionHiddenInStudio) !== "true";
347
347
  }).map(([o, r]) => {
348
- var c;
348
+ var l;
349
349
  return {
350
350
  key: o,
351
- name: at(o),
351
+ name: rt(o),
352
352
  description: r.description ?? "",
353
353
  type: "action",
354
- billable: ((c = r.attributes) == null ? void 0 : c.billable) === "true"
354
+ billable: ((l = r.attributes) == null ? void 0 : l.billable) === "true"
355
355
  };
356
356
  }), e = Object.entries(n.events ?? {}).map(([o, r]) => ({
357
357
  key: o,
358
- name: at(o),
358
+ name: rt(o),
359
359
  description: r.description ?? "",
360
360
  type: "event",
361
361
  enabled: !0
362
362
  })), i = Object.keys(n.channels ?? {}).map((o) => ({
363
363
  key: o,
364
- name: at(o),
364
+ name: rt(o),
365
365
  description: "Channel communication support",
366
366
  type: "channel",
367
367
  enabled: !0
@@ -371,127 +371,127 @@ const on = "width=650,height=800,popup=true", an = 500, rn = 5 * 60 * 1e3, sn =
371
371
  eventCards: e,
372
372
  channelCards: i
373
373
  };
374
- }, Cn = (n) => {
375
- var r, c, a, u;
374
+ }, wn = (n) => {
375
+ var r, l, a, u;
376
376
  if (!n)
377
377
  return [];
378
378
  const e = [
379
379
  {
380
380
  value: null,
381
- label: !!((c = (r = n.configuration) == null ? void 0 : r.identifier) != null && c.linkTemplateScript) ? "Connect with OAuth" : "Default configuration"
381
+ label: !!((l = (r = n.configuration) == null ? void 0 : r.identifier) != null && l.linkTemplateScript) ? "Connect with OAuth" : "Default configuration"
382
382
  }
383
383
  ];
384
- for (const [d, l] of Object.entries(n.configurations ?? {}))
385
- d !== ot && e.push({
384
+ for (const [d, s] of Object.entries(n.configurations ?? {}))
385
+ d !== at && e.push({
386
386
  value: d,
387
- label: gn(l.description) || l.title || d
387
+ label: hn(s.description) || s.title || d
388
388
  });
389
- return !!((a = n.sandbox) == null ? void 0 : a.identifierExtractScript) && !!((u = n.configurations) != null && u[ot]) && e.push({ value: ot, label: "Connect to a Playground" }), e;
390
- }, wn = ({
389
+ return !!((a = n.sandbox) == null ? void 0 : a.identifierExtractScript) && !!((u = n.configurations) != null && u[at]) && e.push({ value: at, label: "Connect to a Playground" }), e;
390
+ }, In = ({
391
391
  installedState: n,
392
392
  connectionMethods: t
393
393
  }) => {
394
394
  var i;
395
395
  const e = (n == null ? void 0 : n.configurationType) ?? null;
396
396
  return t.some((o) => o.value === e) ? e : ((i = t[0]) == null ? void 0 : i.value) ?? null;
397
- }, In = ({
397
+ }, yn = ({
398
398
  integrations: n,
399
399
  searchTerm: t,
400
400
  visibility: e,
401
401
  verification: i,
402
402
  sortMethod: o
403
403
  }) => {
404
- const r = t.trim().toLowerCase(), c = i ?? [];
404
+ const r = t.trim().toLowerCase(), l = i ?? [];
405
405
  let a = n;
406
- if (r && (a = a.filter((l) => (l.title || l.name).toLowerCase().includes(r))), e && e !== "all" && (a = a.filter((l) => e === "private" ? l.isPrivate : !l.isPrivate)), c.length > 0 && (a = a.filter((l) => {
407
- const b = c.includes("official") && l.isOfficial, p = c.includes("verified") && l.isVerified;
408
- return b || p;
406
+ if (r && (a = a.filter((s) => (s.title || s.name).toLowerCase().includes(r))), e && e !== "all" && (a = a.filter((s) => e === "private" ? s.isPrivate : !s.isPrivate)), l.length > 0 && (a = a.filter((s) => {
407
+ const g = l.includes("official") && s.isOfficial, b = l.includes("verified") && s.isVerified;
408
+ return g || b;
409
409
  })), !o)
410
410
  return a;
411
- const u = (l) => (l.title || l.name).toLowerCase(), d = (l) => l.updatedAt ? new Date(l.updatedAt).getTime() : 0;
412
- return [...a].sort((l, b) => o === "asc" ? u(l).localeCompare(u(b), void 0, { sensitivity: "base" }) : o === "desc" ? u(b).localeCompare(u(l), void 0, { sensitivity: "base" }) : o === "newest" ? d(b) - d(l) : d(l) - d(b));
413
- }, Zn = (n) => {
411
+ const u = (s) => (s.title || s.name).toLowerCase(), d = (s) => s.updatedAt ? new Date(s.updatedAt).getTime() : 0;
412
+ return [...a].sort((s, g) => o === "asc" ? u(s).localeCompare(u(g), void 0, { sensitivity: "base" }) : o === "desc" ? u(g).localeCompare(u(s), void 0, { sensitivity: "base" }) : o === "newest" ? d(g) - d(s) : d(s) - d(g));
413
+ }, Jn = (n) => {
414
414
  const t = /* @__PURE__ */ new Map();
415
415
  for (const e of n)
416
416
  t.set(e.id, e);
417
417
  return [...t.values()];
418
- }, yn = (n, t) => ["integration-hub", n, t], Sn = (n) => {
418
+ }, Sn = (n, t) => ["integration-hub", n, t], An = (n) => {
419
419
  var e;
420
420
  if (!n || typeof n != "object")
421
421
  return !1;
422
422
  const t = n;
423
423
  return t.status === 404 || t.statusCode === 404 || ((e = t.response) == null ? void 0 : e.status) === 404;
424
- }, An = async ({
424
+ }, Tn = async ({
425
425
  client: n,
426
426
  integrationId: t
427
427
  }) => {
428
428
  try {
429
429
  return (await n.getPublicIntegrationById({ id: t })).integration;
430
430
  } catch (e) {
431
- if (!Sn(e))
431
+ if (!An(e))
432
432
  throw e;
433
433
  return (await n.getIntegration({ id: t })).integration;
434
434
  }
435
- }, Tn = ({
435
+ }, On = ({
436
436
  installedIntegrations: n,
437
437
  integrationId: t,
438
438
  integrationName: e
439
- }) => pt({
439
+ }) => ft({
440
440
  installedIntegrations: n,
441
441
  integrationId: t,
442
442
  integrationName: e
443
- }) ?? null, On = async ({ client: n, botId: t, integrationId: e }) => {
443
+ }) ?? null, Pn = async ({ client: n, botId: t, integrationId: e }) => {
444
444
  if (!e)
445
445
  return null;
446
446
  const [i, o] = await Promise.all([
447
- An({ client: n, integrationId: e }),
447
+ Tn({ client: n, integrationId: e }),
448
448
  n.getBot({ id: t })
449
- ]), r = Z(o.bot.integrations), c = Tn({
449
+ ]), r = J(o.bot.integrations), l = On({
450
450
  installedIntegrations: r,
451
451
  integrationId: e,
452
452
  integrationName: i.name
453
- }), a = Cn(i);
453
+ }), a = wn(i);
454
454
  return {
455
455
  definition: i,
456
- installedState: c,
457
- capabilities: vn(i),
456
+ installedState: l,
457
+ capabilities: Cn(i),
458
458
  connectionMethods: a,
459
- selectedConnectionMethod: wn({ installedState: c, connectionMethods: a })
459
+ selectedConnectionMethod: In({ installedState: l, connectionMethods: a })
460
460
  };
461
- }, Mt = ({
461
+ }, xt = ({
462
462
  client: n,
463
463
  workspaceId: t,
464
464
  botId: e,
465
465
  integrationId: i,
466
466
  enabled: o = !0
467
467
  }) => {
468
- const r = It(), c = E(() => yn(t, e), [t, e]), { data: a, isLoading: u, error: d, refetch: l } = yt({
469
- queryKey: [...c, "details", i],
468
+ const r = yt(), l = E(() => Sn(t, e), [t, e]), { data: a, isLoading: u, error: d, refetch: s } = St({
469
+ queryKey: [...l, "details", i],
470
470
  enabled: o && !!i,
471
- queryFn: () => On({ client: n, workspaceId: t, botId: e, integrationId: i, enabled: o })
472
- }), b = G(async () => {
473
- await r.invalidateQueries({ queryKey: c });
474
- }, [r, c]), p = () => {
471
+ queryFn: () => Pn({ client: n, workspaceId: t, botId: e, integrationId: i, enabled: o })
472
+ }), g = Z(async () => {
473
+ await r.invalidateQueries({ queryKey: l });
474
+ }, [r, l]), b = () => {
475
475
  if (!(a != null && a.installedState))
476
476
  throw new Error("Integration is not installed on this bot");
477
477
  return a.installedState;
478
478
  }, S = D({
479
479
  mutationFn: async (I) => {
480
- const g = p();
480
+ const p = b();
481
481
  await n.updateBot({
482
482
  id: e,
483
483
  integrations: {
484
- [g.botIntegrationId]: {
484
+ [p.botIntegrationId]: {
485
485
  configuration: I,
486
- configurationType: g.configurationType ?? null
486
+ configurationType: p.configurationType ?? null
487
487
  }
488
488
  }
489
489
  });
490
490
  },
491
- onSuccess: b
492
- }), x = D({
491
+ onSuccess: g
492
+ }), T = D({
493
493
  mutationFn: async () => {
494
- const I = p();
494
+ const I = b();
495
495
  await n.updateBot({
496
496
  id: e,
497
497
  integrations: {
@@ -501,20 +501,20 @@ const on = "width=650,height=800,popup=true", an = 500, rn = 5 * 60 * 1e3, sn =
501
501
  }
502
502
  });
503
503
  },
504
- onSuccess: b
505
- }), P = D({
504
+ onSuccess: g
505
+ }), M = D({
506
506
  mutationFn: async (I) => {
507
- const g = p();
507
+ const p = b();
508
508
  await n.updateBot({
509
509
  id: e,
510
510
  integrations: {
511
- [g.botIntegrationId]: {
511
+ [p.botIntegrationId]: {
512
512
  configurationType: I
513
513
  }
514
514
  }
515
515
  });
516
516
  },
517
- onSuccess: b
517
+ onSuccess: g
518
518
  });
519
519
  return {
520
520
  definition: (a == null ? void 0 : a.definition) ?? null,
@@ -527,18 +527,18 @@ const on = "width=650,height=800,popup=true", an = 500, rn = 5 * 60 * 1e3, sn =
527
527
  },
528
528
  connectionMethods: (a == null ? void 0 : a.connectionMethods) ?? [],
529
529
  isLoading: u,
530
- error: d ? ut(d) : null,
530
+ error: d ? pt(d) : null,
531
531
  saveConfig: S.mutateAsync,
532
- toggleEnabled: x.mutateAsync,
533
- setConnectionMethod: P.mutateAsync,
532
+ toggleEnabled: T.mutateAsync,
533
+ setConnectionMethod: M.mutateAsync,
534
534
  refresh: () => {
535
- l();
535
+ s();
536
536
  },
537
537
  isSavingConfig: S.isPending,
538
- isTogglingEnabled: x.isPending,
539
- isSettingConnectionMethod: P.isPending
538
+ isTogglingEnabled: T.isPending,
539
+ isSettingConnectionMethod: M.isPending
540
540
  };
541
- }, Jn = Mt, xt = 100, Ut = 200, Pn = (n, t) => ["integration-hub", n, t], Bn = ({
541
+ }, Xn = xt, Ut = 100, kt = 200, Bn = (n, t) => ["integration-hub", n, t], Mn = ({
542
542
  publicIntegrations: n,
543
543
  privateIntegrations: t
544
544
  }) => {
@@ -548,38 +548,38 @@ const on = "width=650,height=800,popup=true", an = 500, rn = 5 * 60 * 1e3, sn =
548
548
  for (const i of t)
549
549
  e.set(i.id, i);
550
550
  return [...e.values()];
551
- }, Mn = async ({ client: n }) => {
551
+ }, xn = async ({ client: n }) => {
552
552
  const t = [];
553
553
  let e, i = 0;
554
554
  do {
555
555
  const o = e, r = await n.listPublicIntegrations({
556
- limit: xt,
556
+ limit: Ut,
557
557
  version: "latest",
558
558
  nextToken: e
559
559
  });
560
- if (t.push(...r.integrations), e = r.meta.nextToken, i += 1, i >= Ut)
560
+ if (t.push(...r.integrations), e = r.meta.nextToken, i += 1, i >= kt)
561
561
  throw new Error("Public integration pagination exceeded safety limit");
562
562
  if (e && e === o)
563
563
  break;
564
564
  } while (e);
565
565
  return t;
566
- }, xn = async ({ client: n }) => {
566
+ }, Un = async ({ client: n }) => {
567
567
  const t = [];
568
568
  let e, i = 0;
569
569
  do {
570
570
  const o = e, r = await n.listIntegrations({
571
- limit: xt,
571
+ limit: Ut,
572
572
  version: "latest",
573
573
  visibility: "private",
574
574
  nextToken: e
575
575
  });
576
- if (t.push(...r.integrations), e = r.meta.nextToken, i += 1, i >= Ut)
576
+ if (t.push(...r.integrations), e = r.meta.nextToken, i += 1, i >= kt)
577
577
  throw new Error("Private integration pagination exceeded safety limit");
578
578
  if (e && e === o)
579
579
  break;
580
580
  } while (e);
581
581
  return t;
582
- }, Un = async ({
582
+ }, kn = async ({
583
583
  client: n,
584
584
  integrationId: t
585
585
  }) => {
@@ -592,434 +592,437 @@ const on = "width=650,height=800,popup=true", an = 500, rn = 5 * 60 * 1e3, sn =
592
592
  return;
593
593
  }
594
594
  }
595
- }, kn = ({
595
+ }, En = ({
596
596
  integrationId: n,
597
597
  installedIntegrations: t
598
598
  }) => {
599
- const e = pt({ installedIntegrations: t, integrationId: n });
599
+ const e = ft({ installedIntegrations: t, integrationId: n });
600
600
  return (e == null ? void 0 : e.botIntegrationId) ?? n;
601
- }, rt = async ({
601
+ }, st = async ({
602
602
  client: n,
603
603
  botId: t,
604
604
  integrationId: e,
605
605
  patch: i
606
606
  }) => {
607
- const { bot: o } = await n.getBot({ id: t }), r = Z(o.integrations), c = kn({ integrationId: e, installedIntegrations: r });
607
+ const { bot: o } = await n.getBot({ id: t }), r = J(o.integrations), l = En({ integrationId: e, installedIntegrations: r });
608
608
  await n.updateBot({
609
609
  id: t,
610
610
  integrations: {
611
- [c]: i
611
+ [l]: i
612
612
  }
613
613
  });
614
- }, En = async ({ client: n, botId: t, categoryResolver: e }) => {
614
+ }, Ln = async ({ client: n, botId: t, categoryResolver: e }) => {
615
615
  const [i, o, r] = await Promise.all([
616
- Mn({ client: n }),
617
616
  xn({ client: n }),
617
+ Un({ client: n }),
618
618
  n.getBot({ id: t })
619
- ]), c = Z(r.bot.integrations), a = Bn({ publicIntegrations: i, privateIntegrations: o }), u = new Map(c.map((p) => [p.name, p])), d = new Map(a.map((p) => [p.name, p])), l = a.map(
620
- (p) => hn({
621
- summary: p,
619
+ ]), l = J(r.bot.integrations), a = Mn({ publicIntegrations: i, privateIntegrations: o }), u = new Map(l.map((b) => [b.name, b])), d = new Map(a.map((b) => [b.name, b])), s = a.map(
620
+ (b) => bn({
621
+ summary: b,
622
622
  installedByName: u,
623
623
  categoryResolver: e
624
624
  })
625
- ), b = c.map(
626
- (p) => bn({
627
- installedIntegration: p,
628
- summary: d.get(p.name),
625
+ ), g = l.map(
626
+ (b) => vn({
627
+ installedIntegration: b,
628
+ summary: d.get(b.name),
629
629
  categoryResolver: e
630
630
  })
631
631
  );
632
632
  return {
633
- integrations: l,
634
- installedIntegrations: b
633
+ integrations: s,
634
+ installedIntegrations: g
635
635
  };
636
- }, kt = ({
636
+ }, Et = ({
637
637
  client: n,
638
638
  workspaceId: t,
639
639
  botId: e,
640
640
  categoryResolver: i,
641
- enabled: o = !0
641
+ enabled: o = !0,
642
+ installEnabled: r
642
643
  }) => {
643
- const r = It(), c = E(() => Pn(t, e), [t, e]), a = dt(Promise.resolve()), { data: u, isLoading: d, error: l, refetch: b } = yt({
644
- queryKey: [...c, "catalog"],
644
+ const l = yt(), a = E(() => Bn(t, e), [t, e]), u = ut(Promise.resolve()), { data: d, isLoading: s, error: g, refetch: b } = St({
645
+ queryKey: [...a, "catalog"],
645
646
  enabled: o,
646
- queryFn: () => En({ client: n, workspaceId: t, botId: e, categoryResolver: i })
647
- }), p = G(async () => {
648
- await r.invalidateQueries({ queryKey: c });
649
- }, [r, c]), S = G(async (C) => {
650
- const L = a.current.then(C, C);
651
- return a.current = L.then(
647
+ queryFn: () => Ln({ client: n, workspaceId: t, botId: e, categoryResolver: i })
648
+ }), S = Z(async () => {
649
+ await l.invalidateQueries({ queryKey: a });
650
+ }, [l, a]), T = Z(async (y) => {
651
+ const N = u.current.then(y, y);
652
+ return u.current = N.then(
652
653
  () => {
653
654
  },
654
655
  () => {
655
656
  }
656
- ), L;
657
- }, []), x = D({
658
- mutationFn: async (C) => {
659
- await S(async () => {
657
+ ), N;
658
+ }, []), M = D({
659
+ mutationFn: async (y) => {
660
+ await T(async () => {
660
661
  await n.updateBot({
661
662
  id: e,
662
663
  integrations: {
663
- [C]: {
664
- enabled: !0
664
+ [y]: {
665
+ enabled: r ?? !0
665
666
  }
666
667
  }
667
668
  });
668
669
  });
669
670
  },
670
- onSuccess: p
671
- }), P = D({
672
- mutationFn: async (C) => {
673
- await S(async () => {
674
- await rt({
671
+ onSuccess: S
672
+ }), I = D({
673
+ mutationFn: async (y) => {
674
+ await T(async () => {
675
+ await st({
675
676
  client: n,
676
677
  botId: e,
677
- integrationId: C,
678
+ integrationId: y,
678
679
  patch: null
679
680
  });
680
681
  });
681
682
  },
682
- onSuccess: p
683
- }), I = D({
684
- mutationFn: async (C) => {
685
- await S(async () => {
686
- await rt({
683
+ onSuccess: S
684
+ }), p = D({
685
+ mutationFn: async (y) => {
686
+ await T(async () => {
687
+ await st({
687
688
  client: n,
688
689
  botId: e,
689
- integrationId: C,
690
+ integrationId: y,
690
691
  patch: {
691
692
  enabled: !0
692
693
  }
693
694
  });
694
695
  });
695
696
  },
696
- onSuccess: p
697
- }), g = D({
698
- mutationFn: async (C) => {
699
- await S(async () => {
700
- await rt({
697
+ onSuccess: S
698
+ }), f = D({
699
+ mutationFn: async (y) => {
700
+ await T(async () => {
701
+ await st({
701
702
  client: n,
702
703
  botId: e,
703
- integrationId: C,
704
+ integrationId: y,
704
705
  patch: {
705
706
  enabled: !1
706
707
  }
707
708
  });
708
709
  });
709
710
  },
710
- onSuccess: p
711
- }), f = D({
712
- mutationFn: async (C) => {
713
- await S(async () => {
714
- const { bot: L } = await n.getBot({ id: e }), H = Z(L.integrations), k = await Un({ client: n, integrationId: C }), y = pt({
715
- installedIntegrations: H,
716
- integrationId: C,
717
- integrationName: k
718
- }), M = {
719
- enabled: (y == null ? void 0 : y.enabled) ?? !0,
720
- configuration: (y == null ? void 0 : y.configuration) ?? {},
721
- configurationType: (y == null ? void 0 : y.configurationType) ?? null
722
- }, U = {
723
- [C]: M
711
+ onSuccess: S
712
+ }), k = D({
713
+ mutationFn: async (y) => {
714
+ await T(async () => {
715
+ const { bot: N } = await n.getBot({ id: e }), U = J(N.integrations), V = await kn({ client: n, integrationId: y }), C = ft({
716
+ installedIntegrations: U,
717
+ integrationId: y,
718
+ integrationName: V
719
+ }), x = {
720
+ enabled: (C == null ? void 0 : C.enabled) ?? !0,
721
+ configuration: (C == null ? void 0 : C.configuration) ?? {},
722
+ configurationType: (C == null ? void 0 : C.configurationType) ?? null
723
+ }, L = {
724
+ [y]: x
724
725
  };
725
- y && y.botIntegrationId !== C && (U[y.botIntegrationId] = null), await n.updateBot({
726
+ C && C.botIntegrationId !== y && (L[C.botIntegrationId] = null), await n.updateBot({
726
727
  id: e,
727
- integrations: U
728
+ integrations: L
728
729
  });
729
730
  });
730
731
  },
731
- onSuccess: p
732
+ onSuccess: S
732
733
  });
733
734
  return {
734
- integrations: (u == null ? void 0 : u.integrations) ?? [],
735
- installedIntegrations: (u == null ? void 0 : u.installedIntegrations) ?? [],
736
- isLoading: d,
737
- error: l ? ut(l) : null,
738
- install: x.mutateAsync,
739
- uninstall: P.mutateAsync,
740
- enable: I.mutateAsync,
741
- disable: g.mutateAsync,
742
- upgrade: f.mutateAsync,
735
+ integrations: (d == null ? void 0 : d.integrations) ?? [],
736
+ installedIntegrations: (d == null ? void 0 : d.installedIntegrations) ?? [],
737
+ isLoading: s,
738
+ error: g ? pt(g) : null,
739
+ install: M.mutateAsync,
740
+ uninstall: I.mutateAsync,
741
+ enable: p.mutateAsync,
742
+ disable: f.mutateAsync,
743
+ upgrade: k.mutateAsync,
743
744
  refresh: () => {
744
745
  b();
745
746
  },
746
- isInstalling: x.isPending,
747
- isUninstalling: P.isPending,
748
- isEnabling: I.isPending,
749
- isDisabling: g.isPending,
750
- isUpgrading: f.isPending
747
+ isInstalling: M.isPending,
748
+ isUninstalling: I.isPending,
749
+ isEnabling: p.isPending,
750
+ isDisabling: f.isPending,
751
+ isUpgrading: k.isPending
751
752
  };
752
- }, Xn = kt, Ln = ["official", "verified"], Nn = () => /* @__PURE__ */ v("div", { className: "flex items-center justify-center py-16", children: /* @__PURE__ */ v(wt, { className: "h-6 w-6 animate-spin text-[var(--gray-9)]" }) }), Fn = () => /* @__PURE__ */ v("div", { className: "flex items-center justify-center py-16 text-sm text-[var(--gray-11)]", children: "Integration details are unavailable for this selection." }), jn = (n) => n ? {
753
+ }, Yn = Et, Nn = ["official", "verified"], Fn = () => /* @__PURE__ */ v("div", { className: "flex items-center justify-center py-16", children: /* @__PURE__ */ v(It, { className: "h-6 w-6 animate-spin text-[var(--gray-9)]" }) }), jn = () => /* @__PURE__ */ v("div", { className: "flex items-center justify-center py-16 text-sm text-[var(--gray-11)]", children: "Integration details are unavailable for this selection." }), Dn = (n) => n ? {
753
754
  key: n.key,
754
755
  type: n.type
755
- } : null, Dn = ({
756
+ } : null, Vn = ({
756
757
  definition: n,
757
758
  selectedConnectionMethod: t
758
759
  }) => {
759
- var e, i, o, r, c;
760
- return t ? ((o = (i = (e = n.configurations) == null ? void 0 : e[t]) == null ? void 0 : i.identifier) == null ? void 0 : o.linkTemplateScript) ?? null : ((c = (r = n.configuration) == null ? void 0 : r.identifier) == null ? void 0 : c.linkTemplateScript) ?? null;
761
- }, Vn = ({
760
+ var e, i, o, r, l;
761
+ return t ? ((o = (i = (e = n.configurations) == null ? void 0 : e[t]) == null ? void 0 : i.identifier) == null ? void 0 : o.linkTemplateScript) ?? null : ((l = (r = n.configuration) == null ? void 0 : r.identifier) == null ? void 0 : l.linkTemplateScript) ?? null;
762
+ }, _n = ({
762
763
  client: n,
763
764
  workspaceId: t,
764
765
  botId: e,
765
766
  initialView: i = "hub",
766
767
  categories: o,
767
768
  bannerSlides: r,
768
- bannerIconUrl: c,
769
+ bannerIconUrl: l,
769
770
  noResultsDocumentationLink: a,
770
771
  disableInstallation: u = !1,
771
- hasWriteAccess: d = !0,
772
- categoryResolver: l,
772
+ installEnabled: d,
773
+ hasWriteAccess: s = !0,
774
+ categoryResolver: g,
773
775
  filterMenuLabels: b,
774
- defaultVisibility: p,
775
- defaultVerification: S,
776
- defaultSortMethod: x,
777
- renderConfigurationForm: P,
778
- renderConnectionsContent: I,
779
- oauthTemplateData: g,
780
- renderDetailPanel: f,
781
- onInstall: C,
782
- onUninstall: L,
783
- onEnable: H,
784
- onDisable: k,
785
- onUpgrade: y,
786
- onError: M
776
+ defaultVisibility: S,
777
+ defaultVerification: T,
778
+ defaultSortMethod: M,
779
+ renderConfigurationForm: I,
780
+ renderConnectionsContent: p,
781
+ oauthTemplateData: f,
782
+ renderDetailPanel: k,
783
+ onInstall: y,
784
+ onUninstall: N,
785
+ onEnable: U,
786
+ onDisable: V,
787
+ onUpgrade: C,
788
+ onError: x
787
789
  }) => {
788
- const [U, K] = O(i), [N, Et] = O(""), [F, q] = O(null), [J, z] = O(null), [X, Lt] = O(p), [Y, Nt] = O(
789
- S ?? [...Ln]
790
- ), [m, Ft] = O(x), [jt, tt] = O("connections"), [Dt, nt] = O("connections"), w = kt({
790
+ const [L, _] = P(i), [q, Lt] = P(""), [F, Q] = P(null), [X, z] = P(null), [Y, Nt] = P(S), [m, Ft] = P(
791
+ T ?? [...Nn]
792
+ ), [tt, jt] = P(M), [Dt, nt] = P("connections"), [Vt, et] = P("connections"), w = Et({
791
793
  client: n,
792
794
  workspaceId: t,
793
795
  botId: e,
794
- categoryResolver: l,
796
+ categoryResolver: g,
797
+ installEnabled: d,
795
798
  enabled: !0
796
- }), Vt = E(
797
- () => In({
799
+ }), _t = E(
800
+ () => yn({
798
801
  integrations: w.integrations,
799
- searchTerm: N,
800
- visibility: X,
801
- verification: Y,
802
- sortMethod: m
802
+ searchTerm: q,
803
+ visibility: Y,
804
+ verification: m,
805
+ sortMethod: tt
803
806
  }),
804
- [w.integrations, N, X, Y, m]
807
+ [w.integrations, q, Y, m, tt]
805
808
  ), B = E(
806
809
  () => [...w.integrations, ...w.installedIntegrations].find(
807
810
  (h) => h.id === F
808
811
  ) ?? null,
809
812
  [w.integrations, w.installedIntegrations, F]
810
- ), s = Mt({
813
+ ), c = xt({
811
814
  client: n,
812
815
  workspaceId: t,
813
816
  botId: e,
814
817
  integrationId: F,
815
818
  enabled: !!F
816
- }), _t = E(
819
+ }), Ht = E(
817
820
  () => (o == null ? void 0 : o.filter((h) => h.name !== "Popular").map((h) => h.name)) ?? [],
818
821
  [o]
819
- ), Q = G(
822
+ ), W = Z(
820
823
  (h) => {
821
- const T = ut(h);
822
- M == null || M(T);
824
+ const O = pt(h);
825
+ x == null || x(O);
823
826
  },
824
- [M]
825
- ), W = async ({
827
+ [x]
828
+ ), R = async ({
826
829
  operation: h,
827
- onSuccess: T,
830
+ onSuccess: O,
828
831
  integration: j
829
832
  }) => {
830
- const V = j ?? B;
831
- if (V)
833
+ const H = j ?? B;
834
+ if (H)
832
835
  try {
833
- await h(), T == null || T(V);
834
- } catch (et) {
835
- Q(et);
836
+ await h(), O == null || O(H);
837
+ } catch (it) {
838
+ W(it);
836
839
  }
837
- }, Ht = (h) => {
838
- var gt, ht, bt, vt;
840
+ }, Kt = (h) => {
841
+ var ht, bt, vt, Ct;
839
842
  if (!F || h !== F)
840
843
  return null;
841
- if (s.isLoading)
842
- return Nn();
843
- if (!s.definition || !B)
844
+ if (c.isLoading)
844
845
  return Fn();
845
- const T = !!s.installedState, j = Dn({
846
- definition: s.definition,
847
- selectedConnectionMethod: s.selectedConnectionMethod
848
- }), V = s.connectionMethods.length > 1 || !!j, et = St({
849
- definition: s.definition,
850
- selectedConnectionMethod: s.selectedConnectionMethod
851
- }), Kt = At(et).length > 0, zt = !!P || Kt, ft = async (A) => {
846
+ if (!c.definition || !B)
847
+ return jn();
848
+ const O = !!c.installedState, j = Vn({
849
+ definition: c.definition,
850
+ selectedConnectionMethod: c.selectedConnectionMethod
851
+ }), H = c.connectionMethods.length > 1 || !!j, it = At({
852
+ definition: c.definition,
853
+ selectedConnectionMethod: c.selectedConnectionMethod
854
+ }), zt = Tt(it).length > 0, qt = !!I || zt, gt = async (A) => {
852
855
  try {
853
- await s.saveConfig(A);
854
- } catch (R) {
855
- Q(R);
856
+ await c.saveConfig(A);
857
+ } catch ($) {
858
+ W($);
856
859
  }
857
- }, qt = I ? I({
858
- definition: s.definition,
859
- installedState: s.installedState,
860
- connectionMethods: s.connectionMethods,
861
- selectedConnectionMethod: s.selectedConnectionMethod,
862
- onConnectionMethodChange: s.setConnectionMethod,
863
- isSettingConnectionMethod: s.isSettingConnectionMethod
864
- }) : /* @__PURE__ */ _("div", { className: "flex flex-col gap-4", children: [
860
+ }, Qt = p ? p({
861
+ definition: c.definition,
862
+ installedState: c.installedState,
863
+ connectionMethods: c.connectionMethods,
864
+ selectedConnectionMethod: c.selectedConnectionMethod,
865
+ onConnectionMethodChange: c.setConnectionMethod,
866
+ isSettingConnectionMethod: c.isSettingConnectionMethod
867
+ }) : /* @__PURE__ */ K("div", { className: "flex flex-col gap-4", children: [
865
868
  /* @__PURE__ */ v("div", { className: "self-end", children: /* @__PURE__ */ v(
866
- Jt,
869
+ Xt,
867
870
  {
868
- options: s.connectionMethods,
869
- value: s.selectedConnectionMethod,
870
- disabled: !d,
871
+ options: c.connectionMethods,
872
+ value: c.selectedConnectionMethod,
873
+ disabled: !s,
871
874
  onChange: (A) => {
872
- d && s.setConnectionMethod(A).catch(Q);
875
+ s && c.setConnectionMethod(A).catch(W);
873
876
  }
874
877
  }
875
878
  ) }),
876
879
  j ? /* @__PURE__ */ v(
877
- un,
880
+ pn,
878
881
  {
879
882
  client: n,
880
- integrationName: s.definition.title ?? s.definition.name,
883
+ integrationName: c.definition.title ?? c.definition.name,
881
884
  linkTemplateScript: j,
882
- webhookUrl: (gt = s.installedState) == null ? void 0 : gt.webhookUrl,
883
- oauthTemplateData: g,
884
- isAuthorized: !!((ht = s.installedState) != null && ht.identifier),
885
- disabled: !d,
885
+ webhookUrl: (ht = c.installedState) == null ? void 0 : ht.webhookUrl,
886
+ oauthTemplateData: f,
887
+ isAuthorized: !!((bt = c.installedState) != null && bt.identifier),
888
+ disabled: !s,
886
889
  onAuthorized: async () => {
887
- s.refresh(), w.refresh();
890
+ c.refresh(), w.refresh();
888
891
  },
889
- onError: Q
892
+ onError: W
890
893
  }
891
- ) : /* @__PURE__ */ _("p", { className: "text-sm text-[var(--gray-11)]", children: [
894
+ ) : /* @__PURE__ */ K("p", { className: "text-sm text-[var(--gray-11)]", children: [
892
895
  "No custom connection UI was provided. Use ",
893
896
  /* @__PURE__ */ v("code", { children: "renderConnectionsContent" }),
894
897
  " to plug your OAuth/manual connection flow."
895
898
  ] })
896
- ] }), Qt = /* @__PURE__ */ v(
897
- Xt,
899
+ ] }), Wt = /* @__PURE__ */ v(
900
+ Yt,
898
901
  {
899
- webhookUrl: (bt = s.installedState) == null ? void 0 : bt.webhookUrl,
900
- isBlocked: !s.installedState,
901
- children: P ? P({
902
- definition: s.definition,
903
- installedState: s.installedState,
904
- selectedConnectionMethod: s.selectedConnectionMethod,
905
- onSave: ft,
906
- isSaving: s.isSavingConfig
902
+ webhookUrl: (vt = c.installedState) == null ? void 0 : vt.webhookUrl,
903
+ isBlocked: !c.installedState,
904
+ children: I ? I({
905
+ definition: c.definition,
906
+ installedState: c.installedState,
907
+ selectedConnectionMethod: c.selectedConnectionMethod,
908
+ onSave: gt,
909
+ isSaving: c.isSavingConfig
907
910
  }) : /* @__PURE__ */ v(
908
- pn,
911
+ fn,
909
912
  {
910
- definition: s.definition,
911
- installedState: s.installedState,
912
- selectedConnectionMethod: s.selectedConnectionMethod,
913
- onSave: ft,
914
- isSaving: s.isSavingConfig,
915
- disabled: !d || !s.installedState
913
+ definition: c.definition,
914
+ installedState: c.installedState,
915
+ selectedConnectionMethod: c.selectedConnectionMethod,
916
+ onSave: gt,
917
+ isSaving: c.isSavingConfig,
918
+ disabled: !s || !c.installedState
916
919
  }
917
920
  )
918
921
  }
919
922
  );
920
923
  return /* @__PURE__ */ v(
921
- Yt,
924
+ mt,
922
925
  {
923
- title: s.definition.title ?? s.definition.name,
924
- iconUrl: s.definition.iconUrl,
926
+ title: c.definition.title ?? c.definition.name,
927
+ iconUrl: c.definition.iconUrl,
925
928
  contributorName: B.author,
926
929
  isOfficial: B.isOfficial,
927
930
  isVerified: B.isVerified,
928
931
  isPrivate: B.isPrivate,
929
932
  onBack: () => {
930
- q(null), z(null);
933
+ Q(null), z(null);
931
934
  },
932
- onInstall: T || u || !d ? void 0 : () => {
933
- W({
935
+ onInstall: O || u || !s ? void 0 : () => {
936
+ R({
934
937
  operation: () => w.install(B.id),
935
- onSuccess: C,
938
+ onSuccess: y,
936
939
  integration: B
937
940
  });
938
941
  },
939
- onToggleEnabled: !T || !d ? void 0 : () => {
940
- const A = s.installedState, R = !!(A != null && A.enabled);
941
- W({
942
+ onToggleEnabled: !O || !s ? void 0 : () => {
943
+ const A = c.installedState, $ = !!(A != null && A.enabled);
944
+ R({
942
945
  operation: async () => {
943
946
  if (!A)
944
947
  throw new Error("Integration is not installed");
945
- if (R) {
948
+ if ($) {
946
949
  await w.disable(A.id);
947
950
  return;
948
951
  }
949
952
  await w.enable(A.id);
950
953
  },
951
- onSuccess: R ? k : H,
954
+ onSuccess: $ ? V : U,
952
955
  integration: B
953
956
  });
954
957
  },
955
- onUninstall: !T || !d ? void 0 : () => {
956
- const A = s.installedState;
957
- W({
958
+ onUninstall: !O || !s ? void 0 : () => {
959
+ const A = c.installedState;
960
+ R({
958
961
  operation: async () => {
959
962
  if (!A)
960
963
  throw new Error("Integration is not installed");
961
964
  await w.uninstall(A.id);
962
965
  },
963
- onSuccess: L,
966
+ onSuccess: N,
964
967
  integration: B
965
968
  });
966
969
  },
967
- onUpgrade: !B.hasUpdate || !d ? void 0 : () => {
968
- W({
970
+ onUpgrade: !B.hasUpdate || !s ? void 0 : () => {
971
+ R({
969
972
  operation: () => w.upgrade(B.id),
970
- onSuccess: y,
973
+ onSuccess: C,
971
974
  integration: B
972
975
  });
973
976
  },
974
- isInstalled: T,
977
+ isInstalled: O,
975
978
  disableInstallation: u,
976
- hasWriteAccess: d,
979
+ hasWriteAccess: s,
977
980
  isInstalling: w.isInstalling,
978
981
  isUninstalling: w.isUninstalling,
979
982
  isTogglingEnabled: w.isEnabling || w.isDisabling,
980
983
  hasUpdate: B.hasUpdate,
981
984
  isUpgrading: w.isUpgrading,
982
- toggleButtonLabel: (vt = s.installedState) != null && vt.enabled ? "Disable" : "Enable",
983
- selectedDetailPanel: J && f ? f({
984
- definition: s.definition,
985
- selectedCard: J,
985
+ toggleButtonLabel: (Ct = c.installedState) != null && Ct.enabled ? "Disable" : "Enable",
986
+ selectedDetailPanel: X && k ? k({
987
+ definition: c.definition,
988
+ selectedCard: X,
986
989
  onClose: () => z(null)
987
990
  }) : void 0,
988
991
  onDismissSelectedDetailPanel: () => z(null),
989
992
  children: /* @__PURE__ */ v(
990
- mt,
993
+ tn,
991
994
  {
992
- integrationTitle: s.definition.title ?? s.definition.name,
993
- isFullyConfigured: T,
994
- hasConnectionStep: V,
995
- hasConfigurationStep: zt,
996
- configuredTab: jt,
997
- onConfiguredTabChange: tt,
998
- setupTab: Dt,
999
- onSetupTabChange: nt,
995
+ integrationTitle: c.definition.title ?? c.definition.name,
996
+ isFullyConfigured: O,
997
+ hasConnectionStep: H,
998
+ hasConfigurationStep: qt,
999
+ configuredTab: Dt,
1000
+ onConfiguredTabChange: nt,
1001
+ setupTab: Vt,
1002
+ onSetupTabChange: et,
1000
1003
  onCancelSetup: () => {
1001
- q(null), z(null);
1004
+ Q(null), z(null);
1002
1005
  },
1003
1006
  metadata: /* @__PURE__ */ v(
1004
- tn,
1007
+ nn,
1005
1008
  {
1006
- version: s.definition.version,
1007
- githubUrl: s.definition.url,
1009
+ version: c.definition.version,
1010
+ githubUrl: c.definition.url,
1008
1011
  aboutLabel: "About Integration"
1009
1012
  }
1010
1013
  ),
1011
- connectionsContent: qt,
1012
- configurationContent: Qt,
1014
+ connectionsContent: Qt,
1015
+ configurationContent: Wt,
1013
1016
  capabilitiesContent: /* @__PURE__ */ v(
1014
- nn,
1017
+ en,
1015
1018
  {
1016
- actionCards: s.capabilities.actionCards,
1017
- eventCards: s.capabilities.eventCards,
1018
- channelCards: s.capabilities.channelCards,
1019
- selectedCard: J,
1019
+ actionCards: c.capabilities.actionCards,
1020
+ eventCards: c.capabilities.eventCards,
1021
+ channelCards: c.capabilities.channelCards,
1022
+ selectedCard: X,
1020
1023
  onCardSelect: (A) => {
1021
1024
  z(
1022
- jn(
1025
+ Dn(
1023
1026
  A ? {
1024
1027
  key: A.key,
1025
1028
  type: A.type
@@ -1034,16 +1037,16 @@ const on = "width=650,height=800,popup=true", an = 500, rn = 5 * 60 * 1e3, sn =
1034
1037
  }
1035
1038
  );
1036
1039
  };
1037
- return /* @__PURE__ */ _("div", { className: "flex h-full min-h-0 flex-col", children: [
1038
- !F && /* @__PURE__ */ v("div", { className: "flex justify-end px-6 pt-4", children: /* @__PURE__ */ _("div", { className: "flex rounded-lg bg-[var(--gray-a3)] p-1", children: [
1040
+ return /* @__PURE__ */ K("div", { className: "flex h-full min-h-0 flex-col", children: [
1041
+ !F && /* @__PURE__ */ v("div", { className: "flex justify-end px-6 pt-4", children: /* @__PURE__ */ K("div", { className: "flex rounded-lg bg-[var(--gray-a3)] p-1", children: [
1039
1042
  /* @__PURE__ */ v(
1040
1043
  "button",
1041
1044
  {
1042
1045
  type: "button",
1043
- onClick: () => K("hub"),
1044
- className: ct(
1046
+ onClick: () => _("hub"),
1047
+ className: lt(
1045
1048
  "cursor-pointer rounded-md px-3 py-1.5 text-sm text-[var(--gray-11)] transition-colors",
1046
- U === "hub" && "bg-[var(--gray-1)] text-[var(--gray-12)] shadow-sm"
1049
+ L === "hub" && "bg-[var(--gray-1)] text-[var(--gray-12)] shadow-sm"
1047
1050
  ),
1048
1051
  children: "Integration Hub"
1049
1052
  }
@@ -1052,46 +1055,46 @@ const on = "width=650,height=800,popup=true", an = 500, rn = 5 * 60 * 1e3, sn =
1052
1055
  "button",
1053
1056
  {
1054
1057
  type: "button",
1055
- onClick: () => K("installed"),
1056
- className: ct(
1058
+ onClick: () => _("installed"),
1059
+ className: lt(
1057
1060
  "cursor-pointer rounded-md px-3 py-1.5 text-sm text-[var(--gray-11)] transition-colors",
1058
- U === "installed" && "bg-[var(--gray-1)] text-[var(--gray-12)] shadow-sm"
1061
+ L === "installed" && "bg-[var(--gray-1)] text-[var(--gray-12)] shadow-sm"
1059
1062
  ),
1060
1063
  children: "Installed Integrations"
1061
1064
  }
1062
1065
  )
1063
1066
  ] }) }),
1064
1067
  /* @__PURE__ */ v(
1065
- Rt,
1068
+ $t,
1066
1069
  {
1067
- view: U,
1068
- searchInput: N,
1069
- searchTerm: N,
1070
- onSearchInputChange: Et,
1070
+ view: L,
1071
+ searchInput: q,
1072
+ searchTerm: q,
1073
+ onSearchInputChange: Lt,
1071
1074
  selectedIntegrationId: F,
1072
- hubIntegrations: Vt,
1075
+ hubIntegrations: _t,
1073
1076
  sidebarIntegrations: w.integrations,
1074
1077
  installedIntegrations: w.installedIntegrations,
1075
1078
  isHubLoading: w.isLoading,
1076
1079
  isInstalledLoading: w.isLoading,
1077
1080
  filterMenu: /* @__PURE__ */ v(
1078
- $t,
1081
+ Gt,
1079
1082
  {
1080
- visibility: X,
1081
- verification: Y,
1082
- sortMethod: m,
1083
+ visibility: Y,
1084
+ verification: m,
1085
+ sortMethod: tt,
1083
1086
  labels: b,
1084
- onVisibilityChange: Lt,
1085
- onVerificationChange: Nt,
1086
- onSortMethodChange: Ft
1087
+ onVisibilityChange: Nt,
1088
+ onVerificationChange: Ft,
1089
+ onSortMethodChange: jt
1087
1090
  }
1088
1091
  ),
1089
1092
  categories: o,
1090
1093
  bannerSlides: r,
1091
- bannerIconUrl: c,
1094
+ bannerIconUrl: l,
1092
1095
  noResultsDocumentationLink: a,
1093
- renderIntegrationCard: (h, { onEscape: T }) => /* @__PURE__ */ v(
1094
- Gt,
1096
+ renderIntegrationCard: (h, { onEscape: O }) => /* @__PURE__ */ v(
1097
+ Zt,
1095
1098
  {
1096
1099
  name: h.title ?? h.name,
1097
1100
  description: h.description,
@@ -1103,49 +1106,49 @@ const on = "width=650,height=800,popup=true", an = 500, rn = 5 * 60 * 1e3, sn =
1103
1106
  private: h.isPrivate,
1104
1107
  iconUrl: h.iconUrl,
1105
1108
  onClick: () => {
1106
- q(h.id), tt("connections"), nt("connections");
1109
+ Q(h.id), nt("connections"), et("connections");
1107
1110
  },
1108
- onEscape: T
1111
+ onEscape: O
1109
1112
  }
1110
1113
  ),
1111
- renderInstalledIntegrations: ({ integrations: h, searchTerm: T, categoryOrder: j }) => /* @__PURE__ */ v(
1112
- Zt,
1114
+ renderInstalledIntegrations: ({ integrations: h, searchTerm: O, categoryOrder: j }) => /* @__PURE__ */ v(
1115
+ Jt,
1113
1116
  {
1114
1117
  integrations: h,
1115
- searchTerm: T,
1116
- categoryOrder: j.length > 0 ? j : _t,
1117
- onSelectIntegration: (V) => {
1118
- q(V.id), tt("connections"), nt("connections");
1118
+ searchTerm: O,
1119
+ categoryOrder: j.length > 0 ? j : Ht,
1120
+ onSelectIntegration: (H) => {
1121
+ Q(H.id), nt("connections"), et("connections");
1119
1122
  }
1120
1123
  }
1121
1124
  ),
1122
- renderIntegrationDetails: Ht
1125
+ renderIntegrationDetails: Kt
1123
1126
  }
1124
1127
  )
1125
1128
  ] });
1126
- }, Yn = Vn;
1129
+ }, mn = _n;
1127
1130
  export {
1128
- Yn as BotpressIntegrationHub,
1129
- Vn as BotpressIntegrationHubScreen,
1130
- un as IntegrationOAuthButton,
1131
- pn as IntegrationStaticZuiConfigurationForm,
1132
- Zn as dedupeById,
1133
- cn as fetchOAuthAuthorizationUrl,
1134
- In as filterAndSortIntegrations,
1135
- pt as findInstalledIntegration,
1136
- Z as getInstalledIntegrations,
1137
- wn as getSelectedConnectionMethod,
1138
- sn as getWebhookIdFromUrl,
1139
- Pt as isOfficialWorkspace,
1140
- ln as openOAuthPopup,
1141
- Bt as resolveCategory,
1142
- vn as toCapabilityCards,
1143
- Cn as toConnectionMethods,
1144
- ut as toError,
1145
- hn as toHubItem,
1146
- bn as toInstalledItem,
1147
- Mt as useBotpressIntegrationDetails,
1148
- kt as useBotpressIntegrationHub,
1149
- Jn as useIntegrationDetails,
1150
- Xn as useIntegrationHub
1131
+ mn as BotpressIntegrationHub,
1132
+ _n as BotpressIntegrationHubScreen,
1133
+ pn as IntegrationOAuthButton,
1134
+ fn as IntegrationStaticZuiConfigurationForm,
1135
+ Jn as dedupeById,
1136
+ ln as fetchOAuthAuthorizationUrl,
1137
+ yn as filterAndSortIntegrations,
1138
+ ft as findInstalledIntegration,
1139
+ J as getInstalledIntegrations,
1140
+ In as getSelectedConnectionMethod,
1141
+ cn as getWebhookIdFromUrl,
1142
+ Bt as isOfficialWorkspace,
1143
+ dn as openOAuthPopup,
1144
+ Mt as resolveCategory,
1145
+ Cn as toCapabilityCards,
1146
+ wn as toConnectionMethods,
1147
+ pt as toError,
1148
+ bn as toHubItem,
1149
+ vn as toInstalledItem,
1150
+ xt as useBotpressIntegrationDetails,
1151
+ Et as useBotpressIntegrationHub,
1152
+ Xn as useIntegrationDetails,
1153
+ Yn as useIntegrationHub
1151
1154
  };