@assistant-ui/react 0.5.20 → 0.5.21

Sign up to get free protection for your applications and to get access to all the features.
package/dist/internal.mjs CHANGED
@@ -1,523 +1,16 @@
1
+ "use client";
1
2
  import {
2
- mergeModelConfigs
3
- } from "./chunk-BV6Y7C43.mjs";
4
-
5
- // src/utils/ProxyConfigProvider.ts
6
- var ProxyConfigProvider = class {
7
- _providers = /* @__PURE__ */ new Set();
8
- getModelConfig() {
9
- return mergeModelConfigs(this._providers);
10
- }
11
- registerModelConfigProvider(provider) {
12
- this._providers.add(provider);
13
- return () => {
14
- this._providers.delete(provider);
15
- };
16
- }
17
- };
18
-
19
- // src/utils/idUtils.tsx
20
- import { customAlphabet } from "nanoid/non-secure";
21
- var generateId = customAlphabet(
22
- "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
23
- 7
24
- );
25
- var optimisticPrefix = "__optimistic__";
26
- var generateOptimisticId = () => `${optimisticPrefix}${generateId()}`;
27
-
28
- // src/runtimes/edge/converters/fromCoreMessage.ts
29
- var fromCoreMessage = (message, {
30
- id = generateId(),
31
- status = { type: "complete", reason: "unknown" }
32
- } = {}) => {
33
- const commonProps = {
34
- id,
35
- createdAt: /* @__PURE__ */ new Date()
36
- };
37
- const role = message.role;
38
- switch (role) {
39
- case "assistant":
40
- return {
41
- ...commonProps,
42
- role,
43
- content: message.content.map((part) => {
44
- if (part.type === "tool-call") {
45
- return {
46
- ...part,
47
- argsText: JSON.stringify(part.args)
48
- };
49
- }
50
- return part;
51
- }),
52
- status
53
- };
54
- case "user":
55
- return {
56
- ...commonProps,
57
- role,
58
- content: message.content
59
- };
60
- case "system":
61
- return {
62
- ...commonProps,
63
- role,
64
- content: message.content
65
- };
66
- default: {
67
- const unsupportedRole = role;
68
- throw new Error(`Unknown message role: ${unsupportedRole}`);
69
- }
70
- }
71
- };
72
-
73
- // src/runtimes/utils/MessageRepository.tsx
74
- var findHead = (message) => {
75
- if (message.next) return findHead(message.next);
76
- return message;
77
- };
78
- var MessageRepository = class {
79
- messages = /* @__PURE__ */ new Map();
80
- // message_id -> item
81
- head = null;
82
- root = {
83
- children: []
84
- };
85
- performOp(newParent, child, operation) {
86
- const parentOrRoot = child.prev ?? this.root;
87
- const newParentOrRoot = newParent ?? this.root;
88
- if (operation === "relink" && parentOrRoot === newParentOrRoot) return;
89
- if (operation !== "link") {
90
- parentOrRoot.children = parentOrRoot.children.filter(
91
- (m) => m !== child.current.id
92
- );
93
- if (child.prev?.next === child) {
94
- const fallbackId = child.prev.children.at(-1);
95
- const fallback = fallbackId ? this.messages.get(fallbackId) : null;
96
- if (fallback === void 0) {
97
- throw new Error(
98
- "MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui."
99
- );
100
- }
101
- child.prev.next = fallback;
102
- }
103
- }
104
- if (operation !== "cut") {
105
- newParentOrRoot.children = [
106
- ...newParentOrRoot.children,
107
- child.current.id
108
- ];
109
- if (newParent && (findHead(child) === this.head || newParent.next === null)) {
110
- newParent.next = child;
111
- }
112
- child.prev = newParent;
113
- }
114
- }
115
- getMessages() {
116
- const messages = new Array(this.head?.level ?? 0);
117
- for (let current = this.head; current; current = current.prev) {
118
- messages[current.level] = current.current;
119
- }
120
- return messages;
121
- }
122
- addOrUpdateMessage(parentId, message) {
123
- const existingItem = this.messages.get(message.id);
124
- const prev = parentId ? this.messages.get(parentId) : null;
125
- if (prev === void 0)
126
- throw new Error(
127
- "MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui."
128
- );
129
- if (existingItem) {
130
- existingItem.current = message;
131
- this.performOp(prev, existingItem, "relink");
132
- return;
133
- }
134
- const newItem = {
135
- prev,
136
- current: message,
137
- next: null,
138
- children: [],
139
- level: prev ? prev.level + 1 : 0
140
- };
141
- this.messages.set(message.id, newItem);
142
- this.performOp(prev, newItem, "link");
143
- if (this.head === prev) {
144
- this.head = newItem;
145
- }
146
- }
147
- getMessage(messageId) {
148
- const message = this.messages.get(messageId);
149
- if (!message)
150
- throw new Error(
151
- "MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui."
152
- );
153
- return {
154
- parentId: message.prev?.current.id ?? null,
155
- message: message.current
156
- };
157
- }
158
- appendOptimisticMessage(parentId, message) {
159
- let optimisticId;
160
- do {
161
- optimisticId = generateOptimisticId();
162
- } while (this.messages.has(optimisticId));
163
- this.addOrUpdateMessage(
164
- parentId,
165
- fromCoreMessage(message, {
166
- id: optimisticId,
167
- status: { type: "running" }
168
- })
169
- );
170
- return optimisticId;
171
- }
172
- deleteMessage(messageId, replacementId) {
173
- const message = this.messages.get(messageId);
174
- if (!message)
175
- throw new Error(
176
- "MessageRepository(deleteMessage): Optimistic message not found. This is likely an internal bug in assistant-ui."
177
- );
178
- const replacement = replacementId === void 0 ? message.prev : replacementId === null ? null : this.messages.get(replacementId);
179
- if (replacement === void 0)
180
- throw new Error(
181
- "MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui."
182
- );
183
- for (const child of message.children) {
184
- const childMessage = this.messages.get(child);
185
- if (!childMessage)
186
- throw new Error(
187
- "MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui."
188
- );
189
- this.performOp(replacement, childMessage, "relink");
190
- }
191
- this.performOp(null, message, "cut");
192
- this.messages.delete(messageId);
193
- if (this.head === message) {
194
- this.head = replacement ? findHead(replacement) : null;
195
- }
196
- }
197
- getBranches(messageId) {
198
- const message = this.messages.get(messageId);
199
- if (!message)
200
- throw new Error(
201
- "MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui."
202
- );
203
- const { children } = message.prev ?? this.root;
204
- return children;
205
- }
206
- switchToBranch(messageId) {
207
- const message = this.messages.get(messageId);
208
- if (!message)
209
- throw new Error(
210
- "MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui."
211
- );
212
- if (message.prev) {
213
- message.prev.next = message;
214
- }
215
- this.head = findHead(message);
216
- }
217
- resetHead(messageId) {
218
- if (messageId === null) {
219
- this.head = null;
220
- return;
221
- }
222
- const message = this.messages.get(messageId);
223
- if (!message)
224
- throw new Error(
225
- "MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui."
226
- );
227
- this.head = message;
228
- for (let current = message; current; current = current.prev) {
229
- if (current.prev) {
230
- current.prev.next = current;
231
- }
232
- }
233
- }
234
- };
235
-
236
- // src/runtimes/core/BaseAssistantRuntime.tsx
237
- var BaseAssistantRuntime = class {
238
- constructor(_thread) {
239
- this._thread = _thread;
240
- this._thread = _thread;
241
- }
242
- get thread() {
243
- return this._thread;
244
- }
245
- set thread(thread) {
246
- this._thread = thread;
247
- this.subscriptionHandler();
248
- }
249
- _subscriptions = /* @__PURE__ */ new Set();
250
- subscribe(callback) {
251
- this._subscriptions.add(callback);
252
- return () => this._subscriptions.delete(callback);
253
- }
254
- subscriptionHandler = () => {
255
- for (const callback of this._subscriptions) callback();
256
- };
257
- };
258
-
259
- // src/utils/smooth/useSmooth.tsx
260
- import { useEffect, useMemo, useRef, useState as useState2 } from "react";
261
-
262
- // src/context/react/MessageContext.ts
263
- import { createContext, useContext } from "react";
264
- var MessageContext = createContext(null);
265
- function useMessageContext(options) {
266
- const context = useContext(MessageContext);
267
- if (!options?.optional && !context)
268
- throw new Error(
269
- "This component can only be used inside a component passed to <ThreadPrimitive.Messages components={...} />."
270
- );
271
- return context;
272
- }
273
-
274
- // src/context/react/ContentPartContext.ts
275
- import { createContext as createContext2, useContext as useContext2 } from "react";
276
- var ContentPartContext = createContext2(
277
- null
278
- );
279
- function useContentPartContext(options) {
280
- const context = useContext2(ContentPartContext);
281
- if (!options?.optional && !context)
282
- throw new Error(
283
- "This component can only be used inside a component passed to <MessagePrimitive.Content components={...} >."
284
- );
285
- return context;
286
- }
287
-
288
- // src/utils/smooth/SmoothContext.tsx
289
- import {
290
- createContext as createContext3,
291
- forwardRef,
292
- useContext as useContext3,
293
- useState
294
- } from "react";
295
- import { create } from "zustand";
296
- import { jsx } from "react/jsx-runtime";
297
- var SmoothContext = createContext3(null);
298
- var makeSmoothContext = (initialState) => {
299
- const useSmoothStatus2 = create(() => initialState);
300
- return { useSmoothStatus: useSmoothStatus2 };
301
- };
302
- var SmoothContextProvider = ({ children }) => {
303
- const outer = useSmoothContext({ optional: true });
304
- const { useContentPart } = useContentPartContext();
305
- const [context] = useState(
306
- () => makeSmoothContext(useContentPart.getState().status)
307
- );
308
- if (outer) return children;
309
- return /* @__PURE__ */ jsx(SmoothContext.Provider, { value: context, children });
310
- };
311
- var withSmoothContextProvider = (Component) => {
312
- const Wrapped = forwardRef((props, ref) => {
313
- return /* @__PURE__ */ jsx(SmoothContextProvider, { children: /* @__PURE__ */ jsx(Component, { ...props, ref }) });
314
- });
315
- Wrapped.displayName = Component.displayName;
316
- return Wrapped;
317
- };
318
- function useSmoothContext(options) {
319
- const context = useContext3(SmoothContext);
320
- if (!options?.optional && !context)
321
- throw new Error(
322
- "This component must be used within a SmoothContextProvider."
323
- );
324
- return context;
325
- }
326
- var useSmoothStatus = () => {
327
- const { useSmoothStatus: useSmoothStatus2 } = useSmoothContext();
328
- return useSmoothStatus2();
329
- };
330
-
331
- // src/utils/smooth/useSmooth.tsx
332
- import { useCallbackRef } from "@radix-ui/react-use-callback-ref";
333
- var TextStreamAnimator = class {
334
- constructor(currentText, setText) {
335
- this.currentText = currentText;
336
- this.setText = setText;
337
- }
338
- animationFrameId = null;
339
- lastUpdateTime = Date.now();
340
- targetText = "";
341
- start() {
342
- if (this.animationFrameId !== null) return;
343
- this.lastUpdateTime = Date.now();
344
- this.animate();
345
- }
346
- stop() {
347
- if (this.animationFrameId !== null) {
348
- cancelAnimationFrame(this.animationFrameId);
349
- this.animationFrameId = null;
350
- }
351
- }
352
- animate = () => {
353
- const currentTime = Date.now();
354
- const deltaTime = currentTime - this.lastUpdateTime;
355
- let timeToConsume = deltaTime;
356
- const remainingChars = this.targetText.length - this.currentText.length;
357
- const baseTimePerChar = Math.min(5, 250 / remainingChars);
358
- let charsToAdd = 0;
359
- while (timeToConsume >= baseTimePerChar && charsToAdd < remainingChars) {
360
- charsToAdd++;
361
- timeToConsume -= baseTimePerChar;
362
- }
363
- if (charsToAdd !== remainingChars) {
364
- this.animationFrameId = requestAnimationFrame(this.animate);
365
- } else {
366
- this.animationFrameId = null;
367
- }
368
- if (charsToAdd === 0) return;
369
- this.currentText = this.targetText.slice(
370
- 0,
371
- this.currentText.length + charsToAdd
372
- );
373
- this.lastUpdateTime = currentTime - timeToConsume;
374
- this.setText(this.currentText);
375
- };
376
- };
377
- var SMOOTH_STATUS = Object.freeze({
378
- type: "running"
379
- });
380
- var useSmooth = (state, smooth = false) => {
381
- const { useSmoothStatus: useSmoothStatus2 } = useSmoothContext({ optional: true }) ?? {};
382
- const {
383
- part: { text }
384
- } = state;
385
- const { useMessage } = useMessageContext();
386
- const id = useMessage((m) => m.message.id);
387
- const idRef = useRef(id);
388
- const [displayedText, setDisplayedText] = useState2(text);
389
- const setText = useCallbackRef((text2) => {
390
- setDisplayedText(text2);
391
- useSmoothStatus2?.setState(text2 !== state.part.text ? SMOOTH_STATUS : state.status);
392
- });
393
- const [animatorRef] = useState2(
394
- new TextStreamAnimator(text, setText)
395
- );
396
- useEffect(() => {
397
- if (!smooth) {
398
- animatorRef.stop();
399
- return;
400
- }
401
- if (idRef.current !== id || !text.startsWith(animatorRef.targetText)) {
402
- idRef.current = id;
403
- setText(text);
404
- animatorRef.currentText = text;
405
- animatorRef.targetText = text;
406
- animatorRef.stop();
407
- return;
408
- }
409
- animatorRef.targetText = text;
410
- animatorRef.start();
411
- }, [setText, animatorRef, id, smooth, text]);
412
- useEffect(() => {
413
- return () => {
414
- animatorRef.stop();
415
- };
416
- }, [animatorRef]);
417
- return useMemo(
418
- () => smooth ? {
419
- part: { type: "text", text: displayedText },
420
- status: text === displayedText ? state.status : SMOOTH_STATUS
421
- } : state,
422
- [smooth, displayedText, state, text]
423
- );
424
- };
425
-
426
- // src/ui/base/tooltip-icon-button.tsx
427
- import { forwardRef as forwardRef4 } from "react";
428
-
429
- // src/ui/base/tooltip.tsx
430
- import * as TooltipPrimitive from "@radix-ui/react-tooltip";
431
-
432
- // src/ui/utils/withDefaults.tsx
433
- import {
434
- forwardRef as forwardRef2
435
- } from "react";
436
- import classNames from "classnames";
437
- import { jsx as jsx2 } from "react/jsx-runtime";
438
- var withDefaultProps = ({
439
- className,
440
- ...defaultProps
441
- }) => ({ className: classNameProp, ...props }) => {
442
- return {
443
- className: classNames(className, classNameProp),
444
- ...defaultProps,
445
- ...props
446
- };
447
- };
448
- var withDefaults = (Component, defaultProps) => {
449
- const getProps = withDefaultProps(defaultProps);
450
- const WithDefaults = forwardRef2(
451
- (props, ref) => {
452
- const ComponentAsAny = Component;
453
- return /* @__PURE__ */ jsx2(ComponentAsAny, { ...getProps(props), ref });
454
- }
455
- );
456
- WithDefaults.displayName = "withDefaults(" + (typeof Component === "string" ? Component : Component.displayName) + ")";
457
- return WithDefaults;
458
- };
459
-
460
- // src/ui/base/tooltip.tsx
461
- import { jsx as jsx3 } from "react/jsx-runtime";
462
- var Tooltip = (props) => {
463
- return /* @__PURE__ */ jsx3(TooltipPrimitive.Provider, { children: /* @__PURE__ */ jsx3(TooltipPrimitive.Root, { ...props }) });
464
- };
465
- Tooltip.displayName = "Tooltip";
466
- var TooltipTrigger = TooltipPrimitive.Trigger;
467
- var TooltipContent = withDefaults(TooltipPrimitive.Content, {
468
- sideOffset: 4,
469
- className: "aui-tooltip-content"
470
- });
471
- TooltipContent.displayName = "TooltipContent";
472
-
473
- // src/ui/base/button.tsx
474
- import { cva } from "class-variance-authority";
475
- import { Primitive } from "@radix-ui/react-primitive";
476
- import { forwardRef as forwardRef3 } from "react";
477
- import { jsx as jsx4 } from "react/jsx-runtime";
478
- var buttonVariants = cva("aui-button", {
479
- variants: {
480
- variant: {
481
- default: "aui-button-primary",
482
- outline: "aui-button-outline",
483
- ghost: "aui-button-ghost"
484
- },
485
- size: {
486
- default: "aui-button-medium",
487
- icon: "aui-button-icon"
488
- }
489
- },
490
- defaultVariants: {
491
- variant: "default",
492
- size: "default"
493
- }
494
- });
495
- var Button = forwardRef3(
496
- ({ className, variant, size, ...props }, ref) => {
497
- return /* @__PURE__ */ jsx4(
498
- Primitive.button,
499
- {
500
- className: buttonVariants({ variant, size, className }),
501
- ...props,
502
- ref
503
- }
504
- );
505
- }
506
- );
507
- Button.displayName = "Button";
508
-
509
- // src/ui/base/tooltip-icon-button.tsx
510
- import { jsx as jsx5, jsxs } from "react/jsx-runtime";
511
- var TooltipIconButton = forwardRef4(({ children, tooltip, side = "bottom", ...rest }, ref) => {
512
- return /* @__PURE__ */ jsxs(Tooltip, { children: [
513
- /* @__PURE__ */ jsx5(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { variant: "ghost", size: "icon", ...rest, ref, children: [
514
- children,
515
- /* @__PURE__ */ jsx5("span", { className: "aui-sr-only", children: tooltip })
516
- ] }) }),
517
- /* @__PURE__ */ jsx5(TooltipContent, { side, children: tooltip })
518
- ] });
519
- });
520
- TooltipIconButton.displayName = "TooltipIconButton";
3
+ BaseAssistantRuntime,
4
+ MessageRepository,
5
+ ProxyConfigProvider,
6
+ TooltipIconButton,
7
+ generateId,
8
+ useSmooth,
9
+ useSmoothStatus,
10
+ withSmoothContextProvider
11
+ } from "./chunk-V66MVXBH.mjs";
12
+ import "./chunk-QBS6JLLN.mjs";
13
+ import "./chunk-BJPOCE4O.mjs";
521
14
  export {
522
15
  BaseAssistantRuntime,
523
16
  MessageRepository,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/ProxyConfigProvider.ts","../src/utils/idUtils.tsx","../src/runtimes/edge/converters/fromCoreMessage.ts","../src/runtimes/utils/MessageRepository.tsx","../src/runtimes/core/BaseAssistantRuntime.tsx","../src/utils/smooth/useSmooth.tsx","../src/context/react/MessageContext.ts","../src/context/react/ContentPartContext.ts","../src/utils/smooth/SmoothContext.tsx","../src/ui/base/tooltip-icon-button.tsx","../src/ui/base/tooltip.tsx","../src/ui/utils/withDefaults.tsx","../src/ui/base/button.tsx"],"sourcesContent":["\"use client\";\nimport {\n type ModelConfigProvider,\n mergeModelConfigs,\n} from \"../types/ModelConfigTypes\";\n\nexport class ProxyConfigProvider implements ModelConfigProvider {\n private _providers = new Set<ModelConfigProvider>();\n\n getModelConfig() {\n return mergeModelConfigs(this._providers);\n }\n\n registerModelConfigProvider(provider: ModelConfigProvider) {\n this._providers.add(provider);\n return () => {\n this._providers.delete(provider);\n };\n }\n}\n","import { customAlphabet } from \"nanoid/non-secure\";\n\nexport const generateId = customAlphabet(\n \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\",\n 7,\n);\n\nconst optimisticPrefix = \"__optimistic__\";\nexport const generateOptimisticId = () => `${optimisticPrefix}${generateId()}`;\nexport const isOptimisticId = (id: string) => id.startsWith(optimisticPrefix);\n","import { generateId } from \"../../../internal\";\nimport {\n ThreadMessage,\n CoreMessage,\n ToolCallContentPart,\n MessageStatus,\n} from \"../../../types\";\n\nexport const fromCoreMessages = (\n message: readonly CoreMessage[],\n): ThreadMessage[] => {\n return message.map((message) => fromCoreMessage(message));\n};\n\nexport const fromCoreMessage = (\n message: CoreMessage,\n {\n id = generateId(),\n status = { type: \"complete\", reason: \"unknown\" } as MessageStatus,\n } = {},\n): ThreadMessage => {\n const commonProps = {\n id,\n createdAt: new Date(),\n };\n\n const role = message.role;\n switch (role) {\n case \"assistant\":\n return {\n ...commonProps,\n role,\n content: message.content.map((part) => {\n if (part.type === \"tool-call\") {\n return {\n ...part,\n argsText: JSON.stringify(part.args),\n } satisfies ToolCallContentPart;\n }\n return part;\n }),\n status,\n } satisfies ThreadMessage;\n\n case \"user\":\n return {\n ...commonProps,\n role,\n content: message.content,\n } satisfies ThreadMessage;\n\n case \"system\":\n return {\n ...commonProps,\n role,\n content: message.content,\n } satisfies ThreadMessage;\n\n default: {\n const unsupportedRole: never = role;\n throw new Error(`Unknown message role: ${unsupportedRole}`);\n }\n }\n};\n","import type { CoreMessage, ThreadMessage } from \"../../types/AssistantTypes\";\nimport { generateOptimisticId } from \"../../utils/idUtils\";\nimport { fromCoreMessage } from \"../edge/converters/fromCoreMessage\";\n\ntype RepositoryParent = {\n children: string[];\n};\n\ntype RepositoryMessage = RepositoryParent & {\n prev: RepositoryMessage | null;\n current: ThreadMessage;\n next: RepositoryMessage | null;\n level: number;\n};\n\nconst findHead = (message: RepositoryMessage): RepositoryMessage => {\n if (message.next) return findHead(message.next);\n return message;\n};\n\nexport class MessageRepository {\n private messages = new Map<string, RepositoryMessage>(); // message_id -> item\n private head: RepositoryMessage | null = null;\n private root: RepositoryParent = {\n children: [],\n };\n\n private performOp(\n newParent: RepositoryMessage | null,\n child: RepositoryMessage,\n operation: \"cut\" | \"link\" | \"relink\",\n ) {\n const parentOrRoot = child.prev ?? this.root;\n const newParentOrRoot = newParent ?? this.root;\n\n if (operation === \"relink\" && parentOrRoot === newParentOrRoot) return;\n\n // cut\n if (operation !== \"link\") {\n parentOrRoot.children = parentOrRoot.children.filter(\n (m) => m !== child.current.id,\n );\n\n if (child.prev?.next === child) {\n const fallbackId = child.prev.children.at(-1);\n const fallback = fallbackId ? this.messages.get(fallbackId) : null;\n if (fallback === undefined) {\n throw new Error(\n \"MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui.\",\n );\n }\n child.prev.next = fallback;\n }\n }\n\n // link\n if (operation !== \"cut\") {\n newParentOrRoot.children = [\n ...newParentOrRoot.children,\n child.current.id,\n ];\n\n if (\n newParent &&\n (findHead(child) === this.head || newParent.next === null)\n ) {\n newParent.next = child;\n }\n\n child.prev = newParent;\n }\n }\n getMessages() {\n const messages = new Array<ThreadMessage>(this.head?.level ?? 0);\n for (let current = this.head; current; current = current.prev) {\n messages[current.level] = current.current;\n }\n return messages;\n }\n\n addOrUpdateMessage(parentId: string | null, message: ThreadMessage) {\n const existingItem = this.messages.get(message.id);\n const prev = parentId ? this.messages.get(parentId) : null;\n if (prev === undefined)\n throw new Error(\n \"MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui.\",\n );\n\n // update existing message\n if (existingItem) {\n existingItem.current = message;\n this.performOp(prev, existingItem, \"relink\");\n return;\n }\n\n // create a new message\n const newItem: RepositoryMessage = {\n prev,\n current: message,\n next: null,\n children: [],\n level: prev ? prev.level + 1 : 0,\n };\n\n this.messages.set(message.id, newItem);\n this.performOp(prev, newItem, \"link\");\n\n if (this.head === prev) {\n this.head = newItem;\n }\n }\n\n getMessage(messageId: string) {\n const message = this.messages.get(messageId);\n if (!message)\n throw new Error(\n \"MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui.\",\n );\n\n return {\n parentId: message.prev?.current.id ?? null,\n message: message.current,\n };\n }\n\n appendOptimisticMessage(parentId: string | null, message: CoreMessage) {\n let optimisticId: string;\n do {\n optimisticId = generateOptimisticId();\n } while (this.messages.has(optimisticId));\n\n this.addOrUpdateMessage(\n parentId,\n fromCoreMessage(message, {\n id: optimisticId,\n status: { type: \"running\" },\n }),\n );\n\n return optimisticId;\n }\n\n deleteMessage(messageId: string, replacementId?: string | null | undefined) {\n const message = this.messages.get(messageId);\n\n if (!message)\n throw new Error(\n \"MessageRepository(deleteMessage): Optimistic message not found. This is likely an internal bug in assistant-ui.\",\n );\n\n const replacement =\n replacementId === undefined\n ? message.prev // if no replacementId is provided, use the parent\n : replacementId === null\n ? null\n : this.messages.get(replacementId);\n if (replacement === undefined)\n throw new Error(\n \"MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui.\",\n );\n\n for (const child of message.children) {\n const childMessage = this.messages.get(child);\n if (!childMessage)\n throw new Error(\n \"MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui.\",\n );\n this.performOp(replacement, childMessage, \"relink\");\n }\n\n this.performOp(null, message, \"cut\");\n this.messages.delete(messageId);\n\n if (this.head === message) {\n this.head = replacement ? findHead(replacement) : null;\n }\n }\n\n getBranches(messageId: string) {\n const message = this.messages.get(messageId);\n if (!message)\n throw new Error(\n \"MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui.\",\n );\n\n const { children } = message.prev ?? this.root;\n return children;\n }\n\n switchToBranch(messageId: string) {\n const message = this.messages.get(messageId);\n if (!message)\n throw new Error(\n \"MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui.\",\n );\n\n if (message.prev) {\n message.prev.next = message;\n }\n\n this.head = findHead(message);\n }\n\n resetHead(messageId: string | null) {\n if (messageId === null) {\n this.head = null;\n return;\n }\n\n const message = this.messages.get(messageId);\n if (!message)\n throw new Error(\n \"MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui.\",\n );\n\n this.head = message;\n for (\n let current: RepositoryMessage | null = message;\n current;\n current = current.prev\n ) {\n if (current.prev) {\n current.prev.next = current;\n }\n }\n }\n}\n","import { type ModelConfigProvider } from \"../../types/ModelConfigTypes\";\nimport type { Unsubscribe } from \"../../types/Unsubscribe\";\nimport type { AssistantRuntime } from \"./AssistantRuntime\";\nimport { ReactThreadRuntime } from \"./ReactThreadRuntime\";\n\nexport abstract class BaseAssistantRuntime<\n TThreadRuntime extends ReactThreadRuntime,\n> implements AssistantRuntime\n{\n constructor(private _thread: TThreadRuntime) {\n this._thread = _thread;\n }\n\n get thread() {\n return this._thread;\n }\n\n set thread(thread: TThreadRuntime) {\n this._thread = thread;\n this.subscriptionHandler();\n }\n\n public abstract registerModelConfigProvider(\n provider: ModelConfigProvider,\n ): Unsubscribe;\n public abstract switchToThread(threadId: string | null): void;\n\n private _subscriptions = new Set<() => void>();\n\n public subscribe(callback: () => void): Unsubscribe {\n this._subscriptions.add(callback);\n return () => this._subscriptions.delete(callback);\n }\n\n private subscriptionHandler = () => {\n for (const callback of this._subscriptions) callback();\n };\n}\n","\"use client\";\n\nimport { useEffect, useMemo, useRef, useState } from \"react\";\nimport { useMessageContext } from \"../../context\";\nimport {\n ContentPartStatus,\n ToolCallContentPartStatus,\n} from \"../../types/AssistantTypes\";\nimport { TextContentPartState } from \"../../context/stores/ContentPart\";\nimport { useSmoothContext } from \"./SmoothContext\";\nimport { StoreApi } from \"zustand\";\nimport { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\n\nclass TextStreamAnimator {\n private animationFrameId: number | null = null;\n private lastUpdateTime: number = Date.now();\n\n public targetText: string = \"\";\n\n constructor(\n public currentText: string,\n private setText: (newText: string) => void,\n ) {}\n\n start() {\n if (this.animationFrameId !== null) return;\n this.lastUpdateTime = Date.now();\n this.animate();\n }\n\n stop() {\n if (this.animationFrameId !== null) {\n cancelAnimationFrame(this.animationFrameId);\n this.animationFrameId = null;\n }\n }\n\n private animate = () => {\n const currentTime = Date.now();\n const deltaTime = currentTime - this.lastUpdateTime;\n let timeToConsume = deltaTime;\n\n const remainingChars = this.targetText.length - this.currentText.length;\n const baseTimePerChar = Math.min(5, 250 / remainingChars);\n\n let charsToAdd = 0;\n while (timeToConsume >= baseTimePerChar && charsToAdd < remainingChars) {\n charsToAdd++;\n timeToConsume -= baseTimePerChar;\n }\n\n if (charsToAdd !== remainingChars) {\n this.animationFrameId = requestAnimationFrame(this.animate);\n } else {\n this.animationFrameId = null;\n }\n if (charsToAdd === 0) return;\n\n this.currentText = this.targetText.slice(\n 0,\n this.currentText.length + charsToAdd,\n );\n this.lastUpdateTime = currentTime - timeToConsume;\n this.setText(this.currentText);\n };\n}\n\nconst SMOOTH_STATUS: ContentPartStatus = Object.freeze({\n type: \"running\",\n});\n\nexport const useSmooth = (\n state: TextContentPartState,\n smooth: boolean = false,\n): TextContentPartState => {\n const { useSmoothStatus } = useSmoothContext({ optional: true }) ?? {};\n\n const {\n part: { text },\n } = state;\n const { useMessage } = useMessageContext();\n const id = useMessage((m) => m.message.id);\n\n const idRef = useRef(id);\n const [displayedText, setDisplayedText] = useState(text);\n\n const setText = useCallbackRef((text: string) => {\n setDisplayedText(text);\n (\n useSmoothStatus as unknown as\n | StoreApi<ToolCallContentPartStatus>\n | undefined\n )?.setState(text !== state.part.text ? SMOOTH_STATUS : state.status);\n });\n\n const [animatorRef] = useState<TextStreamAnimator>(\n new TextStreamAnimator(text, setText),\n );\n\n useEffect(() => {\n if (!smooth) {\n animatorRef.stop();\n return;\n }\n\n if (idRef.current !== id || !text.startsWith(animatorRef.targetText)) {\n idRef.current = id;\n setText(text);\n\n animatorRef.currentText = text;\n animatorRef.targetText = text;\n animatorRef.stop();\n\n return;\n }\n\n animatorRef.targetText = text;\n animatorRef.start();\n }, [setText, animatorRef, id, smooth, text]);\n\n useEffect(() => {\n return () => {\n animatorRef.stop();\n };\n }, [animatorRef]);\n\n return useMemo(\n () =>\n smooth\n ? {\n part: { type: \"text\", text: displayedText },\n status: text === displayedText ? state.status : SMOOTH_STATUS,\n }\n : state,\n [smooth, displayedText, state, text],\n );\n};\n","\"use client\";\n\nimport { createContext, useContext } from \"react\";\nimport type { MessageState } from \"../stores/Message\";\nimport type { EditComposerState } from \"../stores/EditComposer\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { MessageUtilsState } from \"../stores/MessageUtils\";\n\nexport type MessageContextValue = {\n useMessage: ReadonlyStore<MessageState>;\n useMessageUtils: ReadonlyStore<MessageUtilsState>;\n useEditComposer: ReadonlyStore<EditComposerState>;\n};\n\nexport const MessageContext = createContext<MessageContextValue | null>(null);\n\nexport function useMessageContext(): MessageContextValue;\nexport function useMessageContext(options: {\n optional: true;\n}): MessageContextValue | null;\nexport function useMessageContext(options?: { optional: true }) {\n const context = useContext(MessageContext);\n if (!options?.optional && !context)\n throw new Error(\n \"This component can only be used inside a component passed to <ThreadPrimitive.Messages components={...} />.\",\n );\n return context;\n}\n","\"use client\";\n\nimport { createContext, useContext } from \"react\";\nimport type { ContentPartState } from \"../stores/ContentPart\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\n\nexport type ContentPartContextValue = {\n useContentPart: ReadonlyStore<ContentPartState>;\n};\n\nexport const ContentPartContext = createContext<ContentPartContextValue | null>(\n null,\n);\n\nexport function useContentPartContext(): ContentPartContextValue;\nexport function useContentPartContext(options: {\n optional: true;\n}): ContentPartContextValue | null;\nexport function useContentPartContext(options?: { optional: true }) {\n const context = useContext(ContentPartContext);\n if (!options?.optional && !context)\n throw new Error(\n \"This component can only be used inside a component passed to <MessagePrimitive.Content components={...} >.\",\n );\n return context;\n}\n","import {\n createContext,\n FC,\n forwardRef,\n PropsWithChildren,\n useContext,\n useState,\n} from \"react\";\nimport { useContentPartContext } from \"../../context\";\nimport { ReadonlyStore } from \"../../context/ReadonlyStore\";\nimport { create } from \"zustand\";\nimport {\n ContentPartStatus,\n ToolCallContentPartStatus,\n} from \"../../types/AssistantTypes\";\n\ntype SmoothContextValue = {\n useSmoothStatus: ReadonlyStore<ToolCallContentPartStatus | ContentPartStatus>;\n};\n\nconst SmoothContext = createContext<SmoothContextValue | null>(null);\n\nconst makeSmoothContext = (\n initialState: ContentPartStatus | ToolCallContentPartStatus,\n) => {\n const useSmoothStatus = create(() => initialState);\n return { useSmoothStatus };\n};\n\nexport const SmoothContextProvider: FC<PropsWithChildren> = ({ children }) => {\n const outer = useSmoothContext({ optional: true });\n const { useContentPart } = useContentPartContext();\n\n const [context] = useState(() =>\n makeSmoothContext(useContentPart.getState().status),\n );\n\n // do not wrap if there is an outer SmoothContextProvider\n if (outer) return children;\n\n return (\n <SmoothContext.Provider value={context}>{children}</SmoothContext.Provider>\n );\n};\n\nexport const withSmoothContextProvider = <C extends React.ComponentType<any>>(\n Component: C,\n): C => {\n const Wrapped = forwardRef((props, ref) => {\n return (\n <SmoothContextProvider>\n <Component {...(props as any)} ref={ref} />\n </SmoothContextProvider>\n );\n });\n Wrapped.displayName = Component.displayName;\n return Wrapped as any;\n};\n\nexport function useSmoothContext(): SmoothContextValue;\nexport function useSmoothContext(options: {\n optional: true;\n}): SmoothContextValue | null;\nexport function useSmoothContext(options?: { optional: true }) {\n const context = useContext(SmoothContext);\n if (!options?.optional && !context)\n throw new Error(\n \"This component must be used within a SmoothContextProvider.\",\n );\n return context;\n}\n\nexport const useSmoothStatus = () => {\n const { useSmoothStatus } = useSmoothContext();\n return useSmoothStatus();\n};\n","\"use client\";\n\nimport { forwardRef } from \"react\";\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"./tooltip\";\nimport { Button, ButtonProps } from \"./button\";\n\nexport type TooltipIconButtonProps = ButtonProps & {\n tooltip: string;\n side?: \"top\" | \"bottom\" | \"left\" | \"right\";\n};\n\nexport const TooltipIconButton = forwardRef<\n HTMLButtonElement,\n TooltipIconButtonProps\n>(({ children, tooltip, side = \"bottom\", ...rest }, ref) => {\n return (\n <Tooltip>\n <TooltipTrigger asChild>\n <Button variant=\"ghost\" size=\"icon\" {...rest} ref={ref}>\n {children}\n <span className=\"aui-sr-only\">{tooltip}</span>\n </Button>\n </TooltipTrigger>\n <TooltipContent side={side}>{tooltip}</TooltipContent>\n </Tooltip>\n );\n});\n\nTooltipIconButton.displayName = \"TooltipIconButton\";\n","\"use client\";\n\nimport * as TooltipPrimitive from \"@radix-ui/react-tooltip\";\nimport { withDefaults } from \"../utils/withDefaults\";\nimport { FC } from \"react\";\n\nexport const Tooltip: FC<TooltipPrimitive.TooltipProps> = (props) => {\n return (\n <TooltipPrimitive.Provider>\n <TooltipPrimitive.Root {...props} />\n </TooltipPrimitive.Provider>\n );\n};\n\nTooltip.displayName = \"Tooltip\";\n\nexport const TooltipTrigger = TooltipPrimitive.Trigger;\n\nexport const TooltipContent = withDefaults(TooltipPrimitive.Content, {\n sideOffset: 4,\n className: \"aui-tooltip-content\",\n});\n\nTooltipContent.displayName = \"TooltipContent\";\n","import {\n ComponentPropsWithoutRef,\n ElementRef,\n ElementType,\n forwardRef,\n} from \"react\";\nimport classNames from \"classnames\";\n\nexport const withDefaultProps =\n <TProps extends { className?: string }>({\n className,\n ...defaultProps\n }: Partial<TProps>) =>\n ({ className: classNameProp, ...props }: TProps) => {\n return {\n className: classNames(className, classNameProp),\n ...defaultProps,\n ...props,\n } as TProps;\n };\n\nexport const withDefaults = <TComponent extends ElementType>(\n Component: TComponent,\n defaultProps: Partial<Omit<ComponentPropsWithoutRef<TComponent>, \"asChild\">>,\n) => {\n type TComponentProps = typeof defaultProps;\n const getProps = withDefaultProps<TComponentProps>(defaultProps);\n const WithDefaults = forwardRef<ElementRef<TComponent>, TComponentProps>(\n (props, ref) => {\n const ComponentAsAny = Component as any;\n return <ComponentAsAny {...getProps(props)} ref={ref} />;\n },\n );\n WithDefaults.displayName =\n \"withDefaults(\" +\n (typeof Component === \"string\" ? Component : Component.displayName) +\n \")\";\n return WithDefaults;\n};\n","import { cva, type VariantProps } from \"class-variance-authority\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { ElementRef, forwardRef } from \"react\";\n\nconst buttonVariants = cva(\"aui-button\", {\n variants: {\n variant: {\n default: \"aui-button-primary\",\n outline: \"aui-button-outline\",\n ghost: \"aui-button-ghost\",\n },\n size: {\n default: \"aui-button-medium\",\n icon: \"aui-button-icon\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"default\",\n },\n});\n\ntype ButtonElement = ElementRef<typeof Primitive.button>;\n\nexport type ButtonProps = React.ComponentPropsWithoutRef<\n typeof Primitive.button\n> &\n VariantProps<typeof buttonVariants>;\n\nconst Button = forwardRef<ButtonElement, ButtonProps>(\n ({ className, variant, size, ...props }, ref) => {\n return (\n <Primitive.button\n className={buttonVariants({ variant, size, className })}\n {...props}\n ref={ref}\n />\n );\n },\n);\n\nButton.displayName = \"Button\";\n\nexport { Button, buttonVariants };\n"],"mappings":";;;;;AAMO,IAAM,sBAAN,MAAyD;AAAA,EACtD,aAAa,oBAAI,IAAyB;AAAA,EAElD,iBAAiB;AACf,WAAO,kBAAkB,KAAK,UAAU;AAAA,EAC1C;AAAA,EAEA,4BAA4B,UAA+B;AACzD,SAAK,WAAW,IAAI,QAAQ;AAC5B,WAAO,MAAM;AACX,WAAK,WAAW,OAAO,QAAQ;AAAA,IACjC;AAAA,EACF;AACF;;;ACnBA,SAAS,sBAAsB;AAExB,IAAM,aAAa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;AACb,CAAC;AAED,eAAe,cAAc;;;AEvB7B,SAAS,WAA8B;AACvC,SAAS,iBAAiB;AAC1B,SAAqB,cAAAC,mBAAkB;AA8BjC,gBAAAC,YAAA;AA5BN,IAAM,iBAAiB,IAAI,cAAc;AAAA,EACvC,UAAU;AAAA,IACR,SAAS;AAAA,MACP,SAAS;AAAA,MACT,SAAS;AAAA,MACT,OAAO;AAAA,IACT;AAAA,IACA,MAAM;AAAA,MACJ,SAAS;AAAA,MACT,MAAM;AAAA,IACR;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf,SAAS;AAAA,IACT,MAAM;AAAA,EACR;AACF,CAAC;AASD,IAAM,SAASD;AAAA,EACb,CAAC,EAAE,WAAW,SAAS,MAAM,GAAG,MAAM,GAAG,QAAQ;AAC/C,WACE,gBAAAC;AAAA,MAAC,UAAU;AAAA,MAAV;AAAA,QACC,WAAW,eAAe,EAAE,SAAS,MAAM,UAAU,CAAC;AAAA,QACrD,GAAG;AAAA,QACJ;AAAA;AAAA,IACF;AAAA,EAEJ;AACF;AAEA,OAAO,cAAc;;;AHvBb,SAEE,OAAAC,MAFF;AAPD,IAAM,oBAAoBC,YAG/B,CAAC,EAAE,UAAU,SAAS,OAAO,UAAU,GAAG,KAAK,GAAG,QAAQ;AAC1D,SACE,qBAAC,WACC;AAAA,oBAAAD,KAAC,kBAAe,SAAO,MACrB,+BAAC,UAAO,SAAQ,SAAQ,MAAK,QAAQ,GAAG,MAAM,KAC3C;AAAA;AAAA,MACD,gBAAAA,KAAC,UAAK,WAAU,eAAe,mBAAQ;AAAA,OACzC,GACF;AAAA,IACA,gBAAAA,KAAC,kBAAe,MAAa,mBAAQ;AAAA,KACvC;AAEJ,CAAC;AAED,kBAAkB,cAAc;","names":["useState","createContext","useContext","createContext","useContext","createContext","useSmoothStatus","useContext","useSmoothStatus","useState","text","forwardRef","forwardRef","jsx","jsx","forwardRef","jsx","jsx","forwardRef"]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  "use strict";
