@copilotkit/react-ui 0.9.0-alpha.0 → 0.9.0-alpha.10

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 (145) hide show
  1. package/.turbo/turbo-build.log +89 -86
  2. package/CHANGELOG.md +87 -0
  3. package/dist/components/chat-components/chat-list.mjs +488 -12
  4. package/dist/components/chat-components/chat-list.mjs.map +1 -1
  5. package/dist/components/chat-components/chat-message-actions.mjs +184 -7
  6. package/dist/components/chat-components/chat-message-actions.mjs.map +1 -1
  7. package/dist/components/chat-components/chat-message.mjs +440 -10
  8. package/dist/components/chat-components/chat-message.mjs.map +1 -1
  9. package/dist/components/chat-components/chat-panel.mjs +334 -9
  10. package/dist/components/chat-components/chat-panel.mjs.map +1 -1
  11. package/dist/components/chat-components/chat-scroll-anchor.mjs +48 -4
  12. package/dist/components/chat-components/chat-scroll-anchor.mjs.map +1 -1
  13. package/dist/components/chat-components/clear-history.mjs +268 -26
  14. package/dist/components/chat-components/clear-history.mjs.map +1 -1
  15. package/dist/components/chat-components/copilot-chat.mjs +931 -21
  16. package/dist/components/chat-components/copilot-chat.mjs.map +1 -1
  17. package/dist/components/chat-components/default-empty-screen.mjs +206 -7
  18. package/dist/components/chat-components/default-empty-screen.mjs.map +1 -1
  19. package/dist/components/chat-components/external-link.mjs +31 -3
  20. package/dist/components/chat-components/external-link.mjs.map +1 -1
  21. package/dist/components/chat-components/markdown.mjs +10 -3
  22. package/dist/components/chat-components/markdown.mjs.map +1 -1
  23. package/dist/components/chat-components/prompt-form.mjs +246 -8
  24. package/dist/components/chat-components/prompt-form.mjs.map +1 -1
  25. package/dist/components/chat-components/theme-toggle.mjs +133 -15
  26. package/dist/components/chat-components/theme-toggle.mjs.map +1 -1
  27. package/dist/components/chat-components/toaster.mjs +6 -3
  28. package/dist/components/chat-components/toaster.mjs.map +1 -1
  29. package/dist/components/chat-components/ui/alert-dialog.mjs +216 -5
  30. package/dist/components/chat-components/ui/alert-dialog.mjs.map +1 -1
  31. package/dist/components/chat-components/ui/badge.mjs +49 -7
  32. package/dist/components/chat-components/ui/badge.mjs.map +1 -1
  33. package/dist/components/chat-components/ui/button.mjs +88 -4
  34. package/dist/components/chat-components/ui/button.mjs.map +1 -1
  35. package/dist/components/chat-components/ui/codeblock.mjs +298 -7
  36. package/dist/components/chat-components/ui/codeblock.mjs.map +1 -1
  37. package/dist/components/chat-components/ui/dialog.mjs +94 -26
  38. package/dist/components/chat-components/ui/dialog.mjs.map +1 -1
  39. package/dist/components/chat-components/ui/dropdown-menu.mjs +61 -8
  40. package/dist/components/chat-components/ui/dropdown-menu.mjs.map +1 -1
  41. package/dist/components/chat-components/ui/icons.mjs +551 -4
  42. package/dist/components/chat-components/ui/icons.mjs.map +1 -1
  43. package/dist/components/chat-components/ui/input.mjs +48 -7
  44. package/dist/components/chat-components/ui/input.mjs.map +1 -1
  45. package/dist/components/chat-components/ui/label.mjs +51 -9
  46. package/dist/components/chat-components/ui/label.mjs.map +1 -1
  47. package/dist/components/chat-components/ui/select.mjs +113 -27
  48. package/dist/components/chat-components/ui/select.mjs.map +1 -1
  49. package/dist/components/chat-components/ui/separator.mjs +67 -4
  50. package/dist/components/chat-components/ui/separator.mjs.map +1 -1
  51. package/dist/components/chat-components/ui/sheet.mjs +93 -24
  52. package/dist/components/chat-components/ui/sheet.mjs.map +1 -1
  53. package/dist/components/chat-components/ui/switch.mjs +53 -8
  54. package/dist/components/chat-components/ui/switch.mjs.map +1 -1
  55. package/dist/components/chat-components/ui/textarea.mjs +48 -7
  56. package/dist/components/chat-components/ui/textarea.mjs.map +1 -1
  57. package/dist/components/chat-components/ui/tooltip.mjs +69 -4
  58. package/dist/components/chat-components/ui/tooltip.mjs.map +1 -1
  59. package/dist/components/index.mjs +1057 -25
  60. package/dist/components/index.mjs.map +1 -1
  61. package/dist/components/sidebar/copilot-sidebar-ui-provider.mjs +1052 -24
  62. package/dist/components/sidebar/copilot-sidebar-ui-provider.mjs.map +1 -1
  63. package/dist/components/sidebar/copilot-sidebar.mjs +974 -22
  64. package/dist/components/sidebar/copilot-sidebar.mjs.map +1 -1
  65. package/dist/components/sidebar/sidebar-context.mjs +10 -3
  66. package/dist/components/sidebar/sidebar-context.mjs.map +1 -1
  67. package/dist/context/index.mjs +0 -2
  68. package/dist/context/index.mjs.map +1 -1
  69. package/dist/hooks/index.mjs +0 -2
  70. package/dist/hooks/index.mjs.map +1 -1
  71. package/dist/hooks/use-at-bottom.mjs +21 -3
  72. package/dist/hooks/use-at-bottom.mjs.map +1 -1
  73. package/dist/hooks/use-copy-to-clipboard.mjs +27 -3
  74. package/dist/hooks/use-copy-to-clipboard.mjs.map +1 -1
  75. package/dist/hooks/use-enter-submit.mjs +16 -3
  76. package/dist/hooks/use-enter-submit.mjs.map +1 -1
  77. package/dist/index.mjs +1057 -28
  78. package/dist/index.mjs.map +1 -1
  79. package/dist/lib/utils.mjs +62 -3
  80. package/dist/lib/utils.mjs.map +1 -1
  81. package/dist/lib/utils.test.mjs +0 -1
  82. package/dist/lib/utils.test.mjs.map +1 -1
  83. package/dist/types/index.mjs +0 -2
  84. package/dist/types/index.mjs.map +1 -1
  85. package/dist/types/types.mjs +0 -2
  86. package/dist/types/types.mjs.map +1 -1
  87. package/package.json +8 -7
  88. package/src/components/chat-components/prompt-form.tsx +3 -3
  89. package/src/components/chat-components/ui/codeblock.tsx +0 -2
  90. package/dist/chunk-6LAC5RA2.mjs +0 -28
  91. package/dist/chunk-6LAC5RA2.mjs.map +0 -1
  92. package/dist/chunk-6LRNF2VU.mjs +0 -12
  93. package/dist/chunk-6LRNF2VU.mjs.map +0 -1
  94. package/dist/chunk-6UJWRTL6.mjs +0 -45
  95. package/dist/chunk-6UJWRTL6.mjs.map +0 -1
  96. package/dist/chunk-752MT4QP.mjs +0 -72
  97. package/dist/chunk-752MT4QP.mjs.map +0 -1
  98. package/dist/chunk-7NSRDJ5C.mjs +0 -3
  99. package/dist/chunk-7NSRDJ5C.mjs.map +0 -1
  100. package/dist/chunk-BHJWB2SA.mjs +0 -48
  101. package/dist/chunk-BHJWB2SA.mjs.map +0 -1
  102. package/dist/chunk-BIPCPNHG.mjs +0 -18
  103. package/dist/chunk-BIPCPNHG.mjs.map +0 -1
  104. package/dist/chunk-BS6RR2DJ.mjs +0 -25
  105. package/dist/chunk-BS6RR2DJ.mjs.map +0 -1
  106. package/dist/chunk-DHK56U5Z.mjs +0 -106
  107. package/dist/chunk-DHK56U5Z.mjs.map +0 -1
  108. package/dist/chunk-DOMJCSI6.mjs +0 -26
  109. package/dist/chunk-DOMJCSI6.mjs.map +0 -1
  110. package/dist/chunk-H4VKQGVU.mjs +0 -3
  111. package/dist/chunk-H4VKQGVU.mjs.map +0 -1
  112. package/dist/chunk-I2AB5FK4.mjs +0 -123
  113. package/dist/chunk-I2AB5FK4.mjs.map +0 -1
  114. package/dist/chunk-IU3WTXLQ.mjs +0 -3
  115. package/dist/chunk-IU3WTXLQ.mjs.map +0 -1
  116. package/dist/chunk-JUGCIZPN.mjs +0 -69
  117. package/dist/chunk-JUGCIZPN.mjs.map +0 -1
  118. package/dist/chunk-JUPNM7ZR.mjs +0 -75
  119. package/dist/chunk-JUPNM7ZR.mjs.map +0 -1
  120. package/dist/chunk-KR7MH7XO.mjs +0 -481
  121. package/dist/chunk-KR7MH7XO.mjs.map +0 -1
  122. package/dist/chunk-KXJV37FS.mjs +0 -33
  123. package/dist/chunk-KXJV37FS.mjs.map +0 -1
  124. package/dist/chunk-MC6KTH4X.mjs +0 -12
  125. package/dist/chunk-MC6KTH4X.mjs.map +0 -1
  126. package/dist/chunk-MRXNTQOX.mjs +0 -55
  127. package/dist/chunk-MRXNTQOX.mjs.map +0 -1
  128. package/dist/chunk-N7KB3Z57.mjs +0 -23
  129. package/dist/chunk-N7KB3Z57.mjs.map +0 -1
  130. package/dist/chunk-RSONJDLO.mjs +0 -28
  131. package/dist/chunk-RSONJDLO.mjs.map +0 -1
  132. package/dist/chunk-RVWZKSLL.mjs +0 -29
  133. package/dist/chunk-RVWZKSLL.mjs.map +0 -1
  134. package/dist/chunk-TVTG3V4F.mjs +0 -40
  135. package/dist/chunk-TVTG3V4F.mjs.map +0 -1
  136. package/dist/chunk-U6NJWGTV.mjs +0 -3
  137. package/dist/chunk-U6NJWGTV.mjs.map +0 -1
  138. package/dist/chunk-V6QYUEJR.mjs +0 -47
  139. package/dist/chunk-V6QYUEJR.mjs.map +0 -1
  140. package/dist/chunk-VQNV2DHJ.mjs +0 -142
  141. package/dist/chunk-VQNV2DHJ.mjs.map +0 -1
  142. package/dist/chunk-VSNDSL6W.mjs +0 -74
  143. package/dist/chunk-VSNDSL6W.mjs.map +0 -1
  144. package/dist/chunk-ZAS4O7XI.mjs +0 -53
  145. package/dist/chunk-ZAS4O7XI.mjs.map +0 -1
