@bpinternal/integration-hub 0.7.0 → 0.8.1

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