2
3
  var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/tailwindcss/index.ts"],"sourcesContent":["import plugin from \"tailwindcss/plugin\";\n\ntype AssistantTailwindPluginColors = {\n border: string;\n input: string;\n ring: string;\n background: string;\n foreground: string;\n primary: {\n DEFAULT: string;\n foreground: string;\n };\n secondary: {\n DEFAULT: string;\n foreground: string;\n };\n destructive: {\n DEFAULT: string;\n foreground: string;\n };\n muted: {\n DEFAULT: string;\n foreground: string;\n };\n accent: {\n DEFAULT: string;\n foreground: string;\n };\n popover: {\n DEFAULT: string;\n foreground: string;\n };\n card: {\n DEFAULT: string;\n foreground: string;\n };\n};\n\ntype AssisstantTailwindPluginOptions = {\n components?: (\"default-theme\" | \"base\" | \"thread\" | \"assistant-modal\")[];\n colors?: AssistantTailwindPluginColors;\n shadcn?: boolean;\n};\n\nconst auiPlugin = plugin.withOptions<AssisstantTailwindPluginOptions>(\n ({ components = [\"assistant-modal\", \"thread\"], shadcn = false } = {}) =>\n ({ addComponents }) => {\n const assistantModal = components.includes(\"assistant-modal\");\n const thread = assistantModal || components.includes(\"thread\");\n const base = thread || components.includes(\"base\");\n const defaultTheme = components.includes(\"default-theme\");\n\n if (defaultTheme && shadcn)\n throw new Error(\"default-theme cannot be used with shadcn\");\n\n if (defaultTheme || (base && !shadcn)) {\n addComponents({\n '@import \"@assistant-ui/react/styles/themes/default.css\"': \"\",\n });\n }\n\n if (base) {\n addComponents({\n '@import \"@assistant-ui/react/styles/tailwindcss/base-components.css\"':\n \"\",\n });\n }\n\n if (thread) {\n addComponents({\n '@import \"@assistant-ui/react/styles/tailwindcss/thread.css\"': \"\",\n });\n }\n\n if (assistantModal) {\n addComponents({\n '@import \"@assistant-ui/react/styles/tailwindcss/modal.css\"': \"\",\n });\n }\n },\n ({ shadcn = false, colors = {} } = {}) => {\n const prefix = !shadcn ? \"--aui-\" : \"--\";\n return {\n theme: {\n extend: {\n colors: {\n aui: {\n border: colors.border ?? `hsl(var(${prefix}border))`,\n input: colors.input ?? `hsl(var(${prefix}input))`,\n ring: colors.ring ?? `hsl(var(${prefix}ring))`,\n background: colors.background ?? `hsl(var(${prefix}background))`,\n foreground: colors.foreground ?? `hsl(var(${prefix}foreground))`,\n primary: {\n DEFAULT:\n colors.primary?.DEFAULT ?? `hsl(var(${prefix}primary))`,\n foreground:\n colors.primary?.foreground ??\n `hsl(var(${prefix}primary-foreground))`,\n },\n secondary: {\n DEFAULT:\n colors.secondary?.DEFAULT ?? `hsl(var(${prefix}secondary))`,\n foreground:\n colors.secondary?.foreground ??\n `hsl(var(${prefix}secondary-foreground))`,\n },\n destructive: {\n DEFAULT:\n colors.destructive?.DEFAULT ??\n `hsl(var(${prefix}destructive))`,\n foreground: `hsl(var(${prefix}destructive-foreground))`,\n },\n muted: {\n DEFAULT: `hsl(var(${prefix}muted))`,\n foreground:\n colors.muted?.foreground ??\n `hsl(var(${prefix}muted-foreground))`,\n },\n accent: {\n DEFAULT: colors.accent?.DEFAULT ?? `hsl(var(${prefix}accent))`,\n foreground:\n colors.accent?.foreground ??\n `hsl(var(${prefix}accent-foreground))`,\n },\n popover: {\n DEFAULT:\n colors.popover?.DEFAULT ?? `hsl(var(${prefix}popover))`,\n foreground:\n colors.popover?.foreground ??\n `hsl(var(${prefix}popover-foreground))`,\n },\n card: {\n DEFAULT: colors.card?.DEFAULT ?? `hsl(var(${prefix}card))`,\n foreground:\n colors.card?.foreground ??\n `hsl(var(${prefix}card-foreground))`,\n },\n },\n },\n },\n },\n };\n },\n);\n\nexport default auiPlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAmB;AA4CnB,IAAM,YAAY,cAAAA,QAAO;AAAA,EACvB,CAAC,EAAE,aAAa,CAAC,mBAAmB,QAAQ,GAAG,SAAS,MAA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AAO,WAAW,cAClB,WAAW,MAAM;AAAA,cACrB;AAAA,cACA,aAAa;AAAA,gBACX,SACE,OAAO,aAAa,WACpB,WAAW,MAAM;AAAA,gBACnB,YAAY,WAAW,MAAM;AAAA,cAC/B;AAAA,cACA,OAAO;AAAA,gBACL,SAAS,WAAW,MAAM;AAAA,gBAC1B,YACE,OAAO,OAAO,cACd,WAAW,MAAM;AAAA,cACrB;AAAA,cACA,QAAQ;AAAA,gBACN,SAAS,OAAO,QAAQ,WAAW,WAAW,MAAM;AAAA,gBACpD,YACE,OAAO,QAAQ,cACf,WAAW,MAAM;AAAA,cACrB;AAAA,cACA,SAAS;AAAA,gBACP,SACE,OAAO,SAAS,WAAW,WAAW,MAAM;AAAA,gBAC9C,YACE,OAAO,SAAS,cAChB,WAAW,MAAM;AAAA,cACrB;AAAA,cACA,MAAM;AAAA,gBACJ,SAAS,OAAO,MAAM,WAAW,WAAW,MAAM;AAAA,gBAClD,YACE,OAAO,MAAM,cACb,WAAW,MAAM;AAAA,cACrB;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAO,sBAAQ;","names":["plugin"]}
