@brainfish-ai/components 0.25.1 → 0.25.3

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.
Files changed (51) hide show
  1. package/dist/conversation.d.ts +222 -0
  2. package/dist/esm/chunks/{ChatSearch.DGeR-vOp.js → ChatSearch.C7aXA1pe.js} +5 -4
  3. package/dist/esm/chunks/ChatSearch.C7aXA1pe.js.map +1 -0
  4. package/dist/esm/chunks/Conversation.BEDav4lr.js +826 -0
  5. package/dist/esm/chunks/Conversation.BEDav4lr.js.map +1 -0
  6. package/dist/esm/chunks/{feature-flags.C57XMODn.js → feature-flags.DeDEcnd1.js} +2 -2
  7. package/dist/esm/chunks/{feature-flags.C57XMODn.js.map → feature-flags.DeDEcnd1.js.map} +1 -1
  8. package/dist/esm/chunks/{filters.LuyM6z8R.js → filters.-7vSLEQ2.js} +2 -2
  9. package/dist/esm/chunks/filters.-7vSLEQ2.js.map +1 -0
  10. package/dist/esm/chunks/{header-nav.BfxbPhBr.js → header-nav.BNurn_vB.js} +2 -2
  11. package/dist/esm/chunks/{header-nav.BfxbPhBr.js.map → header-nav.BNurn_vB.js.map} +1 -1
  12. package/dist/esm/chunks/{layout.r6wmt9tu.js → header-pane.BKCOw7kk.js} +50 -5
  13. package/dist/esm/chunks/header-pane.BKCOw7kk.js.map +1 -0
  14. package/dist/esm/chunks/{hooks.r53voN37.js → hooks.m-nIJmio.js} +2 -2
  15. package/dist/esm/chunks/{hooks.r53voN37.js.map → hooks.m-nIJmio.js.map} +1 -1
  16. package/dist/esm/chunks/input-with-tags.tg2nhPFv.js +110 -0
  17. package/dist/esm/chunks/input-with-tags.tg2nhPFv.js.map +1 -0
  18. package/dist/esm/chunks/{review-list.Gro9EAA8.js → review-list.DjtiIcPl.js} +2 -2
  19. package/dist/esm/chunks/{review-list.Gro9EAA8.js.map → review-list.DjtiIcPl.js.map} +1 -1
  20. package/dist/esm/chunks/{sidebar.BXXr2DBo.js → sidebar.PfXKnt9J.js} +9 -3
  21. package/dist/esm/chunks/sidebar.PfXKnt9J.js.map +1 -0
  22. package/dist/esm/components/article-suggestions-banner.js +2 -3
  23. package/dist/esm/components/article-suggestions-banner.js.map +1 -1
  24. package/dist/esm/components/chat-search.js +1 -1
  25. package/dist/esm/components/conversation.js +2 -0
  26. package/dist/esm/components/conversation.js.map +1 -0
  27. package/dist/esm/components/filter.js +1 -1
  28. package/dist/esm/components/input-with-tags.js +2 -0
  29. package/dist/esm/components/input-with-tags.js.map +1 -0
  30. package/dist/esm/components/ui/tooltip.js +21 -23
  31. package/dist/esm/components/ui/tooltip.js.map +1 -1
  32. package/dist/esm/global.css +1 -1
  33. package/dist/esm/index.js +17 -987
  34. package/dist/esm/index.js.map +1 -1
  35. package/dist/esm/layouts/full-layout.js +1 -7
  36. package/dist/esm/layouts/full-layout.js.map +1 -1
  37. package/dist/esm/layouts/header-nav.js +1 -1
  38. package/dist/esm/layouts/sidebar.js +1 -1
  39. package/dist/esm/scenes/knowledge-review.js +3 -4
  40. package/dist/esm/scenes/knowledge-review.js.map +1 -1
  41. package/dist/full-layout.d.ts +97 -4
  42. package/dist/index.d.ts +2 -4
  43. package/dist/input-with-tags.d.ts +31 -0
  44. package/dist/layouts/full-layout.d.ts +1 -3
  45. package/dist/stats.html +1 -1
  46. package/dist/tooltip.d.ts +2 -4
  47. package/package.json +7 -2
  48. package/dist/esm/chunks/ChatSearch.DGeR-vOp.js.map +0 -1
  49. package/dist/esm/chunks/filters.LuyM6z8R.js.map +0 -1
  50. package/dist/esm/chunks/layout.r6wmt9tu.js.map +0 -1
  51. package/dist/esm/chunks/sidebar.BXXr2DBo.js.map +0 -1
package/dist/esm/index.js CHANGED
@@ -1,26 +1,21 @@
1
1
  import './global.css';/* empty css */
2
2
  export { BrainfishColors } from './colors.js';
3
- export { C as ChatSearch, a as ChatSearchProvider, u as useChatSearch, b as useIsChatSearchDirty } from './chunks/ChatSearch.DGeR-vOp.js';
4
- import { F as FormattedMessage } from './chunks/FormattedMessage.CRbM-hF6.js';
5
- export { C as CodeBlock, M as MemoizedReactMarkdown, Z as ZoomableImage, a as addPopupWidgetUtm, b as addUtmParameters } from './chunks/FormattedMessage.CRbM-hF6.js';
3
+ export { C as ChatSearch, a as ChatSearchProvider, u as useChatSearch, b as useIsChatSearchDirty } from './chunks/ChatSearch.C7aXA1pe.js';
4
+ export { C as ContextPillBadge, a as Conversation, b as ConversationActions, c as ConversationInput, d as ConversationLoading, e as ConversationMessageAssistant, f as ConversationMessageUser, g as ConversationMessages, h as ConversationProvider, i as ConversationSuggestions, u as useConversation } from './chunks/Conversation.BEDav4lr.js';
5
+ export { C as CodeBlock, F as FormattedMessage, M as MemoizedReactMarkdown, Z as ZoomableImage, a as addPopupWidgetUtm, b as addUtmParameters } from './chunks/FormattedMessage.CRbM-hF6.js';
6
6
  export { MermaidDiagram } from './chunks/MermaidDiagram.xQ0CVFOI.js';
7
7
  export { Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage } from './components/ui/avatar.js';
8
- import { B as Button } from './chunks/button.DQL6gCAt.js';
9
- export { b as buttonVariants } from './chunks/button.DQL6gCAt.js';
8
+ export { B as Button, b as buttonVariants } from './chunks/button.DQL6gCAt.js';
10
9
  export { Collapsible, CollapsibleContent, CollapsibleTrigger } from './components/ui/collapsible.js';
11
- import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator } from './components/ui/dropdown-menu.js';
12
- export { DropdownMenuCheckboxItem, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger } from './components/ui/dropdown-menu.js';
10
+ export { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger } from './components/ui/dropdown-menu.js';
13
11
  export { Switch } from './components/ui/switch.js';
14
- import { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider } from './components/ui/tooltip.js';
15
- import { Textarea } from './components/ui/textarea.js';
16
- import { ScrollArea } from './components/ui/scroll-area.js';
17
- export { ScrollBar } from './components/ui/scroll-area.js';
12
+ export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from './components/ui/tooltip.js';
13
+ export { Textarea } from './components/ui/textarea.js';
14
+ export { ScrollArea, ScrollBar } from './components/ui/scroll-area.js';
18
15
  export { Label } from './components/ui/label.js';
19
16
  export { Input } from './components/ui/input.js';
20
- import { Popover, PopoverTrigger, PopoverContent } from './components/ui/popover.js';
21
- export { PopoverAnchor } from './components/ui/popover.js';
22
- import { Command, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem } from './components/ui/command.js';
23
- export { CommandDialog, CommandSeparator, CommandShortcut } from './components/ui/command.js';
17
+ export { Popover, PopoverAnchor, PopoverContent, PopoverTrigger } from './components/ui/popover.js';
18
+ export { Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut } from './components/ui/command.js';
24
19
  export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger } from './components/ui/dialog.js';
