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