@@ -1,25 +1,1053 @@
1
- export { CopilotSidebarUIProvider } from '../../chunk-752MT4QP.mjs';
2
- import '../../chunk-BHJWB2SA.mjs';
3
- import '../../chunk-ZAS4O7XI.mjs';
4
- import '../../chunk-JUGCIZPN.mjs';
5
- import '../../chunk-DHK56U5Z.mjs';
6
- import '../../chunk-BS6RR2DJ.mjs';
7
- import '../../chunk-RSONJDLO.mjs';
8
- import '../../chunk-VSNDSL6W.mjs';
9
- import '../../chunk-KXJV37FS.mjs';
10
- import '../../chunk-BIPCPNHG.mjs';
11
- import '../../chunk-MC6KTH4X.mjs';
12
- import '../../chunk-RVWZKSLL.mjs';
13
- import '../../chunk-DOMJCSI6.mjs';
14
- import '../../chunk-JUPNM7ZR.mjs';
15
- import '../../chunk-VQNV2DHJ.mjs';
16
- import '../../chunk-6LRNF2VU.mjs';
17
- import '../../chunk-6UJWRTL6.mjs';
18
- import '../../chunk-V6QYUEJR.mjs';
19
- import '../../chunk-KR7MH7XO.mjs';
20
- import '../../chunk-TVTG3V4F.mjs';
21
- import '../../chunk-N7KB3Z57.mjs';
22
- import '../../chunk-6LAC5RA2.mjs';
23
- import '../../chunk-MRXNTQOX.mjs';
24
- //# sourceMappingURL=out.js.map
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
32
+ var __async = (__this, __arguments, generator) => {
33
+ return new Promise((resolve, reject) => {
34
+ var fulfilled = (value) => {
35
+ try {
36
+ step(generator.next(value));
37
+ } catch (e) {
38
+ reject(e);
39
+ }
40
+ };
41
+ var rejected = (value) => {
42
+ try {
43
+ step(generator.throw(value));
44
+ } catch (e) {
45
+ reject(e);
46
+ }
47
+ };
48
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
49
+ step((generator = generator.apply(__this, __arguments)).next());
50
+ });
51
+ };
52
+
53
+ // src/components/sidebar/copilot-sidebar-ui-provider.tsx
54
+ import { useCallback } from "react";
55
+ import { useState as useState3 } from "react";
56
+
57
+ // src/components/chat-components/ui/separator.tsx
58
+ import * as React from "react";
59
+ import * as SeparatorPrimitive from "@radix-ui/react-separator";
60
+
61
+ // src/lib/utils.ts
62
+ import { clsx } from "clsx";
63
+ import { customAlphabet } from "nanoid";
64
+ import { twMerge } from "tailwind-merge";
65
+ function cn(...inputs) {
66
+ return twMerge(clsx(inputs));
67
+ }
68
+ var nanoid = customAlphabet(
69
+ "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
70
+ 7
71
+ );
72
+
73
+ // src/components/chat-components/ui/separator.tsx
74
+ import { jsx } from "react/jsx-runtime";
75
+ "use client";
76
+ var Separator = React.forwardRef(
77
+ (_a, ref) => {
78
+ var _b = _a, { className, orientation = "horizontal", decorative = true } = _b, props = __objRest(_b, ["className", "orientation", "decorative"]);
79
+ return /* @__PURE__ */ jsx(SeparatorPrimitive.Root, __spreadValues({
80
+ ref,
81
+ decorative,
82
+ orientation,
83
+ className: cn(
84
+ "shrink-0 bg-border",
85
+ orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
86
+ className
87
+ )
88
+ }, props));
89
+ }
90
+ );
91
+ Separator.displayName = SeparatorPrimitive.Root.displayName;
92
+
93
+ // src/components/chat-components/chat-message.tsx
94
+ import remarkGfm from "remark-gfm";
95
+ import remarkMath from "remark-math";
96
+
97
+ // src/components/chat-components/ui/codeblock.tsx
98
+ import { memo } from "react";
99
+ import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
100
+
101
+ // src/hooks/use-copy-to-clipboard.tsx
102
+ import * as React2 from "react";
103
+ "use client";
104
+ function useCopyToClipboard({
105
+ timeout = 2e3
106
+ }) {
107
+ const [isCopied, setIsCopied] = React2.useState(false);
108
+ const copyToClipboard = (value) => {
109
+ var _a;
110
+ if (typeof window === "undefined" || !((_a = navigator.clipboard) == null ? void 0 : _a.writeText)) {
111
+ return;
112
+ }
113
+ if (!value) {
114
+ return;
115
+ }
116
+ navigator.clipboard.writeText(value).then(() => {
117
+ setIsCopied(true);
118
+ setTimeout(() => {
119
+ setIsCopied(false);
120
+ }, timeout);
121
+ });
122
+ };
123
+ return { isCopied, copyToClipboard };
124
+ }
125
+
126
+ // src/components/chat-components/ui/icons.tsx
127
+ import * as React3 from "react";
128
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
129
+ "use client";
130
+ function IconOpenAI(_a) {
131
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
132
+ return /* @__PURE__ */ jsxs("svg", __spreadProps(__spreadValues({
133
+ fill: "currentColor",
134
+ viewBox: "0 0 24 24",
135
+ role: "img",
136
+ xmlns: "http://www.w3.org/2000/svg",
137
+ className: cn("h-4 w-4", className)
138
+ }, props), {
139
+ children: [
140
+ /* @__PURE__ */ jsx2("title", {
141
+ children: "OpenAI icon"
142
+ }),
143
+ /* @__PURE__ */ jsx2("path", {
144
+ d: "M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z"
145
+ })
146
+ ]
147
+ }));
148
+ }
149
+ function IconArrowRight(_a) {
150
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
151
+ return /* @__PURE__ */ jsx2("svg", __spreadProps(__spreadValues({
152
+ xmlns: "http://www.w3.org/2000/svg",
153
+ viewBox: "0 0 256 256",
154
+ fill: "currentColor",
155
+ className: cn("h-4 w-4", className)
156
+ }, props), {
157
+ children: /* @__PURE__ */ jsx2("path", {
158
+ d: "m221.66 133.66-72 72a8 8 0 0 1-11.32-11.32L196.69 136H40a8 8 0 0 1 0-16h156.69l-58.35-58.34a8 8 0 0 1 11.32-11.32l72 72a8 8 0 0 1 0 11.32Z"
159
+ })
160
+ }));
161
+ }
162
+ function IconUser(_a) {
163
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
164
+ return /* @__PURE__ */ jsx2("svg", __spreadProps(__spreadValues({
165
+ xmlns: "http://www.w3.org/2000/svg",
166
+ viewBox: "0 0 256 256",
167
+ fill: "currentColor",
168
+ className: cn("h-4 w-4", className)
169
+ }, props), {
170
+ children: /* @__PURE__ */ jsx2("path", {
171
+ d: "M230.92 212c-15.23-26.33-38.7-45.21-66.09-54.16a72 72 0 1 0-73.66 0c-27.39 8.94-50.86 27.82-66.09 54.16a8 8 0 1 0 13.85 8c18.84-32.56 52.14-52 89.07-52s70.23 19.44 89.07 52a8 8 0 1 0 13.85-8ZM72 96a56 56 0 1 1 56 56 56.06 56.06 0 0 1-56-56Z"
172
+ })
173
+ }));
174
+ }
175
+ function IconArrowElbow(_a) {
176
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
177
+ return /* @__PURE__ */ jsx2("svg", __spreadProps(__spreadValues({
178
+ xmlns: "http://www.w3.org/2000/svg",
179
+ viewBox: "0 0 256 256",
180
+ fill: "currentColor",
181
+ className: cn("h-4 w-4", className)
182
+ }, props), {
183
+ children: /* @__PURE__ */ jsx2("path", {
184
+ d: "M200 32v144a8 8 0 0 1-8 8H67.31l34.35 34.34a8 8 0 0 1-11.32 11.32l-48-48a8 8 0 0 1 0-11.32l48-48a8 8 0 0 1 11.32 11.32L67.31 168H184V32a8 8 0 0 1 16 0Z"
185
+ })
186
+ }));
187
+ }
188
+ function IconRefresh(_a) {
189
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
190
+ return /* @__PURE__ */ jsx2("svg", __spreadProps(__spreadValues({
191
+ xmlns: "http://www.w3.org/2000/svg",
192
+ viewBox: "0 0 256 256",
193
+ fill: "currentColor",
194
+ className: cn("h-4 w-4", className)
195
+ }, props), {
196
+ children: /* @__PURE__ */ jsx2("path", {
197
+ d: "M197.67 186.37a8 8 0 0 1 0 11.29C196.58 198.73 170.82 224 128 224c-37.39 0-64.53-22.4-80-39.85V208a8 8 0 0 1-16 0v-48a8 8 0 0 1 8-8h48a8 8 0 0 1 0 16H55.44C67.76 183.35 93 208 128 208c36 0 58.14-21.46 58.36-21.68a8 8 0 0 1 11.31.05ZM216 40a8 8 0 0 0-8 8v23.85C192.53 54.4 165.39 32 128 32c-42.82 0-68.58 25.27-69.66 26.34a8 8 0 0 0 11.3 11.34C69.86 69.46 92 48 128 48c35 0 60.24 24.65 72.56 40H168a8 8 0 0 0 0 16h48a8 8 0 0 0 8-8V48a8 8 0 0 0-8-8Z"
198
+ })
199
+ }));
200
+ }
201
+ function IconStop(_a) {
202
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
203
+ return /* @__PURE__ */ jsx2("svg", __spreadProps(__spreadValues({
204
+ xmlns: "http://www.w3.org/2000/svg",
205
+ viewBox: "0 0 256 256",
206
+ fill: "currentColor",
207
+ className: cn("h-4 w-4", className)
208
+ }, props), {
209
+ children: /* @__PURE__ */ jsx2("path", {
210
+ d: "M128 24a104 104 0 1 0 104 104A104.11 104.11 0 0 0 128 24Zm0 192a88 88 0 1 1 88-88 88.1 88.1 0 0 1-88 88Zm24-120h-48a8 8 0 0 0-8 8v48a8 8 0 0 0 8 8h48a8 8 0 0 0 8-8v-48a8 8 0 0 0-8-8Zm-8 48h-32v-32h32Z"
211
+ })
212
+ }));
213
+ }
214
+ function IconCopy(_a) {
215
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
216
+ return /* @__PURE__ */ jsx2("svg", __spreadProps(__spreadValues({
217
+ xmlns: "http://www.w3.org/2000/svg",
218
+ viewBox: "0 0 256 256",
219
+ fill: "currentColor",
220
+ className: cn("h-4 w-4", className)
221
+ }, props), {
222
+ children: /* @__PURE__ */ jsx2("path", {
223
+ d: "M216 32H88a8 8 0 0 0-8 8v40H40a8 8 0 0 0-8 8v128a8 8 0 0 0 8 8h128a8 8 0 0 0 8-8v-40h40a8 8 0 0 0 8-8V40a8 8 0 0 0-8-8Zm-56 176H48V96h112Zm48-48h-32V88a8 8 0 0 0-8-8H96V48h112Z"
224
+ })
225
+ }));
226
+ }
227
+ function IconCheck(_a) {
228
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
229
+ return /* @__PURE__ */ jsx2("svg", __spreadProps(__spreadValues({
230
+ xmlns: "http://www.w3.org/2000/svg",
231
+ viewBox: "0 0 256 256",
232
+ fill: "currentColor",
233
+ className: cn("h-4 w-4", className)
234
+ }, props), {
235
+ children: /* @__PURE__ */ jsx2("path", {
236
+ d: "m229.66 77.66-128 128a8 8 0 0 1-11.32 0l-56-56a8 8 0 0 1 11.32-11.32L96 188.69 218.34 66.34a8 8 0 0 1 11.32 11.32Z"
237
+ })
238
+ }));
239
+ }
240
+ function IconDownload(_a) {
241
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
242
+ return /* @__PURE__ */ jsx2("svg", __spreadProps(__spreadValues({
243
+ xmlns: "http://www.w3.org/2000/svg",
244
+ viewBox: "0 0 256 256",
245
+ fill: "currentColor",
246
+ className: cn("h-4 w-4", className)
247
+ }, props), {
248
+ children: /* @__PURE__ */ jsx2("path", {
249
+ d: "M224 152v56a16 16 0 0 1-16 16H48a16 16 0 0 1-16-16v-56a8 8 0 0 1 16 0v56h160v-56a8 8 0 0 1 16 0Zm-101.66 5.66a8 8 0 0 0 11.32 0l40-40a8 8 0 0 0-11.32-11.32L136 132.69V40a8 8 0 0 0-16 0v92.69l-26.34-26.35a8 8 0 0 0-11.32 11.32Z"
250
+ })
251
+ }));
252
+ }
253
+
254
+ // src/components/chat-components/ui/button.tsx
255
+ import * as React4 from "react";
256
+ import { Slot } from "@radix-ui/react-slot";
257
+ import { cva } from "class-variance-authority";
258
+ import { jsx as jsx3 } from "react/jsx-runtime";
259
+ var buttonVariants = cva(
260
+ "inline-flex items-center justify-center rounded-md text-sm font-medium shadow ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
261
+ {
262
+ variants: {
263
+ variant: {
264
+ default: "bg-primary text-primary-foreground shadow-md hover:bg-primary/90",
265
+ destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
266
+ outline: "border border-input hover:bg-accent hover:text-accent-foreground",
267
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
268
+ ghost: "shadow-none hover:bg-accent hover:text-accent-foreground",
269
+ link: "text-primary underline-offset-4 shadow-none hover:underline"
270
+ },
271
+ size: {
272
+ default: "h-8 px-4 py-2",
273
+ sm: "h-8 rounded-md px-3",
274
+ lg: "h-11 rounded-md px-8",
275
+ icon: "h-8 w-8 p-0"
276
+ }
277
+ },
278
+ defaultVariants: {
279
+ variant: "default",
280
+ size: "default"
281
+ }
282
+ }
283
+ );
284
+ var Button = React4.forwardRef(
285
+ (_a, ref) => {
286
+ var _b = _a, { className, variant, size, asChild = false } = _b, props = __objRest(_b, ["className", "variant", "size", "asChild"]);
287
+ const Comp = asChild ? Slot : "button";
288
+ return /* @__PURE__ */ jsx3(Comp, __spreadValues({
289
+ className: cn(buttonVariants({ variant, size, className })),
290
+ ref
291
+ }, props));
292
+ }
293
+ );
294
+ Button.displayName = "Button";
295
+
296
+ // src/components/chat-components/ui/codeblock.tsx
297
+ import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
298
+ "use client";
299
+ var programmingLanguages = {
300
+ javascript: ".js",
301
+ python: ".py",
302
+ java: ".java",
303
+ c: ".c",
304
+ cpp: ".cpp",
305
+ "c++": ".cpp",
306
+ "c#": ".cs",
307
+ ruby: ".rb",
308
+ php: ".php",
309
+ swift: ".swift",
310
+ "objective-c": ".m",
311
+ kotlin: ".kt",
312
+ typescript: ".ts",
313
+ go: ".go",
314
+ perl: ".pl",
315
+ rust: ".rs",
316
+ scala: ".scala",
317
+ haskell: ".hs",
318
+ lua: ".lua",
319
+ shell: ".sh",
320
+ sql: ".sql",
321
+ html: ".html",
322
+ css: ".css"
323
+ };
324
+ var generateRandomString = (length, lowercase = false) => {
325
+ const chars = "ABCDEFGHJKLMNPQRSTUVWXY3456789";
326
+ let result = "";
327
+ for (let i = 0; i < length; i++) {
328
+ result += chars.charAt(Math.floor(Math.random() * chars.length));
329
+ }
330
+ return lowercase ? result.toLowerCase() : result;
331
+ };
332
+ var CodeBlock = memo(({ language, value }) => {
333
+ const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2e3 });
334
+ const downloadAsFile = () => {
335
+ if (typeof window === "undefined") {
336
+ return;
337
+ }
338
+ const fileExtension = programmingLanguages[language] || ".file";
339
+ const suggestedFileName = `file-${generateRandomString(
340
+ 3,
341
+ true
342
+ )}${fileExtension}`;
343
+ const fileName = window.prompt("Enter file name", suggestedFileName);
344
+ if (!fileName) {
345
+ return;
346
+ }
347
+ const blob = new Blob([value], { type: "text/plain" });
348
+ const url = URL.createObjectURL(blob);
349
+ const link = document.createElement("a");
350
+ link.download = fileName;
351
+ link.href = url;
352
+ link.style.display = "none";
353
+ document.body.appendChild(link);
354
+ link.click();
355
+ document.body.removeChild(link);
356
+ URL.revokeObjectURL(url);
357
+ };
358
+ const onCopy = () => {
359
+ if (isCopied)
360
+ return;
361
+ copyToClipboard(value);
362
+ };
363
+ return /* @__PURE__ */ jsxs2("div", {
364
+ className: "codeblock relative w-full bg-zinc-950 font-sans",
365
+ children: [
366
+ /* @__PURE__ */ jsxs2("div", {
367
+ className: "flex w-full items-center justify-between bg-zinc-800 px-6 py-2 pr-4 text-zinc-100",
368
+ children: [
369
+ /* @__PURE__ */ jsx4("span", {
370
+ className: "text-xs lowercase",
371
+ children: language
372
+ }),
373
+ /* @__PURE__ */ jsxs2("div", {
374
+ className: "flex items-center space-x-1",
375
+ children: [
376
+ /* @__PURE__ */ jsxs2(Button, {
377
+ variant: "ghost",
378
+ className: "hover:bg-zinc-800 focus-visible:ring-1 focus-visible:ring-slate-700 focus-visible:ring-offset-0",
379
+ onClick: downloadAsFile,
380
+ size: "icon",
381
+ children: [
382
+ /* @__PURE__ */ jsx4(IconDownload, {}),
383
+ /* @__PURE__ */ jsx4("span", {
384
+ className: "sr-only",
385
+ children: "Download"
386
+ })
387
+ ]
388
+ }),
389
+ /* @__PURE__ */ jsxs2(Button, {
390
+ variant: "ghost",
391
+ size: "icon",
392
+ className: "text-xs hover:bg-zinc-800 focus-visible:ring-1 focus-visible:ring-slate-700 focus-visible:ring-offset-0",
393
+ onClick: onCopy,
394
+ children: [
395
+ isCopied ? /* @__PURE__ */ jsx4(IconCheck, {}) : /* @__PURE__ */ jsx4(IconCopy, {}),
396
+ /* @__PURE__ */ jsx4("span", {
397
+ className: "sr-only",
398
+ children: "Copy code"
399
+ })
400
+ ]
401
+ })
402
+ ]
403
+ })
404
+ ]
405
+ }),
406
+ /* @__PURE__ */ jsx4(SyntaxHighlighter, {
407
+ language,
408
+ PreTag: "div",
409
+ showLineNumbers: true,
410
+ customStyle: {
411
+ margin: 0,
412
+ width: "100%",
413
+ background: "transparent",
414
+ padding: "1.5rem 1rem"
415
+ },
416
+ codeTagProps: {
417
+ style: {
418
+ fontSize: "0.9rem",
419
+ fontFamily: "var(--font-mono)"
420
+ }
421
+ },
422
+ children: value
423
+ })
424
+ ]
425
+ });
426
+ });
427
+ CodeBlock.displayName = "CodeBlock";
428
+
429
+ // src/components/chat-components/markdown.tsx
430
+ import { memo as memo2 } from "react";
431
+ import ReactMarkdown from "react-markdown";
432
+ var MemoizedReactMarkdown = memo2(
433
+ ReactMarkdown,
434
+ (prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.className === nextProps.className
435
+ );
436
+
437
+ // src/components/chat-components/chat-message-actions.tsx
438
+ import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
439
+ "use client";
440
+ function ChatMessageActions(_a) {
441
+ var _b = _a, {
442
+ message,
443
+ className
444
+ } = _b, props = __objRest(_b, [
445
+ "message",
446
+ "className"
447
+ ]);
448
+ const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2e3 });
449
+ const onCopy = () => {
450
+ if (isCopied)
451
+ return;
452
+ copyToClipboard(message.content);
453
+ };
454
+ return /* @__PURE__ */ jsx5("div", __spreadProps(__spreadValues({
455
+ className: cn(
456
+ "flex items-center justify-end transition-opacity group-hover:opacity-100 md:absolute md:-right-10 md:-top-2 md:opacity-0",
457
+ className
458
+ )
459
+ }, props), {
460
+ children: /* @__PURE__ */ jsxs3(Button, {
461
+ variant: "ghost",
462
+ size: "icon",
463
+ onClick: onCopy,
464
+ children: [
465
+ isCopied ? /* @__PURE__ */ jsx5(IconCheck, {}) : /* @__PURE__ */ jsx5(IconCopy, {}),
466
+ /* @__PURE__ */ jsx5("span", {
467
+ className: "sr-only",
468
+ children: "Copy message"
469
+ })
470
+ ]
471
+ })
472
+ }));
473
+ }
474
+
475
+ // src/components/chat-components/chat-message.tsx
476
+ import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
477
+ function ChatMessage(_a) {
478
+ var _b = _a, { message } = _b, props = __objRest(_b, ["message"]);
479
+ return /* @__PURE__ */ jsxs4("div", __spreadProps(__spreadValues({
480
+ className: cn("group relative mb-4 flex items-start")
481
+ }, props), {
482
+ children: [
483
+ /* @__PURE__ */ jsx6("div", {
484
+ className: cn(
485
+ "flex h-8 w-8 shrink-0 select-none items-center justify-center rounded-md border shadow",
486
+ message.role === "user" ? "bg-background" : "bg-primary text-primary-foreground"
487
+ ),
488
+ children: message.role === "user" ? /* @__PURE__ */ jsx6(IconUser, {}) : /* @__PURE__ */ jsx6(IconOpenAI, {})
489
+ }),
490
+ /* @__PURE__ */ jsxs4("div", {
491
+ className: "ml-4 flex-1 space-y-2 overflow-hidden px-1",
492
+ children: [
493
+ /* @__PURE__ */ jsx6(MemoizedReactMarkdown, {
494
+ className: "prose break-words dark:prose-invert prose-p:leading-relaxed prose-pre:p-0 text-sm",
495
+ remarkPlugins: [remarkGfm, remarkMath],
496
+ components: {
497
+ p({ children }) {
498
+ return /* @__PURE__ */ jsx6("p", {
499
+ className: "mb-2 last:mb-0",
500
+ children
501
+ });
502
+ },
503
+ code(_a2) {
504
+ var _b2 = _a2, { children, className, inline } = _b2, props2 = __objRest(_b2, ["children", "className", "inline"]);
505
+ if (children.length) {
506
+ if (children[0] == "\u258D") {
507
+ return /* @__PURE__ */ jsx6("span", {
508
+ className: "mt-1 animate-pulse cursor-default",
509
+ children: "\u258D"
510
+ });
511
+ }
512
+ children[0] = children[0].replace("`\u258D`", "\u258D");
513
+ }
514
+ const match = /language-(\w+)/.exec(className || "");
515
+ if (inline) {
516
+ return /* @__PURE__ */ jsx6("code", __spreadProps(__spreadValues({
517
+ className
518
+ }, props2), {
519
+ children
520
+ }));
521
+ }
522
+ return /* @__PURE__ */ jsx6(CodeBlock, __spreadValues({
523
+ language: match && match[1] || "",
524
+ value: String(children).replace(/\n$/, "")
525
+ }, props2), Math.random());
526
+ }
527
+ },
528
+ children: message.content
529
+ }),
530
+ /* @__PURE__ */ jsx6(ChatMessageActions, {
531
+ message
532
+ })
533
+ ]
534
+ })
535
+ ]
536
+ }));
537
+ }
538
+
539
+ // src/components/chat-components/chat-list.tsx
540
+ import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
541
+ function ChatList({ messages }) {
542
+ const displayedMessages = messages.filter(
543
+ (message) => message.role !== "system"
544
+ );
545
+ if (!displayedMessages.length) {
546
+ return null;
547
+ }
548
+ return /* @__PURE__ */ jsx7("div", {
549
+ className: "relative mx-auto max-w-2xl px-0",
550
+ children: displayedMessages.map((message, index) => /* @__PURE__ */ jsxs5("div", {
551
+ children: [
552
+ /* @__PURE__ */ jsx7(ChatMessage, {
553
+ message
554
+ }),
555
+ index < displayedMessages.length - 1 && /* @__PURE__ */ jsx7(Separator, {
556
+ className: "my-4 md:my-4"
557
+ })
558
+ ]
559
+ }, index))
560
+ });
561
+ }
562
+
563
+ // src/components/chat-components/prompt-form.tsx
564
+ import * as React6 from "react";
565
+ import TextareaAutosize from "react-textarea-autosize";
566
+
567
+ // src/hooks/use-enter-submit.tsx
568
+ import { useRef } from "react";
569
+ function useEnterSubmit() {
570
+ const formRef = useRef(null);
571
+ const handleKeyDown = (event) => {
572
+ var _a;
573
+ if (event.key === "Enter" && !event.shiftKey && !event.nativeEvent.isComposing) {
574
+ (_a = formRef.current) == null ? void 0 : _a.requestSubmit();
575
+ event.preventDefault();
576
+ }
577
+ };
578
+ return { formRef, onKeyDown: handleKeyDown };
579
+ }
580
+
581
+ // src/components/chat-components/ui/tooltip.tsx
582
+ import * as React5 from "react";
583
+ import * as TooltipPrimitive from "@radix-ui/react-tooltip";
584
+ import { jsx as jsx8 } from "react/jsx-runtime";
585
+ "use client";
586
+ var TooltipProvider = TooltipPrimitive.Provider;
587
+ var Tooltip = TooltipPrimitive.Root;
588
+ var TooltipTrigger = TooltipPrimitive.Trigger;
589
+ var TooltipContent = React5.forwardRef((_a, ref) => {
590
+ var _b = _a, { className, sideOffset = 4 } = _b, props = __objRest(_b, ["className", "sideOffset"]);
591
+ return /* @__PURE__ */ jsx8(TooltipPrimitive.Content, __spreadValues({
592
+ ref,
593
+ sideOffset,
594
+ className: cn(
595
+ "z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-xs font-medium text-popover-foreground shadow-md animate-in fade-in-50 data-[side=bottom]:slide-in-from-top-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1",
596
+ className
597
+ )
598
+ }, props));
599
+ });
600
+ TooltipContent.displayName = TooltipPrimitive.Content.displayName;
601
+
602
+ // src/components/chat-components/prompt-form.tsx
603
+ import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
604
+ function PromptForm({
605
+ onSubmit,
606
+ input,
607
+ setInput,
608
+ isLoading
609
+ }) {
610
+ const { formRef, onKeyDown } = useEnterSubmit();
611
+ const inputRef = React6.useRef(null);
612
+ React6.useEffect(() => {
613
+ if (inputRef.current) {
614
+ inputRef.current.focus();
615
+ }
616
+ }, []);
617
+ return /* @__PURE__ */ jsx9("form", {
618
+ onSubmit: (e) => __async(this, null, function* () {
619
+ e.preventDefault();
620
+ if (!(input == null ? void 0 : input.trim())) {
621
+ return;
622
+ }
623
+ setInput("");
624
+ yield onSubmit(input);
625
+ }),
626
+ ref: formRef,
627
+ children: /* @__PURE__ */ jsxs6("div", {
628
+ className: "relative flex max-h-60 w-full grow flex-col overflow-hidden bg-background px-8 sm:rounded-md border sm:px-12",
629
+ children: [
630
+ /* @__PURE__ */ jsxs6(Tooltip, {
631
+ children: [
632
+ /* @__PURE__ */ jsx9(TooltipTrigger, {
633
+ asChild: true
634
+ }),
635
+ /* @__PURE__ */ jsx9(TooltipContent, {
636
+ children: "New Chat"
637
+ })
638
+ ]
639
+ }),
640
+ /* @__PURE__ */ jsx9(TextareaAutosize, {
641
+ ref: inputRef,
642
+ tabIndex: 0,
643
+ onKeyDown,
644
+ rows: 1,
645
+ value: input,
646
+ onChange: (e) => setInput(e.target.value),
647
+ placeholder: "Send a message.",
648
+ spellCheck: false,
649
+ className: "min-h-[60px] w-full resize-none bg-transparent px-4 py-[1.3rem] focus-within:outline-none sm:text-sm"
650
+ }),
651
+ /* @__PURE__ */ jsx9("div", {
652
+ className: "absolute right-0 top-4 sm:right-4",
653
+ children: /* @__PURE__ */ jsxs6(Tooltip, {
654
+ children: [
655
+ /* @__PURE__ */ jsx9(TooltipTrigger, {
656
+ asChild: true,
657
+ children: /* @__PURE__ */ jsxs6(Button, {
658
+ type: "submit",
659
+ size: "icon",
660
+ disabled: isLoading || input === "",
661
+ className: " bg-slate-300",
662
+ children: [
663
+ /* @__PURE__ */ jsx9(IconArrowElbow, {}),
664
+ /* @__PURE__ */ jsx9("span", {
665
+ className: "sr-only",
666
+ children: "Send message"
667
+ })
668
+ ]
669
+ })
670
+ }),
671
+ /* @__PURE__ */ jsx9(TooltipContent, {
672
+ children: "Send message"
673
+ })
674
+ ]
675
+ })
676
+ })
677
+ ]
678
+ })
679
+ });
680
+ }
681
+
682
+ // src/components/chat-components/chat-panel.tsx
683
+ import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
684
+ function ChatPanel({
685
+ id,
686
+ isLoading,
687
+ stop,
688
+ append,
689
+ reload,
690
+ input,
691
+ setInput,
692
+ messages
693
+ }) {
694
+ return /* @__PURE__ */ jsx10("div", {
695
+ className: "inset-x-0 bottom-0 bg-gradient-to-b from-muted/10 from-10% to-muted/30 to-50% mt-4 mb-8",
696
+ style: { width: "100%", overflow: "hidden", boxSizing: "border-box" },
697
+ children: /* @__PURE__ */ jsxs7("div", {
698
+ className: "mx-auto sm:max-w-2xl sm:px-4",
699
+ children: [
700
+ /* @__PURE__ */ jsx10("div", {
701
+ className: "flex h-10 items-center justify-center mb-4",
702
+ children: isLoading ? /* @__PURE__ */ jsxs7(Button, {
703
+ variant: "outline",
704
+ onClick: () => stop(),
705
+ className: "bg-background",
706
+ children: [
707
+ /* @__PURE__ */ jsx10(IconStop, {
708
+ className: "mr-2"
709
+ }),
710
+ "Stop generating"
711
+ ]
712
+ }) : (messages == null ? void 0 : messages.length) > 0 && /* @__PURE__ */ jsxs7(Button, {
713
+ variant: "outline",
714
+ onClick: () => reload(),
715
+ className: "bg-background",
716
+ children: [
717
+ /* @__PURE__ */ jsx10(IconRefresh, {
718
+ className: "mr-2"
719
+ }),
720
+ "Regenerate response"
721
+ ]
722
+ })
723
+ }),
724
+ /* @__PURE__ */ jsx10("div", {
725
+ className: "space-y-4 border-2 bg-background px-4 py-2 shadow-lg sm:rounded-xl md:py-4",
726
+ children: /* @__PURE__ */ jsx10(PromptForm, {
727
+ onSubmit: (value) => __async(this, null, function* () {
728
+ yield append({
729
+ id,
730
+ content: value,
731
+ role: "user"
732
+ });
733
+ }),
734
+ input,
735
+ setInput,
736
+ isLoading
737
+ })
738
+ })
739
+ ]
740
+ })
741
+ });
742
+ }
743
+
744
+ // src/components/chat-components/external-link.tsx
745
+ import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
746
+ function ExternalLink({
747
+ href,
748
+ children
749
+ }) {
750
+ return /* @__PURE__ */ jsxs8("a", {
751
+ href,
752
+ target: "_blank",
753
+ className: "inline-flex flex-1 justify-center gap-1 leading-4 hover:underline",
754
+ children: [
755
+ /* @__PURE__ */ jsx11("span", {
756
+ children
757
+ }),
758
+ /* @__PURE__ */ jsx11("svg", {
759
+ "aria-hidden": "true",
760
+ height: "7",
761
+ viewBox: "0 0 6 6",
762
+ width: "7",
763
+ className: "opacity-70",
764
+ children: /* @__PURE__ */ jsx11("path", {
765
+ d: "M1.25215 5.54731L0.622742 4.9179L3.78169 1.75597H1.3834L1.38936 0.890915H5.27615V4.78069H4.40513L4.41109 2.38538L1.25215 5.54731Z",
766
+ fill: "currentColor"
767
+ })
768
+ })
769
+ ]
770
+ });
771
+ }
772
+
773
+ // src/components/chat-components/default-empty-screen.tsx
774
+ import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
775
+ "use client";
776
+ var exampleMessages = [
777
+ {
778
+ heading: "Explain technical concepts",
779
+ message: `What is a "serverless function"?`
780
+ },
781
+ {
782
+ heading: "Summarize an article",
783
+ message: "Summarize the following article for a 2nd grader: \n"
784
+ },
785
+ {
786
+ heading: "Draft an email",
787
+ message: `Draft an email to my boss about the following:
788
+ `
789
+ }
790
+ ];
791
+ var DefaultEmptyScreen = (props) => {
792
+ return /* @__PURE__ */ jsx12("div", {
793
+ className: "mx-auto max-w-2xl px-4",
794
+ children: /* @__PURE__ */ jsxs9("div", {
795
+ className: "rounded-lg border bg-background p-8",
796
+ children: [
797
+ /* @__PURE__ */ jsx12("h1", {
798
+ className: "mb-2 text-lg font-semibold",
799
+ children: "Welcome to CopilotKit! \u{1F44B}"
800
+ }),
801
+ /* @__PURE__ */ jsxs9("p", {
802
+ className: "mb-2 leading-normal text-muted-foreground",
803
+ children: [
804
+ "This is a Copilot built with",
805
+ " ",
806
+ /* @__PURE__ */ jsx12(ExternalLink, {
807
+ href: "https://recursively.ai",
808
+ children: "recursively.ai's"
809
+ }),
810
+ " ",
811
+ /* @__PURE__ */ jsx12(ExternalLink, {
812
+ href: "https://github.com/RecursivelyAI/CopilotKit",
813
+ children: "CopilotKit"
814
+ }),
815
+ " ",
816
+ "."
817
+ ]
818
+ }),
819
+ /* @__PURE__ */ jsx12("p", {
820
+ className: "leading-normal text-muted-foreground",
821
+ children: "You can start a conversation here or try the following examples:"
822
+ }),
823
+ /* @__PURE__ */ jsx12("div", {
824
+ className: "mt-4 flex flex-col items-start space-y-2",
825
+ children: exampleMessages.map((message, index) => /* @__PURE__ */ jsxs9(Button, {
826
+ variant: "link",
827
+ className: "h-auto p-0 text-base",
828
+ onClick: () => props.setInput(message.message),
829
+ children: [
830
+ /* @__PURE__ */ jsx12(IconArrowRight, {
831
+ className: "mr-2 text-muted-foreground"
832
+ }),
833
+ message.heading
834
+ ]
835
+ }, index))
836
+ })
837
+ ]
838
+ })
839
+ });
840
+ };
841
+
842
+ // src/components/chat-components/chat-scroll-anchor.tsx
843
+ import * as React8 from "react";
844
+ import { useInView } from "react-intersection-observer";
845
+
846
+ // src/hooks/use-at-bottom.tsx
847
+ import * as React7 from "react";
848
+ function useAtBottom(offset = 0) {
849
+ const [isAtBottom, setIsAtBottom] = React7.useState(false);
850
+ React7.useEffect(() => {
851
+ const handleScroll = () => {
852
+ setIsAtBottom(
853
+ window.innerHeight + window.scrollY >= document.body.offsetHeight - offset
854
+ );
855
+ };
856
+ window.addEventListener("scroll", handleScroll, { passive: true });
857
+ handleScroll();
858
+ return () => {
859
+ window.removeEventListener("scroll", handleScroll);
860
+ };
861
+ }, [offset]);
862
+ return isAtBottom;
863
+ }
864
+
865
+ // src/components/chat-components/chat-scroll-anchor.tsx
866
+ import { jsx as jsx13 } from "react/jsx-runtime";
867
+ "use client";
868
+ function ChatScrollAnchor({ trackVisibility }) {
869
+ const isAtBottom = useAtBottom();
870
+ const { ref, entry, inView } = useInView({
871
+ trackVisibility,
872
+ delay: 100,
873
+ rootMargin: "0px 0px -150px 0px"
874
+ });
875
+ React8.useEffect(() => {
876
+ if (isAtBottom && trackVisibility && !inView) {
877
+ entry == null ? void 0 : entry.target.scrollIntoView({
878
+ block: "start"
879
+ });
880
+ }
881
+ }, [inView, entry, isAtBottom, trackVisibility]);
882
+ return /* @__PURE__ */ jsx13("div", {
883
+ ref,
884
+ className: "h-px w-full"
885
+ });
886
+ }
887
+
888
+ // src/components/chat-components/copilot-chat.tsx
889
+ import { useCopilotChat } from "@copilotkit/react-core";
890
+ import { jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
891
+ "use client";
892
+ function CopilotChat({
893
+ id,
894
+ initialMessages,
895
+ makeSystemMessage,
896
+ EmptyScreen = DefaultEmptyScreen
897
+ }) {
898
+ const { visibleMessages, append, reload, stop, isLoading, input, setInput } = useCopilotChat({ id, initialMessages, makeSystemMessage });
899
+ return /* @__PURE__ */ jsxs10("div", {
900
+ className: "w-full h-full flex flex-col overflow-hidden box-border items-start",
901
+ children: [
902
+ /* @__PURE__ */ jsx14("div", {
903
+ className: "pt-5 px-5 overflow-y-auto overflow-x-hidden w-full flex-grow",
904
+ children: visibleMessages.length ? /* @__PURE__ */ jsxs10("div", {
905
+ className: "pl-0 pr-6",
906
+ children: [
907
+ /* @__PURE__ */ jsx14(ChatList, {
908
+ messages: visibleMessages
909
+ }),
910
+ /* @__PURE__ */ jsx14(ChatScrollAnchor, {
911
+ trackVisibility: isLoading
912
+ })
913
+ ]
914
+ }) : /* @__PURE__ */ jsx14(EmptyScreen, {
915
+ setInput
916
+ })
917
+ }),
918
+ /* @__PURE__ */ jsx14("div", {
919
+ className: "flex-shrink-0 w-full",
920
+ children: /* @__PURE__ */ jsx14(ChatPanel, {
921
+ id,
922
+ isLoading,
923
+ stop,
924
+ append,
925
+ reload,
926
+ messages: visibleMessages,
927
+ input,
928
+ setInput
929
+ })
930
+ })
931
+ ]
932
+ });
933
+ }
934
+
935
+ // src/components/sidebar/copilot-sidebar.tsx
936
+ import { XMarkIcon } from "@heroicons/react/24/outline";
937
+ import { jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
938
+ function CopilotSidebar(props) {
939
+ return /* @__PURE__ */ jsxs11("div", {
940
+ className: "shadow-lg bg-gray-50 flex flex-col border-l-2",
941
+ style: { width: "100%", height: "100%" },
942
+ children: [
943
+ /* @__PURE__ */ jsx15(TopBar, __spreadValues({}, props)),
944
+ /* @__PURE__ */ jsx15(CopilotChat, {})
945
+ ]
946
+ });
947
+ }
948
+ function TopBar(props) {
949
+ return /* @__PURE__ */ jsxs11("div", {
950
+ className: "py-6 flex bg-gray-50 items-center justify-between px-4",
951
+ children: [
952
+ /* @__PURE__ */ jsx15("h1", {
953
+ className: "text-base font-semibold leading-6 text-gray-900",
954
+ children: "Copilot Chat"
955
+ }),
956
+ /* @__PURE__ */ jsx15("div", {
957
+ className: "ml-3 flex h-7 items-center",
958
+ children: /* @__PURE__ */ jsxs11("button", {
959
+ type: "button",
960
+ className: "rounded-md bg-white text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2",
961
+ onClick: () => props.setSidebarOpen(false),
962
+ children: [
963
+ /* @__PURE__ */ jsx15("span", {
964
+ className: "sr-only",
965
+ children: "Close panel"
966
+ }),
967
+ /* @__PURE__ */ jsx15(XMarkIcon, {
968
+ className: "h-6 w-6",
969
+ "aria-hidden": "true"
970
+ })
971
+ ]
972
+ })
973
+ })
974
+ ]
975
+ });
976
+ }
977
+
978
+ // src/components/sidebar/sidebar-context.tsx
979
+ import { createContext } from "react";
980
+ var CopilotSidebarContext = createContext({
981
+ isSidebarOpen: false,
982
+ toggleSidebar: () => {
983
+ }
984
+ });
985
+
986
+ // src/components/sidebar/copilot-sidebar-ui-provider.tsx
987
+ import { Fragment, jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
988
+ function CopilotSidebarUIProvider({
989
+ children
990
+ }) {
991
+ const [sidebarOpen, setSidebarOpen] = useState3(true);
992
+ const toggleSidebar = useCallback(() => {
993
+ setSidebarOpen((prev) => !prev);
994
+ }, []);
995
+ return /* @__PURE__ */ jsx16(CopilotSidebarContext.Provider, {
996
+ value: { isSidebarOpen: sidebarOpen, toggleSidebar },
997
+ children: /* @__PURE__ */ jsx16(Fragment, {
998
+ children: /* @__PURE__ */ jsxs12("div", {
999
+ style: {
1000
+ height: "100vh",
1001
+ width: "100vw",
1002
+ position: "relative"
1003
+ },
1004
+ children: [
1005
+ /* @__PURE__ */ jsx16("div", {
1006
+ style: {
1007
+ overflowY: "auto",
1008
+ overflowX: "hidden",
1009
+ height: "100%",
1010
+ width: sidebarOpen ? "calc(100% - 450px)" : "100%",
1011
+ position: "absolute",
1012
+ transition: "width 0.5s ease-in-out"
1013
+ },
1014
+ children: /* @__PURE__ */ jsx16("main", {
1015
+ children
1016
+ })
1017
+ }),
1018
+ /* @__PURE__ */ jsx16("div", {
1019
+ style: {
1020
+ overflowY: "auto",
1021
+ height: "100%",
1022
+ width: "450px",
1023
+ position: "absolute",
1024
+ right: sidebarOpen ? "0" : "-450px",
1025
+ transition: "right 0.5s ease-in-out"
1026
+ },
1027
+ children: /* @__PURE__ */ jsx16(TooltipProvider, {
1028
+ children: /* @__PURE__ */ jsx16(CopilotSidebar, {
1029
+ setSidebarOpen
1030
+ })
1031
+ })
1032
+ }),
1033
+ !sidebarOpen && /* @__PURE__ */ jsx16("button", {
1034
+ onClick: toggleSidebar,
1035
+ style: {
1036
+ position: "absolute",
1037
+ top: "5%",
1038
+ right: "20px",
1039
+ transform: "translateY(-50%)",
1040
+ transition: "opacity 0.5s ease-in-out"
1041
+ },
1042
+ className: "bg-slate-100 ring-2 ring-slate-600 font-semibold text-black p-2 rounded-lg shadow-lg",
1043
+ children: "Open Copilot"
1044
+ })
1045
+ ]
1046
+ })
1047
+ })
1048
+ });
1049
+ }
1050
+ export {
1051
+ CopilotSidebarUIProvider
1052
+ };
25
1053
  //# sourceMappingURL=copilot-sidebar-ui-provider.mjs.map