@galaxycore/ai-chat 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +1 -1
- package/dist/appearance-CCOHF5L-.d.ts +19 -0
- package/dist/appearance.d.ts +2 -1
- package/dist/appearance.js +1 -1
- package/dist/branches-Dvdv5ug7.d.ts +398 -0
- package/dist/branches-M2XjURF5.js +539 -0
- package/dist/branches-M2XjURF5.js.map +1 -0
- package/dist/context.js +1 -1
- package/dist/headless.d.ts +2 -2
- package/dist/headless.js +2 -2
- package/dist/icons-CZZENm5N.d.ts +20 -0
- package/dist/index.d.ts +55 -3
- package/dist/index.js +874 -293
- package/dist/index.js.map +1 -1
- package/dist/styles.css +33 -0
- package/dist/{ui-primitives-BCbe9Ds8.js → ui-primitives-BzbdVU2_.js} +12 -2
- package/dist/ui-primitives-BzbdVU2_.js.map +1 -0
- package/docs/publishing.md +5 -5
- package/package.json +1 -1
- package/dist/appearance-BUtKwRL5.d.ts +0 -34
- package/dist/labels-BM5o9a9K.js +0 -116
- package/dist/labels-BM5o9a9K.js.map +0 -1
- package/dist/labels-a_-_yLBi.d.ts +0 -195
- package/dist/ui-primitives-BCbe9Ds8.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createContext, forwardRef, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
-
import { ArrowDown, ArrowUp, ArrowUpRight, AudioLines, Ban, Brain, ChartNoAxesCombined, Check, ChevronRight, CircleAlert, Copy, Crosshair, FileText, Link, LoaderCircle, Mic, MoreHorizontal, PanelTop, Plus, RotateCcw, Search, Sparkles, Square, SquarePen, Table2, TextQuote, Wrench, X } from "lucide-react";
|
|
3
|
+
import { ArrowDown, ArrowUp, ArrowUpRight, AtSign, AudioLines, Ban, Brain, ChartNoAxesCombined, Check, ChevronLeft, ChevronRight, CircleAlert, Compass, Copy, Crosshair, FileText, GitBranch, Layers, Link, LoaderCircle, Mic, MoreHorizontal, PanelTop, Paperclip, Plus, RotateCcw, Scan, Search, SlidersHorizontal, Sparkles, Square, SquarePen, Table2, TextQuote, Undo2, Wrench, X, Zap } from "lucide-react";
|
|
4
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { createPortal } from "react-dom";
|
|
6
6
|
//#region src/icons.tsx
|
|
@@ -27,7 +27,17 @@ const defaultIcons = {
|
|
|
27
27
|
more: MoreHorizontal,
|
|
28
28
|
edit: SquarePen,
|
|
29
29
|
chevron: ChevronRight,
|
|
30
|
+
chevronLeft: ChevronLeft,
|
|
31
|
+
undo: Undo2,
|
|
32
|
+
branch: GitBranch,
|
|
30
33
|
link: Link,
|
|
34
|
+
compass: Compass,
|
|
35
|
+
scan: Scan,
|
|
36
|
+
paperclip: Paperclip,
|
|
37
|
+
layers: Layers,
|
|
38
|
+
at: AtSign,
|
|
39
|
+
sliders: SlidersHorizontal,
|
|
40
|
+
zap: Zap,
|
|
31
41
|
tool: Wrench,
|
|
32
42
|
thinking: Brain,
|
|
33
43
|
warning: CircleAlert,
|
|
@@ -174,4 +184,4 @@ const ChatIconButton = forwardRef(function ChatIconButton({ label, icon, childre
|
|
|
174
184
|
//#endregion
|
|
175
185
|
export { ChatAppearanceProvider as n, Icon as r, ChatIconButton as t };
|
|
176
186
|
|
|
177
|
-
//# sourceMappingURL=ui-primitives-
|
|
187
|
+
//# sourceMappingURL=ui-primitives-BzbdVU2_.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-primitives-BzbdVU2_.js","names":[],"sources":["../src/icons.tsx","../src/ui-primitives.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, useContext, useMemo } from 'react';\nimport type { ComponentType, ReactNode } from 'react';\nimport {\n Mic, AudioLines, TextQuote, Table2, ChartNoAxesCombined, PanelTop, Crosshair, ArrowUpRight,\n ArrowDown, ArrowUp, AtSign, Ban, Brain, Check, ChevronLeft, ChevronRight, CircleAlert, Compass,\n Copy, FileText, GitBranch, Layers, Link, LoaderCircle, MoreHorizontal, Paperclip, Plus,\n RotateCcw, Scan, Sparkles, Search, SlidersHorizontal, Square, SquarePen, Undo2, Wrench, X, Zap,\n} from 'lucide-react';\nimport type { LucideProps } from 'lucide-react';\n\nexport type ChatIconName = 'send' | 'stop' | 'plus' | 'close' | 'copy' | 'check' | 'refresh' | 'down' | 'file' | 'sparkle' | 'more' | 'edit' | 'chevron' | 'chevronLeft' | 'undo' | 'branch' | 'link' | 'tool' | 'thinking' | 'warning' | 'blocked' | 'loader' | 'mic' | 'audio' | 'text' | 'table' | 'chart' | 'page' | 'target' | 'external' | 'search' | 'compass' | 'scan' | 'paperclip' | 'layers' | 'at' | 'sliders' | 'zap';\nexport type ChatIconProps = Omit<LucideProps, 'ref'>;\nexport type ChatIconOverrides = Partial<Record<ChatIconName, ComponentType<ChatIconProps>>>;\n/** @internal Alias retained for component implementations. */\nexport type IconName = ChatIconName;\n\n// Named imports keep the icon set small; consumers never download a dynamic icon registry.\nconst defaultIcons: Record<ChatIconName, ComponentType<ChatIconProps>> = {\n mic: Mic, audio: AudioLines, text: TextQuote, table: Table2, chart: ChartNoAxesCombined, page: PanelTop, target: Crosshair, external: ArrowUpRight, search: Search,\n send: ArrowUp, stop: Square, plus: Plus, close: X, copy: Copy, check: Check,\n refresh: RotateCcw, down: ArrowDown, file: FileText, sparkle: Sparkles,\n more: MoreHorizontal, edit: SquarePen, chevron: ChevronRight, chevronLeft: ChevronLeft,\n undo: Undo2, branch: GitBranch, link: Link,\n compass: Compass, scan: Scan, paperclip: Paperclip, layers: Layers, at: AtSign,\n sliders: SlidersHorizontal, zap: Zap,\n tool: Wrench, thinking: Brain, warning: CircleAlert, blocked: Ban, loader: LoaderCircle,\n};\n\nconst IconContext = createContext<ChatIconOverrides>({});\n\nexport interface ChatAppearanceProviderProps {\n /** Replace just the icons your product needs. Overrides inherit through nested providers. */\n icons?: ChatIconOverrides;\n children: ReactNode;\n}\n\n/** A DOM-free, instance-scoped provider. Works with ChatPanel and standalone primitives. */\nexport function ChatAppearanceProvider({ icons, children }: ChatAppearanceProviderProps) {\n const parent = useContext(IconContext);\n const value = useMemo(() => {\n const merged = { ...parent };\n for (const name of Object.keys(icons ?? {}) as ChatIconName[]) {\n if (icons?.[name]) merged[name] = icons[name];\n }\n return merged;\n }, [parent, icons]);\n return <IconContext.Provider value={value}>{children}</IconContext.Provider>;\n}\n\nexport function Icon({ name, ...props }: ChatIconProps & { name: ChatIconName }) {\n const overrides = useContext(IconContext);\n const Component = overrides[name] ?? defaultIcons[name];\n return <Component width={16} height={16} strokeWidth={1.6} aria-hidden=\"true\" focusable=\"false\" {...props} />;\n}\n","\"use client\";\n\nimport { forwardRef, useEffect, useRef, useState } from 'react';\nimport type { ButtonHTMLAttributes, CSSProperties, ReactNode } from 'react';\nimport { createPortal } from 'react-dom';\nimport { Icon, type ChatIconName } from './icons';\n\nexport interface ChatIconButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children'> {\n /** Accessible name; also used as the default tooltip. */\n label: string;\n icon?: ChatIconName;\n children?: ReactNode;\n size?: 'sm' | 'md';\n variant?: 'ghost' | 'filled';\n /** Set false to suppress the visual tooltip, or pass a more descriptive label. */\n tooltip?: boolean | string;\n}\n\ntype TooltipPosition = { left: number; top: number; placement: 'top' | 'bottom'; style: CSSProperties };\n\n/** Labelled native button with a viewport-safe tooltip. No wrapper affects host flex layouts. */\nexport const ChatIconButton = forwardRef<HTMLButtonElement, ChatIconButtonProps>(function ChatIconButton({\n label, icon, children, size = 'md', variant = 'ghost', tooltip = true, className, type = 'button',\n onPointerEnter, onPointerLeave, onPointerDown, onFocus, onBlur, onClick, onKeyDown, ...props\n}, forwardedRef) {\n const button = useRef<HTMLButtonElement | null>(null);\n const tooltipElement = useRef<HTMLSpanElement | null>(null);\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const [position, setPosition] = useState<TooltipPosition>();\n const text = typeof tooltip === 'string' ? tooltip : label;\n\n function hide() {\n clearTimeout(timer.current);\n setPosition(undefined);\n }\n function show(delay: number) {\n clearTimeout(timer.current);\n if (!tooltip || props.disabled) return;\n timer.current = setTimeout(() => {\n const element = button.current;\n if (!element || !element.isConnected) return;\n const rect = element.getBoundingClientRect();\n const theme = window.getComputedStyle(element);\n const placement = rect.top > 120 ? 'top' : 'bottom';\n // The tooltip is portalled to avoid clipping by message scrollers and panels.\n // Resolve tokens at the trigger so each instance retains its own theme.\n setPosition({\n left: Math.max(Math.min(128, window.innerWidth / 2), Math.min(window.innerWidth - Math.min(128, window.innerWidth / 2), rect.left + rect.width / 2)),\n top: placement === 'top' ? rect.top - 8 : rect.bottom + 8,\n placement,\n style: {\n background: theme.getPropertyValue('--gc-chat-tooltip-bg').trim() || '#272b32',\n color: theme.getPropertyValue('--gc-chat-tooltip-text').trim() || '#fff',\n fontFamily: theme.fontFamily,\n },\n });\n }, delay);\n }\n\n useEffect(() => () => clearTimeout(timer.current), []);\n useEffect(() => {\n if (!position) return;\n const dismiss = (event: KeyboardEvent) => { if (event.key === 'Escape') hide(); };\n // Hide on movement rather than leaving a detached tooltip over different content.\n const onScroll = (event: Event) => { if (event.target !== tooltipElement.current) hide(); };\n window.addEventListener('scroll', onScroll, true);\n window.addEventListener('resize', hide);\n window.addEventListener('keydown', dismiss);\n return () => {\n window.removeEventListener('scroll', onScroll, true);\n window.removeEventListener('resize', hide);\n window.removeEventListener('keydown', dismiss);\n };\n }, [position]);\n useEffect(() => { if (props.disabled || !tooltip) hide(); }, [props.disabled, tooltip]);\n\n return <>\n <button {...props} ref={element => {\n button.current = element;\n if (typeof forwardedRef === 'function') return forwardedRef(element);\n else if (forwardedRef) forwardedRef.current = element;\n }} type={type} aria-label={label}\n className={['gc-chat__icon-button', className].filter(Boolean).join(' ')}\n data-size={size} data-variant={variant}\n onPointerEnter={event => { onPointerEnter?.(event); if (!event.defaultPrevented && event.pointerType !== 'touch') show(400); }}\n onPointerLeave={event => { onPointerLeave?.(event); clearTimeout(timer.current); timer.current = setTimeout(hide, 150); }}\n onPointerDown={event => { onPointerDown?.(event); hide(); }}\n onFocus={event => { onFocus?.(event); if (!event.defaultPrevented) show(0); }}\n onBlur={event => { onBlur?.(event); hide(); }}\n onClick={event => { onClick?.(event); hide(); }}\n onKeyDown={event => { onKeyDown?.(event); if (event.key === 'Escape') hide(); }}>\n {children ?? (icon ? <Icon name={icon} /> : null)}\n </button>\n {position && createPortal(<span ref={tooltipElement} className=\"gc-chat__tooltip\" role=\"tooltip\" data-placement={position.placement}\n onPointerEnter={() => clearTimeout(timer.current)} onPointerLeave={hide}\n style={{ left: position.left, top: position.top, ...position.style }}>{text}</span>, button.current?.ownerDocument.body ?? document.body)}\n </>;\n});\n"],"mappings":";;;;;;AAmBA,MAAM,eAAmE;CACvE,KAAK;CAAK,OAAO;CAAY,MAAM;CAAW,OAAO;CAAQ,OAAO;CAAqB,MAAM;CAAU,QAAQ;CAAW,UAAU;CAAc,QAAQ;CAC5J,MAAM;CAAS,MAAM;CAAQ,MAAM;CAAM,OAAO;CAAG,MAAM;CAAM,OAAO;CACtE,SAAS;CAAW,MAAM;CAAW,MAAM;CAAU,SAAS;CAC9D,MAAM;CAAgB,MAAM;CAAW,SAAS;CAAc,aAAa;CAC3E,MAAM;CAAO,QAAQ;CAAW,MAAM;CACtC,SAAS;CAAS,MAAM;CAAM,WAAW;CAAW,QAAQ;CAAQ,IAAI;CACxE,SAAS;CAAmB,KAAK;CACjC,MAAM;CAAQ,UAAU;CAAO,SAAS;CAAa,SAAS;CAAK,QAAQ;AAC7E;AAEA,MAAM,cAAc,cAAiC,CAAC,CAAC;;AASvD,SAAgB,uBAAuB,EAAE,OAAO,YAAyC;CACvF,MAAM,SAAS,WAAW,WAAW;CACrC,MAAM,QAAQ,cAAc;EAC1B,MAAM,SAAS,EAAE,GAAG,OAAO;EAC3B,KAAK,MAAM,QAAQ,OAAO,KAAK,SAA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c;EAC/B,iBAAgB,UAAS;GAAE,iBAAiB,KAAK;GAAG,IAAI,CAAC,MAAM,oBAAoB,MAAM,gBAAgB,SAAS,KAAK,GAAG;EAAG;EAC7H,iBAAgB,UAAS;GAAE,iBAAiB,KAAK;GAAG,aAAa,MAAM,OAAO;GAAG,MAAM,UAAU,WAAW,MAAM,GAAG;EAAG;EACxH,gBAAe,UAAS;GAAE,gBAAgB,KAAK;GAAG,KAAK;EAAG;EAC1D,UAAS,UAAS;GAAE,UAAU,KAAK;GAAG,IAAI,CAAC,MAAM,kBAAkB,KAAK,CAAC;EAAG;EAC5E,SAAQ,UAAS;GAAE,SAAS,KAAK;GAAG,KAAK;EAAG;EAC5C,UAAS,UAAS;GAAE,UAAU,KAAK;GAAG,KAAK;EAAG;EAC9C,YAAW,UAAS;GAAE,YAAY,KAAK;GAAG,IAAI,MAAM,QAAQ,UAAU,KAAK;EAAG;EAC7E,UAAA,aAAa,OAAO,oBAAC,MAAD,EAAM,MAAM,KAAO,CAAA,IAAI;CACtC,CAAA,GACP,YAAY,aAAa,oBAAC,QAAD;EAAM,KAAK;EAAgB,WAAU;EAAmB,MAAK;EAAU,kBAAgB,SAAS;EACxH,sBAAsB,aAAa,MAAM,OAAO;EAAG,gBAAgB;EACnE,OAAO;GAAE,MAAM,SAAS;GAAM,KAAK,SAAS;GAAK,GAAG,SAAS;EAAM;EAAI,UAAA;CAAW,CAAA,GAAG,OAAO,SAAS,cAAc,QAAQ,SAAS,IAAI,CAC1I,EAAA,CAAA;AACJ,CAAC"}
|
package/docs/publishing.md
CHANGED
|
@@ -36,7 +36,7 @@ mkdir -p artifacts
|
|
|
36
36
|
npm pack --pack-destination artifacts
|
|
37
37
|
|
|
38
38
|
# 消费项目:替换为真实文件的绝对路径
|
|
39
|
-
npm install /absolute/path/to/galaxycore-ai-chat-0.
|
|
39
|
+
npm install /absolute/path/to/galaxycore-ai-chat-0.8.0.tgz
|
|
40
40
|
npm install ai@^7.0.137 @ai-sdk/react@^4.0.140
|
|
41
41
|
```
|
|
42
42
|
|
|
@@ -53,7 +53,7 @@ npm run check
|
|
|
53
53
|
npm pack --dry-run
|
|
54
54
|
mkdir -p artifacts
|
|
55
55
|
npm pack --pack-destination artifacts
|
|
56
|
-
tar -tzf artifacts/galaxycore-ai-chat-0.
|
|
56
|
+
tar -tzf artifacts/galaxycore-ai-chat-0.8.0.tgz
|
|
57
57
|
```
|
|
58
58
|
|
|
59
59
|
`check` 执行类型检查、组件与网关测试、库构建和可部署示例构建;示例构建包含文档站。`prepack` 构建库,`prepublishOnly` 执行完整检查。tarball 应包含公开 JS 入口、声明、CSS、README 和文档,不应包含模型凭据、认证配置或业务数据。
|
|
@@ -85,12 +85,12 @@ CI 构建和测试步骤无需发布凭据。发布 job 可使用 CI secret 注
|
|
|
85
85
|
|
|
86
86
|
## 版本与发布
|
|
87
87
|
|
|
88
|
-
当前组件版本为 `0.
|
|
88
|
+
当前组件版本为 `0.8.0`,网关版本为 `0.2.0`,两者独立升级。0.x 阶段,修复使用 patch,新增功能和未冻结接口调整使用 minor,并在 changelog 说明兼容性。稳定 API 后再发布 1.0。
|
|
89
89
|
|
|
90
90
|
下面以 npmjs.org 公开发布为例。命令会实际上传产物,应在完成验收后由发布负责人执行;发布私有 registry 时替换地址,并按该服务调整可见性参数:
|
|
91
91
|
|
|
92
92
|
```sh
|
|
93
|
-
npm publish ./artifacts/galaxycore-ai-chat-0.
|
|
93
|
+
npm publish ./artifacts/galaxycore-ai-chat-0.8.0.tgz \
|
|
94
94
|
--access public --tag latest \
|
|
95
95
|
--registry=https://registry.npmjs.org/
|
|
96
96
|
```
|
|
@@ -98,7 +98,7 @@ npm publish ./artifacts/galaxycore-ai-chat-0.7.0.tgz \
|
|
|
98
98
|
使用 tarball 发布时,先显式执行完整检查,不依赖源仓库的生命周期脚本一定被触发。`latest` 是不指定版本安装时使用的标签,不代表 API 已冻结。需要独立试用通道时,可以采用预发布版本及 `next` 标签。发布后检查远端版本和完整性:
|
|
99
99
|
|
|
100
100
|
```sh
|
|
101
|
-
npm view @galaxycore/ai-chat@0.
|
|
101
|
+
npm view @galaxycore/ai-chat@0.8.0 version dist.integrity \
|
|
102
102
|
--registry=https://registry.npmjs.org/
|
|
103
103
|
npm dist-tag ls @galaxycore/ai-chat \
|
|
104
104
|
--registry=https://registry.npmjs.org/
|
package/package.json
CHANGED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { ButtonHTMLAttributes, ComponentType, ReactNode } from "react";
|
|
3
|
-
import { LucideProps } from "lucide-react";
|
|
4
|
-
//#region src/icons.d.ts
|
|
5
|
-
type ChatIconName = 'send' | 'stop' | 'plus' | 'close' | 'copy' | 'check' | 'refresh' | 'down' | 'file' | 'sparkle' | 'more' | 'edit' | 'chevron' | 'link' | 'tool' | 'thinking' | 'warning' | 'blocked' | 'loader' | 'mic' | 'audio' | 'text' | 'table' | 'chart' | 'page' | 'target' | 'external' | 'search';
|
|
6
|
-
type ChatIconProps = Omit<LucideProps, 'ref'>;
|
|
7
|
-
type ChatIconOverrides = Partial<Record<ChatIconName, ComponentType<ChatIconProps>>>;
|
|
8
|
-
interface ChatAppearanceProviderProps {
|
|
9
|
-
/** Replace just the icons your product needs. Overrides inherit through nested providers. */
|
|
10
|
-
icons?: ChatIconOverrides;
|
|
11
|
-
children: ReactNode;
|
|
12
|
-
}
|
|
13
|
-
/** A DOM-free, instance-scoped provider. Works with ChatPanel and standalone primitives. */
|
|
14
|
-
declare function ChatAppearanceProvider({ icons, children }: ChatAppearanceProviderProps): import("react").JSX.Element;
|
|
15
|
-
declare function Icon({ name, ...props }: ChatIconProps & {
|
|
16
|
-
name: ChatIconName;
|
|
17
|
-
}): import("react").JSX.Element;
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region src/ui-primitives.d.ts
|
|
20
|
-
interface ChatIconButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children'> {
|
|
21
|
-
/** Accessible name; also used as the default tooltip. */
|
|
22
|
-
label: string;
|
|
23
|
-
icon?: ChatIconName;
|
|
24
|
-
children?: ReactNode;
|
|
25
|
-
size?: 'sm' | 'md';
|
|
26
|
-
variant?: 'ghost' | 'filled';
|
|
27
|
-
/** Set false to suppress the visual tooltip, or pass a more descriptive label. */
|
|
28
|
-
tooltip?: boolean | string;
|
|
29
|
-
}
|
|
30
|
-
/** Labelled native button with a viewport-safe tooltip. No wrapper affects host flex layouts. */
|
|
31
|
-
declare const ChatIconButton: import("react").ForwardRefExoticComponent<ChatIconButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
32
|
-
//#endregion
|
|
33
|
-
export { ChatIconName as a, Icon as c, ChatAppearanceProviderProps as i, ChatIconButtonProps as n, ChatIconOverrides as o, ChatAppearanceProvider as r, ChatIconProps as s, ChatIconButton as t };
|
|
34
|
-
//# sourceMappingURL=appearance-BUtKwRL5.d.ts.map
|
package/dist/labels-BM5o9a9K.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useChat } from "@ai-sdk/react";
|
|
3
|
-
//#region src/use-ai-chat.ts
|
|
4
|
-
/** Preserves the SDK's typed contract and throttles visual stream updates to 25 fps. */
|
|
5
|
-
function useAiChat(options = {}) {
|
|
6
|
-
const chat = useChat({
|
|
7
|
-
throttle: 40,
|
|
8
|
-
...options
|
|
9
|
-
});
|
|
10
|
-
return {
|
|
11
|
-
...chat,
|
|
12
|
-
isBusy: chat.status === "submitted" || chat.status === "streaming"
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
//#endregion
|
|
16
|
-
//#region src/labels.ts
|
|
17
|
-
const zhCN = {
|
|
18
|
-
title: "AI 助手",
|
|
19
|
-
assistant: "助手",
|
|
20
|
-
user: "你",
|
|
21
|
-
placeholder: "输入消息,与 AI 一起探索",
|
|
22
|
-
send: "发送消息",
|
|
23
|
-
stop: "停止生成",
|
|
24
|
-
attach: "添加附件",
|
|
25
|
-
removeAttachment: "移除附件",
|
|
26
|
-
uploading: "上传中",
|
|
27
|
-
uploadFailed: "附件上传失败,请重新添加",
|
|
28
|
-
tooManyFiles: "附件数量超过限制",
|
|
29
|
-
fileTooLarge: "文件大小超过限制",
|
|
30
|
-
fileNotAccepted: "不支持此文件类型",
|
|
31
|
-
emptyTitle: "有什么可以帮你?",
|
|
32
|
-
emptyDescription: "整理思路、理解资料,或从一个问题开始。",
|
|
33
|
-
thinking: "正在思考",
|
|
34
|
-
reasoning: "思考过程",
|
|
35
|
-
sources: "参考来源",
|
|
36
|
-
copy: "复制回答",
|
|
37
|
-
copied: "已复制",
|
|
38
|
-
regenerate: "重新生成",
|
|
39
|
-
retry: "重试",
|
|
40
|
-
error: "暂时无法完成回答,请重试。",
|
|
41
|
-
dismiss: "关闭提示",
|
|
42
|
-
jumpToLatest: "回到最新消息",
|
|
43
|
-
approve: "允许",
|
|
44
|
-
reject: "拒绝",
|
|
45
|
-
tool: "工具调用",
|
|
46
|
-
toolInput: "输入",
|
|
47
|
-
toolOutput: "结果",
|
|
48
|
-
toolPending: "准备中",
|
|
49
|
-
toolRunning: "执行中",
|
|
50
|
-
toolComplete: "已完成",
|
|
51
|
-
toolFailed: "执行失败",
|
|
52
|
-
toolDenied: "已拒绝",
|
|
53
|
-
toolApproval: "等待你的确认",
|
|
54
|
-
toolWaiting: "等待结果",
|
|
55
|
-
toolDetails: "展开详情",
|
|
56
|
-
toolHideDetails: "收起详情",
|
|
57
|
-
suggestions: "接下来可以",
|
|
58
|
-
composerHint: "Enter 发送 · Shift + Enter 换行",
|
|
59
|
-
unsupportedPart: "此内容需要自定义渲染器",
|
|
60
|
-
disclaimer: "AI 生成的内容可能不准确,请核实重要信息。"
|
|
61
|
-
};
|
|
62
|
-
const enUS = {
|
|
63
|
-
title: "AI assistant",
|
|
64
|
-
assistant: "Assistant",
|
|
65
|
-
user: "You",
|
|
66
|
-
placeholder: "Ask a question or explore an idea",
|
|
67
|
-
send: "Send message",
|
|
68
|
-
stop: "Stop generating",
|
|
69
|
-
attach: "Attach files",
|
|
70
|
-
removeAttachment: "Remove attachment",
|
|
71
|
-
uploading: "Uploading",
|
|
72
|
-
uploadFailed: "Upload failed. Please attach the file again.",
|
|
73
|
-
tooManyFiles: "Too many attachments",
|
|
74
|
-
fileTooLarge: "File exceeds the size limit",
|
|
75
|
-
fileNotAccepted: "File type is not supported",
|
|
76
|
-
emptyTitle: "How can I help?",
|
|
77
|
-
emptyDescription: "Make sense of your documents, explore ideas, or start with a question.",
|
|
78
|
-
thinking: "Thinking",
|
|
79
|
-
reasoning: "Reasoning",
|
|
80
|
-
sources: "Sources",
|
|
81
|
-
copy: "Copy response",
|
|
82
|
-
copied: "Copied",
|
|
83
|
-
regenerate: "Regenerate",
|
|
84
|
-
retry: "Retry",
|
|
85
|
-
error: "Unable to complete the response. Please try again.",
|
|
86
|
-
dismiss: "Dismiss",
|
|
87
|
-
jumpToLatest: "Jump to latest",
|
|
88
|
-
approve: "Approve",
|
|
89
|
-
reject: "Deny",
|
|
90
|
-
tool: "Tool call",
|
|
91
|
-
toolInput: "Input",
|
|
92
|
-
toolOutput: "Result",
|
|
93
|
-
toolPending: "Preparing",
|
|
94
|
-
toolRunning: "Running",
|
|
95
|
-
toolComplete: "Completed",
|
|
96
|
-
toolFailed: "Failed",
|
|
97
|
-
toolDenied: "Denied",
|
|
98
|
-
toolApproval: "Waiting for your approval",
|
|
99
|
-
toolWaiting: "Awaiting result",
|
|
100
|
-
toolDetails: "Show details",
|
|
101
|
-
toolHideDetails: "Hide details",
|
|
102
|
-
suggestions: "Suggested next steps",
|
|
103
|
-
composerHint: "Enter to send · Shift + Enter for a new line",
|
|
104
|
-
unsupportedPart: "This content requires a custom renderer",
|
|
105
|
-
disclaimer: "AI can make mistakes. Verify important information."
|
|
106
|
-
};
|
|
107
|
-
function resolveLabels(overrides) {
|
|
108
|
-
return {
|
|
109
|
-
...zhCN,
|
|
110
|
-
...overrides
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
//#endregion
|
|
114
|
-
export { useAiChat as i, resolveLabels as n, zhCN as r, enUS as t };
|
|
115
|
-
|
|
116
|
-
//# sourceMappingURL=labels-BM5o9a9K.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"labels-BM5o9a9K.js","names":[],"sources":["../src/use-ai-chat.ts","../src/labels.ts"],"sourcesContent":["\"use client\";\n\nimport { useChat } from '@ai-sdk/react';\nimport type { UIMessage } from 'ai';\nimport type { AiChatController, AiChatOptions } from './types';\n\n/** Preserves the SDK's typed contract and throttles visual stream updates to 25 fps. */\nexport function useAiChat<M extends UIMessage = UIMessage>(options: AiChatOptions<M> = {}): AiChatController<M> {\n const chat = useChat<M>({ throttle: 40, ...options });\n return { ...chat, isBusy: chat.status === 'submitted' || chat.status === 'streaming' };\n}\n","import type { ChatLabels } from './types';\n\nexport const zhCN: Required<ChatLabels> = {\n title: 'AI 助手', assistant: '助手', user: '你', placeholder: '输入消息,与 AI 一起探索',\n send: '发送消息', stop: '停止生成', attach: '添加附件', removeAttachment: '移除附件',\n uploading: '上传中', uploadFailed: '附件上传失败,请重新添加', tooManyFiles: '附件数量超过限制',\n fileTooLarge: '文件大小超过限制', fileNotAccepted: '不支持此文件类型',\n emptyTitle: '有什么可以帮你?', emptyDescription: '整理思路、理解资料,或从一个问题开始。',\n thinking: '正在思考', reasoning: '思考过程', sources: '参考来源', copy: '复制回答', copied: '已复制',\n regenerate: '重新生成', retry: '重试', error: '暂时无法完成回答,请重试。', dismiss: '关闭提示',\n jumpToLatest: '回到最新消息', approve: '允许', reject: '拒绝', tool: '工具调用', toolInput: '输入',\n toolOutput: '结果', toolPending: '准备中', toolRunning: '执行中', toolComplete: '已完成',\n toolFailed: '执行失败', toolDenied: '已拒绝', toolApproval: '等待你的确认',\n toolWaiting: '等待结果', toolDetails: '展开详情', toolHideDetails: '收起详情',\n suggestions: '接下来可以', composerHint: 'Enter 发送 · Shift + Enter 换行',\n unsupportedPart: '此内容需要自定义渲染器', disclaimer: 'AI 生成的内容可能不准确,请核实重要信息。',\n};\n\nexport const enUS: Required<ChatLabels> = {\n title: 'AI assistant', assistant: 'Assistant', user: 'You', placeholder: 'Ask a question or explore an idea',\n send: 'Send message', stop: 'Stop generating', attach: 'Attach files', removeAttachment: 'Remove attachment',\n uploading: 'Uploading', uploadFailed: 'Upload failed. Please attach the file again.', tooManyFiles: 'Too many attachments',\n fileTooLarge: 'File exceeds the size limit', fileNotAccepted: 'File type is not supported',\n emptyTitle: 'How can I help?', emptyDescription: 'Make sense of your documents, explore ideas, or start with a question.',\n thinking: 'Thinking', reasoning: 'Reasoning', sources: 'Sources', copy: 'Copy response', copied: 'Copied',\n regenerate: 'Regenerate', retry: 'Retry', error: 'Unable to complete the response. Please try again.', dismiss: 'Dismiss',\n jumpToLatest: 'Jump to latest', approve: 'Approve', reject: 'Deny', tool: 'Tool call', toolInput: 'Input',\n toolOutput: 'Result', toolPending: 'Preparing', toolRunning: 'Running', toolComplete: 'Completed',\n toolFailed: 'Failed', toolDenied: 'Denied', toolApproval: 'Waiting for your approval',\n toolWaiting: 'Awaiting result', toolDetails: 'Show details', toolHideDetails: 'Hide details',\n suggestions: 'Suggested next steps', composerHint: 'Enter to send · Shift + Enter for a new line',\n unsupportedPart: 'This content requires a custom renderer', disclaimer: 'AI can make mistakes. Verify important information.',\n};\n\nexport function resolveLabels(overrides?: Partial<ChatLabels>): Required<ChatLabels> {\n return { ...zhCN, ...overrides };\n}\n"],"mappings":";;;;AAOA,SAAgB,UAA2C,UAA4B,CAAC,GAAwB;CAC9G,MAAM,OAAO,QAAW;EAAE,UAAU;EAAI,GAAG;CAAQ,CAAC;CACpD,OAAO;EAAE,GAAG;EAAM,QAAQ,KAAK,WAAW,eAAe,KAAK,WAAW;CAAY;AACvF;;;ACRA,MAAa,OAA6B;CACxC,OAAO;CAAS,WAAW;CAAM,MAAM;CAAK,aAAa;CACzD,MAAM;CAAQ,MAAM;CAAQ,QAAQ;CAAQ,kBAAkB;CAC9D,WAAW;CAAO,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4
|
-
import { HTMLAttributes, ReactNode, Ref } from "react";
|
|
5
|
-
import { ChatRequestOptions, FileUIPart, UIMessage } from "ai";
|
|
6
|
-
//#region src/types.d.ts
|
|
7
|
-
type AiChatController<M extends UIMessage = UIMessage> = UseChatHelpers<M> & {
|
|
8
|
-
isBusy: boolean;
|
|
9
|
-
};
|
|
10
|
-
type AiChatOptions<M extends UIMessage = UIMessage> = UseChatOptions<M>;
|
|
11
|
-
interface ChatLabels {
|
|
12
|
-
title: string;
|
|
13
|
-
assistant: string;
|
|
14
|
-
user: string;
|
|
15
|
-
placeholder: string;
|
|
16
|
-
send: string;
|
|
17
|
-
stop: string;
|
|
18
|
-
attach: string;
|
|
19
|
-
removeAttachment: string;
|
|
20
|
-
uploading: string;
|
|
21
|
-
uploadFailed: string;
|
|
22
|
-
tooManyFiles: string;
|
|
23
|
-
fileTooLarge: string;
|
|
24
|
-
fileNotAccepted: string;
|
|
25
|
-
emptyTitle: string;
|
|
26
|
-
emptyDescription: string;
|
|
27
|
-
thinking: string;
|
|
28
|
-
reasoning: string;
|
|
29
|
-
sources: string;
|
|
30
|
-
copy: string;
|
|
31
|
-
copied: string;
|
|
32
|
-
regenerate: string;
|
|
33
|
-
retry: string;
|
|
34
|
-
error: string;
|
|
35
|
-
dismiss: string;
|
|
36
|
-
jumpToLatest: string;
|
|
37
|
-
approve: string;
|
|
38
|
-
reject: string;
|
|
39
|
-
tool: string;
|
|
40
|
-
toolInput: string;
|
|
41
|
-
toolOutput: string;
|
|
42
|
-
toolPending: string;
|
|
43
|
-
toolRunning: string;
|
|
44
|
-
toolComplete: string;
|
|
45
|
-
toolFailed: string;
|
|
46
|
-
toolDenied: string;
|
|
47
|
-
toolApproval: string;
|
|
48
|
-
unsupportedPart: string;
|
|
49
|
-
disclaimer: string;
|
|
50
|
-
/** Optional additions keep existing complete locale objects compatible. */
|
|
51
|
-
toolWaiting?: string;
|
|
52
|
-
toolDetails?: string;
|
|
53
|
-
toolHideDetails?: string;
|
|
54
|
-
suggestions?: string;
|
|
55
|
-
composerHint?: string;
|
|
56
|
-
}
|
|
57
|
-
type TextRenderer = (props: {
|
|
58
|
-
text: string;
|
|
59
|
-
isStreaming: boolean;
|
|
60
|
-
}) => ReactNode;
|
|
61
|
-
interface PartRendererProps<M extends UIMessage = UIMessage, P = M['parts'][number]> {
|
|
62
|
-
part: P;
|
|
63
|
-
message: M;
|
|
64
|
-
isStreaming: boolean;
|
|
65
|
-
chat: AiChatController<M>;
|
|
66
|
-
}
|
|
67
|
-
type PartRenderers<M extends UIMessage = UIMessage> = Partial<{ [T in M['parts'][number]['type']]: (props: PartRendererProps<M, Extract<M['parts'][number], {
|
|
68
|
-
type: T;
|
|
69
|
-
}>>) => ReactNode; }>;
|
|
70
|
-
type ToolPart<M extends UIMessage = UIMessage> = Extract<M['parts'][number], {
|
|
71
|
-
type: `tool-${string}` | 'dynamic-tool';
|
|
72
|
-
}>;
|
|
73
|
-
type ToolRenderers<M extends UIMessage = UIMessage> = Record<string, (props: PartRendererProps<M, ToolPart<M>>) => ReactNode>;
|
|
74
|
-
/** Customize the default activity row without replacing its states, details or approval controls. */
|
|
75
|
-
interface ToolPresentation {
|
|
76
|
-
title?: string;
|
|
77
|
-
/** Decorative, non-interactive icon. Runtime state indicators remain visible separately. */
|
|
78
|
-
icon?: ReactNode;
|
|
79
|
-
/** Short, host-authored context such as a file name or result count. Never HTML. */
|
|
80
|
-
summary?: string;
|
|
81
|
-
}
|
|
82
|
-
type ToolPresentationResolver<M extends UIMessage = UIMessage> = (props: PartRendererProps<M, ToolPart<M>>) => ToolPresentation | undefined;
|
|
83
|
-
interface ChatMessageActionContext<M extends UIMessage = UIMessage> {
|
|
84
|
-
message: M;
|
|
85
|
-
chat: AiChatController<M>;
|
|
86
|
-
/** Focus this panel's input without changing or sending its draft. */
|
|
87
|
-
focusComposer: () => void;
|
|
88
|
-
}
|
|
89
|
-
/** Host-authored actions; labels never become prompts automatically. */
|
|
90
|
-
interface ChatSuggestedAction<M extends UIMessage = UIMessage> {
|
|
91
|
-
id: string;
|
|
92
|
-
label: string;
|
|
93
|
-
icon?: ReactNode;
|
|
94
|
-
trailingIcon?: ReactNode;
|
|
95
|
-
emphasis?: 'recommended' | 'secondary' | 'quiet';
|
|
96
|
-
pendingLabel?: string;
|
|
97
|
-
disabled?: boolean;
|
|
98
|
-
onSelect: (context: ChatMessageActionContext<M>) => void | Promise<void>;
|
|
99
|
-
}
|
|
100
|
-
interface AttachmentOptions {
|
|
101
|
-
upload: (file: File, context: {
|
|
102
|
-
signal: AbortSignal;
|
|
103
|
-
}) => Promise<FileUIPart>;
|
|
104
|
-
/** Defaults to 5. */
|
|
105
|
-
maxFiles?: number;
|
|
106
|
-
/** Defaults to 10 MiB per file. */
|
|
107
|
-
maxSize?: number;
|
|
108
|
-
/** Same comma-separated syntax as an HTML file input's accept. */
|
|
109
|
-
accept?: string;
|
|
110
|
-
}
|
|
111
|
-
interface ChatComposerProps<M extends UIMessage = UIMessage> {
|
|
112
|
-
chat: AiChatController<M>;
|
|
113
|
-
labels?: Partial<ChatLabels>;
|
|
114
|
-
attachments?: AttachmentOptions;
|
|
115
|
-
/** Optional dictation adapter; transcripts are editable and never auto-sent. */
|
|
116
|
-
speech?: SpeechInputOptions;
|
|
117
|
-
toolbar?: ReactNode;
|
|
118
|
-
context?: ReactNode;
|
|
119
|
-
requestOptions?: ChatRequestOptions;
|
|
120
|
-
disabled?: boolean;
|
|
121
|
-
className?: string;
|
|
122
|
-
onActionError?: (error: Error) => void;
|
|
123
|
-
}
|
|
124
|
-
interface ChatScrollHandle {
|
|
125
|
-
/** Reveal a transcript target, pausing follow only when the message viewport moves. */
|
|
126
|
-
reveal(target: Element | Range): boolean;
|
|
127
|
-
}
|
|
128
|
-
interface ChatMessagesProps<M extends UIMessage = UIMessage> {
|
|
129
|
-
chat: AiChatController<M>;
|
|
130
|
-
labels?: Partial<ChatLabels>;
|
|
131
|
-
/** Overrides default assistant Markdown and literal user text rendering. */
|
|
132
|
-
renderText?: TextRenderer;
|
|
133
|
-
/** Smooth append-only assistant text in a short display buffer. Defaults to true.
|
|
134
|
-
* Does not change messages or tool events. Stop/completion and reduced motion flush immediately.
|
|
135
|
-
* Custom part renderers retain control of their own presentation. */
|
|
136
|
-
smoothStreaming?: boolean;
|
|
137
|
-
/** Optional access to programmatic navigation inside the message viewport. */
|
|
138
|
-
scrollRef?: Ref<ChatScrollHandle>;
|
|
139
|
-
renderers?: PartRenderers<M>;
|
|
140
|
-
tools?: ToolRenderers<M>;
|
|
141
|
-
toolPresentation?: ToolPresentationResolver<M>;
|
|
142
|
-
/** Only shown below the latest completed assistant message. At most three. */
|
|
143
|
-
suggestedActions?: readonly ChatSuggestedAction<M>[];
|
|
144
|
-
suggestionsTitle?: ReactNode;
|
|
145
|
-
suggestionsDescription?: ReactNode;
|
|
146
|
-
/** Inline confirmation/clarification content in the latest assistant turn. */
|
|
147
|
-
renderMessageActions?: (context: ChatMessageActionContext<M>) => ReactNode;
|
|
148
|
-
/** Return null to hide the default assistant identity; timestamps remain host-owned. */
|
|
149
|
-
renderMessageHeader?: (context: {
|
|
150
|
-
message: M;
|
|
151
|
-
isStreaming: boolean;
|
|
152
|
-
chat: AiChatController<M>;
|
|
153
|
-
}) => ReactNode;
|
|
154
|
-
empty?: ReactNode;
|
|
155
|
-
className?: string;
|
|
156
|
-
requestOptions?: ChatRequestOptions;
|
|
157
|
-
onActionError?: (error: Error) => void;
|
|
158
|
-
/** Hide operations unsupported by the connected runtime. */
|
|
159
|
-
capabilities?: {
|
|
160
|
-
regenerate?: boolean;
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
interface ChatPanelProps<M extends UIMessage = UIMessage> extends Omit<HTMLAttributes<HTMLElement>, 'children'>, ChatMessagesProps<M> {
|
|
164
|
-
title?: string;
|
|
165
|
-
subtitle?: ReactNode;
|
|
166
|
-
headerIcon?: ReactNode;
|
|
167
|
-
header?: ReactNode;
|
|
168
|
-
headerActions?: ReactNode;
|
|
169
|
-
footer?: ReactNode;
|
|
170
|
-
composer?: ReactNode;
|
|
171
|
-
composerProps?: Omit<ChatComposerProps<M>, 'chat' | 'labels' | 'requestOptions' | 'onActionError'>;
|
|
172
|
-
theme?: 'light' | 'dark' | 'auto';
|
|
173
|
-
variant?: 'panel' | 'sidebar' | 'embedded';
|
|
174
|
-
density?: 'comfortable' | 'compact';
|
|
175
|
-
}
|
|
176
|
-
interface AiChatProps<M extends UIMessage = UIMessage> extends Omit<ChatPanelProps<M>, 'chat'> {
|
|
177
|
-
options?: AiChatOptions<M>;
|
|
178
|
-
}
|
|
179
|
-
//#endregion
|
|
180
|
-
//#region src/use-ai-chat.d.ts
|
|
181
|
-
/** Preserves the SDK's typed contract and throttles visual stream updates to 25 fps. */
|
|
182
|
-
declare function useAiChat<M extends UIMessage = UIMessage>(options?: AiChatOptions<M>): AiChatController<M>;
|
|
183
|
-
//#endregion
|
|
184
|
-
//#region src/utils.d.ts
|
|
185
|
-
declare function getMessageText(message: UIMessage): string;
|
|
186
|
-
/** Only web URLs and same-origin paths. Never render model-supplied javascript/data links. */
|
|
187
|
-
declare function safeUrl(value: string | undefined): string | undefined;
|
|
188
|
-
declare function acceptsFile(file: Pick<File, 'name' | 'type'>, accept?: string): boolean;
|
|
189
|
-
//#endregion
|
|
190
|
-
//#region src/labels.d.ts
|
|
191
|
-
declare const zhCN: Required<ChatLabels>;
|
|
192
|
-
declare const enUS: Required<ChatLabels>;
|
|
193
|
-
//#endregion
|
|
194
|
-
export { ToolPresentationResolver as C, ToolPresentation as S, ChatSuggestedAction as _, safeUrl as a, TextRenderer as b, AiChatOptions as c, ChatComposerProps as d, ChatLabels as f, ChatScrollHandle as g, ChatPanelProps as h, getMessageText as i, AiChatProps as l, ChatMessagesProps as m, zhCN as n, useAiChat as o, ChatMessageActionContext as p, acceptsFile as r, AiChatController as s, enUS as t, AttachmentOptions as u, PartRendererProps as v, ToolRenderers as w, ToolPart as x, PartRenderers as y };
|
|
195
|
-
//# sourceMappingURL=labels-a_-_yLBi.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ui-primitives-BCbe9Ds8.js","names":[],"sources":["../src/icons.tsx","../src/ui-primitives.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, useContext, useMemo } from 'react';\nimport type { ComponentType, ReactNode } from 'react';\nimport {\n Mic, AudioLines, TextQuote, Table2, ChartNoAxesCombined, PanelTop, Crosshair, ArrowUpRight,\n ArrowDown, ArrowUp, Ban, Brain, Check, ChevronRight, CircleAlert, Copy,\n FileText, Link, LoaderCircle, MoreHorizontal, Plus, RotateCcw, Sparkles,\n Search, Square, SquarePen, Wrench, X,\n} from 'lucide-react';\nimport type { LucideProps } from 'lucide-react';\n\nexport type ChatIconName = 'send' | 'stop' | 'plus' | 'close' | 'copy' | 'check' | 'refresh' | 'down' | 'file' | 'sparkle' | 'more' | 'edit' | 'chevron' | 'link' | 'tool' | 'thinking' | 'warning' | 'blocked' | 'loader' | 'mic' | 'audio' | 'text' | 'table' | 'chart' | 'page' | 'target' | 'external' | 'search';\nexport type ChatIconProps = Omit<LucideProps, 'ref'>;\nexport type ChatIconOverrides = Partial<Record<ChatIconName, ComponentType<ChatIconProps>>>;\n/** @internal Alias retained for component implementations. */\nexport type IconName = ChatIconName;\n\n// Named imports keep the icon set small; consumers never download a dynamic icon registry.\nconst defaultIcons: Record<ChatIconName, ComponentType<ChatIconProps>> = {\n mic: Mic, audio: AudioLines, text: TextQuote, table: Table2, chart: ChartNoAxesCombined, page: PanelTop, target: Crosshair, external: ArrowUpRight, search: Search,\n send: ArrowUp, stop: Square, plus: Plus, close: X, copy: Copy, check: Check,\n refresh: RotateCcw, down: ArrowDown, file: FileText, sparkle: Sparkles,\n more: MoreHorizontal, edit: SquarePen, chevron: ChevronRight, link: Link,\n tool: Wrench, thinking: Brain, warning: CircleAlert, blocked: Ban, loader: LoaderCircle,\n};\n\nconst IconContext = createContext<ChatIconOverrides>({});\n\nexport interface ChatAppearanceProviderProps {\n /** Replace just the icons your product needs. Overrides inherit through nested providers. */\n icons?: ChatIconOverrides;\n children: ReactNode;\n}\n\n/** A DOM-free, instance-scoped provider. Works with ChatPanel and standalone primitives. */\nexport function ChatAppearanceProvider({ icons, children }: ChatAppearanceProviderProps) {\n const parent = useContext(IconContext);\n const value = useMemo(() => {\n const merged = { ...parent };\n for (const name of Object.keys(icons ?? {}) as ChatIconName[]) {\n if (icons?.[name]) merged[name] = icons[name];\n }\n return merged;\n }, [parent, icons]);\n return <IconContext.Provider value={value}>{children}</IconContext.Provider>;\n}\n\nexport function Icon({ name, ...props }: ChatIconProps & { name: ChatIconName }) {\n const overrides = useContext(IconContext);\n const Component = overrides[name] ?? defaultIcons[name];\n return <Component width={16} height={16} strokeWidth={1.6} aria-hidden=\"true\" focusable=\"false\" {...props} />;\n}\n","\"use client\";\n\nimport { forwardRef, useEffect, useRef, useState } from 'react';\nimport type { ButtonHTMLAttributes, CSSProperties, ReactNode } from 'react';\nimport { createPortal } from 'react-dom';\nimport { Icon, type ChatIconName } from './icons';\n\nexport interface ChatIconButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children'> {\n /** Accessible name; also used as the default tooltip. */\n label: string;\n icon?: ChatIconName;\n children?: ReactNode;\n size?: 'sm' | 'md';\n variant?: 'ghost' | 'filled';\n /** Set false to suppress the visual tooltip, or pass a more descriptive label. */\n tooltip?: boolean | string;\n}\n\ntype TooltipPosition = { left: number; top: number; placement: 'top' | 'bottom'; style: CSSProperties };\n\n/** Labelled native button with a viewport-safe tooltip. No wrapper affects host flex layouts. */\nexport const ChatIconButton = forwardRef<HTMLButtonElement, ChatIconButtonProps>(function ChatIconButton({\n label, icon, children, size = 'md', variant = 'ghost', tooltip = true, className, type = 'button',\n onPointerEnter, onPointerLeave, onPointerDown, onFocus, onBlur, onClick, onKeyDown, ...props\n}, forwardedRef) {\n const button = useRef<HTMLButtonElement | null>(null);\n const tooltipElement = useRef<HTMLSpanElement | null>(null);\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const [position, setPosition] = useState<TooltipPosition>();\n const text = typeof tooltip === 'string' ? tooltip : label;\n\n function hide() {\n clearTimeout(timer.current);\n setPosition(undefined);\n }\n function show(delay: number) {\n clearTimeout(timer.current);\n if (!tooltip || props.disabled) return;\n timer.current = setTimeout(() => {\n const element = button.current;\n if (!element || !element.isConnected) return;\n const rect = element.getBoundingClientRect();\n const theme = window.getComputedStyle(element);\n const placement = rect.top > 120 ? 'top' : 'bottom';\n // The tooltip is portalled to avoid clipping by message scrollers and panels.\n // Resolve tokens at the trigger so each instance retains its own theme.\n setPosition({\n left: Math.max(Math.min(128, window.innerWidth / 2), Math.min(window.innerWidth - Math.min(128, window.innerWidth / 2), rect.left + rect.width / 2)),\n top: placement === 'top' ? rect.top - 8 : rect.bottom + 8,\n placement,\n style: {\n background: theme.getPropertyValue('--gc-chat-tooltip-bg').trim() || '#272b32',\n color: theme.getPropertyValue('--gc-chat-tooltip-text').trim() || '#fff',\n fontFamily: theme.fontFamily,\n },\n });\n }, delay);\n }\n\n useEffect(() => () => clearTimeout(timer.current), []);\n useEffect(() => {\n if (!position) return;\n const dismiss = (event: KeyboardEvent) => { if (event.key === 'Escape') hide(); };\n // Hide on movement rather than leaving a detached tooltip over different content.\n const onScroll = (event: Event) => { if (event.target !== tooltipElement.current) hide(); };\n window.addEventListener('scroll', onScroll, true);\n window.addEventListener('resize', hide);\n window.addEventListener('keydown', dismiss);\n return () => {\n window.removeEventListener('scroll', onScroll, true);\n window.removeEventListener('resize', hide);\n window.removeEventListener('keydown', dismiss);\n };\n }, [position]);\n useEffect(() => { if (props.disabled || !tooltip) hide(); }, [props.disabled, tooltip]);\n\n return <>\n <button {...props} ref={element => {\n button.current = element;\n if (typeof forwardedRef === 'function') return forwardedRef(element);\n else if (forwardedRef) forwardedRef.current = element;\n }} type={type} aria-label={label}\n className={['gc-chat__icon-button', className].filter(Boolean).join(' ')}\n data-size={size} data-variant={variant}\n onPointerEnter={event => { onPointerEnter?.(event); if (!event.defaultPrevented && event.pointerType !== 'touch') show(400); }}\n onPointerLeave={event => { onPointerLeave?.(event); clearTimeout(timer.current); timer.current = setTimeout(hide, 150); }}\n onPointerDown={event => { onPointerDown?.(event); hide(); }}\n onFocus={event => { onFocus?.(event); if (!event.defaultPrevented) show(0); }}\n onBlur={event => { onBlur?.(event); hide(); }}\n onClick={event => { onClick?.(event); hide(); }}\n onKeyDown={event => { onKeyDown?.(event); if (event.key === 'Escape') hide(); }}>\n {children ?? (icon ? <Icon name={icon} /> : null)}\n </button>\n {position && createPortal(<span ref={tooltipElement} className=\"gc-chat__tooltip\" role=\"tooltip\" data-placement={position.placement}\n onPointerEnter={() => clearTimeout(timer.current)} onPointerLeave={hide}\n style={{ left: position.left, top: position.top, ...position.style }}>{text}</span>, button.current?.ownerDocument.body ?? document.body)}\n </>;\n});\n"],"mappings":";;;;;;AAmBA,MAAM,eAAmE;CACvE,KAAK;CAAK,OAAO;CAAY,MAAM;CAAW,OAAO;CAAQ,OAAO;CAAqB,MAAM;CAAU,QAAQ;CAAW,UAAU;CAAc,QAAQ;CAC5J,MAAM;CAAS,MAAM;CAAQ,MAAM;CAAM,OAAO;CAAG,MAAM;CAAM,OAAO;CACtE,SAAS;CAAW,MAAM;CAAW,MAAM;CAAU,SAAS;CAC9D,MAAM;CAAgB,MAAM;CAAW,SAAS;CAAc,MAAM;CACpE,MAAM;CAAQ,UAAU;CAAO,SAAS;CAAa,SAAS;CAAK,QAAQ;AAC7E;AAEA,MAAM,cAAc,cAAiC,CAAC,CAAC;;AASvD,SAAgB,uBAAuB,EAAE,OAAO,YAAyC;CACvF,MAAM,SAAS,WAAW,WAAW;CACrC,MAAM,QAAQ,cAAc;EAC1B,MAAM,SAAS,EAAE,GAAG,OAAO;EAC3B,KAAK,MAAM,QAAQ,OAAO,KAAK,SAAS,CAAC,CAAC,GACxC,IAAI,QAAQ,OAAO,OAAO,QAAQ,MAAM;EAE1C,OAAO;CACT,GAA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