@burdenoff/microfe-botmanor 2026.1114.1 → 2026.1115.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.
@@ -0,0 +1,18 @@
1
+ import { FC, ReactNode } from 'react';
2
+ export interface ActionMenuItem {
3
+ key: string;
4
+ label: string;
5
+ icon?: ReactNode;
6
+ onSelect: () => void;
7
+ /** Rendered in the error colour, for destructive actions. */
8
+ destructive?: boolean;
9
+ }
10
+ interface ActionMenuProps {
11
+ /** Accessible name of the trigger, e.g. "Actions for Support Bot". */
12
+ label: string;
13
+ items: ActionMenuItem[];
14
+ /** Hide the trigger until the parent `group` is hovered or focused. */
15
+ revealOnHover?: boolean;
16
+ }
17
+ export declare const ActionMenu: FC<ActionMenuProps>;
18
+ export {};
@@ -0,0 +1,76 @@
1
+ import { cn as e } from "../utils/cn.js";
2
+ import { useCallback as t, useEffect as n, useId as r, useRef as i, useState as a } from "react";
3
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
4
+ import { MoreVertical as c } from "lucide-react";
5
+ // src/botlit/components/ActionMenu.tsx
6
+ var l = ({ label: l, items: u, revealOnHover: d = !0 }) => {
7
+ let [f, p] = a(!1), m = i(null), h = i(null), g = r(), _ = t((e) => {
8
+ p(!1), e && h.current?.focus();
9
+ }, []);
10
+ return n(() => {
11
+ if (!f) return;
12
+ let e = (e) => {
13
+ m.current && !m.current.contains(e.target) && _(!1);
14
+ };
15
+ return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
16
+ }, [f, _]), n(() => {
17
+ f && m.current?.querySelector("[role=\"menuitem\"]")?.focus();
18
+ }, [f]), u.length === 0 ? null : /* @__PURE__ */ s("div", {
19
+ ref: m,
20
+ className: "relative",
21
+ children: [/* @__PURE__ */ o("button", {
22
+ ref: h,
23
+ type: "button",
24
+ "aria-label": l,
25
+ "aria-haspopup": "menu",
26
+ "aria-expanded": f,
27
+ "aria-controls": f ? g : void 0,
28
+ onClick: () => p((e) => !e),
29
+ className: e("inline-flex h-10 w-10 items-center justify-center rounded-md transition-opacity hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary", d && !f && "opacity-0 group-hover:opacity-100 focus-visible:opacity-100"),
30
+ children: /* @__PURE__ */ o(c, {
31
+ size: 16,
32
+ "aria-hidden": "true"
33
+ })
34
+ }), f && /* @__PURE__ */ o("div", {
35
+ id: g,
36
+ role: "menu",
37
+ "aria-label": l,
38
+ tabIndex: -1,
39
+ onKeyDown: (e) => {
40
+ let t = Array.from(m.current?.querySelectorAll("[role=\"menuitem\"]") ?? []), n = t.indexOf(document.activeElement), r = (e) => t[(e + t.length) % t.length]?.focus();
41
+ switch (e.key) {
42
+ case "ArrowDown":
43
+ e.preventDefault(), r(n + 1);
44
+ break;
45
+ case "ArrowUp":
46
+ e.preventDefault(), r(n - 1);
47
+ break;
48
+ case "Home":
49
+ e.preventDefault(), r(0);
50
+ break;
51
+ case "End":
52
+ e.preventDefault(), r(t.length - 1);
53
+ break;
54
+ case "Escape":
55
+ e.preventDefault(), e.stopPropagation(), _(!0);
56
+ break;
57
+ case "Tab": _(!1);
58
+ }
59
+ },
60
+ className: "absolute right-0 top-full z-10 mt-1 w-48 rounded-md border border-border-subtle bg-popover shadow-lg",
61
+ children: u.map((t) => /* @__PURE__ */ s("button", {
62
+ type: "button",
63
+ role: "menuitem",
64
+ tabIndex: -1,
65
+ className: e("flex w-full items-center gap-2 px-4 py-2 text-left text-sm hover:bg-accent focus-visible:bg-accent focus-visible:outline-none", t.destructive && "text-status-error-text"),
66
+ onClick: () => {
67
+ _(!1), t.onSelect();
68
+ },
69
+ children: [t.icon, t.label]
70
+ }, t.key))
71
+ })]
72
+ });
73
+ };
74
+ export { l as ActionMenu };
75
+
76
+ //# sourceMappingURL=ActionMenu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionMenu.js","names":["ActionMenu","open","setOpen","useState","rootRef","useRef","triggerRef","menuId","useId","close","useCallback","returnFocus","useEffect","onPointerDown","event","items","label","value","cn","revealOnHover","MoreVertical","entries","current","focusAt","index","item"],"sources":["../../../src/botlit/components/ActionMenu.tsx"],"sourcesContent":["/**\n * Action Menu\n * @module botlit/components\n *\n * A \"more actions\" menu button with real menu semantics (BOFF-12443): the\n * trigger announces `aria-haspopup`/`aria-expanded`, the items are\n * `role=\"menuitem\"`, arrow keys move between them, Home/End jump, Escape closes\n * and returns focus to the trigger, and a click outside closes it. The trigger\n * is hidden until the row is hovered or focused, but stays focusable and shows\n * itself when it has focus, so a keyboard user never lands on an invisible\n * control.\n */\n\nimport type { FC, ReactNode } from 'react';\nimport { useCallback, useEffect, useId, useRef, useState } from 'react';\nimport { MoreVertical } from 'lucide-react';\nimport { cn } from '../utils/cn';\n\nexport interface ActionMenuItem {\n key: string;\n label: string;\n icon?: ReactNode;\n onSelect: () => void;\n /** Rendered in the error colour, for destructive actions. */\n destructive?: boolean;\n}\n\ninterface ActionMenuProps {\n /** Accessible name of the trigger, e.g. \"Actions for Support Bot\". */\n label: string;\n items: ActionMenuItem[];\n /** Hide the trigger until the parent `group` is hovered or focused. */\n revealOnHover?: boolean;\n}\n\nexport const ActionMenu: FC<ActionMenuProps> = ({ label, items, revealOnHover = true }) => {\n const [open, setOpen] = useState(false);\n const rootRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const menuId = useId();\n\n const close = useCallback((returnFocus: boolean) => {\n setOpen(false);\n if (returnFocus) triggerRef.current?.focus();\n }, []);\n\n useEffect(() => {\n if (!open) return;\n const onPointerDown = (event: MouseEvent) => {\n if (rootRef.current && !rootRef.current.contains(event.target as Node)) close(false);\n };\n document.addEventListener('mousedown', onPointerDown);\n return () => document.removeEventListener('mousedown', onPointerDown);\n }, [open, close]);\n\n useEffect(() => {\n if (!open) return;\n rootRef.current?.querySelector<HTMLElement>('[role=\"menuitem\"]')?.focus();\n }, [open]);\n\n const onMenuKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n const entries = Array.from(\n rootRef.current?.querySelectorAll<HTMLElement>('[role=\"menuitem\"]') ?? []\n );\n const current = entries.indexOf(document.activeElement as HTMLElement);\n const focusAt = (index: number) => entries[(index + entries.length) % entries.length]?.focus();\n\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault();\n focusAt(current + 1);\n break;\n case 'ArrowUp':\n event.preventDefault();\n focusAt(current - 1);\n break;\n case 'Home':\n event.preventDefault();\n focusAt(0);\n break;\n case 'End':\n event.preventDefault();\n focusAt(entries.length - 1);\n break;\n case 'Escape':\n event.preventDefault();\n event.stopPropagation();\n close(true);\n break;\n case 'Tab':\n close(false);\n break;\n }\n };\n\n if (items.length === 0) return null;\n\n return (\n <div ref={rootRef} className=\"relative\">\n <button\n ref={triggerRef}\n type=\"button\"\n aria-label={label}\n aria-haspopup=\"menu\"\n aria-expanded={open}\n aria-controls={open ? menuId : undefined}\n onClick={() => setOpen((value) => !value)}\n className={cn(\n 'inline-flex h-10 w-10 items-center justify-center rounded-md transition-opacity hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary',\n revealOnHover && !open && 'opacity-0 group-hover:opacity-100 focus-visible:opacity-100'\n )}\n >\n <MoreVertical size={16} aria-hidden=\"true\" />\n </button>\n {open && (\n <div\n id={menuId}\n role=\"menu\"\n aria-label={label}\n tabIndex={-1}\n onKeyDown={onMenuKeyDown}\n className=\"absolute right-0 top-full z-10 mt-1 w-48 rounded-md border border-border-subtle bg-popover shadow-lg\"\n >\n {items.map((item) => (\n <button\n key={item.key}\n type=\"button\"\n role=\"menuitem\"\n tabIndex={-1}\n className={cn(\n 'flex w-full items-center gap-2 px-4 py-2 text-left text-sm hover:bg-accent focus-visible:bg-accent focus-visible:outline-none',\n item.destructive && 'text-status-error-text'\n )}\n onClick={() => {\n close(false);\n item.onSelect();\n }}\n >\n {item.icon}\n {item.label}\n </button>\n ))}\n </div>\n )}\n </div>\n );\n};\n"],"mappings":";;;;;AAmCA,IAAaA,KAAmC,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GAC/DE,KAAW,MAAkBF,GAASG,IAAQH,EAAQ,UAAUA,EAAQ,OAAO,EAAE,MAAM;IAE7F,QAAQP,EAAM,KAAd;KACE,KAAK;MAEH,AADAA,EAAM,eAAe,GACrBS,EAAQD,IAAU,CAAC;MACnB;KACF,KAAK;MAEH,AADAR,EAAM,eAAe,GACrBS,EAAQD,IAAU,CAAC;MACnB;KACF,KAAK;MAEH,AADAR,EAAM,eAAe,GACrBS,EAAQ,CAAC;MACT;KACF,KAAK;MAEH,AADAT,EAAM,eAAe,GACrBS,EAAQF,EAAQ,SAAS,CAAC;MAC1B;KACF,KAAK;MAGH,AAFAP,EAAM,eAAe,GACrBA,EAAM,gBAAgB,GACtBL,EAAM,EAAI;MACV;KACF,KAAK,OACH,EAAM,EAAK;IAEf;GACF;GA4BQ,WAAU;GAET,UAAAM,EAAM,KAAK,MACV,kBAAC,UAAD;IAEE,MAAK;IACL,MAAK;IACL,UAAU;IACV,WAAWG,EACT,iIACAO,EAAK,eAAe,wBACtB;IACA,eAAe;KAEb,AADAhB,EAAM,EAAK,GACXgB,EAAK,SAAS;IAChB;IAZF,UAAA,CAcGA,EAAK,MACLA,EAAK,KACA;GAfD,GAAAA,EAAK,GAeJ,CACT;EACE,CAAA,CAEJ;;AAET"}
@@ -0,0 +1,35 @@
1
+ import { FC } from 'react';
2
+ import { BotIdentityErrors } from '../utils/botIdentity';
3
+ /** Routing strategies the bot form offers. */
4
+ export declare const ROUTING_STRATEGIES: readonly ["SINGLE", "ROUND_ROBIN", "INTELLIGENT", "CUSTOM"];
5
+ export type BotRoutingStrategy = (typeof ROUTING_STRATEGIES)[number];
6
+ /** Editable subset of a bot app — one field per `UpdateBotAppInput` field. */
7
+ export interface BotAppForm {
8
+ name: string;
9
+ slug: string;
10
+ description: string;
11
+ icon: string;
12
+ routingStrategy: BotRoutingStrategy;
13
+ welcomeMessage: string;
14
+ fallbackMessage: string;
15
+ defaultAgentId: string;
16
+ }
17
+ export declare const DEFAULT_BOT_ICON = "\uD83E\uDD16";
18
+ export declare const DEFAULT_BOT_FORM: BotAppForm;
19
+ interface BotFormFieldsProps {
20
+ /** Prefix for field ids, so the create and edit forms never collide. */
21
+ idPrefix: string;
22
+ value: BotAppForm;
23
+ onChange: (next: BotAppForm) => void;
24
+ /** Validation result; only shown once the user has tried to submit. */
25
+ errors: BotIdentityErrors;
26
+ showErrors: boolean;
27
+ /** Edit mode also exposes the welcome and fallback messages and the default agent. */
28
+ mode: 'create' | 'edit';
29
+ agents?: ReadonlyArray<{
30
+ id: string;
31
+ name: string;
32
+ }>;
33
+ }
34
+ export declare const BotFormFields: FC<BotFormFieldsProps>;
35
+ export {};
@@ -0,0 +1,261 @@
1
+ import { useTr as e } from "../../shared/hooks/useTr.js";
2
+ import { FormField as t, Input as n, Textarea as r } from "./Input.js";
3
+ import { BOT_IDENTITY_MESSAGES as i, slugify as a } from "../utils/botIdentity.js";
4
+ import { cn as o } from "../utils/cn.js";
5
+ import { toUnion as s } from "../utils/unions.js";
6
+ import { useRef as c } from "react";
7
+ import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
8
+ // src/botlit/components/BotFormFields.tsx
9
+ var f = [
10
+ "SINGLE",
11
+ "ROUND_ROBIN",
12
+ "INTELLIGENT",
13
+ "CUSTOM"
14
+ ], p = "🤖", m = {
15
+ name: "",
16
+ slug: "",
17
+ description: "",
18
+ icon: p,
19
+ routingStrategy: "SINGLE",
20
+ welcomeMessage: "",
21
+ fallbackMessage: "",
22
+ defaultAgentId: ""
23
+ }, h = [
24
+ {
25
+ icon: "🤖",
26
+ key: "robot",
27
+ label: "Robot"
28
+ },
29
+ {
30
+ icon: "💼",
31
+ key: "briefcase",
32
+ label: "Briefcase"
33
+ },
34
+ {
35
+ icon: "🎧",
36
+ key: "headset",
37
+ label: "Headset"
38
+ },
39
+ {
40
+ icon: "📊",
41
+ key: "chart",
42
+ label: "Chart"
43
+ },
44
+ {
45
+ icon: "🎯",
46
+ key: "target",
47
+ label: "Target"
48
+ },
49
+ {
50
+ icon: "🔧",
51
+ key: "wrench",
52
+ label: "Wrench"
53
+ },
54
+ {
55
+ icon: "📚",
56
+ key: "books",
57
+ label: "Books"
58
+ },
59
+ {
60
+ icon: "💡",
61
+ key: "idea",
62
+ label: "Light bulb"
63
+ },
64
+ {
65
+ icon: "🚀",
66
+ key: "rocket",
67
+ label: "Rocket"
68
+ },
69
+ {
70
+ icon: "⚡",
71
+ key: "lightning",
72
+ label: "Lightning"
73
+ }
74
+ ], g = ({ value: t, onChange: n }) => {
75
+ let r = e(), i = c(null), a = h.some((e) => e.icon === t) ? h : [{
76
+ icon: t,
77
+ key: "current",
78
+ label: "Current icon"
79
+ }, ...h], s = (e, t) => {
80
+ let r = (e + t + a.length) % a.length;
81
+ n(a[r].icon), i.current?.querySelectorAll("[role=\"radio\"]")[r]?.focus();
82
+ };
83
+ return /* @__PURE__ */ u("div", {
84
+ ref: i,
85
+ role: "radiogroup",
86
+ "aria-label": r("botlit.botDetail.form.icon", "Icon"),
87
+ className: "flex flex-wrap gap-2",
88
+ children: a.map((e, i) => {
89
+ let a = e.icon === t;
90
+ return /* @__PURE__ */ u("button", {
91
+ type: "button",
92
+ role: "radio",
93
+ "aria-checked": a,
94
+ "aria-label": r(`botlit.botDetail.form.icons.${e.key}`, e.label),
95
+ tabIndex: a ? 0 : -1,
96
+ onClick: () => n(e.icon),
97
+ onKeyDown: (e) => {
98
+ e.key === "ArrowRight" || e.key === "ArrowDown" ? (e.preventDefault(), s(i, 1)) : (e.key === "ArrowLeft" || e.key === "ArrowUp") && (e.preventDefault(), s(i, -1));
99
+ },
100
+ className: o("rounded-lg border-2 p-3 text-3xl transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary", a ? "border-primary bg-accent" : "border-dashed border-border-subtle hover:border-primary"),
101
+ children: /* @__PURE__ */ u("span", {
102
+ "aria-hidden": "true",
103
+ children: e.icon
104
+ })
105
+ }, e.key);
106
+ })
107
+ });
108
+ }, _ = ({ idPrefix: o, value: c, onChange: p, errors: m, showErrors: h, mode: _, agents: v }) => {
109
+ let y = e(), b = (e) => `${o}-${e}`, x = (e) => e ? y(`botlit.botDetail.form.errors.${e}`, i[e], {
110
+ nameMax: 100,
111
+ slugMax: 64
112
+ }) : void 0, S = h ? x(m.name) : void 0, C = h ? x(m.slug) : void 0, w = c.slug.trim() === "" ? a(c.name) : "", T = (e, t, n) => t ? b(`${e}-error`) : n ? b(`${e}-description`) : void 0;
113
+ return /* @__PURE__ */ d("div", {
114
+ className: "space-y-6",
115
+ children: [
116
+ /* @__PURE__ */ u("div", {
117
+ className: "flex items-start gap-4",
118
+ children: /* @__PURE__ */ u(g, {
119
+ value: c.icon,
120
+ onChange: (e) => p({
121
+ ...c,
122
+ icon: e
123
+ })
124
+ })
125
+ }),
126
+ /* @__PURE__ */ u(t, {
127
+ label: y("botlit.botDetail.form.botName", "Bot Name"),
128
+ required: !0,
129
+ htmlFor: b("name"),
130
+ error: S,
131
+ children: /* @__PURE__ */ u(n, {
132
+ id: b("name"),
133
+ required: !0,
134
+ maxLength: 120,
135
+ "aria-invalid": S ? !0 : void 0,
136
+ "aria-describedby": T("name", S, !1),
137
+ placeholder: y("botlit.botDetail.form.botNamePlaceholder", "e.g., Customer Support Bot"),
138
+ value: c.name,
139
+ onChange: (e) => p({
140
+ ...c,
141
+ name: e.target.value
142
+ })
143
+ })
144
+ }),
145
+ /* @__PURE__ */ u(t, {
146
+ label: y("botlit.botDetail.form.slug", "Slug"),
147
+ htmlFor: b("slug"),
148
+ error: C,
149
+ description: w ? y("botlit.botDetail.form.slugDerived", "Will be saved as \"{{slug}}\".", { slug: w }) : y("botlit.botDetail.form.slugHelp", "Lowercase letters, numbers and hyphens. Left empty, it is made from the name."),
150
+ children: /* @__PURE__ */ u(n, {
151
+ id: b("slug"),
152
+ "aria-invalid": C ? !0 : void 0,
153
+ "aria-describedby": T("slug", C, !0),
154
+ placeholder: y("botlit.botDetail.form.slugPlaceholder", "customer-support-bot"),
155
+ value: c.slug,
156
+ onChange: (e) => p({
157
+ ...c,
158
+ slug: e.target.value
159
+ })
160
+ })
161
+ }),
162
+ /* @__PURE__ */ u(t, {
163
+ label: y("botlit.botDetail.form.description", "Description"),
164
+ htmlFor: b("description"),
165
+ children: /* @__PURE__ */ u(r, {
166
+ id: b("description"),
167
+ placeholder: y("botlit.botDetail.form.descriptionPlaceholder", "Describe what this bot does..."),
168
+ value: c.description,
169
+ onChange: (e) => p({
170
+ ...c,
171
+ description: e.target.value
172
+ }),
173
+ rows: 4
174
+ })
175
+ }),
176
+ /* @__PURE__ */ u(t, {
177
+ label: y("botlit.botDetail.form.routingStrategy", "Routing Strategy"),
178
+ htmlFor: b("routing"),
179
+ children: /* @__PURE__ */ d("select", {
180
+ id: b("routing"),
181
+ className: "flex h-10 w-full rounded-md border border-border-default bg-bg-surface px-3 py-2 text-sm",
182
+ value: c.routingStrategy,
183
+ onChange: (e) => p({
184
+ ...c,
185
+ routingStrategy: s(e.target.value, f, "SINGLE")
186
+ }),
187
+ children: [
188
+ /* @__PURE__ */ u("option", {
189
+ value: "SINGLE",
190
+ children: y("botlit.botDetail.routing.single", "Single")
191
+ }),
192
+ /* @__PURE__ */ u("option", {
193
+ value: "ROUND_ROBIN",
194
+ children: y("botlit.botDetail.routing.roundRobin", "Round Robin")
195
+ }),
196
+ /* @__PURE__ */ u("option", {
197
+ value: "INTELLIGENT",
198
+ children: y("botlit.botDetail.routing.intelligent", "Intelligent")
199
+ }),
200
+ /* @__PURE__ */ u("option", {
201
+ value: "CUSTOM",
202
+ children: y("botlit.botDetail.routing.custom", "Custom")
203
+ })
204
+ ]
205
+ })
206
+ }),
207
+ _ === "edit" && /* @__PURE__ */ d(l, { children: [
208
+ /* @__PURE__ */ u(t, {
209
+ label: y("botlit.botDetail.form.welcomeMessage", "Welcome Message"),
210
+ htmlFor: b("welcome"),
211
+ children: /* @__PURE__ */ u(r, {
212
+ id: b("welcome"),
213
+ placeholder: y("botlit.botDetail.form.welcomeMessagePlaceholder", "Welcome message shown to users..."),
214
+ value: c.welcomeMessage,
215
+ onChange: (e) => p({
216
+ ...c,
217
+ welcomeMessage: e.target.value
218
+ }),
219
+ rows: 3
220
+ })
221
+ }),
222
+ /* @__PURE__ */ u(t, {
223
+ label: y("botlit.botDetail.form.fallbackMessage", "Fallback Message"),
224
+ htmlFor: b("fallback"),
225
+ children: /* @__PURE__ */ u(n, {
226
+ id: b("fallback"),
227
+ placeholder: y("botlit.botDetail.form.fallbackMessagePlaceholder", "Message when agent can't respond..."),
228
+ value: c.fallbackMessage,
229
+ onChange: (e) => p({
230
+ ...c,
231
+ fallbackMessage: e.target.value
232
+ })
233
+ })
234
+ }),
235
+ /* @__PURE__ */ u(t, {
236
+ label: y("botlit.botDetail.form.defaultAgent", "Default Agent"),
237
+ htmlFor: b("default-agent"),
238
+ children: /* @__PURE__ */ d("select", {
239
+ id: b("default-agent"),
240
+ className: "flex h-10 w-full rounded-md border border-border-default bg-bg-surface px-3 py-2 text-sm",
241
+ value: c.defaultAgentId,
242
+ onChange: (e) => p({
243
+ ...c,
244
+ defaultAgentId: e.target.value
245
+ }),
246
+ children: [/* @__PURE__ */ u("option", {
247
+ value: "",
248
+ children: y("botlit.botDetail.form.noDefaultAgent", "No default agent")
249
+ }), v?.map((e) => /* @__PURE__ */ u("option", {
250
+ value: e.id,
251
+ children: e.name
252
+ }, e.id))]
253
+ })
254
+ })
255
+ ] })
256
+ ]
257
+ });
258
+ };
259
+ export { _ as BotFormFields, m as DEFAULT_BOT_FORM, p as DEFAULT_BOT_ICON, f as ROUTING_STRATEGIES };
260
+
261
+ //# sourceMappingURL=BotFormFields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BotFormFields.js","names":["_Fragment","Fragment$1","ROUTING_STRATEGIES","DEFAULT_BOT_ICON","DEFAULT_BOT_FORM","ICON_CHOICES","IconChooser","t","useTr","groupRef","useRef","choices","c","value","move","next","from","delta","onChange","selected","choice","event","index","cn","BotFormFields","id","idPrefix","field","message","key","BOT_IDENTITY_MESSAGES","nameError","showErrors","errors","slugError","derivedSlug","slugify","describedBy","error","hasDescription","FormField","Input","Textarea","toUnion","mode","agents","agent"],"sources":["../../../src/botlit/components/BotFormFields.tsx"],"sourcesContent":["/**\n * Bot form fields\n * @module botlit/components\n *\n * The fields shared by the create and edit bot forms (BOFF-12439, 12440, 12443).\n * One component so validation messages, field ids and accessibility are fixed\n * once: inline errors tied to their inputs with `aria-describedby`, `aria-invalid`\n * and a native `required`, and an icon chooser that is a real radio group\n * (keyboard and screen-reader operable) instead of a button that cycles emojis.\n */\n\nimport type { FC } from 'react';\nimport { useRef } from 'react';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { FormField, Input, Textarea } from './Input';\nimport {\n BOT_IDENTITY_MESSAGES,\n BOT_NAME_MAX_LENGTH,\n BOT_SLUG_MAX_LENGTH,\n slugify,\n type BotIdentityErrors,\n} from '../utils/botIdentity';\nimport { cn } from '../utils/cn';\nimport { toUnion } from '../utils/unions';\n\n/** Routing strategies the bot form offers. */\nexport const ROUTING_STRATEGIES = ['SINGLE', 'ROUND_ROBIN', 'INTELLIGENT', 'CUSTOM'] as const;\nexport type BotRoutingStrategy = (typeof ROUTING_STRATEGIES)[number];\n\n/** Editable subset of a bot app — one field per `UpdateBotAppInput` field. */\nexport interface BotAppForm {\n name: string;\n slug: string;\n description: string;\n icon: string;\n routingStrategy: BotRoutingStrategy;\n welcomeMessage: string;\n fallbackMessage: string;\n defaultAgentId: string;\n}\n\nexport const DEFAULT_BOT_ICON = '\\u{1F916}';\n\nexport const DEFAULT_BOT_FORM: BotAppForm = {\n name: '',\n slug: '',\n description: '',\n icon: DEFAULT_BOT_ICON,\n routingStrategy: 'SINGLE',\n welcomeMessage: '',\n fallbackMessage: '',\n defaultAgentId: '',\n};\n\n/** Icons the chooser offers, with the name a screen reader announces. */\nconst ICON_CHOICES: ReadonlyArray<{ icon: string; key: string; label: string }> = [\n { icon: '🤖', key: 'robot', label: 'Robot' },\n { icon: '💼', key: 'briefcase', label: 'Briefcase' },\n { icon: '🎧', key: 'headset', label: 'Headset' },\n { icon: '📊', key: 'chart', label: 'Chart' },\n { icon: '🎯', key: 'target', label: 'Target' },\n { icon: '🔧', key: 'wrench', label: 'Wrench' },\n { icon: '📚', key: 'books', label: 'Books' },\n { icon: '💡', key: 'idea', label: 'Light bulb' },\n { icon: '🚀', key: 'rocket', label: 'Rocket' },\n { icon: '⚡', key: 'lightning', label: 'Lightning' },\n];\n\ninterface IconChooserProps {\n value: string;\n onChange: (icon: string) => void;\n}\n\nconst IconChooser: FC<IconChooserProps> = ({ value, onChange }) => {\n const t = useTr();\n const groupRef = useRef<HTMLDivElement>(null);\n // A bot may carry an icon the chooser does not list; keep it selectable.\n const choices = ICON_CHOICES.some((c) => c.icon === value)\n ? ICON_CHOICES\n : [{ icon: value, key: 'current', label: 'Current icon' }, ...ICON_CHOICES];\n\n const move = (from: number, delta: number) => {\n const next = (from + delta + choices.length) % choices.length;\n onChange(choices[next].icon);\n groupRef.current?.querySelectorAll<HTMLElement>('[role=\"radio\"]')[next]?.focus();\n };\n\n return (\n <div\n ref={groupRef}\n role=\"radiogroup\"\n aria-label={t('botlit.botDetail.form.icon', 'Icon')}\n className=\"flex flex-wrap gap-2\"\n >\n {choices.map((choice, index) => {\n const selected = choice.icon === value;\n return (\n <button\n key={choice.key}\n type=\"button\"\n role=\"radio\"\n aria-checked={selected}\n aria-label={t(`botlit.botDetail.form.icons.${choice.key}`, choice.label)}\n tabIndex={selected ? 0 : -1}\n onClick={() => onChange(choice.icon)}\n onKeyDown={(event) => {\n if (event.key === 'ArrowRight' || event.key === 'ArrowDown') {\n event.preventDefault();\n move(index, 1);\n } else if (event.key === 'ArrowLeft' || event.key === 'ArrowUp') {\n event.preventDefault();\n move(index, -1);\n }\n }}\n className={cn(\n 'rounded-lg border-2 p-3 text-3xl transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary',\n selected\n ? 'border-primary bg-accent'\n : 'border-dashed border-border-subtle hover:border-primary'\n )}\n >\n <span aria-hidden=\"true\">{choice.icon}</span>\n </button>\n );\n })}\n </div>\n );\n};\n\ninterface BotFormFieldsProps {\n /** Prefix for field ids, so the create and edit forms never collide. */\n idPrefix: string;\n value: BotAppForm;\n onChange: (next: BotAppForm) => void;\n /** Validation result; only shown once the user has tried to submit. */\n errors: BotIdentityErrors;\n showErrors: boolean;\n /** Edit mode also exposes the welcome and fallback messages and the default agent. */\n mode: 'create' | 'edit';\n agents?: ReadonlyArray<{ id: string; name: string }>;\n}\n\nexport const BotFormFields: FC<BotFormFieldsProps> = ({\n idPrefix,\n value,\n onChange,\n errors,\n showErrors,\n mode,\n agents,\n}) => {\n const t = useTr();\n const id = (field: string) => `${idPrefix}-${field}`;\n const message = (key: keyof typeof BOT_IDENTITY_MESSAGES | undefined) =>\n key\n ? t(`botlit.botDetail.form.errors.${key}`, BOT_IDENTITY_MESSAGES[key], {\n nameMax: BOT_NAME_MAX_LENGTH,\n slugMax: BOT_SLUG_MAX_LENGTH,\n })\n : undefined;\n const nameError = showErrors ? message(errors.name) : undefined;\n const slugError = showErrors ? message(errors.slug) : undefined;\n const derivedSlug = value.slug.trim() === '' ? slugify(value.name) : '';\n\n const describedBy = (field: string, error: string | undefined, hasDescription: boolean) =>\n error ? id(`${field}-error`) : hasDescription ? id(`${field}-description`) : undefined;\n\n return (\n <div className=\"space-y-6\">\n <div className=\"flex items-start gap-4\">\n <IconChooser value={value.icon} onChange={(icon) => onChange({ ...value, icon })} />\n </div>\n\n <FormField\n label={t('botlit.botDetail.form.botName', 'Bot Name')}\n required\n htmlFor={id('name')}\n error={nameError}\n >\n <Input\n id={id('name')}\n required\n maxLength={BOT_NAME_MAX_LENGTH + 20}\n aria-invalid={nameError ? true : undefined}\n aria-describedby={describedBy('name', nameError, false)}\n placeholder={t('botlit.botDetail.form.botNamePlaceholder', 'e.g., Customer Support Bot')}\n value={value.name}\n onChange={(e) => onChange({ ...value, name: e.target.value })}\n />\n </FormField>\n\n <FormField\n label={t('botlit.botDetail.form.slug', 'Slug')}\n htmlFor={id('slug')}\n error={slugError}\n description={\n derivedSlug\n ? t('botlit.botDetail.form.slugDerived', 'Will be saved as \"{{slug}}\".', {\n slug: derivedSlug,\n })\n : t(\n 'botlit.botDetail.form.slugHelp',\n 'Lowercase letters, numbers and hyphens. Left empty, it is made from the name.'\n )\n }\n >\n <Input\n id={id('slug')}\n aria-invalid={slugError ? true : undefined}\n aria-describedby={describedBy('slug', slugError, true)}\n placeholder={t('botlit.botDetail.form.slugPlaceholder', 'customer-support-bot')}\n value={value.slug}\n onChange={(e) => onChange({ ...value, slug: e.target.value })}\n />\n </FormField>\n\n <FormField\n label={t('botlit.botDetail.form.description', 'Description')}\n htmlFor={id('description')}\n >\n <Textarea\n id={id('description')}\n placeholder={t(\n 'botlit.botDetail.form.descriptionPlaceholder',\n 'Describe what this bot does...'\n )}\n value={value.description}\n onChange={(e) => onChange({ ...value, description: e.target.value })}\n rows={4}\n />\n </FormField>\n\n <FormField\n label={t('botlit.botDetail.form.routingStrategy', 'Routing Strategy')}\n htmlFor={id('routing')}\n >\n <select\n id={id('routing')}\n className=\"flex h-10 w-full rounded-md border border-border-default bg-bg-surface px-3 py-2 text-sm\"\n value={value.routingStrategy}\n onChange={(e) =>\n onChange({\n ...value,\n routingStrategy: toUnion(e.target.value, ROUTING_STRATEGIES, 'SINGLE'),\n })\n }\n >\n <option value=\"SINGLE\">{t('botlit.botDetail.routing.single', 'Single')}</option>\n <option value=\"ROUND_ROBIN\">\n {t('botlit.botDetail.routing.roundRobin', 'Round Robin')}\n </option>\n <option value=\"INTELLIGENT\">\n {t('botlit.botDetail.routing.intelligent', 'Intelligent')}\n </option>\n <option value=\"CUSTOM\">{t('botlit.botDetail.routing.custom', 'Custom')}</option>\n </select>\n </FormField>\n\n {mode === 'edit' && (\n <>\n <FormField\n label={t('botlit.botDetail.form.welcomeMessage', 'Welcome Message')}\n htmlFor={id('welcome')}\n >\n <Textarea\n id={id('welcome')}\n placeholder={t(\n 'botlit.botDetail.form.welcomeMessagePlaceholder',\n 'Welcome message shown to users...'\n )}\n value={value.welcomeMessage}\n onChange={(e) => onChange({ ...value, welcomeMessage: e.target.value })}\n rows={3}\n />\n </FormField>\n\n <FormField\n label={t('botlit.botDetail.form.fallbackMessage', 'Fallback Message')}\n htmlFor={id('fallback')}\n >\n <Input\n id={id('fallback')}\n placeholder={t(\n 'botlit.botDetail.form.fallbackMessagePlaceholder',\n \"Message when agent can't respond...\"\n )}\n value={value.fallbackMessage}\n onChange={(e) => onChange({ ...value, fallbackMessage: e.target.value })}\n />\n </FormField>\n\n <FormField\n label={t('botlit.botDetail.form.defaultAgent', 'Default Agent')}\n htmlFor={id('default-agent')}\n >\n <select\n id={id('default-agent')}\n className=\"flex h-10 w-full rounded-md border border-border-default bg-bg-surface px-3 py-2 text-sm\"\n value={value.defaultAgentId}\n onChange={(e) => onChange({ ...value, defaultAgentId: e.target.value })}\n >\n <option value=\"\">\n {t('botlit.botDetail.form.noDefaultAgent', 'No default agent')}\n </option>\n {agents?.map((agent) => (\n <option key={agent.id} value={agent.id}>\n {agent.name}\n </option>\n ))}\n </select>\n </FormField>\n </>\n )}\n </div>\n );\n};\n"],"mappings":";;;;;;;;AA0BA,IAAaE,IAAqB;CAAC;CAAU;CAAe;CAAe;AAAQ,GAetEC,IAAmB,MAEnBC,IAA+B;CAC1C,MAAM;CACN,MAAM;CACN,aAAa;CACb,MAAMD;CACN,iBAAiB;CACjB,gBAAgB;CAChB,iBAAiB;CACjB,gBAAgB;AAClB,GAGME,IAA4E;CAChF;EAAE,MAAM;EAAM,KAAK;EAAS,OAAO;CAAQ;CAC3C;EAAE,MAAM;EAAM,KAAK;EAAa,OAAO;CAAY;CACnD;EAAE,MAAM;EAAM,KAAK;EAAW,OAAO;CAAU;CAC/C;EAAE,MAAM;EAAM,KAAK;EAAS,OAAO;CAAQ;CAC3C;EAAE,MAAM;EAAM,KAAK;EAAU,OAAO;CAAS;CAC7C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D,GAFKA,EAAM,EAEX,CACT,CACK;;IACC,CAAA;GACX,EAAA,CAAA;EAED;;AAET"}
@@ -32,6 +32,7 @@ var o = ({ children: t, htmlFor: i, required: a, className: o }) => /* @__PURE__
32
32
  className: e("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70", o),
33
33
  children: [t, a && /* @__PURE__ */ n("span", {
34
34
  className: "text-status-error-text ml-1",
35
+ "aria-hidden": "true",
35
36
  children: "*"
36
37
  })]