1
+ {"version":3,"sources":["../../src/tailwindcss/index.ts"],"sourcesContent":["import plugin from \"tailwindcss/plugin\";\n\ntype AssistantTailwindPluginColors = {\n border: string;\n input: string;\n ring: string;\n background: string;\n foreground: string;\n primary: {\n DEFAULT: string;\n foreground: string;\n };\n secondary: {\n DEFAULT: string;\n foreground: string;\n };\n destructive: {\n DEFAULT: string;\n foreground: string;\n };\n muted: {\n DEFAULT: string;\n foreground: string;\n };\n accent: {\n DEFAULT: string;\n foreground: string;\n };\n popover: {\n DEFAULT: string;\n foreground: string;\n };\n card: {\n DEFAULT: string;\n foreground: string;\n };\n};\n\ntype AssisstantTailwindPluginOptions = {\n components?: (\"default-theme\" | \"base\" | \"thread\" | \"assistant-modal\")[];\n colors?: AssistantTailwindPluginColors;\n shadcn?: boolean;\n};\n\nconst auiPlugin = plugin.withOptions<AssisstantTailwindPluginOptions>(\n ({ components = [\"assistant-modal\", \"thread\"], shadcn = false } = {}) =>\n ({ addComponents }) => {\n const assistantModal = components.includes(\"assistant-modal\");\n const thread = assistantModal || components.includes(\"thread\");\n const base = thread || components.includes(\"base\");\n const defaultTheme = components.includes(\"default-theme\");\n\n if (defaultTheme && shadcn)\n throw new Error(\"default-theme cannot be used with shadcn\");\n\n if (defaultTheme || (base && !shadcn)) {\n addComponents({\n '@import \"@assistant-ui/react/styles/themes/default.css\"': \"\",\n });\n }\n\n if (base) {\n addComponents({\n '@import \"@assistant-ui/react/styles/tailwindcss/base-components.css\"':\n \"\",\n });\n }\n\n if (thread) {\n addComponents({\n '@import \"@assistant-ui/react/styles/tailwindcss/thread.css\"': \"\",\n });\n }\n\n if (assistantModal) {\n addComponents({\n '@import \"@assistant-ui/react/styles/tailwindcss/modal.css\"': \"\",\n });\n }\n },\n ({ shadcn = false, colors = {} } = {}) => {\n const prefix = !shadcn ? \"--aui-\" : \"--\";\n return {\n theme: {\n extend: {\n colors: {\n aui: {\n border: colors.border ?? `hsl(var(${prefix}border))`,\n input: colors.input ?? `hsl(var(${prefix}input))`,\n ring: colors.ring ?? `hsl(var(${prefix}ring))`,\n background: colors.background ?? `hsl(var(${prefix}background))`,\n foreground: colors.foreground ?? `hsl(var(${prefix}foreground))`,\n primary: {\n DEFAULT:\n colors.primary?.DEFAULT ?? `hsl(var(${prefix}primary))`,\n foreground:\n colors.primary?.foreground ??\n `hsl(var(${prefix}primary-foreground))`,\n },\n secondary: {\n DEFAULT:\n colors.secondary?.DEFAULT ?? `hsl(var(${prefix}secondary))`,\n foreground:\n colors.secondary?.foreground ??\n `hsl(var(${prefix}secondary-foreground))`,\n },\n destructive: {\n DEFAULT:\n colors.destructive?.DEFAULT ??\n `hsl(var(${prefix}destructive))`,\n foreground: `hsl(var(${prefix}destructive-foreground))`,\n },\n muted: {\n DEFAULT: `hsl(var(${prefix}muted))`,\n foreground:\n colors.muted?.foreground ??\n `hsl(var(${prefix}muted-foreground))`,\n },\n accent: {\n DEFAULT: colors.accent?.DEFAULT ?? `hsl(var(${prefix}accent))`,\n foreground:\n colors.accent?.foreground ??\n `hsl(var(${prefix}accent-foreground))`,\n },\n popover: {\n DEFAULT:\n colors.popover?.DEFAULT ?? `hsl(var(${prefix}popover))`,\n foreground:\n colors.popover?.foreground ??\n `hsl(var(${prefix}popover-foreground))`,\n },\n card: {\n DEFAULT: colors.card?.DEFAULT ?? `hsl(var(${prefix}card))`,\n foreground:\n colors.card?.foreground ??\n `hsl(var(${prefix}card-foreground))`,\n },\n },\n },\n },\n },\n };\n },\n);\n\nexport default auiPlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAmB;AA4CnB,IAAM,YAAY,cAAAA,QAAO;AAAA,EACvB,CAAC,EAAE,aAAa,CAAC,mBAAmB,QAAQ,GAAG,SAAS,MAAM,IAAI,CAAC,MACjE,CAAC,EAAE,cAAc,MAAM;AACrB,UAAM,iBAAiB,WAAW,SAAS,iBAAiB;AAC5D,UAAM,SAAS,kBAAkB,WAAW,SAAS,QAAQ;AAC7D,UAAM,OAAO,UAAU,WAAW,SAAS,MAAM;AACjD,UAAM,eAAe,WAAW,SAAS,eAAe;AAExD,QAAI,gBAAgB;AAClB,YAAM,IAAI,MAAM,0CAA0C;AAE5D,QAAI,gBAAiB,QAAQ,CAAC,QAAS;AACrC,oBAAc;AAAA,QACZ,2DAA2D;AAAA,MAC7D,CAAC;AAAA,IACH;AAEA,QAAI,MAAM;AACR,oBAAc;AAAA,QACZ,wEACE;AAAA,MACJ,CAAC;AAAA,IACH;AAEA,QAAI,QAAQ;AACV,oBAAc;AAAA,QACZ,+DAA+D;AAAA,MACjE,CAAC;AAAA,IACH;AAEA,QAAI,gBAAgB;AAClB,oBAAc;AAAA,QACZ,8DAA8D;AAAA,MAChE,CAAC;AAAA,IAC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b,WAAW,MAAM;AAAA,cACrB;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAO,sBAAQ;","names":["plugin"]}
@@ -1,3 +1,6 @@
1
+ "use client";
2
+ import "../chunk-BJPOCE4O.mjs";
3
+
1
4
  // src/tailwindcss/index.ts
2
5
  import plugin from "tailwindcss/plugin";
3
6
  var auiPlugin = plugin.withOptions(