@galaxycore/ai-chat 0.10.0 → 0.11.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/dist/styles.css CHANGED
@@ -462,6 +462,120 @@
462
462
  .gc-chat__reasoning-segment:hover:not([data-selected='true']) { color: var(--gc-chat-text); }
463
463
  .gc-chat__reasoning-segment[data-selected='true'] { background: var(--gc-chat-bg); color: var(--gc-chat-text); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
464
464
  .gc-chat__reasoning-segment:focus-visible { outline: 2px solid var(--gc-chat-focus); outline-offset: -2px; }
465
+ /* Circular context-window ring trigger, Cursor-style breakdown popover, and compaction divider. */
466
+ .gc-chat__context-usage {
467
+ --gc-chat-ctx-slate: #7d8590;
468
+ --gc-chat-ctx-violet: #b07be8;
469
+ --gc-chat-ctx-green: #58c26a;
470
+ --gc-chat-ctx-amber: #d49753;
471
+ --gc-chat-ctx-magenta: #d660de;
472
+ --gc-chat-ctx-blue: #4a9cf0;
473
+ --gc-chat-ctx-orange: #dc7026;
474
+ --gc-chat-ctx-teal: #2ea89b;
475
+ position: relative;
476
+ display: inline-flex;
477
+ align-items: center;
478
+ flex-shrink: 0;
479
+ }
480
+ .gc-chat[data-theme='dark'] .gc-chat__context-usage,
481
+ :root[data-theme='dark'] .gc-chat__context-usage {
482
+ --gc-chat-ctx-slate: #838b98;
483
+ --gc-chat-ctx-violet: #c084fc;
484
+ --gc-chat-ctx-green: #7ce38b;
485
+ --gc-chat-ctx-amber: #d8a265;
486
+ --gc-chat-ctx-magenta: #e26ee5;
487
+ --gc-chat-ctx-blue: #58a6ff;
488
+ --gc-chat-ctx-orange: #db6d28;
489
+ --gc-chat-ctx-teal: #3ec9ba;
490
+ }
491
+ @media (prefers-color-scheme: dark) {
492
+ .gc-chat[data-theme='auto'] .gc-chat__context-usage {
493
+ --gc-chat-ctx-slate: #838b98;
494
+ --gc-chat-ctx-violet: #c084fc;
495
+ --gc-chat-ctx-green: #7ce38b;
496
+ --gc-chat-ctx-amber: #d8a265;
497
+ --gc-chat-ctx-magenta: #e26ee5;
498
+ --gc-chat-ctx-blue: #58a6ff;
499
+ --gc-chat-ctx-orange: #db6d28;
500
+ --gc-chat-ctx-teal: #3ec9ba;
501
+ }
502
+ }
503
+ :where(.gc-chat__composer, .ai-chat-composer) .gc-chat__context-usage { position: static; }
504
+ .gc-chat__context-usage-trigger { display: inline-grid; place-items: center; width: var(--gc-chat-control-size, 30px); height: var(--gc-chat-control-size, 30px); padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--gc-chat-muted, #677287); cursor: pointer; flex-shrink: 0; transition: background-color 160ms ease, color 160ms ease; }
505
+ .gc-chat__context-usage-trigger:hover:not(:disabled),
506
+ .gc-chat__context-usage-trigger[data-open='true'] { background: var(--gc-chat-surface-hover, #f7f8fb); color: var(--gc-chat-text, #253047); }
507
+ .gc-chat__context-usage-trigger:focus-visible { outline: 2px solid var(--gc-chat-focus, #3157d5); outline-offset: 2px; }
508
+ .gc-chat__context-usage-trigger:disabled { opacity: .5; cursor: not-allowed; }
509
+ .gc-chat__context-usage-ring { width: 18px; height: 18px; display: block; overflow: visible; }
510
+ .gc-chat__context-usage-ring-track { fill: none; stroke: color-mix(in srgb, var(--gc-chat-muted, #677287) 30%, transparent); stroke-width: 2.15; }
511
+ .gc-chat__context-usage-ring-fill { fill: none; stroke: var(--gc-chat-text, #253047); stroke-width: 2.15; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset 260ms cubic-bezier(.23, 1, .32, 1), stroke 200ms ease; }
512
+ .gc-chat__context-usage-ring[data-level='warn'] .gc-chat__context-usage-ring-fill { stroke: var(--gc-chat-warning, #8b631c); }
513
+ .gc-chat__context-usage-ring[data-level='high'] .gc-chat__context-usage-ring-fill { stroke: var(--gc-chat-danger, #b44444); }
514
+ .gc-chat__popover.gc-chat__context-usage-popover { left: auto; right: 0; width: min(360px, calc(100vw - 24px)); min-width: min(260px, calc(100vw - 24px)); max-width: calc(100vw - 24px); padding: 16px 18px 18px; border: 1px solid var(--gc-chat-border, #e8ecf3); border-radius: 14px; background: var(--gc-chat-popover-bg, var(--gc-chat-bg, #ffffff)); color: var(--gc-chat-text, #253047); box-shadow: var(--gc-chat-popover-shadow, 0 12px 32px rgba(0, 0, 0, .12), 0 2px 6px rgba(0, 0, 0, .06)); }
515
+ .gc-chat[data-theme='dark'] .gc-chat__popover.gc-chat__context-usage-popover,
516
+ :root[data-theme='dark'] .gc-chat__popover.gc-chat__context-usage-popover { border-color: color-mix(in srgb, var(--gc-chat-text, #e6ebf5) 12%, var(--gc-chat-border, #343e50)); }
517
+ @media (prefers-color-scheme: dark) {
518
+ .gc-chat[data-theme='auto'] .gc-chat__popover.gc-chat__context-usage-popover { border-color: color-mix(in srgb, var(--gc-chat-text, #e6ebf5) 12%, var(--gc-chat-border, #343e50)); }
519
+ }
520
+ :where(.gc-chat__composer, .ai-chat-composer) .gc-chat__popover.gc-chat__context-usage-popover { left: 0; right: 0; bottom: calc(100% + 8px); width: auto; min-width: 0; max-width: none; }
521
+ .gc-chat__context-usage-panel { display: grid; gap: 14px; }
522
+ .gc-chat__context-usage-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
523
+ .gc-chat__context-usage-heading { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
524
+ .gc-chat__context-usage-title { font-size: 14px; font-weight: 500; line-height: 1.4; color: color-mix(in srgb, var(--gc-chat-text, #253047) 80%, var(--gc-chat-muted, #677287)); white-space: nowrap; }
525
+ .gc-chat__context-usage-model { font-size: 13px; line-height: 1.4; color: var(--gc-chat-muted, #677287); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
526
+ .gc-chat__context-usage-close { display: inline-grid; place-items: center; width: 26px; height: 26px; flex: none; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--gc-chat-muted, #677287); cursor: pointer; transition: background-color 140ms ease, color 140ms ease; }
527
+ .gc-chat__context-usage-close:hover { background: var(--gc-chat-surface-hover, #f7f8fb); color: var(--gc-chat-text, #253047); }
528
+ .gc-chat__context-usage-close:focus-visible { outline: 2px solid var(--gc-chat-focus, #3157d5); outline-offset: 2px; }
529
+ .gc-chat__context-usage-close > svg,
530
+ .gc-chat__context-usage-close > svg.lucide { width: 15px; height: 15px; }
531
+ .gc-chat__context-usage-meter { display: grid; gap: 8px; }
532
+ .gc-chat__context-usage-summary { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }
533
+ .gc-chat__context-usage-percent { font-size: 13px; font-weight: 400; line-height: 1.4; color: color-mix(in srgb, var(--gc-chat-text, #253047) 76%, var(--gc-chat-muted, #677287)); }
534
+ .gc-chat__context-usage-percent[data-level='warn'] { color: var(--gc-chat-warning, #8b631c); font-weight: 500; }
535
+ .gc-chat__context-usage-percent[data-level='high'] { color: var(--gc-chat-danger, #b44444); font-weight: 500; }
536
+ .gc-chat__context-usage-tokens { font-size: 13px; line-height: 1.4; color: color-mix(in srgb, var(--gc-chat-text, #253047) 72%, var(--gc-chat-muted, #677287)); white-space: nowrap; }
537
+ .gc-chat__context-usage-bar { display: flex; align-items: stretch; height: 5px; width: 100%; border-radius: 9999px; background: color-mix(in srgb, var(--gc-chat-muted, #677287) 22%, transparent); overflow: hidden; }
538
+ .gc-chat__context-usage-bar-fill { display: flex; align-items: stretch; gap: 2px; height: 100%; max-width: 100%; min-width: fit-content; }
539
+ .gc-chat__context-usage-bar-segment { height: 100%; flex-shrink: 1; flex-basis: 0; min-width: 3px; border-radius: 2px; background: var(--gc-chat-ctx-color, var(--gc-chat-ctx-slate)); }
540
+ .gc-chat__context-usage-bar-segment:first-child { border-start-start-radius: 9999px; border-end-start-radius: 9999px; }
541
+ .gc-chat__context-usage-bar-segment:last-child { border-start-end-radius: 9999px; border-end-end-radius: 9999px; }
542
+ .gc-chat__context-usage-bar-segment[data-tone='slate'], .gc-chat__context-usage-swatch[data-tone='slate'] { --gc-chat-ctx-color: var(--gc-chat-ctx-slate); }
543
+ .gc-chat__context-usage-bar-segment[data-tone='violet'], .gc-chat__context-usage-swatch[data-tone='violet'] { --gc-chat-ctx-color: var(--gc-chat-ctx-violet); }
544
+ .gc-chat__context-usage-bar-segment[data-tone='green'], .gc-chat__context-usage-swatch[data-tone='green'] { --gc-chat-ctx-color: var(--gc-chat-ctx-green); }
545
+ .gc-chat__context-usage-bar-segment[data-tone='amber'], .gc-chat__context-usage-swatch[data-tone='amber'] { --gc-chat-ctx-color: var(--gc-chat-ctx-amber); }
546
+ .gc-chat__context-usage-bar-segment[data-tone='magenta'], .gc-chat__context-usage-swatch[data-tone='magenta'] { --gc-chat-ctx-color: var(--gc-chat-ctx-magenta); }
547
+ .gc-chat__context-usage-bar-segment[data-tone='blue'], .gc-chat__context-usage-swatch[data-tone='blue'] { --gc-chat-ctx-color: var(--gc-chat-ctx-blue); }
548
+ .gc-chat__context-usage-bar-segment[data-tone='orange'], .gc-chat__context-usage-swatch[data-tone='orange'] { --gc-chat-ctx-color: var(--gc-chat-ctx-orange); }
549
+ .gc-chat__context-usage-bar-segment[data-tone='teal'], .gc-chat__context-usage-swatch[data-tone='teal'] { --gc-chat-ctx-color: var(--gc-chat-ctx-teal); }
550
+ .gc-chat__context-usage-legend { display: grid; gap: 11px; margin: 4px 0 0; padding: 0; list-style: none; }
551
+ .gc-chat__context-usage-legend-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-width: 0; font-size: 13.5px; line-height: 1.4; }
552
+ .gc-chat__context-usage-legend-label { display: inline-flex; align-items: center; gap: 12px; min-width: 0; color: color-mix(in srgb, var(--gc-chat-text, #253047) 84%, var(--gc-chat-muted, #677287)); }
553
+ .gc-chat__context-usage-legend-label > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
554
+ .gc-chat__context-usage-swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; background: var(--gc-chat-ctx-color, var(--gc-chat-ctx-slate)); }
555
+ .gc-chat__context-usage-legend-value { flex: none; color: color-mix(in srgb, var(--gc-chat-text, #253047) 68%, var(--gc-chat-muted, #677287)); font-variant-numeric: tabular-nums; white-space: nowrap; }
556
+ .gc-chat__context-usage-empty { margin: 2px 0 0; font-size: 13px; line-height: 1.5; color: var(--gc-chat-muted, #677287); }
557
+ .gc-chat__context-usage-compacted { display: flex; align-items: center; gap: 8px; padding-top: 12px; border-top: 1px solid var(--gc-chat-border, #e8ecf3); font-size: 12.5px; line-height: 1.45; color: var(--gc-chat-muted, #677287); }
558
+ .gc-chat__context-usage-compacted > svg,
559
+ .gc-chat__context-usage-compacted > svg.lucide { width: 13px; height: 13px; flex: none; color: var(--gc-chat-text, #253047); opacity: .72; }
560
+ /* Inline context-compaction divider inside the conversation stream. */
561
+ .gc-chat__compaction-notice { display: flex; align-items: center; gap: 10px; width: 100%; margin-block: 2px 6px; color: var(--gc-chat-muted, #677287); font-size: 12px; line-height: 1.45; }
562
+ .gc-chat__compaction-notice::before,
563
+ .gc-chat__compaction-notice::after { content: ''; flex: 1 1 16px; height: 1px; background: var(--gc-chat-border, #e8ecf3); }
564
+ .gc-chat__compaction-pill { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 3px 10px; border: 1px solid var(--gc-chat-border, #e8ecf3); border-radius: 9999px; background: var(--gc-chat-surface-hover, #f7f8fb); color: var(--gc-chat-muted, #677287); font-variant-numeric: tabular-nums; }
565
+ .gc-chat__compaction-pill > svg,
566
+ .gc-chat__compaction-pill > svg.lucide { width: 12px; height: 12px; flex: none; opacity: .8; }
567
+ .gc-chat__compaction-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
568
+ .gc-chat__compaction-notice[data-status='running'] .gc-chat__compaction-text {
569
+ background-image: linear-gradient(100deg, color-mix(in srgb, var(--gc-chat-muted, #677287) 84%, transparent) 32%, var(--gc-chat-text, #253047) 50%, color-mix(in srgb, var(--gc-chat-muted, #677287) 84%, transparent) 68%);
570
+ background-size: 240% 100%;
571
+ background-position: 100% 0;
572
+ -webkit-background-clip: text;
573
+ background-clip: text;
574
+ -webkit-text-fill-color: transparent;
575
+ color: transparent;
576
+ animation: gc-chat-shimmer 2s linear infinite;
577
+ }
578
+ @keyframes gc-chat-shimmer { to { background-position: 0 0; } }
465
579
  /* Both narrow viewports and sidebars keep the prototype’s mobile layout. */
466
580
  @media (max-width: 520px) {
467
581
  .gc-chat__header { padding: 16px 17px; }
@@ -486,7 +600,7 @@
486
600
  .gc-chat__context-label-text { max-width: 140px; }
487
601
  }
488
602
  @media (pointer: coarse) {
489
- .gc-chat .gc-chat__icon-button, .gc-chat .gc-chat__send { min-width: 44px; min-height: 44px; }
603
+ .gc-chat .gc-chat__icon-button, .gc-chat .gc-chat__send, .gc-chat__context-usage-trigger { min-width: 44px; min-height: 44px; }
490
604
  .gc-chat__button, .gc-chat__suggestion, .gc-chat__text-button { min-height: 44px; min-width: 44px; }
491
605
  .gc-chat__context-select, .gc-chat__tool-heading, .gc-chat__reasoning > summary, .gc-chat__disclosures > details > summary { min-height: 44px; }
492
606
  .gc-chat__context-label { min-height: 48px; }
@@ -495,4 +609,6 @@
495
609
  }
496
610
  @media (prefers-reduced-motion: reduce) {
497
611
  .gc-chat *, .gc-chat *::before, .gc-chat *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
612
+ .gc-chat__context-usage-ring-fill { transition: none !important; }
613
+ .gc-chat__compaction-notice[data-status='running'] .gc-chat__compaction-text { background-image: none; -webkit-text-fill-color: currentColor; color: var(--gc-chat-muted, #677287); animation: none !important; }
498
614
  }
@@ -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, AtSign, AudioLines, Ban, Brain, ChartNoAxesCombined, Check, ChevronDown, 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";
3
+ import { ArrowDown, ArrowUp, ArrowUpRight, AtSign, AudioLines, Ban, Brain, ChartNoAxesCombined, Check, ChevronDown, ChevronLeft, ChevronRight, CircleAlert, Compass, Copy, Crosshair, FileText, GitBranch, Layers, Link, LoaderCircle, Mic, Minimize2, Minus, 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
@@ -39,6 +39,8 @@ const defaultIcons = {
39
39
  at: AtSign,
40
40
  sliders: SlidersHorizontal,
41
41
  zap: Zap,
42
+ minus: Minus,
43
+ minimize: Minimize2,
42
44
  tool: Wrench,
43
45
  thinking: Brain,
44
46
  warning: CircleAlert,
@@ -185,4 +187,4 @@ const ChatIconButton = forwardRef(function ChatIconButton({ label, icon, childre
185
187
  //#endregion
186
188
  export { ChatAppearanceProvider as n, Icon as r, ChatIconButton as t };
187
189
 
188
- //# sourceMappingURL=ui-primitives-XhFvDm8o.js.map
190
+ //# sourceMappingURL=ui-primitives-CV3lrveW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui-primitives-CV3lrveW.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, ChevronDown, ChevronLeft, ChevronRight, CircleAlert, Compass,\n Copy, FileText, GitBranch, Layers, Link, LoaderCircle, Minimize2, Minus, 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' | 'chevronDown' | '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' | 'minus' | 'minimize';\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, chevronDown: ChevronDown, 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, minus: Minus, minimize: Minimize2,\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;CAAa,aAAa;CACrG,MAAM;CAAO,QAAQ;CAAW,MAAM;CACtC,SAAS;CAAS,MAAM;CAAM,WAAW;CAAW,QAAQ;CAAQ,IAAI;CACxE,SAAS;CAAmB,KAAK;CAAK,OAAO;CAAO,UAAU;CAC9D,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,CA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BAAgB,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"}
@@ -6,7 +6,7 @@
6
6
 
7
7
  | 入口 | 导出与用途 |
8
8
  | --- | --- |
9
- | 根入口 | `AiChat`、`ChatPanel`、`ChatMessages`、`ChatComposer`、`ChatHistoryMenu`、`useAiChat`、labels、外观和上下文能力 |
9
+ | 根入口 | `AiChat`、`ChatPanel`、`ChatMessages`、`ChatComposer`、`ChatContextUsage`、`ChatCompactionNotice`、`ChatModelPicker`、`ChatHistoryMenu`、`useAiChat`、labels、外观和上下文能力 |
10
10
  | `/headless` | Hook、类型和辅助函数;宿主自行渲染 |
11
11
  | `/gateway` | `createGatewayClient`、`GatewayRequestError`、会话和能力类型 |
12
12
  | `/context` | `useChatContext`、`ContextTray`、`createTextSelectionAdapter` |
@@ -47,7 +47,7 @@ options 沿用 `@ai-sdk/react` 的 `UseChatOptions<M>`。返回 SDK `UseChatHelp
47
47
  | `composerProps` | Composer props 子集 | 上下文、toolbar、attachments、speech、disabled |
48
48
  | `renderText` | `({text,isStreaming}) => ReactNode` | 覆盖默认助手 Markdown / 用户纯文本渲染 |
49
49
  | `smoothStreaming` | `boolean`,默认 `true` | 活跃文本的短窗口平滑显示;停止立即展示全文,自定义 part renderer 自行控制。见 [流式体验](streaming.md) |
50
- | `scrollRef` | `Ref<ChatScrollHandle>` | 定位消息区中的元素或文字范围。见 [定位消息内容](streaming.md#定位消息内容) |
50
+ | `scrollRef` | `Ref<ChatScrollHandle>` | 定位消息区中的元素或文字范围(`reveal`),或显式恢复到底部跟随(`scrollToLatest`)。见 [定位消息内容](streaming.md#定位消息内容) |
51
51
  | `renderers` | 按 part.type 映射 | 最高优先级的自定义消息片段 |
52
52
  | `tools` | 按 toolName 映射 | 自定义业务工具结果卡片 |
53
53
  | `toolPresentation` | `ToolPresentationResolver<M>` | 只定制默认工具动作行的标题、图标和摘要 |
@@ -70,9 +70,17 @@ options 沿用 `@ai-sdk/react` 的 `UseChatOptions<M>`。返回 SDK `UseChatHelp
70
70
  | `toolbar` | 左侧工具区域;自定义按钮务必 `type="button"` |
71
71
  | `attachments` | `{upload,maxFiles?,maxSize?,accept?}`,宿主提供上传接口 |
72
72
  | `speech` | `{adapter,lang?,labels?}`,语音输入适配 |
73
+ | `modelPicker` | 内联模型与推理强度选择器(`ChatModelPickerProps`) |
74
+ | `contextUsage` | 上下文窗口占用环与分段占比弹层(`ChatContextUsageProps`) |
73
75
  | `disabled` | 禁用新发送及输入,适合初始化/停止确认阶段 |
74
76
  | `requestOptions` | 单轮请求参数 |
75
77
 
78
+ ## ChatContextUsage 与 ChatCompactionNotice
79
+
80
+ `ChatContextUsage` 在输入区右侧以紧凑圆环展示当前上下文窗口占用比例;点击后在输入区正上方展开与输入区等宽的分段占比面板,展示百分比、已用/窗口 Token 数、分段色块图例以及自动压缩提示。无 UI 需求时可从根入口或 `/headless` 直接使用 `formatChatTokens` 与 `resolveChatContextUsage`。
81
+
82
+ `ChatCompactionNotice` 在消息流中以克制的水平细线与胶囊呈现自动压缩中(`status="running"`)或压缩完成(`status="done"`,可选 `beforeTokens` / `afterTokens` / `savedTokens`)的状态。两者均支持 `zhCN` / `enUS` 与 `labels` 覆盖,并自动适配浅色、深色与自动主题。
83
+
76
84
  语音不会自动提交。开始录音前显示处理说明;取消丢弃本轮语音,完成后将文字追加到当前草稿。切换会话、适配器或卸载会中止录音。已输入的草稿不会被迟到的识别回调覆盖。
77
85
 
78
86
  附件上传默认最多 5 个文件、单个 10MiB。`upload(file,{signal})` 返回 SDK `FileUIPart`。服务端还必须检查文件身份、类型与权限;当前 pi 网关不支持附件,因此示例不显示无效的附件按钮。
@@ -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.10.0.tgz
39
+ npm install /absolute/path/to/galaxycore-ai-chat-0.11.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.10.0.tgz
56
+ tar -tzf artifacts/galaxycore-ai-chat-0.11.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.10.0`,网关版本为 `0.2.0`,两者独立升级。0.x 阶段,修复使用 patch,新增功能和未冻结接口调整使用 minor,并在 changelog 说明兼容性。稳定 API 后再发布 1.0。
88
+ 当前组件版本为 `0.11.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.10.0.tgz \
93
+ npm publish ./artifacts/galaxycore-ai-chat-0.11.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.10.0.tgz \
98
98
  使用 tarball 发布时,先显式执行完整检查,不依赖源仓库的生命周期脚本一定被触发。`latest` 是不指定版本安装时使用的标签,不代表 API 已冻结。需要独立试用通道时,可以采用预发布版本及 `next` 标签。发布后检查远端版本和完整性:
99
99
 
100
100
  ```sh
101
- npm view @galaxycore/ai-chat@0.10.0 version dist.integrity \
101
+ npm view @galaxycore/ai-chat@0.11.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,6 +1,6 @@
1
1
  {
2
2
  "name": "@galaxycore/ai-chat",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Composable React AI chat for GalaxyCore, powered by Vercel AI SDK",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -1 +0,0 @@
1
- {"version":3,"file":"branches-CRxWPjfD.js","names":[],"sources":["../src/use-ai-chat.ts","../src/labels.ts","../src/composer-triggers.ts","../src/model-picker.ts","../src/branches.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 revert: '撤回', branch: '分支对话',\n previousBranch: '上一分支', nextBranch: '下一分支', branchPosition: '分支 {current}/{total}',\n revertedBanner: '已撤回到此消息之前', restoreBranch: '恢复',\n skillsMenu: '技能菜单', addSkill: '添加技能', browseSkills: '浏览与管理技能',\n noMatchingSkills: '没有匹配的技能',\n mentionMenu: '提及页面元素', noMatchingMentions: '没有匹配的页面元素',\n plusMenu: '添加内容与工具',\n selectModel: '选择模型', reasoningEffort: '推理能力', reasoningDefault: '默认',\n reasoningNone: '关闭', reasoningLow: '低', reasoningMedium: '中', reasoningHigh: '高', reasoningXhigh: '极高',\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 revert: 'Revert', branch: 'Branch chat',\n previousBranch: 'Previous branch', nextBranch: 'Next branch', branchPosition: 'Branch {current} of {total}',\n revertedBanner: 'Reverted before this message', restoreBranch: 'Restore',\n skillsMenu: 'Skills menu', addSkill: 'Add skill', browseSkills: 'Browse & manage skills',\n noMatchingSkills: 'No matching skills',\n mentionMenu: 'Mention page elements', noMatchingMentions: 'No matching page elements',\n plusMenu: 'Add context and tools',\n selectModel: 'Model', reasoningEffort: 'Reasoning', reasoningDefault: 'Auto',\n reasoningNone: 'Off', reasoningLow: 'Low', reasoningMedium: 'Med', reasoningHigh: 'High', reasoningXhigh: 'Max',\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","import { useCallback, useEffect, useState } from 'react';\nimport type { KeyboardEvent as ReactKeyboardEvent } from 'react';\nimport type { ChatIconName } from './icons';\n\nexport type ComposerTriggerKind = '/' | '@';\n\nexport interface ComposerTriggerMatch {\n trigger: ComposerTriggerKind;\n query: string;\n /** Inclusive index of the trigger character (`/` or `@`) in the draft string. */\n start: number;\n /** Exclusive end index (typically the current caret position). */\n end: number;\n}\n\nexport interface ChatSkillItem {\n id: string;\n slug: string;\n name: string;\n description?: string;\n prompt: string;\n /** Optional short emoji or ChatIconName displayed beside the skill name. */\n icon?: string;\n source?: string;\n sourceUrl?: string;\n enabled?: boolean;\n builtin?: boolean;\n}\n\nexport interface ParsedSkillMarkdown {\n slug: string;\n name: string;\n description: string;\n prompt: string;\n icon?: string;\n}\n\nexport interface ChatMentionItem {\n id: string;\n label: string;\n description?: string;\n group?: string;\n kind?: string;\n badge?: string;\n keywords?: readonly string[];\n disabled?: boolean;\n}\n\nexport interface ChatComposerMenuAction {\n id: string;\n label: string;\n description?: string;\n icon?: ChatIconName;\n badge?: string;\n trailing?: 'chevron' | 'check' | 'toggle';\n checked?: boolean;\n disabled?: boolean;\n section?: string;\n onSelect?: () => void;\n onToggle?: (next: boolean) => void;\n}\n\nexport function slugifySkillName(input: string): string {\n const ascii = input\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, 48);\n return ascii || 'custom-skill';\n}\n\nfunction unquoteYaml(raw: string): string {\n const trimmed = raw.trim();\n if (trimmed.length >= 2) {\n const first = trimmed[0];\n const last = trimmed[trimmed.length - 1];\n if ((first === '\"' && last === '\"') || (first === \"'\" && last === \"'\")) {\n return trimmed.slice(1, -1).trim();\n }\n }\n return trimmed;\n}\n\n/**\n * Parse a SKILL.md document (YAML frontmatter + Markdown body) into editable skill fields.\n * Never executes code; treats every field as plain text data.\n */\nexport function parseSkillMarkdown(raw: string, fallbackName?: string): ParsedSkillMarkdown {\n const normalized = raw.replace(/\\r\\n?/g, '\\n').trim();\n const fields: Record<string, string> = {};\n let body = normalized;\n\n const frontmatter = /^---\\n([\\s\\S]*?)\\n---\\n?([\\s\\S]*)$/.exec(normalized);\n if (frontmatter) {\n const head = frontmatter[1] ?? '';\n body = (frontmatter[2] ?? '').trim();\n for (const line of head.split('\\n')) {\n const separator = line.indexOf(':');\n if (separator <= 0) continue;\n const key = line.slice(0, separator).trim().toLowerCase();\n const value = unquoteYaml(line.slice(separator + 1));\n if (key && value && !(key in fields)) fields[key] = value;\n }\n }\n\n let headingTitle = '';\n if (!fields.title && !fields.name) {\n const heading = /^#\\s+(.+)$/m.exec(body);\n if (heading?.[1]) headingTitle = heading[1].trim();\n }\n\n const rawName = fields.title || fields.name || headingTitle || fallbackName?.trim() || 'Custom skill';\n const slugSource = fields.slug || fields.name || rawName;\n const description = fields.description || '';\n const prompt = (body || normalized).slice(0, 4000);\n const icon = fields.icon ? fields.icon.slice(0, 16) : undefined;\n\n return {\n slug: slugifySkillName(slugSource),\n name: rawName.slice(0, 80),\n description: description.slice(0, 240),\n prompt,\n ...(icon ? { icon } : {}),\n };\n}\n\n/**\n * Detect an active `/` or `@` trigger immediately preceding `cursor`.\n * Requires the trigger to appear at index 0 or immediately after whitespace so URLs and\n * email addresses (e.g. `https://a/b`, `user@example.com`) do not open a popup.\n */\nexport function detectComposerTrigger(\n value: string,\n cursor: number,\n triggers: readonly ComposerTriggerKind[] = ['/', '@'],\n): ComposerTriggerMatch | null {\n if (!triggers.length || cursor <= 0 || cursor > value.length) return null;\n const before = value.slice(0, cursor);\n for (let index = before.length - 1; index >= 0; index -= 1) {\n const char = before[index];\n if (char === undefined) break;\n if (/\\s/.test(char)) return null;\n if ((char === '/' || char === '@') && triggers.includes(char)) {\n if (index > 0 && !/\\s/.test(before[index - 1] ?? '')) return null;\n return {\n trigger: char,\n query: before.slice(index + 1),\n start: index,\n end: cursor,\n };\n }\n }\n return null;\n}\n\nexport function replaceComposerTrigger(\n value: string,\n match: ComposerTriggerMatch,\n replacement: string,\n): { value: string; cursor: number } {\n const prefix = value.slice(0, match.start);\n const suffix = value.slice(match.end);\n const nextValue = `${prefix}${replacement}${suffix}`;\n return { value: nextValue, cursor: prefix.length + replacement.length };\n}\n\nexport function filterSkills(skills: readonly ChatSkillItem[], query: string): ChatSkillItem[] {\n const needle = query.trim().toLowerCase();\n const enabled = skills.filter((skill) => skill.enabled !== false);\n if (!needle) return enabled;\n const scored: Array<{ skill: ChatSkillItem; rank: number }> = [];\n for (const skill of enabled) {\n const slug = skill.slug.toLowerCase();\n const name = skill.name.toLowerCase();\n const desc = (skill.description ?? '').toLowerCase();\n if (slug.startsWith(needle) || name.startsWith(needle)) scored.push({ skill, rank: 0 });\n else if (slug.includes(needle) || name.includes(needle)) scored.push({ skill, rank: 1 });\n else if (desc.includes(needle)) scored.push({ skill, rank: 2 });\n }\n return scored.sort((a, b) => a.rank - b.rank).map((entry) => entry.skill);\n}\n\nexport function filterMentions(\n mentions: readonly ChatMentionItem[],\n query: string,\n): ChatMentionItem[] {\n const needle = query.trim().toLowerCase();\n if (!needle) return [...mentions];\n const scored: Array<{ item: ChatMentionItem; rank: number }> = [];\n for (const item of mentions) {\n const label = item.label.toLowerCase();\n const desc = (item.description ?? '').toLowerCase();\n const group = (item.group ?? '').toLowerCase();\n const keywords = (item.keywords ?? []).join(' ').toLowerCase();\n if (label.startsWith(needle)) scored.push({ item, rank: 0 });\n else if (label.includes(needle)) scored.push({ item, rank: 1 });\n else if (desc.includes(needle) || keywords.includes(needle) || group.includes(needle)) {\n scored.push({ item, rank: 2 });\n }\n }\n return scored.sort((a, b) => a.rank - b.rank).map((entry) => entry.item);\n}\n\nexport interface UseComposerTriggerOptions {\n value: string;\n cursor: number;\n triggers?: readonly ComposerTriggerKind[];\n enabled?: boolean;\n itemCount: number;\n onCommit?: (index: number, match: ComposerTriggerMatch) => void;\n}\n\nexport interface ComposerTriggerController {\n match: ComposerTriggerMatch | null;\n open: boolean;\n activeIndex: number;\n setActiveIndex: (index: number) => void;\n dismiss: () => void;\n /** Returns true when the trigger menu consumed the key event. */\n handleKeyDown: (event: ReactKeyboardEvent<HTMLTextAreaElement>) => boolean;\n}\n\nexport function useComposerTrigger({\n value,\n cursor,\n triggers = ['/', '@'],\n enabled = true,\n itemCount,\n onCommit,\n}: UseComposerTriggerOptions): ComposerTriggerController {\n const rawMatch = enabled ? detectComposerTrigger(value, cursor, triggers) : null;\n const tokenKey = rawMatch ? `${rawMatch.trigger}:${rawMatch.start}` : null;\n const [dismissedKey, setDismissedKey] = useState<string | null>(null);\n const [activeIndex, setActiveIndex] = useState(0);\n\n useEffect(() => {\n if (!tokenKey) setDismissedKey(null);\n }, [tokenKey]);\n\n const open = Boolean(rawMatch && tokenKey !== dismissedKey);\n const safeIndex = itemCount > 0 ? Math.min(activeIndex, itemCount - 1) : 0;\n\n useEffect(() => {\n setActiveIndex(0);\n }, [rawMatch?.trigger, rawMatch?.start, rawMatch?.query]);\n\n const dismiss = useCallback(() => {\n if (tokenKey) setDismissedKey(tokenKey);\n }, [tokenKey]);\n\n const handleKeyDown = useCallback(\n (event: ReactKeyboardEvent<HTMLTextAreaElement>): boolean => {\n if (!open || !rawMatch) return false;\n if (event.nativeEvent.isComposing || event.keyCode === 229) return false;\n if (event.key === 'Escape') {\n event.preventDefault();\n dismiss();\n return true;\n }\n if (itemCount <= 0) return false;\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n setActiveIndex((current) => (current + 1) % itemCount);\n return true;\n }\n if (event.key === 'ArrowUp') {\n event.preventDefault();\n setActiveIndex((current) => (current - 1 + itemCount) % itemCount);\n return true;\n }\n if ((event.key === 'Enter' && !event.shiftKey) || event.key === 'Tab') {\n event.preventDefault();\n onCommit?.(safeIndex, rawMatch);\n return true;\n }\n return false;\n },\n [open, rawMatch, itemCount, safeIndex, onCommit, dismiss],\n );\n\n return {\n match: open ? rawMatch : null,\n open,\n activeIndex: safeIndex,\n setActiveIndex,\n dismiss,\n handleKeyDown,\n };\n}\n","import type { ReactNode } from 'react';\n\nexport const CHAT_REASONING_EFFORTS = ['none', 'low', 'medium', 'high', 'xhigh'] as const;\nexport type ChatReasoningEffort = (typeof CHAT_REASONING_EFFORTS)[number];\n\nexport interface ChatModelOption {\n id: string;\n label: string;\n /** Underlying model identifier when distinct from the display label. */\n model?: string;\n /** Optional provider or vendor key for display or grouping. */\n provider?: string;\n description?: string;\n badge?: string;\n icon?: ReactNode;\n /** Supported reasoning effort levels for this model; omit or pass empty to hide the effort picker. */\n reasoningEfforts?: readonly ChatReasoningEffort[];\n /** Default reasoning effort when switching to this model without an explicit effort. */\n defaultReasoningEffort?: ChatReasoningEffort;\n disabled?: boolean;\n}\n\nexport interface ChatModelSelection {\n modelId: string;\n reasoningEffort?: ChatReasoningEffort;\n}\n\nexport interface ResolvedChatModelSelection {\n model: ChatModelOption | undefined;\n modelId: string | undefined;\n reasoningEffort: ChatReasoningEffort | undefined;\n supportedEfforts: readonly ChatReasoningEffort[];\n}\n\nexport function isChatReasoningEffort(value: unknown): value is ChatReasoningEffort {\n return typeof value === 'string' && (CHAT_REASONING_EFFORTS as readonly string[]).includes(value);\n}\n\n/**\n * Reconciles a requested or persisted selection against the currently available model list.\n * Falls back cleanly to the first enabled model and its default reasoning effort when stale.\n */\nexport function resolveChatModelSelection(\n models: readonly ChatModelOption[],\n selection?: Partial<ChatModelSelection> | null,\n): ResolvedChatModelSelection {\n const enabledModels = models.filter((item) => !item.disabled);\n const matched = selection?.modelId\n ? enabledModels.find((item) => item.id === selection.modelId)\n : undefined;\n const chosen = matched ?? enabledModels[0] ?? models[0];\n\n if (!chosen) {\n return { model: undefined, modelId: undefined, reasoningEffort: undefined, supportedEfforts: [] };\n }\n\n const supported = (chosen.reasoningEfforts ?? []).filter(isChatReasoningEffort);\n // Only honor the persisted effort when it belongs to the matched model (or no modelId was stored).\n const requestedEffort = matched || !selection?.modelId ? selection?.reasoningEffort : undefined;\n const reasoningEffort =\n requestedEffort && supported.includes(requestedEffort)\n ? requestedEffort\n : chosen.defaultReasoningEffort && supported.includes(chosen.defaultReasoningEffort)\n ? chosen.defaultReasoningEffort\n : undefined;\n\n return {\n model: chosen,\n modelId: chosen.id,\n reasoningEffort,\n supportedEfforts: supported,\n };\n}\n\n/**\n * Computes the next selection when the user switches models, preserving the current\n * reasoning effort when supported by the new model and otherwise using its default.\n */\nexport function selectChatModel(\n nextModel: ChatModelOption,\n currentEffort?: ChatReasoningEffort,\n): ChatModelSelection {\n const supported = (nextModel.reasoningEfforts ?? []).filter(isChatReasoningEffort);\n const reasoningEffort =\n currentEffort && supported.includes(currentEffort)\n ? currentEffort\n : nextModel.defaultReasoningEffort && supported.includes(nextModel.defaultReasoningEffort)\n ? nextModel.defaultReasoningEffort\n : undefined;\n return {\n modelId: nextModel.id,\n ...(reasoningEffort !== undefined ? { reasoningEffort } : {}),\n };\n}\n","\"use client\";\n\nimport { useCallback, useMemo, useState } from 'react';\nimport type { ChatBranchInfo } from './types';\n\nconst ROOT_KEY = '__root__';\n\nexport interface ProjectChatBranchesOptions<T extends { id: string }> {\n /**\n * Resolve an item's parent ID:\n * - `string`: explicit parent item ID\n * - `null`: explicit root item (starts a root-level branch)\n * - `undefined`: legacy linear item (chains after `items[index - 1]`)\n */\n getParentId?: (item: T, index: number, items: readonly T[]) => string | null | undefined;\n /** Selected child ID keyed by parent ID (`'__root__'` for root-level siblings). */\n selections?: Readonly<Record<string, string>>;\n /**\n * Active head or checkpoint stop position:\n * - `undefined`: follow selected/latest children to a leaf\n * - `null`: reverted to the empty root before the first message\n * - `string`: follow ancestors of this item, stopping at it when `stopAtHead` is true\n */\n headId?: string | null;\n /** When true and `headId` is provided, stop at `headId` instead of descending to its leaf. */\n stopAtHead?: boolean;\n}\n\nexport interface ChatBranchProjection<T extends { id: string }> {\n messages: T[];\n branches: Record<string, ChatBranchInfo>;\n /** Last visible item ID on the active path, or `null` when empty / reverted to root. */\n headId: string | null;\n /** Root-level branch navigation when reverted before the first message. */\n rootBranches?: ChatBranchInfo;\n}\n\nfunction parentKey(parentId: string | null): string {\n return parentId === null ? ROOT_KEY : `p:${parentId}`;\n}\n\nexport function projectChatBranches<T extends { id: string }>(\n items: readonly T[],\n options: ProjectChatBranchesOptions<T> = {},\n): ChatBranchProjection<T> {\n const { getParentId, selections, headId, stopAtHead = false } = options;\n if (items.length === 0) {\n return { messages: [], branches: {}, headId: null };\n }\n\n const byId = new Map<string, T>();\n for (const item of items) byId.set(item.id, item);\n\n const parentOf = new Map<string, string | null>();\n const childrenOf = new Map<string, T[]>();\n\n items.forEach((item, index) => {\n const raw = getParentId ? getParentId(item, index, items) : undefined;\n const resolved =\n raw === undefined\n ? (index > 0 ? items[index - 1]!.id : null)\n : raw !== null && byId.has(raw)\n ? raw\n : null;\n const safeParent = resolved === item.id ? null : resolved;\n parentOf.set(item.id, safeParent);\n const key = parentKey(safeParent);\n const group = childrenOf.get(key);\n if (group) group.push(item);\n else childrenOf.set(key, [item]);\n });\n\n const effectiveSelections: Record<string, string> = { ...selections };\n if (typeof headId === 'string' && byId.has(headId)) {\n let cursor: string | null = headId;\n const seen = new Set<string>();\n while (cursor !== null && !seen.has(cursor)) {\n seen.add(cursor);\n const p: string | null = parentOf.get(cursor) ?? null;\n effectiveSelections[parentKey(p)] = cursor;\n cursor = p;\n }\n }\n\n const toBranchInfo = (siblings: readonly T[], activeIndex: number): ChatBranchInfo | undefined => {\n if (siblings.length <= 1 || activeIndex < 0) return undefined;\n return {\n index: activeIndex + 1,\n count: siblings.length,\n prevId: activeIndex > 0 ? siblings[activeIndex - 1]!.id : undefined,\n nextId: activeIndex + 1 < siblings.length ? siblings[activeIndex + 1]!.id : undefined,\n };\n };\n\n if (headId === null) {\n const roots = childrenOf.get(ROOT_KEY) ?? [];\n const chosenId = effectiveSelections[ROOT_KEY];\n const idx = chosenId ? roots.findIndex(item => item.id === chosenId) : roots.length - 1;\n return {\n messages: [],\n branches: {},\n headId: null,\n rootBranches: toBranchInfo(roots, idx >= 0 ? idx : roots.length - 1),\n };\n }\n\n const messages: T[] = [];\n const branches: Record<string, ChatBranchInfo> = {};\n const visited = new Set<string>();\n let currentParent: string | null = null;\n\n while (true) {\n const siblings: T[] | undefined = childrenOf.get(parentKey(currentParent));\n if (!siblings || siblings.length === 0) break;\n const preferredId: string | undefined = effectiveSelections[parentKey(currentParent)];\n let index: number = preferredId ? siblings.findIndex(item => item.id === preferredId) : -1;\n if (index < 0) index = siblings.length - 1;\n const chosen: T = siblings[index]!;\n if (visited.has(chosen.id)) break;\n visited.add(chosen.id);\n messages.push(chosen);\n const info = toBranchInfo(siblings, index);\n if (info) branches[chosen.id] = info;\n if (stopAtHead && headId === chosen.id) break;\n currentParent = chosen.id;\n }\n\n return {\n messages,\n branches,\n headId: messages.at(-1)?.id ?? null,\n };\n}\n\nexport interface ChatBranchesState {\n selections: Record<string, string>;\n checkpoint?: {\n afterId: string | null;\n revertedMessageId?: string;\n restoreLeafId: string | null;\n };\n}\n\nexport interface ChatBranchesController<T extends { id: string }> extends ChatBranchProjection<T> {\n /** Parent ID to attach to the next newly submitted user message (`null` when starting at root). */\n nextParentId: string | null;\n /** Message ID that was reverted to create the current checkpoint, if any. */\n revertedMessageId?: string;\n /** Whether a previous branch leaf can be restored after a revert/checkpoint action. */\n canRestore: boolean;\n /** Switch to the branch containing `messageId` and follow it to its leaf. */\n selectBranch: (messageId: string) => void;\n /** Revert the active view to immediately before `messageId`, keeping the old branch restorable. */\n revertBefore: (messageId: string) => T | undefined;\n /** Position the active view right after `messageId` so the next message branches from there. */\n branchFrom: (messageId: string) => boolean;\n /** Restore the branch leaf that was active before `revertBefore` or `branchFrom`. */\n restore: () => void;\n /** Clear any active checkpoint (call when submitting a new message from the checkpoint). */\n commitFromCheckpoint: () => string | null;\n}\n\nexport function useChatBranches<T extends { id: string }>(\n items: readonly T[],\n options: Omit<ProjectChatBranchesOptions<T>, 'selections' | 'headId' | 'stopAtHead'> = {},\n): ChatBranchesController<T> {\n const { getParentId } = options;\n const [state, setState] = useState<ChatBranchesState>({ selections: {} });\n\n const parentMap = useMemo(() => {\n const byId = new Set(items.map(item => item.id));\n const map = new Map<string, string | null>();\n items.forEach((item, index) => {\n const raw = getParentId ? getParentId(item, index, items) : undefined;\n const resolved =\n raw === undefined\n ? (index > 0 ? items[index - 1]!.id : null)\n : raw !== null && byId.has(raw)\n ? raw\n : null;\n map.set(item.id, resolved === item.id ? null : resolved);\n });\n return map;\n }, [items, getParentId]);\n\n const projection = useMemo(\n () =>\n projectChatBranches(items, {\n getParentId,\n selections: state.selections,\n headId: state.checkpoint ? state.checkpoint.afterId : undefined,\n stopAtHead: state.checkpoint !== undefined,\n }),\n [items, getParentId, state],\n );\n\n const selectBranch = useCallback(\n (messageId: string) => {\n if (!parentMap.has(messageId)) return;\n setState(current => {\n const nextSelections = { ...current.selections };\n let cursor: string | null = messageId;\n const seen = new Set<string>();\n while (cursor !== null && !seen.has(cursor)) {\n seen.add(cursor);\n const p: string | null = parentMap.get(cursor) ?? null;\n nextSelections[parentKey(p)] = cursor;\n cursor = p;\n }\n return { selections: nextSelections, checkpoint: undefined };\n });\n },\n [parentMap],\n );\n\n const revertBefore = useCallback(\n (messageId: string): T | undefined => {\n const target = items.find(item => item.id === messageId);\n if (!target) return undefined;\n const afterId = parentMap.get(messageId) ?? null;\n const currentLeaf = projection.headId;\n setState(current => ({\n selections: current.selections,\n checkpoint: {\n afterId,\n revertedMessageId: messageId,\n restoreLeafId: current.checkpoint?.restoreLeafId ?? currentLeaf,\n },\n }));\n return target;\n },\n [items, parentMap, projection.headId],\n );\n\n const branchFrom = useCallback(\n (messageId: string): boolean => {\n if (!parentMap.has(messageId)) return false;\n const currentLeaf = projection.headId;\n setState(current => ({\n selections: current.selections,\n checkpoint: {\n afterId: messageId,\n restoreLeafId: current.checkpoint?.restoreLeafId ?? currentLeaf,\n },\n }));\n return true;\n },\n [parentMap, projection.headId],\n );\n\n const restore = useCallback(() => {\n setState(current => {\n const leaf = current.checkpoint?.restoreLeafId;\n if (!leaf || !parentMap.has(leaf)) return { ...current, checkpoint: undefined };\n const nextSelections = { ...current.selections };\n let cursor: string | null = leaf;\n const seen = new Set<string>();\n while (cursor !== null && !seen.has(cursor)) {\n seen.add(cursor);\n const p: string | null = parentMap.get(cursor) ?? null;\n nextSelections[parentKey(p)] = cursor;\n cursor = p;\n }\n return { selections: nextSelections, checkpoint: undefined };\n });\n }, [parentMap]);\n\n const commitFromCheckpoint = useCallback(() => {\n const parentId = projection.headId;\n setState(current => {\n const nextSelections = { ...current.selections };\n delete nextSelections[parentKey(parentId)];\n return { selections: nextSelections, checkpoint: undefined };\n });\n return parentId;\n }, [projection.headId]);\n\n return {\n ...projection,\n nextParentId: projection.headId,\n revertedMessageId: state.checkpoint?.revertedMessageId,\n canRestore: Boolean(state.checkpoint?.restoreLeafId && parentMap.has(state.checkpoint.restoreLeafId)),\n selectBranch,\n revertBefore,\n branchFrom,\n restore,\n commitFromCheckpoint,\n };\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;C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iB,UAAU,IAAI,MAAM,WAAW,aAAa,CAAC;EACpG;EACA;EACA;EACA;EACA;CACF;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ui-primitives-XhFvDm8o.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, ChevronDown, 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' | 'chevronDown' | '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, chevronDown: ChevronDown, 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;CAAa,aAAa;CACrG,MAAM;CAAO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