25
20
  export { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from './components/ui/card.js';
26
21
  export { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow } from './components/ui/table.js';
@@ -42,983 +37,18 @@ export { S as SimpleSelect } from './chunks/simpleSelect.B1rktKkt.js';
42
37
  export { D as DatePicker } from './chunks/date-picker._cBTpdEK.js';
43
38
  export { C as Combobox } from './chunks/combobox.CJKym3Z1.js';
44
39
  export { T as TwoLevelCombobox } from './chunks/two-level-combobox.BXs2z9u5.js';
45
- export { F as Filter, a as Filters, O as Operator } from './chunks/filters.LuyM6z8R.js';
40
+ export { F as Filter, a as Filters, O as Operator } from './chunks/filters.-7vSLEQ2.js';
46
41
  export { F as FileUpload, a as FileUploadStatus, f as formatFileSize } from './chunks/file-upload-status.DP2iuttI.js';
47
42
  export { D as DataTable } from './chunks/data-table.DbcAYxMY.js';
48
- import { L as Logo } from './chunks/logo.D5BMN6Db.js';
43
+ export { I as InputWithTags } from './chunks/input-with-tags.tg2nhPFv.js';
44
+ export { L as Logo } from './chunks/logo.D5BMN6Db.js';
49
45
  export { T as Trend, a as TrendValue } from './chunks/trend-value.COSukPwk.js';
50
46
  export { F as FontPicker, a as FontPickerItem, c as clearFontCache, g as getCachedFonts, l as loadFont, s as setCachedFonts, u as useFontOptions } from './chunks/font-picker.DisEoE8a.js';
51
- export { H as HEADER_NAV_HEIGHT, a as HeaderNav } from './chunks/header-nav.BfxbPhBr.js';
52
- export { S as Sidebar, u as useSidebar } from './chunks/sidebar.BXXr2DBo.js';
47
+ export { F as FullLayout, a as FullLayoutHeader, b as FullLayoutLeftSidebar, c as FullLayoutNavStateContext, d as FullLayoutProvider, e as FullLayoutRightSidebar, u as useFullLayoutContext, f as useRightSidebar } from './chunks/header-pane.BKCOw7kk.js';
48
+ export { H as HEADER_NAV_HEIGHT, a as HeaderNav } from './chunks/header-nav.BNurn_vB.js';
49
+ export { S as Sidebar, u as useSidebar } from './chunks/sidebar.PfXKnt9J.js';
53
50
  export { MicrosoftTeamsLogo } from './logos/microsoft-teams-logo.js';
54
51
  export { SlackLogo } from './logos/slack-logo.js';
55
52
  export { MicrosoftLogo } from './logos/microsoft-logo.js';
56
- export { F as FullLayout, a as FullLayoutLeftSidebar, b as FullLayoutNavStateContext, c as FullLayoutProvider, d as FullLayoutRightSidebar, u as useFullLayoutContext, e as useRightSidebar } from './chunks/layout.r6wmt9tu.js';
57
- import * as React from 'react';
58
- import React__default, { useMemo, useContext, createContext, useCallback, useRef, useEffect, useLayoutEffect, useState, Suspense, forwardRef, Component, createElement, useImperativeHandle } from 'react';
59
- import { Sparkle, ThumbsUp, ThumbsDown, Copy, DotsThreeVertical, X as X$1, Plus, CaretRight, Stop, ArrowUp } from '@phosphor-icons/react';
60
- import { c as cn } from './chunks/utils.Cwtlq8dh.js';
61
- import { createEditor, $getRoot, $createParagraphNode, $getSelection, HISTORY_MERGE_TAG, $caretFromPoint, $isExtendableTextPointCaret, $extendCaretToRange, $isChildCaret, $isElementNode, $isDecoratorNode, $isRootNode, $getEditor, $isTokenOrSegmented, $getCharacterOffsets, $cloneWithPropertiesEphemeral, $isRangeSelection, $findMatchingParent, mergeRegister, DecoratorNode, addClassNamesToElement, shallowMergeConfig, $create, defineExtension, safeCast, createState, FORMAT_TEXT_COMMAND, $isNodeSelection, COMMAND_PRIORITY_LOW, RootNode, TextNode, LineBreakNode, TabNode, ParagraphNode, $isEditorState, createCommand, CLICK_COMMAND, isDOMNode, $getNodeFromDOMNode, $createNodeSelection, $setSelection, $getState, toggleTextFormatType, TEXT_TYPE_TO_FORMAT, $setState, $getNodeByKey, removeClassNamesFromElement, CLEAR_EDITOR_COMMAND, COMMAND_PRIORITY_EDITOR, KEY_TAB_COMMAND, $isBlockElementNode, $createRangeSelection, $normalizeSelection__EXPERIMENTAL, OUTDENT_CONTENT_COMMAND, INDENT_CONTENT_COMMAND, INSERT_TAB_COMMAND, COMMAND_PRIORITY_CRITICAL, $isParagraphNode, $isTextNode, isDOMDocumentNode, ArtificialNode__DO_NOT_USE, $createLineBreakNode, $isRootOrShadowRoot, isBlockDomNode, isInlineDomNode, getRegisteredNode, isHTMLElement, isDocumentFragment, $createTabNode, getDOMSelection, COPY_COMMAND, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, $isTextPointCaret, $getCaretRange, $getChildCaret, $parseSerializedNode, isSelectionWithinEditor, DELETE_CHARACTER_COMMAND, DELETE_WORD_COMMAND, DELETE_LINE_COMMAND, CONTROLLED_TEXT_INSERTION_COMMAND, REMOVE_TEXT_COMMAND, FORMAT_ELEMENT_COMMAND, INSERT_LINE_BREAK_COMMAND, INSERT_PARAGRAPH_COMMAND, $insertNodes, KEY_ARROW_UP_COMMAND, $getAdjacentNode, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_LEFT_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND, DROP_COMMAND, $getNearestNodeFromDOMNode, DRAGSTART_COMMAND, DRAGOVER_COMMAND, SELECT_ALL_COMMAND, $selectAll, CUT_COMMAND, PASTE_COMMAND, isSelectionCapturedInDecoratorInput, PASTE_TAG, KEY_SPACE_COMMAND, ElementNode, setNodeIndentFromDOM, $applyNodeReplacement, COMMAND_PRIORITY_HIGH } from 'lexical';
62
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
63
- import { flushSync, createPortal } from 'react-dom';
64
- import { createEmptyHistoryState, registerHistory } from '@lexical/history';
65
- import { ListNode, ListItemNode, registerList, registerListStrictIndentTransform, $isListItemNode } from '@lexical/list';
66
- import { LinkNode, registerLink, AutoLinkNode } from '@lexical/link';
67
- import { registerMarkdownShortcuts, TRANSFORMERS, ORDERED_LIST, UNORDERED_LIST, LINK, INLINE_CODE, CODE, $convertToMarkdownString, $convertFromMarkdownString } from '@lexical/markdown';
68
- import { CodeNode, CodeHighlightNode, $isCodeNode } from '@lexical/code';
69
- export { a as ReviewList, b as ReviewListItem, R as ReviewsSelectionProvider, u as useReviewsSelection } from './chunks/review-list.Gro9EAA8.js';
70
-
71
- const ConversationContext = createContext(null);
72
- function useConversation() {
73
- const ctx = useContext(ConversationContext);
74
- if (!ctx) {
75
- throw new Error("useConversation must be used within a <Conversation> provider");
76
- }
77
- return ctx;
78
- }
79
- function ConversationProvider({ messages, callbacks, children }) {
80
- const isStreaming = messages.some((m) => m.status === "streaming");
81
- const value = useMemo(() => ({ messages, callbacks, isStreaming }), [messages, callbacks, isStreaming]);
82
- return /* @__PURE__ */ React__default.createElement(ConversationContext.Provider, { value }, children);
83
- }
84
-
85
- const TextBlock = ({ part, isStreaming }) => {
86
- return /* @__PURE__ */ React__default.createElement(FormattedMessage, { message: { content: part.text }, isStreaming });
87
- };
88
-
89
- const CitationBlock = ({ part, onCitationClick }) => {
90
- return /* @__PURE__ */ React__default.createElement("span", { className: "inline-flex flex-wrap gap-1" }, part.citations.map((citation) => /* @__PURE__ */ React__default.createElement(CitationBadge, { key: citation.id, citation, onClick: onCitationClick })));
91
- };
92
- const CitationBadge = ({ citation, onClick }) => {
93
- return /* @__PURE__ */ React__default.createElement(Tooltip, null, /* @__PURE__ */ React__default.createElement(TooltipTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(
94
- "button",
95
- {
96
- type: "button",
97
- className: "inline-flex h-5 w-5 items-center justify-center rounded-full bg-primary/10 text-xs font-medium text-primary hover:bg-primary/20 transition-colors",
98
- onClick: () => onClick?.(citation)
99
- },
100
- citation.index
101
- )), /* @__PURE__ */ React__default.createElement(TooltipContent, { side: "top", className: "max-w-xs" }, /* @__PURE__ */ React__default.createElement("p", { className: "text-sm font-medium" }, citation.title), /* @__PURE__ */ React__default.createElement("p", { className: "text-xs text-muted-foreground truncate" }, citation.url)));
102
- };
103
-
104
- const ImageBlock = ({ part }) => {
105
- return /* @__PURE__ */ React__default.createElement("div", { className: "my-2" }, /* @__PURE__ */ React__default.createElement("img", { src: part.url, alt: part.alt ?? "", className: "max-w-full rounded-lg", loading: "lazy" }));
106
- };
107
-
108
- const ToolCallBlock = ({ part }) => {
109
- return /* @__PURE__ */ React__default.createElement("div", { className: "my-2 rounded-lg border border-border bg-muted/50 p-3 text-sm" }, /* @__PURE__ */ React__default.createElement("div", { className: "flex items-center gap-2" }, /* @__PURE__ */ React__default.createElement("span", { className: "font-medium" }, part.toolName), /* @__PURE__ */ React__default.createElement("span", { className: "text-xs text-muted-foreground capitalize" }, "(", part.status, ")")), part.result && /* @__PURE__ */ React__default.createElement("pre", { className: "mt-2 whitespace-pre-wrap text-xs text-muted-foreground" }, part.result));
110
- };
111
-
112
- const ThinkingBlock = ({ part }) => {
113
- return /* @__PURE__ */ React__default.createElement("div", { className: "my-2 rounded-lg border border-dashed border-border bg-muted/30 p-3 text-sm italic text-muted-foreground" }, part.text);
114
- };
115
-
116
- const BlockRenderer = ({ part, isStreaming, onCitationClick }) => {
117
- switch (part.type) {
118
- case "text":
119
- return /* @__PURE__ */ React__default.createElement(TextBlock, { part, isStreaming });
120
- case "citation":
121
- return /* @__PURE__ */ React__default.createElement(CitationBlock, { part, onCitationClick });
122
- case "image":
123
- return /* @__PURE__ */ React__default.createElement(ImageBlock, { part });
124
- case "tool-call":
125
- return /* @__PURE__ */ React__default.createElement(ToolCallBlock, { part });
126
- case "thinking":
127
- return /* @__PURE__ */ React__default.createElement(ThinkingBlock, { part });
128
- case "action-buttons":
129
- return null;
130
- default:
131
- return null;
132
- }
133
- };
134
-
135
- const ConversationLoading = ({ className }) => {
136
- return /* @__PURE__ */ React__default.createElement("div", { className: cn("flex gap-3 py-4", className) }, /* @__PURE__ */ React__default.createElement("div", { className: "flex-shrink-0 mt-1" }, /* @__PURE__ */ React__default.createElement(Sparkle, { className: "h-5 w-5 text-primary animate-pulse", weight: "fill" })), /* @__PURE__ */ React__default.createElement("div", { className: "flex-1 space-y-3" }, /* @__PURE__ */ React__default.createElement("div", { className: "h-3 w-3/4 animate-pulse rounded bg-muted" }), /* @__PURE__ */ React__default.createElement("div", { className: "h-3 w-full animate-pulse rounded bg-muted" }), /* @__PURE__ */ React__default.createElement("div", { className: "h-3 w-5/6 animate-pulse rounded bg-muted" }), /* @__PURE__ */ React__default.createElement("div", { className: "h-3 w-2/3 animate-pulse rounded bg-muted" })));
137
- };
138
-
139
- const ConversationMessageAssistant = ({ message, className }) => {
140
- const { callbacks } = useConversation();
141
- const isStreaming = message.status === "streaming";
142
- const isPending = message.status === "pending";
143
- const isCompleted = message.status === "completed";
144
- const actionButtonsParts = message.parts.filter((p) => p.type === "action-buttons");
145
- const contentParts = message.parts.filter((p) => p.type !== "action-buttons");
146
- const handleCopy = useCallback(() => {
147
- const textContent = message.parts.filter((p) => p.type === "text").map((p) => p.text).join("\n");
148
- callbacks.onCopy?.(message.id, textContent);
149
- }, [message, callbacks]);
150
- if (isPending && contentParts.length === 0) {
151
- return /* @__PURE__ */ React__default.createElement(ConversationLoading, { className });
152
- }
153
- return /* @__PURE__ */ React__default.createElement("div", { className: cn("flex gap-3 p-4 bg-surface rounded", className) }, /* @__PURE__ */ React__default.createElement("div", { className: "flex-1 min-w-0" }, /* @__PURE__ */ React__default.createElement("div", { className: "space-y-1" }, contentParts.map((part, i) => /* @__PURE__ */ React__default.createElement(BlockRenderer, { key: i, part, isStreaming, onCitationClick: callbacks.onCitationClick }))), isCompleted && /* @__PURE__ */ React__default.createElement("div", { className: "mt-3 flex items-center gap-1" }, /* @__PURE__ */ React__default.createElement(
154
- ActionBarButton,
155
- {
156
- tooltip: "Helpful",
157
- active: message.feedback === "positive",
158
- onClick: () => callbacks.onFeedback?.(message.id, "positive")
159
- },
160
- /* @__PURE__ */ React__default.createElement(ThumbsUp, { className: "h-4 w-4", weight: message.feedback === "positive" ? "fill" : "regular" })
161
- ), /* @__PURE__ */ React__default.createElement(
162
- ActionBarButton,
163
- {
164
- tooltip: "Not helpful",
165
- active: message.feedback === "negative",
166
- onClick: () => callbacks.onFeedback?.(message.id, "negative")
167
- },
168
- /* @__PURE__ */ React__default.createElement(ThumbsDown, { className: "h-4 w-4", weight: message.feedback === "negative" ? "fill" : "regular" })
169
- ), /* @__PURE__ */ React__default.createElement(ActionBarButton, { tooltip: "Copy", onClick: handleCopy }, /* @__PURE__ */ React__default.createElement(Copy, { className: "h-4 w-4" })), /* @__PURE__ */ React__default.createElement(ActionBarButton, { tooltip: "More" }, /* @__PURE__ */ React__default.createElement(DotsThreeVertical, { className: "h-4 w-4" })), actionButtonsParts.map(
170
- (part) => part.type === "action-buttons" ? part.actions.map((action) => /* @__PURE__ */ React__default.createElement(
171
- "button",
172
- {
173
- key: action.id,
174
- type: "button",
175
- className: "ml-2 inline-flex items-center gap-1.5 rounded-full border border-border px-3 py-1 text-xs text-muted-foreground hover:bg-muted transition-colors",
176
- onClick: () => callbacks.onActionClick?.(action, message.id)
177
- },
178
- action.label
179
- )) : null
180
- ))));
181
- };
182
- const ActionBarButton = ({ children, tooltip, active, onClick }) => {
183
- return /* @__PURE__ */ React__default.createElement(Tooltip, null, /* @__PURE__ */ React__default.createElement(TooltipTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(
184
- "button",
185
- {
186
- type: "button",
187
- className: cn(
188
- "inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
189
- active && "text-primary"
190
- ),
191
- onClick
192
- },
193
- children
194
- )), /* @__PURE__ */ React__default.createElement(TooltipContent, { side: "bottom" }, /* @__PURE__ */ React__default.createElement("p", { className: "text-xs" }, tooltip)));
195
- };
196
-
197
- const ConversationMessageUser = ({ message, className }) => {
198
- const textContent = message.parts.filter((p) => p.type === "text").map((p) => p.text).join("\n");
199
- return /* @__PURE__ */ React__default.createElement("div", { className: cn("flex justify-end py-4", className) }, /* @__PURE__ */ React__default.createElement("div", { className: "max-w-[85%] rounded bg-surface px-4 py-2.5 text-primary-foreground" }, /* @__PURE__ */ React__default.createElement("p", { className: "whitespace-pre-wrap" }, textContent)));
200
- };
201
-
202
- const ConversationMessage = ({ message, className }) => {
203
- switch (message.role) {
204
- case "assistant":
205
- return /* @__PURE__ */ React__default.createElement(ConversationMessageAssistant, { message, className });
206
- case "user":
207
- return /* @__PURE__ */ React__default.createElement(ConversationMessageUser, { message, className });
208
- default:
209
- return null;
210
- }
211
- };
212
-
213
- const ConversationMessages = ({ className, bottomPadding = 0, onContentBehind }) => {
214
- const { messages } = useConversation();
215
- const viewportRef = useRef(null);
216
- const sentinelRef = useRef(null);
217
- useEffect(() => {
218
- const viewport = viewportRef.current;
219
- if (viewport) {
220
- viewport.scrollTop = viewport.scrollHeight;
221
- }
222
- }, [messages]);
223
- useEffect(() => {
224
- const sentinel = sentinelRef.current;
225
- const viewport = viewportRef.current;
226
- if (!sentinel || !viewport || !onContentBehind) return;
227
- const observer = new IntersectionObserver(
228
- ([entry]) => {
229
- if (entry) onContentBehind(!entry.isIntersecting);
230
- },
231
- { root: viewport, threshold: 0, rootMargin: `0px 0px -${bottomPadding}px 0px` }
232
- );
233
- observer.observe(sentinel);
234
- return () => observer.disconnect();
235
- }, [onContentBehind, bottomPadding]);
236
- return /* @__PURE__ */ React__default.createElement(ScrollArea, { ref: viewportRef, className: cn("h-full", className) }, /* @__PURE__ */ React__default.createElement("div", { className: "px-4" }, messages.map((message) => /* @__PURE__ */ React__default.createElement(ConversationMessage, { key: message.id, message })), /* @__PURE__ */ React__default.createElement("div", { ref: sentinelRef, className: "h-px" })), /* @__PURE__ */ React__default.createElement("div", { style: { height: bottomPadding + 8 } }));
237
- };
238
-
239
- /**
240
- * Copyright (c) Meta Platforms, Inc. and affiliates.
241
- *
242
- * This source code is licensed under the MIT license found in the
243
- * LICENSE file in the root directory of this source tree.
244
- *
245
- */
246
-
247
- const r$2=createContext(null);function t(n,e){return {getTheme:function(){return null!=e?e:null}}}function o(){const n=useContext(r$2);return null==n&&function(n,...e){const r=new URL("https://lexical.dev/docs/error"),t=new URLSearchParams;t.append("code",n);for(const n of e)t.append("v",n);throw r.search=t.toString(),Error(`Minified Lexical error #${n}; visit ${r.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(8),n}
248
-
249
- /**
250
- * Copyright (c) Meta Platforms, Inc. and affiliates.
251
- *
252
- * This source code is licensed under the MIT license found in the
253
- * LICENSE file in the root directory of this source tree.
254
- *
255
- */
256
-
257
- const m$3="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,u$3=m$3?useLayoutEffect:useEffect,p$2={tag:HISTORY_MERGE_TAG};function f$3({initialConfig:a,children:c}){const l=useMemo(()=>{const{theme:t$1,namespace:c,nodes:l,onError:d,editorState:s,html:u}=a,f=t(null,t$1),E=createEditor({editable:a.editable,html:u,namespace:c,nodes:l,onError:e=>d(e,E),theme:t$1});return function(e,t){if(null===t)return;if(void 0===t)e.update(()=>{const t=$getRoot();if(t.isEmpty()){const o=$createParagraphNode();t.append(o);const n=m$3?document.activeElement:null;(null!==$getSelection()||null!==n&&n===e.getRootElement())&&o.select();}},p$2);else if(null!==t)switch(typeof t){case "string":{const o=e.parseEditorState(t);e.setEditorState(o,p$2);break}case "object":e.setEditorState(t,p$2);break;case "function":e.update(()=>{$getRoot().isEmpty()&&t(e);},p$2);}}(E,s),[E,f]},[]);return u$3(()=>{const e=a.editable,[t]=l;t.setEditable(void 0===e||e);},[]),jsx(r$2.Provider,{value:l,children:c})}
258
-
259
- /**
260
- * Copyright (c) Meta Platforms, Inc. and affiliates.
261
- *
262
- * This source code is licensed under the MIT license found in the
263
- * LICENSE file in the root directory of this source tree.
264
- *
265
- */
266
-
267
- const c$2="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?useLayoutEffect:useEffect;function u$2(e){return {initialValueFn:()=>e.isEditable(),subscribe:n=>e.registerEditableListener(n)}}function a$2(){return function(n){const[t]=o(),u=useMemo(()=>n(t),[t,n]),[a,l]=useState(()=>u.initialValueFn()),d=useRef(a);return c$2(()=>{const{initialValueFn:e,subscribe:n}=u,t=e();return d.current!==t&&(d.current=t,l(t)),n(e=>{d.current=e,l(e);})},[u,n]),a}(u$2)}
268
-
269
- /**
270
- * Copyright (c) Meta Platforms, Inc. and affiliates.
271
- *
272
- * This source code is licensed under the MIT license found in the
273
- * LICENSE file in the root directory of this source tree.
274
- *
275
- */
276
-
277
- const E$2=new Map;function F$1(e){const t={};if(!e)return t;const n=e.split(";");for(const e of n)if(""!==e){const[n,o]=e.split(/:([^]+)/);n&&o&&(t[n.trim()]=o.trim());}return t}function z(e){const n=$getEditor().getElementByKey(e.getKey());if(null===n)return null;const o=n.ownerDocument.defaultView;return null===o?null:o.getComputedStyle(n)}function O$1(e){return z($isRootNode(e)?e:e.getParentOrThrow())}function A$1(e){const t=O$1(e);return null!==t&&"rtl"===t.direction}function M$1(e,t,n="self"){const o=e.getStartEndPoints();if(t.isSelected(e)&&!$isTokenOrSegmented(t)&&null!==o){const[l,r]=o,s=e.isBackward(),i=l.getNode(),c=r.getNode(),f=t.is(i),u=t.is(c);if(f||u){const[o,l]=$getCharacterOffsets(e),r=i.is(c),f=t.is(s?c:i),u=t.is(s?i:c);let d,p=0;if(r)p=o>l?l:o,d=o>l?o:l;else if(f){p=s?l:o,d=void 0;}else if(u){p=0,d=s?o:l;}const h=t.__text.slice(p,d);h!==t.__text&&("clone"===n&&(t=$cloneWithPropertiesEphemeral(t)),t.__text=h);}}return t}function $(e){const t=e.getStyle(),n=F$1(t);E$2.set(t,n);}function Q$1(e){const t=Y$1(e);return null!==t&&"vertical-rl"===t.writingMode}function Y$1(e){const t=e.anchor.getNode();return $isElementNode(t)?z(t):O$1(t)}function Z$1(e,t){let n=Q$1(e)?!t:t;te$1(e)&&(n=!n);const l=$caretFromPoint(e.focus,n?"previous":"next");if($isExtendableTextPointCaret(l))return false;for(const e of $extendCaretToRange(l)){if($isChildCaret(e))return !e.origin.isInline();if(!$isElementNode(e.origin)){if($isDecoratorNode(e.origin))return true;break}}return false}function ee$1(e,t,n,o){e.modify(t?"extend":"move",n,o);}function te$1(e){const t=Y$1(e);return null!==t&&"rtl"===t.direction}function ne$1(e,t,n){const o=te$1(e);let l;l=Q$1(e)||o?!n:n,ee$1(e,t,l,"character");}
278
-
279
- /**
280
- * Copyright (c) Meta Platforms, Inc. and affiliates.
281
- *
282
- * This source code is licensed under the MIT license found in the
283
- * LICENSE file in the root directory of this source tree.
284
- *
285
- */
286
-
287
- function T(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);throw n.search=o.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const B$1="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,_$1=B$1&&"documentMode"in document?document.documentMode:null;!(!B$1||!("InputEvent"in window)||_$1)&&"getTargetRanges"in new window.InputEvent("input");function yt$1(t){const e=$findMatchingParent(t,t=>$isElementNode(t)&&!t.isInline());return $isElementNode(e)||T(4,t.__key),e}function At$2(t,e){return null!==t&&Object.getPrototypeOf(t).constructor.name===e.name}function bt$2(t){const e=$getSelection();if(!$isRangeSelection(e))return false;const i=new Set,l=e.getNodes();for(let e=0;e<l.length;e++){const n=l[e],o=n.getKey();if(i.has(o))continue;const s=$findMatchingParent(n,t=>$isElementNode(t)&&!t.isInline());if(null===s)continue;const u=s.getKey();s.canIndent()&&!i.has(u)&&(i.add(u),t(s));}return i.size>0}
288
-
289
- /**
290
- * Copyright (c) Meta Platforms, Inc. and affiliates.
291
- *
292
- * This source code is licensed under the MIT license found in the
293
- * LICENSE file in the root directory of this source tree.
294
- *
295
- */
296
-
297
- const Z=Symbol.for("preact-signals");function J$1(){if(Y>1)return void Y--;let t,e=false;for(;void 0!==Q;){let n=Q;for(Q=void 0,tt++;void 0!==n;){const i=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&st(n))try{n.c();}catch(n){e||(t=n,e=true);}n=i;}}if(tt=0,Y--,e)throw t}function H(t){if(Y>0)return t();Y++;try{return t()}finally{J$1();}}let q,Q;function X(t){const e=q;q=void 0;try{return t()}finally{q=e;}}let Y=0,tt=0,et=0;function nt(t){if(void 0===q)return;let e=t.n;return void 0===e||e.t!==q?(e={i:0,S:t,p:q.s,n:void 0,t:q,e:void 0,x:void 0,r:e},void 0!==q.s&&(q.s.n=e),q.s=e,t.n=e,32&q.f&&t.S(e),e):-1===e.i?(e.i=0,void 0!==e.n&&(e.n.p=e.p,void 0!==e.p&&(e.p.n=e.n),e.p=q.s,e.n=void 0,q.s.n=e,q.s=e),e):void 0}function it(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name;}function ot(t,e){return new it(t,e)}function st(t){for(let e=t.s;void 0!==e;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return true;return false}function rt(t){for(let e=t.s;void 0!==e;e=e.n){const n=e.S.n;if(void 0!==n&&(e.r=n),e.S.n=e,e.i=-1,void 0===e.n){t.s=e;break}}}function ct(t){let e,n=t.s;for(;void 0!==n;){const t=n.p;-1===n.i?(n.S.U(n),void 0!==t&&(t.n=n.n),void 0!==n.n&&(n.n.p=t)):e=n,n.S.n=n.r,void 0!==n.r&&(n.r=void 0),n=t;}t.s=e;}function at(t,e){it.call(this,void 0),this.x=t,this.s=void 0,this.g=et-1,this.f=4,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name;}function dt(t,e){return new at(t,e)}function ut(t){const e=t.u;if(t.u=void 0,"function"==typeof e){Y++;const n=q;q=void 0;try{e();}catch(e){throw t.f&=-2,t.f|=8,ft(t),e}finally{q=n,J$1();}}}function ft(t){for(let e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,ut(t);}function ht$1(t){if(q!==this)throw new Error("Out-of-order effect");ct(this),q=t,this.f&=-2,8&this.f&&ft(this),J$1();}function lt(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==e?void 0:e.name;}function gt(t,e){const n=new lt(t,e);try{n.c();}catch(t){throw n.d(),t}const i=n.d.bind(n);return i[Symbol.dispose]=i,i}function pt$1(t,e={}){const n={};for(const i in t){const o=e[i],s=ot(void 0===o?t[i]:o);n[i]=s;}return n}it.prototype.brand=Z,it.prototype.h=function(){return true},it.prototype.S=function(t){const e=this.t;e!==t&&void 0===t.e&&(t.x=e,this.t=t,void 0!==e?e.e=t:X(()=>{var t;null==(t=this.W)||t.call(this);}));},it.prototype.U=function(t){if(void 0!==this.t){const e=t.e,n=t.x;void 0!==e&&(e.x=n,t.e=void 0),void 0!==n&&(n.e=e,t.x=void 0),t===this.t&&(this.t=n,void 0===n&&X(()=>{var t;null==(t=this.Z)||t.call(this);}));}},it.prototype.subscribe=function(t){return gt(()=>{const e=this.value,n=q;q=void 0;try{t(e);}finally{q=n;}},{name:"sub"})},it.prototype.valueOf=function(){return this.value},it.prototype.toString=function(){return this.value+""},it.prototype.toJSON=function(){return this.value},it.prototype.peek=function(){const t=q;q=void 0;try{return this.value}finally{q=t;}},Object.defineProperty(it.prototype,"value",{get(){const t=nt(this);return void 0!==t&&(t.i=this.i),this.v},set(t){if(t!==this.v){if(tt>100)throw new Error("Cycle detected");this.v=t,this.i++,et++,Y++;try{for(let t=this.t;void 0!==t;t=t.x)t.t.N();}finally{J$1();}}}}),at.prototype=new it,at.prototype.h=function(){if(this.f&=-3,1&this.f)return false;if(32==(36&this.f))return true;if(this.f&=-5,this.g===et)return true;if(this.g=et,this.f|=1,this.i>0&&!st(this))return this.f&=-2,true;const t=q;try{rt(this),q=this;const t=this.x();(16&this.f||this.v!==t||0===this.i)&&(this.v=t,this.f&=-17,this.i++);}catch(t){this.v=t,this.f|=16,this.i++;}return q=t,ct(this),this.f&=-2,true},at.prototype.S=function(t){if(void 0===this.t){this.f|=36;for(let t=this.s;void 0!==t;t=t.n)t.S.S(t);}it.prototype.S.call(this,t);},at.prototype.U=function(t){if(void 0!==this.t&&(it.prototype.U.call(this,t),void 0===this.t)){this.f&=-33;for(let t=this.s;void 0!==t;t=t.n)t.S.U(t);}},at.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let t=this.t;void 0!==t;t=t.x)t.t.N();}},Object.defineProperty(at.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const t=nt(this);if(this.h(),void 0!==t&&(t.i=this.i),16&this.f)throw this.v;return this.v}}),lt.prototype.c=function(){const t=this.S();try{if(8&this.f)return;if(void 0===this.x)return;const t=this.x();"function"==typeof t&&(this.u=t);}finally{t();}},lt.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,ut(this),rt(this),Y++;const t=q;return q=this,ht$1.bind(this,t)},lt.prototype.N=function(){2&this.f||(this.f|=2,this.o=Q,Q=this);},lt.prototype.d=function(){this.f|=8,1&this.f||ft(this);},lt.prototype.dispose=function(){this.d();};defineExtension({build:(t,e,n)=>pt$1(e),config:safeCast({defaultSelection:"rootEnd",disabled:false}),name:"@lexical/extension/AutoFocus",register(t,e,n){const i=n.getOutput();return gt(()=>i.disabled.value?void 0:t.registerRootListener(e=>{t.focus(()=>{const t=document.activeElement;null===e||null!==t&&e.contains(t)||e.focus({preventScroll:true});},{defaultSelection:i.defaultSelection.peek()});}))}});function vt$1(){const t=$getRoot(),e=$getSelection(),n=$createParagraphNode();t.clear(),t.append(n),null!==e&&n.select(),$isRangeSelection(e)&&(e.format=0);}function xt$1(t,e=vt$1){return t.registerCommand(CLEAR_EDITOR_COMMAND,n=>(t.update(e),true),COMMAND_PRIORITY_EDITOR)}defineExtension({build:(t,e,n)=>pt$1(e),config:safeCast({$onClear:vt$1}),name:"@lexical/extension/ClearEditor",register(t,e,n){const{$onClear:i}=n.getOutput();return gt(()=>xt$1(t,i.value))}});function Et$1(t){return ("function"==typeof t.nodes?t.nodes():t.nodes)||[]}const bt$1=createState("format",{parse:t=>"number"==typeof t?t:0});let wt$1 = class wt extends DecoratorNode{$config(){return this.config("decorator-text",{extends:DecoratorNode,stateConfigs:[{flat:true,stateConfig:bt$1}]})}getFormat(){return $getState(this,bt$1)}getFormatFlags(t,e){return toggleTextFormatType(this.getFormat(),t,e)}hasFormat(t){const e=TEXT_TYPE_TO_FORMAT[t];return 0!==(this.getFormat()&e)}setFormat(t){return $setState(this,bt$1,t)}toggleFormat(t){const e=this.getFormat(),n=toggleTextFormatType(e,t,null);return this.setFormat(n)}isInline(){return true}createDOM(){return document.createElement("span")}updateDOM(){return false}};function Nt$1(t){return t instanceof wt$1}defineExtension({name:"@lexical/extension/DecoratorText",nodes:()=>[wt$1],register:(t,e,n)=>t.registerCommand(FORMAT_TEXT_COMMAND,t=>{const e=$getSelection();if($isNodeSelection(e)||$isRangeSelection(e))for(const n of e.getNodes())Nt$1(n)&&n.toggleFormat(t);return false},COMMAND_PRIORITY_LOW)});function Ft$1(t,e){let n;return ot(t(),{unwatched(){n&&(n(),n=void 0);},watched(){this.value=t(),n=e(this);}})}const It=defineExtension({build:t=>Ft$1(()=>t.getEditorState(),e=>t.registerUpdateListener(t=>{e.value=t.editorState;})),name:"@lexical/extension/EditorState"});function _t$1(t,...e){const n=new URL("https://lexical.dev/docs/error"),i=new URLSearchParams;i.append("code",t);for(const t of e)i.append("v",t);throw n.search=i.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function jt(t,e){if(t&&e&&!Array.isArray(e)&&"object"==typeof t&&"object"==typeof e){const n=t,i=e;for(const t in i)n[t]=jt(n[t],i[t]);return t}return e}const At$1=0,kt$1=1,Pt=2,Kt$1=3,$t=4,zt=5,Ut=6,Lt=7;function Tt$1(t){return t.id===At$1}function Bt(t){return t.id===Pt}function Wt(t){return function(t){return t.id===kt$1}(t)||_t$1(305,String(t.id),String(kt$1)),Object.assign(t,{id:Pt})}const Gt=new Set;class Vt{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(t,e){this.builder=t,this.extension=e,this.configs=new Set,this.state={id:At$1};}mergeConfigs(){let t=this.extension.config||{};const e=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):shallowMergeConfig;for(const n of this.configs)t=e(t,n);return t}init(t){const e=this.state;Bt(e)||_t$1(306,String(e.id));const n={getDependency:this.getInitDependency.bind(this),getDirectDependentNames:this.getDirectDependentNames.bind(this),getPeer:this.getInitPeer.bind(this),getPeerNameSet:this.getPeerNameSet.bind(this)},i={...n,getDependency:this.getDependency.bind(this),getInitResult:this.getInitResult.bind(this),getPeer:this.getPeer.bind(this)},o=function(t,e,n){return Object.assign(t,{config:e,id:Kt$1,registerState:n})}(e,this.mergeConfigs(),n);let s;this.state=o,this.extension.init&&(s=this.extension.init(t,o.config,n)),this.state=function(t,e,n){return Object.assign(t,{id:$t,initResult:e,registerState:n})}(o,s,i);}build(t){const e=this.state;let n;e.id!==$t&&_t$1(307,String(e.id),String(zt)),this.extension.build&&(n=this.extension.build(t,e.config,e.registerState));const i={...e.registerState,getOutput:()=>n,getSignal:this.getSignal.bind(this)};this.state=function(t,e,n){return Object.assign(t,{id:zt,output:e,registerState:n})}(e,n,i);}register(t,e){this._signal=e;const n=this.state;n.id!==zt&&_t$1(308,String(n.id),String(zt));const i=this.extension.register&&this.extension.register(t,n.config,n.registerState);return this.state=function(t){return Object.assign(t,{id:Ut})}(n),()=>{const t=this.state;t.id!==Lt&&_t$1(309,String(n.id),String(Lt)),this.state=function(t){return Object.assign(t,{id:zt})}(t),i&&i();}}afterRegistration(t){const e=this.state;let n;return e.id!==Ut&&_t$1(310,String(e.id),String(Ut)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(t,e.config,e.registerState)),this.state=function(t){return Object.assign(t,{id:Lt})}(e),n}getSignal(){return void 0===this._signal&&_t$1(311),this._signal}getInitResult(){ void 0===this.extension.init&&_t$1(312,this.extension.name);const t=this.state;return function(t){return t.id>=$t}(t)||_t$1(313,String(t.id),String($t)),t.initResult}getInitPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionInitDependency():void 0}getExtensionInitDependency(){const t=this.state;return function(t){return t.id>=Kt$1}(t)||_t$1(314,String(t.id),String(Kt$1)),{config:t.config}}getPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionDependency():void 0}getInitDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&_t$1(315,this.extension.name,t.name),e.getExtensionInitDependency()}getDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&_t$1(315,this.extension.name,t.name),e.getExtensionDependency()}getState(){const t=this.state;return function(t){return t.id>=Lt}(t)||_t$1(316,String(t.id),String(Lt)),t}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||Gt}getPeerNameSet(){let t=this._peerNameSet;return t||(t=new Set((this.extension.peerDependencies||[]).map(([t])=>t)),this._peerNameSet=t),t}getExtensionDependency(){if(!this._dependency){const t=this.state;((function(t){return t.id>=zt}))(t)||_t$1(317,this.extension.name),this._dependency={config:t.config,init:t.initResult,output:t.output};}return this._dependency}}const Zt={tag:HISTORY_MERGE_TAG};function Jt$1(){const t=$getRoot();t.isEmpty()&&t.append($createParagraphNode());}const Ht=defineExtension({config:safeCast({setOptions:Zt,updateOptions:Zt}),init:({$initialEditorState:t=Jt$1})=>({$initialEditorState:t,initialized:false}),afterRegistration(t,{updateOptions:e,setOptions:n},i){const o=i.getInitResult();if(!o.initialized){o.initialized=true;const{$initialEditorState:i}=o;if($isEditorState(i))t.setEditorState(i,n);else if("function"==typeof i)t.update(()=>{i(t);},e);else if(i&&("string"==typeof i||"object"==typeof i)){const e=t.parseEditorState(i);t.setEditorState(e,n);}}return ()=>{}},name:"@lexical/extension/InitialState",nodes:[RootNode,TextNode,LineBreakNode,TabNode,ParagraphNode]}),qt=Symbol.for("@lexical/extension/LexicalBuilder");function Xt(){}function Yt(t){throw t}function te(t){return Array.isArray(t)?t:[t]}const ee="0.41.0+prod.esm";class ne{roots;extensionNameMap;outgoingConfigEdges;incomingEdges;conflicts;_sortedExtensionReps;PACKAGE_VERSION;constructor(t){this.outgoingConfigEdges=new Map,this.incomingEdges=new Map,this.extensionNameMap=new Map,this.conflicts=new Map,this.PACKAGE_VERSION=ee,this.roots=t;for(const e of t)this.addExtension(e);}static fromExtensions(t){const e=[te(Ht)];for(const n of t)e.push(te(n));return new ne(e)}static maybeFromEditor(t){const e=t[qt];return e&&(e.PACKAGE_VERSION!==ee&&_t$1(292,e.PACKAGE_VERSION,ee),e instanceof ne||_t$1(293)),e}static fromEditor(t){const e=ne.maybeFromEditor(t);return void 0===e&&_t$1(294),e}constructEditor(){const{$initialEditorState:t,onError:e,...n}=this.buildCreateEditorArgs(),i=Object.assign(createEditor({...n,...e?{onError:t=>{e(t,i);}}:{}}),{[qt]:this});for(const t of this.sortedExtensionReps())t.build(i);return i}buildEditor(){let t=Xt;function e(){try{t();}finally{t=Xt;}}const n=Object.assign(this.constructEditor(),{dispose:e,[Symbol.dispose]:e});return t=mergeRegister(this.registerEditor(n),()=>n.setRootElement(null)),n}hasExtensionByName(t){return this.extensionNameMap.has(t)}getExtensionRep(t){const e=this.extensionNameMap.get(t.name);if(e)return e.extension!==t&&_t$1(295,t.name),e}addEdge(t,e,n){const i=this.outgoingConfigEdges.get(t);i?i.set(e,n):this.outgoingConfigEdges.set(t,new Map([[e,n]]));const o=this.incomingEdges.get(e);o?o.add(t):this.incomingEdges.set(e,new Set([t]));}addExtension(t){ void 0!==this._sortedExtensionReps&&_t$1(296);const e=te(t),[n]=e;"string"!=typeof n.name&&_t$1(297,typeof n.name);let i=this.extensionNameMap.get(n.name);if(void 0!==i&&i.extension!==n&&_t$1(298,n.name),!i){i=new Vt(this,n),this.extensionNameMap.set(n.name,i);const t=this.conflicts.get(n.name);"string"==typeof t&&_t$1(299,n.name,t);for(const t of n.conflictsWith||[])this.extensionNameMap.has(t)&&_t$1(299,n.name,t),this.conflicts.set(t,n.name);for(const t of n.dependencies||[]){const e=te(t);this.addEdge(n.name,e[0].name,e.slice(1)),this.addExtension(e);}for(const[t,e]of n.peerDependencies||[])this.addEdge(n.name,t,e?[e]:[]);}}sortedExtensionReps(){if(this._sortedExtensionReps)return this._sortedExtensionReps;const t=[],e=(n,i)=>{let o=n.state;if(Bt(o))return;const s=n.extension.name;var r;Tt$1(o)||_t$1(300,s,i||"[unknown]"),Tt$1(r=o)||_t$1(304,String(r.id),String(At$1)),o=Object.assign(r,{id:kt$1}),n.state=o;const c=this.outgoingConfigEdges.get(s);if(c)for(const t of c.keys()){const n=this.extensionNameMap.get(t);n&&e(n,s);}o=Wt(o),n.state=o,t.push(n);};for(const t of this.extensionNameMap.values())Tt$1(t.state)&&e(t);for(const e of t)for(const[t,n]of this.outgoingConfigEdges.get(e.extension.name)||[])if(n.length>0){const e=this.extensionNameMap.get(t);if(e)for(const t of n)e.configs.add(t);}for(const[t,...e]of this.roots)if(e.length>0){const n=this.extensionNameMap.get(t.name);void 0===n&&_t$1(301,t.name);for(const t of e)n.configs.add(t);}return this._sortedExtensionReps=t,this._sortedExtensionReps}registerEditor(t){const e=this.sortedExtensionReps(),n=new AbortController,i=[()=>n.abort()],o=n.signal;for(const n of e){const e=n.register(t,o);e&&i.push(e);}for(const n of e){const e=n.afterRegistration(t);e&&i.push(e);}return mergeRegister(...i)}buildCreateEditorArgs(){const t={},e=new Set,n=new Map,i=new Map,o={},s={},r=this.sortedExtensionReps();for(const c of r){const{extension:r}=c;if(void 0!==r.onError&&(t.onError=r.onError),void 0!==r.disableEvents&&(t.disableEvents=r.disableEvents),void 0!==r.parentEditor&&(t.parentEditor=r.parentEditor),void 0!==r.editable&&(t.editable=r.editable),void 0!==r.namespace&&(t.namespace=r.namespace),void 0!==r.$initialEditorState&&(t.$initialEditorState=r.$initialEditorState),r.nodes)for(const t of Et$1(r)){if("function"!=typeof t){const e=n.get(t.replace);e&&_t$1(302,r.name,t.replace.name,e.extension.name),n.set(t.replace,c);}e.add(t);}if(r.html){if(r.html.export)for(const[t,e]of r.html.export.entries())i.set(t,e);r.html.import&&Object.assign(o,r.html.import);}r.theme&&jt(s,r.theme);}Object.keys(s).length>0&&(t.theme=s),e.size&&(t.nodes=[...e]);const c=Object.keys(o).length>0,a=i.size>0;(c||a)&&(t.html={},c&&(t.html.import=o),a&&(t.html.export=i));for(const e of r)e.init(t);return t.onError||(t.onError=Yt),t}}const re=new Set,ce=defineExtension({build(t,e,n){const i=n.getDependency(It).output,o=ot({watchedNodeKeys:new Map}),r=Ft$1(()=>{},()=>gt(()=>{const t=r.peek(),{watchedNodeKeys:e}=o.value;let n,c=false;i.value.read(()=>{if($getSelection())for(const[i,o]of e.entries()){if(0===o.size){e.delete(i);continue}const s=$getNodeByKey(i),r=s&&s.isSelected()||false;c=c||r!==(!!t&&t.has(i)),r&&(n=n||new Set,n.add(i));}}),!c&&n&&t&&n.size===t.size||(r.value=n);}));return {watchNodeKey:function(t){const e=dt(()=>(r.value||re).has(t)),{watchedNodeKeys:n}=o.peek();let i=n.get(t);const s=void 0!==i;return i=i||new Set,i.add(e),s||(n.set(t,i),o.value={watchedNodeKeys:n}),e}}},dependencies:[It],name:"@lexical/extension/NodeSelection"});createCommand("INSERT_HORIZONTAL_RULE_COMMAND");class de extends DecoratorNode{static getType(){return "horizontalrule"}static clone(t){return new de(t.__key)}static importJSON(t){return fe().updateFromJSON(t)}static importDOM(){return {hr:()=>({conversion:ue,priority:0})}}exportDOM(){return {element:document.createElement("hr")}}createDOM(t){const e=document.createElement("hr");return addClassNamesToElement(e,t.theme.hr),e}getTextContent(){return "\n"}isInline(){return false}updateDOM(){return false}}function ue(){return {node:fe()}}function fe(){return $create(de)}function he(t){return t instanceof de}defineExtension({dependencies:[It,ce],name:"@lexical/extension/HorizontalRule",nodes:()=>[de],register(t,e,n){const{watchNodeKey:i}=n.getDependency(ce).output,o=ot({nodeSelections:new Map}),r=t._config.theme.hrSelected??"selected";return mergeRegister(t.registerCommand(CLICK_COMMAND,t=>{if(isDOMNode(t.target)){const e=$getNodeFromDOMNode(t.target);if(he(e))return function(t,e=false){const n=$getSelection(),i=t.isSelected(),o=t.getKey();let r;e&&$isNodeSelection(n)?r=n:(r=$createNodeSelection(),$setSelection(r)),i?r.delete(o):r.add(o);}(e,t.shiftKey),true}return false},COMMAND_PRIORITY_LOW),t.registerMutationListener(de,(e,n)=>{H(()=>{let n=!1;const{nodeSelections:s}=o.peek();for(const[o,r]of e.entries())if("destroyed"===r)s.delete(o),n=!0;else {const e=s.get(o),r=t.getElementByKey(o);e?e.domNode.value=r:(n=!0,s.set(o,{domNode:ot(r),selectedSignal:i(o)}));}n&&(o.value={nodeSelections:s});});}),gt(()=>{const t=[];for(const{domNode:e,selectedSignal:n}of o.value.nodeSelections.values())t.push(gt(()=>{const t=e.value;if(t){n.value?addClassNamesToElement(t,r):removeClassNamesFromElement(t,r);}}));return mergeRegister(...t)}))}});function ge(t){return t.canBeEmpty()}function pe(t,e,n=ge){return mergeRegister(t.registerCommand(KEY_TAB_COMMAND,e=>{const n=$getSelection();if(!$isRangeSelection(n))return false;e.preventDefault();const i=function(t){if(t.getNodes().filter(t=>$isBlockElementNode(t)&&t.canIndent()).length>0)return true;const e=t.anchor,n=t.focus,i=n.isBefore(e)?n:e,o=i.getNode(),s=yt$1(o);if(s.canIndent()){const t=s.getKey();let e=$createRangeSelection();if(e.anchor.set(t,0,"element"),e.focus.set(t,0,"element"),e=$normalizeSelection__EXPERIMENTAL(e),e.anchor.is(i))return true}return false}(n)?e.shiftKey?OUTDENT_CONTENT_COMMAND:INDENT_CONTENT_COMMAND:INSERT_TAB_COMMAND;return t.dispatchCommand(i,void 0)},COMMAND_PRIORITY_EDITOR),t.registerCommand(INDENT_CONTENT_COMMAND,()=>{const t="number"==typeof e?e:e?e.peek():null,i=$getSelection();if(!$isRangeSelection(i))return false;const o="function"==typeof n?n:n.peek();return bt$2(e=>{if(o(e)){const n=e.getIndent()+1;(!t||n<t)&&e.setIndent(n);}})},COMMAND_PRIORITY_CRITICAL))}defineExtension({build:(t,e,n)=>pt$1(e),config:safeCast({$canIndent:ge,disabled:false,maxIndent:null}),name:"@lexical/extension/TabIndentation",register(t,e,n){const{disabled:i,maxIndent:o,$canIndent:s}=n.getOutput();return gt(()=>{if(!i.value)return pe(t,o,s)})}});
298
-
299
- /**
300
- * Copyright (c) Meta Platforms, Inc. and affiliates.
301
- *
302
- * This source code is licensed under the MIT license found in the
303
- * LICENSE file in the root directory of this source tree.
304
- *
305
- */
306
-
307
- const r$1=defineExtension({name:"@lexical/react/ReactProvider"});
308
-
309
- /**
310
- * Copyright (c) Meta Platforms, Inc. and affiliates.
311
- *
312
- * This source code is licensed under the MIT license found in the
313
- * LICENSE file in the root directory of this source tree.
314
- *
315
- */
316
-
317
- function s$1(){return $getRoot().getTextContent()}function f$2(t,e=true){if(t)return false;let n=s$1();return e&&(n=n.trim()),""===n}function c$1(o){if(!f$2(o,false))return false;const l=$getRoot().getChildren(),s=l.length;if(s>1)return false;for(let t=0;t<s;t++){const o=l[t];if($isDecoratorNode(o))return false;if($isElementNode(o)){if(!$isParagraphNode(o))return false;if(0!==o.__indent)return false;const e=o.getChildren(),n=e.length;for(let r=0;r<n;r++){const n=e[t];if(!$isTextNode(n))return false}}}return true}function g$2(t){return ()=>c$1(t)}
318
-
319
- /**
320
- * Copyright (c) Meta Platforms, Inc. and affiliates.
321
- *
322
- * This source code is licensed under the MIT license found in the
323
- * LICENSE file in the root directory of this source tree.
324
- *
325
- */
326
-
327
- function s(e){const t=window.location.origin,n=n=>{if(n.origin!==t)return;const o=e.getRootElement();if(document.activeElement!==o)return;const s=n.data;if("string"==typeof s){let t;try{t=JSON.parse(s);}catch(e){return}if(t&&"nuanria_messaging"===t.protocol&&"request"===t.type){const o=t.payload;if(o&&"makeChanges"===o.functionId){const t=o.args;if(t){const[o,s,d,c,g]=t;e.update(()=>{const e=$getSelection();if($isRangeSelection(e)){const t=e.anchor;let i=t.getNode(),a=0,l=0;if($isTextNode(i)&&o>=0&&s>=0&&(a=o,l=o+s,e.setTextNodeRange(i,a,i,l)),a===l&&""===d||(e.insertRawText(d),i=t.getNode()),$isTextNode(i)){a=c,l=c+g;const t=i.getTextContentSize();a=a>t?t:a,l=l>t?t:l,e.setTextNodeRange(i,a,i,l);}n.stopImmediatePropagation();}});}}}}};return window.addEventListener("message",n,true),()=>{window.removeEventListener("message",n,true);}}const d$1=defineExtension({build:(e,n,o)=>pt$1(n),config:safeCast({disabled:"undefined"==typeof window}),name:"@lexical/dragon",register:(t,n,o)=>gt(()=>o.getOutput().disabled.value?void 0:s(t))});
328
-
329
- /**
330
- * Copyright (c) Meta Platforms, Inc. and affiliates.
331
- *
332
- * This source code is licensed under the MIT license found in the
333
- * LICENSE file in the root directory of this source tree.
334
- *
335
- */
336
-
337
- function m$2(e,n){const t=isDOMDocumentNode(n)?n.body.childNodes:n.childNodes;let l=[];const r=[];for(const n of t)if(!w$1.has(n.nodeName)){const t=y$1(n,e,r,false);null!==t&&(l=l.concat(t));}return function(e){for(const n of e)n.getNextSibling()instanceof ArtificialNode__DO_NOT_USE&&n.insertAfter($createLineBreakNode());for(const n of e){const e=n.getChildren();for(const t of e)n.insertBefore(t);n.remove();}}(r),l}function g$1(e,n){if("undefined"==typeof document||"undefined"==typeof window&&void 0===global.window)throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");const t=document.createElement("div"),o=$getRoot().getChildren();for(let l=0;l<o.length;l++){x$2(e,o[l],t,n);}return t.innerHTML}function x$2(t,o,l,u=null){let f=null===u||o.isSelected(u);const a=$isElementNode(o)&&o.excludeFromCopy("html");let d=o;null!==u&&$isTextNode(o)&&(d=M$1(u,o,"clone"));const p=$isElementNode(d)?d.getChildren():[],h=getRegisteredNode(t,d.getType());let m;m=h&&void 0!==h.exportDOM?h.exportDOM(t,d):d.exportDOM(t);const{element:g,after:w}=m;if(!g)return false;const y=document.createDocumentFragment();for(let e=0;e<p.length;e++){const n=p[e],l=x$2(t,n,y,u);!f&&$isElementNode(o)&&l&&o.extractWithChild(n,u,"html")&&(f=true);}if(f&&!a){if((isHTMLElement(g)||isDocumentFragment(g))&&g.append(y),l.append(g),w){const e=w.call(d,g);e&&(isDocumentFragment(g)?g.replaceChildren(e):g.replaceWith(e));}}else l.append(y);return f}const w$1=new Set(["STYLE","SCRIPT"]);function y$1(e,n,o,l,i=new Map,s){let c=[];if(w$1.has(e.nodeName))return c;let m=null;const g=function(e,n){const{nodeName:t}=e,o=n._htmlConversions.get(t.toLowerCase());let l=null;if(void 0!==o)for(const n of o){const t=n(e);null!==t&&(null===l||(l.priority||0)<=(t.priority||0))&&(l=t);}return null!==l?l.conversion:null}(e,n),x=g?g(e):null;let b=null;if(null!==x){b=x.after;const n=x.node;if(m=Array.isArray(n)?n[n.length-1]:n,null!==m){for(const[,e]of i)if(m=e(m,s),!m)break;m&&c.push(...Array.isArray(n)?n:[m]);}null!=x.forChild&&i.set(e.nodeName,x.forChild);}const S=e.childNodes;let v=[];const N=(null==m||!$isRootOrShadowRoot(m))&&(null!=m&&$isBlockElementNode(m)||l);for(let e=0;e<S.length;e++)v.push(...y$1(S[e],n,o,N,new Map(i),m));return null!=b&&(v=b(v)),isBlockDomNode(e)&&(v=C$1(e,v,N?()=>{const e=new ArtificialNode__DO_NOT_USE;return o.push(e),e}:$createParagraphNode)),null==m?v.length>0?c=c.concat(v):isBlockDomNode(e)&&function(e){if(null==e.nextSibling||null==e.previousSibling)return false;return isInlineDomNode(e.nextSibling)&&isInlineDomNode(e.previousSibling)}(e)&&(c=c.concat($createLineBreakNode())):$isElementNode(m)&&m.append(...v),c}function C$1(e,n,t){const o=e.style.textAlign,l=[];let r=[];for(let e=0;e<n.length;e++){const i=n[e];if($isBlockElementNode(i))o&&!i.getFormat()&&i.setFormat(o),l.push(i);else if(r.push(i),e===n.length-1||e<n.length-1&&$isBlockElementNode(n[e+1])){const e=t();e.setFormat(o),e.append(...r),l.push(e),r=[];}}return l}
338
-
339
- /**
340
- * Copyright (c) Meta Platforms, Inc. and affiliates.
341
- *
342
- * This source code is licensed under the MIT license found in the
343
- * LICENSE file in the root directory of this source tree.
344
- *
345
- */
346
-
347
- function v$2(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);throw n.search=o.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function D(e,n=$getSelection()){return null==n&&v$2(166),$isRangeSelection(n)&&n.isCollapsed()||0===n.getNodes().length?"":g$1(e,n)}function S(t,e=$getSelection()){return null==e&&v$2(166),$isRangeSelection(e)&&e.isCollapsed()||0===e.getNodes().length?null:JSON.stringify(E$1(t,e))}function R(t,n,o){const r=t.getData("application/x-lexical-editor");if(r)try{const t=JSON.parse(r);if(t.namespace===o._config.namespace&&Array.isArray(t.nodes)){return A(o,L$1(t.nodes),n)}}catch(t){console.error(t);}const c=t.getData("text/html"),a=t.getData("text/plain");if(c&&a!==c)try{const t=(new DOMParser).parseFromString(function(t){if(window.trustedTypes&&window.trustedTypes.createPolicy){return window.trustedTypes.createPolicy("lexical",{createHTML:t=>t}).createHTML(t)}return t}(c),"text/html");return A(o,m$2(o,t),n)}catch(t){console.error(t);}const u=a||t.getData("text/uri-list");if(null!=u)if($isRangeSelection(n)){const t=u.split(/(\r?\n|\t)/);""===t[t.length-1]&&t.pop();for(let e=0;e<t.length;e++){const n=$getSelection();if($isRangeSelection(n)){const o=t[e];"\n"===o||"\r\n"===o?n.insertParagraph():"\t"===o?n.insertNodes([$createTabNode()]):n.insertText(o);}}}else n.insertRawText(u);}function A(t,e,n){t.dispatchCommand(SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,{nodes:e,selection:n})||(n.insertNodes(e),function(t){if($isRangeSelection(t)&&t.isCollapsed()){const e=t.anchor;let n=null;const o=$caretFromPoint(e,"previous");if(o)if($isTextPointCaret(o))n=o.origin;else {const t=$getCaretRange(o,$getChildCaret($getRoot(),"next").getFlipped());for(const e of t){if($isTextNode(e.origin)){n=e.origin;break}if($isElementNode(e.origin)&&!e.origin.isInline())break}}if(n&&$isTextNode(n)){const e=n.getFormat(),o=n.getStyle();t.format===e&&t.style===o||(t.format=e,t.style=o,t.dirty=true);}}}(n));}function P(t,e,n,r=[]){let i=null===e||n.isSelected(e);const l=$isElementNode(n)&&n.excludeFromCopy("html");let s=n;null!==e&&$isTextNode(s)&&(s=M$1(e,s,"clone"));const c=$isElementNode(s)?s.getChildren():[],a=function(t){const e=t.exportJSON(),n=t.constructor;if(e.type!==n.getType()&&v$2(58,n.name),$isElementNode(t)){const t=e.children;Array.isArray(t)||v$2(59,n.name);}return e}(s);$isTextNode(s)&&0===s.getTextContentSize()&&(i=false);for(let o=0;o<c.length;o++){const r=c[o],l=P(t,e,r,a.children);!i&&$isElementNode(n)&&l&&n.extractWithChild(r,e,"clone")&&(i=true);}if(i&&!l)r.push(a);else if(Array.isArray(a.children))for(let t=0;t<a.children.length;t++){const e=a.children[t];r.push(e);}return i}function E$1(t,e){const n=[],o=$getRoot().getChildren();for(let r=0;r<o.length;r++){P(t,e,o[r],n);}return {namespace:t._config.namespace,nodes:n}}function L$1(t){const e=[];for(let o=0;o<t.length;o++){const r=t[o],i=$parseSerializedNode(r);$isTextNode(i)&&$(i),e.push(i);}return e}let b$2=null;async function F(t,e,n){if(null!==b$2)return false;if(null!==e)return new Promise((o,r)=>{t.update(()=>{o(M(t,e,n));});});const o=t.getRootElement(),i=t._window||window,l=i.document,s=getDOMSelection(i);if(null===o||null===s)return false;const c=l.createElement("span");c.style.cssText="position: fixed; top: -1000px;",c.append(l.createTextNode("#")),o.append(c);const a=new Range;return a.setStart(c,0),a.setEnd(c,1),s.removeAllRanges(),s.addRange(a),new Promise((e,o)=>{const s=t.registerCommand(COPY_COMMAND,o=>(At$2(o,ClipboardEvent)&&(s(),null!==b$2&&(i.clearTimeout(b$2),b$2=null),e(M(t,o,n))),true),COMMAND_PRIORITY_CRITICAL);b$2=i.setTimeout(()=>{s(),b$2=null,e(false);},50),l.execCommand("copy"),c.remove();})}function M(t,e,n){if(void 0===n){const e=getDOMSelection(t._window),o=$getSelection();if(!o||o.isCollapsed())return false;if(!e)return false;const r=e.anchorNode,l=e.focusNode;if(null!==r&&null!==l&&!isSelectionWithinEditor(t,r,l))return false;n=_(o);}e.preventDefault();const o=e.clipboardData;return null!==o&&(J(o,n),true)}const O=[["text/html",D],["application/x-lexical-editor",S]];function _(t=$getSelection()){const e={"text/plain":t?t.getTextContent():""};if(t){const n=$getEditor();for(const[o,r]of O){const i=r(n,t);null!==i&&(e[o]=i);}}return e}function J(t,e){for(const[n]of O) void 0===e[n]&&t.setData(n,"");for(const n in e){const o=e[n];void 0!==o&&t.setData(n,o);}}
348
-
349
- /**
350
- * Copyright (c) Meta Platforms, Inc. and affiliates.
351
- *
352
- * This source code is licensed under the MIT license found in the
353
- * LICENSE file in the root directory of this source tree.
354
- *
355
- */
356
-
357
- function pt(t,e){if(void 0!==document.caretRangeFromPoint){const n=document.caretRangeFromPoint(t,e);return null===n?null:{node:n.startContainer,offset:n.startOffset}}if("undefined"!==document.caretPositionFromPoint){const n=document.caretPositionFromPoint(t,e);return null===n?null:{node:n.offsetNode,offset:n.offset}}return null}const ht="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,vt=ht&&"documentMode"in document?document.documentMode:null,Ct=ht&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),yt=!(!ht||!("InputEvent"in window)||vt)&&"getTargetRanges"in new window.InputEvent("input"),xt=ht&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Dt=ht&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Nt=ht&&/^(?=.*Chrome).*/i.test(navigator.userAgent),wt=ht&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&Ct&&!Nt,Et=createCommand("DRAG_DROP_PASTE_FILE");class _t extends ElementNode{static getType(){return "quote"}static clone(t){return new _t(t.__key)}createDOM(t){const e=document.createElement("blockquote");return addClassNamesToElement(e,t.theme.quote),e}updateDOM(t,e){return false}static importDOM(){return {blockquote:t=>({conversion:St,priority:0})}}exportDOM(t){const{element:e}=super.exportDOM(t);if(isHTMLElement(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();t&&(e.style.textAlign=t);const n=this.getDirection();n&&(e.dir=n);}return {element:e}}static importJSON(t){return Ot().updateFromJSON(t)}insertNewAfter(t,e){const n=$createParagraphNode(),r=this.getDirection();return n.setDirection(r),this.insertAfter(n,e),n}collapseAtStart(){const t=$createParagraphNode();return this.getChildren().forEach(e=>t.append(e)),this.replace(t),true}canMergeWhenEmpty(){return true}}function Ot(){return $applyNodeReplacement(new _t)}class Tt extends ElementNode{__tag;static getType(){return "heading"}static clone(t){return new Tt(t.__tag,t.__key)}constructor(t,e){super(e),this.__tag=t;}getTag(){return this.__tag}setTag(t){const e=this.getWritable();return this.__tag=t,e}createDOM(t){const e=this.__tag,n=document.createElement(e),r=t.theme.heading;if(void 0!==r){const t=r[e];addClassNamesToElement(n,t);}return n}updateDOM(t,e,n){return t.__tag!==this.__tag}static importDOM(){return {h1:t=>({conversion:At,priority:0}),h2:t=>({conversion:At,priority:0}),h3:t=>({conversion:At,priority:0}),h4:t=>({conversion:At,priority:0}),h5:t=>({conversion:At,priority:0}),h6:t=>({conversion:At,priority:0}),p:t=>{const e=t.firstChild;return null!==e&&Ft(e)?{conversion:()=>({node:null}),priority:3}:null},span:t=>Ft(t)?{conversion:t=>({node:Mt("h1")}),priority:3}:null}}exportDOM(t){const{element:e}=super.exportDOM(t);if(isHTMLElement(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();t&&(e.style.textAlign=t);const n=this.getDirection();n&&(e.dir=n);}return {element:e}}static importJSON(t){return Mt(t.tag).updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setTag(t.tag)}exportJSON(){return {...super.exportJSON(),tag:this.getTag()}}insertNewAfter(t,e=true){const n=t?t.anchor.offset:0,r=this.getLastDescendant(),o=!r||t&&t.anchor.key===r.getKey()&&n===r.getTextContentSize()||!t?$createParagraphNode():Mt(this.getTag()),i=this.getDirection();if(o.setDirection(i),this.insertAfter(o,e),0===n&&!this.isEmpty()&&t){const t=$createParagraphNode();t.select(),this.replace(t,true);}return o}collapseAtStart(){const t=this.isEmpty()?$createParagraphNode():Mt(this.getTag());return this.getChildren().forEach(e=>t.append(e)),this.replace(t),true}extractWithChild(){return true}}function Ft(t){return "span"===t.nodeName.toLowerCase()&&"26pt"===t.style.fontSize}function At(t){const e=t.nodeName.toLowerCase();let n=null;return "h1"!==e&&"h2"!==e&&"h3"!==e&&"h4"!==e&&"h5"!==e&&"h6"!==e||(n=Mt(e),null!==t.style&&(setNodeIndentFromDOM(t,n),n.setFormat(t.style.textAlign))),{node:n}}function St(t){const e=Ot();return null!==t.style&&(e.setFormat(t.style.textAlign),setNodeIndentFromDOM(t,e)),{node:e}}function Mt(t="h1"){return $applyNodeReplacement(new Tt(t))}function bt(t){let e=null;if(At$2(t,DragEvent)?e=t.dataTransfer:At$2(t,ClipboardEvent)&&(e=t.clipboardData),null===e)return [false,[],false];const n=e.types,r=n.includes("Files"),o=n.includes("text/html")||n.includes("text/plain");return [r,Array.from(e.files),o]}function Kt(t){const e=$getNearestNodeFromDOMNode(t);return $isDecoratorNode(e)}function kt(t){for(const e of ["lowercase","uppercase","capitalize"])t.hasFormat(e)&&t.toggleFormat(e);}function Jt(n){return mergeRegister(n.registerCommand(CLICK_COMMAND,t=>{const e=$getSelection();return !!$isNodeSelection(e)&&(e.clear(),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(DELETE_CHARACTER_COMMAND,t=>{const e=$getSelection();return $isRangeSelection(e)?(e.deleteCharacter(t),true):!!$isNodeSelection(e)&&(e.deleteNodes(),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(DELETE_WORD_COMMAND,t=>{const e=$getSelection();return !!$isRangeSelection(e)&&(e.deleteWord(t),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(DELETE_LINE_COMMAND,t=>{const e=$getSelection();return !!$isRangeSelection(e)&&(e.deleteLine(t),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(CONTROLLED_TEXT_INSERTION_COMMAND,e=>{const r=$getSelection();if("string"==typeof e)null!==r&&r.insertText(e);else {if(null===r)return false;const o=e.dataTransfer;if(null!=o)R(o,r,n);else if($isRangeSelection(r)){const t=e.data;return t&&r.insertText(t),true}}return true},COMMAND_PRIORITY_EDITOR),n.registerCommand(REMOVE_TEXT_COMMAND,()=>{const t=$getSelection();return !!$isRangeSelection(t)&&(t.removeText(),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(FORMAT_TEXT_COMMAND,t=>{const e=$getSelection();return !!$isRangeSelection(e)&&(e.formatText(t),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(FORMAT_ELEMENT_COMMAND,t=>{const e=$getSelection();if(!$isRangeSelection(e)&&!$isNodeSelection(e))return false;const n=e.getNodes();for(const e of n){const n=$findMatchingParent(e,t=>$isElementNode(t)&&!t.isInline());null!==n&&n.setFormat(t);}return true},COMMAND_PRIORITY_EDITOR),n.registerCommand(INSERT_LINE_BREAK_COMMAND,t=>{const e=$getSelection();return !!$isRangeSelection(e)&&(e.insertLineBreak(t),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(INSERT_PARAGRAPH_COMMAND,()=>{const t=$getSelection();return !!$isRangeSelection(t)&&(t.insertParagraph(),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(INSERT_TAB_COMMAND,()=>{const t=$createTabNode(),e=$getSelection();return $isRangeSelection(e)&&(t.setFormat(e.format),t.setStyle(e.style)),$insertNodes([t]),true},COMMAND_PRIORITY_EDITOR),n.registerCommand(INDENT_CONTENT_COMMAND,()=>bt$2(t=>{const e=t.getIndent();t.setIndent(e+1);}),COMMAND_PRIORITY_EDITOR),n.registerCommand(OUTDENT_CONTENT_COMMAND,()=>bt$2(t=>{const e=t.getIndent();e>0&&t.setIndent(Math.max(0,e-1));}),COMMAND_PRIORITY_EDITOR),n.registerCommand(KEY_ARROW_UP_COMMAND,t=>{const e=$getSelection();if($isNodeSelection(e)){const n=e.getNodes();if(n.length>0)return t.preventDefault(),n[0].selectPrevious(),true}else if($isRangeSelection(e)){const n=$getAdjacentNode(e.focus,true);if(!t.shiftKey&&$isDecoratorNode(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),t.preventDefault(),true}return false},COMMAND_PRIORITY_EDITOR),n.registerCommand(KEY_ARROW_DOWN_COMMAND,t=>{const e=$getSelection();if($isNodeSelection(e)){const n=e.getNodes();if(n.length>0)return t.preventDefault(),n[0].selectNext(0,0),true}else if($isRangeSelection(e)){if(function(t){const e=t.focus;return "root"===e.key&&e.offset===$getRoot().getChildrenSize()}(e))return t.preventDefault(),true;const n=$getAdjacentNode(e.focus,false);if(!t.shiftKey&&$isDecoratorNode(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),t.preventDefault(),true}return false},COMMAND_PRIORITY_EDITOR),n.registerCommand(KEY_ARROW_LEFT_COMMAND,t=>{const e=$getSelection();if($isNodeSelection(e)){const n=e.getNodes();if(n.length>0)return t.preventDefault(),A$1(n[0])?n[0].selectNext(0,0):n[0].selectPrevious(),true}if(!$isRangeSelection(e))return false;if(Z$1(e,true)){const n=t.shiftKey;return t.preventDefault(),ne$1(e,n,true),true}return false},COMMAND_PRIORITY_EDITOR),n.registerCommand(KEY_ARROW_RIGHT_COMMAND,t=>{const e=$getSelection();if($isNodeSelection(e)){const n=e.getNodes();if(n.length>0)return t.preventDefault(),A$1(n[0])?n[0].selectPrevious():n[0].selectNext(0,0),true}if(!$isRangeSelection(e))return false;const n=t.shiftKey;return !!Z$1(e,false)&&(t.preventDefault(),ne$1(e,n,false),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(KEY_BACKSPACE_COMMAND,t=>{if(Kt(t.target))return false;const e=$getSelection();if($isRangeSelection(e)){if(function(t){if(!t.isCollapsed())return false;const{anchor:e}=t;if(0!==e.offset)return false;const n=e.getNode();if($isRootNode(n))return false;const r=yt$1(n);return r.getIndent()>0&&(r.is(n)||n.is(r.getFirstDescendant()))}(e))return t.preventDefault(),n.dispatchCommand(OUTDENT_CONTENT_COMMAND,void 0);if(Dt&&"ko-KR"===navigator.language)return false}else if(!$isNodeSelection(e))return false;return t.preventDefault(),n.dispatchCommand(DELETE_CHARACTER_COMMAND,true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(KEY_DELETE_COMMAND,t=>{if(Kt(t.target))return false;const e=$getSelection();return !(!$isRangeSelection(e)&&!$isNodeSelection(e))&&(t.preventDefault(),n.dispatchCommand(DELETE_CHARACTER_COMMAND,false))},COMMAND_PRIORITY_EDITOR),n.registerCommand(KEY_ENTER_COMMAND,t=>{const e=$getSelection();if(!$isRangeSelection(e))return false;if(kt(e),null!==t){if((Dt||xt||wt)&&yt)return false;if(t.preventDefault(),t.shiftKey)return n.dispatchCommand(INSERT_LINE_BREAK_COMMAND,false)}return n.dispatchCommand(INSERT_PARAGRAPH_COMMAND,void 0)},COMMAND_PRIORITY_EDITOR),n.registerCommand(KEY_ESCAPE_COMMAND,()=>{const t=$getSelection();return !!$isRangeSelection(t)&&(n.blur(),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(DROP_COMMAND,t=>{const[,e]=bt(t);if(e.length>0){const r=pt(t.clientX,t.clientY);if(null!==r){const{offset:t,node:o}=r,i=$getNearestNodeFromDOMNode(o);if(null!==i){const e=$createRangeSelection();if($isTextNode(i))e.anchor.set(i.getKey(),t,"text"),e.focus.set(i.getKey(),t,"text");else {const t=i.getParentOrThrow().getKey(),n=i.getIndexWithinParent()+1;e.anchor.set(t,n,"element"),e.focus.set(t,n,"element");}const n=$normalizeSelection__EXPERIMENTAL(e);$setSelection(n);}n.dispatchCommand(Et,e);}return t.preventDefault(),true}const r=$getSelection();return !!$isRangeSelection(r)},COMMAND_PRIORITY_EDITOR),n.registerCommand(DRAGSTART_COMMAND,t=>{const[e]=bt(t),n=$getSelection();return !(e&&!$isRangeSelection(n))},COMMAND_PRIORITY_EDITOR),n.registerCommand(DRAGOVER_COMMAND,t=>{const[e]=bt(t),n=$getSelection();if(e&&!$isRangeSelection(n))return false;const r=pt(t.clientX,t.clientY);if(null!==r){const e=$getNearestNodeFromDOMNode(r.node);$isDecoratorNode(e)&&t.preventDefault();}return true},COMMAND_PRIORITY_EDITOR),n.registerCommand(SELECT_ALL_COMMAND,()=>($selectAll(),true),COMMAND_PRIORITY_EDITOR),n.registerCommand(COPY_COMMAND,t=>(F(n,At$2(t,ClipboardEvent)?t:null),true),COMMAND_PRIORITY_EDITOR),n.registerCommand(CUT_COMMAND,t=>(async function(t,n){await F(n,At$2(t,ClipboardEvent)?t:null),n.update(()=>{const t=$getSelection();$isRangeSelection(t)?t.removeText():$isNodeSelection(t)&&t.getNodes().forEach(t=>t.remove());});}(t,n),true),COMMAND_PRIORITY_EDITOR),n.registerCommand(PASTE_COMMAND,e=>{const[,r,o]=bt(e);if(r.length>0&&!o)return n.dispatchCommand(Et,r),true;if(isDOMNode(e.target)&&isSelectionCapturedInDecoratorInput(e.target))return false;return null!==$getSelection()&&(function(e,n){e.preventDefault(),n.update(()=>{const r=$getSelection(),o=At$2(e,InputEvent)||At$2(e,KeyboardEvent)?null:e.clipboardData;null!=o&&null!==r&&R(o,r,n);},{tag:PASTE_TAG});}(e,n),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(KEY_SPACE_COMMAND,t=>{const e=$getSelection();return $isRangeSelection(e)&&kt(e),false},COMMAND_PRIORITY_EDITOR),n.registerCommand(KEY_TAB_COMMAND,t=>{const e=$getSelection();return $isRangeSelection(e)&&kt(e),false},COMMAND_PRIORITY_EDITOR))}defineExtension({conflictsWith:["@lexical/plain-text"],dependencies:[d$1],name:"@lexical/rich-text",nodes:()=>[Tt,_t],register:Jt});
358
-
359
- /**
360
- * Copyright (c) Meta Platforms, Inc. and affiliates.
361
- *
362
- * This source code is licensed under the MIT license found in the
363
- * LICENSE file in the root directory of this source tree.
364
- *
365
- */
366
-
367
- function g(r,...e){const t=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",r);for(const r of e)o.append("v",r);throw t.search=o.toString(),Error(`Minified Lexical error #${r}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const y="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?useLayoutEffect:useEffect;function w({editor:r,ErrorBoundary:e}){return function(r,e){const[t,o]=useState(()=>r.getDecorators());return y(()=>r.registerDecoratorListener(r=>{flushSync(()=>{o(r);});}),[r]),useEffect(()=>{o(r.getDecorators());},[r]),useMemo(()=>{const o=[],n=Object.keys(t);for(let i=0;i<n.length;i++){const c=n[i],a=jsx(e,{onError:e=>r._onError(e),children:jsx(Suspense,{fallback:null,children:t[c]})}),s=r.getElementByKey(c);null!==s&&o.push(createPortal(a,s,c));}return o},[e,t,r])}(r,e)}function v$1({editor:r,ErrorBoundary:e}){return function(r){const e=ne.maybeFromEditor(r);if(e&&e.hasExtensionByName(r$1.name)){for(const r of ["@lexical/plain-text","@lexical/rich-text"])e.hasExtensionByName(r)&&g(320,r);return true}return false}(r)?null:jsx(w,{editor:r,ErrorBoundary:e})}function B(r){return r.getEditorState().read(g$2(r.isComposing()))}function L({contentEditable:e,placeholder:t=null,ErrorBoundary:o$1}){const[n]=o();return function(r){y(()=>mergeRegister(Jt(r),s(r)),[r]);}(n),jsxs(Fragment,{children:[e,jsx(b$1,{content:t}),jsx(v$1,{editor:n,ErrorBoundary:o$1})]})}function b$1({content:t}){const[o$1]=o(),n=function(r){const[e,t]=useState(()=>B(r));return y(()=>{function e(){const e=B(r);t(e);}return e(),mergeRegister(r.registerUpdateListener(()=>{e();}),r.registerEditableListener(()=>{e();}))},[r]),e}(o$1),i=a$2();return n?"function"==typeof t?t(i):t:null}
368
-
369
- /**
370
- * Copyright (c) Meta Platforms, Inc. and affiliates.
371
- *
372
- * This source code is licensed under the MIT license found in the
373
- * LICENSE file in the root directory of this source tree.
374
- *
375
- */
376
-
377
- const m$1="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?useLayoutEffect:useEffect;function f$1({editor:e,ariaActiveDescendant:t,ariaAutoComplete:i,ariaControls:a,ariaDescribedBy:d,ariaErrorMessage:c,ariaExpanded:s,ariaInvalid:u,ariaLabel:f,ariaLabelledBy:b,ariaMultiline:p,ariaOwns:x,ariaRequired:E,autoCapitalize:v,className:w,id:y,role:C="textbox",spellCheck:g=true,style:L,tabIndex:h,"data-testid":D,...I},R){const[k,q]=useState(e.isEditable()),z=useCallback(t=>{t&&t.ownerDocument&&t.ownerDocument.defaultView?e.setRootElement(t):e.setRootElement(null);},[e]),A=useMemo(()=>function(...e){return t=>{for(const i of e)"function"==typeof i?i(t):null!=i&&(i.current=t);}}(R,z),[z,R]);return m$1(()=>(q(e.isEditable()),e.registerEditableListener(e=>{q(e);})),[e]),jsx("div",{"aria-activedescendant":k?t:void 0,"aria-autocomplete":k?i:"none","aria-controls":k?a:void 0,"aria-describedby":d,...null!=c?{"aria-errormessage":c}:{},"aria-expanded":k&&"combobox"===C?!!s:void 0,...null!=u?{"aria-invalid":u}:{},"aria-label":f,"aria-labelledby":b,"aria-multiline":p,"aria-owns":k?x:void 0,"aria-readonly":!k||void 0,"aria-required":E,autoCapitalize:v,className:w,contentEditable:k,"data-testid":D,id:y,ref:A,role:C,spellCheck:g,style:L,tabIndex:h,...I})}const b=forwardRef(f$1);function p$1(e){return e.getEditorState().read(g$2(e.isComposing()))}const x$1=forwardRef(E);function E(t,i){const{placeholder:a,...r}=t,[n]=o();return jsxs(Fragment,{children:[jsx(b,{editor:n,...r,ref:i}),null!=a&&jsx(v,{editor:n,content:a})]})}function v({content:e,editor:i}){const a=function(e){const[t,i]=useState(()=>p$1(e));return m$1(()=>{function t(){const t=p$1(e);i(t);}return t(),mergeRegister(e.registerUpdateListener(()=>{t();}),e.registerEditableListener(()=>{t();}))},[e]),t}(i),[n,o]=useState(i.isEditable());if(useLayoutEffect(()=>(o(i.isEditable()),i.registerEditableListener(e=>{o(e);})),[i]),!a)return null;let d=null;return "function"==typeof e?d=e(n):null!==e&&(d=e),null===d?null:jsx("div",{"aria-hidden":true,children:d})}
378
-
379
- /**
380
- * Copyright (c) Meta Platforms, Inc. and affiliates.
381
- *
382
- * This source code is licensed under the MIT license found in the
383
- * LICENSE file in the root directory of this source tree.
384
- *
385
- */
386
-
387
- function a$1({delay:a,externalHistoryState:c}){const[l]=o();return function(t,a,c=1e3){const l=useMemo(()=>a||createEmptyHistoryState(),[a]);useEffect(()=>registerHistory(t,l,c),[c,t,l]);}(l,c,a),null}
388
-
389
- /**
390
- * Copyright (c) Meta Platforms, Inc. and affiliates.
391
- *
392
- * This source code is licensed under the MIT license found in the
393
- * LICENSE file in the root directory of this source tree.
394
- *
395
- */
396
-
397
- function l$1({hasStrictIndent:l=false,shouldPreserveNumbering:m=false}){const[c]=o();return useEffect(()=>{if(!c.hasNodes([ListNode,ListItemNode]))throw new Error("ListPlugin: ListNode and/or ListItemNode not registered on editor")},[c]),useEffect(()=>mergeRegister(registerList(c,{restoreNumbering:m}),l?registerListStrictIndentTransform(c):()=>{}),[c,l,m]),function(e){useEffect(()=>registerList(e),[e]);}(c),null}
398
-
399
- /**
400
- * Copyright (c) Meta Platforms, Inc. and affiliates.
401
- *
402
- * This source code is licensed under the MIT license found in the
403
- * LICENSE file in the root directory of this source tree.
404
- *
405
- */
406
-
407
- function l({validateUrl:l,attributes:n}){const[a]=o();return useEffect(()=>{if(!a.hasNodes([LinkNode]))throw new Error("LinkPlugin: LinkNode not registered on editor")}),useEffect(()=>registerLink(a,pt$1({attributes:n,validateUrl:l})),[a,l,n]),null}
408
-
409
- /**
410
- * Copyright (c) Meta Platforms, Inc. and affiliates.
411
- *
412
- * This source code is licensed under the MIT license found in the
413
- * LICENSE file in the root directory of this source tree.
414
- *
415
- */
416
-
417
- const r="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?useLayoutEffect:useEffect;function n$1({ignoreHistoryMergeTagChange:o$1=true,ignoreSelectionChange:i=false,onChange:n}){const[a]=o();return r(()=>{if(n)return a.registerUpdateListener(({editorState:e,dirtyElements:r,dirtyLeaves:d,prevEditorState:s,tags:c})=>{i&&0===r.size&&0===d.size||o$1&&c.has(HISTORY_MERGE_TAG)||s.isEmpty()||n(e,a,c);})},[a,o$1,i,n]),null}
418
-
419
- /**
420
- * Copyright (c) Meta Platforms, Inc. and affiliates.
421
- *
422
- * This source code is licensed under the MIT license found in the
423
- * LICENSE file in the root directory of this source tree.
424
- *
425
- */
426
-
427
- function d(e,t){return e.getEditorState().read(()=>{const e=$getNodeByKey(t);return null!==e&&e.isSelected()})}function u$1(c){const[u]=o(),[p,s]=useState(()=>d(u,c));useEffect(()=>{let e=true;const t=u.registerUpdateListener(()=>{e&&s(d(u,c));});return ()=>{e=false,t();}},[u,c]);return [p,useCallback(e=>{u.update(()=>{let a=$getSelection();$isNodeSelection(a)||(a=$createNodeSelection(),$setSelection(a)),$isNodeSelection(a)&&(e?a.add(c):a.delete(c));});},[u,c]),useCallback(()=>{u.update(()=>{const e=$getSelection();$isNodeSelection(e)&&e.clear();});},[u])]}
428
-
429
- /**
430
- * Copyright (c) Meta Platforms, Inc. and affiliates.
431
- *
432
- * This source code is licensed under the MIT license found in the
433
- * LICENSE file in the root directory of this source tree.
434
- *
435
- */
436
-
437
- function u({nodeKey:e}){const[l]=o(),[s,u,p]=u$1(e);return useEffect(()=>mergeRegister(l.registerCommand(CLICK_COMMAND,t=>{const r=l.getElementByKey(e);return t.target===r&&(t.shiftKey||p(),u(!s),true)},COMMAND_PRIORITY_LOW)),[p,l,s,e,u]),useEffect(()=>{const t=l.getElementByKey(e),r=l._config.theme.hrSelected??"selected";null!==t&&(s?addClassNamesToElement(t,r):removeClassNamesFromElement(t,r));},[l,s,e]),null}class p extends de{static getType(){return "horizontalrule"}static clone(e){return new p(e.__key)}static importJSON(e){return f().updateFromJSON(e)}static importDOM(){return {hr:()=>({conversion:x,priority:0})}}decorate(){return jsx(u,{nodeKey:this.__key})}}function x(){return {node:f()}}function f(){return $applyNodeReplacement(new p)}
438
-
439
- /**
440
- * Copyright (c) Meta Platforms, Inc. and affiliates.
441
- *
442
- * This source code is licensed under the MIT license found in the
443
- * LICENSE file in the root directory of this source tree.
444
- *
445
- */
446
-
447
- const i=[{dependencies:[p],export:e=>he(e)?"***":null,regExp:/^(---|\*\*\*|___)\s?$/,replace:(e,r,t,o)=>{const n=f();o||null!=e.getNextSibling()?e.replace(n):e.insertBefore(n),n.selectNext();},type:"element"},...TRANSFORMERS];function a({transformers:e=i}){const[o$1]=o();return useEffect(()=>registerMarkdownShortcuts(o$1,e),[o$1,e]),null}
448
-
449
- const h = createContext(null), c = {
450
- didCatch: false,
451
- error: null
452
- };
453
- class m extends Component {
454
- constructor(e) {
455
- super(e), this.resetErrorBoundary = this.resetErrorBoundary.bind(this), this.state = c;
456
- }
457
- static getDerivedStateFromError(e) {
458
- return { didCatch: true, error: e };
459
- }
460
- resetErrorBoundary(...e) {
461
- const { error: t } = this.state;
462
- t !== null && (this.props.onReset?.({
463
- args: e,
464
- reason: "imperative-api"
465
- }), this.setState(c));
466
- }
467
- componentDidCatch(e, t) {
468
- this.props.onError?.(e, t);
469
- }
470
- componentDidUpdate(e, t) {
471
- const { didCatch: o } = this.state, { resetKeys: s } = this.props;
472
- o && t.error !== null && C(e.resetKeys, s) && (this.props.onReset?.({
473
- next: s,
474
- prev: e.resetKeys,
475
- reason: "keys"
476
- }), this.setState(c));
477
- }
478
- render() {
479
- const { children: e, fallbackRender: t, FallbackComponent: o, fallback: s } = this.props, { didCatch: n, error: a } = this.state;
480
- let i = e;
481
- if (n) {
482
- const u = {
483
- error: a,
484
- resetErrorBoundary: this.resetErrorBoundary
485
- };
486
- if (typeof t == "function")
487
- i = t(u);
488
- else if (o)
489
- i = createElement(o, u);
490
- else if (s !== void 0)
491
- i = s;
492
- else
493
- throw a;
494
- }
495
- return createElement(
496
- h.Provider,
497
- {
498
- value: {
499
- didCatch: n,
500
- error: a,
501
- resetErrorBoundary: this.resetErrorBoundary
502
- }
503
- },
504
- i
505
- );
506
- }
507
- }
508
- function C(r = [], e = []) {
509
- return r.length !== e.length || r.some((t, o) => !Object.is(t, e[o]));
510
- }
511
-
512
- /**
513
- * Copyright (c) Meta Platforms, Inc. and affiliates.
514
- *
515
- * This source code is licensed under the MIT license found in the
516
- * LICENSE file in the root directory of this source tree.
517
- *
518
- */
519
-
520
- function n({children:n,onError:e}){return jsx(m,{fallback:jsx("div",{style:{border:"1px solid #f00",color:"#f00",padding:"8px"},children:"An error was thrown."}),onError:e,children:n})}
521
-
522
- const CHAT_TRANSFORMERS = [ORDERED_LIST, UNORDERED_LIST, LINK, INLINE_CODE, CODE];
523
- function EditorRefPlugin({ editorRef }) {
524
- const [editor] = o();
525
- useEffect(() => {
526
- editorRef.current = editor;
527
- return () => {
528
- editorRef.current = null;
529
- };
530
- }, [editor, editorRef]);
531
- return null;
532
- }
533
- function SubmitPlugin({ onSubmit }) {
534
- const [editor] = o();
535
- useEffect(() => {
536
- return editor.registerCommand(
537
- KEY_ENTER_COMMAND,
538
- (event) => {
539
- if (event.shiftKey) return false;
540
- const selection = $getSelection();
541
- if ($isRangeSelection(selection)) {
542
- const node = selection.anchor.getNode();
543
- if ($isListItemNode(node) || $isListItemNode(node.getParent())) return false;
544
- if ($isCodeNode(node) || $isCodeNode(node.getParent())) return false;
545
- }
546
- event.preventDefault();
547
- editor.read(() => {
548
- onSubmit?.($convertToMarkdownString(CHAT_TRANSFORMERS));
549
- });
550
- return true;
551
- },
552
- COMMAND_PRIORITY_HIGH
553
- );
554
- }, [editor, onSubmit]);
555
- return null;
556
- }
557
- function LexicalEditor({
558
- defaultValue,
559
- onChange,
560
- onSubmit,
561
- placeholder,
562
- disabled,
563
- className,
564
- autoFocus,
565
- forwardedRef
566
- }) {
567
- const editorRef = useRef(null);
568
- useImperativeHandle(forwardedRef, () => ({
569
- clear() {
570
- editorRef.current?.update(() => {
571
- const root = $getRoot();
572
- root.clear();
573
- root.append($createParagraphNode());
574
- });
575
- },
576
- focus() {
577
- editorRef.current?.focus();
578
- }
579
- }));
580
- const initialConfig = {
581
- namespace: "RichTextInput",
582
- nodes: [ListNode, ListItemNode, LinkNode, AutoLinkNode, CodeNode, CodeHighlightNode],
583
- editable: !disabled,
584
- editorState: defaultValue ? () => $convertFromMarkdownString(defaultValue, CHAT_TRANSFORMERS) : void 0,
585
- onError: (error) => console.error("[RichTextInput]", error)
586
- };
587
- return /* @__PURE__ */ React__default.createElement(f$3, { initialConfig }, /* @__PURE__ */ React__default.createElement("div", { className }, /* @__PURE__ */ React__default.createElement("div", { className: "relative" }, /* @__PURE__ */ React__default.createElement(
588
- L,
589
- {
590
- contentEditable: /* @__PURE__ */ React__default.createElement(
591
- x$1,
592
- {
593
- autoFocus,
594
- className: "outline-none w-full max-h-[7.5rem] overflow-y-auto [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:list-decimal [&_ol]:pl-5"
595
- }
596
- ),
597
- placeholder: placeholder ? /* @__PURE__ */ React__default.createElement("div", { className: "pointer-events-none absolute top-0 left-0 select-none text-muted-foreground" }, placeholder) : null,
598
- ErrorBoundary: n
599
- }
600
- ))), /* @__PURE__ */ React__default.createElement(a$1, null), /* @__PURE__ */ React__default.createElement(l$1, null), /* @__PURE__ */ React__default.createElement(l, null), /* @__PURE__ */ React__default.createElement(a, { transformers: CHAT_TRANSFORMERS }), onChange && /* @__PURE__ */ React__default.createElement(
601
- n$1,
602
- {
603
- onChange: (editorState) => {
604
- editorState.read(() => {
605
- onChange($convertToMarkdownString(CHAT_TRANSFORMERS));
606
- });
607
- }
608
- }
609
- ), /* @__PURE__ */ React__default.createElement(SubmitPlugin, { onSubmit }), /* @__PURE__ */ React__default.createElement(EditorRefPlugin, { editorRef }));
610
- }
611
-
612
- const RichTextInput = forwardRef((props, ref) => /* @__PURE__ */ React__default.createElement(LexicalEditor, { ...props, forwardedRef: ref }));
613
- RichTextInput.displayName = "RichTextInput";
614
-
615
- const ContextPillBadge = ({ pill, onRemove }) => {
616
- return /* @__PURE__ */ React__default.createElement("span", { className: "inline-flex items-center gap-0.5 rounded-full bg-muted px-2 py-1 text-xs text-muted-foreground" }, pill.label, onRemove && /* @__PURE__ */ React__default.createElement(
617
- "button",
618
- {
619
- type: "button",
620
- className: "ml-0.5 inline-flex h-3.5 w-3.5 items-center justify-center rounded-full hover:bg-muted-foreground/20",
621
- onClick: () => onRemove(pill)
622
- },
623
- /* @__PURE__ */ React__default.createElement(X$1, { className: "h-2.5 w-2.5" })
624
- ));
625
- };
626
-
627
- const COLLECTION_SEARCH_THRESHOLD = 5;
628
- const ConversationInput = ({
629
- placeholder = "What can we help with today?",
630
- attachments = [],
631
- collections = [],
632
- contextPills = [],
633
- disabled = false,
634
- isElevated = false,
635
- className
636
- }) => {
637
- const { callbacks, isStreaming } = useConversation();
638
- const [hasText, setHasText] = useState(false);
639
- const latestMarkdown = useRef("");
640
- const editorRef = useRef(null);
641
- const [menuOpen, setMenuOpen] = useState(false);
642
- const [collectionPickerOpen, setCollectionPickerOpen] = useState(false);
643
- const collectionCloseTimer = useRef(null);
644
- const collectionHasFocus = useRef(false);
645
- const openCollectionPicker = useCallback(() => {
646
- if (collectionCloseTimer.current) {
647
- clearTimeout(collectionCloseTimer.current);
648
- collectionCloseTimer.current = null;
649
- }
650
- setCollectionPickerOpen(true);
651
- }, []);
652
- const scheduleCollectionPickerClose = useCallback(() => {
653
- collectionCloseTimer.current = setTimeout(() => {
654
- if (!collectionHasFocus.current) {
655
- setCollectionPickerOpen(false);
656
- }
657
- }, 150);
658
- }, []);
659
- const isDisabled = disabled;
660
- const handleSend = useCallback(
661
- (markdown) => {
662
- const trimmed = (markdown ?? latestMarkdown.current).trim();
663
- if (!trimmed || isDisabled || isStreaming) return;
664
- callbacks.onSend?.(trimmed, attachments.length > 0 ? attachments : void 0);
665
- editorRef.current?.clear();
666
- editorRef.current?.focus();
667
- },
668
- [isDisabled, isStreaming, callbacks, attachments]
669
- );
670
- const handleStop = useCallback(() => {
671
- callbacks.onStop?.();
672
- }, [callbacks]);
673
- const handleAttachmentAction = useCallback(
674
- (action) => {
675
- callbacks.onAttachmentAction?.(action);
676
- },
677
- [callbacks]
678
- );
679
- const handleCollectionSelect = useCallback(
680
- (collection) => {
681
- setCollectionPickerOpen(false);
682
- setMenuOpen(false);
683
- handleAttachmentAction({ type: "select-collection", collection });
684
- },
685
- [handleAttachmentAction]
686
- );
687
- return /* @__PURE__ */ React__default.createElement("div", { className: cn("px-2", className) }, /* @__PURE__ */ React__default.createElement(
688
- "div",
689
- {
690
- className: cn(
691
- "relative rounded-t-2xl rounded-b-lg bg-gradient-yellowfin p-2 transition-shadow duration-300",
692
- isElevated && "shadow-[0_-20px_25px_-5px_rgba(0,0,0,0.1),0_-8px_10px_-6px_rgba(0,0,0,0.1)]"
693
- )
694
- },
695
- /* @__PURE__ */ React__default.createElement("div", { className: "rounded-t-lg rounded-b bg-surface shadow-md" }, contextPills.length > 0 && /* @__PURE__ */ React__default.createElement("div", { className: "flex flex-wrap gap-1.5 px-3 pt-3" }, contextPills.map((pill) => /* @__PURE__ */ React__default.createElement(ContextPillBadge, { key: pill.id, pill, onRemove: callbacks.onContextPillRemove }))), /* @__PURE__ */ React__default.createElement(
696
- RichTextInput,
697
- {
698
- ref: editorRef,
699
- placeholder,
700
- disabled,
701
- autoFocus: true,
702
- className: "w-full bg-transparent p-4 text-sm disabled:cursor-not-allowed disabled:opacity-50",
703
- onChange: (markdown) => {
704
- latestMarkdown.current = markdown;
705
- setHasText(markdown.trim().length > 0);
706
- },
707
- onSubmit: handleSend
708
- }
709
- ), /* @__PURE__ */ React__default.createElement("div", { className: "flex items-center justify-between px-2 pb-2" }, /* @__PURE__ */ React__default.createElement("div", { className: "flex items-center gap-1" }, /* @__PURE__ */ React__default.createElement(DropdownMenu, { open: menuOpen, onOpenChange: setMenuOpen }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger, { asChild: true, disabled: disabled || isStreaming }, /* @__PURE__ */ React__default.createElement(
710
- "button",
711
- {
712
- type: "button",
713
- className: cn(
714
- "inline-flex h-6 w-6 items-center justify-center rounded text-default hover:bg-muted transition-all",
715
- menuOpen && "shadow-md dark:shadow-md"
716
- ),
717
- disabled: disabled || isStreaming
718
- },
719
- /* @__PURE__ */ React__default.createElement(Plus, { className: cn("h-4 w-4 transition-transform duration-200", menuOpen && "-rotate-45") })
720
- )), /* @__PURE__ */ React__default.createElement(
721
- DropdownMenuContent,
722
- {
723
- align: "end",
724
- side: "right",
725
- className: "rounded border-none shadow-md bg-surface p-2 min-w-[200px] dark:border-none dark:shadow-md"
726
- },
727
- collections.length > 0 && /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(Popover, { open: collectionPickerOpen, onOpenChange: setCollectionPickerOpen }, /* @__PURE__ */ React__default.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(
728
- DropdownMenuItem,
729
- {
730
- className: "p-2",
731
- onSelect: (e) => e.preventDefault(),
732
- onMouseEnter: openCollectionPicker,
733
- onMouseLeave: scheduleCollectionPickerClose,
734
- onFocus: openCollectionPicker
735
- },
736
- "Collection",
737
- /* @__PURE__ */ React__default.createElement(CaretRight, { className: "ml-auto h-4 w-4" })
738
- )), /* @__PURE__ */ React__default.createElement(
739
- PopoverContent,
740
- {
741
- className: "w-[200px] rounded border-none p-0 shadow-md dark:border-none dark:shadow-md",
742
- side: "right",
743
- align: "start",
744
- onMouseEnter: openCollectionPicker,
745
- onMouseLeave: scheduleCollectionPickerClose,
746
- onFocusCapture: () => {
747
- collectionHasFocus.current = true;
748
- },
749
- onBlurCapture: () => {
750
- collectionHasFocus.current = false;
751
- scheduleCollectionPickerClose();
752
- }
753
- },
754
- /* @__PURE__ */ React__default.createElement(Command, null, collections.length > COLLECTION_SEARCH_THRESHOLD && /* @__PURE__ */ React__default.createElement(CommandInput, { placeholder: "Search collections..." }), /* @__PURE__ */ React__default.createElement(CommandList, null, /* @__PURE__ */ React__default.createElement(CommandEmpty, null, "No collections found."), /* @__PURE__ */ React__default.createElement(CommandGroup, null, collections.map((collection) => /* @__PURE__ */ React__default.createElement(
755
- CommandItem,
756
- {
757
- key: collection.id,
758
- value: collection.label,
759
- onSelect: () => handleCollectionSelect(collection)
760
- },
761
- collection.label
762
- )))))
763
- )), /* @__PURE__ */ React__default.createElement(DropdownMenuSeparator, null)),
764
- /* @__PURE__ */ React__default.createElement(DropdownMenuItem, { className: "p-2", onSelect: () => handleAttachmentAction({ type: "attach-tab" }) }, "Attach tab"),
765
- /* @__PURE__ */ React__default.createElement(DropdownMenuSeparator, null),
766
- /* @__PURE__ */ React__default.createElement(DropdownMenuItem, { className: "p-2", onSelect: () => handleAttachmentAction({ type: "screenshot" }) }, "Take a screenshot"),
767
- /* @__PURE__ */ React__default.createElement(DropdownMenuItem, { className: "p-2", onSelect: () => handleAttachmentAction({ type: "record-video" }) }, "Record a video"),
768
- /* @__PURE__ */ React__default.createElement(DropdownMenuItem, { className: "p-2", onSelect: () => handleAttachmentAction({ type: "add-file" }) }, "Add image or file")
769
- ))), isStreaming ? /* @__PURE__ */ React__default.createElement(
770
- "button",
771
- {
772
- type: "button",
773
- className: "inline-flex h-6 w-6 items-center justify-center rounded transition-colors bg-input text-primary-foreground hover:bg-input/90",
774
- onClick: handleStop,
775
- disabled
776
- },
777
- /* @__PURE__ */ React__default.createElement(Stop, { className: "h-4 w-4", weight: "fill" })
778
- ) : /* @__PURE__ */ React__default.createElement(
779
- "button",
780
- {
781
- type: "button",
782
- className: cn(
783
- "inline-flex h-6 w-6 items-center justify-center rounded transition-colors",
784
- hasText ? "bg-input text-primary-foreground hover:bg-input/90" : "bg-muted text-muted-foreground"
785
- ),
786
- onClick: () => handleSend(),
787
- disabled: isDisabled || !hasText
788
- },
789
- /* @__PURE__ */ React__default.createElement(ArrowUp, { className: "h-4 w-4", weight: "bold" })
790
- )))
791
- ));
792
- };
793
-
794
- const ConversationSuggestions = ({ items, className }) => {
795
- const { callbacks } = useConversation();
796
- if (items.length === 0) return null;
797
- return /* @__PURE__ */ React__default.createElement("div", { className: cn("flex flex-wrap justify-end gap-2 px-4 py-2", className) }, items.map((suggestion) => /* @__PURE__ */ React__default.createElement(
798
- "button",
799
- {
800
- key: suggestion.id,
801
- type: "button",
802
- className: "rounded-full border border-border px-4 py-2 text-sm text-foreground hover:bg-muted transition-colors",
803
- onClick: () => callbacks.onSuggestionClick?.(suggestion)
804
- },
805
- suggestion.text
806
- )));
807
- };
808
-
809
- const ConversationActions = ({ actions, onActionClick, className }) => {
810
- if (actions.length === 0) return null;
811
- return /* @__PURE__ */ React__default.createElement("div", { className: cn("flex flex-wrap gap-2 px-4 py-2", className) }, actions.map((action) => /* @__PURE__ */ React__default.createElement(
812
- "button",
813
- {
814
- key: action.id,
815
- type: "button",
816
- className: "inline-flex items-center gap-2 rounded-full border border-border px-4 py-2 text-sm text-foreground hover:bg-muted transition-colors",
817
- onClick: () => onActionClick?.(action)
818
- },
819
- action.label,
820
- action.description && /* @__PURE__ */ React__default.createElement("span", { className: "text-muted-foreground" }, action.description)
821
- )));
822
- };
823
-
824
- const ConversationRoot = ({
825
- messages,
826
- callbacks,
827
- children,
828
- suggestions = [],
829
- actions = [],
830
- placeholder,
831
- attachments,
832
- collections,
833
- contextPills,
834
- showBranding = false,
835
- className
836
- }) => {
837
- const isCompound = !!children;
838
- const bottomRef = useRef(null);
839
- const [bottomHeight, setBottomHeight] = useState(0);
840
- const [hasContentBehind, setContentBehind] = useState(false);
841
- useEffect(() => {
842
- const el = bottomRef.current;
843
- if (!el) return;
844
- const observer = new ResizeObserver(([entry]) => {
845
- if (entry) setBottomHeight(entry.borderBoxSize[0]?.blockSize ?? entry.contentRect.height);
846
- });
847
- observer.observe(el);
848
- return () => observer.disconnect();
849
- }, []);
850
- return /* @__PURE__ */ React__default.createElement(TooltipProvider, null, /* @__PURE__ */ React__default.createElement(ConversationProvider, { messages, callbacks }, /* @__PURE__ */ React__default.createElement("div", { className: cn("flex h-full flex-col", className) }, isCompound ? children : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("div", { className: "relative min-h-0 flex-1 grid grid-rows-[1fr] grid-cols-[1fr] pb-2" }, /* @__PURE__ */ React__default.createElement("div", { className: "row-start-1 col-start-1 min-h-0" }, /* @__PURE__ */ React__default.createElement(ConversationMessages, { bottomPadding: bottomHeight, onContentBehind: setContentBehind })), /* @__PURE__ */ React__default.createElement("div", { ref: bottomRef, className: "row-start-1 col-start-1 self-end z-10 pointer-events-none" }, /* @__PURE__ */ React__default.createElement("div", { className: "pointer-events-auto" }, suggestions.length > 0 && /* @__PURE__ */ React__default.createElement(ConversationSuggestions, { items: suggestions }), actions.length > 0 && /* @__PURE__ */ React__default.createElement(
851
- ConversationActions,
852
- {
853
- actions,
854
- onActionClick: (action) => callbacks.onActionClick?.(action, "")
855
- }
856
- ), /* @__PURE__ */ React__default.createElement(
857
- ConversationInput,
858
- {
859
- placeholder,
860
- attachments,
861
- collections,
862
- contextPills,
863
- isElevated: hasContentBehind
864
- }
865
- )))), showBranding && /* @__PURE__ */ React__default.createElement("div", { className: "relative z-10 pb-2" }, /* @__PURE__ */ React__default.createElement(Branding, null))))));
866
- };
867
- const Branding = () => /* @__PURE__ */ React__default.createElement("div", { className: "flex items-center justify-center gap-1 text-[0.625rem] text-subtle" }, /* @__PURE__ */ React__default.createElement("span", null, "Powered by"), /* @__PURE__ */ React__default.createElement(Logo, { variant: "full", color: "outline", className: "h-2.5 w-auto" }));
868
- const Conversation = Object.assign(ConversationRoot, {
869
- Messages: ConversationMessages,
870
- Input: ConversationInput,
871
- Suggestions: ConversationSuggestions,
872
- Actions: ConversationActions,
873
- Loading: ConversationLoading
874
- });
875
-
876
- function InputWithTags({
877
- title,
878
- placeholder,
879
- tags,
880
- value: controlledValue,
881
- defaultValue,
882
- onChange,
883
- onTagClick,
884
- singleValue = false,
885
- className,
886
- inputClassName,
887
- tagsClassName,
888
- disabled,
889
- name,
890
- id,
891
- required,
892
- maxLength,
893
- minLength,
894
- rows
895
- }) {
896
- const findTagsInValue = React.useCallback(
897
- (val) => {
898
- if (!val) return /* @__PURE__ */ new Set();
899
- const trimmedVal = val.trim();
900
- const foundTags = /* @__PURE__ */ new Set();
901
- for (const tag of tags) {
902
- const tagValue = tag.value.trim();
903
- if (singleValue) {
904
- if (trimmedVal === tagValue) {
905
- foundTags.add(tag.value);
906
- }
907
- } else {
908
- if (trimmedVal === tagValue || trimmedVal.startsWith(tagValue + " ") || trimmedVal.includes(" " + tagValue + " ") || trimmedVal.endsWith(" " + tagValue)) {
909
- foundTags.add(tag.value);
910
- }
911
- }
912
- }
913
- return foundTags;
914
- },
915
- [tags, singleValue]
916
- );
917
- const initialValue = controlledValue !== void 0 ? controlledValue : defaultValue || "";
918
- const [internalValue, setInternalValue] = React.useState(defaultValue || "");
919
- const [clickedTags, setClickedTags] = React.useState(() => findTagsInValue(initialValue));
920
- const value = controlledValue !== void 0 ? controlledValue : internalValue;
921
- React.useEffect(() => {
922
- const currentValue = controlledValue !== void 0 ? controlledValue : internalValue;
923
- setClickedTags(findTagsInValue(currentValue));
924
- }, [controlledValue, internalValue, tags, singleValue, findTagsInValue]);
925
- const availableTags = tags.filter((tag) => !clickedTags.has(tag.value));
926
- const handleInputChange = (e) => {
927
- const newValue = e.target.value;
928
- if (controlledValue === void 0) {
929
- setInternalValue(newValue);
930
- setClickedTags(findTagsInValue(newValue));
931
- }
932
- onChange?.(newValue);
933
- };
934
- const handleTagClick = (tag) => {
935
- const newValue = singleValue ? tag.value : value ? `${value} ${tag.value}` : tag.value;
936
- if (controlledValue === void 0) {
937
- setInternalValue(newValue);
938
- if (singleValue) {
939
- setClickedTags(/* @__PURE__ */ new Set([tag.value]));
940
- } else {
941
- setClickedTags(findTagsInValue(newValue));
942
- }
943
- }
944
- onChange?.(newValue);
945
- onTagClick?.(tag);
946
- };
947
- return /* @__PURE__ */ React.createElement("div", { className: cn("w-full flex flex-col gap-3", className) }, title && /* @__PURE__ */ React.createElement("label", { htmlFor: id, className: "text-sm font-semibold" }, title), /* @__PURE__ */ React.createElement("div", { className: "relative w-full" }, /* @__PURE__ */ React.createElement(
948
- Textarea,
949
- {
950
- id,
951
- name,
952
- placeholder,
953
- value,
954
- onChange: handleInputChange,
955
- disabled,
956
- required,
957
- maxLength,
958
- minLength,
959
- rows,
960
- className: inputClassName
961
- }
962
- )), availableTags.length > 0 && /* @__PURE__ */ React.createElement("div", { className: cn("flex flex-wrap gap-2", tagsClassName) }, availableTags.map((tag, index) => /* @__PURE__ */ React.createElement(
963
- Button,
964
- {
965
- key: `${tag.value}-${index}`,
966
- type: "button",
967
- variant: "outline",
968
- size: "sm",
969
- onClick: () => handleTagClick(tag),
970
- disabled,
971
- className: "rounded-full"
972
- },
973
- /* @__PURE__ */ React.createElement(Plus, { size: 16, className: "text-muted-foreground" }),
974
- /* @__PURE__ */ React.createElement("span", null, tag.label)
975
- ))));
976
- }
977
-
978
- const FullLayoutHeader = React__default.forwardRef(
979
- ({ onOpenLeft, onOpenRight, className, children, ...props }, ref) => {
980
- return /* @__PURE__ */ React__default.createElement(
981
- "header",
982
- {
983
- ref,
984
- "data-slot": "full-layout-header",
985
- className: cn("h-16 bg-white shadow-md flex items-center px-4 shrink-0 sticky top-0 z-20", className),
986
- ...props
987
- },
988
- onOpenLeft != null && /* @__PURE__ */ React__default.createElement(
989
- "button",
990
- {
991
- "data-slot": "full-layout-header-trigger-left",
992
- type: "button",
993
- onClick: onOpenLeft,
994
- className: "p-2 hover:bg-gray-100 rounded-lg transition-colors mr-4 lg:hidden",
995
- "aria-label": "Toggle menu"
996
- },
997
- /* @__PURE__ */ React__default.createElement("svg", { className: "size-6", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24" }, /* @__PURE__ */ React__default.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M4 6h16M4 12h16M4 18h16" }))
998
- ),
999
- /* @__PURE__ */ React__default.createElement("div", { "data-slot": "full-layout-header-center", className: "flex-1 min-w-0" }, children),
1000
- onOpenRight != null && /* @__PURE__ */ React__default.createElement("div", { "data-slot": "full-layout-header-trigger-right", className: "ml-auto" }, /* @__PURE__ */ React__default.createElement(
1001
- "button",
1002
- {
1003
- type: "button",
1004
- onClick: onOpenRight,
1005
- className: "p-2 hover:bg-gray-100 rounded-lg transition-colors",
1006
- "aria-label": "Toggle chat"
1007
- },
1008
- /* @__PURE__ */ React__default.createElement("svg", { className: "size-6", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24" }, /* @__PURE__ */ React__default.createElement(
1009
- "path",
1010
- {
1011
- strokeLinecap: "round",
1012
- strokeLinejoin: "round",
1013
- strokeWidth: 2,
1014
- d: "M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"
1015
- }
1016
- ))
1017
- ))
1018
- );
1019
- }
1020
- );
1021
- FullLayoutHeader.displayName = "FullLayoutHeader";
1022
-
1023
- export { Button, Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, ContextPillBadge, Conversation, ConversationActions, ConversationInput, ConversationLoading, ConversationMessageAssistant, ConversationMessageUser, ConversationMessages, ConversationProvider, ConversationSuggestions, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, FormattedMessage, FullLayoutHeader, InputWithTags, Logo, Popover, PopoverContent, PopoverTrigger, ScrollArea, Textarea, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, useConversation };
53
+ export { R as ReviewList, a as ReviewListItem, b as ReviewsSelectionProvider, u as useReviewsSelection } from './chunks/review-list.DjtiIcPl.js';
1024
54
  //# sourceMappingURL=index.js.map