37
38
  }), s = ({ label: t, htmlFor: i, required: a, error: s, description: c, children: l, className: u }) => /* @__PURE__ */ r("div", {
@@ -44,10 +45,13 @@ var o = ({ children: t, htmlFor: i, required: a, className: o }) => /* @__PURE__
44
45
  }),
45
46
  l,
46
47
  c && !s && /* @__PURE__ */ n("p", {
48
+ id: i ? `${i}-description` : void 0,
47
49
  className: "text-xs text-text-secondary",
48
50
  children: c
49
51
  }),
50
52
  s && /* @__PURE__ */ n("p", {
53
+ id: i ? `${i}-error` : void 0,
54
+ role: "alert",
51
55
  className: "text-xs text-status-error-text",
52
56
  children: s
53
57
  })
@@ -1 +1 @@
1
- {"version":3,"file":"Input.js","names":["Input","forwardRef","props","cn","error","className","Textarea","Label","children","required","FormField","label","description"],"sources":["../../../src/botlit/components/Input.tsx"],"sourcesContent":["/**\n * Input Components\n * @module botlit/components\n */\n\nimport type { FC, InputHTMLAttributes, TextareaHTMLAttributes } from 'react';\nimport { forwardRef } from 'react';\nimport { cn } from '../utils/cn';\n\ninterface InputProps extends InputHTMLAttributes<HTMLInputElement> {\n error?: string;\n}\n\nexport const Input = forwardRef<HTMLInputElement, InputProps>(\n ({ className, type = 'text', error, ...props }, ref) => {\n return (\n <div className=\"w-full\">\n <input\n type={type}\n className={cn(\n 'flex h-10 w-full rounded-md border border-border-default bg-bg-surface px-3 py-2 text-sm',\n 'ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium',\n 'placeholder:text-text-secondary',\n 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)] focus-visible:ring-offset-2',\n 'disabled:cursor-not-allowed disabled:opacity-50',\n error && 'border-status-error-border focus-visible:ring-destructive',\n className\n )}\n ref={ref}\n {...props}\n />\n {error && <p className=\"mt-1 text-xs text-status-error-text\">{error}</p>}\n </div>\n );\n }\n);\n\nInput.displayName = 'Input';\n\ninterface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {\n error?: string;\n}\n\nexport const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(\n ({ className, error, ...props }, ref) => {\n return (\n <div className=\"w-full\">\n <textarea\n className={cn(\n 'flex min-h-[80px] w-full rounded-md border border-border-default bg-bg-surface px-3 py-2 text-sm',\n 'ring-offset-background placeholder:text-text-secondary',\n 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)] focus-visible:ring-offset-2',\n 'disabled:cursor-not-allowed disabled:opacity-50',\n error && 'border-status-error-border focus-visible:ring-destructive',\n className\n )}\n ref={ref}\n {...props}\n />\n {error && <p className=\"mt-1 text-xs text-status-error-text\">{error}</p>}\n </div>\n );\n }\n);\n\nTextarea.displayName = 'Textarea';\n\ninterface LabelProps {\n children: React.ReactNode;\n htmlFor?: string;\n required?: boolean;\n className?: string;\n}\n\nexport const Label: FC<LabelProps> = ({ children, htmlFor, required, className }) => {\n return (\n <label\n htmlFor={htmlFor}\n className={cn(\n 'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70',\n className\n )}\n >\n {children}\n {required && <span className=\"text-status-error-text ml-1\">*</span>}\n </label>\n );\n};\n\ninterface FormFieldProps {\n label: string;\n htmlFor?: string;\n required?: boolean;\n error?: string;\n description?: string;\n children: React.ReactNode;\n className?: string;\n}\n\nexport const FormField: FC<FormFieldProps> = ({\n label,\n htmlFor,\n required,\n error,\n description,\n children,\n className,\n}) => {\n return (\n <div className={cn('space-y-2', className)}>\n <Label htmlFor={htmlFor} required={required}>\n {label}\n </Label>\n {children}\n {description && !error && <p className=\"text-xs text-text-secondary\">{description}</p>}\n {error && <p className=\"text-xs text-status-error-text\">{error}</p>}\n </div>\n );\n};\n"],"mappings":";;;;AAaA,IAAaA,IAAQC,GAClB,EAAE,cAAW,UAAO,QAAQ,UAAO,GAAGC,KAAS,MAE5C,kBAAC,OAAD;CAAK,WAAU;CAAf,UAAA,CACE,kBAAC,SAAD;EACQ;EACN,WAAWC,EACT,4FACA,0FACA,mCACA,4HACA,mDACAC,KAAS,6DACTC,CACF;EACK;EACL,GAAIH;CACL,CAAA,GACAE,KAAS,kBAAC,KAAD;EAAG,WAAU;EAAuC,UAAAA;CAAS,CAAA,CACpE;A,EAGX;AAEA,EAAM,cAAc;AAMpB,IAAaE,IAAWL,GACrB,EAAE,cAAW,UAAO,GAAGC,KAAS,MAE7B,kBAAC,OAAD;CAAK,WAAU;CAAf,UAAA,CACE,kBAAC,YAAD;EACE,WAAWC,EACT,oGACA,0DACA,4HACA,mDACAC,KAAS,6DACTC,CACF;EACK;EACL,GAAIH;CACL,CAAA,GACAE,KAAS,kBAAC,KAAD;EAAG,WAAU;EAAuC,UAAAA;CAAS,CAAA,CACpE;A,EAGX;AAEA,EAAS,cAAc;AASvB,IAAaG,KAAyB,EAAE,aAAU,YAAS,aAAU,mBAEjE,kBAAC,SAAD;CACW;CACT,WAAWJ,EACT,8FACAE,CACF;CALF,UAAA,CAOGG,GACAC,KAAY,kBAAC,QAAD;EAAM,WAAU;EAA8B,UAAA;CAAO,CAAA,CAC7D;A,IAcEC,KAAiC,EAC5C,UACA,YACA,aACA,UACA,gBACA,aACA,mBAGE,kBAAC,OAAD;CAAK,WAAWP,EAAG,aAAaE,CAAS;CAAzC,UAAA;EACE,kBAACE,GAAD;GAAgB;GAAmB;GAChC,UAAAI;EACI,CAAA;EACNH;EACAI,KAAe,CAACR,KAAS,kBAAC,KAAD;GAAG,WAAU;GAA+B,UAAAQ;EAAe,CAAA;EACpFR,KAAS,kBAAC,KAAD;GAAG,WAAU;GAAkC,UAAAA;EAAS,CAAA;CAC/D"}
1
+ {"version":3,"file":"Input.js","names":["Input","forwardRef","props","cn","error","className","Textarea","Label","children","required","FormField","label","description","htmlFor"],"sources":["../../../src/botlit/components/Input.tsx"],"sourcesContent":["/**\n * Input Components\n * @module botlit/components\n */\n\nimport type { FC, InputHTMLAttributes, TextareaHTMLAttributes } from 'react';\nimport { forwardRef } from 'react';\nimport { cn } from '../utils/cn';\n\ninterface InputProps extends InputHTMLAttributes<HTMLInputElement> {\n error?: string;\n}\n\nexport const Input = forwardRef<HTMLInputElement, InputProps>(\n ({ className, type = 'text', error, ...props }, ref) => {\n return (\n <div className=\"w-full\">\n <input\n type={type}\n className={cn(\n 'flex h-10 w-full rounded-md border border-border-default bg-bg-surface px-3 py-2 text-sm',\n 'ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium',\n 'placeholder:text-text-secondary',\n 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)] focus-visible:ring-offset-2',\n 'disabled:cursor-not-allowed disabled:opacity-50',\n error && 'border-status-error-border focus-visible:ring-destructive',\n className\n )}\n ref={ref}\n {...props}\n />\n {error && <p className=\"mt-1 text-xs text-status-error-text\">{error}</p>}\n </div>\n );\n }\n);\n\nInput.displayName = 'Input';\n\ninterface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {\n error?: string;\n}\n\nexport const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(\n ({ className, error, ...props }, ref) => {\n return (\n <div className=\"w-full\">\n <textarea\n className={cn(\n 'flex min-h-[80px] w-full rounded-md border border-border-default bg-bg-surface px-3 py-2 text-sm',\n 'ring-offset-background placeholder:text-text-secondary',\n 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)] focus-visible:ring-offset-2',\n 'disabled:cursor-not-allowed disabled:opacity-50',\n error && 'border-status-error-border focus-visible:ring-destructive',\n className\n )}\n ref={ref}\n {...props}\n />\n {error && <p className=\"mt-1 text-xs text-status-error-text\">{error}</p>}\n </div>\n );\n }\n);\n\nTextarea.displayName = 'Textarea';\n\ninterface LabelProps {\n children: React.ReactNode;\n htmlFor?: string;\n required?: boolean;\n className?: string;\n}\n\nexport const Label: FC<LabelProps> = ({ children, htmlFor, required, className }) => {\n return (\n <label\n htmlFor={htmlFor}\n className={cn(\n 'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70',\n className\n )}\n >\n {children}\n {required && (\n <span className=\"text-status-error-text ml-1\" aria-hidden=\"true\">\n *\n </span>\n )}\n </label>\n );\n};\n\ninterface FormFieldProps {\n label: string;\n htmlFor?: string;\n required?: boolean;\n error?: string;\n description?: string;\n children: React.ReactNode;\n className?: string;\n}\n\nexport const FormField: FC<FormFieldProps> = ({\n label,\n htmlFor,\n required,\n error,\n description,\n children,\n className,\n}) => {\n return (\n <div className={cn('space-y-2', className)}>\n <Label htmlFor={htmlFor} required={required}>\n {label}\n </Label>\n {children}\n {description && !error && (\n <p\n id={htmlFor ? `${htmlFor}-description` : undefined}\n className=\"text-xs text-text-secondary\"\n >\n {description}\n </p>\n )}\n {error && (\n <p\n id={htmlFor ? `${htmlFor}-error` : undefined}\n role=\"alert\"\n className=\"text-xs text-status-error-text\"\n >\n {error}\n </p>\n )}\n </div>\n );\n};\n"],"mappings":";;;;AAaA,IAAaA,IAAQC,GAClB,EAAE,cAAW,UAAO,QAAQ,UAAO,GAAGC,KAAS,MAE5C,kBAAC,OAAD;CAAK,WAAU;CAAf,UAAA,CACE,kBAAC,SAAD;EACQ;EACN,WAAWC,EACT,4FACA,0FACA,mCACA,4HACA,mDACAC,KAAS,6DACTC,CACF;EACK;EACL,GAAIH;CACL,CAAA,GACAE,KAAS,kBAAC,KAAD;EAAG,WAAU;EAAuC,UAAAA;CAAS,CAAA,CACpE;A,EAGX;AAEA,EAAM,cAAc;AAMpB,IAAaE,IAAWL,GACrB,EAAE,cAAW,UAAO,GAAGC,KAAS,MAE7B,kBAAC,OAAD;CAAK,WAAU;CAAf,UAAA,CACE,kBAAC,YAAD;EACE,WAAWC,EACT,oGACA,0DACA,4HACA,mDACAC,KAAS,6DACTC,CACF;EACK;EACL,GAAIH;CACL,CAAA,GACAE,KAAS,kBAAC,KAAD;EAAG,WAAU;EAAuC,UAAAA;CAAS,CAAA,CACpE;A,EAGX;AAEA,EAAS,cAAc;AASvB,IAAaG,KAAyB,EAAE,aAAU,YAAS,aAAU,mBAEjE,kBAAC,SAAD;CACW;CACT,WAAWJ,EACT,8FACAE,CACF;CALF,UAAA,CAOGG,GACAC,KACC,kBAAC,QAAD;EAAM,WAAU;EAA8B,eAAY;EAAO,UAAA;CAE3D,CAAA,CAEH;A,IAcEC,KAAiC,EAC5C,UACA,YACA,aACA,UACA,gBACA,aACA,mBAGE,kBAAC,OAAD;CAAK,WAAWP,EAAG,aAAaE,CAAS;CAAzC,UAAA;EACE,kBAACE,GAAD;GAAgB;GAAmB;GAChC,UAAAI;EACI,CAAA;EACNH;EACAI,KAAe,CAACR,KACf,kBAAC,KAAD;GACE,IAAIS,IAAU,GAAGA,EAAQ,gBAAgB,KAAA;GACzC,WAAU;GAET,UAAAD;EACA,CAAA;EAEJR,KACC,kBAAC,KAAD;GACE,IAAIS,IAAU,GAAGA,EAAQ,UAAU,KAAA;GACnC,MAAK;GACL,WAAU;GAET,UAAAT;EACA,CAAA;CAEF"}
@@ -9,6 +9,7 @@ export { Input, Textarea, Label, FormField } from './Input';
9
9
  export { Badge, StatusBadge } from './Badge';
10
10
  export { EmptyState } from './EmptyState';
11
11
  export { ErrorState } from './ErrorState';
12
+ export { ActionMenu } from './ActionMenu';
12
13
  export { ChannelSelectorSheet } from './ChannelSelectorSheet';
13
14
  export { RouteLoader, type RouteLoaderProps } from './RouteLoader';
14
15
  export { WorkspaceRequired, type WorkspaceRequiredProps } from './WorkspaceRequired';
@@ -179,10 +179,11 @@ function w(e) {
179
179
  query: f,
180
180
  variables: { id: e },
181
181
  fetchPolicy: "network-only"
182
- });
182
+ }), i = n.error;
183
+ if (i != null) throw i instanceof Error ? i : /* @__PURE__ */ Error("Failed to load bot");
183
184
  r(n.data?.getBotApp ?? null);
