@mcp-use/inspector 20.0.0-beta.6 → 20.0.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/{AnimatePresence-Dcw-FOy8.js → AnimatePresence-D1bZ5_-l.js} +79 -78
- package/dist/cdn/{ChatTab-D6J3Gyp7.js → ChatTab-DtUGK07C.js} +1951 -1932
- package/dist/cdn/CheckboxIndicator-BjF73mGX.js +252 -0
- package/dist/cdn/{ConnectionSettingsForm-CWQueI8J.js → ConnectionSettingsForm-CNuMa6jp.js} +202 -202
- package/dist/cdn/{ConnectionSettingsTab-FGyt3QaI.js → ConnectionSettingsTab-qSVQ1aIF.js} +36 -35
- package/dist/cdn/{ElicitationTab-CL1KJ0bz.js → ElicitationTab-PEmEDvC5.js} +47 -46
- package/dist/cdn/{FormContext-tmgN_Vdr.js → FormContext-NtUiZclE.js} +26 -26
- package/dist/cdn/{InspectorContext-UjtEbNod.js → InspectorContext-BBKCdfmK.js} +1 -1
- package/dist/cdn/{JSONDisplay-BFxf5oEu.js → JSONDisplay-BJqMz7Ny.js} +22 -22
- package/dist/cdn/{ListTabHeader-Cv-GmtGF.js → ListTabHeader-DzmTtN1e.js} +20 -19
- package/dist/cdn/{WidgetWrapper-CruwjBOd.js → MCPAppsDebugControls-BpP-Ifap.js} +514 -550
- package/dist/cdn/{ManufactOAuthCallback-B98kSYCj.js → ManufactOAuthCallback-ChbbjFIT.js} +2 -2
- package/dist/cdn/{MarkdownRenderer-gLqUICEd.js → MarkdownRenderer-bX1BrKgI.js} +23 -23
- package/dist/cdn/McpAppsViewPanel-jlsYQ7uS.js +56 -0
- package/dist/cdn/{NotificationsTab-CeImSrhx.js → NotificationsTab-B7uebqMV.js} +21 -21
- package/dist/cdn/{OAuthCallback-Bg2bP-o9.js → OAuthCallback--NZdLoWx.js} +3 -3
- package/dist/cdn/PromptsTab-BlXDcau3.js +902 -0
- package/dist/cdn/{ResourcesTab-CQkKni-P.js → ResourcesTab-D45_JojP.js} +116 -114
- package/dist/cdn/{SamplingTab-D8q-iCMc.js → SamplingTab-r7tImM6L.js} +34 -33
- package/dist/cdn/{ServerMetadataTab-CvrKX8fz.js → ServerMetadataTab-BM3VhSLf.js} +9 -9
- package/dist/cdn/{StatusIcon-D0-ARyOh.js → StatusIcon-Q3n3YRtE.js} +10 -11
- package/dist/cdn/{ToolsTab-6xaVH43x.js → ToolsTab-DOAO8HnS.js} +664 -652
- package/dist/cdn/{ViewPreview-Ohh6JwOn.js → ViewPreview-CBhrVdwx.js} +3 -3
- package/dist/cdn/{WidgetDebugContext-D4usL_MA.js → WidgetDebugContext-B6yoOVVV.js} +1 -11
- package/dist/cdn/WidgetWrapper-BlbQAh_X.js +12 -0
- package/dist/cdn/{bell-CGjAO_0s.js → bell-GrTZcnD2.js} +1 -1
- package/dist/cdn/{browser-CbQIH4w2.js → browser-DG2Z8392.js} +1 -1
- package/dist/cdn/{brush-B_mKhyxG.js → brush-CelVvMGp.js} +1 -1
- package/dist/cdn/button-CB4uOoUV.js +2509 -0
- package/dist/cdn/card-BA-DQk-G.js +41 -0
- package/dist/cdn/{checkbox-By0FklhG.js → checkbox-kwVa4gRX.js} +7 -7
- package/dist/cdn/{clock-CmUbSx_B.js → clock-YMF8Gtw5.js} +1 -1
- package/dist/cdn/{code-V_0nf5rg.js → code-C8sN2OGR.js} +1 -1
- package/dist/cdn/{jsx-runtime-CIxvMpEo.js → createLucideIcon-BONxC1L5.js} +57 -24
- package/dist/cdn/{dialog-BsDpuJd3.js → dialog-CJGnC5Ag.js} +171 -171
- package/dist/cdn/{dist-DaMB0Su9.js → dist-CTJnCYmk.js} +1 -1
- package/dist/cdn/{dist-CXHFvGre.js → dist-SxRsB1iS.js} +3 -3
- package/dist/cdn/{external-link-CjmfT6rW.js → external-link-Bo4lQxr1.js} +1 -1
- package/dist/cdn/{eye-B7H96av8.js → eye-pSGG7nvf.js} +1 -1
- package/dist/cdn/{folder-open-B3lu2rG_.js → folder-open-aM8CPtBO.js} +1 -1
- package/dist/cdn/{hash-BVQnWi7q.js → hash-DDs2vE1k.js} +1 -1
- package/dist/cdn/{history-Csw4rb44.js → history-BfUFpL1d.js} +1 -1
- package/dist/cdn/{index-browser-DkQOzkvX.js → index-browser-Dm3R1Mfe.js} +1 -1
- package/dist/cdn/{info-CNiOwqkf.js → info-BMkB68mB.js} +1 -1
- package/dist/cdn/{input-C2OBd4PJ.js → input-BCpgLXU1.js} +2993 -5499
- package/dist/cdn/inspector.css +1 -1
- package/dist/cdn/inspector.js +7106 -7140
- package/dist/cdn/{label-B9Jmm9be.js → label-A0UGV8FE.js} +9 -9
- package/dist/cdn/{loader-circle-BLy9A_pp.js → loader-circle-BKRHJEB7.js} +1 -1
- package/dist/cdn/{maximize-2-CH5Lq90B.js → maximize-2-DdrB_spi.js} +1 -1
- package/dist/cdn/{maximize-BALCV_ep.js → maximize-hSOCz133.js} +1 -1
- package/dist/cdn/{message-square-BnxdpJxZ.js → message-square-D3tKB3uJ.js} +1 -1
- package/dist/cdn/{not-found-DEtSM_Wd.js → not-found-BajFyZpp.js} +9 -11
- package/dist/cdn/{play-vuZ5PLnI.js → play-B1leulYf.js} +1 -1
- package/dist/cdn/providerMeta-CjGU4rID.js +436 -0
- package/dist/cdn/{react-BLtCruam.js → react-Bl-hSkvn.js} +562 -512
- package/dist/cdn/{refresh-cw-BXY-Pa0U.js → refresh-cw-CyvXrS91.js} +1 -1
- package/dist/cdn/{save-Tgil_AJZ.js → save-CmdEPUAm.js} +1 -1
- package/dist/cdn/{select-DDdiIPR2.js → select-CCFHjOGk.js} +808 -807
- package/dist/cdn/{servers-Dm72iTpY.js → servers-Dd0Vcp81.js} +5 -1
- package/dist/cdn/{shared-DaILIQPP.js → shared-CJVHJhag.js} +36 -36
- package/dist/cdn/{sheet-Br_l2kry.js → sheet-oyq1mIyg.js} +620 -619
- package/dist/cdn/{sparkles-BntO2rDR.js → sparkles-CxeZpVtX.js} +1 -1
- package/dist/cdn/spinner-Be1GlSGX.js +15 -0
- package/dist/cdn/{square-check-big-BvwQ17Bl.js → square-check-big-C_4wbfwF.js} +1 -1
- package/dist/cdn/{switch-C3IyQuid.js → switch-DHXEA_N5.js} +190 -189
- package/dist/cdn/{tabs-subtle-CkdI6Mac.js → tabs-subtle-Dubd6Kj8.js} +269 -268
- package/dist/cdn/{telemetry-C7Ytz2BG.js → telemetry-TwPKZlFf.js} +2 -2
- package/dist/cdn/{textarea-DSbwcFVt.js → textarea-CwmI8_uI.js} +6 -6
- package/dist/cdn/{trash-2-RwpJY5SL.js → trash-2-BhumJAFE.js} +1 -1
- package/dist/cdn/{useAriaLabelledBy-DqAdnppm.js → useAriaLabelledBy-Cra6w3YY.js} +2 -1
- package/dist/cdn/{useCompositeItem-BRqEzYh-.js → useCompositeItem-Dhnm-7el.js} +3 -3
- package/dist/cdn/{useConfig-BW6uQf2m.js → useConfig-leHVjdjl.js} +2 -2
- package/dist/cdn/{useSavedRequests-Ci2I919u.js → useSavedRequests-mSIsDd4c.js} +1 -1
- package/dist/cdn/{useViewHostProps-CINeSkth.js → useViewHostProps-CDOm2w6u.js} +124 -109
- package/dist/cdn/{wrench-DzGmCfnb.js → wrench-DvK20LUT.js} +1 -1
- package/dist/cdn/{x-C3vRQIYu.js → x-EilKPiCX.js} +1 -1
- package/dist/cdn/{zap-Mb-pbw2X.js → zap-0Wr9QO7N.js} +1 -1
- package/dist/cli.js +1 -1
- package/dist/client/components/ChatTab.d.ts.map +1 -1
- package/dist/client/components/MCPAppsDebugControls.d.ts.map +1 -1
- package/dist/client/components/ToolsTab.d.ts.map +1 -1
- package/dist/client/components/chat/ConfigurationDialog.d.ts.map +1 -1
- package/dist/client/components/chat/ToolResultRenderer.d.ts.map +1 -1
- package/dist/client/components/mcp-apps/McpAppsViewPanel.d.ts +29 -0
- package/dist/client/components/mcp-apps/McpAppsViewPanel.d.ts.map +1 -0
- package/dist/client/components/tools/ToolExecutionPanel.d.ts.map +1 -1
- package/dist/client/components/tools/ToolResultDisplay.d.ts +2 -1
- package/dist/client/components/tools/ToolResultDisplay.d.ts.map +1 -1
- package/dist/client/components/tools/useToolsTabNavigation.d.ts.map +1 -1
- package/dist/client/components/ui/MeshGradientCanvas.d.ts.map +1 -1
- package/dist/client/components/ui/mesh-animation-pause.d.ts +14 -0
- package/dist/client/components/ui/mesh-animation-pause.d.ts.map +1 -0
- package/dist/client/components/ui/mesh-gradient-colors.d.ts +6 -0
- package/dist/client/components/ui/mesh-gradient-colors.d.ts.map +1 -0
- package/dist/client/components/ui/mesh-tab-background.d.ts +1 -1
- package/dist/client/components/ui/mesh-tab-background.d.ts.map +1 -1
- package/dist/client/components/ui/not-found.d.ts.map +1 -1
- package/dist/client/context/WidgetDebugContext.d.ts +1 -11
- package/dist/client/context/WidgetDebugContext.d.ts.map +1 -1
- package/dist/client/hooks/useDeviceViewport.d.ts +1 -5
- package/dist/client/hooks/useDeviceViewport.d.ts.map +1 -1
- package/dist/client/hooks/useViewHostProps.d.ts +1 -1
- package/dist/client/hooks/useViewHostProps.d.ts.map +1 -1
- package/dist/client/index.js +2086 -1860
- package/dist/client/utils/servers.d.ts +5 -0
- package/dist/client/utils/servers.d.ts.map +1 -1
- package/dist/server/cdn-shell.js +2 -2
- package/dist/server/{chunk-GBY4WAVP.js → chunk-5GVQGIAX.js} +1 -1
- package/dist/server/{chunk-IFF5T5J4.js → chunk-UZZDBVKF.js} +1 -1
- package/dist/server/{chunk-NUHI6MJ6.js → chunk-VFVFLXKP.js} +1 -1
- package/dist/server/cli.js +2 -2
- package/dist/server/index.js +3 -3
- package/dist/server/middleware.js +3 -3
- package/dist/server/version.js +1 -1
- package/dist/web/assets/AnimatePresence-FfDQQNFJ.js +9 -0
- package/dist/web/assets/ChatTab-B6ubLbeA.js +18 -0
- package/dist/web/assets/ConnectionSettingsTab-Cb2eDgEu.js +1 -0
- package/dist/web/assets/ElicitationTab-CbnCrmu9.js +1 -0
- package/dist/web/assets/FormContext-sV-yByKz.js +1 -0
- package/dist/web/assets/ListTabHeader-CrGae306.js +1 -0
- package/dist/web/assets/MCPAppsDebugControls-sRglMhat.js +34 -0
- package/dist/web/assets/{ManufactOAuthCallback-BRO6TPkZ.js → ManufactOAuthCallback-D4uYGigW.js} +1 -1
- package/dist/web/assets/{MarkdownRenderer-gaJFjbtr.js → MarkdownRenderer-Cwxp9fLj.js} +2 -2
- package/dist/web/assets/McpAppsViewPanel-jQYFoZNX.js +1 -0
- package/dist/web/assets/{NotificationsTab-LYcfRjyd.js → NotificationsTab-DuSm762_.js} +1 -1
- package/dist/web/assets/{OAuthCallback-D8UItgTB.js → OAuthCallback-VLHlUe2c.js} +1 -1
- package/dist/web/assets/PromptsTab-DK6XZxR8.js +15 -0
- package/dist/web/assets/ResourcesTab-CUE4MAtJ.js +2 -0
- package/dist/web/assets/SamplingTab-BYNkVCTu.js +1 -0
- package/dist/web/assets/ServerMetadataTab-DWjNFMbq.js +1 -0
- package/dist/web/assets/ToolsTab-BisWWY2p.js +8 -0
- package/dist/web/assets/{ViewPreview--z6jL0Zg.js → ViewPreview-COrmPpRr.js} +1 -1
- package/dist/web/assets/WidgetWrapper-cv_BM1bY.js +1 -0
- package/dist/web/assets/{brush--0LobUi4.js → brush-DX0UZ_pI.js} +1 -1
- package/dist/web/assets/button-C8Xa2k4x.js +1 -0
- package/dist/web/assets/checkbox-B6dtF73d.js +1 -0
- package/dist/web/assets/code-B14rVdNt.js +1 -0
- package/dist/web/assets/createLucideIcon-BEHeJH0M.js +1 -0
- package/dist/web/assets/{dist-B8sA8Zml.js → dist-9Oy7e0v8.js} +4 -4
- package/dist/web/assets/index-BMaSsizY.js +499 -0
- package/dist/web/assets/index-D7TVTIt9.css +1 -0
- package/dist/web/assets/input-C0OQCUZy.js +1 -0
- package/dist/web/assets/{label-Cdim77Jw.js → label-CI7JWQOo.js} +1 -1
- package/dist/web/assets/{maximize-2-BTT9QQU9.js → maximize-2-Br1WQzT2.js} +1 -1
- package/dist/web/assets/{maximize-_O55kFcr.js → maximize-CJNgRe6S.js} +1 -1
- package/dist/web/assets/{refresh-cw-C9wQl8_d.js → refresh-cw-B5iaAZKn.js} +1 -1
- package/dist/web/assets/{save-B-MsgxX9.js → save-TM6fvNrt.js} +1 -1
- package/dist/web/assets/select-D6jzbLJn.js +1 -0
- package/dist/web/assets/shared-CFs9CZfB.js +1 -0
- package/dist/web/assets/{sparkles-2OAsc1aP.js → sparkles-BGYTDThM.js} +1 -1
- package/dist/web/assets/tabs-subtle-D2XkWhLL.js +1 -0
- package/dist/web/assets/textarea-CRTXuRmE.js +1 -0
- package/dist/web/assets/{useConfig-BAsKhUxf.js → useConfig-B6tXvJOb.js} +1 -1
- package/dist/web/assets/useViewHostProps-DZqOwiAm.js +1 -0
- package/dist/web/assets/{zap-Du2Uc5pa.js → zap-BDWHCVHU.js} +1 -1
- package/dist/web/index.html +10 -10
- package/package.json +4 -4
- package/dist/cdn/CheckboxIndicator-Bt4IICtv.js +0 -251
- package/dist/cdn/PromptsTab-C4LuwyWN.js +0 -901
- package/dist/cdn/card-DgiYnSg-.js +0 -41
- package/dist/cdn/createLucideIcon-C5fZZ6oB.js +0 -38
- package/dist/cdn/providerMeta-BQIfHuNL.js +0 -379
- package/dist/cdn/spinner-jQtC7EBj.js +0 -15
- package/dist/web/assets/AnimatePresence-C5p0yiY1.js +0 -9
- package/dist/web/assets/ChatTab-CsBPVCSc.js +0 -18
- package/dist/web/assets/ConnectionSettingsTab-DQTXfnl1.js +0 -1
- package/dist/web/assets/ElicitationTab-_FKB7nNG.js +0 -1
- package/dist/web/assets/FormContext-DH2caWKO.js +0 -1
- package/dist/web/assets/ListTabHeader-R17w_JsB.js +0 -1
- package/dist/web/assets/PromptsTab-B2uVMRR2.js +0 -15
- package/dist/web/assets/ResourcesTab-DhOZYPjE.js +0 -2
- package/dist/web/assets/SamplingTab-C-oY2hoi.js +0 -1
- package/dist/web/assets/ServerMetadataTab-BkTxO5KS.js +0 -1
- package/dist/web/assets/ToolsTab-DupHgo7A.js +0 -8
- package/dist/web/assets/WidgetWrapper-CZaEVEw4.js +0 -34
- package/dist/web/assets/checkbox-BQ9mI_6k.js +0 -1
- package/dist/web/assets/code-tME-5H6D.js +0 -1
- package/dist/web/assets/createLucideIcon-B3b8EU0b.js +0 -1
- package/dist/web/assets/index-C_fCIJ4C.js +0 -492
- package/dist/web/assets/index-fBX3akc8.css +0 -1
- package/dist/web/assets/input-CLYhA7PK.js +0 -1
- package/dist/web/assets/jsx-runtime-Cjj9sGSy.js +0 -1
- package/dist/web/assets/select-CJ57-Bor.js +0 -1
- package/dist/web/assets/shared-CCC9rTz4.js +0 -1
- package/dist/web/assets/tabs-subtle-246ABJqx.js +0 -1
- package/dist/web/assets/textarea-DLAmNVf_.js +0 -1
- package/dist/web/assets/useViewHostProps-CV5zBxUb.js +0 -1
|
@@ -6,9 +6,14 @@ interface ServerNameLike {
|
|
|
6
6
|
serverInfo?: {
|
|
7
7
|
title?: string;
|
|
8
8
|
name?: string;
|
|
9
|
+
icon?: string;
|
|
10
|
+
icons?: Array<{
|
|
11
|
+
src: string;
|
|
12
|
+
}>;
|
|
9
13
|
} | null;
|
|
10
14
|
}
|
|
11
15
|
export declare function getConfiguredServerAlias(server: ServerNameLike): string;
|
|
12
16
|
export declare function getServerDisplayName(server: ServerNameLike): string;
|
|
17
|
+
export declare function getServerIconUrl(server: ServerNameLike): string | null;
|
|
13
18
|
export {};
|
|
14
19
|
//# sourceMappingURL=servers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"servers.d.ts","sourceRoot":"","sources":["../../../src/client/utils/servers.ts"],"names":[],"mappings":"AAGA,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAa/D;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAM5D;AAED,UAAU,cAAc;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE;QACX,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"servers.d.ts","sourceRoot":"","sources":["../../../src/client/utils/servers.ts"],"names":[],"mappings":"AAGA,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAa/D;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAM5D;AAED,UAAU,cAAc;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE;QACX,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,KAAK,CAAC;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KAChC,GAAG,IAAI,CAAC;CACV;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CASvE;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CASnE;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,GAAG,IAAI,CAKtE"}
|
package/dist/server/cdn-shell.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
registerInspectorCdnShell
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-UZZDBVKF.js";
|
|
4
4
|
import "./chunk-M5TZA42I.js";
|
|
5
|
-
import "./chunk-
|
|
5
|
+
import "./chunk-5GVQGIAX.js";
|
|
6
6
|
import "./chunk-H6ZCIKBS.js";
|
|
7
7
|
import "./chunk-J4FNYLBF.js";
|
|
8
8
|
import "./chunk-WFT4JHYI.js";
|
package/dist/server/cli.js
CHANGED
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
} from "./chunk-KD7K27XK.js";
|
|
6
6
|
import {
|
|
7
7
|
registerInspectorCdnShell
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-UZZDBVKF.js";
|
|
9
9
|
import "./chunk-M5TZA42I.js";
|
|
10
10
|
import {
|
|
11
11
|
getInspectorVersion
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-5GVQGIAX.js";
|
|
13
13
|
import "./chunk-H6ZCIKBS.js";
|
|
14
14
|
import {
|
|
15
15
|
registerInspectorProxyRoutes
|
package/dist/server/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
mountInspector
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-VFVFLXKP.js";
|
|
4
4
|
import {
|
|
5
5
|
registerInspectorCdnShell
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-UZZDBVKF.js";
|
|
7
7
|
import "./chunk-M5TZA42I.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-5GVQGIAX.js";
|
|
9
9
|
import "./chunk-H6ZCIKBS.js";
|
|
10
10
|
import {
|
|
11
11
|
registerInspectorProxyRoutes
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
mountInspector
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-VFVFLXKP.js";
|
|
4
|
+
import "./chunk-UZZDBVKF.js";
|
|
5
5
|
import "./chunk-M5TZA42I.js";
|
|
6
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-5GVQGIAX.js";
|
|
7
7
|
import "./chunk-H6ZCIKBS.js";
|
|
8
8
|
import "./chunk-UJLXHNQP.js";
|
|
9
9
|
import "./chunk-IKTZUWSX.js";
|
package/dist/server/version.js
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{s as e,t}from"./react-CU_d2d5K.js";import{C as n,H as r,U as i,V as a,W as o,m as s,p as c}from"./input-C0OQCUZy.js";import{n as l}from"./createLucideIcon-BEHeJH0M.js";import{_ as u,g as d,j as f,v as p}from"./button-C8Xa2k4x.js";var m=e(t(),1),h=m.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function g(){return m.useContext(h)}var _=function(e){return e[e.None=0]=`None`,e[e.GuessFromOrder=1]=`GuessFromOrder`,e}({});function v(e={}){let{label:t,metadata:n,textRef:r,indexGuessBehavior:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,elementsRef:l,labelsRef:u,nextIndexRef:f}=g(),p=m.useRef(-1),[h,v]=m.useState(a??(i===_.GuessFromOrder?()=>{if(p.current===-1){let e=f.current;f.current+=1,p.current=e}return p.current}:-1)),y=m.useRef(null),b=m.useCallback(e=>{if(y.current=e,h!==-1&&e!==null&&(l.current[h]=e,u)){let n=t!==void 0;u.current[h]=n?t:r?.current?.textContent??e.textContent}},[h,l,u,t,r]);return d(()=>{if(a!=null)return;let e=y.current;if(e)return o(e,n),()=>{s(e)}},[a,o,s,n]),d(()=>{if(a==null)return c(e=>{let t=y.current?e.get(y.current)?.index:null;t!=null&&v(t)})},[a,c,v]),{ref:b,index:h}}var y=`ArrowUp`,b=`ArrowDown`,x=`ArrowLeft`,S=`ArrowRight`,C=`Home`,w=new Set([x,S]),T=new Set([x,S,C,`End`]),E=new Set([y,b]),D=new Set([y,b,C,`End`]),O=new Set([...w,...E]),k=new Set([...O,C,`End`]),A=`Shift`,j=new Set([A,`Control`,`Alt`,`Meta`]);function M(e){return f(e)&&e.tagName===`INPUT`}function N(e){return!!(M(e)&&e.selectionStart!=null||f(e)&&e.tagName===`TEXTAREA`)}function P(e,t,n,r){if(!e||!t||!t.scrollTo)return;let i=e.scrollLeft,a=e.scrollTop,o=e.clientWidth<e.scrollWidth,s=e.clientHeight<e.scrollHeight;if(o&&r!==`vertical`){let r=F(e,t,`left`),a=I(e),o=I(t);n===`ltr`&&(r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight?i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight:r-o.scrollMarginLeft<e.scrollLeft+a.scrollPaddingLeft&&(i=r-o.scrollMarginLeft-a.scrollPaddingLeft)),n===`rtl`&&(r-o.scrollMarginRight<e.scrollLeft+a.scrollPaddingLeft?i=r-o.scrollMarginLeft-a.scrollPaddingLeft:r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight&&(i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight))}if(s&&r!==`horizontal`){let n=F(e,t,`top`),r=I(e),i=I(t);n-i.scrollMarginTop<e.scrollTop+r.scrollPaddingTop?a=n-i.scrollMarginTop-r.scrollPaddingTop:n+t.offsetHeight+i.scrollMarginBottom>e.scrollTop+e.clientHeight-r.scrollPaddingBottom&&(a=n+t.offsetHeight+i.scrollMarginBottom-e.clientHeight+r.scrollPaddingBottom)}e.scrollTo({left:i,top:a,behavior:`auto`})}function F(e,t,n){let r=n===`left`?`offsetLeft`:`offsetTop`,i=0;for(;t.offsetParent&&(i+=t[r],t.offsetParent!==e);)t=t.offsetParent;return i}function I(e){let t=getComputedStyle(e);return{scrollMarginTop:parseFloat(t.scrollMarginTop)||0,scrollMarginRight:parseFloat(t.scrollMarginRight)||0,scrollMarginBottom:parseFloat(t.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(t.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(t.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(t.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(t.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(t.scrollPaddingLeft)||0}}var L=l();function R(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=u(i),o=m.useRef(0),s=p(B).current,c=p(z).current,[l,f]=m.useState(0),g=m.useRef(l),_=u((e,t)=>{c.set(e,t??null),g.current+=1,f(g.current)}),v=u(e=>{c.delete(e),g.current+=1,f(g.current)}),y=m.useMemo(()=>{let e=new Map;return Array.from(c.keys()).filter(e=>e.isConnected).sort(V).forEach((t,n)=>{let r=c.get(t)??{};e.set(t,{...r,index:n})}),e},[c,l]);d(()=>{if(typeof MutationObserver!=`function`||y.size===0)return;let e=new MutationObserver(e=>{let t=new Set,n=e=>t.has(e)?t.delete(e):t.add(e);e.forEach(e=>{e.removedNodes.forEach(n),e.addedNodes.forEach(n)}),t.size===0&&(g.current+=1,f(g.current))});return y.forEach((t,n)=>{n.parentElement&&e.observe(n.parentElement,{childList:!0})}),()=>{e.disconnect()}},[y]),d(()=>{g.current===l&&(n.current.length!==y.size&&(n.current.length=y.size),r&&r.current.length!==y.size&&(r.current.length=y.size),o.current=y.size),a(y)},[a,y,n,r,l]),d(()=>()=>{n.current=[]},[n]),d(()=>()=>{r&&(r.current=[])},[r]);let b=u(e=>(s.add(e),()=>{s.delete(e)}));d(()=>{s.forEach(e=>e(y))},[s,y]);let x=m.useMemo(()=>({register:_,unregister:v,subscribeMapChange:b,elementsRef:n,labelsRef:r,nextIndexRef:o}),[_,v,b,n,r,o]);return(0,L.jsx)(h.Provider,{value:x,children:t})}function z(){return new Map}function B(){return new Set}function V(e,t){let n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}function H(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}function U(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function W(...e){return t=>{let n=!1,r=e.map(e=>{let r=U(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():U(e[t],null)}}}}function G(...e){return m.useCallback(W(...e),e)}var K=class extends m.Component{getSnapshotBeforeUpdate(e){let t=this.props.childRef.current;if(n(t)&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){let e=t.offsetParent,r=n(e)&&e.offsetWidth||0,i=n(e)&&e.offsetHeight||0,a=getComputedStyle(t),o=this.props.sizeRef.current;o.height=parseFloat(a.height),o.width=parseFloat(a.width),o.top=t.offsetTop,o.left=t.offsetLeft,o.right=r-o.width-o.left,o.bottom=i-o.height-o.top,o.direction=a.direction}return null}componentDidUpdate(){}render(){return this.props.children}};function q({children:e,isPresent:t,anchorX:n,anchorY:r,root:i,pop:a}){let o=(0,m.useId)(),c=(0,m.useRef)(null),l=(0,m.useRef)({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:`ltr`}),{nonce:u}=(0,m.useContext)(s),d=G(c,e.props?.ref??e?.ref);return(0,m.useInsertionEffect)(()=>{let{width:e,height:s,top:d,left:f,right:p,bottom:m,direction:h}=l.current;if(t||a===!1||!c.current||!e||!s)return;let g=h===`rtl`,_=n===`left`?g?`right: ${p}`:`left: ${f}`:g?`left: ${f}`:`right: ${p}`,v=r===`bottom`?`bottom: ${m}`:`top: ${d}`;c.current.dataset.motionPopId=o;let y=document.createElement(`style`);u&&(y.nonce=u);let b=i??document.head;return b.appendChild(y),y.sheet&&y.sheet.insertRule(`
|
|
2
|
+
[data-motion-pop-id="${o}"] {
|
|
3
|
+
position: absolute !important;
|
|
4
|
+
width: ${e}px !important;
|
|
5
|
+
height: ${s}px !important;
|
|
6
|
+
${_}px !important;
|
|
7
|
+
${v}px !important;
|
|
8
|
+
}
|
|
9
|
+
`),()=>{c.current?.removeAttribute(`data-motion-pop-id`),b.contains(y)&&b.removeChild(y)}},[t]),(0,L.jsx)(K,{isPresent:t,childRef:c,sizeRef:l,pop:a,children:a===!1?e:m.cloneElement(e,{ref:d})})}var J=({children:e,initial:t,isPresent:n,onExitComplete:o,custom:s,presenceAffectsLayout:c,mode:l,anchorX:u,anchorY:d,root:f})=>{let p=i(Y),h=(0,m.useId)(),g=(0,m.useRef)(n),_=(0,m.useRef)(o);r(()=>{g.current=n,_.current=o});let v=!0,y=(0,m.useMemo)(()=>(v=!1,{id:h,initial:t,isPresent:n,custom:s,onExitComplete:e=>{p.set(e,!0);for(let e of p.values())if(!e)return;o&&o()},register:e=>(p.set(e,!1),()=>{p.delete(e),!g.current&&!p.size&&_.current?.()})}),[n,p,o]);return c&&v&&(y={...y}),(0,m.useMemo)(()=>{p.forEach((e,t)=>p.set(t,!1))},[n]),m.useEffect(()=>{!n&&!p.size&&o&&o()},[n]),e=(0,L.jsx)(q,{pop:l===`popLayout`,isPresent:n,anchorX:u,anchorY:d,root:f,children:e}),(0,L.jsx)(a.Provider,{value:y,children:e})};function Y(){return new Map}var X=e=>e.key||``;function Z(e){let t=[];return m.Children.forEach(e,e=>{(0,m.isValidElement)(e)&&t.push(e)}),t}var Q=({children:e,custom:t,initial:n=!0,onExitComplete:a,presenceAffectsLayout:s=!0,mode:l=`sync`,propagate:u=!1,anchorX:d=`left`,anchorY:f=`top`,root:p})=>{let[h,g]=c(u),_=(0,m.useMemo)(()=>Z(e),[e]),v=u&&!h?[]:_.map(X),y=(0,m.useRef)(!0),b=(0,m.useRef)(_),x=i(()=>new Map),S=(0,m.useRef)(new Set),[C,w]=(0,m.useState)(_),[T,E]=(0,m.useState)(_);r(()=>{y.current=!1,b.current=_;for(let e=0;e<T.length;e++){let t=X(T[e]);v.includes(t)?(x.delete(t),S.current.delete(t)):x.get(t)!==!0&&x.set(t,!1)}},[T,v.length,v.join(`-`)]);let D=[];if(_!==C){let e=[..._];for(let t=0;t<T.length;t++){let n=T[t],r=X(n);v.includes(r)||(e.splice(t,0,n),D.push(n))}return l===`wait`&&D.length&&(e=D),E(Z(e)),w(_),null}let{forceRender:O}=(0,m.useContext)(o);return(0,L.jsx)(L.Fragment,{children:T.map(e=>{let r=X(e),i=u&&!h?!1:_===T||v.includes(r);return(0,L.jsx)(J,{isPresent:i,initial:!y.current||n?void 0:!1,custom:t,presenceAffectsLayout:s,mode:l,root:p,onExitComplete:i?void 0:()=>{if(S.current.has(r))return;if(x.has(r))S.current.add(r),x.set(r,!0);else return;let e=!0;x.forEach(t=>{t||(e=!1)}),e&&(O?.(),E(b.current),u&&g?.(),a&&a())},anchorX:d,anchorY:f,children:e},r)})})};export{N as _,O as a,v as b,y as c,w as d,T as f,D as g,E as h,b as i,k as l,A as m,H as n,x as o,j as p,R as r,S as s,Q as t,C as u,P as v,_ as y};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import{s as e,t}from"./react-CU_d2d5K.js";import{En as n,G as r,Mn as i,Nn as a,Tn as o,Yn as s,a as c,an as l,c as u,d,f,in as p,kn as m,mn as h,n as g,on as _,or as v,pn as y,r as b,s as x,sr as S,t as C,u as w}from"./input-C0OQCUZy.js";import{n as T,t as E}from"./createLucideIcon-BEHeJH0M.js";import{H as D,O,V as k,_ as A,a as ee,c as j,d as M,g as N,h as P,m as F,o as I,s as L,t as R,u as te,v as z}from"./button-C8Xa2k4x.js";import{n as B,t as V}from"./label-CI7JWQOo.js";import{m as H,t as ne}from"./AnimatePresence-FfDQQNFJ.js";import{a as re,c as U,i as ie,n as W,o as G,p as ae,r as K,s as oe,t as q}from"./select-D6jzbLJn.js";import{a as J,c as se,i as ce,l as le,n as ue,o as Y,r as de,s as fe,t as pe}from"./FormContext-sV-yByKz.js";import{t as me}from"./refresh-cw-B5iaAZKn.js";import{A as he,B as ge,Bt as _e,C as ve,D as ye,E as be,F as xe,Ft as Se,G as Ce,Gt as we,H as Te,Ht as Ee,I as De,Jt as Oe,Kt as ke,N as Ae,O as je,Ot as Me,P as Ne,R as Pe,S as Fe,Sn as Ie,T as Le,Tn as Re,Tt as ze,U as Be,Ut as Ve,V as He,Vt as Ue,Wt as We,Xt as Ge,Zt as Ke,_n as qe,a as X,b as Je,bt as Ye,c as Xe,cn as Ze,d as Qe,dn as $e,et,f as Z,fn as tt,g as nt,gn as rt,gt as it,hn as at,i as ot,jt as st,k as ct,l as lt,ln as ut,n as dt,o as ft,ot as pt,p as mt,qt as ht,r as gt,s as _t,sn as vt,tn as yt,u as bt,v as xt,vn as St,wn as Ct,x as wt,y as Tt,yn as Et,yt as Dt}from"./index-BMaSsizY.js";import{a as Ot,c as kt,i as At,n as jt,o as Mt,r as Nt,s as Pt}from"./dist-9Oy7e0v8.js";import{n as Ft,t as It}from"./MarkdownRenderer-Cwxp9fLj.js";import{a as Lt,i as Rt,n as zt,t as Bt}from"./tabs-subtle-D2XkWhLL.js";import{a as Vt,c as Ht,i as Ut,l as Wt,n as Gt,o as Kt,r as qt,s as Jt,t as Yt}from"./useConfig-B6tXvJOb.js";import{t as Xt}from"./textarea-CRTXuRmE.js";import{t as Zt}from"./checkbox-B6dtF73d.js";import{n as Qt,t as $t}from"./schemaHelpers-DLNTQr_6.js";import{t as en}from"./McpAppsViewPanel-jQYFoZNX.js";var tn=E(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),nn=E(`arrow-left-from-line`,[[`path`,{d:`m9 6-6 6 6 6`,key:`7v63n9`}],[`path`,{d:`M3 12h14`,key:`13k4hi`}],[`path`,{d:`M21 19V5`,key:`b4bplr`}]]),rn=E(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),an=E(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),on=E(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),sn=E(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),cn=E(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),Q=e(t(),1),$=T(),ln=Q.forwardRef(({className:e,children:t,...n},r)=>(0,$.jsx)(`div`,{ref:r,"data-slot":`scroll-area`,className:D(`relative overflow-hidden`,e),...n,children:(0,$.jsx)(`div`,{"data-slot":`scroll-area-viewport`,className:`h-full w-full overflow-y-auto overflow-x-hidden`,children:t})}));ln.displayName=`ScrollArea`;function un({count:e}){return(0,$.jsx)(`div`,{className:`flex flex-row absolute top-0 right-0 z-10 w-full items-center justify-between gap-2 ${w}`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-full`,children:[(0,$.jsx)(`h2`,{className:d,children:`Chat History`}),(0,$.jsx)(S,{className:`bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent`,variant:`outline`,children:e})]})})}function dn({className:e,...t}){return(0,$.jsx)(`div`,{"data-slot":`skeleton`,className:D(`animate-pulse rounded-md bg-muted`,e),...t})}var fn=`New Chat`,pn=`Chat`;function mn(e){return e===`New Chat`||e===`Chat`}var hn=`Generate a concise title (maximum 60 characters) for this chat based on the user's first message. Name the subject matter, task, or question — not the act of chatting. Never output meta phrases (e.g. do not use: greeting, introduction, initiation, conversation start, chat session). If there is no specific topic yet, reply with exactly: Chat. Return only the title, no quotes or extra text.`,gn=[`greeting`,`initiation`,`conversation start`,`introduction to`,`chat session`,`starting a chat`,`beginning of`];function _n(e){return typeof e.content==`string`?e.content.trim():String(e.content??``).trim()}function vn(e){for(let t of e){if(t.role!==`user`)continue;let e=_n(t);if(e)return e}return null}function yn(e){let t=e.toLowerCase();for(let e of gn)if(t.includes(e))return!0;return!1}function bn(e){let t=e.trim().split(/\r?\n/)[0].trim();if(!t)return!0;if(t.length>48)return!1;let n=t.replace(/\s+/g,` `).toLowerCase();return/^(hi|hello|hey|greetings?)[!.]?$/i.test(n)||/^(good morning|good afternoon|good evening)[!.]?$/i.test(n)||/^(hi|hello|hey)\s+(there|all|team|everyone)[!.]?$/i.test(n)}function xn(e){return e.length>60?`${e.substring(0,57)}...`:e}function Sn(e){return e?.model?.trim()?e.provider===`ollama`?!0:!!e.apiKey?.trim():!1}async function Cn(e,t,n){let r=t.trim();if(!r||!Sn(e))return null;if(bn(r))return xn(r);try{let t=(await Ot({config:kt(e.provider,e.model,{apiKey:e.apiKey,temperature:e.temperature,baseUrl:e.baseUrl,maxTokens:128}),messages:[{role:`system`,content:hn},{role:`user`,content:r}],signal:n})).trim();if(!t)return null;let i=xn(t);return i===`Chat`||yn(i)?xn(r):i}catch{return null}}var wn=28,Tn=3,En=.72;function Dn({chatId:e,title:t,className:n,onRevealComplete:r}){let[i,a]=(0,Q.useState)(t),[o,s]=(0,Q.useState)(0),[c,l]=(0,Q.useState)(1),u=(0,Q.useRef)(t),d=(0,Q.useRef)(null),f=(0,Q.useRef)(e);return(0,Q.useEffect)(()=>{if(f.current!==e){f.current=e,u.current=t,d.current=null,a(t),s(0),l(1);return}},[e,t]),(0,Q.useEffect)(()=>{let n=`${e}:${t}`;if(d.current===n){a(t),s(0),l(1);return}let i=u.current,o=mn(i)&&!mn(t)&&t!==i;if(u.current=t,!o){a(t),s(0),l(1);return}d.current=n;let c=0,f=t.length;a(``),s(Tn),l(En);let p,m=()=>{c+=1;let e=f>0?c/f:1;a(t.slice(0,c)),s(Tn*(1-e)),l(En+(1-En)*e),c<f?p=setTimeout(m,wn):r?.()};return p=setTimeout(m,wn),()=>{p&&clearTimeout(p)}},[e,t,r]),(0,$.jsx)(`span`,{className:D(`block truncate transition-[filter,opacity] duration-75`,n),style:{filter:o>0?`blur(${o}px)`:void 0,opacity:c},children:i})}function On({compact:e,hideAgentName:t}){return(0,$.jsxs)(`div`,{className:D(`flex items-center justify-between py-3 gap-2`,e?`px-4`:`px-3 rounded-lg`),children:[(0,$.jsxs)(`div`,{className:D(`flex-1 min-w-0 flex flex-col gap-1`,t?`gap-1.5`:`gap-1`),children:[(0,$.jsx)(dn,{className:`h-4 w-3/4`}),!t&&(0,$.jsx)(dn,{className:`h-3 w-1/2`})]}),(0,$.jsx)(dn,{className:`h-3 w-14 shrink-0`})]})}function kn({chats:e,onDelete:t,onSelect:n,compact:i,hideAgentName:a,isLoading:o,currentChatId:s}){let[c,l]=Q.useState(``),u=e.filter(e=>e.type!==`agent_execution`),d=u.filter(e=>(e.title??``).toLowerCase().includes(c.toLowerCase())),f=e=>{let t=new Date(e),n=new Date;if(t.toDateString()===n.toDateString())return t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});let r=new Date(n);if(r.setDate(r.getDate()-1),t.toDateString()===r.toDateString())return`Yesterday`;let i=n.getTime()-t.getTime(),a=Math.floor(i/(1e3*60*60*24));return a<7?`${a} days ago`:t.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})},p=e=>(0,$.jsxs)(`div`,{className:D(`flex items-center justify-between py-3 hover:bg-muted/50 transition-colors gap-2 cursor-pointer`,i?`px-4`:`px-3 rounded-lg`,s===e.id&&`bg-muted/50`),children:[(0,$.jsxs)(`div`,{className:D(`flex-1 min-w-0 flex overflow-hidden`,a?`flex-col`:`flex-col gap-1`),children:[(0,$.jsx)(`p`,{className:`text-sm font-medium truncate w-full`,children:(0,$.jsx)(Dn,{chatId:e.id,title:e.title},`${e.id}:${e.title}`)}),!a&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground truncate w-full`,children:e.agent_name})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2 shrink-0`,children:(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:f(e.updated_at)})})]});return(0,$.jsxs)(`div`,{className:`flex h-full w-full flex-col`,children:[(0,$.jsx)(`div`,{className:`mb-4 px-3 sm:px-5`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(r,{className:`absolute left-3 top-2.5 h-4 w-4 text-muted-foreground`}),(0,$.jsx)(C,{placeholder:`Search chats...`,value:c,onChange:e=>l(e.target.value),className:`pl-9 h-8 border-gray-300 dark:border-zinc-600`})]})}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:o&&u.length===0?(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(On,{compact:i,hideAgentName:a}),(0,$.jsx)(On,{compact:i,hideAgentName:a}),(0,$.jsx)(On,{compact:i,hideAgentName:a})]}):u.length===0?(0,$.jsx)(`div`,{className:`flex flex-1 flex-col items-center justify-center p-4 text-center min-h-[12rem]`,children:(0,$.jsx)(We,{vertical:!0,noBorder:!0,message:`No chats`,className:`mt-0`})}):d.length===0?null:(0,$.jsx)(`div`,{className:`space-y-1`,children:d.map(e=>n?(0,$.jsx)(`button`,{type:`button`,onClick:()=>n(e.id),className:`block w-full text-left group cursor-pointer`,children:p(e)},e.id):(0,$.jsx)(`div`,{className:`block group cursor-pointer`,children:p(e)},e.id))})})]})}var An=20;function jn({provider:e,enabled:t=!0,agentId:n,refetchKey:r,refetchInterval:i=!1}){let[a,o]=(0,Q.useState)(1),[s,c]=(0,Q.useState)([]),[l,u]=(0,Q.useState)(0),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(null),h=(0,Q.useRef)(void 0),g=(0,Q.useCallback)(async()=>{if(t){f(!0),m(null);try{let t=await e.listChats({...n?{agentId:n}:{},take:An*a,skip:0});c(t.items),u(t.total)}catch(e){m(e instanceof Error?e:Error(String(e)))}finally{f(!1)}}},[e,t,n,a]);(0,Q.useEffect)(()=>{t&&o(1)},[t]),(0,Q.useEffect)(()=>{g()},[g]),(0,Q.useEffect)(()=>{r!==void 0&&r!==h.current&&(h.current=r,t&&g())},[r,t,g]),(0,Q.useEffect)(()=>{if(!t||!i)return;let e=setInterval(()=>void g(),i);return()=>clearInterval(e)},[t,i,g]);let _=l>s.length;return{chats:s,total:l,isLoading:d,error:p,hasNextPage:_,loadMore:(0,Q.useCallback)(()=>{_&&!d&&o(e=>e+1)},[_,d]),refetch:(0,Q.useCallback)(()=>{g()},[g]),deleteChat:(0,Q.useCallback)(async t=>{await e.deleteChat(t),await g()},[e,g])}}function Mn({provider:e,open:t,onOpenChange:n,currentChatId:r,container:i,agentId:a,agentDisplayNameFallback:o,onSelectChat:s,variant:c=`drawer`,containerClassName:l,refetchKey:u,refetchInterval:d=!1,onCurrentChatDeleted:f,onDeleteSuccess:p,onDeleteError:m}){let h=(0,Q.useRef)(null),g=(0,Q.useRef)(null),{chats:_,isLoading:v,hasNextPage:y,loadMore:b,deleteChat:x}=jn({provider:e,enabled:t,agentId:a,refetchKey:u,refetchInterval:o?d||3e3:d});(0,Q.useEffect)(()=>{if(!t||!g.current)return;let e=new IntersectionObserver(e=>{e[0]?.isIntersecting&&b()},{threshold:.5});return e.observe(g.current),()=>{e.disconnect()}},[t,y,v,b]);let S=async e=>{try{await x(e),p?.(),e===r&&f?.()}catch(e){console.error(`Failed to delete chat:`,e),m?.(e)}},C=_.map(e=>({...e,title:e.title||`New Chat`,agent_name:e.agent_name??o??`Unknown Agent`})),w=C.filter(e=>e.type!==`agent_execution`).length,T=(0,$.jsx)(kn,{chats:C,onDelete:S,compact:c===`inline`,hideAgentName:!!o,isLoading:v&&_.length===0,currentChatId:r,onSelect:s?e=>{s(e),n(!1)}:void 0}),E=(0,$.jsxs)(`div`,{className:`relative flex h-full min-h-0 flex-col`,children:[(0,$.jsx)(un,{count:w}),(0,$.jsxs)(ln,{ref:h,className:D(`min-h-0 flex-1 w-full pt-14 sm:pt-16 [&_[data-slot=scroll-area-viewport]]:block!`,c===`inline`?`p-0`:`px-3 sm:px-5`),children:[T,y&&(0,$.jsx)(`div`,{ref:g,className:`py-4 flex items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(Ze,{className:`h-4 w-4 animate-spin`}),`Loading more...`]})})]})]});return c===`inline`?(0,$.jsx)(`div`,{className:D(`flex h-full min-h-0 flex-col`,l),children:E}):(0,$.jsx)(Xe,{open:t,onOpenChange:n,children:(0,$.jsx)(lt,{side:`left`,className:`w-[400px] sm:w-[400px] border-zinc-200 p-0 dark:border-zinc-700`,container:i,children:E})})}function Nn({onCollapse:e}){return(0,$.jsxs)(g,{children:[(0,$.jsx)(c,{render:(0,$.jsxs)(R,{type:`button`,variant:`ghost`,size:`icon-sm`,tabIndex:-1,"aria-label":`Collapse`,onClick:e,className:`border-border absolute top-1/2 right-0 z-30 size-7 min-h-7 min-w-7 -translate-y-1/2 translate-x-1/2 rounded-full border bg-background`,children:[(0,$.jsx)(nn,{className:`size-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Collapse`})]}),nativeButton:!0}),(0,$.jsx)(b,{side:`right`,children:`Collapse`})]})}var Pn=`mcp-inspector-chats`,Fn=`New Chat`,In=40;function Ln(){try{let e=localStorage.getItem(Pn);if(!e)return{sessions:[],messages:{}};let t=JSON.parse(e);return{sessions:Array.isArray(t.sessions)?t.sessions:[],messages:t.messages&&typeof t.messages==`object`?t.messages:{}}}catch{return{sessions:[],messages:{}}}}function Rn(e){localStorage.setItem(Pn,JSON.stringify(e))}function zn(){return new Date().toISOString()}function Bn(e){let t=e.find(e=>e.role===`user`);if(!t)return;let n=typeof t.content==`string`?t.content.trim():String(t.content??``).trim();if(n)return n.length>In?`${n.slice(0,In)}…`:n}var Vn=class{saveTimers=new Map;async listChats(e){let{sessions:t}=Ln(),n=t;e.agentId&&(n=t.filter(t=>t.agent_id===e.agentId)),n=[...n].sort((e,t)=>new Date(t.updated_at).getTime()-new Date(e.updated_at).getTime());let r=n.length,i=e.skip??0,a=e.take??r;return{items:n.slice(i,i+a),total:r}}async getMessages(e){let{messages:t}=Ln();return t[e]??[]}async createChat(e){let t=Ln(),n=zn(),r={id:crypto.randomUUID(),title:e.title??Fn,agent_id:e.agentId,agent_name:e.agentName??`MCP Server`,created_at:n,updated_at:n};return t.sessions.push(r),t.messages[r.id]=[],Rn(t),r}async updateChat(e,t){let n=Ln(),r=n.sessions.findIndex(t=>t.id===e);if(r===-1)throw Error(`Chat not found: ${e}`);let i=n.sessions[r];return t.title!==void 0&&(i.title=t.title),i.updated_at=zn(),n.sessions[r]=i,Rn(n),i}async deleteChat(e){let t=Ln();t.sessions=t.sessions.filter(t=>t.id!==e),delete t.messages[e],Rn(t)}async saveMessages(e,t){let n=this.saveTimers.get(e);n&&clearTimeout(n),await new Promise(n=>{let r=setTimeout(()=>{this.saveTimers.delete(e);let r=Ln();r.messages[e]=t;let i=r.sessions.findIndex(t=>t.id===e);if(i!==-1){let e=r.sessions[i];if(e.updated_at=zn(),e.title===Fn){let n=Bn(t);n&&(e.title=n)}r.sessions[i]=e}Rn(r),n()},500);this.saveTimers.set(e,r)})}};function Hn({activeChatId:e,storage:t,messages:n,isLoading:r,effectiveClientSide:i,llmConfig:a,activeChatTitle:o,titleGenerationReady:s=!0,onTitleGenerated:c,onHistoryRefetch:l}){let u=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{u.current=null},[e]),(0,Q.useEffect)(()=>{if(!e||!t||r||!s||o&&!mn(o))return;let d=vn(n);if(!d)return;let f=`${e}:${d}`;if(u.current===f)return;u.current=f;let p=!1;return(async()=>{let n=null;if(t.generateTitle?n=await t.generateTitle(e):i&&a&&(n=await Cn(a,d),n&&await t.updateChat(e,{title:n})),!p){if(!n||n===`New Chat`){u.current=null;return}l?.(),c?.(e,n)}})().catch(()=>{p||(u.current=null)}),()=>{p=!0}},[e,t,n,r,i,a,o,s,c,l])}var Un=[`#e0eaff`,`#f9ffbd`,`#dedede`,`#ffffff`],Wn=[`#27272a`,`#9a9448`,`#3f3f46`,`#18181b`];function Gn(e){return e===`dark`?Wn:Un}var Kn=.54,qn=.4,Jn=`linear-gradient(to top, black 0%, black 12%, rgba(0,0,0,0.55) 38%, transparent 100%)`;function Yn({className:e,children:t,shaderPhase:n=`hidden`,onShaderFadeComplete:r,meshAnimationPaused:i=!1,...a}){let o=(0,Q.useRef)(null),[s,c]=(0,Q.useState)(!1),{resolvedTheme:l}=ct(),u=Gn(l),d=l===`dark`,{paused:f,toggle:p}=Ee(_e),m=f||i;(0,Q.useEffect)(()=>{let e=window.requestAnimationFrame(()=>c(!0));return()=>window.cancelAnimationFrame(e)},[]),(0,Q.useEffect)(()=>{n===`fading`&&!s&&r?.()},[n,s,r]);let h=n!==`hidden`,g=n===`visible`&&s,_=e=>{e.propertyName===`opacity`&&n===`fading`&&r?.()};return(0,$.jsxs)(`div`,{ref:o,className:D(`relative flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,e),...a,children:[h&&(0,$.jsx)(`div`,{className:D(`pointer-events-none absolute inset-x-0 bottom-0 z-0 transition-opacity duration-500`,g?`opacity-100`:`opacity-0`),style:{height:`${Kn*100}%`},"aria-hidden":!0,onTransitionEnd:_,children:(0,$.jsxs)(`div`,{className:D(`absolute inset-0`,s?d?`opacity-90`:`opacity-75`:`opacity-0`),style:{maskImage:Jn,WebkitMaskImage:Jn},children:[(0,$.jsx)(`div`,{className:`absolute inset-0 bg-[#edf2ff] dark:hidden`}),(0,$.jsx)(Ve,{className:`absolute inset-0 h-full w-full`,colors:[...u],distortion:.8,swirl:.1,grainMixer:0,grainOverlay:d?.12:.3,speed:m?0:qn})]})}),h&&(0,$.jsx)(Ue,{paused:f,onToggle:p,className:`absolute bottom-3 right-3 sm:bottom-5 sm:right-5`}),(0,$.jsx)(`div`,{className:`relative z-10 flex min-h-0 flex-1 flex-col`,children:t})]})}function Xn(e){return e?e.apiKey===`server-managed`||e.baseUrl?.includes(`/inspector/llm`)===!0:!1}function Zn(e){if(!(e instanceof Error))return!1;let t=e.message.toLowerCase();return t.includes(`failed to fetch`)||t.includes(`networkerror`)||t.includes(`network request failed`)||t.includes(`load failed`)}function Qn(e,t){if(!t)return e>=502&&e<=504?{kind:`cloud_unavailable`}:null;if(e===402)return{kind:`credits_exhausted`,billingUrl:typeof t.upgradeUrl==`string`?t.upgradeUrl:typeof t.billingUrl==`string`?t.billingUrl:void 0,message:typeof t.message==`string`?t.message:`You've used your included free plan credits.`};if(e===429){if(t.loginRequired&&t.loginUrl)return{kind:`login_required`,loginUrl:String(t.loginUrl)};if(t.creditsExhausted)return{kind:`credits_exhausted`,billingUrl:typeof t.billingUrl==`string`?t.billingUrl:void 0,message:typeof t.message==`string`?t.message:`You've used your included free plan credits.`};if(t.error===`free_org_rate_limited`||typeof t.reason==`string`)return{kind:`credits_exhausted`,message:typeof t.message==`string`?t.message:`You've reached your included chat quota for this workspace.`}}return e>=502&&e<=504?{kind:`cloud_unavailable`}:null}function $n(e){let t=e.match(/^OpenAI request failed \((\d+) /);if(!t)return null;let n=Number(t[1]),r=e.indexOf(`{`);if(r===-1)return null;try{let t=JSON.parse(e.slice(r));if(t&&typeof t==`object`&&!Array.isArray(t))return{status:n,body:t}}catch{}return null}function er(e){if(e instanceof Error&&e.name===`LlmRequestError`){let t=e.status??0,n=e.body;return Qn(t,n&&typeof n==`object`&&!Array.isArray(n)?n:void 0)}if(e instanceof Error){let t=$n(e.message);if(t)return Qn(t.status,t.body)}return Zn(e)?{kind:`cloud_unavailable`}:null}function tr(e,t){return Qn(e,t)}var nr=Q.createContext(null);function rr(){let e=Q.useContext(nr);if(!e)throw Error(`Command components must be used within <Command>`);return e}function ir(e,t){return t?e.toLowerCase().includes(t.toLowerCase()):!0}var ar=Q.forwardRef(({className:e,...t},n)=>{let[r,i]=Q.useState(``),[a,o]=Q.useState(null),[s,c]=Q.useState(0),l=Q.useCallback(()=>(c(e=>e+1),()=>c(e=>Math.max(0,e-1))),[]);return(0,$.jsx)(nr.Provider,{value:{search:r,setSearch:i,activeValue:a,setActiveValue:o,visibleCount:s,registerVisible:l},children:(0,$.jsx)(`div`,{ref:n,className:D(`flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground`,e),...t})})});ar.displayName=`Command`;var or=Q.forwardRef(({className:e,...t},n)=>{let{search:r,setSearch:i}=rr();return(0,$.jsx)(`div`,{className:`flex items-center border-b px-3`,children:(0,$.jsx)(`input`,{ref:n,value:r,onChange:e=>i(e.target.value),className:D(`flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`,e),...t})})});or.displayName=`CommandInput`;var sr=Q.forwardRef(({className:e,...t},n)=>(0,$.jsx)(`div`,{ref:n,className:D(`max-h-[300px] overflow-y-auto overflow-x-hidden`,e),...t}));sr.displayName=`CommandList`;var cr=Q.forwardRef(({className:e,...t},n)=>{let{visibleCount:r}=rr();return r>0?null:(0,$.jsx)(`div`,{ref:n,className:D(`py-6 text-center text-sm`,e),...t})});cr.displayName=`CommandEmpty`;var lr=Q.forwardRef(({className:e,heading:t,children:n,...r},i)=>(0,$.jsxs)(`div`,{ref:i,className:D(`overflow-hidden p-1 text-foreground [&_[data-command-group-heading]]:px-2 [&_[data-command-group-heading]]:py-1.5 [&_[data-command-group-heading]]:text-xs [&_[data-command-group-heading]]:font-medium [&_[data-command-group-heading]]:text-muted-foreground`,e),...r,children:[t?(0,$.jsx)(`div`,{"data-command-group-heading":``,children:t}):null,n]}));lr.displayName=`CommandGroup`;var ur=Q.forwardRef(({className:e,value:t,keywords:n,onSelect:r,disabled:i,onClick:a,...o},s)=>{let{search:c,activeValue:l,setActiveValue:u,registerVisible:d}=rr(),f=Array.isArray(n)?n.join(` `):n,p=ir(f?`${t} ${f}`:t,c),m=l===t;return Q.useLayoutEffect(()=>{if(p)return d()},[p,d]),Q.useEffect(()=>{p&&l===null&&!i&&u(t)},[p,l,i,u,t]),p?(0,$.jsx)(`div`,{ref:s,role:`option`,"aria-selected":m,"data-selected":m,"data-disabled":i,className:D(`relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50`,e),onMouseEnter:()=>!i&&u(t),onClick:e=>{a?.(e),i||r?.(t)},...o}):null});ur.displayName=`CommandItem`;var dr=`mcp-inspector-models-cache`,fr=1440*60*1e3;function pr(){try{let e=localStorage.getItem(dr);if(e)return JSON.parse(e)}catch(e){console.error(`Failed to load models cache:`,e)}return{}}function mr(e,t){try{let n=pr();n[e]={models:t,timestamp:Date.now()},localStorage.setItem(dr,JSON.stringify(n))}catch(e){console.error(`Failed to save models cache:`,e)}}function hr(e){try{let t=pr(),n=t[e];if(n){if(Date.now()-n.timestamp<fr)return n.models;delete t[e],localStorage.setItem(dr,JSON.stringify(t))}}catch(e){console.error(`Failed to get cached models:`,e)}return null}function gr(e,t){return!Wt(e)||!t?.trim()?e:`${e}:${e===`ollama`?Pt(t):t.trim().toLowerCase()}`}var _r=`chat-config-source`;function vr(e){return e===`openai`||e===`anthropic`||e===`google`?e:`openrouter`}async function yr(e,t){let n={};t&&(n.Authorization=`Bearer ${t}`);let r;try{r=await fetch(`${e}/models`,{headers:n})}catch{throw Error(`Failed to reach the server. Check the URL is correct and that CORS is enabled on the server.`)}if(!r.ok)throw Error(`Failed to fetch models: ${r.statusText}`);if(!(r.headers.get(`content-type`)??``).includes(`application/json`))throw Error(`Invalid URL — response was not JSON`);let i=await r.json();if(!Array.isArray(i?.data))throw Error(`Unexpected response format — expected { data: [...] } from the OpenAI-compatible endpoint`);return i.data.map(e=>({id:e.id}))}async function br(e){let t=await fetch(`https://api.openai.com/v1/models`,{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw Error(`Failed to fetch OpenAI models: ${t.statusText}`);return(await t.json()).data.map(e=>({id:e.id}))}async function xr(e){let t=await fetch(`https://api.anthropic.com/v1/models`,{headers:{"x-api-key":e,"anthropic-version":`2023-06-01`,"anthropic-dangerous-direct-browser-access":`true`}});if(!t.ok)throw Error(`Failed to fetch Anthropic models: ${t.statusText}`);return(await t.json()).data.map(e=>({id:e.id,displayName:e.display_name}))}async function Sr(e){let t=await fetch(`https://generativelanguage.googleapis.com/v1beta/models?key=${e}`);if(!t.ok)throw Error(`Failed to fetch Google models: ${t.statusText}`);return((await t.json()).models||[]).map(e=>({id:e.name,displayName:e.displayName}))}async function Cr(e){let t=await fetch(`https://openrouter.ai/api/v1/models`,{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw Error(`Failed to fetch OpenRouter models: ${t.statusText}`);return(await t.json()).data.map(e=>({id:e.id,displayName:e.name}))}async function wr(e,t){let n;try{n=await fetch(At(e,`/api/tags`),{headers:{...t.trim()?{Authorization:`Bearer ${t.trim()}`}:{}}})}catch(e){throw new Nt(e)}if(!n.ok)throw Error(`Failed to fetch Ollama models: ${n.statusText}`);return((await n.json()).models||[]).map(e=>({id:e.model||e.name||``}))}function Tr({open:e,onOpenChange:t,tempProvider:n,tempModel:r,tempApiKey:i,tempBaseUrl:a,onProviderChange:o,onModelChange:s,onApiKeyChange:c,onBaseUrlChange:l,onSave:u,onClear:d,showClearButton:f=!1,buttonLabel:p=`Configure API Key`,hostedInspector:m=!1,freeTierInfo:h,managedCloudInfo:g,useManagedCloud:_=!1,onSaveManagedCloud:v}){let{resolvedTheme:y}=ct(),b=Gn(y),x=y===`dark`,[S,w]=(0,Q.useState)([]),[T,E]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(null),[A,ee]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(!1),[F,I]=(0,Q.useState)(+!_),L=gr(n,a),te=!!(m||h||g),z=!!(g&&F===0);(0,Q.useEffect)(()=>{e&&I(+!_)},[e,_]),(0,Q.useEffect)(()=>{let t=Ht(n),r=Wt(n);if(z||!e||!n||t&&!i.trim()||r&&!a.trim()){w([]),k(null);return}let o=setTimeout(async()=>{let e=hr(L);if(e){w(e),k(null);return}E(!0),k(null);try{let e=[];n===`openai-compatible`?e=await yr(a,i):n===`openai`?e=await br(i):n===`anthropic`?e=await xr(i):n===`google`?e=await Sr(i):n===`openrouter`?e=await Cr(i):n===`ollama`&&(e=await wr(a,i)),mr(L,e),w(e)}catch(e){k(e instanceof Error?e.message:`Failed to fetch models. Please check your API key.`),w([])}finally{E(!1)}},500);return()=>clearTimeout(o)},[i,a,n,e,L,z]);let B=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(!e||z){e||(B.current=null);return}let t=B.current;t!==null&&t!==n&&s(``),B.current=n},[n,e,s,z]);let H=Wt(n),ne=!Ht(n),U=e&&(!Ht(n)||!!i.trim())&&(!H||!!a.trim()),G=ne?`API Key (optional)`:`API Key`,ae=ne?n===`ollama`?`Leave empty for local Ollama`:`Enter your API key (optional)`:`Enter your API key`,oe=n===`openai-compatible`?`http://localhost:11434/v1`:Jt(n),J=n===`openai-compatible`?`Base URL of your OpenAI-compatible API. Local servers must have CORS enabled.`:null,se=n===`ollama`?`Optional for local Ollama. Stored locally and never sent to our servers.`:`Your API key is stored locally and never sent to our servers.`,ce=g?g.models.reduce((e,t)=>(e[t.provider]||(e[t.provider]=[]),e[t.provider].push(t),e),{}):{},le=g?.models.find(e=>e.id===g.selectedModelId),ue=Object.keys(ce),Y=le?.provider??ue[0]??``,de=Y?ce[Y]??[]:[],fe=!!d&&f&&(!g||F===1),pe=()=>{if(z&&v){v();return}u()},me=z?!!(g?.isLoading||!g?.selectedModelId||g?.models.length===0):Ht(n)&&!i.trim()||H&&!a.trim()||!r.trim();return(0,$.jsx)(Pe,{open:e,onOpenChange:t,children:(0,$.jsxs)(ge,{className:`max-w-md`,"data-testid":`chat-config-dialog`,children:[(0,$.jsxs)(Be,{children:[(0,$.jsx)(Ce,{children:te?`Configure Chat`:`LLM Provider Configuration`}),(0,$.jsx)(He,{children:g?`Pick a Manufact cloud model or bring your own API key.`:h?`Chat requires an LLM. You can chat for free if you have a Manufact account, or you can use your own API key (not sent to Manufact).`:`Configure your LLM provider and API key to start chatting with the MCP server`})]}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[h&&(0,$.jsxs)(`button`,{type:`button`,onClick:h.onLoginClick,"data-testid":`chat-config-sign-in-card`,className:`relative w-full cursor-pointer overflow-hidden rounded-2xl text-left transition-opacity hover:opacity-95 active:opacity-90`,children:[(0,$.jsx)(`div`,{className:`absolute inset-0 bg-[#edf2ff] dark:bg-background`,"aria-hidden":!0}),(0,$.jsx)(`div`,{className:`absolute inset-0 dark:opacity-90`,children:(0,$.jsx)(Ve,{className:`absolute inset-0 h-full w-full`,colors:[...b],grainOverlay:x?.1:.15})}),(0,$.jsxs)(`div`,{className:`relative flex items-center justify-between gap-4 px-4 py-3.5`,children:[(0,$.jsxs)(`div`,{className:`text-sm font-medium text-foreground`,children:[(0,$.jsx)(`p`,{children:`Chat for free with a`}),(0,$.jsxs)(`p`,{className:`mt-1 flex items-center gap-1.5`,children:[(0,$.jsx)(gt,{symbolSize:14,textClassName:`text-sm`}),`account`]})]}),(0,$.jsx)(R,{size:`sm`,render:(0,$.jsx)(`span`,{"aria-hidden":`true`}),nativeButton:!1,tabIndex:-1,className:`pointer-events-none shrink-0`,children:`Sign in`})]})]}),g&&(0,$.jsx)(`div`,{className:`flex justify-center`,children:(0,$.jsxs)(Bt,{selectedIndex:F,onSelect:I,idPrefix:_r,className:`w-fit`,children:[(0,$.jsx)(zt,{index:0,label:`Manufact cloud`}),(0,$.jsx)(zt,{index:1,label:`API key`})]})}),(0,$.jsxs)(`div`,{className:D(`space-y-2`,g&&`!mt-2`),children:[(0,$.jsx)(V,{children:`Provider`}),z?(0,$.jsxs)(q,{value:Y,onValueChange:e=>{let t=g?.models.find(t=>t.provider===e);t&&g?.onModelChange(t.id)},children:[(0,$.jsx)(ie,{className:`rounded-md`,leading:Y?(0,$.jsx)(X,{provider:vr(Y),className:`shrink-0`}):void 0,children:(0,$.jsx)(re,{})}),(0,$.jsx)(W,{children:ue.map(e=>(0,$.jsx)(K,{value:e,label:_t(vr(e)),children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{provider:vr(e)}),(0,$.jsx)(`span`,{children:_t(vr(e))})]})},e))})]}):(0,$.jsxs)(q,{value:n,onValueChange:e=>o(e),children:[(0,$.jsx)(ie,{className:`rounded-md`,leading:(0,$.jsx)(X,{provider:n,className:`shrink-0`}),children:(0,$.jsx)(re,{})}),(0,$.jsxs)(W,{children:[(0,$.jsx)(K,{value:`openai`,label:_t(`openai`),children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{provider:`openai`}),(0,$.jsx)(`span`,{children:_t(`openai`)})]})}),(0,$.jsx)(K,{value:`anthropic`,label:_t(`anthropic`),children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{provider:`anthropic`}),(0,$.jsx)(`span`,{children:_t(`anthropic`)})]})}),(0,$.jsx)(K,{value:`google`,label:_t(`google`),children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{provider:`google`}),(0,$.jsx)(`span`,{children:_t(`google`)})]})}),(0,$.jsx)(K,{value:`ollama`,label:_t(`ollama`),children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{provider:`ollama`}),(0,$.jsx)(`span`,{children:_t(`ollama`)})]})}),(0,$.jsx)(K,{value:`openrouter`,label:_t(`openrouter`),children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{provider:`openrouter`}),(0,$.jsx)(`span`,{children:_t(`openrouter`)})]})}),(0,$.jsx)(K,{value:`openai-compatible`,label:_t(`openai-compatible`),children:(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(`span`,{children:_t(`openai-compatible`)})})})]})]})]}),!z&&H&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(V,{children:`Base URL`}),(0,$.jsx)(C,{value:a,onChange:e=>l(e.target.value),placeholder:oe,"data-testid":`chat-config-base-url-input`}),J&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:J})]}),!z&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(V,{children:G}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(C,{type:N?`text`:`password`,value:i,onChange:e=>c(e.target.value),placeholder:ae,className:`pr-10`,"data-testid":`chat-config-api-key-input`}),(0,$.jsx)(R,{type:`button`,variant:`ghost`,size:`sm`,className:`absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent`,onClick:()=>P(!N),children:N?(0,$.jsx)(rt,{className:`h-4 w-4 text-muted-foreground`}):(0,$.jsx)(at,{className:`h-4 w-4 text-muted-foreground`})})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:se})]}),z?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(V,{children:`Model`}),g?.isLoading?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(Ze,{className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{children:`Loading models…`})]}):de.length>0?(0,$.jsxs)(be,{open:j,modal:!0,onOpenChange:M,children:[(0,$.jsx)(je,{render:(0,$.jsxs)(R,{variant:`outline`,role:`combobox`,"aria-expanded":j,className:`w-full justify-between rounded-md`,"data-testid":`chat-config-cloud-model-select`,children:[(0,$.jsx)(`span`,{className:`inline-flex min-w-0 items-center gap-2 truncate`,children:le?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{provider:vr(le.provider),className:`shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:ft(le.name,le.provider)})]}):`Select a model…`}),(0,$.jsx)(rn,{className:`ml-2 h-4 w-4 shrink-0 opacity-50`})]}),nativeButton:!0}),(0,$.jsx)(ye,{className:`w-full p-0`,align:`start`,children:(0,$.jsxs)(ar,{children:[(0,$.jsx)(or,{placeholder:`Search models…`,className:`h-9`}),(0,$.jsxs)(sr,{children:[(0,$.jsx)(cr,{children:`No model found.`}),(0,$.jsx)(lr,{children:de.map(e=>(0,$.jsxs)(ur,{value:e.id,keywords:[e.name,e.id,e.provider],onSelect:e=>{g?.onModelChange(e),M(!1)},children:[ft(e.name,e.provider),(0,$.jsx)(Ie,{className:D(`ml-auto h-4 w-4`,g?.selectedModelId===e.id?`opacity-100`:`opacity-0`)})]},e.id))})]})]})})]}):(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Cloud models unavailable — try again or use your own key.`})]}):U&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(V,{children:`Model`}),T?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(Ze,{className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{children:`Loading models...`})]}):O?(0,$.jsx)(`div`,{className:`text-sm text-destructive`,children:O}):S.length>0?(0,$.jsxs)(be,{open:A,modal:!0,onOpenChange:ee,children:[(0,$.jsx)(je,{render:(0,$.jsxs)(R,{variant:`outline`,role:`combobox`,"aria-expanded":A,className:`w-full justify-between rounded-md`,"data-testid":`chat-config-model-select`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:r&&(S.find(e=>e.id===r)?.displayName||S.find(e=>e.id===r)?.id)||`Select a model...`}),(0,$.jsx)(rn,{className:`ml-2 h-4 w-4 shrink-0 opacity-50`})]}),nativeButton:!0}),(0,$.jsx)(ye,{className:`w-full p-0`,align:`start`,children:(0,$.jsxs)(ar,{children:[(0,$.jsx)(or,{placeholder:`Search models...`,className:`h-9`}),(0,$.jsxs)(sr,{children:[(0,$.jsx)(cr,{children:`No model found.`}),(0,$.jsx)(lr,{children:S.map(e=>(0,$.jsxs)(ur,{value:e.id,keywords:e.displayName,onSelect:e=>{s(e===r?``:e),ee(!1)},children:[e.displayName||e.id,(0,$.jsx)(Ie,{className:D(`ml-auto h-4 w-4`,r===e.id?`opacity-100`:`opacity-0`)})]},e.id))})]})]})})]}):(0,$.jsx)(C,{value:r,onChange:e=>s(e.target.value),placeholder:`Enter model name manually`,"data-testid":`chat-config-model-input`})]}),(0,$.jsxs)(`div`,{className:`flex justify-between`,children:[fe&&(0,$.jsx)(R,{variant:`outline`,onClick:d,children:`Clear Config`}),(0,$.jsxs)(R,{onClick:pe,disabled:me,className:fe?`ml-auto`:``,"data-testid":`chat-config-save-button`,children:[(0,$.jsx)(ut,{className:`h-4 w-4 mr-2`}),`Save Configuration`]})]})]})]})})}var Er=`rounded-full bg-background/80 backdrop-blur-md supports-[backdrop-filter]:bg-background/60 dark:bg-zinc-950/75 dark:supports-[backdrop-filter]:bg-zinc-950/55`,Dr=D(Er,`w-fit`),Or=D(Er,`h-9 gap-1.5 px-3`),kr=`chat-view`;function Ar({llmConfig:e,hasMessages:t,configDialogOpen:n,onConfigDialogOpenChange:r,onClearChat:i,tempProvider:a,tempModel:o,tempApiKey:s,tempBaseUrl:l,onProviderChange:u,onModelChange:d,onApiKeyChange:f,onBaseUrlChange:p,onSaveConfig:m,onClearConfig:h,hideConfigButton:_,hostedInspector:v,freeTierInfo:y,managedCloudInfo:x,useManagedCloud:S,onSaveManagedCloud:C,showClearButton:T,clearButtonLabel:E,hideTitle:O,clearButtonHideIcon:k,clearButtonHideShortcut:A,clearButtonVariant:ee,hideClearButton:j,onCopyChat:M,onExportChat:N,activeChatId:P,chatTitle:F,showViewToggle:I,viewIndex:L=0,onViewIndexChange:te,elevatedHeader:z}){return(0,$.jsxs)(`div`,{className:D(`relative flex w-full items-center gap-2 overflow-visible`,w,z?`pointer-events-none absolute top-0 right-0 z-50`:`absolute top-0 right-0 z-10`),children:[(0,$.jsx)(`div`,{className:D(`flex min-w-0 flex-1 items-center`,z&&`pointer-events-auto`),children:!O&&(0,$.jsx)(`h2`,{className:D(`text-[15px] text-foreground [font-variation-settings:'wght'_550,'opsz'_20]`,Dr),children:P?(0,$.jsx)(Dn,{chatId:P,title:F??`Chat`},P):`Chat`})}),I&&te&&(0,$.jsx)(`div`,{className:D(`absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 overflow-visible px-1`,z&&`pointer-events-auto`),children:(0,$.jsxs)(Bt,{selectedIndex:L,onSelect:te,idPrefix:kr,className:`shrink-0 overflow-visible`,"data-testid":`chat-view-tabs`,children:[(0,$.jsx)(zt,{label:`Conv`,index:0}),(0,$.jsx)(zt,{label:`Raw`,index:1})]})}),(0,$.jsxs)(`div`,{className:D(`ml-auto flex shrink-0 items-center gap-2`,z&&`pointer-events-auto`),children:[!j&&t&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[M&&(0,$.jsxs)(R,{"data-testid":`chat-copy-button`,variant:`ghost`,size:`sm`,className:Or,onClick:M,children:[(0,$.jsx)(Et,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:`Copy`})]}),N&&(0,$.jsxs)(we,{children:[(0,$.jsx)(Oe,{render:(0,$.jsxs)(R,{"data-testid":`chat-export-button`,variant:`ghost`,size:`sm`,className:Or,children:[(0,$.jsx)(St,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:`Export`})]}),nativeButton:!0}),(0,$.jsxs)(ke,{align:`end`,children:[(0,$.jsx)(ht,{"data-testid":`chat-export-json`,onClick:()=>N(`json`),children:`Export as JSON`}),(0,$.jsx)(ht,{"data-testid":`chat-export-markdown`,onClick:()=>N(`markdown`),children:`Export as Markdown`})]})]}),(0,$.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),(0,$.jsxs)(g,{children:[(0,$.jsx)(c,{render:(0,$.jsxs)(R,{variant:ee??`default`,size:`default`,className:`p-2 cursor-pointer ${A?`sm:px-3`:`sm:pr-1 sm:pl-3`}`,onClick:i,children:[!k&&(0,$.jsx)(cn,{className:`h-4 w-4 sm:mr-2`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:E??`New Chat`}),!A&&(0,$.jsx)(`span`,{className:`hidden sm:inline text-[12px] border text-zinc-300 p-1 rounded-full border-zinc-300 dark:text-zinc-600 dark:border-zinc-500 ml-2`,children:`⌘O`})]}),nativeButton:!0}),(0,$.jsx)(b,{children:(0,$.jsx)(`p`,{children:E??`New Chat`})})]})]}),(!_||v||y||x)&&(0,$.jsx)(Tr,{open:n,onOpenChange:r,tempProvider:a,tempModel:o,tempApiKey:s,tempBaseUrl:l,onProviderChange:u,onModelChange:d,onApiKeyChange:f,onBaseUrlChange:p,onSave:m,onClear:h,showClearButton:T??(!!e&&!y&&!x),buttonLabel:e?`Change API Key`:`Configure API Key`,hostedInspector:v,freeTierInfo:y,managedCloudInfo:x,useManagedCloud:S,onSaveManagedCloud:C})]})]})}function jr({tools:e,disabledTools:t,onDisabledToolsChange:n,disabled:r}){let[i,a]=(0,Q.useState)(!1),o=e.length-t.size,s=t.size===0,l=t.size>0&&t.size<e.length,u=(0,Q.useCallback)(e=>{let r=new Set(t);r.has(e)?r.delete(e):r.add(e),n(r)},[t,n]),d=(0,Q.useCallback)(()=>{n(s?new Set(e.map(e=>e.name)):new Set)},[s,e,n]),f=(0,Q.useMemo)(()=>[...e].sort((e,t)=>e.name.localeCompare(t.name)),[e]);return e.length===0?null:(0,$.jsxs)(be,{open:i,onOpenChange:a,children:[(0,$.jsxs)(g,{children:[(0,$.jsx)(c,{render:(0,$.jsx)(je,{render:(0,$.jsxs)(R,{variant:`ghost`,size:`sm`,disabled:r,className:D(`h-auto gap-1 rounded-full px-2 py-2`,l?`text-amber-500 dark:text-amber-400`:`text-muted-foreground hover:text-foreground`),type:`button`,"data-testid":`chat-tool-selector`,children:[(0,$.jsx)(Ke,{className:`h-4 w-4 shrink-0`}),l&&(0,$.jsx)(`span`,{className:`flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-amber-500 px-1 text-[9px] font-bold leading-none text-white`,children:o})]}),nativeButton:!0}),nativeButton:!0}),(0,$.jsx)(b,{side:`top`,children:(0,$.jsxs)(`p`,{children:[`Tools (`,o,`/`,e.length,`)`]})})]}),(0,$.jsxs)(ye,{className:`w-72 gap-0 p-0`,align:`start`,side:`top`,sideOffset:8,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b`,children:[(0,$.jsxs)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:[`Allowed Tools (`,o,`/`,e.length,`)`]}),(0,$.jsx)(R,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:d,type:`button`,children:s?`Disable All`:`Enable All`})]}),(0,$.jsx)(`div`,{className:`max-h-64 overflow-y-auto`,children:f.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2.5 w-full px-3 py-1.5 text-left hover:bg-accent/50 transition-colors cursor-pointer`,onClick:()=>u(e.name),children:[(0,$.jsx)(Zt,{checked:!t.has(e.name),className:`pointer-events-none`,tabIndex:-1}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-mono`,children:e.name})]},e.name))})]})]})}function Mr({inputValue:e,isConnected:t,isLoading:n,textareaRef:r,attachments:i,placeholder:a=`Ask a question`,className:o,showAttachButton:s=!0,tools:c,disabledTools:l,onDisabledToolsChange:u,onInputChange:d,onKeyDown:f,onKeyUp:p,onClick:m,onAttachmentAdd:h,onAttachmentRemove:g,inlineControls:_,trailingControls:v}){let y=k(),b=(0,Q.useRef)(null),x=e=>{let t=e.target.files;if(t&&t.length>0)for(let e=0;e<t.length;e++)h(t[e]);b.current&&(b.current.value=``)},S=i.length>0;return(0,$.jsxs)(`div`,{className:`relative w-full`,children:[S&&(0,$.jsx)(`div`,{className:`absolute top-0 left-0 right-0 z-20 p-3 flex gap-2 flex-wrap`,children:i.map((e,t)=>(0,$.jsxs)(`div`,{className:`relative group bg-zinc-100/90 dark:bg-zinc-900/90 backdrop-blur-sm rounded-lg p-2 flex items-center gap-2 border border-zinc-200 dark:border-zinc-700`,"data-testid":`chat-attachment-${t}`,children:[(0,$.jsx)($e,{className:`h-4 w-4 text-muted-foreground shrink-0`}),(0,$.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium truncate max-w-[150px]`,children:e.name||`Image`}),e.size&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:ve(e.size)})]}),(0,$.jsx)(`button`,{onClick:()=>g(t),className:`shrink-0 p-1 rounded-full hover:bg-zinc-200 dark:hover:bg-zinc-800 transition-colors`,title:`Remove attachment`,type:`button`,"data-testid":`chat-attachment-remove-${t}`,children:(0,$.jsx)(Ge,{className:`h-3 w-3`})})]},t))}),(0,$.jsx)(Xt,{ref:r,value:e,onChange:e=>d(e.target.value),onKeyDown:f,onKeyUp:p,onClick:m,placeholder:t?a:`Server not connected`,className:D(`p-4 min-h-[150px] max-h-[300px]`,y.container,S&&`pt-20`,o),disabled:!t||n,"data-testid":`chat-input`}),(0,$.jsx)(`input`,{ref:b,type:`file`,accept:`image/*`,multiple:!0,onChange:x,className:`hidden`,"aria-label":`Upload images`}),(0,$.jsxs)(`div`,{className:`absolute inset-x-0 bottom-0 flex items-center justify-between gap-2 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1`,children:[s&&(0,$.jsx)(R,{variant:`ghost`,size:`sm`,onClick:()=>b.current?.click(),disabled:!t||n,className:`h-auto w-auto aspect-square rounded-full p-2 text-muted-foreground hover:text-foreground`,title:`Attach images`,type:`button`,"data-testid":`chat-attach-button`,children:(0,$.jsx)(on,{className:`h-4 w-4`})}),c&&c.length>0&&l&&u&&(0,$.jsx)(jr,{tools:c,disabledTools:l,onDisabledToolsChange:u,disabled:!t||n}),_]}),v?(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:v}):null]})]})}function Nr({promptResults:e,onDeletePromptResult:t}){return(0,$.jsx)(`div`,{className:`absolute top-4 left-4 right-4 flex gap-2 overflow-x-auto z-20 flex-nowrap`,style:{scrollbarWidth:`none`,msOverflowStyle:`none`},children:e.map(({promptName:e},n)=>(0,$.jsxs)(R,{type:`button`,className:`flex items-center gap-2 bg-zinc-200 text-zinc-700 dark:text-zinc-300 text-[10px] px-1.5 py-0.5 dark:bg-zinc-700 rounded-lg border border-zinc-200 dark:border-zinc-300 font-medium hover:bg-zinc-300 dark:hover:bg-zinc-600`,children:[(0,$.jsx)(vt,{className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,title:e,children:e}),(0,$.jsx)(`span`,{className:`ml-1 h-4 w-4 rounded-full bg-zinc-400 dark:bg-zinc-600 hover:bg-zinc-500 dark:hover:bg-zinc-500 flex items-center justify-center cursor-pointer shrink-0 transition-colors`,onClick:e=>{e.stopPropagation(),t(n)},title:`Remove prompt`,role:`button`,tabIndex:0,children:(0,$.jsx)(Ge,{className:`h-2.5 w-2.5 text-white`})})]},n))})}function Pr({isOpen:e,focusedIndex:t,prompts:n,selectedPrompt:r,onPromptSelect:i}){return e?((0,Q.useEffect)(()=>{if(t>=0){let e=document.getElementById(`prompt-${t}`);e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})}},[t]),(0,$.jsx)(`div`,{className:`absolute bottom-full left-0 right-0 max-w-3xl w-full max-h-[300px] overflow-y-auto rounded-lg border border-zinc-200 dark:border-zinc-800 bg-white dark:bg-zinc-900 shadow-lg z-30 flex flex-col gap-2 mb-1`,"data-testid":`chat-prompts-dropdown`,children:(0,$.jsxs)(`div`,{className:`p-2`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-zinc-900 dark:text-zinc-100 mb-2`,children:`Prompts`}),n.map((e,n)=>(0,$.jsxs)(g,{children:[(0,$.jsx)(c,{render:(0,$.jsxs)(R,{id:`prompt-${n}`,type:`button`,variant:`ghost`,className:D(`w-full flex items-center px-3 py-2 rounded-md hover:bg-zinc-200 dark:hover:bg-zinc-700 transition-colors text-left justify-start`,t===n&&`bg-zinc-200 dark:bg-zinc-700`),onClick:()=>i(e),"data-testid":`chat-prompt-option-${n}`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-center shrink-0`,children:(0,$.jsx)(vt,{className:`h-4 w-4 text-zinc-600 dark:text-zinc-400`})}),(0,$.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,$.jsxs)(`div`,{className:`text-sm font-medium text-zinc-900 dark:text-zinc-100 flex items-center gap-2`,children:[e.name,r?.name===e.name&&(0,$.jsx)(xe,{className:`size-3 text-zinc-600 dark:text-zinc-400`})]})})]}),nativeButton:!0}),(0,$.jsx)(b,{children:e.description})]},n))]})})):null}var Fr=Q.createContext(void 0);function Ir(e=!1){let t=Q.useContext(Fr);if(!t&&!e)throw Error(F(86));return t}var Lr=Q.createContext(void 0);function Rr(){return Q.useContext(Lr)}var zr=[H],Br=Q.forwardRef(function(e,t){let{render:n,className:r,disabled:i,readOnly:o,required:s,onValueChange:c,value:l,defaultValue:u,form:d,name:f,inputRef:p,id:m,style:g,..._}=e,{setTouched:v,setFocused:y,validationMode:b,name:x,disabled:S,state:C,validation:w,setDirty:T,setFilled:E,validityData:D}=Y(),{labelId:O}=de(),{clearErrors:k}=pe(),ee=Ir(!0),j=S||i,M=x??f,N=a(m),[P,F]=B({controlled:l,default:u,name:`RadioGroup`,state:`value`}),[I,L]=Q.useState(!1),R=A((e,t)=>{c?.(e,t),!t.isCanceled&&F(e)}),te=Q.useRef(null),z=Q.useRef(null),V=Q.useRef(null);function H(e){let t;return p&&(typeof p==`function`?t=p(e):p.current=e),z.current=e,w.inputRef.current=e,t}let ne=A((e,t=!1)=>{if(e){if(t){te.current===e&&(te.current=null);return}te.current??=e}}),re=A(e=>{if(!e||e.disabled)return;V.current||=e;let t=z.current;if(e.checked||t==null||t.disabled)return H(e)}),U=A(()=>{let e=z.current;return!e||e.disabled||!e.checked?null:P??null});ce(te,N,P??null,U,!j,f),le(P,()=>{k(M),T(P!==D.initialValue),E(P!=null),w.change(P);let e=V.current;P==null&&e&&!e.disabled&&H(e)});let ie=_[`aria-labelledby`]??O??ee?.legendId,W={...C,disabled:j??!1,required:s??!1,readOnly:o??!1},G=Q.useMemo(()=>({...C,checkedValue:P,disabled:j,form:d,validation:w,name:M,readOnly:o,registerControlRef:ne,registerInputRef:re,required:s,setCheckedValue:R,setTouched:L,touched:I}),[P,j,d,w,C,M,o,ne,re,s,R,L,I]),ae={id:m,role:`radiogroup`,"aria-required":s||void 0,"aria-disabled":j||void 0,"aria-readonly":o||void 0,"aria-labelledby":ie,onFocus(){y(!0)},onBlur(e){h(e.currentTarget,e.relatedTarget)||(v(!0),y(!1),b===`onBlur`&&w.commit(P))},onKeyDownCapture(e){e.key.startsWith(`Arrow`)&&(L(!0),y(!0))}};return(0,$.jsx)(Lr.Provider,{value:G,children:(0,$.jsx)(Rt,{render:n,className:r,style:g,state:W,props:[ae,_,e=>w.getValidationProps(j??!1,e)],refs:[t],stateAttributesMapping:se,enableHomeAndEndKeys:!1,modifierKeys:zr})})}),Vr=function(e){return e.checked=`data-checked`,e.unchecked=`data-unchecked`,e.disabled=`data-disabled`,e.readonly=`data-readonly`,e.required=`data-required`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({}),Hr={checked(e){return e?{[Vr.checked]:``}:{[Vr.unchecked]:``}},...v,...se},Ur=Q.createContext(void 0),Wr=Q.forwardRef(function(e,t){let{render:n,className:r,disabled:o=!1,readOnly:c=!1,required:u=!1,"aria-labelledby":d,value:f,inputRef:m,nativeButton:h=!1,id:g,style:_,...v}=e,y=Rr(),{disabled:b,readOnly:x,required:S,form:C,checkedValue:w,touched:T=!1,validation:E,name:D}=y??{},k=y?.setCheckedValue??j,P=y?.setTouched??j,F=y?.registerControlRef??j,I=y?.registerInputRef??j,{setTouched:R,setFilled:z,state:B,disabled:V}=Y(),H=Tt(),{labelId:ne,getDescriptionProps:re}=de(),ie=V||H.disabled||b||o,W=x||c,G=S||u,ae=C,K=y?w===f:f===``,q=Q.useRef(null),J=Q.useRef(null),se=A(e=>{e&&F(e,ie)}),ce=te(m,J,I);N(()=>{J.current?.checked&&z(!0)},[z]),N(()=>{if(J.current){if(ie&&K){I(null);return}q.current&&F(q.current,ie),I(J.current)}},[K,ie,F,I]);let le=a(),ue=U({id:g,implicit:!1,controlRef:q}),fe=h?void 0:ue,pe=Le(d,ne,J,!h,fe),me={role:`radio`,"aria-checked":K,"aria-required":G||void 0,"aria-readonly":W||void 0,"aria-labelledby":pe,[Lt]:K?``:void 0,id:h?ue:le,onKeyDown(e){e.key===`Enter`&&e.preventDefault()},onClick(e){if(e.defaultPrevented||ie||W)return;e.preventDefault();let t=J.current;t&&t.dispatchEvent(new(O(t)).PointerEvent(`click`,{bubbles:!0,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey}))},onFocus(e){e.defaultPrevented||ie||W||!T||(J.current?.click(),P(!1))}},{getButtonProps:he,buttonRef:ge}=M({disabled:ie,native:h,composite:!1}),_e={type:`radio`,ref:ce,form:ae,id:fe,name:D,tabIndex:-1,style:D?l:p,"aria-hidden":!0,...f===void 0?L:{value:oe(f)},disabled:ie,checked:K,required:G,readOnly:W,onChange(e){if(e.nativeEvent.defaultPrevented||ie||W||f===void 0)return;let t=i(s,e.nativeEvent);k(f,t),!t.isCanceled&&R(!0)},onFocus(){q.current?.focus()}},ve=Q.useMemo(()=>({...B,required:G,disabled:ie,readOnly:W,checked:K}),[B,ie,W,K,G]),ye=ve,be=y!==void 0,xe=[t,q,ge,se],Se=[me,v,he,re,E?e=>E.getValidationProps(ie,e):L],Ce=ee(`span`,e,{enabled:!be,state:ve,ref:xe,props:Se,stateAttributesMapping:Hr});return(0,$.jsxs)(Ur.Provider,{value:ye,children:[be?(0,$.jsx)(Re,{tag:`span`,render:n,className:r,style:_,state:ve,refs:xe,props:Se,stateAttributesMapping:Hr}):Ce,(0,$.jsx)(`input`,{..._e,suppressHydrationWarning:!0})]})}),Gr=[];function Kr(e){let{allValues:t=Gr,value:n=Gr,onValueChange:r}=e,i=Q.useRef(n),o=Q.useRef(new Map),[s,c]=Q.useState(`mixed`),l=a(),u=n.length===t.length,d=n.length!==t.length&&n.length>0,f=A(r),p=Q.useCallback(()=>({id:l,indeterminate:d,checked:u,"aria-controls":t.map(e=>`${l}-${e}`).join(` `),onCheckedChange(e,r){let a=i.current,l=t.filter(e=>o.current.get(e)&&a.includes(e)),u=t.filter(e=>!o.current.get(e)||o.current.get(e)&&a.includes(e));if(a.length===u.length||a.length===0){n.length===u.length?f(l,r):f(u,r);return}let d=`mixed`,p=a;s===`mixed`?(d=`on`,p=u):s===`on`&&(d=`off`,p=l),f(p,r),r.isCanceled||c(d)}}),[t,u,l,d,f,s,n.length]),m=Q.useCallback(e=>({checked:n.includes(e),onCheckedChange(t,r){let a=n.slice();t?a.push(e):a.splice(a.indexOf(e),1),f(a,r),r.isCanceled||(i.current=a,c(`mixed`))}}),[f,n]);return Q.useMemo(()=>({id:l,indeterminate:d,getParentProps:p,getChildProps:m,disabledStatesRef:o}),[l,d,p,m])}var qr=Q.forwardRef(function(e,t){let{allValues:n,className:r,defaultValue:i,disabled:o=!1,id:s,onValueChange:c,render:l,value:u,style:d,...f}=e,{disabled:p,name:m,state:h,validation:g,setFilled:_,setDirty:v,validityData:y}=Y(),{labelId:b,getDescriptionProps:x}=de(),{clearErrors:S}=pe(),C=p||o,w=Q.useMemo(()=>{if(u===void 0)return i??[]},[u,i]),[T,E]=B({controlled:u,default:w,name:`CheckboxGroup`,state:`value`}),D=A((e,t)=>{c?.(e,t),!t.isCanceled&&E(e)}),O=Kr({allValues:n,value:T,onValueChange:D}),k=a(s),j=Q.useRef(null),M=Q.useCallback(e=>{j.current==null&&e!=null&&!e.hasAttribute(`data-parent`)&&(j.current=e)},[]);ce(j,k,T,void 0,!!m&&!C,m);let N=T??I;le(N,()=>{m&&S(m);let e=Array.isArray(y.initialValue)?y.initialValue:I;_(N.length>0),v(!G(N,e)),g.change(N)});let P={...h,disabled:C},F=Q.useMemo(()=>({allValues:n,value:T,defaultValue:w,setValue:D,parent:O,disabled:C,validation:g,registerControlRef:M}),[n,T,w,D,O,C,g,M]),L=ee(`div`,e,{state:P,ref:t,props:[{id:s,role:`group`,"aria-labelledby":b},f,x],stateAttributesMapping:se});return(0,$.jsx)(xt.Provider,{value:F,children:L})}),Jr=function(e){let t=a(),n=e.controlId===void 0?t:e.controlId,[r,i]=Q.useState(n),[o,s]=Q.useState(e.labelId),[c,l]=Q.useState([]),u=z(()=>new Map),{messageIds:d}=de(),f=A((e,t)=>{let n=u.current;if(t===void 0){n.delete(e);return}n.set(e,t),i(e=>{if(n.size===0)return;let t;for(let r of n.values()){if(e!==void 0&&r===e)return e;t===void 0&&(t=r)}return t})}),p=Q.useCallback(e=>{let t=e[`aria-describedby`]?e[`aria-describedby`].split(` `):[];return t.push(...d,...c),{...e,"aria-describedby":Array.from(new Set(t)).join(` `)||void 0}},[d,c]),m=Q.useMemo(()=>({controlId:r,registerControlId:f,labelId:o,setLabelId:s,messageIds:c,setMessageIds:l,getDescriptionProps:p}),[r,f,o,s,c,l,p]);return(0,$.jsx)(ue.Provider,{value:m,children:e.children})};function Yr(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}var Xr=Object.keys(fe);function Zr(e){if(!e||e.valid||!e.valueMissing)return!1;let t=!1;for(let n of Xr)n!==`valid`&&(n===`valueMissing`?t=e[n]:e[n]&&(t=!1));return t}function Qr(e){let t=null;for(let n of e)if(!n.disabled){if(!n.validity.valid)return n;t??=n}return t}function $r(e,t){let n=!1;for(let r of t)r.setCustomValidity(``),n||=r===e;n||e.setCustomValidity(``)}function ei(e){let{formRef:t}=pe(),{setValidityData:n,validate:r,validityData:i,validationDebounceTime:a,invalid:s,markedDirtyRef:c,state:l,shouldValidateOnChange:u,getRegisteredFieldId:d}=e,{controlId:f,getDescriptionProps:p}=de(),m=o(),h=Q.useRef(null),g=z(()=>new Set).current,_=Q.useRef(0),v=Q.useCallback(e=>{if(e)return g.add(e),()=>{g.delete(e)}},[g]),y=A(async(e,a=!1)=>{let o=Qr(g)??h.current;if(!o)return;_.current+=1;let p=_.current;function v(e,n=s){let r=d()??f;if(r==null)return;let i=t.current.fields.get(r);if(!i)return;let a=Yr(e,n);t.current.fields.set(r,{...i,validityData:a})}if(a){if(l.valid!==!1)return;let t=o.validity;if(!t.valueMissing){let t={value:e,state:{...fe,valid:!0},error:``,errors:[],initialValue:i.initialValue};$r(o,g),v(t,!1),n(t);return}let r=Xr.reduce((e,n)=>(e[n]=t[n],e),{});if(!r.valid&&!Zr(r))return}function y(e){let t=Xr.reduce((t,n)=>(t[n]=e.validity[n],t),{}),n=!1;for(let e of Xr)if(e!==`valid`){if(e===`valueMissing`&&t[e])n=!0;else if(t[e])return t}return n&&!c.current&&(t.valid=!0,t.valueMissing=!1),t}m.clear();let b=null,x=[],S=y(o),C,w=u();if(o.validationMessage&&!w)C=o.validationMessage,x=[o.validationMessage];else{let n=r(e,Array.from(t.current.fields.values()).reduce((e,t)=>(t.name&&(e[t.name]=t.getValue()),e),{}));if(typeof n==`object`&&n&&`then`in n){if(b=await n,p!==_.current)return}else b=n;b===null?w&&($r(o,g),S.customError=!1,o.validationMessage?(C=o.validationMessage,x=[o.validationMessage]):o.validity.valid&&!S.valid&&(S.valid=!0)):(S.valid=!1,S.customError=!0,Array.isArray(b)?(x=b,o.setCustomValidity(b.join(`
|
|
2
|
+
`))):b&&(x=[b],o.setCustomValidity(b)))}let T={value:e,state:S,error:C??(Array.isArray(b)?b[0]:b??``),errors:x,initialValue:i.initialValue};v(T),n(T)}),b=A(e=>{m.clear();let t=u();t&&e!==``&&a?(_.current+=1,m.start(a,()=>{y(e)})):y(e,!t)}),x=Q.useCallback((e,t={})=>P(p(t),l.valid===!1&&!l.disabled&&!e?{"aria-invalid":!0}:L),[p,l.disabled,l.valid]);return Q.useMemo(()=>({getValidationProps:x,inputRef:h,registerInput:v,commit:y,change:b}),[x,v,y,b])}function ti(e){let{commit:t,invalid:n,markedDirtyRef:r,name:i,setRegisteredFieldName:a,setRegisteredFieldId:o,setValidityData:s,validityData:c}=e,{formRef:l}=pe(),u=Q.useRef(null),d=Q.useRef(null),f=Q.useRef(null),p=A(()=>{let e=d.current;if(e)return e.getValue?e.getValue():e.value});function m(e){return e.value===void 0?p():e.value}let h=A(()=>{let e=d.current;if(r.current=!0,!e){t(c.value);return}t(m(e))});function g(){let e=d.current;!e||!e.id||l.current.fields.set(e.id,{getValue:p,name:i??e.name,controlRef:e.controlRef??f,validityData:Yr(c,n),validate:h})}function _(e=d.current?.id){e&&l.current.fields.delete(e)}function v(){let e=d.current;if(!e)return;let t=m(e);c.initialValue===null&&t!==null&&s(e=>({...e,initialValue:t}))}return N(()=>{let e=d.current;!e||!e.id||(a(i?void 0:e.name),l.current.fields.set(e.id,{getValue:p,name:i??e.name,controlRef:e.controlRef??f,validityData:Yr(c,n),validate:h}))},[l,p,n,i,a,h,c]),N(()=>{let e=l.current.fields;return()=>{let t=d.current?.id;t&&e.delete(t)}},[l]),[h,A((e,t)=>{if(!t){u.current===e&&(u.current=null,_(),d.current=null,a(void 0),o(void 0));return}let n=d.current?.id;u.current=e,d.current=t,i||a(t.name),o(t.id),n&&n!==t.id&&_(n),v(),g()})]}var ni=Q.forwardRef(function(e,t){let{errors:n,validationMode:r,submitAttemptedRef:i}=pe(),{render:a,className:o,validate:s,validationDebounceTime:c=0,validationMode:l=r,name:u,disabled:d=!1,invalid:f,dirty:p,touched:m,actionsRef:h,style:g,..._}=e,v=Ir(!0)?.disabled,y=A(s||(()=>null)),b=v||d,[x,S]=Q.useState(!1),[C,w]=Q.useState(!1),[T,E]=Q.useState(!1),[D,O]=Q.useState(!1),k=p??C,j=m??x,M=Q.useRef(k),P=Q.useRef(void 0),[F,I]=Q.useState(),L=u??F;N(()=>{p!==void 0&&(M.current=p)},[p]);let R=Q.useCallback(()=>P.current,[]),te=Q.useCallback(e=>{P.current=e},[]),z=A(e=>{p===void 0&&(e&&(M.current=!0),w(e))}),B=A(e=>{m===void 0&&S(e)}),V=A(()=>l===`onChange`||l===`onSubmit`&&i.current),H=L&&Object.hasOwn(n,L)?n[L]:null,ne=!!(Array.isArray(H)?H.length:H),re=f===!0||ne,[U,ie]=Q.useState({state:fe,error:``,errors:[],value:null,initialValue:null}),W=b?null:!re&&U.state.valid,G=Q.useMemo(()=>({disabled:b,touched:j,dirty:k,valid:W,filled:T,focused:D}),[b,j,k,W,T,D]),ae=ei({setValidityData:ie,validate:y,validityData:U,validationDebounceTime:c,invalid:re,markedDirtyRef:M,state:G,shouldValidateOnChange:V,getRegisteredFieldId:R}),[K,oe]=ti({commit:ae.commit,invalid:re,markedDirtyRef:M,name:u,setRegisteredFieldName:I,setRegisteredFieldId:te,setValidityData:ie,validityData:U});Q.useImperativeHandle(h,()=>({validate:K}),[K]);let q=Q.useMemo(()=>({invalid:re,name:L,validityData:U,setValidityData:ie,disabled:b,touched:j,setTouched:B,dirty:k,setDirty:z,filled:T,setFilled:E,focused:D,setFocused:O,validate:y,validationMode:l,validationDebounceTime:c,shouldValidateOnChange:V,state:G,markedDirtyRef:M,registerFieldControl:oe,validation:ae}),[re,L,U,b,j,B,k,z,T,E,D,O,y,l,c,V,G,oe,ae]),ce=ee(`div`,e,{ref:t,state:G,props:_,stateAttributesMapping:se});return(0,$.jsx)(J.Provider,{value:q,children:ce})}),ri=Q.forwardRef(function(e,t){return(0,$.jsx)(Jr,{children:(0,$.jsx)(ni,{...e,ref:t})})}),ii={...se,...v},ai=Q.forwardRef(function(e,t){let{render:r,id:i,className:o,match:s,style:c,...l}=e,u=a(i),{validityData:d,state:f,name:p}=Y(!1),{setMessageIds:h}=de(),{errors:g}=pe(),_=p&&Object.hasOwn(g,p)?g[p]:null,v=!!(Array.isArray(_)?_.length:_),y=typeof s==`string`,b=!1;b=s===!0?!0:f.disabled?!1:y?!!d.state[s]:v||d.state.valid===!1;let{mounted:x,transitionStatus:S,setMounted:C}=m(b);N(()=>{if(!(!b||!u))return h(e=>e.concat(u)),()=>{h(e=>e.filter(e=>e!==u))}},[b,u,h]);let w=Q.useRef(null),[T,E]=Q.useState(null),[D,O]=Q.useState(null),k=d.error;!y&&v?k=_:d.errors.length>1&&(k=d.errors);let A=k??``;Array.isArray(k)&&(A=k.length>1?(0,$.jsx)(`ul`,{children:k.map(e=>(0,$.jsx)(`li`,{children:e},e))}):k[0]??``);let j=Array.isArray(k)?JSON.stringify(k):k;b&&j!==D&&(O(j),E(A)),n({open:b,ref:w,onComplete(){b||C(!1)}});let M={...f,transitionStatus:S},P=ee(`div`,e,{ref:[t,w],state:M,props:[{id:u,children:b?A:T},l],stateAttributesMapping:ii,enabled:x});return x?P:null}),oi=Q.forwardRef(function(e,t){let{render:n,className:r,id:a,name:o,value:c,disabled:l=!1,onValueChange:u,defaultValue:d,autoFocus:f=!1,style:p,...m}=e,{state:h,name:g,disabled:v,setTouched:b,setDirty:x,validityData:S,setFocused:C,setFilled:w,validationMode:T,validation:E}=Y(),{clearErrors:D}=pe(),O=v||l,k=g??o,j={...h,disabled:O},{labelId:M}=de(),P=U({id:a});N(()=>{let e=c!=null;E.inputRef.current?.value||e&&c!==``?w(!0):e&&c===``&&w(!1)},[E.inputRef,w,c]);let F=Q.useRef(null);N(()=>{f&&F.current===y(_(F.current))&&C(!0)},[f,C]);let[I]=B({controlled:c,default:d,name:`FieldControl`,state:`value`}),L=c!==void 0,R=L?I:void 0,te=A(()=>E.inputRef.current?.value);return ce(E.inputRef,P,R,te,!O,o),ee(`input`,e,{ref:[t,F],state:j,props:[{id:P,disabled:O,name:k,ref:E.inputRef,"aria-labelledby":M,autoFocus:f,...L?{value:R}:{defaultValue:d},onChange(e){let t=e.currentTarget.value;u?.(t,i(s,e.nativeEvent)),x(t!==S.initialValue),w(t!==``),e.nativeEvent.defaultPrevented||(D(k),E.change(t))},onFocus(){C(!0)},onBlur(e){b(!0),C(!1),T===`onBlur`&&E.commit(e.currentTarget.value)},onKeyDown(e){e.currentTarget.tagName===`INPUT`&&e.key===`Enter`&&(b(!0),E.commit(e.currentTarget.value))}},m,e=>E.getValidationProps(O,e)],stateAttributesMapping:se})}),si=typeof window<`u`?Q.useLayoutEffect:Q.useEffect,ci=x.moderate,li=.07,ui=(ci.duration+li)*1e3+80,di=ci.duration*1e3+80;function fi(e,t){let n=t.filter(t=>t.start>=e.start&&t.end<=e.end).sort((e,t)=>e.start-t.start);if(n.length!==2)return null;let[r,i]=n;return i.start===r.end+2?{up:r,lo:i,gap:r.end+1}:null}function pi(e,t,n,r){let i=n[e],a=n[t];if(!i||!a)return null;if(r===`y`)return{top:i.top,left:Math.min(i.left,a.left),width:Math.max(i.width,a.width),height:a.top+a.height-i.top};let o=Math.min(i.left,a.left),s=Math.max(i.left+i.width,a.left+a.width);return{top:Math.min(i.top,a.top),left:o,width:s-o,height:Math.max(i.height,a.height)}}function mi(e,t){return t===`y`?e.top+e.height/2:e.left+e.width/2}function hi(e,t){return t===`y`?[e,e,0,0]:[e,0,0,e]}function gi(e,t){return t===`y`?[0,0,e,e]:[0,e,e,0]}function _i(e){return[e,e,e,e]}function vi(e,t,n,r,i){let a=mi(n,r);if(r===`y`){let n=t.top+t.height;e.height=a-e.top,e.radii=hi(i,r),e.instant=!0,t.top=a,t.height=n-a,t.radii=gi(i,r),t.instant=!0,t.enterFrom={top:a,left:t.left,width:t.width,height:n-a,radii:gi(i,r)};return}let o=t.left+t.width;e.width=a-e.left,e.radii=hi(i,r),e.instant=!0,t.left=a,t.width=o-a,t.radii=gi(i,r),t.instant=!0,t.enterFrom={top:t.top,left:a,width:o-a,height:t.height,radii:gi(i,r)}}function yi(e,t,n,r=`y`){let[i,a]=(0,Q.useState)([]),o=(0,Q.useRef)([]),s=(0,Q.useRef)(0),c=(0,Q.useRef)(new Map);si(()=>{let t=o.current,n=e,r=[];for(let e of n){let n=fi(e,t);n&&(e.id===n.up.id||e.id===n.lo.id)&&r.push({tid:++s.current,kind:`merge`,survivorId:e.id,otherId:e.id===n.up.id?n.lo.id:n.up.id,gapIndex:n.gap,phase:`converge`})}for(let e of t){let t=fi(e,n);t&&r.push({tid:++s.current,kind:`split`,survivorId:t.up.id,otherId:t.lo.id,gapIndex:t.gap,phase:`splitIn`})}o.current=n.map(e=>({...e}));for(let e of r)c.current.set(e.tid,setTimeout(()=>{c.current.delete(e.tid),a(t=>t.some(t=>t.tid===e.tid)?t.flatMap(t=>t.tid===e.tid?t.kind===`merge`?[{...t,phase:`commit`}]:[]:[t]):t)},e.kind===`merge`?ui:di));let i=e=>e.kind===`merge`?n.some(t=>t.id===e.survivorId&&e.gapIndex>t.start&&e.gapIndex<t.end):n.some(t=>t.id===e.survivorId&&t.end===e.gapIndex-1)&&n.some(t=>t.id===e.otherId&&t.start===e.gapIndex+1);a(e=>{for(let t of e){if(i(t))continue;let e=c.current.get(t.tid);e!==void 0&&(clearTimeout(e),c.current.delete(t.tid))}return[...e.filter(i),...r]})},[e.map(e=>`${e.id}:${e.start}-${e.end}`).join(`|`)]),(0,Q.useEffect)(()=>{let e=c.current;return()=>e.forEach(clearTimeout)},[]),(0,Q.useEffect)(()=>{i.some(e=>e.phase===`splitIn`||e.phase===`commit`)&&a(e=>e.flatMap(e=>e.phase===`commit`?[]:[{...e,phase:e.phase===`splitIn`?`diverge`:e.phase}]))},[i]);let l=[];for(let i of e){let e=pi(i.start,i.end,t,r);e&&l.push({key:`sel-${i.id}`,...e,radii:_i(n),instant:!1,exitInstant:!1,delayCorners:!1})}let u=new Map(l.map(e=>[e.key,e]));for(let e of i){let i=t[e.gapIndex],a=u.get(`sel-${e.survivorId}`);if(!i||!a)continue;let o=mi(i,r);if(e.kind===`merge`){if(e.phase===`commit`){a.instant=!0,r===`y`?l.push({key:`sel-${e.otherId}`,top:o,left:a.left,width:a.width,height:a.top+a.height-o,radii:gi(n,r),instant:!0,exitInstant:!0,delayCorners:!1,opacity:0}):l.push({key:`sel-${e.otherId}`,top:a.top,left:o,width:a.left+a.width-o,height:a.height,radii:gi(n,r),instant:!0,exitInstant:!0,delayCorners:!1,opacity:0});continue}let t=Math.min(.1,Math.max(li,li+o/Math.max(r===`y`?i.height:i.width,1)*.002));if(r===`y`){let i=a.top+a.height;a.height=o-a.top,a.radii=hi(n,r),a.delayCorners=!0,a.cornerDelay=t,l.push({key:`sel-${e.otherId}`,top:o,left:a.left,width:a.width,height:i-o,radii:gi(n,r),enterFrom:{top:o,left:a.left,width:a.width,height:i-o,radii:_i(n)},instant:!1,exitInstant:!0,delayCorners:!0,cornerDelay:t})}else{let i=a.left+a.width;a.width=o-a.left,a.radii=hi(n,r),a.delayCorners=!0,a.cornerDelay=t,l.push({key:`sel-${e.otherId}`,top:a.top,left:o,width:i-o,height:a.height,radii:gi(n,r),enterFrom:{top:a.top,left:o,width:i-o,height:a.height,radii:_i(n)},instant:!1,exitInstant:!0,delayCorners:!0,cornerDelay:t})}}else if(e.phase===`splitIn`){let t=u.get(`sel-${e.otherId}`);if(!t)continue;vi(a,t,i,r,n)}}for(let i of o.current){let a=fi(i,e),o=a&&t[a.gap];if(!a||!o)continue;let s=u.get(`sel-${a.up.id}`),c=u.get(`sel-${a.lo.id}`);!s||!c||vi(s,c,o,r,n)}return l}function bi({blocks:e,dimmed:t}){return(0,$.jsx)(ne,{children:e.map(e=>{let n=e.delayCorners?{...ci,delay:e.cornerDelay??li}:ci,r=e.opacity??(t?.8:1);return(0,$.jsx)(f.div,{"aria-hidden":!0,className:`absolute bg-active pointer-events-none`,initial:e.enterFrom?{opacity:r,top:e.enterFrom.top,left:e.enterFrom.left,width:e.enterFrom.width,height:e.enterFrom.height,borderTopLeftRadius:e.enterFrom.radii[0],borderTopRightRadius:e.enterFrom.radii[1],borderBottomRightRadius:e.enterFrom.radii[2],borderBottomLeftRadius:e.enterFrom.radii[3]}:!1,animate:{top:e.top,left:e.left,width:e.width,height:e.height,borderTopLeftRadius:e.radii[0],borderTopRightRadius:e.radii[1],borderBottomRightRadius:e.radii[2],borderBottomLeftRadius:e.radii[3],opacity:r},exit:{opacity:0,transition:e.exitInstant?{duration:0}:ci.exit},transition:e.instant?{duration:0}:{...ci,borderTopLeftRadius:n,borderTopRightRadius:n,borderBottomRightRadius:n,borderBottomLeftRadius:n,opacity:{duration:.08}}},e.key)})})}function xi(e,t){return e.id??`q-${t}`}function Si(e,t){return e.id??`o-${t}`}var Ci=[],wi=(0,Q.forwardRef)(function({questions:e,currentIndex:t,defaultCurrentIndex:n=0,onCurrentIndexChange:r,answers:i,defaultAnswers:a,onAnswersChange:o,onComplete:s,onSkip:c,skipLabel:l=`Skip`,intro:d,onCancel:p,cancelLabel:m=`Cancel`,footerLeading:h,className:g,..._},v){let[y,b]=(0,Q.useState)(n),S=t!==void 0,C=S?t:y,w=(0,Q.useCallback)(e=>{S||b(e),r?.(e)},[S,r]),[T,E]=(0,Q.useState)(a??{}),O=i!==void 0,A=O?i:T,ee=(0,Q.useRef)(A);(0,Q.useEffect)(()=>{ee.current=A},[A]);let j=(0,Q.useCallback)(e=>{let t=e(ee.current);return ee.current=t,O||E(t),o?.(t),t},[O,o]),M=k(),N=et(`arrow-left`),P=et(`arrow-right`),F=(0,Q.useMemo)(()=>function(e){return(0,$.jsx)(N,{...e,className:D(e.className,`hidden sm:block`)})},[N]),I=(0,Q.useMemo)(()=>function(e){return(0,$.jsx)(P,{...e,className:D(e.className,`hidden sm:block`)})},[P]),[L]=(0,Q.useState)(()=>{if(typeof navigator>`u`)return!1;let e=navigator,t=e.userAgentData?.platform||e.platform||``;return/mac/i.test(t)}),te=(0,Q.useId)(),z=e.length,B=Math.max(0,Math.min(C,Math.max(0,z-1))),V=e[B],H=V?xi(V,B):``,re=A[H],U=!!V?.multiSelect,ie=V?.skippable!==!1,W=!!V?.freeText,G=V?.freeTextMultiline!==!1,K=!W&&!!V?.allowOther,oe=(0,Q.useMemo)(()=>re?.selectedIds??[],[re]),q=re?.otherText??``,J=V?.options??[],se=K?J.length:-1,ce=J.length+ +!!K,le=(0,Q.useRef)(null),ue=!!V;(0,Q.useEffect)(()=>{if(!ue)return;let e=le.current;if(e)return Ci.push(e),()=>{let t=Ci.indexOf(e);t!==-1&&Ci.splice(t,1)}},[ue]);let Y=(0,Q.useRef)(null),de=(0,Q.useRef)(null),fe=(0,Q.useRef)(0),pe=(0,Q.useRef)(new Map),{activeIndex:me,setActiveIndex:he,itemRects:ge,sessionRef:_e,handlers:ve,registerItem:ye,measureItems:be}=ae(Y);(0,Q.useEffect)(()=>{be()},[be,H,ce,M]);let[xe,Se]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{Se(!1)},[H]),(0,Q.useEffect)(()=>{let e=de.current;if(!e)return;e.style.height=`0px`,e.style.height=`${e.scrollHeight}px`;let t=parseFloat(window.getComputedStyle(e).lineHeight)||18;Se(e.scrollHeight>t*1.5),be()},[q,be,H]),(0,Q.useEffect)(()=>{W&&de.current?.focus({preventScroll:!0})},[W,H]);let Ce=(0,Q.useRef)(null),[we,Te]=(0,Q.useState)(`auto`);(0,Q.useEffect)(()=>{let e=Ce.current;if(!e)return;let t=()=>Te(e.offsetHeight);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let[Ee,De]=(0,Q.useState)(null),[Oe,ke]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{he(null),De(null),ke(null)},[B,he]);let Ae=(0,Q.useRef)(!1),je=(0,Q.useCallback)(()=>{Y.current?.contains(document.activeElement)&&(Ae.current=!0)},[]);(0,Q.useEffect)(()=>{Ae.current&&(Ae.current=!1,(Y.current?.querySelector(`[data-proximity-index="0"]`))?.focus())},[B]);let Me=(0,Q.useCallback)(e=>{B>=z-1?s?.(e):(je(),w(B+1))},[B,z,s,w,je]),Ne=(0,Q.useCallback)(e=>{if(!V)return;let t=ee.current[H]?.otherText;Me(j(n=>({...n,[H]:{questionId:H,selectedIds:[e],otherText:t||void 0,skipped:!1}})))},[V,H,j,Me]),Pe=(0,Q.useCallback)(e=>{V&&j(t=>{let n=t[H],r=new Set(n?.selectedIds??[]);return r.has(e)?r.delete(e):r.add(e),{...t,[H]:{questionId:H,selectedIds:Array.from(r),otherText:n?.otherText,skipped:!1}}})},[V,H,j]),Fe=(0,Q.useCallback)(e=>{V&&j(t=>({...t,[H]:{questionId:H,selectedIds:e,otherText:t[H]?.otherText,skipped:!1}}))},[V,H,j]),Ie=(0,Q.useCallback)(e=>{V&&(ke(null),j(t=>({...t,[H]:{questionId:H,selectedIds:t[H]?.selectedIds??[],otherText:e,skipped:!1}})))},[V,H,j]),Le=(0,Q.useCallback)(()=>{if(!V)return;let e=(ee.current[H]?.otherText??``).trim();if(e){if(V.freeText&&V.freeTextValidate){let t=V.freeTextValidate(e);if(t){ke(t);return}}ke(null),Me(j(t=>({...t,[H]:{questionId:H,selectedIds:t[H]?.selectedIds??[],otherText:e,skipped:!1}})))}},[V,H,j,Me]),Re=(0,Q.useCallback)(()=>{if(!V)return;let e=j(e=>({...e,[H]:{questionId:H,selectedIds:e[H]?.selectedIds??[],otherText:e[H]?.otherText,skipped:!0}}));c?.(H,B),Me(e)},[V,H,j,c,B,Me]),ze=(0,Q.useCallback)(()=>{p?.()},[p]),Be=(0,Q.useCallback)(()=>{Me(A)},[Me,A]),Ve=(0,Q.useCallback)(()=>{B>0&&(je(),w(B-1))},[B,w,je]);(0,Q.useEffect)(()=>{if(!V)return;let e=e=>{if(e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target;if(!t)return;let n=t.tagName;if(n===`INPUT`||n===`TEXTAREA`||t.isContentEditable)return;let r=le.current;if(!r||!r.contains(t)&&(Ci.some(e=>e!==r&&e.contains(t))||Ci[Ci.length-1]!==r))return;let i=e.key;if(i<`1`||i>`9`)return;let a=parseInt(i,10)-1;if(a>=0&&a<J.length){e.preventDefault();let t=Si(J[a],a);U?Pe(t):Ne(t)}else a===J.length&&K&&(e.preventDefault(),de.current?.focus())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[V,J,U,K,Ne,Pe]);let He=e=>{(Y.current?.querySelector(`[data-proximity-index="${e}"]`))?.focus()},Ue=(0,Q.useCallback)(e=>{he(e),K&&e===se?de.current?.focus():He(e)},[K,se,he]),We=e=>{let t=e.target,n=t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable;if(n&&e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;if(n&&(e.key===`ArrowUp`||e.key===`ArrowDown`)&&t.tagName===`TEXTAREA`){let n=t;if(e.key===`ArrowUp`&&n.selectionStart>0||e.key===`ArrowDown`&&n.selectionEnd<n.value.length)return}let r=e.preventBaseUIHandler;if(e.key===`ArrowLeft`||e.key===`ArrowRight`){e.preventDefault(),e.stopPropagation(),r?.(),e.key===`ArrowLeft`?B>0&&Ve():ie&&z>1&&Re();return}if(ce!==0&&(e.key===`ArrowDown`||e.key===`ArrowUp`||e.key===`Home`||e.key===`End`)){e.preventDefault(),e.stopPropagation(),r?.();let t;if(e.key===`Home`)t=0;else if(e.key===`End`)t=ce-1;else{let r=n?se:me??-1;t=e.key===`ArrowDown`?r+1:r-1,t=(t+ce)%ce}Ue(t)}},Ge=e=>{if(e.key===`Enter`&&!(!(L?e.metaKey:e.ctrlKey)||!(U||W))){if(e.preventDefault(),W){q.trim().length>0&&Le();return}(oe.length>0||q.trim().length>0)&&Be()}};if(!V)return(0,$.jsx)(`div`,{ref:v,className:D(`w-full max-w-[520px] p-5 bg-card border border-border`,M.container,g),..._,children:(0,$.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`No questions.`})});let Ke=me===null?null:ge[me],qe=Ee!==null&&!(K&&Ee===se)?ge[Ee]:null,X=(0,Q.useMemo)(()=>{let e=new Set;return J.forEach((t,n)=>{oe.includes(Si(t,n))&&e.add(n)}),K&&q.length>0&&e.add(se),e},[J,oe,K,q,se]),Je=(0,Q.useMemo)(()=>{let e=[],t=[...X].sort((e,t)=>e-t);for(let n of t){let t=e[e.length-1];t&&n===t.end+1?t.end=n:e.push({start:n,end:n})}let n=new Set,r=new Map,i=e.map(e=>{let t=null;for(let r=e.start;r<=e.end;r++){let e=pe.current.get(r);if(e!==void 0&&!n.has(e)){t=e;break}}let i=t??++fe.current;n.add(i);for(let t=e.start;t<=e.end;t++)r.set(t,i);return{...e,id:i}});return pe.current=r,i},[X]),Ye=me!==null&&!X.has(me),Xe=yi(Je,ge,M.bgRadius),Ze=z>1&&B>0,Qe=p!=null,$e=!Qe&&z>1&&ie,Z=U||W,tt=Ze||$e||Z||Qe||h!=null,rt=J.findIndex((e,t)=>oe.includes(Si(e,t))),it=(0,$.jsxs)(`div`,{ref:Y,role:U?`group`:`radiogroup`,"aria-labelledby":`${te}-${H}-title`,onMouseEnter:ve.onMouseEnter,onMouseMove:ve.onMouseMove,onMouseLeave:ve.onMouseLeave,onFocus:e=>{let t=e.target.closest(`[data-proximity-index]`)?.getAttribute(`data-proximity-index`);if(t!=null){let n=Number(t);he(n),De(e.target.matches(`:focus-visible`)?n:null)}},onBlur:e=>{Y.current?.contains(e.relatedTarget)||(De(null),he(null))},onKeyDown:We,className:`relative flex flex-col gap-0.5 -mx-3`,children:[(0,$.jsx)(ne,{children:(()=>{if(!K)return null;let e=ge[se],t=Ee===se&&q.length===0;return!e||!t?null:(0,$.jsx)(f.div,{"aria-hidden":!0,className:D(`absolute pointer-events-none bg-card ring-1 ring-inset ring-border`,M.bg),initial:{opacity:0,top:e.top,left:e.left,width:e.width,height:e.height},animate:{opacity:1,top:e.top,left:e.left,width:e.width,height:e.height},exit:{opacity:0,transition:x.fast.exit},transition:{...x.fast,opacity:{duration:.08}}},`other-input`)})()}),(0,$.jsx)(ne,{children:Ke&&(0,$.jsx)(f.div,{"aria-hidden":!0,className:D(`absolute pointer-events-none bg-hover`,M.bg),initial:{opacity:0,top:Ke.top,left:Ke.left,width:Ke.width,height:Ke.height},animate:{opacity:1,top:Ke.top,left:Ke.left,width:Ke.width,height:Ke.height},exit:{opacity:0,transition:x.fast.exit},transition:{...x.fast,opacity:{duration:.08}}},`hover-${_e.current}`)}),(0,$.jsx)(bi,{blocks:Xe,dimmed:Ye}),(0,$.jsx)(ne,{children:qe&&(0,$.jsx)(f.div,{"aria-hidden":!0,className:D(`absolute pointer-events-none border border-[color:var(--focus-ring,#6B97FF)] z-20`,M.focusRing),initial:{opacity:0,top:qe.top-2,left:qe.left-2,width:qe.width+4,height:qe.height+4},animate:{opacity:1,top:qe.top-2,left:qe.left-2,width:qe.width+4,height:qe.height+4},exit:{opacity:0,transition:x.fast.exit},transition:{...x.fast,opacity:{duration:.08}}})}),J.map((e,t)=>{let n=Si(e,t),r=oe.includes(n),i=!U&&me===t;return(0,$.jsx)(Ei,{index:t,registerItem:ye,role:U?`checkbox`:`radio`,isSelected:r,tabIndex:t===rt||rt===-1&&t===0?0:-1,onClick:()=>U?Pe(n):Ne(n),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&!e.metaKey&&!e.ctrlKey&&(e.preventDefault(),U?Pe(n):Ne(n))},shape:M,"aria-checked":r,chipContent:t+1,chipFilled:r,isMulti:U,showArrow:i,bodyLayout:V.layout===`stacked`?`stacked`:`inline`,topAlign:V.layout===`stacked`,chipPosition:V.chipPosition??`right`,arrowIcon:(0,$.jsx)(P,{size:14,strokeWidth:2,className:`h-3.5 w-3.5`}),hiddenControl:U?(0,$.jsx)(nt,{name:n,className:`sr-only`,tabIndex:-1,"aria-hidden":!0}):(0,$.jsx)(Wr,{value:n,className:`sr-only`,tabIndex:-1,"aria-hidden":!0}),children:V.layout===`stacked`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{className:`inline-grid`,children:[(0,$.jsx)(`span`,{className:`col-start-1 row-start-1 invisible`,style:{fontVariationSettings:u.semibold},"aria-hidden":`true`,children:e.title}),(0,$.jsx)(`span`,{className:`col-start-1 row-start-1 text-foreground transition-[color,font-variation-settings] duration-80`,style:{fontVariationSettings:r?u.semibold:u.medium},children:e.title})]}),e.description&&(0,$.jsx)(`span`,{className:`text-[12px] text-muted-foreground leading-snug`,children:e.description})]}):(0,$.jsxs)(`span`,{children:[(0,$.jsxs)(`span`,{className:`inline-grid`,children:[(0,$.jsx)(`span`,{className:`col-start-1 row-start-1 invisible`,style:{fontVariationSettings:u.semibold},"aria-hidden":`true`,children:e.title}),(0,$.jsx)(`span`,{className:`col-start-1 row-start-1 text-foreground transition-[color,font-variation-settings] duration-80`,style:{fontVariationSettings:r?u.semibold:u.medium},children:e.title})]}),e.description&&(0,$.jsxs)($.Fragment,{children:[` `,(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.description})]})]})},n)}),K&&(0,$.jsx)(Ei,{index:se,registerItem:ye,role:null,isSelected:q.length>0,tabIndex:-1,onClick:()=>de.current?.focus(),shape:M,chipContent:se+1,chipFilled:q.length>0,isMulti:U,topAlign:xe,chipPosition:V.chipPosition??`right`,ariaLabel:V.otherPlaceholder??`Describe in your own words`,showArrow:!U&&(Ee===se||me===se)&&q.trim().length>0,arrowIcon:(0,$.jsx)(P,{size:14,strokeWidth:2,className:`h-3.5 w-3.5`}),onArrowClick:!U&&q.trim().length>0?Le:void 0,children:(0,$.jsx)(`span`,{className:`inline-grid w-full`,children:(0,$.jsx)(`textarea`,{ref:de,rows:1,value:q,placeholder:V.otherPlaceholder??`Describe in your own words…`,"aria-label":V.otherPlaceholder??`Describe in your own words`,onChange:e=>Ie(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.shiftKey||U||(e.preventDefault(),Le()))},onClick:e=>e.stopPropagation(),className:D(`col-start-1 row-start-1 block w-full bg-transparent border-0 p-0 m-0 outline-none resize-none overflow-hidden text-[13px] leading-snug text-foreground placeholder:text-muted-foreground`),style:{fontVariationSettings:u.medium}})})})]});return(0,$.jsxs)(`div`,{ref:e=>{le.current=e,typeof v==`function`?v(e):v&&(v.current=e)},className:D(`relative w-full max-w-[520px] overflow-hidden bg-card border border-border`,M.container,g),..._,onKeyDown:e=>{_.onKeyDown?.(e),Ge(e)},children:[(0,$.jsx)(`div`,{className:`flex items-center px-4 sm:px-5 pt-4 sm:pt-5 pb-2 text-[12px] text-muted-foreground`,children:(0,$.jsxs)(`span`,{children:[`Question `,B+1,` of `,z]})}),d!=null&&(0,$.jsx)(`div`,{className:`px-4 sm:px-5 pb-3 text-[13px] leading-snug text-muted-foreground`,children:d}),(0,$.jsxs)(ri,{invalid:Oe!==null,className:`contents`,children:[(0,$.jsx)(f.div,{animate:{height:we},initial:!1,transition:x.slow,className:`overflow-hidden`,children:(0,$.jsx)(`div`,{ref:Ce,className:D(`px-4 sm:px-5`,tt?`pb-1`:`pb-2.5 sm:pb-3`),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`h3`,{id:`${te}-${H}-title`,className:`text-[16px] text-foreground leading-snug`,style:{fontVariationSettings:u.semibold},children:V.title}),W?(0,$.jsx)(`div`,{onClick:()=>de.current?.focus(),className:D(`relative mt-1 -mx-3 px-3 py-2.5 cursor-text transition-colors`,G?`min-h-[76px]`:`min-h-10`,M.bg,q.length>0?`bg-active`:`hover:bg-hover focus-within:bg-card focus-within:ring-1 focus-within:ring-inset focus-within:ring-border`),children:(0,$.jsx)(oi,{value:q,onValueChange:Ie,render:(0,$.jsx)(`textarea`,{ref:de,rows:1,placeholder:V.freeTextPlaceholder??`Type your answer…`,"aria-labelledby":`${te}-${H}-title`,onKeyDown:e=>{e.key===`Enter`&&(e.shiftKey||e.metaKey||e.ctrlKey||G||(e.preventDefault(),Le()))},className:`block w-full bg-transparent border-0 p-0 m-0 outline-none resize-none overflow-hidden text-[13px] leading-snug text-foreground placeholder:text-muted-foreground`,style:{fontVariationSettings:u.medium}})})}):U?(0,$.jsx)(qr,{value:oe,onValueChange:Fe,render:it}):(0,$.jsx)(Br,{value:oe[0]??null,onValueChange:e=>{typeof e==`string`&&Ne(e)},render:it})]},H)})}),tt&&(0,$.jsx)(`div`,{className:`px-4 sm:px-5 pt-1 pb-2`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 -mx-2 sm:-mx-3`,children:[(0,$.jsxs)(`div`,{className:`relative flex flex-1 min-w-0 items-center gap-2`,children:[h!=null&&(0,$.jsx)(`div`,{className:`shrink-0 px-2 sm:px-3`,children:h}),(0,$.jsx)(ne,{mode:`popLayout`,initial:!1,children:Ze&&(0,$.jsx)(f.div,{layout:`position`,initial:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.85},transition:{...x.fast,opacity:{duration:.1}},children:(0,$.jsx)(R,{variant:`ghost`,size:`sm`,leadingIcon:F,onClick:Ve,className:`pl-3 sm:pl-[6px]`,children:`Back`})},`back`)}),Oe&&(0,$.jsx)(ai,{match:!0,render:(0,$.jsx)(f.p,{role:`alert`,initial:{opacity:0,y:-2},animate:{opacity:1,y:0},transition:{...x.fast,opacity:{duration:.12}},className:`min-w-0 px-2 sm:px-3 text-left text-[12px] leading-snug text-destructive`}),children:Oe},`ft-error`)]}),(0,$.jsx)(`div`,{className:`relative flex items-center gap-2`,children:(0,$.jsxs)(ne,{mode:`popLayout`,initial:!1,children:[Qe&&(0,$.jsx)(f.div,{layout:`position`,initial:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.85},transition:{...x.fast,opacity:{duration:.1}},children:(0,$.jsx)(R,{variant:`ghost`,size:`sm`,trailingIcon:I,onClick:ze,className:`pr-3 sm:pr-[6px]`,children:m})},`cancel`),$e&&(0,$.jsx)(f.div,{layout:`position`,initial:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.85},transition:{...x.fast,opacity:{duration:.1}},children:(0,$.jsx)(R,{variant:`ghost`,size:`sm`,trailingIcon:I,onClick:Re,className:`pr-3 sm:pr-[6px]`,children:l})},`skip`),Z&&(0,$.jsx)(f.div,{layout:`position`,initial:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.85},transition:{...x.fast,opacity:{duration:.1}},children:(0,$.jsx)(R,{variant:`primary`,size:`sm`,onClick:W?Le:Be,disabled:(W||oe.length===0)&&q.trim().length===0,className:`pr-3 sm:pr-[6px]`,children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[V.nextLabel??(B>=z-1?`Finish`:`Continue`),(0,$.jsx)(`span`,{className:`hidden sm:contents`,children:(0,$.jsxs)(Ti,{shape:M,tone:`inverted`,children:[L?`⌘`:`⌃`,`↵`]})})]})})},`continue`)]})})]})})]})]})});wi.displayName=`AskUserQuestions`;function Ti({children:e,tone:t=`muted`,shape:n}){return(0,$.jsx)(`kbd`,{"aria-hidden":!0,suppressHydrationWarning:!0,className:D(`inline-flex items-center justify-center gap-0.5 px-1 min-w-[18px] h-[18px] text-[11px] leading-none font-sans tracking-wide`,t===`inverted`?`bg-background/15 text-background`:`bg-foreground/10 text-muted-foreground`,n.bg),children:e})}function Ei({index:e,registerItem:t,role:n,isSelected:r,tabIndex:i,onClick:a,onKeyDown:o,shape:s,chipContent:c,chipFilled:l,isMulti:d,ariaLabel:p,showArrow:m,arrowIcon:h,onArrowClick:g,bodyLayout:_=`inline`,topAlign:v=!1,chipPosition:y=`right`,hiddenControl:b,children:S,...C}){let w=(0,Q.useRef)(null);(0,Q.useEffect)(()=>(t(e,w.current),()=>t(e,null)),[e,t]);let T=(0,$.jsx)(ne,{children:m&&(0,$.jsx)(f.span,{"aria-hidden":!g,role:g?`button`:void 0,onClick:g?e=>{e.stopPropagation(),g()}:void 0,className:D(`absolute inset-0 inline-flex items-center justify-center bg-foreground text-background`,s.bg,g&&`cursor-pointer`),initial:{opacity:0,scale:.6},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.6,transition:x.fast.exit},transition:{...x.fast,opacity:{duration:.08}},children:h})}),E=(0,$.jsxs)(`span`,{className:D(`shrink-0 w-7 h-7 relative inline-flex items-center justify-center`,v&&(_===`stacked`?`-mt-[1px]`:`-mt-[5px]`)),children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:D(`absolute inline-flex items-center justify-center w-5 h-5 text-[11px] transition-[opacity,font-variation-settings] duration-80`,d&&s.bg,d?l?`bg-foreground text-background`:`border border-border text-muted-foreground`:l?`text-foreground`:`text-muted-foreground`,y===`right`&&m&&`opacity-0`),style:{fontVariationSettings:l?u.semibold:u.medium},children:c}),y===`right`&&T]}),O=y===`left`&&!d&&(0,$.jsx)(`span`,{className:D(`shrink-0 w-7 h-7 relative inline-flex items-center justify-center`,v&&(_===`stacked`?`-mt-[1px]`:`-mt-[5px]`)),children:T});return(0,$.jsxs)(`div`,{ref:w,"data-proximity-index":e,"data-state":r?`checked`:`unchecked`,role:n??void 0,"aria-checked":n===`radio`||n===`checkbox`?!!C[`aria-checked`]:void 0,"aria-label":p,tabIndex:i,onMouseDown:e=>{let t=e.target.closest(`button:not([tabindex="-1"]), a[href], input, select, textarea, [tabindex]:not([tabindex="-1"])`);t&&t!==e.currentTarget||(e.preventDefault(),e.currentTarget.focus())},onClick:a,onKeyDown:o,className:D(`relative z-10 flex cursor-pointer select-none outline-none`,y===`left`?`gap-2`:`gap-3`,v?`items-start`:`items-center`,_===`stacked`?`min-h-14 py-2`:`min-h-10 py-1.5`,y===`left`?d?`pl-1.5 pr-3`:`pl-1.5 pr-1.5`:`pl-3 pr-1.5`,s.item),children:[y===`left`&&E,(0,$.jsx)(`span`,{className:D(`min-w-0 flex-1 text-[13px] leading-snug`,_===`stacked`?`flex flex-col gap-0.5`:`inline-flex items-center gap-0`),children:S}),y===`right`?E:O,b]})}function Di(e){if(e.mode===`url`&&`url`in e)return[{id:`__url_confirm__`,title:`Confirm completion`,layout:`stacked`,options:[{id:`confirmed`,title:`I've completed the required action`,description:e.url}],skippable:!1,nextLabel:`Confirm`}];let t=`requestedSchema`in e?e.requestedSchema:void 0;if(!t||t.type!==`object`||!t.properties)return[{id:`__freeform__`,title:`Your response`,freeText:!0,freeTextPlaceholder:`Type your response…`,skippable:!1}];let n=t.properties,r=t.required??[];return Object.entries(n).map(([e,t])=>{let n=t,i=r.includes(e),a=n.title||e,o=n.description,s=n.type||`string`,c=Qt(n),l=$t(n),u=Array.isArray(n.enum),d=s===`array`&&Array.isArray(n.items?.enum),f=s===`array`&&l.length>0,p={id:e,title:a,skippable:!i,layout:o&&o.length>60?`stacked`:`inline`};if(s===`boolean`)return{...p,options:[{id:`true`,title:`Yes`},{id:`false`,title:`No`}]};if(f||d){let e=f?l:n.items.enum.map(e=>({const:e,title:e}))??[];return{...p,multiSelect:!0,options:e.map(e=>({id:e.const,title:e.title||e.const}))}}if(c.length>0)return{...p,layout:`stacked`,options:c.map(e=>({id:e.const,title:e.title||e.const}))};if(u){let e=n.enum,t=n.enumNames;return{...p,options:e.map((e,n)=>({id:e,title:t?.[n]||e}))}}return s===`number`||s===`integer`?{...p,freeText:!0,freeTextMultiline:!1,freeTextPlaceholder:n.default===void 0?`Enter a number…`:String(n.default),freeTextValidate:e=>{let t=e.trim();if(!t)return i?`Required`:null;let n=s===`integer`?parseInt(t,10):parseFloat(t);return Number.isNaN(n)?`Enter a valid number`:null}}:s===`string`&&(n.format===`textarea`||(n.maxLength??0)>100)?{...p,freeText:!0,freeTextPlaceholder:n.default||`Type your answer…`}:{...p,freeText:!0,freeTextMultiline:!1,freeTextPlaceholder:n.default===void 0?`Type your answer…`:String(n.default),freeTextValidate:e=>!e.trim()&&i?`Required`:null}})}function Oi(e,t,n){if(n.mode===`url`)return{};let r=`requestedSchema`in n?n.requestedSchema:void 0,i=r?.type===`object`&&r.properties?r.properties:{},a={};for(let n of e){let e=n.id??``;if(e===`__freeform__`){let n=t[e]?.otherText?.trim();n&&(a.response=n);continue}let r=t[e];if(!r||r.skipped)continue;let o=i[e]?.type||`string`;if(n.freeText){let t=r.otherText?.trim()??``;if(!t)continue;a[e]=o===`number`||o===`integer`?o===`integer`?parseInt(t,10):parseFloat(t):t;continue}if(n.multiSelect){a[e]=r.selectedIds;continue}if(o===`boolean`){a[e]=r.selectedIds[0]===`true`;continue}r.selectedIds[0]!==void 0&&(a[e]=r.selectedIds[0])}return a}function ki(e,t,n){if(n.mode===`url`)return[];let r=`requestedSchema`in n?n.requestedSchema:void 0;return(r?.type===`object`?r.required??[]:[]).filter(n=>{let r=t[n];if(!r||r.skipped)return!0;let i=e.find(e=>e.id===n);return i?i.freeText?!r.otherText?.trim():(i.multiSelect,r.selectedIds.length===0):!0})}function Ai(e,t){if(t.mode===`url`)return{};let n=`requestedSchema`in t?t.requestedSchema:void 0,r=n?.type===`object`&&n.properties?n.properties:{},i={};for(let t of e){let e=t.id;if(!e||e.startsWith(`__`))continue;let n=r[e];if(!(!n||n.default===void 0)){if(t.freeText){i[e]={questionId:e,selectedIds:[],otherText:String(n.default),skipped:!1};continue}if(t.multiSelect&&Array.isArray(n.default)){i[e]={questionId:e,selectedIds:n.default.map(String),skipped:!1};continue}if(n.type===`boolean`){i[e]={questionId:e,selectedIds:[String(n.default)],skipped:!1};continue}i[e]={questionId:e,selectedIds:[String(n.default)],skipped:!1}}}return i}function ji({request:e,onApprove:t,onReject:n,testId:r=`inline-elicitation`,actionTestIdPrefix:i=`inline-elicitation`}){let[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(``),l=(0,Q.useMemo)(()=>Di(e.request),[e.request]),u=(0,Q.useMemo)(()=>Ai(l,e.request),[l,e.request]),d=(e.request.mode||`form`)===`url`,f=d&&`url`in e.request?e.request.url:void 0,p=(n,r)=>{o(!0),c(n),t(e.id,r)};return a?(0,$.jsxs)(`p`,{className:`text-sm text-muted-foreground`,"data-testid":`${r}-responded`,children:[`Elicitation `,s,` — the tool will continue executing.`]}):(0,$.jsx)(wi,{questions:l,defaultAnswers:u,onComplete:t=>{if(a)return;if(d){if(!t.__url_confirm__?.selectedIds.includes(`confirmed`)){pt.error(`Confirm you've completed the external action`);return}p(`accepted`,{action:`accept`});return}let n=ki(l,t,e.request);if(n.length>0){pt.error(`Missing required fields`,{description:`Please fill in: ${n.join(`, `)}`});return}p(`accepted`,{action:`accept`,content:Oi(l,t,e.request)})},intro:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`p`,{className:`text-foreground/90`,children:e.request.message}),d&&f&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border bg-muted/40 p-2`,children:[(0,$.jsx)(`code`,{className:`flex-1 text-xs font-mono break-all`,children:f}),(0,$.jsxs)(R,{size:`sm`,variant:`outline`,onClick:()=>window.open(f,`_blank`),"data-testid":`${i}-open-url`,children:[(0,$.jsx)(qe,{className:`h-3 w-3 mr-1`}),`Open`]})]})]}),onCancel:()=>n(e.id,`User cancelled elicitation request`),cancelLabel:`Cancel`,footerLeading:(0,$.jsx)(`button`,{type:`button`,className:`shrink-0 cursor-pointer text-[12px] text-muted-foreground underline-offset-2 hover:text-foreground hover:underline`,onClick:()=>p(`declined`,{action:`decline`}),"data-testid":`${i}-decline-button`,children:`Decline`}),className:`w-full max-w-none shadow-lg`,"data-testid":r})}function Mi({requests:e,onApprove:t,onReject:n}){return e.length===0?null:(0,$.jsx)(`div`,{className:`mb-3 space-y-3 pointer-events-auto`,"data-testid":`floating-elicitation-stack`,children:e.map(e=>(0,$.jsx)(f.div,{initial:{opacity:0,y:12,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:8,scale:.98},transition:x.moderate,children:(0,$.jsx)(ji,{request:e,onApprove:t,onReject:n})},e.id))})}var Ni=`You are a helpful assistant with access to MCP tools. Help users interact with the MCP server.`;function Pi(e){let t=e?.trim();return t?t!==Ni:!1}function Fi({value:e,onSave:t,disabled:n,isSaving:r=!1,compact:i=!1}){let[a,o]=(0,Q.useState)(!1),[s,l]=(0,Q.useState)(e??``),[u,d]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{l(e??``)},[e]);let f=(0,Q.useCallback)(async()=>{d(!0);try{await t(s),o(!1)}finally{d(!1)}},[s,t]),p=r||u,m=Pi(e),h=(0,$.jsxs)(`button`,{type:`button`,"data-testid":`chat-system-prompt-button`,onClick:()=>o(!0),disabled:n,className:i?D(`inline-flex h-auto w-auto aspect-square items-center justify-center rounded-full p-2 transition-colors disabled:pointer-events-none disabled:opacity-50`,m?`text-amber-500 dark:text-amber-400`:`text-muted-foreground hover:text-foreground`):D(`inline-flex h-9 items-center justify-center gap-1.5 rounded-full border border-input bg-secondary px-3 text-sm font-medium shadow-xs transition-colors hover:bg-secondary/80 disabled:pointer-events-none disabled:opacity-50`,m?`text-amber-600 dark:text-amber-400`:`text-secondary-foreground`),children:[(0,$.jsx)(sn,{className:`h-4 w-4`}),!i&&(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:`System Prompt`})]});return(0,$.jsxs)(Pe,{open:a,onOpenChange:o,children:[i?(0,$.jsxs)(g,{children:[(0,$.jsx)(c,{render:h,nativeButton:!0}),(0,$.jsx)(b,{side:`top`,children:(0,$.jsx)(`p`,{children:m?`Custom system prompt`:`System Prompt`})})]}):h,(0,$.jsxs)(ge,{className:`sm:max-w-xl`,children:[(0,$.jsx)(Be,{children:(0,$.jsx)(Ce,{children:`System Prompt`})}),(0,$.jsx)(Xt,{value:s,onChange:e=>l(e.target.value),placeholder:`Describe the assistant's behavior...`,className:`min-h-[160px] text-sm`}),(0,$.jsx)(Te,{children:(0,$.jsxs)(R,{size:`sm`,onClick:f,disabled:p||s===(e??``),className:`gap-1.5`,children:[p?(0,$.jsx)(Ze,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(Ie,{className:`h-3.5 w-3.5`}),`Save`]})})]})]})}function Ii({inputValue:e,isConnected:t,isLoading:n,textareaRef:r,llmConfig:i,promptsDropdownOpen:a,promptFocusedIndex:o,prompts:s,selectedPrompt:l,promptResults:u,attachments:d,tools:f,disabledTools:p,onDisabledToolsChange:m,onInputChange:h,onKeyDown:_,onKeyUp:v,onClick:y,onSendMessage:x,onStopStreaming:S,onConfigDialogOpenChange:C,onPromptSelect:w,onDeletePromptResult:T,onAttachmentAdd:E,onAttachmentRemove:O,hideModelBadge:k,freeTierInfo:A,managedCloudInfo:ee,modelBadgeMode:j=`byok`,modelDisplayName:M,followups:N=[],onFollowupSelect:P,pendingElicitationRequests:F,onApproveElicitation:I,onRejectElicitation:L,systemPromptProvider:te}){let z=e.trim()||u.length>0||d.length>0,B=(F?.length??0)>0,V=i&&(!k||A||ee)?(0,$.jsxs)(g,{children:[(0,$.jsx)(c,{render:(0,$.jsx)(ot,{provider:i.provider,model:i.model,displayName:M,mode:j,className:`shrink-0`,onClick:()=>C(!0)}),nativeButton:!0}),(0,$.jsx)(b,{children:(0,$.jsx)(`p`,{children:ee||A?`Change model`:`Change API Key`})})]}):null;return(0,$.jsx)(`div`,{className:`w-full flex shrink-0 flex-col items-center px-2 pb-2 pt-0 sm:px-4 sm:pb-2 text-foreground`,children:(0,$.jsxs)(`div`,{className:`relative w-full max-w-3xl backdrop-blur-xl`,children:[B&&I&&L&&(0,$.jsx)(Mi,{requests:F,onApprove:I,onReject:L}),N.length>0&&(0,$.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:N.map(e=>(0,$.jsx)(R,{type:`button`,variant:`outline`,size:`sm`,className:`rounded-full`,onClick:()=>P?.(e),disabled:n||!t,children:e},e))}),(0,$.jsx)(Pr,{isOpen:a,prompts:s,selectedPrompt:l,focusedIndex:o,onPromptSelect:w}),(0,$.jsx)(Nr,{promptResults:u,onDeletePromptResult:T}),(0,$.jsx)(Mr,{inputValue:e,isConnected:t,isLoading:n,textareaRef:r,attachments:d,placeholder:`Ask a question or request an action...`,className:D(`bg-white/80 dark:text-white dark:bg-black backdrop-blur-sm border-gray-200 dark:border-zinc-800`,u.length>0&&`pt-16`),tools:f,disabledTools:p,onDisabledToolsChange:m,onInputChange:h,onKeyDown:_,onKeyUp:v,onClick:y,onAttachmentAdd:E,onAttachmentRemove:O,inlineControls:i&&te?(0,$.jsx)(Fi,{compact:!0,value:te.prompt,onSave:te.savePrompt,disabled:!t||n||te.disabled,isSaving:te.isSaving}):null,trailingControls:(0,$.jsxs)($.Fragment,{children:[V,(0,$.jsx)(R,{type:`button`,size:`sm`,className:D(`h-8 w-8 rounded-full p-0`,n&&`animate-spin`,!z&&!n&&`bg-zinc-400`),disabled:!n&&(!z||!t||B),title:n?`Stop streaming`:`Send`,onClick:n?S:x,"data-testid":`chat-send-button`,children:n?(0,$.jsx)(Ze,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(Ct,{className:`h-3.5 w-3.5`})})]})})]})})}function Li({serverDisplayName:e,composerNotice:t,quickQuestions:n=[],onQuickQuestionSelect:r,...i}){return(0,$.jsx)(`div`,{className:`flex h-full flex-col items-center justify-center`,children:(0,$.jsxs)(De,{className:`w-full max-w-4xl mx-auto px-2 sm:px-4`,children:[(0,$.jsxs)(`div`,{className:`text-center mb-6 sm:mb-8`,children:[(0,$.jsxs)(`h1`,{className:`text-2xl sm:text-4xl font-light mb-2 dark:text-white`,"data-testid":`chat-landing-header`,children:[`Chat with `,e]}),(0,$.jsx)(`p`,{className:`mx-auto max-w-xl text-sm text-muted-foreground sm:text-base`,"data-testid":`chat-landing-description`,children:`Chat, inspect traces, preview widgets, and more.`})]}),(0,$.jsxs)(`div`,{className:`space-y-6`,children:[t,(0,$.jsx)(Ii,{...i}),n.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-center gap-2 px-2`,children:n.map(e=>(0,$.jsx)(R,{type:`button`,variant:`outline`,size:`sm`,className:`rounded-full bg-white/70 dark:bg-black/50 text-gray-900 dark:text-white`,onClick:()=>r?.(e),disabled:i.isLoading||!i.isConnected,children:e},e))})]})]})})}function Ri({onConfigureClick:e}){return(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-center`,children:[(0,$.jsx)(ut,{className:`h-12 w-12 text-muted-foreground mb-4`}),(0,$.jsx)(`h3`,{className:`text-lg font-semibold mb-2`,children:`Configure Your LLM Provider`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground mb-4 max-w-md`,children:`To start chatting with the MCP server, you need to configure your LLM provider and API key. Your credentials are stored locally and used only for this chat.`}),(0,$.jsxs)(R,{onClick:e,"data-testid":`chat-configure-api-key-button`,children:[(0,$.jsx)(yt,{className:`h-4 w-4 mr-2`}),`Configure API Key`]})]})}function zi({children:e,as:t=`p`,className:n,duration:r=2,spread:i=2}){let a=f.create(t),o=(0,Q.useMemo)(()=>e.length*i,[e,i]);return(0,$.jsx)(a,{className:D(`relative inline-block bg-[length:250%_100%,auto] bg-clip-text`,`text-transparent [--base-color:#a1a1aa] [--base-gradient-color:#000]`,`[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--base-gradient-color),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]`,`dark:[--base-color:#71717a] dark:[--base-gradient-color:#ffffff] dark:[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--base-gradient-color),#0000_calc(50%+var(--spread)))]`,n),initial:{backgroundPosition:`100% center`},animate:{backgroundPosition:`0% center`},transition:{repeat:1/0,duration:r,ease:`linear`},style:{"--spread":`${o}px`,backgroundImage:`var(--bg), linear-gradient(var(--base-color), var(--base-color))`},children:e})}function Bi(e){let t=e.match(/```/g);return t&&t.length%2==1?`${e}\n\`\`\``:e}var Vi=(0,Q.memo)(function({content:e,isStreaming:t=!1}){let n=(0,Q.useMemo)(()=>t?Bi(e):e,[e,t]);return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(It,{className:D(`text-[14px] leading-relaxed text-foreground`,`[&_p]:mb-2 [&_p:last-child]:mb-0`,`[&_pre]:my-3 [&_ul]:mb-2 [&_ol]:mb-2`),content:n}),t?(0,$.jsx)(`span`,{className:`inline-block w-0.5 h-[1em] ml-0.5 -mt-1 align-middle bg-foreground/60 animate-pulse`,"aria-hidden":!0}):null]})});function Hi(){let[e,t]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{if(typeof window>`u`)return;let e=new AbortController,{signal:n}=e,r=()=>{let e=`ontouchstart`in window||navigator.maxTouchPoints>0,n=window.matchMedia(`(pointer: coarse)`).matches;t(e&&n)};return window.matchMedia(`(pointer: coarse)`).addEventListener(`change`,r,{signal:n}),window.addEventListener(`pointerdown`,r,{signal:n}),r(),()=>e.abort()},[]),e}function Ui({size:e}){return(0,$.jsxs)(`svg`,{width:Math.max(16,e*.35),height:Math.max(16,e*.35),viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,$.jsx)(`path`,{d:`M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z`}),(0,$.jsx)(`path`,{d:`M14 3v5h5`})]})}function Wi({file:e,size:t,className:n}){let r=k(),i=e.type.startsWith(`image/`),[a,o]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(!i){o(null);return}let t=URL.createObjectURL(e);return o(t),()=>URL.revokeObjectURL(t)},[i,e]);let s=i&&!a;return(0,$.jsx)(`div`,{className:D(`relative shrink-0 overflow-hidden bg-accent border border-border`,r.bg,n),style:{width:t,height:t},children:a?(0,$.jsx)(`img`,{src:a,alt:e.name,className:`absolute inset-0 w-full h-full object-cover`}):s?(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,$.jsx)(`div`,{className:`w-6 h-6 rounded-full border-2 border-border border-t-muted-foreground animate-spin`,"aria-label":`Loading preview`,role:`status`})}):(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-muted-foreground`,role:`img`,"aria-label":e.name,children:(0,$.jsx)(Ui,{size:t})})})}var Gi=(0,Q.forwardRef)(({from:e,files:t,thumbnailSize:n=64,time:r,actions:i,children:a,className:o,...s},c)=>{let l=k(),u=e===`user`,d=Hi(),p=u&&r!=null;return(0,$.jsxs)(f.div,{ref:c,layout:`position`,initial:{opacity:0,y:8,scale:.96},animate:{opacity:1,y:0,scale:1},transition:x.moderate,style:{transformOrigin:u?`bottom right`:`bottom left`},className:D(`group flex max-w-[80%] flex-col gap-1.5`,u?`items-end self-end`:`items-start self-start`,o),...s,children:[t&&t.length>0&&(0,$.jsx)(`div`,{className:D(`flex flex-wrap gap-1.5`,u?`justify-end`:`justify-start`),children:t.map((e,t)=>(0,$.jsx)(Wi,{file:e,size:n},`${e.name}-${e.size}-${e.lastModified}-${t}`))}),a!=null&&a!==``&&(0,$.jsx)(`div`,{className:D(`py-2 text-[14px] whitespace-pre-wrap break-words`,u?D(l.bg,`px-3.5 text-pretty bg-[color-mix(in_oklab,var(--accent),var(--background)_45%)] text-accent-foreground`):`text-foreground`),children:a}),(p||i!=null)&&(0,$.jsxs)(`div`,{className:D(`flex items-center gap-2 px-1 text-[12px] leading-none text-muted-foreground select-none`,!d&&[`opacity-0 pointer-events-none transition-opacity duration-150`,`group-hover:opacity-100 group-hover:pointer-events-auto`,`group-focus-within:opacity-100 group-focus-within:pointer-events-auto`]),children:[p&&(0,$.jsx)(`span`,{className:`tabular-nums`,children:r}),i!=null&&(0,$.jsx)(`span`,{className:`flex items-center gap-0.5`,children:i})]})]})});Gi.displayName=`ChatMessage`;function Ki({text:e}){let[t,n]=(0,Q.useState)(!1);return(0,$.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:text-foreground flex items-center rounded p-0.5`,onClick:async()=>{await Ye(e),n(!0),setTimeout(()=>n(!1),2e3)},title:`Copy message content`,"data-testid":`copy-button`,children:t?(0,$.jsx)(Ie,{className:`h-3.5 w-3.5`}):(0,$.jsx)(Et,{className:`h-3.5 w-3.5`})})}function qi(e,t){let n=e===1?`token`:`tokens`;return`${e.toLocaleString()} ${n} ${t}`}function Ji({variant:e,copyText:t,inputTokens:n,outputTokens:r}){let i=!!t,a=e===`user`&&n!=null?qi(n,`in`):e===`assistant`&&r!=null?qi(r,`out`):null;if(!i&&!a)return null;let o=i?(0,$.jsx)(Ki,{text:t}):null,s=a?(0,$.jsx)(`span`,{className:`tabular-nums`,title:e===`user`?`Input tokens`:`Output tokens`,"data-testid":e===`user`?`message-input-tokens`:`message-output-tokens`,children:a}):null;return e===`user`?(0,$.jsxs)($.Fragment,{children:[s,o]}):(0,$.jsxs)($.Fragment,{children:[o,s]})}function Yi({content:e,timestamp:t,_isStreaming:n,outputTokens:r}){return!e||e.length===0?null:(0,$.jsxs)(`div`,{"data-testid":`chat-message-assistant`,children:[(0,$.jsx)(Gi,{from:`assistant`,actions:(0,$.jsx)(Ji,{variant:`assistant`,copyText:e,outputTokens:r}),"data-testid":`chat-message-content`,children:(0,$.jsx)(Vi,{content:e,isStreaming:n})}),t!=null&&(0,$.jsx)(`span`,{className:`sr-only`,children:new Date(t).toLocaleTimeString()})]})}function Xi({toolName:e,args:t,result:n,state:r=`result`,partialArgs:i}){let a=r===`call`&&i?i:t,o=()=>{switch(r){case`call`:return(0,$.jsx)(Ze,{className:`h-4 w-4 animate-spin text-blue-500 dark:text-blue-400`});case`result`:return(0,$.jsx)(Ie,{className:`h-4 w-4 text-emerald-800 dark:text-emerald-400`});case`error`:return(0,$.jsx)(Ge,{className:`h-4 w-4 text-red-500 dark:text-red-400`});default:return(0,$.jsx)(Ie,{className:`h-4 w-4 text-emerald-800 dark:text-emerald-400`})}},s=()=>{switch(r){case`call`:return` bg-blue-500/20 dark:bg-blue-500/20`;case`result`:return` bg-emerald-500/20 dark:bg-emerald-500/20`;case`error`:return` bg-red-500/20 dark:bg-red-500/20`;default:return` bg-emerald-500/20 dark:bg-emerald-500/20`}},c=e=>typeof e==`object`?wt(e).preview:String(e);return(0,$.jsxs)(Xe,{children:[(0,$.jsx)(mt,{render:(0,$.jsxs)(`div`,{className:`flex max-w-min items-center gap-3 p-1 rounded-full border bg-card hover:bg-accent/50 transition-colors cursor-pointer my-4`,"data-testid":`chat-tool-call-${e}`,children:[(0,$.jsx)(`div`,{className:`w-8 h-8 rounded-full bg-zinc-100 dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-800 flex items-center justify-center shrink-0`,children:(0,$.jsx)(Ke,{className:`size-4 text-muted-foreground`})}),(0,$.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsxs)(`span`,{className:`text-sm font-medium truncate`,children:[e,`(`,Object.keys(a).length>0?(0,$.jsxs)(`span`,{className:`bg-muted-foreground/20 rounded-full px-1.5 mx-1 py-0.5 text-xs`,children:[Object.keys(a).length,` args`]}):``,`)`]})})}),(0,$.jsx)(`div`,{className:D(`w-8 h-8 rounded-full flex items-center justify-center`,s()),"data-testid":`chat-tool-call-status-${r}`,children:o()})]}),nativeButton:!1}),(0,$.jsxs)(lt,{side:`right`,className:`w-[400px] sm:w-[540px] p-4 overflow-y-auto`,"data-testid":`chat-tool-drawer`,children:[(0,$.jsxs)(Qe,{children:[(0,$.jsxs)(Z,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Ke,{className:`h-5 w-5`}),`Tool Call Details`]}),(0,$.jsxs)(bt,{className:`flex items-center gap-2`,children:[e,` — `,r,r===`call`&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-blue-500 dark:text-blue-400`,children:[(0,$.jsx)(Ze,{className:`h-3 w-3 animate-spin`}),`streaming…`]})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-6 py-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Arguments`}),(0,$.jsxs)(`div`,{className:`relative`,"data-testid":`chat-tool-drawer-args`,children:[(0,$.jsx)(`pre`,{className:`text-xs bg-muted/50 rounded-lg p-3 overflow-x-auto border font-mono leading-relaxed max-h-48 whitespace-pre-wrap break-words`,children:c(a)}),(0,$.jsx)(R,{variant:`ghost`,size:`sm`,onClick:()=>Ye(c(a)),className:`absolute top-2 right-2 h-6 w-6 p-0 opacity-70 hover:opacity-100`,title:`Copy arguments`,children:(0,$.jsx)(Et,{className:`h-3 w-3`})})]})]}),n&&(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Result`}),(0,$.jsx)(`div`,{className:`relative`,"data-testid":`chat-tool-drawer-result`,children:typeof n==`string`?(0,$.jsxs)(`div`,{className:D(`p-3 rounded-lg border text-sm leading-relaxed max-h-48 overflow-x-auto whitespace-pre-wrap break-words max-w-full`,r===`error`?`bg-destructive/10 border-destructive/20 text-destructive-foreground`:`bg-muted/30 border-border`),children:[n.startsWith(`Error`)?(0,$.jsxs)(`div`,{className:`font-mono`,children:[(0,$.jsx)(`div`,{className:`font-semibold text-destructive mb-1`,children:`Error:`}),(0,$.jsx)(`div`,{className:`whitespace-pre-wrap break-words`,children:n.replace(/^Error:\s*/,``)})]}):(0,$.jsx)(`div`,{className:`whitespace-pre-wrap font-mono break-words`,children:n}),(0,$.jsx)(R,{variant:`ghost`,size:`sm`,onClick:()=>Ye(n),className:`absolute top-2 right-2 h-6 w-6 p-0 opacity-70 hover:opacity-100`,title:`Copy result`,children:(0,$.jsx)(Et,{className:`h-3 w-3`})})]}):(0,$.jsxs)(`div`,{className:D(`p-3 rounded-lg border text-sm leading-relaxed max-h-96 overflow-y-auto max-w-full`,r===`error`?`bg-destructive/10 border-destructive/20 text-destructive-foreground`:`bg-muted/30 border-border`),children:[(0,$.jsx)(Je,{data:n,filename:`tool-call-${e}-result-${Date.now()}.json`}),(0,$.jsx)(R,{variant:`ghost`,size:`sm`,onClick:()=>Ye(JSON.stringify(n,null,2)),className:`absolute top-2 right-2 h-6 w-6 p-0 opacity-70 hover:opacity-100`,title:`Copy result`,children:(0,$.jsx)(Et,{className:`h-3 w-3`})})]})})]})]})]})]})}function Zi({widgetId:e}){let{getWidget:t}=dt(),n=t(e)?.modelContext;if(!n?.content?.length&&!n?.structuredContent)return null;let r=n.content?.map(e=>e.text).join(` `)??JSON.stringify(n.structuredContent).slice(0,80);return(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-1.5 text-[11px] text-muted-foreground bg-muted/30 border border-border/40 rounded-md mt-1`,children:[(0,$.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-blue-400 shrink-0`}),(0,$.jsx)(`span`,{className:`font-medium`,children:`State synced to model`}),(0,$.jsx)(`span`,{className:`truncate opacity-60 max-w-[300px]`,children:r})]})}function Qi({toolName:e,toolArgs:t,result:n,serverId:r,readResource:i,toolMeta:a,onSendFollowUp:o,partialToolArgs:s,cancelled:c}){let l=(0,Q.useMemo)(()=>`chat-tool-${e}-${Date.now()}-${Math.random().toString(36).substring(2,11)}`,[e]),[u,d]=(0,Q.useState)(`inline`),f=(0,Q.useMemo)(()=>{if(!n)return null;if(typeof n==`string`)try{return JSON.parse(n)}catch{return n}return n},[n]),p=ze(a),m=p?a?.ui?.resourceUri??null:null,h=(0,Q.useMemo)(()=>t,[e,f]),g=(0,Q.useMemo)(()=>f,[e,f]);return p&&m&&r&&i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(en,{serverId:r,viewId:l,toolName:e,resourceUri:m,toolInput:h,toolOutput:g,toolMetadata:a,readResource:i,displayMode:u,onDisplayModeChange:d,onSendFollowUp:o,partialToolInput:s,cancelled:c,noWrapper:!0,className:`my-4`}),(0,$.jsx)(Zi,{widgetId:l})]}):p&&!m?(0,$.jsx)(`div`,{className:`flex items-center justify-center w-full h-[200px] rounded border`,children:(0,$.jsx)(xe,{className:`size-5`})}):p&&(!r||!i)?(0,$.jsx)(`div`,{className:`my-4 p-4 bg-red-50/30 dark:bg-red-950/20 border border-red-200/50 dark:border-red-800/50 rounded-lg`,children:(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:`Cannot render widget: Missing required props (serverId or readResource)`})}):null}function $i(e){let t=atob(e.data),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return new File([n],e.name||`attachment`,{type:e.mimeType})}function ea({content:e,timestamp:t,attachments:n,inputTokens:r}){let i=(0,Q.useMemo)(()=>n?.map($i),[n]);return(!e||e.length===0)&&(!n||n.length===0)?null:(0,$.jsx)(`div`,{"data-testid":`chat-message-user`,className:`flex flex-col items-end`,children:(0,$.jsx)(Gi,{from:`user`,files:i,time:t?new Date(t).toLocaleTimeString():void 0,actions:e||r!=null?(0,$.jsx)(Ji,{variant:`user`,copyText:e||void 0,inputTokens:r}):void 0,"data-testid":`chat-message-content`,children:e&&e.length>0?e:void 0})})}var ta={events:[],spans:[]};function na(e){if(!e||typeof e!=`object`)return;let t=e,n=(...e)=>{for(let n of e)if(typeof t[n]==`number`)return t[n]},r=n(`inputTokens`,`input_tokens`,`promptTokens`),i=n(`outputTokens`,`output_tokens`,`completionTokens`),a=n(`totalTokens`,`total_tokens`)??(r!==void 0&&i!==void 0?r+i:void 0);if(!(r===void 0&&i===void 0&&a===void 0))return{inputTokens:r,outputTokens:i,totalTokens:a}}var ra=new Set([`apikey`,`authorization`,`accesstoken`,`refreshtoken`,`password`,`cookie`,`secret`]);function ia(e){return Array.isArray(e)?e.map(ia):!e||typeof e!=`object`?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,ra.has(e.toLowerCase().replace(/[_-]/g,``))?`[REDACTED]`:ia(t)]))}function aa(e,t=120){let n;try{n=JSON.stringify(e)}catch{n=String(e)}return n.length>t?`${n.slice(0,t)}…`:n}function oa(e){switch(e.type){case`request`:return`LLM request`;case`text-delta`:return e.delta.trim()||`Text delta`;case`tool-call-start`:return e.toolName;case`tool-call-args`:return aa(e.args);case`tool-result`:return aa(e.result);case`usage`:return`${e.usage.totalTokens??`?`} tokens`;case`error`:return e.message;case`done`:return`Completed`;default:return e}}function sa(e,t){let n=(e,t)=>e===void 0&&t===void 0?void 0:(e??0)+(t??0);return{inputTokens:n(e?.inputTokens,t.inputTokens),outputTokens:n(e?.outputTokens,t.outputTokens),totalTokens:n(e?.totalTokens,t.totalTokens),cachedInputTokens:n(e?.cachedInputTokens,t.cachedInputTokens),reasoningTokens:n(e?.reasoningTokens,t.reasoningTokens)}}function ca(e,t){let n=e.spans.map(e=>({...e})),r=e.usage,i=[...n].reverse().find(e=>e.kind===`llm`&&e.status===`running`);if(t.type===`request`)n.push({id:`llm-${t.id}`,kind:`llm`,name:`LLM`,status:`running`,startedAt:t.timestamp,preview:oa(t)});else if((t.type===`text-delta`||t.type===`tool-call-start`)&&!i)i={id:`llm-${t.id}`,kind:`llm`,name:`LLM`,status:`running`,startedAt:t.timestamp,preview:t.type===`text-delta`?oa(t):`LLM response`},n.push(i),t.type===`tool-call-start`&&n.push({id:t.toolCallId,kind:`tool`,name:t.toolName,status:`running`,startedAt:t.timestamp,preview:oa(t)});else if(t.type===`tool-call-start`)n.push({id:t.toolCallId,kind:`tool`,name:t.toolName,status:`running`,startedAt:t.timestamp,preview:oa(t)});else if(t.type===`tool-call-args`){let e=n.find(e=>e.id===t.toolCallId);e&&(e.preview=oa(t))}else if(t.type===`tool-result`){let e=t.toolCallId?n.find(e=>e.id===t.toolCallId):[...n].reverse().find(e=>e.kind===`tool`&&e.name===t.toolName&&e.status===`running`);e&&(e.status=t.isError?`error`:`success`,e.endedAt=t.timestamp,e.preview=oa(t))}else t.type===`usage`?(r=sa(r,t.usage),i&&(i.usage=sa(i.usage,t.usage))):(t.type===`error`||t.type===`done`)&&i&&(i.status=t.type===`error`?`error`:`success`,i.endedAt=t.timestamp,i.preview=oa(t));return{events:[...e.events,t],spans:n,usage:r}}function la(e,t){let n=[],r=null;for(let t of e)t.type===`request`?(r&&n.push(r),r={request:t,response:[]}):r&&r.response.push(t);return r&&n.push(r),{turns:n,tokenUsage:t??null}}function ua(e){let t;for(let n of e)n.type===`usage`&&(t=sa(t,n.usage));return t}function da(e){let t=[],n=0;for(;n<e.length;){if(e[n]?.role!==`user`){n++;continue}let r=e[n].id;n++;let i=null;for(;n<e.length&&e[n]?.role===`assistant`;)i=e[n].id,n++;t.push({userId:r,assistantId:i})}return t}function fa(e,t){let{turns:n}=la(t),r=da(e),i=new Map,a=Math.min(n.length,r.length);for(let e=0;e<a;e++){let t=ua(n[e].response);if(!t)continue;let{userId:a,assistantId:o}=r[e];t.inputTokens!=null&&i.set(a,{...i.get(a),inputTokens:t.inputTokens}),o!=null&&t.outputTokens!=null&&i.set(o,{...i.get(o),outputTokens:t.outputTokens})}return i}var pa=(0,Q.memo)(({messages:e,isLoading:t,serverId:n,readResource:r,tools:i,sendMessage:a,messagesEndRef:o,traceEvents:s=[]})=>{let c=(0,Q.useMemo)(()=>fa(e,s),[e,s]),l=e=>{let t=e=>e.replace(/-/g,`_`),n=t(e);return i?.find(e=>t(e.name)===n)?._meta},u=e=>ze(l(e)),d=(0,Q.useCallback)(e=>{let t=e.filter(e=>e.type===`text`&&`text`in e).map(e=>e.text).join(`
|
|
3
|
+
`),n=e.filter(e=>e.type===`image`&&`data`in e&&`mimeType`in e).map(e=>({type:`image`,data:e.data,mimeType:e.mimeType}));a?.(t,n.length>0?n:void 0)},[a]),f=t&&(()=>{if(e.length===0)return!0;let t=e[e.length-1];if(t.role===`user`)return!0;if(t.role===`assistant`){if(t.parts&&t.parts.length>0)return!1;let e=typeof t.content==`string`?t.content:Array.isArray(t.content)?t.content.map(e=>typeof e==`string`?e:e.text||JSON.stringify(e)).join(``):JSON.stringify(t.content);return!(e&&e.trim().length>0)}return!1})(),p=e[e.length-1],m=t&&p?.role===`assistant`,h=e=>{for(let t=e.length-1;t>=0;t--)if(e[t]?.type===`text`)return t;return-1},g=(e,t,n)=>m&&e.id===p?.id&&t===h(n),_=e=>m&&e.id===p?.id;return(0,$.jsxs)(`div`,{className:`space-y-6 max-w-3xl mx-auto px-2`,children:[e.map(e=>{let t=typeof e.content==`string`?e.content:Array.isArray(e.content)?e.content.map(e=>typeof e==`string`?e:e.text||JSON.stringify(e)).join(``):JSON.stringify(e.content);if(e.role===`user`)return(0,$.jsx)(ea,{content:t,timestamp:e.timestamp,attachments:e.attachments,inputTokens:c.get(e.id)?.inputTokens},e.id);if(e.role===`assistant`){let i=c.get(e.id)?.outputTokens,a=e.parts&&e.parts.length>0?h(e.parts):-1;return(0,$.jsx)(`div`,{className:`space-y-4`,children:e.parts&&e.parts.length>0?e.parts.map((t,o)=>{let s=t.type===`text`?`${e.id}-text-${o}`:`${e.id}-tool-${t.toolInvocation?.toolCallId??`${t.toolInvocation?.toolName}-${o}`}`;return t.type===`text`?(0,$.jsx)(Yi,{content:t.text||``,timestamp:o===e.parts.length-1?e.timestamp:void 0,_isStreaming:g(e,o,e.parts),outputTokens:o===a?i:void 0},s):t.type===`tool-invocation`&&t.toolInvocation?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Xi,{toolName:t.toolInvocation.toolName,args:t.toolInvocation.args,result:t.toolInvocation.result,state:t.toolInvocation.state===`error`?`error`:t.toolInvocation.state===`streaming`||t.toolInvocation.state===`pending`?`call`:`result`,partialArgs:t.toolInvocation.partialArgs}),(t.toolInvocation.result||t.toolInvocation.state===`streaming`||u(t.toolInvocation.toolName))&&(0,$.jsx)(`div`,{"data-tool-call-id":`${e.id}-${t.toolInvocation.toolName}-${o}`,children:(0,$.jsx)(Qi,{toolName:t.toolInvocation.toolName,toolArgs:t.toolInvocation.args,result:t.toolInvocation.result||null,serverId:n,readResource:r,toolMeta:l(t.toolInvocation.toolName),onSendFollowUp:d,partialToolArgs:t.toolInvocation.partialArgs,cancelled:t.toolInvocation.state===`error`&&t.toolInvocation.result===`Cancelled by user`})})]},s):null}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Yi,{content:t,timestamp:e.timestamp,_isStreaming:_(e),outputTokens:i}),e.toolCalls&&e.toolCalls.length>0&&(0,$.jsx)(`div`,{className:`space-y-2`,children:e.toolCalls.map(t=>{let i=`${e.id}-${t.toolName}-${JSON.stringify(t.args).slice(0,50)}`;return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Xi,{toolName:t.toolName,args:t.args,result:t.result,state:t.result?`result`:`call`}),(t.result||u(t.toolName))&&(0,$.jsx)(`div`,{"data-tool-call-id":i,children:(0,$.jsx)(Qi,{toolName:t.toolName,toolArgs:t.args,result:t.result||null,serverId:n,readResource:r,toolMeta:l(t.toolName),onSendFollowUp:d})})]},i)})})]})},e.id)}return null}),f&&(0,$.jsx)(`div`,{className:`flex items-start gap-3`,children:(0,$.jsx)(`div`,{className:`flex-1`,children:(0,$.jsx)(`div`,{className:`rounded-lg p-4 max-w-fit`,children:(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(`span`,{className:`text-sm`,children:(0,$.jsx)(zi,{duration:2,spread:1,children:`Thinking...`})})})})})}),(0,$.jsx)(`div`,{ref:o})]})});function ma({visible:e,onClick:t}){return(0,$.jsx)(`div`,{className:`pointer-events-none absolute bottom-2 left-0 right-0 z-30 flex justify-center`,children:(0,$.jsx)(ne,{children:e&&(0,$.jsx)(f.div,{initial:{opacity:0,y:8,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:8,scale:.96},transition:{duration:.18,ease:`easeOut`},children:(0,$.jsx)(R,{type:`button`,variant:`secondary`,className:`pointer-events-auto size-9 rounded-full border bg-background/95 p-0 shadow-lg backdrop-blur supports-[backdrop-filter]:bg-background/80`,onClick:t,"aria-label":`Scroll to bottom`,title:`Scroll to bottom`,"data-testid":`chat-scroll-to-bottom`,children:(0,$.jsx)(tn,{className:`size-4`})})})})})}function ha({visible:e}){return(0,$.jsx)(`div`,{"aria-hidden":!0,className:D(`pointer-events-none absolute inset-x-0 top-0 z-[5] h-32 bg-[linear-gradient(to_bottom,var(--background)_0%,var(--background)_24%,transparent_46%)] transition-opacity duration-200 sm:h-36`,e?`opacity-100`:`opacity-0`)})}function ga(e,{messageCount:t,isLoading:n,enabled:r=!0}){let i=(0,Q.useRef)(null),[a,o]=(0,Q.useState)(!0),[s,c]=(0,Q.useState)(!1),l=(0,Q.useRef)(!0),u=(0,Q.useRef)({length:0,loading:!1}),d=t>0,f=r&&d&&!a,p=(0,Q.useCallback)(()=>{let t=e.current;if(!t)return;let n=t.scrollHeight-(t.scrollTop+t.clientHeight)<=64;l.current=n,o(n),c(t.scrollTop>8)},[e]),m=(0,Q.useCallback)(t=>{let n=e.current;n&&(n.scrollTo({top:n.scrollHeight,behavior:t}),l.current=!0,o(!0))},[e]);return(0,Q.useEffect)(()=>{if(!r)return;let t=e.current;if(!t)return;p();let n=()=>p();t.addEventListener(`scroll`,n,{passive:!0});let i=typeof ResizeObserver<`u`?new ResizeObserver(()=>p()):null;return i?.observe(t),()=>{t.removeEventListener(`scroll`,n),i?.disconnect()}},[r,p,t,e]),(0,Q.useEffect)(()=>{if(!r||!d||!l.current)return;let e=u.current,i=t!==e.length,a=n!==e.loading;u.current={length:t,loading:n},!(!i&&!a)&&m(n?`auto`:`smooth`)},[r,d,n,t,m]),{messagesEndRef:i,showScrollToBottom:f,showTopFade:s,scrollToBottom:m}}function _a(e){return Mt(e)}var va=e=>{let t=[];for(let n of e){if(n.error||n.result?.isError){let e={id:`prompt-error-${n.promptName}-${n.timestamp}`,role:`assistant`,content:n.error||`Prompt execution failed`,timestamp:n.timestamp};t.push(e);continue}let e=n.result;if(e&&`messages`in e&&Array.isArray(e.messages))for(let r of e.messages){let e=``,i=[];if(typeof r.content==`string`)e=r.content;else if(Array.isArray(r.content)){let t=[];for(let e of r.content)e.type===`text`&&e.text?t.push(e.text):e.type===`image`&&e.data?i.push({type:`image`,data:e.data,mimeType:e.mimeType||`image/png`}):e.type===`resource`&&t.push(`[Resource: ${e.resource?.uri||`embedded`}]`);e=t.join(`
|
|
4
|
+
`)}else r.content&&typeof r.content==`object`&&(r.content.type===`text`&&r.content.text?e=r.content.text:r.content.type===`image`&&r.content.data?i.push({type:`image`,data:r.content.data,mimeType:r.content.mimeType||`image/png`}):e=JSON.stringify(r.content));!e&&i.length===0&&(e=`[no content]`);let a={id:`prompt-${n.promptName}-${n.timestamp}-${t.length}`,role:r.role,content:e||``,timestamp:n.timestamp,attachments:i.length>0?i:void 0};t.push(a)}}return t};function ya(e){if(!e)return;let t=ba(e);if(t)return t;let n=[],r=!1,i=!1;for(let t of e){if(r){i?i=!1:t===`\\`?i=!0:t===`"`&&(r=!1);continue}t===`"`?r=!0:t===`{`?n.push(`}`):t===`[`?n.push(`]`):(t===`}`||t===`]`)&&n[n.length-1]===t&&n.pop()}let a=e;return r&&i&&(a=a.slice(0,-1)),r&&(a+=`"`),a+=[...n].reverse().join(``),ba(a)}function ba(e){try{let t=JSON.parse(e);return t!==null&&!Array.isArray(t)&&typeof t==`object`?t:void 0}catch{return}}function xa({mcpServerUrl:e,llmConfig:t,authConfig:n,mcpAuthTokens:r,isConnected:i,chatApiUrl:a,waitForChatApiUrl:o,widgetModelContexts:s,initialMessages:c,disabledTools:l,streamProtocol:u=`sse`,credentials:d,extraHeaders:f,body:p}){let[m,h]=(0,Q.useState)(c??[]),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)([]),[b,x]=(0,Q.useState)(ta),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(null),E=(0,Q.useRef)(null),D=(0,Q.useRef)(0),O=(0,Q.useCallback)(e=>{let t={...e,id:`trace-${++D.current}`,timestamp:Date.now()};x(e=>ca(e,t))},[]),k=(0,Q.useCallback)(async(c,g,b)=>{let x=[...v,...b??[]];if(!(c.trim()||g.length>0||x.length>0)||!t||!i)return;let S=[...va(g)];if(c.trim()||x.length>0){let e={id:`user-${Date.now()}`,role:`user`,content:c.trim(),timestamp:Date.now(),attachments:x.length>0?x:void 0};S.push(e)}h(e=>[...e,...S]),_(!0),y([]),E.current=new AbortController;try{let i=n,c=n?.type===`bearer`&&!!n.token,g=n?.type===`basic`&&!!(n.username||n.password);if(!c&&!g)if(r?.access_token)i={type:`oauth`,oauthTokens:r};else try{let t=`mcp:auth_${Vt(e)}_tokens`,n=localStorage.getItem(t);if(n){let e=JSON.parse(n);e?.access_token&&(i={type:`oauth`,oauthTokens:e})}}catch(e){console.warn(`Failed to retrieve OAuth tokens:`,e)}let _=[];if(s&&s.size>0){let e=[];for(let[,t]of s)t&&(t.content?.length?e.push(t.content.map(e=>e.text).join(`
|
|
5
|
+
`)):t.structuredContent&&e.push(JSON.stringify(t.structuredContent)));e.length>0&&_.push({id:`widget-context-${Date.now()}`,role:`user`,content:`[Current Widget State]\n${e.join(`
|
|
6
|
+
`)}`,timestamp:Date.now()})}let v=[...m,...S,..._],y=[...v.map(e=>({role:e.role,content:e.content||(e.parts?.filter(e=>e.type===`text`).map(e=>e.text).join(``)??``),attachments:e.attachments}))],b=a??(o?await o():void 0)??Dt(`chat/stream`),x=p?p(y):{mcpServerUrl:e,llmConfig:t,authConfig:i,messages:y,...l&&l.size>0?{disabledTools:[...l]}:{}};O({type:`request`,request:{url:b,protocol:u,envelope:p?ia(x):{mcpServerUrl:e,llmConfig:{provider:t.provider,model:t.model,temperature:t.temperature,baseUrl:t.baseUrl},messages:y,...l&&l.size>0?{disabledTools:[...l]}:{}},providerMessages:_a(v)}});let w=await fetch(b,{method:`POST`,headers:{"Content-Type":`application/json`,...f},signal:E.current.signal,...d?{credentials:d}:{},body:JSON.stringify(x)});if(!w.ok){let t=await w.json().catch(()=>null);if(a){let e=tr(w.status,t);if(e){C(e);return}}if(w.status===401&&t?.error===`mcp_auth_required`){T({mcpServerUrl:t.mcpServerUrl??e,message:t.message});return}throw Error(`HTTP error! status: ${w.status}`)}let D=`assistant-${Date.now()}`,k=``,A=[];h(e=>[...e,{id:D,role:`assistant`,content:``,timestamp:Date.now(),parts:[]}]);let ee=w.body?.getReader(),j=new TextDecoder;if(!ee)throw Error(`No response body`);let M=()=>{h(e=>e.map(e=>e.id===D?{...e,parts:[...A]}:e))},N=()=>{h(e=>e.map(e=>e.id===D?{...e,parts:[...A],content:``}:e))},P=e=>{k+=e;let t=A[A.length-1];t&&t.type===`text`?t.text=k:A.push({type:`text`,text:k}),M()},F=new Map,I=new Map,L=(e,t)=>{k&&=``,!F.has(e)&&(A.push({type:`tool-invocation`,toolInvocation:{toolCallId:e,toolName:t,args:{},state:`streaming`,partialArgs:{}}}),F.set(e,A.length-1),I.set(e,``),M())},R=(e,t)=>{let n=F.get(e);if(n===void 0||!t)return;let r=(I.get(e)??``)+t;I.set(e,r);let i=ya(r),a=A[n]?.toolInvocation;!i||!a||(a.partialArgs=i,M())},te=(e,t,n)=>{k&&=``;let r=F.get(e),i=r===void 0?void 0:A[r]?.toolInvocation;i?(i.toolName=t,i.args=n,i.state=`pending`,i.partialArgs=void 0):(A.push({type:`tool-invocation`,toolInvocation:{toolCallId:e,toolName:t,args:n,state:`pending`}}),F.set(e,A.length-1)),I.delete(e),M()},z=(e,t)=>{let n;n=e.by===`toolName`?A.find(t=>t.type===`tool-invocation`&&t.toolInvocation?.toolName===e.toolName&&!t.toolInvocation?.result):A[e.index],n?.toolInvocation&&(n.toolInvocation.result=t,n.toolInvocation.state=t?.isError?`error`:`result`,M())},B=``;for(;;){if(E.current?.signal.aborted){await ee.cancel();break}let{done:e,value:t}=await ee.read();if(e)break;B+=j.decode(t,{stream:!0});let n=B.split(`
|
|
7
|
+
`);B=n.pop()||``;for(let e of n)if(e.trim())try{if(u===`data-stream`){let t=e.indexOf(`:`);if(t===-1)continue;let n=e.slice(0,t),r=e.slice(t+1),i;try{i=JSON.parse(r)}catch{continue}switch(n){case`0`:{let e=typeof i==`string`?i:String(i);O({type:`text-delta`,delta:e,raw:i}),P(e);break}case`b`:{let e=i,t=String(e.toolCallId??`tool-${A.length}`),n=String(e.toolName??``);O({type:`tool-call-start`,toolCallId:t,toolName:n,raw:i}),L(t,n);break}case`c`:{let e=i;R(String(e.toolCallId??``),String(e.argsTextDelta??e.argsDelta??``));break}case`9`:{let e=i,t=e.args??{};if(typeof t.input==`string`&&Object.keys(t).length===1)try{let e=JSON.parse(t.input);typeof e==`object`&&e&&(t=e)}catch{}let n=String(e.toolCallId??`tool-${A.length}`),r=String(e.toolName??``);F.has(n)||O({type:`tool-call-start`,toolCallId:n,toolName:r,raw:i}),O({type:`tool-call-args`,toolCallId:n,toolName:r,args:t,raw:i}),te(n,r,t);break}case`a`:{let e=i,t=F.get(e.toolCallId),n=e.result,r=n;if(r?.lc===1&&r?.type===`constructor`&&r?.kwargs?.content){let e=r.kwargs.content;if(typeof e==`string`)try{n=JSON.parse(e)}catch{n=e}}t!==void 0&&(O({type:`tool-result`,toolCallId:String(e.toolCallId??``),toolName:A[t]?.toolInvocation?.toolName??`Tool`,result:n,isError:!!(n&&typeof n==`object`&&n.isError),raw:i}),z({by:`index`,index:t},n));break}case`d`:{let e=na((i&&typeof i==`object`?i:void 0)?.usage);e&&O({type:`usage`,usage:e,raw:i}),O({type:`done`,raw:i}),N();break}case`3`:throw O({type:`error`,message:typeof i==`string`?i:JSON.stringify(i),raw:i}),Error(typeof i==`string`?i:JSON.stringify(i));default:break}}else{if(!e.startsWith(`data: `))continue;let t=JSON.parse(e.slice(6));if(t.type!==`message`){if(t.type===`text`)O({type:`text-delta`,delta:t.content,raw:t}),P(t.content);else if(t.type===`tool-call-start`){let e=t.toolCallId??`tool-${A.length}`;O({type:`tool-call-start`,toolCallId:e,toolName:t.toolName,raw:t}),L(e,t.toolName)}else if(t.type===`tool-call-delta`||t.type===`tool-call-args-delta`)R(t.toolCallId,t.argsDelta??t.argsTextDelta??``);else if(t.type===`tool-call`){let e=t.toolCallId??`tool-${A.length}`;F.has(e)||O({type:`tool-call-start`,toolCallId:e,toolName:t.toolName,raw:t}),O({type:`tool-call-args`,toolCallId:e,toolName:t.toolName,args:t.args,raw:t}),te(e,t.toolName,t.args)}else if(t.type===`tool-result`){O({type:`tool-result`,toolCallId:t.toolCallId,toolName:t.toolName,result:t.result,isError:t.isError??t.result?.isError,raw:t});let e=F.get(t.toolCallId);z(e===void 0?{by:`toolName`,toolName:t.toolName}:{by:`index`,index:e},t.result)}else if(t.type===`done`){let e=na(t.usage);e&&O({type:`usage`,usage:e,raw:t}),O({type:`done`,raw:t}),N()}else if(t.type===`usage`){let e=na(t.usage??t);e&&O({type:`usage`,usage:e,raw:t})}else if(t.type===`error`)throw O({type:`error`,message:t.message||`Streaming error`,raw:t}),Error(t.message||`Streaming error`)}}}catch(t){if(t instanceof Error&&t.message!==`Streaming error`)console.error(`Failed to parse streaming event:`,t,e);else throw t}}if(E.current?.signal.aborted){for(let e of A)e.type===`tool-invocation`&&(e.toolInvocation?.state===`pending`||e.toolInvocation?.state===`streaming`)&&(e.toolInvocation.state=`error`,e.toolInvocation.result=`Cancelled by user`);h(e=>e.map(e=>e.id===D?{...e,parts:[...A],content:``}:e))}}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;if(a&&Zn(e)){C({kind:`cloud_unavailable`});return}let t=`Unknown error occurred`;if(e instanceof Error){t=e.message;let n=e;n.status&&(t=`HTTP ${n.status}: ${t}`),(n.code===401||t.includes(`401`)||t.includes(`Unauthorized`))&&(t=`Authentication failed (401). Check your Authorization header in the connection settings.`)}let n={id:`error-${Date.now()}`,role:`assistant`,content:`Error: ${t}`,timestamp:Date.now()};h(e=>[...e,n])}finally{_(!1),E.current=null}},[t,i,e,m,n,r,v,a,o,s,l,u,d,f,p,O]),A=(0,Q.useCallback)(()=>{h([]),C(null),T(null),x(ta)},[]),ee=(0,Q.useCallback)(()=>{C(null)},[]),j=(0,Q.useCallback)(e=>{C(e)},[]),M=(0,Q.useCallback)(()=>x(ta),[]);return{messages:m,isLoading:g,attachments:v,managedChatNotice:S,mcpServerAuthRequired:w,sendMessage:k,clearMessages:A,clearManagedChatNotice:ee,showManagedChatNotice:j,clearMcpServerAuthRequired:(0,Q.useCallback)(()=>{T(null)},[]),setMessages:h,stop:(0,Q.useCallback)(()=>{E.current&&E.current.abort()},[]),addAttachment:(0,Q.useCallback)(async e=>{try{let t=await Ut(e);y(e=>{let n=[...e,t];return Kt(n)?n:(alert(`Total attachment size exceeds 20MB limit`),e)})}catch(e){e instanceof Error?alert(e.message):alert(`Failed to add attachment`)}},[]),removeAttachment:(0,Q.useCallback)(e=>{y(t=>t.filter((t,n)=>n!==e))},[]),clearAttachments:(0,Q.useCallback)(()=>{y([])},[]),clearTrace:M,traceEvents:b.events,tokenUsage:b.usage}}function Sa({connection:e,llmConfig:t,isConnected:n,readResource:r,widgetModelContexts:i,disabledTools:a,initialMessages:o,systemPrompt:s=Ni}){let[c,l]=(0,Q.useState)(o??[]),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)([]),[m,h]=(0,Q.useState)(ta),[g,_]=(0,Q.useState)(null),v=(0,Q.useRef)(null),y=(0,Q.useRef)(0),b=(0,Q.useCallback)(e=>{let t={...e,id:`trace-${++y.current}`,timestamp:Date.now()};h(e=>ca(e,t))},[]);(0,Q.useEffect)(()=>{o!==void 0&&l(o)},[o]);let x=(0,Q.useCallback)(async(r,o,u)=>{let m=[...f,...u??[]];if(!(r.trim()||o.length>0||m.length>0)||!t||!n)return;let h=va(o),g={id:`user-${Date.now()}`,role:`user`,content:r.trim(),timestamp:Date.now(),attachments:m.length>0?m:void 0},y=[...h];(r.trim()||m.length>0)&&y.push(g),l(e=>[...e,...y]),d(!0),p([]),v.current=new AbortController;let x=Date.now(),S=0,C=`assistant-${Date.now()}`;try{let n=``,o=[],u=new Map,d=0,f=async()=>{let e=Date.now();e-d>=80&&(d=e,await new Promise(e=>setTimeout(e,0)))};l(e=>[...e,{id:C,role:`assistant`,content:``,timestamp:Date.now(),parts:[]}]);let p=[];if(i&&i.size>0){let e=[];for(let[,t]of i)t&&(t.content?.length?e.push(t.content.map(e=>e.text).join(`
|
|
8
|
+
`)):t.structuredContent&&e.push(JSON.stringify(t.structuredContent)));e.length>0&&p.push({id:`widget-context-${Date.now()}`,role:`user`,content:`[Current Widget State]\n${e.join(`
|
|
9
|
+
`)}`,timestamp:Date.now()})}let m=(g.attachments?.length??0)>0,_=_a([...c,...h,...p,...r.trim()||m?[g]:[]]);b({type:`request`,request:{provider:t.provider,model:t.model,messages:_}});let y=new jt({llm:kt(t.provider,t.model,{apiKey:t.apiKey,temperature:t.temperature,baseUrl:t.baseUrl,credentials:t.credentials}),mcpServers:[e],systemPrompt:s,disallowedTools:a?[...a]:void 0,maxSteps:10,autoInitialize:!0}),w=()=>{l(e=>e.map(e=>e.id===C?{...e,parts:[...o]}:e))};for await(let e of y.streamEvents({messages:_,signal:v.current?.signal})){if(v.current?.signal.aborted)break;if(e.type===`usage`){let t=e;b({type:`usage`,usage:t.usage,raw:t});continue}if(e.type===`text-delta`){b({type:`text-delta`,delta:e.delta,raw:e}),n+=e.delta;let t=o[o.length-1];t&&t.type===`text`?t.text=n:o.push({type:`text`,text:n}),w()}else if(e.type===`tool-call-start`)b({type:`tool-call-start`,toolCallId:e.toolCallId,toolName:e.toolName,raw:e}),n&&=``,u.set(e.toolCallId,{accumulatedJson:``}),o.push({type:`tool-invocation`,toolInvocation:{toolCallId:e.toolCallId,toolName:e.toolName,args:{},state:`streaming`,partialArgs:{}}}),w();else if(e.type===`tool-call-args-delta`){let t=u.get(e.toolCallId);if(t){t.accumulatedJson+=e.argsDelta;let n=ya(t.accumulatedJson);if(n){let t=o.find(t=>t.type===`tool-invocation`&&t.toolInvocation?.state===`streaming`&&t.toolInvocation?.toolCallId===e.toolCallId);t&&t.toolInvocation&&(t.toolInvocation.partialArgs=n,w(),await f())}}}else if(e.type===`tool-call-ready`){b({type:`tool-call-args`,toolCallId:e.toolCallId,toolName:e.toolName,args:e.args,raw:e}),S++,n&&=``;let t=o.find(t=>t.type===`tool-invocation`&&t.toolInvocation?.state===`streaming`&&t.toolInvocation?.toolCallId===e.toolCallId);t&&t.toolInvocation?(t.toolInvocation.args=e.args,t.toolInvocation.state=`pending`,t.toolInvocation.partialArgs=void 0):o.push({type:`tool-invocation`,toolInvocation:{toolCallId:e.toolCallId,toolName:e.toolName,args:e.args,state:`pending`}}),w()}else if(e.type===`tool-result`){b({type:`tool-result`,toolCallId:e.toolCallId,toolName:e.toolName,result:e.result,isError:e.isError,raw:e});let t=o.find(t=>t.type===`tool-invocation`&&t.toolInvocation?.toolCallId===e.toolCallId&&!t.toolInvocation?.result);t&&t.toolInvocation&&(t.toolInvocation.result=e.result,t.toolInvocation.state=e.isError||e.result?.isError?`error`:`result`,w())}else if(e.type===`done`)b({type:`done`,raw:e});else if(e.type===`error`)throw b({type:`error`,message:e.message,raw:e}),Error(e.message)}if(v.current?.signal.aborted)for(let e of o)e.type===`tool-invocation`&&(e.toolInvocation?.state===`pending`||e.toolInvocation?.state===`streaming`)&&(e.toolInvocation.state=`error`,e.toolInvocation.result=`Cancelled by user`);l(e=>e.map(e=>e.id===C?{...e,parts:[...o],content:``}:e)),t&&Me(new Se({serverId:e.url,provider:t.provider,model:t.model,messageCount:c.length+1,toolCallsCount:S,success:!0,executionMode:`client-side`,duration:Date.now()-x})).catch(()=>{})}catch(n){if(n instanceof DOMException&&n.name===`AbortError`)return;let r=Xn(t)?er(n):null;if(r){_(r),l(e=>e.filter(e=>e.id!==C));return}console.error(`Client-side agent error:`,n);let i=`Unknown error occurred`;if(n instanceof Error){i=n.message;let e=n;e.status&&(i=`HTTP ${e.status}: ${i}`),(e.code===401||i.includes(`401`)||i.includes(`Unauthorized`))&&(i=`Authentication failed (401). Check your Authorization header in the connection settings.`)}t&&Me(new Se({serverId:e.url,provider:t.provider,model:t.model,messageCount:c.length+1,toolCallsCount:S,success:!1,executionMode:`client-side`,duration:Date.now()-x,error:i})).catch(()=>{});let a={id:`error-${Date.now()}`,role:`assistant`,content:`Error: ${i}`,timestamp:Date.now()};l(e=>[...e,a])}finally{d(!1),v.current=null}},[e,t,n,c,r,f,a,i,b,s]),S=(0,Q.useCallback)(()=>{l([]),h(ta),_(null)},[]),C=(0,Q.useCallback)(()=>h(ta),[]),w=(0,Q.useCallback)(()=>{v.current&&v.current.abort()},[]),T=(0,Q.useCallback)(async e=>{try{let t=await Ut(e);p(e=>{let n=[...e,t];return Kt(n)?n:(alert(`Total attachment size exceeds 20MB limit`),e)})}catch(e){e instanceof Error?alert(e.message):alert(`Failed to add attachment`)}},[]),E=(0,Q.useCallback)(e=>{p(t=>t.filter((t,n)=>n!==e))},[]),D=(0,Q.useCallback)(()=>{p([])},[]);return{messages:c,isLoading:u,attachments:f,managedChatNotice:g,sendMessage:x,clearMessages:S,clearManagedChatNotice:(0,Q.useCallback)(()=>{_(null)},[]),showManagedChatNotice:(0,Q.useCallback)(e=>{_(e)},[]),setMessages:l,stop:w,addAttachment:T,removeAttachment:E,clearAttachments:D,clearTrace:C,traceEvents:m.events,tokenUsage:m.usage}}function Ca({useClientSide:e,managedLlmConfig:t,localLlmConfig:n}){let r=!e&&t!=null,[i,a]=(0,Q.useState)(()=>Gt(r,n)),o=(0,Q.useCallback)(e=>{qt(e?`byok`:`managed`),a(e)},[]),s=r?i:e||i||!!n,c=!!t&&!i;return{forceClientSide:i,setForceClientSide:o,effectiveClientSide:s,llmConfig:c?t??null:n??t??null,isManaged:c,hostUsesServerManagedStream:r}}function wa({serverName:e,serverUrl:t,message:n,onReconnect:r,onDismiss:i}){let[a,o]=(0,Q.useState)(!1),s=(0,Q.useCallback)(async()=>{o(!0);try{await r()}finally{o(!1)}},[r]),c=e;if(!c)try{c=new URL(t).host}catch{c=t}return(0,$.jsx)(`div`,{className:`w-full flex justify-center items-center px-2 sm:px-4 mb-2`,children:(0,$.jsxs)(`div`,{role:`alert`,className:`w-full max-w-3xl flex items-start gap-3 rounded-md border border-amber-300/60 bg-amber-50 px-3 py-2 text-sm text-amber-900 dark:border-amber-500/40 dark:bg-amber-950/40 dark:text-amber-100`,children:[(0,$.jsx)(an,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`font-medium`,children:[`Reconnect to `,(0,$.jsx)(`span`,{className:`font-semibold`,children:c})]}),(0,$.jsx)(`div`,{className:`text-xs opacity-90`,children:n??`The MCP server rejected your credentials. Reconnect to refresh them.`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsxs)(R,{size:`sm`,variant:`default`,onClick:s,disabled:a,children:[(0,$.jsx)(me,{className:`size-3.5 ${a?`animate-spin`:``}`,"aria-hidden":!0}),a?`Reconnecting…`:`Reconnect`]}),i&&(0,$.jsx)(R,{size:`sm`,variant:`ghost`,onClick:i,"aria-label":`Dismiss`,children:`Dismiss`})]})]})})}function Ta({notice:e,onConfigureApiKey:t,onSignIn:n,authorizing:r=!1}){return(0,$.jsx)(`div`,{className:`mb-2 flex w-full justify-center px-2 sm:px-4`,children:(0,$.jsxs)(`p`,{role:`status`,"data-testid":`chat-managed-notice`,className:`max-w-3xl rounded-md border border-amber-300/60 bg-amber-50 px-3 py-2 text-center text-sm text-amber-900 dark:border-amber-500/40 dark:bg-amber-950/40 dark:text-amber-100`,children:[e.kind===`cloud_unavailable`&&(0,$.jsxs)($.Fragment,{children:[`Cloud chat is currently not available.`,` `,(0,$.jsx)(Ea,{onClick:t})]}),e.kind===`login_required`&&(0,$.jsxs)($.Fragment,{children:[`Sign in through Manufact Cloud to continue with managed chat.`,` `,n&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(R,{type:`button`,variant:`link`,size:`sm`,className:`h-auto px-0 align-baseline text-sm text-amber-900 hover:text-amber-700 dark:text-amber-100 dark:hover:text-amber-200`,disabled:r,onClick:n,children:r?`Authorizing…`:`Sign in`}),` · `]}),(0,$.jsx)(Ea,{onClick:t})]}),e.kind===`credits_exhausted`&&(0,$.jsxs)($.Fragment,{children:[e.message??`You've used your included free plan credits for managed chat.`,` `,e.billingUrl&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`a`,{href:e.billingUrl,target:`_blank`,rel:`noopener noreferrer`,className:`underline underline-offset-2 hover:text-amber-700 dark:hover:text-amber-200`,children:`Upgrade your plan`}),` · `]}),(0,$.jsx)(Ea,{onClick:t})]})]})})}function Ea({onClick:e}){return(0,$.jsx)(`button`,{type:`button`,onClick:e,className:`underline underline-offset-2 hover:text-amber-700 dark:hover:text-amber-200`,"data-testid":`chat-managed-notice-configure-link`,children:`Configure your own API key`})}function Da({events:e,usage:t}){return e.length===0?(0,$.jsx)(`p`,{className:`py-12 text-center text-sm text-muted-foreground`,children:`Raw request/response data will appear after the next message.`}):(0,$.jsx)(`div`,{className:`mx-auto max-w-4xl`,"data-testid":`chat-raw-view`,children:(0,$.jsx)(Je,{data:la(e,t),filename:`chat-raw.json`,collapsible:!0,defaultExpanded:!1})})}function Oa(e){return`mcp-inspector-system-prompt:${e}`}function ka(e){return typeof localStorage>`u`?null:localStorage.getItem(Oa(e))}function Aa(e,t){localStorage.setItem(Oa(e),t)}function ja(e){return e?.trim()||`You are a helpful assistant with access to MCP tools. Help users interact with the MCP server.`}function Ma(e){let[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(!1),a=Oa(e);return(0,Q.useEffect)(()=>{let t=()=>{n(ka(e))};t();let r=e=>{e.key===a&&t()};return window.addEventListener(`storage`,r),()=>window.removeEventListener(`storage`,r)},[e,a]),{prompt:t,savePrompt:(0,Q.useCallback)(async t=>{i(!0);try{Aa(e,t),n(t)}finally{i(!1)}},[e]),isSaving:r}}var Na=/(?:^\/$|\s+\/$)/,Pa=[`ArrowDown`,`ArrowUp`,`Escape`,`Enter`];function Fa({connection:e,isConnected:t,useClientSide:n=!0,enableKeyboardShortcuts:r=!0,prompts:i,serverId:a,callPrompt:o,readResource:s,chatApiUrl:l,waitForChatApiUrl:u,initialMessages:d,managedLlmConfig:f,managedCloudModel:p,enableFreeTierUpgrade:m=!1,clearButtonLabel:h,hideTitle:_,hideModelBadge:v,clearButtonHideIcon:y,clearButtonHideShortcut:x,clearButtonVariant:S,hideClearButton:C,hideToolSelector:w,chatQuickQuestions:T=[],chatFollowups:E=[],streamProtocol:D,credentials:O,extraHeaders:k,body:A,chatStorageProvider:ee,enableChatHistory:j,activeChatId:M,onActiveChatIdChange:N,titleGenerationReady:P,activeChatTitle:F,onChatTitleGenerated:I,defaultView:L=`conv`,systemPromptProvider:te,elevatedHeader:z}){let{isEmbedded:B}=Ne(),V=Ma(a),H=te??V,ne=(0,Q.useMemo)(()=>ja(H.prompt),[H.prompt]),re=(0,Q.useRef)(new Vn),U=ee??(!B&&j!==!1?re.current:null),[ie,W]=(0,Q.useState)(null),G=M??ie,ae=(0,Q.useCallback)(e=>{N?N(e):W(e)},[N]),[K,oe]=(0,Q.useState)(!1),[q,J]=(0,Q.useState)(0),[se,ce]=(0,Q.useState)(),[le,ue]=(0,Q.useState)(void 0),[Y,de]=(0,Q.useState)(``),[fe,pe]=(0,Q.useState)(!1),[me,ge]=(0,Q.useState)(-1),[_e,ve]=(0,Q.useState)(T),[ye,be]=(0,Q.useState)(E),[xe,Se]=(0,Q.useState)(L),[Ce,we]=(0,Q.useState)(new Set),Te=(0,Q.useRef)(null),Ee=(0,Q.useRef)(null),De=(0,Q.useRef)(null),Oe=(0,Q.useMemo)(()=>(e.tools??[]).map(e=>({name:e.name,description:e.description})),[e.tools]),{llmConfig:ke,authConfig:je,configDialogOpen:Me,setConfigDialogOpen:Pe,tempProvider:Ie,setTempProvider:Le,tempApiKey:Re,setTempApiKey:ze,tempModel:Be,setTempModel:Ve,tempBaseUrl:He,setTempBaseUrl:Ue,saveLLMConfig:We,clearConfig:Ge}=Yt({mcpServerUrl:e.url??``}),{setForceClientSide:Ke,effectiveClientSide:qe,llmConfig:X,isManaged:Je}=Ca({useClientSide:n,managedLlmConfig:f,localLlmConfig:ke}),{getAllModelContexts:Xe}=dt(),Ze=Xe(),Qe={connection:e,llmConfig:X,isConnected:t,readResource:s,widgetModelContexts:Ze,disabledTools:Ce},$e=xa({mcpServerUrl:e.url??``,llmConfig:X,authConfig:je,mcpAuthTokens:e.authTokens,isConnected:t,chatApiUrl:l,waitForChatApiUrl:u,widgetModelContexts:Ze,initialMessages:le??d,disabledTools:Ce,streamProtocol:D,credentials:O,extraHeaders:k,body:A}),et=Sa({...Qe,initialMessages:le??d,systemPrompt:ne}),{messages:Z,isLoading:nt,attachments:rt,sendMessage:at,clearMessages:ot,setMessages:ct,stop:lt,addAttachment:ut,removeAttachment:mt,clearTrace:ht,traceEvents:gt,tokenUsage:_t}=qe?et:$e,[vt,yt]=(0,Q.useState)(()=>Z.length===0?`visible`:`hidden`),bt=(0,Q.useCallback)(()=>{yt(e=>e===`visible`?`fading`:e)},[]),xt=(0,Q.useCallback)(()=>{ot(),yt(`visible`)},[ot]),{messagesEndRef:St,showScrollToBottom:Ct,showTopFade:wt,scrollToBottom:Tt}=ga(Ee,{messageCount:Z.length,isLoading:nt,enabled:!!X}),Et=(0,Q.useCallback)(async e=>{if(!U)return;let[t,n]=await Promise.all([U.getMessages(e),U.listChats({agentId:a})]);ue(t),ht(),ct(t),yt(t.length===0?`visible`:`hidden`),ae(e),ce(n.items.find(t=>t.id===e)?.title)},[U,ht,ct,ae,a]),Dt=(0,Q.useCallback)(async()=>{ot(),ue([]),yt(`visible`),ce(fn),ae(null),U?(ae((await U.createChat({agentId:a,agentName:e.displayName||e.name||`MCP Server`})).id),J(e=>e+1)):ce(void 0)},[ot,U,a,e.displayName,e.name,ae]),Ot=(0,Q.useCallback)(async()=>{if(!U||G)return G;let t=await U.createChat({agentId:a,agentName:e.displayName||e.name||`MCP Server`});return ae(t.id),ce(fn),J(e=>e+1),t.id},[U,G,a,e.displayName,e.name,ae]);(0,Q.useEffect)(()=>{!U?.saveMessages||!G||U.saveMessages(G,Z)},[U,G,Z]);let kt=(0,Q.useCallback)(()=>{J(e=>e+1)},[]),At=(0,Q.useCallback)((e,t)=>{ce(t),I?.(e,t)},[I]),jt=F??se,Mt=jt&&!mn(jt)?jt:pn;Hn({activeChatId:G,storage:U,messages:Z,isLoading:nt,effectiveClientSide:qe,llmConfig:X,activeChatTitle:jt,titleGenerationReady:P,onTitleGenerated:At,onHistoryRefetch:kt});let Nt=et.managedChatNotice??$e.managedChatNotice??null,Pt=(0,Q.useCallback)(()=>{et.clearManagedChatNotice(),$e.clearManagedChatNotice()},[et.clearManagedChatNotice,$e.clearManagedChatNotice]),It=(0,Q.useCallback)(e=>{et.showManagedChatNotice(e),$e.showManagedChatNotice(e)},[et.showManagedChatNotice,$e.showManagedChatNotice]),Lt=(0,Q.useCallback)(()=>{We()&&(Ke(!0),Pt())},[We,Ke,Pt]),Rt=qe?null:$e.mcpServerAuthRequired??null,zt=qe?void 0:$e.clearMcpServerAuthRequired,Bt=(0,Q.useCallback)(async()=>{try{await e.authenticate()}catch(e){console.error(`[ChatTab] MCP reconnect failed:`,e),pt.error(e instanceof Error?`Reconnect failed: ${e.message}`:`Reconnect failed`);return}zt?.()},[e,zt]),Vt=Rt?(0,$.jsx)(wa,{serverName:e.name,serverUrl:Rt.mcpServerUrl,message:Rt.message,onReconnect:Bt,onDismiss:zt}):null,Ht=(0,Q.useCallback)(()=>{Pe(!0)},[Pe]),{user:Ut,authorizing:Wt,authorize:Gt}=he(m?l:void 0),Kt=(0,Q.useCallback)(()=>{Pe(!1),Gt().catch(e=>{if(l&&Zn(e)){It({kind:`cloud_unavailable`});return}pt.error(e instanceof Error?e.message:`Authorization failed`)})},[Gt,l,Pe,It]),qt=Ut!=null;(0,Q.useEffect)(()=>{qt&&Nt?.kind===`login_required`&&Pt()},[Pt,qt,Nt?.kind]);let Jt=m&&!qt?{onLoginClick:Kt}:void 0,Xt=!!f&&!!v,Zt=Xt,Qt=m&&qt&&p?{models:p.models,selectedModelId:p.selectedModelId,onModelChange:p.setSelectedModelId,isLoading:p.isLoading}:void 0,$t=Je?`managed`:`byok`,en=Je&&p?.selectedModel?ft(p.selectedModel.name,p.selectedModel.provider):void 0,tn=(0,Q.useCallback)(()=>{Ke(!1),Pt(),Pe(!1)},[Pt,Pe,Ke]),{filteredPrompts:nn,setSelectedPrompt:rn,selectedPrompt:an,setPromptArgs:on,executePrompt:sn,results:cn,handleDeleteResult:ln,clearPromptResults:un}=Ft({prompts:i,callPrompt:o,serverId:a}),dn=(0,Q.useCallback)(e=>Array.isArray(e)?e.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean).slice(0,8):[],[]),hn=(0,Q.useCallback)(e=>{if(typeof e.content==`string`&&e.content.trim())return e.content;if(Array.isArray(e.content)&&e.content.length>0)return e.content.map(e=>typeof e==`string`?e:e.text??``).join(``);if(e.parts&&e.parts.length>0){let t=e.parts.filter(e=>e.type===`text`&&e.text).map(e=>e.text);if(t.length>0)return t.join(`
|
|
10
|
+
`)}return``},[]),gn=(0,Q.useCallback)(e=>{if(e==null)return`No result`;if(typeof e==`string`)try{let t=JSON.parse(e);return JSON.stringify(t,null,2)}catch{return e}if(typeof e==`object`&&Array.isArray(e.content)){let t=e.content;return t.length===0?`Empty result`:t.map(e=>{if(e.type===`text`){let t=e.text||``;try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}}return e.type===`image`?`[Image: ${e.mimeType}]`:e.type===`resource`?`[Resource: ${e.resource?.uri||`unknown`}]`:JSON.stringify(e,null,2)}).join(`
|
|
11
|
+
|
|
12
|
+
`)}return JSON.stringify(e,null,2)},[]),_n=(0,Q.useCallback)(()=>Z.map(e=>{let t=hn(e),n=e.parts?.filter(e=>e.type===`tool-invocation`&&e.toolInvocation).map(e=>({toolName:e.toolInvocation.toolName,args:e.toolInvocation.args,state:e.toolInvocation.state,result:typeof e.toolInvocation.result==`string`?e.toolInvocation.result.slice(0,2e3):e.toolInvocation.result==null?void 0:JSON.stringify(e.toolInvocation.result).slice(0,2e3)})),r=t||(n?.length?`[Tool calls: ${n.map(e=>`${e.toolName}(${e.state})`).join(`, `)}]`:``);return{id:e.id,role:e.role,content:r,timestamp:e.timestamp,toolInvocations:n?.length?n:void 0}}),[Z,hn]),vn=(0,Q.useCallback)((e,t={})=>{typeof window>`u`||window.parent===window||window.parent.postMessage({type:e,serverId:a,...t},`*`)},[a]);(0,Q.useEffect)(()=>{vn(`mcp-inspector:chat:ready`,{capabilities:{send:!0,clear:!0,getState:!0,setQuickQuestions:!0,setFollowups:!0,loadMessages:!0}})},[vn]),(0,Q.useEffect)(()=>{vn(`mcp-inspector:chat:state_changed`,{isLoading:nt,messageCount:Z.length,messages:_n(),quickQuestions:_e,followups:ye})},[ye,_n,nt,Z.length,vn,_e]),(0,Q.useEffect)(()=>{let e=e=>{if(!e.data||typeof e.data!=`object`)return;let n=e.data;if(!n.type?.startsWith(`mcp-inspector:chat:`)||n.serverId&&n.serverId!==a)return;let r=n.requestId,i=(e,t={})=>{vn(`mcp-inspector:chat:command_result`,{requestId:r,ok:e,...t})};if(n.type===`mcp-inspector:chat:send`){let e=(n.message??n.prompt??``).trim();if(!e){i(!1,{error:`Missing message`});return}if(!X||!t){i(!1,{error:`Chat is not ready to send messages`});return}Z.length===0&&bt(),at(e,[]).then(()=>{vn(`mcp-inspector:chat:message_sent`,{requestId:r,message:e,source:`bridge`}),i(!0)}).catch(e=>{i(!1,{error:e instanceof Error?e.message:String(e)})});return}if(n.type===`mcp-inspector:chat:clear`){xt(),vn(`mcp-inspector:chat:cleared`,{requestId:r}),i(!0);return}if(n.type===`mcp-inspector:chat:get_state`){vn(`mcp-inspector:chat:state`,{requestId:r,isLoading:nt,messageCount:Z.length,messages:_n(),quickQuestions:_e,followups:ye}),i(!0);return}if(n.type===`mcp-inspector:chat:set_quick_questions`){let e=dn(n.questions);ve(e),i(!0,{quickQuestions:e});return}if(n.type===`mcp-inspector:chat:set_followups`){let e=dn(n.followups);be(e),i(!0,{followups:e});return}if(n.type===`mcp-inspector:chat:load_messages`){let e=n.messages;if(!Array.isArray(e)){i(!1,{error:`messages must be an array`});return}ct(e),i(!0,{count:e.length});return}if(n.type===`mcp-inspector:chat:screenshot`){let e=n.toolCallId;(async()=>{try{let t=null;if(e&&(t=document.querySelector(`[data-tool-call-id="${e}"]`)),!t){let e=document.querySelectorAll(`[data-tool-call-id]`);e.length>0&&(t=e[e.length-1])}if(!t&&Ee.current&&(t=Ee.current),!t){i(!1,{error:`No screenshot target found`});return}let n=1e4,a=null,o=``,s=``;try{let e=await st(()=>import(`https://esm.sh/html-to-image@1.11.13`),[]);e?.toPng?a=await Promise.race([e.toPng(t,{pixelRatio:1,backgroundColor:`#ffffff`,includeQueryParams:!0}),new Promise((e,t)=>setTimeout(()=>t(Error(`html-to-image timed out`)),n))]):o=`toPng not found on module`}catch(e){o=e instanceof Error?e.message:String(e)}if(!a)try{if(!window.html2canvas){let e=document.createElement(`script`);e.src=`https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js`,document.head.appendChild(e),await new Promise((t,n)=>{e.onload=()=>t(),e.onerror=()=>n(Error(`Failed to load html2canvas`))})}let e=window.html2canvas;a=(await Promise.race([e(t,{useCORS:!0,allowTaint:!0,backgroundColor:`#ffffff`,scale:1,logging:!1,foreignObjectRendering:!1}),new Promise((e,t)=>setTimeout(()=>t(Error(`html2canvas timed out`)),n))])).toDataURL(`image/png`)}catch(e){s=e instanceof Error?e.message:String(e)}if(a)vn(`mcp-inspector:chat:screenshot_result`,{requestId:r,toolCallId:e||null,image:a,timestamp:Date.now()}),i(!0);else{let t=Ee.current||document.body,n=t.innerText?.substring(0,5e3)||``,a=t.innerHTML?.substring(0,1e4)||``;vn(`mcp-inspector:chat:screenshot_result`,{requestId:r,toolCallId:e||null,image:``,domText:n,domHtml:a,error:`html-to-image: ${o||`ok`}; html2canvas: ${s||`ok`}`,timestamp:Date.now()}),i(!1,{error:`html-to-image: ${o}; html2canvas: ${s}`})}}catch(t){let n=(Ee.current||document.body).innerText?.substring(0,5e3)||``;vn(`mcp-inspector:chat:screenshot_result`,{requestId:r,toolCallId:e||null,image:``,domText:n,error:t instanceof Error?t.message:`Screenshot capture failed`,timestamp:Date.now()}),i(!1,{error:t instanceof Error?t.message:`Screenshot failed`})}})();return}};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[xt,bt,ct,ye,_n,nt,Z.length,vn,_e,dn,at,a,X,t]),Ae(r?{onNewChat:U?Dt:xt}:{});let yn=t=>{let n=(0,$.jsx)(Yn,{className:`h-full w-full`,shaderPhase:vt,meshAnimationPaused:Me,onShaderFadeComplete:()=>yt(`hidden`),children:t});return U?(0,$.jsxs)(`div`,{className:`flex h-full flex-row overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`group/chat-history relative hidden shrink-0 flex-col overflow-visible transition-[width] duration-200 lg:flex`,style:{width:K?320:0},children:[K&&(0,$.jsx)(`div`,{className:`flex h-full w-full flex-col overflow-hidden border-r border-zinc-200 bg-background dark:border-zinc-700`,children:(0,$.jsx)(Mn,{provider:U,open:!0,onOpenChange:oe,currentChatId:G??void 0,agentId:a,agentDisplayNameFallback:e.displayName||e.name||`MCP Server`,onSelectChat:Et,variant:`inline`,containerClassName:`h-full border-0`,refetchKey:q,onCurrentChatDeleted:()=>void Dt()})}),K&&(0,$.jsx)(Nn,{onCollapse:()=>oe(!1)})]}),(0,$.jsxs)(`div`,{className:`relative min-w-0 flex-1 overflow-hidden`,children:[!K&&(0,$.jsx)(`div`,{"data-chat-history-toggle":!0,className:`absolute top-1/2 left-4 z-50 hidden -translate-y-1/2 lg:block [[data-mcp-widget-fullscreen]_&]:pointer-events-none [[data-mcp-widget-fullscreen]_&]:invisible`,children:(0,$.jsxs)(g,{children:[(0,$.jsx)(c,{render:(0,$.jsx)(R,{size:`icon`,variant:`outline`,className:`size-10 aspect-square rounded-full`,onClick:()=>oe(!0),children:(0,$.jsx)(tt,{size:16})}),nativeButton:!0}),(0,$.jsx)(b,{side:`right`,children:(0,$.jsx)(`p`,{children:`Chat History`})})]})}),n]})]}):n},bn=(0,Q.useCallback)(()=>{ge(-1),pe(!1),De.current=null},[]),xn=(0,Q.useCallback)(()=>{if(!Te.current)return;let e=Te.current.selectionStart,t=Y.slice(0,e),n=Na.test(t);pe(n),n?(De.current={start:e-1,end:e},ge(0)):bn()},[Y,bn]);(0,Q.useEffect)(()=>{X&&Z.length===0&&Te.current&&Te.current.focus()},[X,Z.length]),(0,Q.useEffect)(()=>{!nt&&Z.length>0&&Te.current&&Te.current.focus()},[nt,Z.length]),(0,Q.useEffect)(()=>{Te.current&&xn()},[Y,xn]);let Sn=(0,Q.useCallback)(()=>{rn(null),on({}),bn()},[bn]),Cn=(0,Q.useCallback)(async e=>{if(rn(e),e.arguments&&e.arguments.length>0){rn(null),pt.error(`Prompts with arguments are not supported`,{description:`This prompt requires arguments which are not yet supported in chat mode.`});return}try{await sn(e,{})}catch(e){console.error(`Error executing prompt`,e)}finally{if(Te.current&&De.current){let{start:e,end:t}=De.current;de(Y.slice(0,e)+Y.slice(t)),requestAnimationFrame(()=>{Te.current?.focus(),Te.current?.setSelectionRange(e,e)})}Sn()}},[sn,Sn,Y]),wn=(0,Q.useCallback)(()=>{(Y.trim()||cn.length>0||rt.length>0)&&(Z.length===0&&bt(),Ot().then(()=>{at(Y,cn),de(``),un()}))},[Y,cn,at,un,rt,Ot,Z.length,bt]),Tn=(0,Q.useCallback)(e=>{if(e.key===`ArrowDown`)ge(e=>nn.length===0?-1:(e+1)%nn.length);else if(e.key===`ArrowUp`)ge(e=>nn.length===0?-1:(e-1+nn.length)%nn.length);else if(e.key===`Escape`)e.stopPropagation(),bn();else if(e.key===`Enter`&&me>=0){let e=nn[me];e&&Cn(e)}},[nn,me,Cn,bn]),En=(0,Q.useCallback)(e=>{Pa.includes(e.key)&&fe?(e.preventDefault(),Tn(e)):e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),wn())},[wn,Tn,fe]),Dn=(0,Q.useCallback)(e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&xn()},[xn]),On=(0,Q.useCallback)(e=>{let t=`# Chat Export - ${new Date().toLocaleString()}\n\n`;return t+=e.map(e=>{let t=e.role.charAt(0).toUpperCase()+e.role.slice(1);if(!e.parts||e.parts.length===0){let n=hn(e).trim();return n?`## ${t}\n${n}`:``}let n=[];for(let t of e.parts)if(t.type===`text`&&t.text?.trim())n.push(t.text.trim());else if(t.type===`tool-invocation`&&t.toolInvocation){let e=t.toolInvocation,r=gn(e.result);n.push(`#### ${e.toolName}\n**Arguments:**\n\`\`\`json\n${JSON.stringify(e.args,null,2)}\n\`\`\`\n**Result:**\n\n${r}`)}return n.length===0?``:`## ${t}\n\n${n.join(`
|
|
13
|
+
|
|
14
|
+
`)}`}).filter(e=>e!==``).join(`
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
`),t},[hn,gn]),kn=(0,Q.useCallback)(()=>{Ye(On(Z)).then(()=>pt.success(`Chat copied to clipboard`),()=>pt.error(`Failed to copy chat`))},[Z,On]),An=(0,Q.useCallback)(e=>{let t=`chat-export-${new Date().toISOString().split(`T`)[0]}`;if(e===`json`)Fe(Z.map(e=>({id:e.id,role:e.role,content:hn(e),timestamp:e.timestamp,toolInvocations:e.parts?.filter(e=>e.type===`tool-invocation`&&e.toolInvocation).map(e=>({toolName:e.toolInvocation.toolName,args:e.toolInvocation.args,result:e.toolInvocation.result}))})),t+`.json`);else{let e=On(Z),n=new Blob([e],{type:`text/markdown`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=t+`.md`,document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>URL.revokeObjectURL(r),100)}pt.success(`Chat exported as ${e.toUpperCase()}`)},[Z,On,hn]),jn=(0,Q.useCallback)(()=>{Ge(),Dt()},[Ge,Dt]),Pn=(0,Q.useCallback)(e=>{e.trim()&&(!X||!t||(bt(),at(e,[]).then(()=>{vn(`mcp-inspector:chat:message_sent`,{message:e,source:`quick_question`})})))},[vn,at,X,t,bt]),Fn=(0,Q.useCallback)(e=>{e.trim()&&(!X||!t||at(e,[]).then(()=>{vn(`mcp-inspector:chat:message_sent`,{message:e,source:`followup`})}))},[vn,at,X,t]),In=Nt?(0,$.jsx)(Ta,{notice:Nt,onConfigureApiKey:Ht,onSignIn:Nt.kind===`login_required`?l?Kt:()=>{window.location.href=Nt.loginUrl}:void 0,authorizing:Wt}):null;return X&&Z.length===0?yn((0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`absolute top-4 right-4 z-10`,children:(0,$.jsx)(Tr,{open:Me,onOpenChange:Pe,tempProvider:Ie,tempModel:Be,tempApiKey:Re,tempBaseUrl:He,onProviderChange:Le,onModelChange:Ve,onApiKeyChange:ze,onBaseUrlChange:Ue,onSave:Lt,onClear:jn,showClearButton:!!ke,buttonLabel:`Change API Key`,hostedInspector:m,freeTierInfo:Jt,managedCloudInfo:Qt,useManagedCloud:Je,onSaveManagedCloud:Qt?tn:void 0})}),(0,$.jsx)(Li,{serverDisplayName:it(e),composerNotice:In,inputValue:Y,isConnected:t&&!Nt&&!Rt,isLoading:nt,textareaRef:Te,llmConfig:X,promptsDropdownOpen:fe,promptFocusedIndex:me,prompts:nn,selectedPrompt:an,promptResults:cn,attachments:rt,tools:w?void 0:Oe,disabledTools:w?void 0:Ce,onDisabledToolsChange:w?void 0:we,onDeletePromptResult:ln,onPromptSelect:Cn,onInputChange:de,onKeyDown:En,onKeyUp:Dn,onClick:xn,onSendMessage:wn,onStopStreaming:lt,onConfigDialogOpenChange:Pe,onAttachmentAdd:ut,onAttachmentRemove:mt,hideModelBadge:Zt,freeTierInfo:Jt,managedCloudInfo:Qt,modelBadgeMode:$t,modelDisplayName:en,quickQuestions:_e,onQuickQuestionSelect:Pn,pendingElicitationRequests:e.pendingElicitationRequests,onApproveElicitation:e.approveElicitation,onRejectElicitation:e.rejectElicitation,systemPromptProvider:H}),Vt]})):yn((0,$.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,$.jsx)(Ar,{llmConfig:X,hasMessages:Z.length>0,configDialogOpen:Me,onConfigDialogOpenChange:Pe,onClearChat:U?Dt:xt,tempProvider:Ie,tempModel:Be,tempApiKey:Re,tempBaseUrl:He,onProviderChange:Le,onModelChange:Ve,onApiKeyChange:ze,onBaseUrlChange:Ue,onSaveConfig:Lt,onClearConfig:jn,showClearButton:!!ke,hideConfigButton:Xt,hostedInspector:m,freeTierInfo:Jt,managedCloudInfo:Qt,useManagedCloud:Je,onSaveManagedCloud:Qt?tn:void 0,onCopyChat:kn,onExportChat:An,clearButtonLabel:h,hideTitle:_,clearButtonHideIcon:y,clearButtonHideShortcut:x,clearButtonVariant:S,hideClearButton:C,activeChatId:G,chatTitle:Mt,showViewToggle:!!X,viewIndex:+(xe===`raw`),onViewIndexChange:e=>Se(e===1?`raw`:`conv`),elevatedHeader:z}),(0,$.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,$.jsx)(ha,{visible:wt&&!!X}),(0,$.jsx)(`div`,{ref:Ee,"data-testid":`chat-messages-scroll-container`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-2 sm:p-4 pt-[80px] sm:pt-[100px]`,children:X?xe===`conv`?(0,$.jsx)(pa,{messages:Z,isLoading:nt,serverId:e.url,readResource:s,tools:e.tools,sendMessage:(e,t)=>at(e,[],t),serverBaseUrl:e.url,messagesEndRef:St,traceEvents:gt}):(0,$.jsx)(Da,{events:gt,usage:_t}):(0,$.jsx)(Ri,{onConfigureClick:()=>Pe(!0)})}),X&&(0,$.jsx)(ma,{visible:Ct,onClick:()=>Tt(`smooth`)})]}),X&&(0,$.jsxs)(`div`,{className:`relative shrink-0`,children:[In,(0,$.jsx)(Ii,{inputValue:Y,isConnected:t&&!Nt&&!Rt,isLoading:nt,textareaRef:Te,llmConfig:X,promptsDropdownOpen:fe,promptFocusedIndex:me,prompts:nn,promptResults:cn,selectedPrompt:an,attachments:rt,tools:w?void 0:Oe,disabledTools:w?void 0:Ce,onDisabledToolsChange:w?void 0:we,onDeletePromptResult:ln,onPromptSelect:Cn,onInputChange:de,onKeyDown:En,onKeyUp:Dn,onClick:xn,onSendMessage:wn,onStopStreaming:lt,onConfigDialogOpenChange:Pe,onAttachmentAdd:ut,onAttachmentRemove:mt,hideModelBadge:Zt,freeTierInfo:Jt,managedCloudInfo:Qt,modelBadgeMode:$t,modelDisplayName:en,followups:ye,onFollowupSelect:Fn,pendingElicitationRequests:e.pendingElicitationRequests,onApproveElicitation:e.approveElicitation,onRejectElicitation:e.rejectElicitation,systemPromptProvider:H})]}),Vt]}))}export{Fa as ChatTab};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{s as e,t}from"./react-CU_d2d5K.js";import{d as n,l as r,u as i}from"./input-C0OQCUZy.js";import{n as a}from"./createLucideIcon-BEHeJH0M.js";import{t as o}from"./button-C8Xa2k4x.js";import{L as s,dt as c,ft as l,lt as u,mt as d,ot as f,pt as p,tn as m,ut as h}from"./index-BMaSsizY.js";import{t as g}from"./inspector-settings-layout-yjKRJDai.js";import{n as _}from"./ListTabHeader-CrGae306.js";var v=e(t(),1);function y(e,t){let[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(`auto`),[m,g]=(0,v.useState)(`auto`),[_,y]=(0,v.useState)([]),[b,x]=(0,v.useState)(`10000`),[S,C]=(0,v.useState)(`True`),[w,T]=(0,v.useState)(`60000`),[E,D]=(0,v.useState)(h()),[O,k]=(0,v.useState)(``),[A,j]=(0,v.useState)(``),[M,N]=(0,v.useState)(``);return(0,v.useEffect)(()=>{if(!e||!t)return;let n=d(e,c(e.id));a(n.url),r(n.name||n.url);let i=n.proxyConfig?.proxyAddress||(typeof n.autoProxyFallback==`object`?n.autoProxyFallback.proxyAddress:void 0);s(n.connectionMode||`auto`),g(l(n.protocolNegotiation)),D(i||h());let o=n.headers||{};y(Object.entries(o).map(([e,t],n)=>({id:`header-${n}`,name:e,value:String(t)}))),k(n.oauth?.clientId||``),j(n.oauth?.clientSecret||``),N(n.oauth?.scope||``),n.requestTimeout!==void 0&&x(String(n.requestTimeout)),n.resetTimeoutOnProgress!==void 0&&C(n.resetTimeoutOnProgress?`True`:`False`),n.maxTotalTimeout!==void 0&&T(String(n.maxTotalTimeout))},[e,t]),{alias:n,setAlias:r,url:i,setUrl:a,connectionMode:o,setConnectionMode:s,protocolMode:m,setProtocolMode:g,customHeaders:_,setCustomHeaders:y,requestTimeout:b,setRequestTimeout:x,resetTimeoutOnProgress:S,setResetTimeoutOnProgress:C,maxTotalTimeout:w,setMaxTotalTimeout:T,proxyAddress:E,setProxyAddress:D,clientId:O,setClientId:k,clientSecret:A,setClientSecret:j,scope:M,setScope:N,buildConfig:()=>{if(!i.trim())return null;let e=i.trim();try{let t=new URL(e);if(!(t.protocol===`http:`||t.protocol===`https:`))return f.error(`Invalid URL protocol. Please use http:// or https://`),null}catch{try{let t=`https://${e}`,n=new URL(t);if(!(n.protocol===`http:`||n.protocol===`https:`))return f.error(`Invalid URL protocol. Please use http:// or https://`),null;e=t}catch{return f.error(`Invalid URL format. Please enter a valid URL.`),null}}let t=_.reduce((e,t)=>(t.name&&t.value&&(e[t.name]=t.value),e),{}),r=o===`proxy`&&E.trim()?{proxyAddress:E.trim(),headers:t}:void 0,a=o===`auto`&&E.trim()?{enabled:!0,proxyAddress:E.trim()}:!1,s=u(O,A,M),c=Number.parseInt(b,10),l=Number.parseInt(w,10);return{url:e,name:n.trim()||e,transportType:`http`,connectionMode:o,protocolNegotiation:p(m),proxyConfig:r,headers:Object.keys(t).length>0?t:void 0,autoProxyFallback:a,...s?{oauth:s}:{},...Number.isFinite(c)?{requestTimeout:c}:{},resetTimeoutOnProgress:S===`True`,...Number.isFinite(l)?{maxTotalTimeout:l}:{}}}}}var b=a();function x({connection:e,onSave:t}){let a=y(e,!0),[c,l]=(0,v.useState)(!1);return(0,b.jsxs)(`div`,{className:`h-full overflow-y-auto overscroll-none`,onScroll:e=>l(e.currentTarget.scrollTop>0),children:[(0,b.jsxs)(`div`,{className:`${r(c)} flex flex-row items-center justify-between gap-2 ${i}`,children:[(0,b.jsxs)(`h2`,{className:`${n} flex items-center gap-1.5`,children:[(0,b.jsx)(m,{className:_,"aria-hidden":!0}),`Connection Settings`]}),(0,b.jsx)(o,{"data-testid":`connection-form-save-button`,size:`sm`,onClick:()=>{let e=a.buildConfig();e&&t(e)},children:`Save`})]}),(0,b.jsx)(`div`,{className:g,children:(0,b.jsx)(s,{alias:a.alias,setAlias:a.setAlias,url:a.url,setUrl:a.setUrl,connectionMode:a.connectionMode,setConnectionMode:a.setConnectionMode,protocolMode:a.protocolMode,setProtocolMode:a.setProtocolMode,customHeaders:a.customHeaders,setCustomHeaders:a.setCustomHeaders,requestTimeout:a.requestTimeout,setRequestTimeout:a.setRequestTimeout,resetTimeoutOnProgress:a.resetTimeoutOnProgress,setResetTimeoutOnProgress:a.setResetTimeoutOnProgress,maxTotalTimeout:a.maxTotalTimeout,setMaxTotalTimeout:a.setMaxTotalTimeout,proxyAddress:a.proxyAddress,setProxyAddress:a.setProxyAddress,clientId:a.clientId,setClientId:a.setClientId,clientSecret:a.clientSecret,setClientSecret:a.setClientSecret,scope:a.scope,setScope:a.setScope,showConnectButton:!1,showExportButton:!1,inlineSections:!0,cardSections:!0})})]})}export{x as ConnectionSettingsTab};
|