@copilotkit/react-ui 0.15.0-alpha.0 → 0.15.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +178 -95
- package/CHANGELOG.md +12 -1
- package/dist/chunk-47SYBLI2.mjs +110 -0
- package/dist/chunk-47SYBLI2.mjs.map +1 -0
- package/dist/chunk-6H3Y2XEI.mjs +56 -0
- package/dist/chunk-6H3Y2XEI.mjs.map +1 -0
- package/dist/chunk-7YXG7D47.mjs +191 -0
- package/dist/chunk-7YXG7D47.mjs.map +1 -0
- package/dist/{chunk-NMT7XT2R.mjs → chunk-C34L4AWW.mjs} +2 -2
- package/dist/chunk-C34L4AWW.mjs.map +1 -0
- package/dist/chunk-DN3OI5WF.mjs +72 -0
- package/dist/chunk-DN3OI5WF.mjs.map +1 -0
- package/dist/chunk-DPUPEOGG.mjs +14 -0
- package/dist/chunk-DPUPEOGG.mjs.map +1 -0
- package/dist/chunk-FZRTAML3.mjs +3 -0
- package/dist/chunk-GPEJCUWA.mjs +14 -0
- package/dist/chunk-GPEJCUWA.mjs.map +1 -0
- package/dist/chunk-NXWVWC33.mjs +117 -0
- package/dist/chunk-NXWVWC33.mjs.map +1 -0
- package/dist/chunk-P4GBO6MW.mjs +3 -0
- package/dist/chunk-P4GBO6MW.mjs.map +1 -0
- package/dist/chunk-QFASQEFJ.mjs +51 -0
- package/dist/chunk-QFASQEFJ.mjs.map +1 -0
- package/dist/chunk-UIRFLYXI.mjs +53 -0
- package/dist/chunk-UIRFLYXI.mjs.map +1 -0
- package/dist/chunk-WB3YULQ4.mjs +3 -0
- package/dist/chunk-WB3YULQ4.mjs.map +1 -0
- package/dist/chunk-WM6BS77F.mjs +53 -0
- package/dist/chunk-WM6BS77F.mjs.map +1 -0
- package/dist/chunk-X3Z2EVFV.mjs +26 -0
- package/dist/chunk-X3Z2EVFV.mjs.map +1 -0
- package/dist/chunk-X4T6ZUVM.mjs +14 -0
- package/dist/chunk-X4T6ZUVM.mjs.map +1 -0
- package/dist/{chunk-WLTEQ2FW.mjs → chunk-XGUBRIUV.mjs} +4 -12
- package/dist/chunk-XGUBRIUV.mjs.map +1 -0
- package/dist/chunk-Y2RUG4B3.mjs +21 -0
- package/dist/chunk-Y2RUG4B3.mjs.map +1 -0
- package/dist/chunk-ZVAH2Z2W.mjs +61 -0
- package/dist/chunk-ZVAH2Z2W.mjs.map +1 -0
- package/dist/components/chat/Button.d.ts +7 -0
- package/dist/components/chat/Button.mjs +6 -0
- package/dist/components/chat/Button.mjs.map +1 -0
- package/dist/components/chat/Chat.d.ts +95 -0
- package/dist/components/chat/Chat.mjs +16 -0
- package/dist/components/chat/Chat.mjs.map +1 -0
- package/dist/components/chat/ChatContext.d.ts +105 -0
- package/dist/components/chat/ChatContext.mjs +5 -0
- package/dist/components/chat/ChatContext.mjs.map +1 -0
- package/dist/components/chat/CodeBlock.d.ts +14 -0
- package/dist/components/chat/CodeBlock.mjs +6 -0
- package/dist/components/chat/CodeBlock.mjs.map +1 -0
- package/dist/components/chat/Header.d.ts +7 -0
- package/dist/components/chat/Header.mjs +6 -0
- package/dist/components/chat/Header.mjs.map +1 -0
- package/dist/components/chat/Icons.d.ts +15 -0
- package/dist/components/chat/Icons.mjs +4 -0
- package/dist/components/chat/Icons.mjs.map +1 -0
- package/dist/components/chat/Input.d.ts +7 -0
- package/dist/components/chat/Input.mjs +7 -0
- package/dist/components/chat/Input.mjs.map +1 -0
- package/dist/components/chat/Markdown.d.ts +8 -0
- package/dist/components/chat/Markdown.mjs +7 -0
- package/dist/components/chat/Markdown.mjs.map +1 -0
- package/dist/components/chat/Messages.d.ts +7 -0
- package/dist/components/chat/Messages.mjs +9 -0
- package/dist/components/chat/Messages.mjs.map +1 -0
- package/dist/components/chat/Popup.d.ts +9 -0
- package/dist/components/chat/Popup.mjs +17 -0
- package/dist/components/chat/Popup.mjs.map +1 -0
- package/dist/components/chat/Response.d.ts +7 -0
- package/dist/components/chat/Response.mjs +6 -0
- package/dist/components/chat/Response.mjs.map +1 -0
- package/dist/components/chat/Sidebar.d.ts +12 -0
- package/dist/components/chat/Sidebar.mjs +17 -0
- package/dist/components/chat/Sidebar.mjs.map +1 -0
- package/dist/components/chat/Textarea.d.ts +13 -0
- package/dist/components/chat/Textarea.mjs +4 -0
- package/dist/components/chat/Textarea.mjs.map +1 -0
- package/dist/components/chat/Window.d.ts +6 -0
- package/dist/components/chat/Window.mjs +4 -0
- package/dist/components/chat/Window.mjs.map +1 -0
- package/dist/components/chat/index.d.ts +7 -0
- package/dist/components/chat/index.mjs +20 -0
- package/dist/components/chat/index.mjs.map +1 -0
- package/dist/components/chat/props.d.ts +33 -0
- package/dist/components/chat/props.mjs +3 -0
- package/dist/components/chat/props.mjs.map +1 -0
- package/dist/components/chat-components/copilot-chat.mjs +1 -1
- package/dist/components/chat-components/ui/badge.d.ts +1 -1
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.mjs +20 -4
- package/dist/components/sidebar/copilot-sidebar-ui-provider.d.ts +1 -2
- package/dist/components/sidebar/copilot-sidebar-ui-provider.mjs +3 -3
- package/dist/components/sidebar/copilot-sidebar.d.ts +0 -1
- package/dist/components/sidebar/copilot-sidebar.mjs +2 -2
- package/dist/index.css +452 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.mjs +20 -4
- package/package.json +5 -5
- package/src/components/chat/Button.tsx +24 -0
- package/src/components/chat/Chat.tsx +186 -0
- package/src/components/chat/ChatContext.tsx +176 -0
- package/src/components/chat/CodeBlock.tsx +149 -0
- package/src/components/chat/Header.tsx +16 -0
- package/src/components/chat/Icons.tsx +179 -0
- package/src/components/chat/Input.tsx +51 -0
- package/src/components/chat/Markdown.tsx +62 -0
- package/src/components/chat/Messages.tsx +113 -0
- package/src/components/chat/Popup.tsx +10 -0
- package/src/components/chat/Response.tsx +13 -0
- package/src/components/chat/Sidebar.tsx +28 -0
- package/src/components/chat/Textarea.tsx +61 -0
- package/src/components/chat/Window.tsx +141 -0
- package/src/components/chat/index.tsx +3 -0
- package/src/components/chat/props.ts +36 -0
- package/src/components/index.ts +2 -0
- package/src/components/sidebar/copilot-sidebar-ui-provider.tsx +2 -6
- package/src/components/sidebar/copilot-sidebar.tsx +1 -2
- package/src/css/animations.css +29 -0
- package/src/css/button.css +54 -0
- package/src/css/colors.css +61 -0
- package/src/css/header.css +43 -0
- package/src/css/input.css +79 -0
- package/src/css/messages.css +57 -0
- package/src/css/popup.css +22 -0
- package/src/css/response.css +29 -0
- package/src/css/sidebar.css +34 -0
- package/src/css/window.css +58 -0
- package/src/styles.css +11 -0
- package/dist/chunk-NMT7XT2R.mjs.map +0 -1
- package/dist/chunk-U6NJWGTV.mjs +0 -3
- package/dist/chunk-WLTEQ2FW.mjs.map +0 -1
- /package/dist/{chunk-U6NJWGTV.mjs.map → chunk-FZRTAML3.mjs.map} +0 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { __objRest, __spreadProps, __spreadValues } from './chunk-MRXNTQOX.mjs';
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
var OpenIcon = /* @__PURE__ */ jsx(
|
|
5
|
+
"svg",
|
|
6
|
+
{
|
|
7
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
8
|
+
viewBox: "0 0 24 24",
|
|
9
|
+
fill: "currentColor",
|
|
10
|
+
width: "24",
|
|
11
|
+
height: "24",
|
|
12
|
+
children: /* @__PURE__ */ jsx("g", { transform: "translate(24, 0) scale(-1, 1)", children: /* @__PURE__ */ jsx(
|
|
13
|
+
"path",
|
|
14
|
+
{
|
|
15
|
+
fillRule: "evenodd",
|
|
16
|
+
d: "M5.337 21.718a6.707 6.707 0 01-.533-.074.75.75 0 01-.44-1.223 3.73 3.73 0 00.814-1.686c.023-.115-.022-.317-.254-.543C3.274 16.587 2.25 14.41 2.25 12c0-5.03 4.428-9 9.75-9s9.75 3.97 9.75 9c0 5.03-4.428 9-9.75 9-.833 0-1.643-.097-2.417-.279a6.721 6.721 0 01-4.246.997z",
|
|
17
|
+
clipRule: "evenodd"
|
|
18
|
+
}
|
|
19
|
+
) })
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
var CloseIcon = /* @__PURE__ */ jsx(
|
|
23
|
+
"svg",
|
|
24
|
+
{
|
|
25
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
26
|
+
fill: "none",
|
|
27
|
+
viewBox: "0 0 24 24",
|
|
28
|
+
strokeWidth: "1.5",
|
|
29
|
+
stroke: "currentColor",
|
|
30
|
+
width: "24",
|
|
31
|
+
height: "24",
|
|
32
|
+
children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19.5 8.25l-7.5 7.5-7.5-7.5" })
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
var HeaderCloseIcon = /* @__PURE__ */ jsx(
|
|
36
|
+
"svg",
|
|
37
|
+
{
|
|
38
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
39
|
+
fill: "none",
|
|
40
|
+
viewBox: "0 0 24 24",
|
|
41
|
+
strokeWidth: "1.5",
|
|
42
|
+
stroke: "currentColor",
|
|
43
|
+
width: "24",
|
|
44
|
+
height: "24",
|
|
45
|
+
children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
var SendIcon = /* @__PURE__ */ jsx(
|
|
49
|
+
"svg",
|
|
50
|
+
{
|
|
51
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
52
|
+
fill: "none",
|
|
53
|
+
viewBox: "0 0 24 24",
|
|
54
|
+
strokeWidth: 1.5,
|
|
55
|
+
stroke: "currentColor",
|
|
56
|
+
width: "24",
|
|
57
|
+
height: "24",
|
|
58
|
+
children: /* @__PURE__ */ jsx(
|
|
59
|
+
"path",
|
|
60
|
+
{
|
|
61
|
+
strokeLinecap: "round",
|
|
62
|
+
strokeLinejoin: "round",
|
|
63
|
+
d: "M6 12L3.269 3.126A59.768 59.768 0 0121.485 12 59.77 59.77 0 013.27 20.876L5.999 12zm0 0h7.5"
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
var SpinnerIcon = /* @__PURE__ */ jsxs(
|
|
69
|
+
"svg",
|
|
70
|
+
{
|
|
71
|
+
style: {
|
|
72
|
+
animation: "copilotKitSpinAnimation 1s linear infinite",
|
|
73
|
+
color: "rgb(107 114 128)"
|
|
74
|
+
},
|
|
75
|
+
width: "24",
|
|
76
|
+
height: "24",
|
|
77
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
78
|
+
fill: "none",
|
|
79
|
+
viewBox: "0 0 24 24",
|
|
80
|
+
children: [
|
|
81
|
+
/* @__PURE__ */ jsx(
|
|
82
|
+
"circle",
|
|
83
|
+
{
|
|
84
|
+
style: { opacity: 0.25 },
|
|
85
|
+
cx: "12",
|
|
86
|
+
cy: "12",
|
|
87
|
+
r: "10",
|
|
88
|
+
stroke: "currentColor",
|
|
89
|
+
strokeWidth: "4"
|
|
90
|
+
}
|
|
91
|
+
),
|
|
92
|
+
/* @__PURE__ */ jsx(
|
|
93
|
+
"path",
|
|
94
|
+
{
|
|
95
|
+
style: { opacity: 0.75 },
|
|
96
|
+
fill: "currentColor",
|
|
97
|
+
d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
|
98
|
+
}
|
|
99
|
+
)
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
var ActivityIcon = /* @__PURE__ */ jsxs(
|
|
104
|
+
"svg",
|
|
105
|
+
{
|
|
106
|
+
style: {
|
|
107
|
+
display: "inline-block",
|
|
108
|
+
marginLeft: "0.25rem",
|
|
109
|
+
marginRight: "0.25rem"
|
|
110
|
+
},
|
|
111
|
+
height: "24",
|
|
112
|
+
width: "24",
|
|
113
|
+
viewBox: "0 0 27 27",
|
|
114
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
115
|
+
fill: "currentColor",
|
|
116
|
+
children: [
|
|
117
|
+
/* @__PURE__ */ jsx("circle", { className: "copilotKitActivityDot1", cx: "4", cy: "12", r: "3" }),
|
|
118
|
+
/* @__PURE__ */ jsx("circle", { className: "copilotKitActivityDot1 copilotKitActivityDot2", cx: "12", cy: "12", r: "3" }),
|
|
119
|
+
/* @__PURE__ */ jsx("circle", { className: "copilotKitActivityDot1 copilotKitActivityDot3", cx: "20", cy: "12", r: "3" })
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
function CheckIcon(_a) {
|
|
124
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
125
|
+
return /* @__PURE__ */ jsx(
|
|
126
|
+
"svg",
|
|
127
|
+
__spreadProps(__spreadValues({
|
|
128
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
129
|
+
viewBox: "0 0 256 256",
|
|
130
|
+
fill: "currentColor",
|
|
131
|
+
style: { height: "1rem", width: "1rem" },
|
|
132
|
+
className
|
|
133
|
+
}, props), {
|
|
134
|
+
children: /* @__PURE__ */ jsx("path", { 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" })
|
|
135
|
+
})
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
function DownloadIcon(_a) {
|
|
139
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
140
|
+
return /* @__PURE__ */ jsx(
|
|
141
|
+
"svg",
|
|
142
|
+
__spreadProps(__spreadValues({
|
|
143
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
144
|
+
viewBox: "0 0 256 256",
|
|
145
|
+
fill: "currentColor",
|
|
146
|
+
style: { height: "1rem", width: "1rem" },
|
|
147
|
+
className
|
|
148
|
+
}, props), {
|
|
149
|
+
children: /* @__PURE__ */ jsx("path", { 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" })
|
|
150
|
+
})
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
function CopyIcon(_a) {
|
|
154
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
155
|
+
return /* @__PURE__ */ jsx(
|
|
156
|
+
"svg",
|
|
157
|
+
__spreadProps(__spreadValues({
|
|
158
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
159
|
+
viewBox: "0 0 256 256",
|
|
160
|
+
fill: "currentColor",
|
|
161
|
+
style: { height: "1rem", width: "1rem" },
|
|
162
|
+
className
|
|
163
|
+
}, props), {
|
|
164
|
+
children: /* @__PURE__ */ jsx("path", { 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" })
|
|
165
|
+
})
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
var StopIcon = /* @__PURE__ */ jsx(
|
|
169
|
+
"svg",
|
|
170
|
+
{
|
|
171
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
172
|
+
viewBox: "0 0 256 256",
|
|
173
|
+
fill: "currentColor",
|
|
174
|
+
style: { height: "1rem", width: "1rem" },
|
|
175
|
+
children: /* @__PURE__ */ jsx("path", { 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" })
|
|
176
|
+
}
|
|
177
|
+
);
|
|
178
|
+
var RegenerateIcon = /* @__PURE__ */ jsx(
|
|
179
|
+
"svg",
|
|
180
|
+
{
|
|
181
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
182
|
+
viewBox: "0 0 256 256",
|
|
183
|
+
fill: "currentColor",
|
|
184
|
+
style: { height: "1rem", width: "1rem" },
|
|
185
|
+
children: /* @__PURE__ */ jsx("path", { 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" })
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
export { ActivityIcon, CheckIcon, CloseIcon, CopyIcon, DownloadIcon, HeaderCloseIcon, OpenIcon, RegenerateIcon, SendIcon, SpinnerIcon, StopIcon };
|
|
190
|
+
//# sourceMappingURL=out.js.map
|
|
191
|
+
//# sourceMappingURL=chunk-7YXG7D47.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/Icons.tsx"],"names":[],"mappings":"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","sourcesContent":["import React from \"react\";\n\nexport const OpenIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <g transform=\"translate(24, 0) scale(-1, 1)\">\n <path\n fillRule=\"evenodd\"\n d=\"M5.337 21.718a6.707 6.707 0 01-.533-.074.75.75 0 01-.44-1.223 3.73 3.73 0 00.814-1.686c.023-.115-.022-.317-.254-.543C3.274 16.587 2.25 14.41 2.25 12c0-5.03 4.428-9 9.75-9s9.75 3.97 9.75 9c0 5.03-4.428 9-9.75 9-.833 0-1.643-.097-2.417-.279a6.721 6.721 0 01-4.246.997z\"\n clipRule=\"evenodd\"\n />\n </g>\n </svg>\n);\n\nexport const CloseIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M19.5 8.25l-7.5 7.5-7.5-7.5\" />\n </svg>\n);\n\nexport const HeaderCloseIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M6 18L18 6M6 6l12 12\" />\n </svg>\n);\n\nexport const SendIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth={1.5}\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M6 12L3.269 3.126A59.768 59.768 0 0121.485 12 59.77 59.77 0 013.27 20.876L5.999 12zm0 0h7.5\"\n />\n </svg>\n);\n\nexport const SpinnerIcon = (\n <svg\n style={{\n animation: \"copilotKitSpinAnimation 1s linear infinite\",\n color: \"rgb(107 114 128)\",\n }}\n width=\"24\"\n height=\"24\"\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n >\n <circle\n style={{ opacity: 0.25 }}\n cx=\"12\"\n cy=\"12\"\n r=\"10\"\n stroke=\"currentColor\"\n strokeWidth=\"4\"\n ></circle>\n <path\n style={{ opacity: 0.75 }}\n fill=\"currentColor\"\n d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"\n ></path>\n </svg>\n);\n\nexport const ActivityIcon = (\n <svg\n style={{\n display: \"inline-block\",\n marginLeft: \"0.25rem\",\n marginRight: \"0.25rem\",\n }}\n height=\"24\"\n width=\"24\"\n viewBox=\"0 0 27 27\"\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"currentColor\"\n >\n <circle className=\"copilotKitActivityDot1\" cx=\"4\" cy=\"12\" r=\"3\" />\n <circle className=\"copilotKitActivityDot1 copilotKitActivityDot2\" cx=\"12\" cy=\"12\" r=\"3\" />\n <circle className=\"copilotKitActivityDot1 copilotKitActivityDot3\" cx=\"20\" cy=\"12\" r=\"3\" />\n </svg>\n);\n\nexport function CheckIcon({ className, ...props }: React.ComponentProps<\"svg\">) {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 256 256\"\n fill=\"currentColor\"\n style={{ height: \"1rem\", width: \"1rem\" }}\n className={className}\n {...props}\n >\n <path 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\" />\n </svg>\n );\n}\n\nexport function DownloadIcon({ className, ...props }: React.ComponentProps<\"svg\">) {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 256 256\"\n fill=\"currentColor\"\n style={{ height: \"1rem\", width: \"1rem\" }}\n className={className}\n {...props}\n >\n <path 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\" />\n </svg>\n );\n}\n\nexport function CopyIcon({ className, ...props }: React.ComponentProps<\"svg\">) {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 256 256\"\n fill=\"currentColor\"\n style={{ height: \"1rem\", width: \"1rem\" }}\n className={className}\n {...props}\n >\n <path 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\" />\n </svg>\n );\n}\n\nexport const StopIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 256 256\"\n fill=\"currentColor\"\n style={{ height: \"1rem\", width: \"1rem\" }}\n >\n <path 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\" />\n </svg>\n);\n\nexport const RegenerateIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 256 256\"\n fill=\"currentColor\"\n style={{ height: \"1rem\", width: \"1rem\" }}\n >\n <path 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\" />\n </svg>\n);\n"]}
|
|
@@ -11,7 +11,7 @@ function CopilotSidebar(props) {
|
|
|
11
11
|
style: { width: "100%", height: "100%" },
|
|
12
12
|
children: [
|
|
13
13
|
/* @__PURE__ */ jsx(TopBar, __spreadValues({}, props)),
|
|
14
|
-
/* @__PURE__ */ jsx(CopilotChat, {
|
|
14
|
+
/* @__PURE__ */ jsx(CopilotChat, {})
|
|
15
15
|
]
|
|
16
16
|
}
|
|
17
17
|
);
|
|
@@ -36,4 +36,4 @@ function TopBar(props) {
|
|
|
36
36
|
|
|
37
37
|
export { CopilotSidebar };
|
|
38
38
|
//# sourceMappingURL=out.js.map
|
|
39
|
-
//# sourceMappingURL=chunk-
|
|
39
|
+
//# sourceMappingURL=chunk-C34L4AWW.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/sidebar/copilot-sidebar.tsx"],"names":[],"mappings":";;;;;;;;AAmBA,SAAS,iBAAiB;AAVtB,SAIE,KAJF;AAFG,SAAS,eAAe,OAAkC;AAC/D,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,OAAO,EAAE,OAAO,QAAQ,QAAQ,OAAO;AAAA,MAEvC;AAAA,4BAAC,2BAAW,MAAO;AAAA,QACnB,oBAAC,eAAY;AAAA;AAAA;AAAA,EACf;AAEJ;AAIA,SAAS,OAAO,OAAkC;AAChD,SACE,qBAAC,SAAI,WAAU,0DACb;AAAA,wBAAC,QAAG,WAAU,mDAAkD,0BAAY;AAAA,IAC5E,oBAAC,SAAI,WAAU,8BACb;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,WAAU;AAAA,QACV,SAAS,MAAM,MAAM,eAAe,KAAK;AAAA,QAEzC;AAAA,8BAAC,UAAK,WAAU,WAAU,yBAAW;AAAA,UACrC,oBAAC,aAAU,WAAU,WAAU,eAAY,QAAO;AAAA;AAAA;AAAA,IACpD,GACF;AAAA,KACF;AAEJ","sourcesContent":["import React from \"react\";\nimport { CopilotChat } from \"../chat-components/copilot-chat\";\n\nexport interface SidebarProps {\n setSidebarOpen: (open: boolean) => void;\n}\n\nexport function CopilotSidebar(props: SidebarProps): JSX.Element {\n return (\n <div\n className=\"shadow-lg bg-gray-50 flex flex-col border-l-2\"\n style={{ width: \"100%\", height: \"100%\" }}\n >\n <TopBar {...props} />\n <CopilotChat />\n </div>\n );\n}\n\nimport { XMarkIcon } from \"@heroicons/react/24/outline\";\n\nfunction TopBar(props: SidebarProps): JSX.Element {\n return (\n <div className=\"py-6 flex bg-gray-50 items-center justify-between px-4\">\n <h1 className=\"text-base font-semibold leading-6 text-gray-900\">Copilot Chat</h1>\n <div className=\"ml-3 flex h-7 items-center\">\n <button\n type=\"button\"\n 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\"\n onClick={() => props.setSidebarOpen(false)}\n >\n <span className=\"sr-only\">Close panel</span>\n <XMarkIcon className=\"h-6 w-6\" aria-hidden=\"true\" />\n </button>\n </div>\n </div>\n );\n}\n"]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Window } from './chunk-47SYBLI2.mjs';
|
|
2
|
+
import { Input } from './chunk-QFASQEFJ.mjs';
|
|
3
|
+
import { Messages } from './chunk-ZVAH2Z2W.mjs';
|
|
4
|
+
import { ResponseButton } from './chunk-GPEJCUWA.mjs';
|
|
5
|
+
import { Button } from './chunk-Y2RUG4B3.mjs';
|
|
6
|
+
import { Header } from './chunk-DPUPEOGG.mjs';
|
|
7
|
+
import { ChatContextProvider } from './chunk-6H3Y2XEI.mjs';
|
|
8
|
+
import { __async } from './chunk-MRXNTQOX.mjs';
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { useCopilotChat } from '@copilotkit/react-core';
|
|
11
|
+
import { nanoid } from 'nanoid';
|
|
12
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
13
|
+
|
|
14
|
+
var CopilotKitChat = ({
|
|
15
|
+
instructions,
|
|
16
|
+
defaultOpen = false,
|
|
17
|
+
clickOutsideToClose = true,
|
|
18
|
+
hitEscapeToClose = true,
|
|
19
|
+
onSetOpen,
|
|
20
|
+
hotkey = "e",
|
|
21
|
+
icons,
|
|
22
|
+
labels,
|
|
23
|
+
makeSystemMessage,
|
|
24
|
+
showResponseButton = true,
|
|
25
|
+
Window: Window2 = Window,
|
|
26
|
+
Button: Button2 = Button,
|
|
27
|
+
Header: Header2 = Header,
|
|
28
|
+
Messages: Messages2 = Messages,
|
|
29
|
+
Input: Input2 = Input,
|
|
30
|
+
ResponseButton: ResponseButton2 = ResponseButton,
|
|
31
|
+
className
|
|
32
|
+
}) => {
|
|
33
|
+
const { visibleMessages, append, reload, stop, isLoading, input, setInput } = useCopilotChat({
|
|
34
|
+
id: nanoid(),
|
|
35
|
+
makeSystemMessage,
|
|
36
|
+
additionalInstructions: instructions
|
|
37
|
+
});
|
|
38
|
+
const [openState, setOpenState] = React.useState(defaultOpen);
|
|
39
|
+
const setOpen = (open) => {
|
|
40
|
+
onSetOpen == null ? void 0 : onSetOpen(open);
|
|
41
|
+
setOpenState(open);
|
|
42
|
+
};
|
|
43
|
+
const sendMessage = (message) => __async(void 0, null, function* () {
|
|
44
|
+
append({
|
|
45
|
+
id: nanoid(),
|
|
46
|
+
content: message,
|
|
47
|
+
role: "user"
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
return /* @__PURE__ */ jsx(ChatContextProvider, { icons, labels, children: /* @__PURE__ */ jsxs("div", { className, children: [
|
|
51
|
+
/* @__PURE__ */ jsx(Button2, { open: openState, setOpen }),
|
|
52
|
+
/* @__PURE__ */ jsxs(
|
|
53
|
+
Window2,
|
|
54
|
+
{
|
|
55
|
+
open: openState,
|
|
56
|
+
setOpen,
|
|
57
|
+
clickOutsideToClose,
|
|
58
|
+
hotkey,
|
|
59
|
+
hitEscapeToClose,
|
|
60
|
+
children: [
|
|
61
|
+
/* @__PURE__ */ jsx(Header2, { open: openState, setOpen }),
|
|
62
|
+
/* @__PURE__ */ jsx(Messages2, { messages: visibleMessages, inProgress: isLoading }),
|
|
63
|
+
/* @__PURE__ */ jsx(Input2, { inProgress: isLoading, onSend: sendMessage, children: showResponseButton && visibleMessages.length > 0 && /* @__PURE__ */ jsx(ResponseButton2, { onClick: isLoading ? stop : reload, inProgress: isLoading }) })
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
)
|
|
67
|
+
] }) });
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export { CopilotKitChat };
|
|
71
|
+
//# sourceMappingURL=out.js.map
|
|
72
|
+
//# sourceMappingURL=chunk-DN3OI5WF.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/Chat.tsx"],"names":["Window","Button","Header","Messages","Input","ResponseButton"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,WAAW;AAElB,SAAgC,sBAAsB;AActD,SAAS,cAAc;AAsJf,cACA,YADA;AA3CD,IAAM,iBAAgD,CAAC;AAAA,EAC5D;AAAA,EACA,cAAc;AAAA,EACd,sBAAsB;AAAA,EACtB,mBAAmB;AAAA,EACnB;AAAA,EACA,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA;AAAA,EACA,qBAAqB;AAAA,EACrB,QAAAA,UAAS;AAAA,EACT,QAAAC,UAAS;AAAA,EACT,QAAAC,UAAS;AAAA,EACT,UAAAC,YAAW;AAAA,EACX,OAAAC,SAAQ;AAAA,EACR,gBAAAC,kBAAiB;AAAA,EACjB;AACF,MAAM;AACJ,QAAM,EAAE,iBAAiB,QAAQ,QAAQ,MAAM,WAAW,OAAO,SAAS,IAAI,eAAe;AAAA,IAC3F,IAAI,OAAO;AAAA,IACX;AAAA,IACA,wBAAwB;AAAA,EAC1B,CAAC;AAED,QAAM,CAAC,WAAW,YAAY,IAAI,MAAM,SAAS,WAAW;AAE5D,QAAM,UAAU,CAAC,SAAkB;AACjC,2CAAY;AACZ,iBAAa,IAAI;AAAA,EACnB;AAEA,QAAM,cAAc,CAAO,YAAoB;AAC7C,WAAO;AAAA,MACL,IAAI,OAAO;AAAA,MACX,SAAS;AAAA,MACT,MAAM;AAAA,IACR,CAAC;AAAA,EACH;AAEA,SACE,oBAAC,uBAAoB,OAAc,QACjC,+BAAC,SAAI,WACH;AAAA,wBAACJ,SAAA,EAAO,MAAM,WAAW,SAAkB;AAAA,IAC3C;AAAA,MAACD;AAAA,MAAA;AAAA,QACC,MAAM;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QAEA;AAAA,8BAACE,SAAA,EAAO,MAAM,WAAW,SAAkB;AAAA,UAC3C,oBAACC,WAAA,EAAS,UAAU,iBAAiB,YAAY,WAAW;AAAA,UAC5D,oBAACC,QAAA,EAAM,YAAY,WAAW,QAAQ,aACnC,gCAAsB,gBAAgB,SAAS,KAC9C,oBAACC,iBAAA,EAAe,SAAS,YAAY,OAAO,QAAQ,YAAY,WAAW,GAE/E;AAAA;AAAA;AAAA,IACF;AAAA,KACF,GACF;AAEJ","sourcesContent":["import React from \"react\";\nimport { CopilotKitChatIcons, ChatContextProvider, CopilotKitChatLabels } from \"./ChatContext\";\nimport { SystemMessageFunction, useCopilotChat } from \"@copilotkit/react-core\";\nimport {\n ButtonProps,\n HeaderProps,\n WindowProps,\n MessagesProps,\n InputProps,\n ResponseButtonProps,\n} from \"./props\";\nimport { Window as DefaultWindow } from \"./Window\";\nimport { Button as DefaultButton } from \"./Button\";\nimport { Header as DefaultHeader } from \"./Header\";\nimport { Messages as DefaultMessages } from \"./Messages\";\nimport { Input as DefaultInput } from \"./Input\";\nimport { nanoid } from \"nanoid\";\nimport { ResponseButton as DefaultResponseButton } from \"./Response\";\n\n/**\n * Props for CopilotKitChat component.\n */\nexport interface CopilotKitChatProps {\n /**\n * Custom instructions to be added to the system message. Use this property to\n * provide additional context or guidance to the language model, influencing\n * its responses. These instructions can include specific directions,\n * preferences, or criteria that the model should consider when generating\n * its output, thereby tailoring the conversation more precisely to the\n * user's needs or the application's requirements.\n */\n instructions?: string;\n\n /**\n * Whether the chat window should be open by default.\n * @default false\n */\n defaultOpen?: boolean;\n\n /**\n * If the chat window should close when the user clicks outside of it.\n * @default true\n */\n clickOutsideToClose?: boolean;\n\n /**\n * If the chat window should close when the user hits the Escape key.\n * @default true\n */\n hitEscapeToClose?: boolean;\n\n /**\n * A callback that gets called when the chat window opens or closes.\n */\n onSetOpen?: (open: boolean) => void;\n\n /**\n * The hotkey to open the chat window.\n * Uses Command-<hotkey> on a Mac and Ctrl-<hotkey> on Windows.\n * @default \"e\"\n */\n hotkey?: string;\n\n /**\n * Icons can be used to set custom icons for the chat window.\n */\n icons?: CopilotKitChatIcons;\n\n /**\n * Labels can be used to set custom labels for the chat window.\n */\n labels?: CopilotKitChatLabels;\n\n /**\n * A function that takes in context string and instructions and returns\n * the system message to include in the chat request.\n * Use this to completely override the system message, when providing\n * instructions is not enough.\n */\n makeSystemMessage?: SystemMessageFunction;\n\n /**\n * Whether to show the response button.\n * @default true\n */\n showResponseButton?: boolean;\n\n /**\n * A custom Window component to use instead of the default.\n */\n Window?: React.ComponentType<WindowProps>;\n\n /**\n * A custom Button component to use instead of the default.\n */\n Button?: React.ComponentType<ButtonProps>;\n\n /**\n * A custom Header component to use instead of the default.\n */\n Header?: React.ComponentType<HeaderProps>;\n\n /**\n * A custom Messages component to use instead of the default.\n */\n Messages?: React.ComponentType<MessagesProps>;\n\n /**\n * A custom Input component to use instead of the default.\n */\n Input?: React.ComponentType<InputProps>;\n\n /**\n * A custom ResponseButton component to use instead of the default.\n */\n ResponseButton?: React.ComponentType<ResponseButtonProps>;\n\n /**\n * A class name to apply to the root element.\n */\n className?: string;\n}\n\nexport const CopilotKitChat: React.FC<CopilotKitChatProps> = ({\n instructions,\n defaultOpen = false,\n clickOutsideToClose = true,\n hitEscapeToClose = true,\n onSetOpen,\n hotkey = \"e\",\n icons,\n labels,\n makeSystemMessage,\n showResponseButton = true,\n Window = DefaultWindow,\n Button = DefaultButton,\n Header = DefaultHeader,\n Messages = DefaultMessages,\n Input = DefaultInput,\n ResponseButton = DefaultResponseButton,\n className,\n}) => {\n const { visibleMessages, append, reload, stop, isLoading, input, setInput } = useCopilotChat({\n id: nanoid(),\n makeSystemMessage,\n additionalInstructions: instructions,\n });\n\n const [openState, setOpenState] = React.useState(defaultOpen);\n\n const setOpen = (open: boolean) => {\n onSetOpen?.(open);\n setOpenState(open);\n };\n\n const sendMessage = async (message: string) => {\n append({\n id: nanoid(),\n content: message,\n role: \"user\",\n });\n };\n\n return (\n <ChatContextProvider icons={icons} labels={labels}>\n <div className={className}>\n <Button open={openState} setOpen={setOpen}></Button>\n <Window\n open={openState}\n setOpen={setOpen}\n clickOutsideToClose={clickOutsideToClose}\n hotkey={hotkey}\n hitEscapeToClose={hitEscapeToClose}\n >\n <Header open={openState} setOpen={setOpen} />\n <Messages messages={visibleMessages} inProgress={isLoading} />\n <Input inProgress={isLoading} onSend={sendMessage}>\n {showResponseButton && visibleMessages.length > 0 && (\n <ResponseButton onClick={isLoading ? stop : reload} inProgress={isLoading} />\n )}\n </Input>\n </Window>\n </div>\n </ChatContextProvider>\n );\n};\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useChatContext } from './chunk-6H3Y2XEI.mjs';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
var Header = ({ setOpen }) => {
|
|
5
|
+
const context = useChatContext();
|
|
6
|
+
return /* @__PURE__ */ jsxs("div", { className: "copilotKitHeader", children: [
|
|
7
|
+
/* @__PURE__ */ jsx("div", { children: context.labels.title }),
|
|
8
|
+
/* @__PURE__ */ jsx("button", { onClick: () => setOpen(false), "aria-label": "Close", children: context.icons.headerCloseIcon })
|
|
9
|
+
] });
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { Header };
|
|
13
|
+
//# sourceMappingURL=out.js.map
|
|
14
|
+
//# sourceMappingURL=chunk-DPUPEOGG.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/Header.tsx"],"names":[],"mappings":";;;;;AAQI,SACE,KADF;AAJG,IAAM,SAAgC,CAAC,EAAE,QAAQ,MAAM;AAC5D,QAAM,UAAU,eAAe;AAE/B,SACE,qBAAC,SAAI,WAAU,oBACb;AAAA,wBAAC,SAAK,kBAAQ,OAAO,OAAM;AAAA,IAC3B,oBAAC,YAAO,SAAS,MAAM,QAAQ,KAAK,GAAG,cAAW,SAC/C,kBAAQ,MAAM,iBACjB;AAAA,KACF;AAEJ","sourcesContent":["import React from \"react\";\nimport { HeaderProps } from \"./props\";\nimport { useChatContext } from \"./ChatContext\";\n\nexport const Header: React.FC<HeaderProps> = ({ setOpen }) => {\n const context = useChatContext();\n\n return (\n <div className=\"copilotKitHeader\">\n <div>{context.labels.title}</div>\n <button onClick={() => setOpen(false)} aria-label=\"Close\">\n {context.icons.headerCloseIcon}\n </button>\n </div>\n );\n};\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useChatContext } from './chunk-6H3Y2XEI.mjs';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
var ResponseButton = ({ onClick, inProgress }) => {
|
|
5
|
+
const context = useChatContext();
|
|
6
|
+
return /* @__PURE__ */ jsxs("button", { onClick, className: "copilotKitResponseButton", children: [
|
|
7
|
+
/* @__PURE__ */ jsx("span", { children: inProgress ? context.icons.stopIcon : context.icons.regenerateIcon }),
|
|
8
|
+
inProgress ? context.labels.stopGenerating : context.labels.regenerateResponse
|
|
9
|
+
] });
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { ResponseButton };
|
|
13
|
+
//# sourceMappingURL=out.js.map
|
|
14
|
+
//# sourceMappingURL=chunk-GPEJCUWA.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/Response.tsx"],"names":[],"mappings":";;;;;AAOI,SACE,KADF;AAHG,IAAM,iBAAgD,CAAC,EAAE,SAAS,WAAW,MAAM;AACxF,QAAM,UAAU,eAAe;AAC/B,SACE,qBAAC,YAAO,SAAkB,WAAU,4BAClC;AAAA,wBAAC,UAAM,uBAAa,QAAQ,MAAM,WAAW,QAAQ,MAAM,gBAAe;AAAA,IACzE,aAAa,QAAQ,OAAO,iBAAiB,QAAQ,OAAO;AAAA,KAC/D;AAEJ","sourcesContent":["import React from \"react\";\nimport { useChatContext } from \"./ChatContext\";\nimport { ResponseButtonProps } from \"./props\";\n\nexport const ResponseButton: React.FC<ResponseButtonProps> = ({ onClick, inProgress }) => {\n const context = useChatContext();\n return (\n <button onClick={onClick} className=\"copilotKitResponseButton\">\n <span>{inProgress ? context.icons.stopIcon : context.icons.regenerateIcon}</span>\n {inProgress ? context.labels.stopGenerating : context.labels.regenerateResponse}\n </button>\n );\n};\n"]}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { DownloadIcon, CheckIcon, CopyIcon } from './chunk-7YXG7D47.mjs';
|
|
2
|
+
import { useCopyToClipboard } from './chunk-POVINPXX.mjs';
|
|
3
|
+
import { memo } from 'react';
|
|
4
|
+
import { Prism } from 'react-syntax-highlighter';
|
|
5
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
var CodeActionButton = ({ onClick, children }) => {
|
|
8
|
+
let className = "inline-flex items-center justify-center rounded-md text-sm font-medium 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 ";
|
|
9
|
+
className += "hover:bg-zinc-800 focus-visible:ring-1 focus-visible:ring-slate-700 focus-visible:ring-offset-0 ";
|
|
10
|
+
className += "hover:bg-accent hover:text-accent-foreground ";
|
|
11
|
+
className += "h-10 w-10";
|
|
12
|
+
return /* @__PURE__ */ jsx("button", { className, onClick, children });
|
|
13
|
+
};
|
|
14
|
+
var programmingLanguages = {
|
|
15
|
+
javascript: ".js",
|
|
16
|
+
python: ".py",
|
|
17
|
+
java: ".java",
|
|
18
|
+
c: ".c",
|
|
19
|
+
cpp: ".cpp",
|
|
20
|
+
"c++": ".cpp",
|
|
21
|
+
"c#": ".cs",
|
|
22
|
+
ruby: ".rb",
|
|
23
|
+
php: ".php",
|
|
24
|
+
swift: ".swift",
|
|
25
|
+
"objective-c": ".m",
|
|
26
|
+
kotlin: ".kt",
|
|
27
|
+
typescript: ".ts",
|
|
28
|
+
go: ".go",
|
|
29
|
+
perl: ".pl",
|
|
30
|
+
rust: ".rs",
|
|
31
|
+
scala: ".scala",
|
|
32
|
+
haskell: ".hs",
|
|
33
|
+
lua: ".lua",
|
|
34
|
+
shell: ".sh",
|
|
35
|
+
sql: ".sql",
|
|
36
|
+
html: ".html",
|
|
37
|
+
css: ".css"
|
|
38
|
+
// add more file extensions here, make sure the key is same as language prop in CodeBlock.tsx component
|
|
39
|
+
};
|
|
40
|
+
var generateRandomString = (length, lowercase = false) => {
|
|
41
|
+
const chars = "ABCDEFGHJKLMNPQRSTUVWXY3456789";
|
|
42
|
+
let result = "";
|
|
43
|
+
for (let i = 0; i < length; i++) {
|
|
44
|
+
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
45
|
+
}
|
|
46
|
+
return lowercase ? result.toLowerCase() : result;
|
|
47
|
+
};
|
|
48
|
+
var CodeBlock = memo(({ language, value }) => {
|
|
49
|
+
const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2e3 });
|
|
50
|
+
const downloadAsFile = () => {
|
|
51
|
+
if (typeof window === "undefined") {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const fileExtension = programmingLanguages[language] || ".file";
|
|
55
|
+
const suggestedFileName = `file-${generateRandomString(3, true)}${fileExtension}`;
|
|
56
|
+
const fileName = window.prompt("Enter file name", suggestedFileName);
|
|
57
|
+
if (!fileName) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const blob = new Blob([value], { type: "text/plain" });
|
|
61
|
+
const url = URL.createObjectURL(blob);
|
|
62
|
+
const link = document.createElement("a");
|
|
63
|
+
link.download = fileName;
|
|
64
|
+
link.href = url;
|
|
65
|
+
link.style.display = "none";
|
|
66
|
+
document.body.appendChild(link);
|
|
67
|
+
link.click();
|
|
68
|
+
document.body.removeChild(link);
|
|
69
|
+
URL.revokeObjectURL(url);
|
|
70
|
+
};
|
|
71
|
+
const onCopy = () => {
|
|
72
|
+
if (isCopied)
|
|
73
|
+
return;
|
|
74
|
+
copyToClipboard(value);
|
|
75
|
+
};
|
|
76
|
+
return /* @__PURE__ */ jsxs("div", { className: "codeblock relative w-full bg-zinc-950 font-sans", children: [
|
|
77
|
+
/* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between bg-zinc-800 px-6 py-2 pr-4 text-zinc-100", children: [
|
|
78
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs lowercase", children: language }),
|
|
79
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-1", children: [
|
|
80
|
+
/* @__PURE__ */ jsxs(CodeActionButton, { onClick: downloadAsFile, children: [
|
|
81
|
+
/* @__PURE__ */ jsx(DownloadIcon, {}),
|
|
82
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Download" })
|
|
83
|
+
] }),
|
|
84
|
+
/* @__PURE__ */ jsxs(CodeActionButton, { onClick: onCopy, children: [
|
|
85
|
+
isCopied ? /* @__PURE__ */ jsx(CheckIcon, {}) : /* @__PURE__ */ jsx(CopyIcon, {}),
|
|
86
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Copy code" })
|
|
87
|
+
] })
|
|
88
|
+
] })
|
|
89
|
+
] }),
|
|
90
|
+
/* @__PURE__ */ jsx(
|
|
91
|
+
Prism,
|
|
92
|
+
{
|
|
93
|
+
language,
|
|
94
|
+
PreTag: "div",
|
|
95
|
+
showLineNumbers: true,
|
|
96
|
+
customStyle: {
|
|
97
|
+
margin: 0,
|
|
98
|
+
width: "100%",
|
|
99
|
+
background: "transparent",
|
|
100
|
+
padding: "1.5rem 1rem"
|
|
101
|
+
},
|
|
102
|
+
codeTagProps: {
|
|
103
|
+
style: {
|
|
104
|
+
fontSize: "0.9rem",
|
|
105
|
+
fontFamily: "var(--font-mono)"
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
children: value
|
|
109
|
+
}
|
|
110
|
+
)
|
|
111
|
+
] });
|
|
112
|
+
});
|
|
113
|
+
CodeBlock.displayName = "CodeBlock";
|
|
114
|
+
|
|
115
|
+
export { CodeBlock, generateRandomString, programmingLanguages };
|
|
116
|
+
//# sourceMappingURL=out.js.map
|
|
117
|
+
//# sourceMappingURL=chunk-NXWVWC33.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/CodeBlock.tsx"],"names":[],"mappings":"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","sourcesContent":["\"use client\";\n\nimport { FC, memo } from \"react\";\nimport { Prism as SyntaxHighlighter } from \"react-syntax-highlighter\";\n\nimport { useCopyToClipboard } from \"../../hooks/use-copy-to-clipboard\";\nimport { CheckIcon, CopyIcon, DownloadIcon } from \"./Icons\";\n\ninterface CodeActionButtonProps {\n onClick: () => void;\n children: React.ReactNode;\n}\n\nconst CodeActionButton: FC<CodeActionButtonProps> = ({ onClick, children }) => {\n let className =\n \"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background \" +\n \"transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring \" +\n \"focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 \";\n\n className +=\n \"hover:bg-zinc-800 focus-visible:ring-1 focus-visible:ring-slate-700 focus-visible:ring-offset-0 \";\n className += \"hover:bg-accent hover:text-accent-foreground \";\n className += \"h-10 w-10\";\n\n return (\n <button className={className} onClick={onClick}>\n {children}\n </button>\n );\n};\n\ninterface Props {\n language: string;\n value: string;\n}\n\ninterface languageMap {\n [key: string]: string | undefined;\n}\n\nexport const programmingLanguages: languageMap = {\n javascript: \".js\",\n python: \".py\",\n java: \".java\",\n c: \".c\",\n cpp: \".cpp\",\n \"c++\": \".cpp\",\n \"c#\": \".cs\",\n ruby: \".rb\",\n php: \".php\",\n swift: \".swift\",\n \"objective-c\": \".m\",\n kotlin: \".kt\",\n typescript: \".ts\",\n go: \".go\",\n perl: \".pl\",\n rust: \".rs\",\n scala: \".scala\",\n haskell: \".hs\",\n lua: \".lua\",\n shell: \".sh\",\n sql: \".sql\",\n html: \".html\",\n css: \".css\",\n // add more file extensions here, make sure the key is same as language prop in CodeBlock.tsx component\n};\n\nexport const generateRandomString = (length: number, lowercase = false) => {\n const chars = \"ABCDEFGHJKLMNPQRSTUVWXY3456789\"; // excluding similar looking characters like Z, 2, I, 1, O, 0\n let result = \"\";\n for (let i = 0; i < length; i++) {\n result += chars.charAt(Math.floor(Math.random() * chars.length));\n }\n return lowercase ? result.toLowerCase() : result;\n};\n\nconst CodeBlock: FC<Props> = memo(({ language, value }) => {\n const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2000 });\n\n const downloadAsFile = () => {\n if (typeof window === \"undefined\") {\n return;\n }\n const fileExtension = programmingLanguages[language] || \".file\";\n const suggestedFileName = `file-${generateRandomString(3, true)}${fileExtension}`;\n const fileName = window.prompt(\"Enter file name\" || \"\", suggestedFileName);\n\n if (!fileName) {\n // User pressed cancel on prompt.\n return;\n }\n\n const blob = new Blob([value], { type: \"text/plain\" });\n const url = URL.createObjectURL(blob);\n const link = document.createElement(\"a\");\n link.download = fileName;\n link.href = url;\n link.style.display = \"none\";\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n URL.revokeObjectURL(url);\n };\n\n const onCopy = () => {\n if (isCopied) return;\n copyToClipboard(value);\n };\n\n return (\n <div className=\"codeblock relative w-full bg-zinc-950 font-sans\">\n <div className=\"flex w-full items-center justify-between bg-zinc-800 px-6 py-2 pr-4 text-zinc-100\">\n <span className=\"text-xs lowercase\">{language}</span>\n <div className=\"flex items-center space-x-1\">\n <CodeActionButton onClick={downloadAsFile}>\n <DownloadIcon />\n <span className=\"sr-only\">Download</span>\n </CodeActionButton>\n <CodeActionButton onClick={onCopy}>\n {isCopied ? <CheckIcon /> : <CopyIcon />}\n <span className=\"sr-only\">Copy code</span>\n </CodeActionButton>\n </div>\n </div>\n <SyntaxHighlighter\n language={language}\n PreTag=\"div\"\n showLineNumbers\n customStyle={{\n margin: 0,\n width: \"100%\",\n background: \"transparent\",\n padding: \"1.5rem 1rem\",\n }}\n codeTagProps={{\n style: {\n fontSize: \"0.9rem\",\n fontFamily: \"var(--font-mono)\",\n },\n }}\n >\n {value}\n </SyntaxHighlighter>\n </div>\n );\n});\nCodeBlock.displayName = \"CodeBlock\";\n\nexport { CodeBlock };\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Textarea_default } from './chunk-WM6BS77F.mjs';
|
|
2
|
+
import { useChatContext } from './chunk-6H3Y2XEI.mjs';
|
|
3
|
+
import { useRef, useState } from 'react';
|
|
4
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
var Input = ({ inProgress, onSend, children }) => {
|
|
7
|
+
const context = useChatContext();
|
|
8
|
+
const textareaRef = useRef(null);
|
|
9
|
+
const handleDivClick = (event) => {
|
|
10
|
+
var _a;
|
|
11
|
+
if (event.target !== event.currentTarget)
|
|
12
|
+
return;
|
|
13
|
+
(_a = textareaRef.current) == null ? void 0 : _a.focus();
|
|
14
|
+
};
|
|
15
|
+
const [text, setText] = useState("");
|
|
16
|
+
const send = () => {
|
|
17
|
+
var _a;
|
|
18
|
+
if (inProgress)
|
|
19
|
+
return;
|
|
20
|
+
onSend(text);
|
|
21
|
+
setText("");
|
|
22
|
+
(_a = textareaRef.current) == null ? void 0 : _a.focus();
|
|
23
|
+
};
|
|
24
|
+
const icon = inProgress ? context.icons.activityIcon : context.icons.sendIcon;
|
|
25
|
+
const disabled = inProgress || text.length === 0;
|
|
26
|
+
return /* @__PURE__ */ jsxs("div", { className: "copilotKitInput", onClick: handleDivClick, children: [
|
|
27
|
+
/* @__PURE__ */ jsx("span", { children }),
|
|
28
|
+
/* @__PURE__ */ jsx("button", { className: "copilotKitSendButton", disabled, onClick: send, children: icon }),
|
|
29
|
+
/* @__PURE__ */ jsx(
|
|
30
|
+
Textarea_default,
|
|
31
|
+
{
|
|
32
|
+
ref: textareaRef,
|
|
33
|
+
placeholder: context.labels.placeholder,
|
|
34
|
+
autoFocus: true,
|
|
35
|
+
maxRows: 5,
|
|
36
|
+
value: text,
|
|
37
|
+
onChange: (event) => setText(event.target.value),
|
|
38
|
+
onKeyDown: (event) => {
|
|
39
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
40
|
+
event.preventDefault();
|
|
41
|
+
send();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
] });
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export { Input };
|
|
50
|
+
//# sourceMappingURL=out.js.map
|
|
51
|
+
//# sourceMappingURL=chunk-QFASQEFJ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/Input.tsx"],"names":[],"mappings":";;;;;;;;AAAA,SAAgB,QAAQ,gBAAgB;AA6BpC,SACE,KADF;AAxBG,IAAM,QAA8B,CAAC,EAAE,YAAY,QAAQ,SAAS,MAAM;AAC/E,QAAM,UAAU,eAAe;AAC/B,QAAM,cAAc,OAA4B,IAAI;AAEpD,QAAM,iBAAiB,CAAC,UAA4C;AATtE;AAWI,QAAI,MAAM,WAAW,MAAM;AAAe;AAE1C,sBAAY,YAAZ,mBAAqB;AAAA,EACvB;AAEA,QAAM,CAAC,MAAM,OAAO,IAAI,SAAS,EAAE;AACnC,QAAM,OAAO,MAAM;AAjBrB;AAkBI,QAAI;AAAY;AAChB,WAAO,IAAI;AACX,YAAQ,EAAE;AAEV,sBAAY,YAAZ,mBAAqB;AAAA,EACvB;AAEA,QAAM,OAAO,aAAa,QAAQ,MAAM,eAAe,QAAQ,MAAM;AACrE,QAAM,WAAW,cAAc,KAAK,WAAW;AAE/C,SACE,qBAAC,SAAI,WAAU,mBAAkB,SAAS,gBACxC;AAAA,wBAAC,UAAM,UAAS;AAAA,IAChB,oBAAC,YAAO,WAAU,wBAAuB,UAAoB,SAAS,MACnE,gBACH;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC,KAAK;AAAA,QACL,aAAa,QAAQ,OAAO;AAAA,QAC5B,WAAW;AAAA,QACX,SAAS;AAAA,QACT,OAAO;AAAA,QACP,UAAU,CAAC,UAAU,QAAQ,MAAM,OAAO,KAAK;AAAA,QAC/C,WAAW,CAAC,UAAU;AACpB,cAAI,MAAM,QAAQ,WAAW,CAAC,MAAM,UAAU;AAC5C,kBAAM,eAAe;AACrB,iBAAK;AAAA,UACP;AAAA,QACF;AAAA;AAAA,IACF;AAAA,KACF;AAEJ","sourcesContent":["import React, { useRef, useState } from \"react\";\nimport { InputProps } from \"./props\";\nimport { useChatContext } from \"./ChatContext\";\nimport AutoResizingTextarea from \"./Textarea\";\n\nexport const Input: React.FC<InputProps> = ({ inProgress, onSend, children }) => {\n const context = useChatContext();\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n\n const handleDivClick = (event: React.MouseEvent<HTMLDivElement>) => {\n // Check if the clicked element is not the textarea itself\n if (event.target !== event.currentTarget) return;\n\n textareaRef.current?.focus();\n };\n\n const [text, setText] = useState(\"\");\n const send = () => {\n if (inProgress) return;\n onSend(text);\n setText(\"\");\n\n textareaRef.current?.focus();\n };\n\n const icon = inProgress ? context.icons.activityIcon : context.icons.sendIcon;\n const disabled = inProgress || text.length === 0;\n\n return (\n <div className=\"copilotKitInput\" onClick={handleDivClick}>\n <span>{children}</span>\n <button className=\"copilotKitSendButton\" disabled={disabled} onClick={send}>\n {icon}\n </button>\n <AutoResizingTextarea\n ref={textareaRef}\n placeholder={context.labels.placeholder}\n autoFocus={true}\n maxRows={5}\n value={text}\n onChange={(event) => setText(event.target.value)}\n onKeyDown={(event) => {\n if (event.key === \"Enter\" && !event.shiftKey) {\n event.preventDefault();\n send();\n }\n }}\n />\n </div>\n );\n};\n"]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { CodeBlock } from './chunk-NXWVWC33.mjs';
|
|
2
|
+
import { __objRest, __spreadProps, __spreadValues } from './chunk-MRXNTQOX.mjs';
|
|
3
|
+
import { memo } from 'react';
|
|
4
|
+
import ReactMarkdown from 'react-markdown';
|
|
5
|
+
import remarkGfm from 'remark-gfm';
|
|
6
|
+
import remarkMath from 'remark-math';
|
|
7
|
+
import { jsx } from 'react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
var MemoizedReactMarkdown = memo(
|
|
10
|
+
ReactMarkdown,
|
|
11
|
+
(prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.className === nextProps.className
|
|
12
|
+
);
|
|
13
|
+
var Markdown = ({ content }) => {
|
|
14
|
+
return /* @__PURE__ */ jsx(
|
|
15
|
+
MemoizedReactMarkdown,
|
|
16
|
+
{
|
|
17
|
+
className: "prose break-words dark:prose-invert prose-p:leading-relaxed prose-pre:p-0 text-sm",
|
|
18
|
+
components,
|
|
19
|
+
remarkPlugins: [remarkGfm, remarkMath],
|
|
20
|
+
children: content
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
var components = {
|
|
25
|
+
p({ children }) {
|
|
26
|
+
return /* @__PURE__ */ jsx("p", { className: "mb-2 last:mb-0", children });
|
|
27
|
+
},
|
|
28
|
+
code(_a) {
|
|
29
|
+
var _b = _a, { children, className, inline } = _b, props = __objRest(_b, ["children", "className", "inline"]);
|
|
30
|
+
if (children.length) {
|
|
31
|
+
if (children[0] == "\u258D") {
|
|
32
|
+
return /* @__PURE__ */ jsx("span", { className: "mt-1 animate-pulse cursor-default", children: "\u258D" });
|
|
33
|
+
}
|
|
34
|
+
children[0] = children[0].replace("`\u258D`", "\u258D");
|
|
35
|
+
}
|
|
36
|
+
const match = /language-(\w+)/.exec(className || "");
|
|
37
|
+
if (inline) {
|
|
38
|
+
return /* @__PURE__ */ jsx("code", __spreadProps(__spreadValues({ className }, props), { children }));
|
|
39
|
+
}
|
|
40
|
+
return /* @__PURE__ */ jsx(
|
|
41
|
+
CodeBlock,
|
|
42
|
+
__spreadValues({
|
|
43
|
+
language: match && match[1] || "",
|
|
44
|
+
value: String(children).replace(/\n$/, "")
|
|
45
|
+
}, props),
|
|
46
|
+
Math.random()
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export { Markdown };
|
|
52
|
+
//# sourceMappingURL=out.js.map
|
|
53
|
+
//# sourceMappingURL=chunk-UIRFLYXI.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/Markdown.tsx"],"names":[],"mappings":";;;;;;;;;;AACA,SAAa,YAAY;AACzB,OAAO,mBAA4C;AAEnD,OAAO,eAAe;AACtB,OAAO,gBAAgB;AAcnB;AAZJ,IAAM,wBAAqC;AAAA,EACzC;AAAA,EACA,CAAC,WAAW,cACV,UAAU,aAAa,UAAU,YAAY,UAAU,cAAc,UAAU;AACnF;AAMO,IAAM,WAAoC,CAAC,EAAE,QAAQ,MAAM;AAChE,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV;AAAA,MACA,eAAe,CAAC,WAAW,UAAU;AAAA,MAEpC;AAAA;AAAA,EACH;AAEJ;AAEA,IAAM,aAAyB;AAAA,EAC7B,EAAE,EAAE,SAAS,GAAG;AACd,WAAO,oBAAC,OAAE,WAAU,kBAAkB,UAAS;AAAA,EACjD;AAAA,EACA,KAAK,IAA2C;AAA3C,iBAAE,YAAU,WAAW,OAjC9B,IAiCO,IAAkC,kBAAlC,IAAkC,CAAhC,YAAU,aAAW;AAC1B,QAAI,SAAS,QAAQ;AACnB,UAAI,SAAS,CAAC,KAAK,UAAK;AACtB,eAAO,oBAAC,UAAK,WAAU,qCAAoC,oBAAC;AAAA,MAC9D;AAEA,eAAS,CAAC,IAAK,SAAS,CAAC,EAAa,QAAQ,YAAO,QAAG;AAAA,IAC1D;AAEA,UAAM,QAAQ,iBAAiB,KAAK,aAAa,EAAE;AAEnD,QAAI,QAAQ;AACV,aACE,oBAAC,uCAAK,aAA0B,QAA/B,EACE,WACH;AAAA,IAEJ;AAEA,WACE;AAAA,MAAC;AAAA;AAAA,QAEC,UAAW,SAAS,MAAM,CAAC,KAAM;AAAA,QACjC,OAAO,OAAO,QAAQ,EAAE,QAAQ,OAAO,EAAE;AAAA,SACrC;AAAA,MAHC,KAAK,OAAO;AAAA,IAInB;AAAA,EAEJ;AACF","sourcesContent":["import React from \"react\";\nimport { FC, memo } from \"react\";\nimport ReactMarkdown, { Options, Components } from \"react-markdown\";\nimport { CodeBlock } from \"./CodeBlock\";\nimport remarkGfm from \"remark-gfm\";\nimport remarkMath from \"remark-math\";\n\nconst MemoizedReactMarkdown: FC<Options> = memo(\n ReactMarkdown,\n (prevProps, nextProps) =>\n prevProps.children === nextProps.children && prevProps.className === nextProps.className,\n);\n\ntype MarkdownProps = {\n content: string;\n};\n\nexport const Markdown: React.FC<MarkdownProps> = ({ content }) => {\n return (\n <MemoizedReactMarkdown\n className=\"prose break-words dark:prose-invert prose-p:leading-relaxed prose-pre:p-0 text-sm\"\n components={components}\n remarkPlugins={[remarkGfm, remarkMath]}\n >\n {content}\n </MemoizedReactMarkdown>\n );\n};\n\nconst components: Components = {\n p({ children }) {\n return <p className=\"mb-2 last:mb-0\">{children}</p>;\n },\n code({ children, className, inline, ...props }) {\n if (children.length) {\n if (children[0] == \"▍\") {\n return <span className=\"mt-1 animate-pulse cursor-default\">▍</span>;\n }\n\n children[0] = (children[0] as string).replace(\"`▍`\", \"▍\");\n }\n\n const match = /language-(\\w+)/.exec(className || \"\");\n\n if (inline) {\n return (\n <code className={className} {...props}>\n {children}\n </code>\n );\n }\n\n return (\n <CodeBlock\n key={Math.random()}\n language={(match && match[1]) || \"\"}\n value={String(children).replace(/\\n$/, \"\")}\n {...props}\n />\n );\n },\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|