184
185
  } catch (e) {
185
- d(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load bot"));
186
+ r(null), d(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load bot"));
186
187
  } finally {
187
188
  s(!1);
188
189
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useBots.js","names":["LIST_BOT_APPS_DOCUMENT","GET_BOT_APP_DOCUMENT","CREATE_BOT_APP_DOCUMENT","UPDATE_BOT_APP_DOCUMENT","DELETE_BOT_APP_DOCUMENT","LIST_PAGE_SIZE","NO_BOTS","UPDATE_BOT_APP_FIELDS","fieldsOf","getWorkspaceClient","client","buildBotFilter","workspaceId","filter","useBots","useBotlit","variables","useMemo","useWorkspacePaginatedQuery","data","rows","GET_BOT_APP_COUNTS_DOCUMENT","useBotAppCounts","useWorkspaceQuery","enabled","useBot","useGatewayClient","setData","useState","loading","setLoading","error","setError","refetch","useCallback","botId","result","queryError","useEffect","useCreateBot","state","setState","createdBot","mutationError","useUpdateBot","updatedBot","buildMutationInput","input","useDeleteBot","deleted"],"sources":["../../../src/botlit/hooks/useBots.ts"],"sourcesContent":["import { gql, type ApolloClient } from '@apollo/client';\nimport { useCallback, useEffect, useMemo, useState } from 'react';\nimport { useGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\n\nimport type { UpdateBotAppInput } from '../../generated/wspace-types';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport type { BaseFilter } from '../types';\nimport { buildMutationInput, fieldsOf, type GraphQLInput } from './internal/mutationInput';\nimport {\n useWorkspacePaginatedQuery,\n useWorkspaceQuery,\n type PaginatedQueryResult,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nconst LIST_BOT_APPS_DOCUMENT = gql`\n query ListBotApps($filters: BotAppFilterInput, $pagination: PaginationInput) {\n listBotApps(filters: $filters, pagination: $pagination) {\n id\n name\n slug\n description\n icon\n type\n status\n visibility\n routingStrategy\n defaultAgentId\n welcomeMessage\n fallbackMessage\n workflowId\n executionCount\n lastExecutedAt\n tagIds\n createdAt\n updatedAt\n createdById\n updatedById\n workspaceId\n }\n }\n`;\n\nconst GET_BOT_APP_DOCUMENT = gql`\n query GetBotApp($id: ID!) {\n getBotApp(id: $id) {\n id\n name\n slug\n description\n icon\n type\n status\n visibility\n routingStrategy\n defaultAgentId\n welcomeMessage\n fallbackMessage\n workflowId\n executionCount\n lastExecutedAt\n tagIds\n createdAt\n updatedAt\n createdById\n updatedById\n workspaceId\n }\n }\n`;\n\nconst CREATE_BOT_APP_DOCUMENT = gql`\n mutation CreateBotApp($input: CreateBotAppInput!) {\n createBotApp(input: $input) {\n id\n name\n slug\n description\n icon\n type\n status\n visibility\n routingStrategy\n defaultAgentId\n workflowId\n tagIds\n createdAt\n updatedAt\n workspaceId\n }\n }\n`;\n\nconst UPDATE_BOT_APP_DOCUMENT = gql`\n mutation UpdateBotApp($id: ID!, $input: UpdateBotAppInput!) {\n updateBotApp(id: $id, input: $input) {\n id\n name\n slug\n description\n icon\n type\n status\n visibility\n routingStrategy\n defaultAgentId\n welcomeMessage\n fallbackMessage\n workflowId\n tagIds\n updatedAt\n updatedById\n workspaceId\n }\n }\n`;\n\nconst DELETE_BOT_APP_DOCUMENT = gql`\n mutation DeleteBotApp($id: ID!) {\n deleteBotApp(id: $id)\n }\n`;\n\ntype WorkspaceClient = ApolloClient;\n\nexport interface BotAppRecord {\n id: string;\n name: string;\n slug: string;\n description?: string | null;\n icon?: string | null;\n type: string;\n status: string;\n visibility?: string | null;\n routingStrategy?: string | null;\n defaultAgentId?: string | null;\n welcomeMessage?: string | null;\n fallbackMessage?: string | null;\n /** Bound FluidGrids workflow definition id — the bot's designed behaviour. */\n workflowId?: string | null;\n executionCount?: number | null;\n lastExecutedAt?: string | null;\n tagIds?: string[] | null;\n createdAt?: string | null;\n updatedAt?: string | null;\n createdById?: string | null;\n updatedById?: string | null;\n workspaceId?: string | null;\n}\n\ninterface ListBotAppsData {\n listBotApps: BotAppRecord[];\n}\n\nconst LIST_PAGE_SIZE = 100;\nconst NO_BOTS: BotAppRecord[] = [];\n\ninterface GetBotAppData {\n getBotApp: BotAppRecord | null;\n}\n\ninterface CreateBotAppData {\n createBotApp: BotAppRecord;\n}\n\ninterface UpdateBotAppData {\n updateBotApp: BotAppRecord;\n}\n\ninterface DeleteBotAppData {\n deleteBotApp: boolean;\n}\n\ninterface BotMutationState<T> {\n data: T | undefined;\n loading: boolean;\n error: Error | undefined;\n}\n\ninterface CreateBotInput {\n workspaceId: string;\n name: string;\n slug?: string;\n type: string;\n routingStrategy?: string;\n description?: string;\n icon?: string;\n}\n\ninterface UpdateBotInput {\n botId: string;\n input: GraphQLInput<UpdateBotAppInput>;\n}\n\nconst UPDATE_BOT_APP_FIELDS = fieldsOf<UpdateBotAppInput>({\n bucketId: true,\n context: true,\n defaultAgentId: true,\n description: true,\n fallbackMessage: true,\n icon: true,\n metadata: true,\n name: true,\n routingStrategy: true,\n slug: true,\n status: true,\n tagIds: true,\n tags: true,\n type: true,\n visibility: true,\n welcomeMessage: true,\n workflowId: true,\n});\n\nfunction getWorkspaceClient(client: unknown): WorkspaceClient {\n return client as WorkspaceClient;\n}\n\nfunction buildBotFilter(\n workspaceId: string | undefined,\n filter?: BaseFilter\n): Record<string, unknown> | undefined {\n if (!workspaceId && !filter) return undefined;\n\n return {\n workspaceId,\n search: filter?.search,\n status: filter?.status?.[0],\n visibility: filter?.visibility?.[0],\n bucketId: filter?.bucketId,\n };\n}\n\nexport const botKeys = {\n all: ['bots'] as const,\n lists: () => [...botKeys.all, 'list'] as const,\n list: (filter?: BaseFilter) => [...botKeys.lists(), filter] as const,\n details: () => [...botKeys.all, 'detail'] as const,\n detail: (id: string) => [...botKeys.details(), id] as const,\n};\n\nexport function useBots(filter?: BaseFilter): PaginatedQueryResult<BotAppRecord[]> {\n const { workspaceId } = useBotlit();\n\n const variables = useMemo(\n () => ({ filters: buildBotFilter(workspaceId, filter) }),\n [filter, workspaceId]\n );\n\n return useWorkspacePaginatedQuery<ListBotAppsData, BotAppRecord, BotAppRecord[]>({\n document: LIST_BOT_APPS_DOCUMENT,\n variables,\n pageSize: LIST_PAGE_SIZE,\n extractRows: (data) => data?.listBotApps ?? [],\n select: (rows) => rows,\n fallback: NO_BOTS,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load bots',\n });\n}\n\n/**\n * Exact bot counts by status for the workspace (BOFF-12426). Unlike `useBots`\n * this is not capped at one page, so it is the source for dashboard totals.\n * `total` counts every status; the dashboard shows `total - archived`.\n */\nexport interface BotAppCounts {\n total: number;\n draft: number;\n active: number;\n paused: number;\n archived: number;\n}\n\ninterface BotAppCountsData {\n getBotAppCounts?: BotAppCounts | null;\n}\n\nconst GET_BOT_APP_COUNTS_DOCUMENT = gql`\n query GetBotAppCounts {\n getBotAppCounts {\n total\n draft\n active\n paused\n archived\n }\n }\n`;\n\nexport function useBotAppCounts(enabled = true): QueryResult<BotAppCounts | null> {\n const { workspaceId } = useBotlit();\n const variables = useMemo(() => ({}), []);\n\n return useWorkspaceQuery<BotAppCountsData, BotAppCounts | null>({\n document: GET_BOT_APP_COUNTS_DOCUMENT,\n variables,\n select: (data) => data?.getBotAppCounts ?? null,\n fallback: null,\n enabled: enabled && Boolean(workspaceId),\n errorMessage: 'Failed to load bot counts',\n });\n}\n\nexport function useBot(botId: string | undefined) {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [data, setData] = useState<BotAppRecord | null>(null);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | undefined>();\n\n const refetch = useCallback(async () => {\n if (!botId) {\n setData(null);\n return;\n }\n\n setLoading(true);\n setError(undefined);\n try {\n const result = await client.query<GetBotAppData>({\n query: GET_BOT_APP_DOCUMENT,\n variables: { id: botId },\n fetchPolicy: 'network-only',\n });\n setData(result.data?.getBotApp ?? null);\n } catch (queryError) {\n setError(queryError instanceof Error ? queryError : new Error('Failed to load bot'));\n } finally {\n setLoading(false);\n }\n }, [botId, client]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n return { data, loading, error, refetch };\n}\n\nexport function useCreateBot() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [state, setState] = useState<BotMutationState<BotAppRecord>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const createBot = useCallback(\n async (input: CreateBotInput) => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<CreateBotAppData>({\n mutation: CREATE_BOT_APP_DOCUMENT,\n variables: { input },\n });\n\n const createdBot = result.data?.createBotApp;\n if (!createdBot) {\n throw new Error('Failed to create bot');\n }\n\n setState({ data: createdBot, loading: false, error: undefined });\n return createdBot;\n } catch (mutationError) {\n const error =\n mutationError instanceof Error ? mutationError : new Error('Failed to create bot');\n setState({ data: undefined, loading: false, error });\n throw error;\n }\n },\n [client]\n );\n\n return [createBot, state] as const;\n}\n\nexport function useUpdateBot() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [state, setState] = useState<BotMutationState<BotAppRecord>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const updateBot = useCallback(\n async ({ botId, input }: UpdateBotInput) => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<UpdateBotAppData>({\n mutation: UPDATE_BOT_APP_DOCUMENT,\n variables: { id: botId, input: buildMutationInput(input, UPDATE_BOT_APP_FIELDS) },\n });\n\n const updatedBot = result.data?.updateBotApp;\n if (!updatedBot) {\n throw new Error('Failed to update bot');\n }\n\n setState({ data: updatedBot, loading: false, error: undefined });\n return updatedBot;\n } catch (mutationError) {\n const error =\n mutationError instanceof Error ? mutationError : new Error('Failed to update bot');\n setState({ data: undefined, loading: false, error });\n throw error;\n }\n },\n [client]\n );\n\n return [updateBot, state] as const;\n}\n\nexport function useDeleteBot() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [state, setState] = useState<BotMutationState<boolean>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const deleteBot = useCallback(\n async (botId: string) => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<DeleteBotAppData>({\n mutation: DELETE_BOT_APP_DOCUMENT,\n variables: { id: botId },\n });\n\n const deleted = result.data?.deleteBotApp ?? false;\n setState({ data: deleted, loading: false, error: undefined });\n return deleted;\n } catch (mutationError) {\n const error =\n mutationError instanceof Error ? mutationError : new Error('Failed to delete bot');\n setState({ data: undefined, loading: false, error });\n throw error;\n }\n },\n [client]\n );\n\n return [deleteBot, state] as const;\n}\n"],"mappings":";;;;;;;AAeA,IAAMA,IAAyB,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;GA4B5BC,IAAuB,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;GA4B1BC,IAA0B,CAAG;;;;;;;;;;;;;;;;;;;;GAsB7BC,IAA0B,CAAG;;;;;;;;;;;;;;;;;;;;;;GAwB7BC,IAA0B,CAAG;;;;GAqC7BC,IAAiB,KACjBC,IAA0B,CAAC,GAuC3BC,IAAwBC,EAA4B;CACxD,UAAU;CACV,SAAS;CACT,gBAAgB;CAChB,aAAa;CACb,iBAAiB;CACjB,MAAM;CACN,UAAU;CACV,MAAM;CACN,iBAAiB;CACjB,MAAM;CACN,QAAQ;CACR,QAAQ;CACR,MAAM;CACN,MAAM;CACN,YAAY;CACZ,gBAAgB;CAChB,YAAY;AACd,CAAC;AAED,SAASC,EAAmB,GAAkC;CAC5D,OAAOC;AACT;AAEA,SAASC,EACP,GACA,GACqC;CACrC,IAAKC,KAAgBC,GAErB,OAAO;EACL;EACA,QAAQA,GAAQ;EAChB,QAAQA,GAAQ,SAAS;EACzB,YAAYA,GAAQ,aAAa;EACjC,UAAUA,GAAQ;CACpB;AACF;AAUA,SAAgBC,EAAQ,GAA2D;CACjF,IAAM,EAAE,mBAAgBC,EAAU,GAE5BC,IAAYC,SACT,EAAE,SAASN,EAAeC,GAAaC,CAAM,EAAE,IACtD,C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;IAAE,MAAMI;IAAY,SAAS;IAAO,OAAO,KAAA;GAAU,CAAC,GACxDA;EACT,SAASF,GAAe;GACtB,IAAMZ,IACJY,aAAyB,QAAQA,IAAgB,gBAAI,MAAM,sBAAsB;GAEnF,MADAF,EAAS;IAAE,MAAM,KAAA;IAAW,SAAS;IAAO;GAAM,CAAC,GAC7CV;EACR;CACF,GACA,CAACrB,CAAM,CAGD,GAAW8B,CAAK;AAC1B;AAEA,SAAgBQ,IAAe;CAC7B,IAAMtC,IAASD,EAAmBiB,EAAiB,WAAW,CAAC,GACzD,CAACc,GAAOC,KAAYb,EAAoC;EAC5D,MAAM,KAAA;EACN,SAAS;EACT,OAAO,KAAA;CACT,CAAC;CAwBD,OAAO,CAtBWM,EAChB,OAAO,MAAkB;EACvB,EAAS;GAAE,MAAM,KAAA;GAAW,SAAS;GAAM,OAAO,KAAA;EAAU,CAAC;EAC7D,IAAI;GAMF,IAAMe,KAAU,MALKvC,EAAO,OAAyB;IACnD,UAAUN;IACV,WAAW,EAAE,IAAI+B,EAAM;GACzB,CAAC,EAAA,CAEsB,MAAM,gBAAgB;GAE7C,OADAM,EAAS;IAAE,MAAMQ;IAAS,SAAS;IAAO,OAAO,KAAA;GAAU,CAAC,GACrDA;EACT,SAASN,GAAe;GACtB,IAAMZ,IACJY,aAAyB,QAAQA,IAAgB,gBAAI,MAAM,sBAAsB;GAEnF,MADAF,EAAS;IAAE,MAAM,KAAA;IAAW,SAAS;IAAO;GAAM,CAAC,GAC7CV;EACR;CACF,GACA,CAACrB,CAAM,CAGD,GAAW8B,CAAK;AAC1B"}
1
+ {"version":3,"file":"useBots.js","names":["LIST_BOT_APPS_DOCUMENT","GET_BOT_APP_DOCUMENT","CREATE_BOT_APP_DOCUMENT","UPDATE_BOT_APP_DOCUMENT","DELETE_BOT_APP_DOCUMENT","LIST_PAGE_SIZE","NO_BOTS","UPDATE_BOT_APP_FIELDS","fieldsOf","getWorkspaceClient","client","buildBotFilter","workspaceId","filter","useBots","useBotlit","variables","useMemo","useWorkspacePaginatedQuery","data","rows","GET_BOT_APP_COUNTS_DOCUMENT","useBotAppCounts","useWorkspaceQuery","enabled","useBot","useGatewayClient","setData","useState","loading","setLoading","error","setError","refetch","useCallback","botId","result","operationError","queryError","useEffect","useCreateBot","state","setState","createdBot","mutationError","useUpdateBot","updatedBot","buildMutationInput","input","useDeleteBot","deleted"],"sources":["../../../src/botlit/hooks/useBots.ts"],"sourcesContent":["import { gql, type ApolloClient } from '@apollo/client';\nimport { useCallback, useEffect, useMemo, useState } from 'react';\nimport { useGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\n\nimport type { UpdateBotAppInput } from '../../generated/wspace-types';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport type { BaseFilter } from '../types';\nimport { buildMutationInput, fieldsOf, type GraphQLInput } from './internal/mutationInput';\nimport {\n useWorkspacePaginatedQuery,\n useWorkspaceQuery,\n type PaginatedQueryResult,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nconst LIST_BOT_APPS_DOCUMENT = gql`\n query ListBotApps($filters: BotAppFilterInput, $pagination: PaginationInput) {\n listBotApps(filters: $filters, pagination: $pagination) {\n id\n name\n slug\n description\n icon\n type\n status\n visibility\n routingStrategy\n defaultAgentId\n welcomeMessage\n fallbackMessage\n workflowId\n executionCount\n lastExecutedAt\n tagIds\n createdAt\n updatedAt\n createdById\n updatedById\n workspaceId\n }\n }\n`;\n\nconst GET_BOT_APP_DOCUMENT = gql`\n query GetBotApp($id: ID!) {\n getBotApp(id: $id) {\n id\n name\n slug\n description\n icon\n type\n status\n visibility\n routingStrategy\n defaultAgentId\n welcomeMessage\n fallbackMessage\n workflowId\n executionCount\n lastExecutedAt\n tagIds\n createdAt\n updatedAt\n createdById\n updatedById\n workspaceId\n }\n }\n`;\n\nconst CREATE_BOT_APP_DOCUMENT = gql`\n mutation CreateBotApp($input: CreateBotAppInput!) {\n createBotApp(input: $input) {\n id\n name\n slug\n description\n icon\n type\n status\n visibility\n routingStrategy\n defaultAgentId\n workflowId\n tagIds\n createdAt\n updatedAt\n workspaceId\n }\n }\n`;\n\nconst UPDATE_BOT_APP_DOCUMENT = gql`\n mutation UpdateBotApp($id: ID!, $input: UpdateBotAppInput!) {\n updateBotApp(id: $id, input: $input) {\n id\n name\n slug\n description\n icon\n type\n status\n visibility\n routingStrategy\n defaultAgentId\n welcomeMessage\n fallbackMessage\n workflowId\n tagIds\n updatedAt\n updatedById\n workspaceId\n }\n }\n`;\n\nconst DELETE_BOT_APP_DOCUMENT = gql`\n mutation DeleteBotApp($id: ID!) {\n deleteBotApp(id: $id)\n }\n`;\n\ntype WorkspaceClient = ApolloClient;\n\nexport interface BotAppRecord {\n id: string;\n name: string;\n slug: string;\n description?: string | null;\n icon?: string | null;\n type: string;\n status: string;\n visibility?: string | null;\n routingStrategy?: string | null;\n defaultAgentId?: string | null;\n welcomeMessage?: string | null;\n fallbackMessage?: string | null;\n /** Bound FluidGrids workflow definition id — the bot's designed behaviour. */\n workflowId?: string | null;\n executionCount?: number | null;\n lastExecutedAt?: string | null;\n tagIds?: string[] | null;\n createdAt?: string | null;\n updatedAt?: string | null;\n createdById?: string | null;\n updatedById?: string | null;\n workspaceId?: string | null;\n}\n\ninterface ListBotAppsData {\n listBotApps: BotAppRecord[];\n}\n\nconst LIST_PAGE_SIZE = 100;\nconst NO_BOTS: BotAppRecord[] = [];\n\ninterface GetBotAppData {\n getBotApp: BotAppRecord | null;\n}\n\ninterface CreateBotAppData {\n createBotApp: BotAppRecord;\n}\n\ninterface UpdateBotAppData {\n updateBotApp: BotAppRecord;\n}\n\ninterface DeleteBotAppData {\n deleteBotApp: boolean;\n}\n\ninterface BotMutationState<T> {\n data: T | undefined;\n loading: boolean;\n error: Error | undefined;\n}\n\ninterface CreateBotInput {\n workspaceId: string;\n name: string;\n slug?: string;\n type: string;\n routingStrategy?: string;\n description?: string;\n icon?: string;\n}\n\ninterface UpdateBotInput {\n botId: string;\n input: GraphQLInput<UpdateBotAppInput>;\n}\n\nconst UPDATE_BOT_APP_FIELDS = fieldsOf<UpdateBotAppInput>({\n bucketId: true,\n context: true,\n defaultAgentId: true,\n description: true,\n fallbackMessage: true,\n icon: true,\n metadata: true,\n name: true,\n routingStrategy: true,\n slug: true,\n status: true,\n tagIds: true,\n tags: true,\n type: true,\n visibility: true,\n welcomeMessage: true,\n workflowId: true,\n});\n\nfunction getWorkspaceClient(client: unknown): WorkspaceClient {\n return client as WorkspaceClient;\n}\n\nfunction buildBotFilter(\n workspaceId: string | undefined,\n filter?: BaseFilter\n): Record<string, unknown> | undefined {\n if (!workspaceId && !filter) return undefined;\n\n return {\n workspaceId,\n search: filter?.search,\n status: filter?.status?.[0],\n visibility: filter?.visibility?.[0],\n bucketId: filter?.bucketId,\n };\n}\n\nexport const botKeys = {\n all: ['bots'] as const,\n lists: () => [...botKeys.all, 'list'] as const,\n list: (filter?: BaseFilter) => [...botKeys.lists(), filter] as const,\n details: () => [...botKeys.all, 'detail'] as const,\n detail: (id: string) => [...botKeys.details(), id] as const,\n};\n\nexport function useBots(filter?: BaseFilter): PaginatedQueryResult<BotAppRecord[]> {\n const { workspaceId } = useBotlit();\n\n const variables = useMemo(\n () => ({ filters: buildBotFilter(workspaceId, filter) }),\n [filter, workspaceId]\n );\n\n return useWorkspacePaginatedQuery<ListBotAppsData, BotAppRecord, BotAppRecord[]>({\n document: LIST_BOT_APPS_DOCUMENT,\n variables,\n pageSize: LIST_PAGE_SIZE,\n extractRows: (data) => data?.listBotApps ?? [],\n select: (rows) => rows,\n fallback: NO_BOTS,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load bots',\n });\n}\n\n/**\n * Exact bot counts by status for the workspace (BOFF-12426). Unlike `useBots`\n * this is not capped at one page, so it is the source for dashboard totals.\n * `total` counts every status; the dashboard shows `total - archived`.\n */\nexport interface BotAppCounts {\n total: number;\n draft: number;\n active: number;\n paused: number;\n archived: number;\n}\n\ninterface BotAppCountsData {\n getBotAppCounts?: BotAppCounts | null;\n}\n\nconst GET_BOT_APP_COUNTS_DOCUMENT = gql`\n query GetBotAppCounts {\n getBotAppCounts {\n total\n draft\n active\n paused\n archived\n }\n }\n`;\n\nexport function useBotAppCounts(enabled = true): QueryResult<BotAppCounts | null> {\n const { workspaceId } = useBotlit();\n const variables = useMemo(() => ({}), []);\n\n return useWorkspaceQuery<BotAppCountsData, BotAppCounts | null>({\n document: GET_BOT_APP_COUNTS_DOCUMENT,\n variables,\n select: (data) => data?.getBotAppCounts ?? null,\n fallback: null,\n enabled: enabled && Boolean(workspaceId),\n errorMessage: 'Failed to load bot counts',\n });\n}\n\nexport function useBot(botId: string | undefined) {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [data, setData] = useState<BotAppRecord | null>(null);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | undefined>();\n\n const refetch = useCallback(async () => {\n if (!botId) {\n setData(null);\n return;\n }\n\n setLoading(true);\n setError(undefined);\n try {\n const result = await client.query<GetBotAppData>({\n query: GET_BOT_APP_DOCUMENT,\n variables: { id: botId },\n fetchPolicy: 'network-only',\n });\n // Apollo v4 resolves (not rejects) with `result.error` set on GraphQL errors.\n // Without this a FORBIDDEN read looked like \"bot not found\" (BOFF-12436).\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) {\n throw operationError instanceof Error ? operationError : new Error('Failed to load bot');\n }\n setData(result.data?.getBotApp ?? null);\n } catch (queryError) {\n setData(null);\n setError(queryError instanceof Error ? queryError : new Error('Failed to load bot'));\n } finally {\n setLoading(false);\n }\n }, [botId, client]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n return { data, loading, error, refetch };\n}\n\nexport function useCreateBot() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [state, setState] = useState<BotMutationState<BotAppRecord>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const createBot = useCallback(\n async (input: CreateBotInput) => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<CreateBotAppData>({\n mutation: CREATE_BOT_APP_DOCUMENT,\n variables: { input },\n });\n\n const createdBot = result.data?.createBotApp;\n if (!createdBot) {\n throw new Error('Failed to create bot');\n }\n\n setState({ data: createdBot, loading: false, error: undefined });\n return createdBot;\n } catch (mutationError) {\n const error =\n mutationError instanceof Error ? mutationError : new Error('Failed to create bot');\n setState({ data: undefined, loading: false, error });\n throw error;\n }\n },\n [client]\n );\n\n return [createBot, state] as const;\n}\n\nexport function useUpdateBot() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [state, setState] = useState<BotMutationState<BotAppRecord>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const updateBot = useCallback(\n async ({ botId, input }: UpdateBotInput) => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<UpdateBotAppData>({\n mutation: UPDATE_BOT_APP_DOCUMENT,\n variables: { id: botId, input: buildMutationInput(input, UPDATE_BOT_APP_FIELDS) },\n });\n\n const updatedBot = result.data?.updateBotApp;\n if (!updatedBot) {\n throw new Error('Failed to update bot');\n }\n\n setState({ data: updatedBot, loading: false, error: undefined });\n return updatedBot;\n } catch (mutationError) {\n const error =\n mutationError instanceof Error ? mutationError : new Error('Failed to update bot');\n setState({ data: undefined, loading: false, error });\n throw error;\n }\n },\n [client]\n );\n\n return [updateBot, state] as const;\n}\n\nexport function useDeleteBot() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [state, setState] = useState<BotMutationState<boolean>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const deleteBot = useCallback(\n async (botId: string) => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<DeleteBotAppData>({\n mutation: DELETE_BOT_APP_DOCUMENT,\n variables: { id: botId },\n });\n\n const deleted = result.data?.deleteBotApp ?? false;\n setState({ data: deleted, loading: false, error: undefined });\n return deleted;\n } catch (mutationError) {\n const error =\n mutationError instanceof Error ? mutationError : new Error('Failed to delete bot');\n setState({ data: undefined, loading: false, error });\n throw error;\n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