@aphrody/m3-ai 3.3.0 → 3.3.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/LICENSE.spaceui +21 -21
- package/dist/Markdown.d.ts +22 -0
- package/dist/Markdown.d.ts.map +1 -1
- package/dist/MessageBubble.d.ts +6 -3
- package/dist/MessageBubble.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +452 -30
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { forwardRef, useState, useMemo, useRef, useEffect, useId, useCallback } from 'react';
|
|
2
|
+
import { forwardRef, useState, useMemo, useRef, useEffect, isValidElement, useId, useCallback } from 'react';
|
|
3
3
|
import { clsx } from 'clsx';
|
|
4
4
|
import { AnimatePresence, motion } from 'motion/react';
|
|
5
5
|
import { usePopover, Popover, SelectPill, Icon, CircleButton, Button, DropdownMenu, Collapsible, CollapsibleTrigger, CollapsibleContent, Select, SelectOption, Input, TextArea } from '@aphrody/m3-primitives';
|
|
6
6
|
import { m3Easings, m3Durations } from '@aphrody/m3-motion';
|
|
7
7
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
8
8
|
import ReactMarkdown from 'react-markdown';
|
|
9
|
-
import remarkGfm from 'remark-gfm';
|
|
10
9
|
import rehypeRaw from 'rehype-raw';
|
|
10
|
+
import remarkGfm from 'remark-gfm';
|
|
11
11
|
|
|
12
12
|
// src/types.ts
|
|
13
13
|
var TASK_STATUS_ORDER = [
|
|
@@ -967,6 +967,396 @@ var bodyClass = {
|
|
|
967
967
|
medium: "text-body-medium",
|
|
968
968
|
large: "text-body-large"
|
|
969
969
|
};
|
|
970
|
+
function extractText(node) {
|
|
971
|
+
if (typeof node === "string") return node;
|
|
972
|
+
if (typeof node === "number") return String(node);
|
|
973
|
+
if (Array.isArray(node)) return node.map(extractText).join("");
|
|
974
|
+
if (isValidElement(node)) return extractText(node.props.children);
|
|
975
|
+
return "";
|
|
976
|
+
}
|
|
977
|
+
var LANGUAGE_MAP = {
|
|
978
|
+
typescript: "TypeScript",
|
|
979
|
+
ts: "TypeScript",
|
|
980
|
+
tsx: "TSX",
|
|
981
|
+
javascript: "JavaScript",
|
|
982
|
+
js: "JavaScript",
|
|
983
|
+
jsx: "JSX",
|
|
984
|
+
python: "Python",
|
|
985
|
+
py: "Python",
|
|
986
|
+
rust: "Rust",
|
|
987
|
+
rs: "Rust",
|
|
988
|
+
bash: "Bash",
|
|
989
|
+
sh: "Bash",
|
|
990
|
+
shell: "Bash",
|
|
991
|
+
zsh: "Bash",
|
|
992
|
+
json: "JSON",
|
|
993
|
+
jsonc: "JSONC",
|
|
994
|
+
sql: "SQL",
|
|
995
|
+
html: "HTML",
|
|
996
|
+
css: "CSS",
|
|
997
|
+
scss: "SCSS",
|
|
998
|
+
sass: "Sass",
|
|
999
|
+
yaml: "YAML",
|
|
1000
|
+
yml: "YAML",
|
|
1001
|
+
markdown: "Markdown",
|
|
1002
|
+
md: "Markdown",
|
|
1003
|
+
go: "Go",
|
|
1004
|
+
golang: "Go",
|
|
1005
|
+
java: "Java",
|
|
1006
|
+
c: "C",
|
|
1007
|
+
cpp: "C++",
|
|
1008
|
+
"c++": "C++",
|
|
1009
|
+
csharp: "C#",
|
|
1010
|
+
cs: "C#",
|
|
1011
|
+
"c#": "C#",
|
|
1012
|
+
ruby: "Ruby",
|
|
1013
|
+
rb: "Ruby",
|
|
1014
|
+
php: "PHP",
|
|
1015
|
+
swift: "Swift",
|
|
1016
|
+
kotlin: "Kotlin",
|
|
1017
|
+
kt: "Kotlin",
|
|
1018
|
+
xml: "XML",
|
|
1019
|
+
toml: "TOML",
|
|
1020
|
+
dockerfile: "Dockerfile",
|
|
1021
|
+
docker: "Dockerfile",
|
|
1022
|
+
graphql: "GraphQL",
|
|
1023
|
+
gql: "GraphQL",
|
|
1024
|
+
wasm: "WebAssembly",
|
|
1025
|
+
lua: "Lua",
|
|
1026
|
+
r: "R",
|
|
1027
|
+
diff: "Diff",
|
|
1028
|
+
plaintext: "Text",
|
|
1029
|
+
text: "Text",
|
|
1030
|
+
txt: "Text"
|
|
1031
|
+
};
|
|
1032
|
+
function detectLanguage(raw) {
|
|
1033
|
+
if (!raw) return { raw: "", label: "Code" };
|
|
1034
|
+
const cleaned = raw.replace(/^language-|^lang-/, "").toLowerCase().trim();
|
|
1035
|
+
if (LANGUAGE_MAP[cleaned]) {
|
|
1036
|
+
return { raw: cleaned, label: LANGUAGE_MAP[cleaned] };
|
|
1037
|
+
}
|
|
1038
|
+
const label = cleaned.length <= 3 ? cleaned.toUpperCase() : cleaned.charAt(0).toUpperCase() + cleaned.slice(1);
|
|
1039
|
+
return { raw: cleaned, label };
|
|
1040
|
+
}
|
|
1041
|
+
function CodeBlock({
|
|
1042
|
+
code: explicitCode,
|
|
1043
|
+
language: explicitLang,
|
|
1044
|
+
onCopy,
|
|
1045
|
+
className,
|
|
1046
|
+
children,
|
|
1047
|
+
...restProps
|
|
1048
|
+
}) {
|
|
1049
|
+
const { node: _node, ...props } = restProps;
|
|
1050
|
+
const [copied, setCopied] = useState(false);
|
|
1051
|
+
const timeoutRef = useRef(null);
|
|
1052
|
+
useEffect(() => {
|
|
1053
|
+
return () => {
|
|
1054
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
1055
|
+
};
|
|
1056
|
+
}, []);
|
|
1057
|
+
const childElement = isValidElement(children) ? children : null;
|
|
1058
|
+
const childProps = childElement ? childElement.props : null;
|
|
1059
|
+
const rawLangMatch = explicitLang ?? className?.match(/language-([a-zA-Z0-9_+#-]+)/)?.[1] ?? childProps?.className?.match(/language-([a-zA-Z0-9_+#-]+)/)?.[1];
|
|
1060
|
+
const { raw: rawLang, label: languageLabel } = detectLanguage(rawLangMatch);
|
|
1061
|
+
const rawCode = explicitCode ?? (childProps?.children ? extractText(childProps.children) : extractText(children));
|
|
1062
|
+
const codeContent = rawCode;
|
|
1063
|
+
const codeToCopy = rawCode.replace(/\n$/, "");
|
|
1064
|
+
const handleCopy = async () => {
|
|
1065
|
+
try {
|
|
1066
|
+
if (typeof navigator !== "undefined" && navigator.clipboard?.writeText) {
|
|
1067
|
+
await navigator.clipboard.writeText(codeToCopy);
|
|
1068
|
+
}
|
|
1069
|
+
} catch {
|
|
1070
|
+
}
|
|
1071
|
+
onCopy?.(codeToCopy);
|
|
1072
|
+
setCopied(true);
|
|
1073
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
1074
|
+
timeoutRef.current = setTimeout(() => {
|
|
1075
|
+
setCopied(false);
|
|
1076
|
+
}, 2e3);
|
|
1077
|
+
};
|
|
1078
|
+
return /* @__PURE__ */ jsxs(
|
|
1079
|
+
"div",
|
|
1080
|
+
{
|
|
1081
|
+
className: clsx(
|
|
1082
|
+
"my-3 overflow-hidden rounded-medium border border-outline-variant bg-surface-container-highest",
|
|
1083
|
+
className
|
|
1084
|
+
),
|
|
1085
|
+
...props,
|
|
1086
|
+
children: [
|
|
1087
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between border-b border-outline-variant bg-surface-container px-3 py-1.5", children: [
|
|
1088
|
+
/* @__PURE__ */ jsx("span", { className: "inline-flex items-center rounded-extra-small bg-surface-container-high px-2 py-0.5 text-label-small font-medium text-on-surface-variant border border-outline-variant/60", children: languageLabel }),
|
|
1089
|
+
/* @__PURE__ */ jsxs(
|
|
1090
|
+
"button",
|
|
1091
|
+
{
|
|
1092
|
+
type: "button",
|
|
1093
|
+
onClick: handleCopy,
|
|
1094
|
+
className: clsx(
|
|
1095
|
+
"inline-flex items-center gap-1.5 rounded-small px-2 py-1 text-label-small font-medium transition-colors duration-200",
|
|
1096
|
+
copied ? "text-success" : "text-on-surface-variant hover:bg-on-surface/8 hover:text-on-surface active:bg-on-surface/12",
|
|
1097
|
+
"focus-visible:outline-2 focus-visible:outline-primary"
|
|
1098
|
+
),
|
|
1099
|
+
"aria-label": copied ? "Copied" : "Copy code",
|
|
1100
|
+
title: copied ? "Copied!" : "Copy code",
|
|
1101
|
+
children: [
|
|
1102
|
+
/* @__PURE__ */ jsx(
|
|
1103
|
+
Icon,
|
|
1104
|
+
{
|
|
1105
|
+
name: copied ? "check" : "content_copy",
|
|
1106
|
+
size: 16,
|
|
1107
|
+
className: copied ? "text-success" : void 0
|
|
1108
|
+
}
|
|
1109
|
+
),
|
|
1110
|
+
/* @__PURE__ */ jsx("span", { children: copied ? "Copied!" : "Copy" })
|
|
1111
|
+
]
|
|
1112
|
+
}
|
|
1113
|
+
)
|
|
1114
|
+
] }),
|
|
1115
|
+
/* @__PURE__ */ jsx("pre", { className: "overflow-x-auto p-3 font-code text-body-small text-on-surface bg-surface-container-highest [&_code]:bg-transparent [&_code]:p-0 [&_code]:text-[length:inherit]", children: /* @__PURE__ */ jsx("code", { className: rawLang ? `language-${rawLang}` : void 0, children: codeContent }) })
|
|
1116
|
+
]
|
|
1117
|
+
}
|
|
1118
|
+
);
|
|
1119
|
+
}
|
|
1120
|
+
var GREEK_AND_SYMBOLS = {
|
|
1121
|
+
// Greek letters (lowercase)
|
|
1122
|
+
alpha: "\u03B1",
|
|
1123
|
+
beta: "\u03B2",
|
|
1124
|
+
gamma: "\u03B3",
|
|
1125
|
+
delta: "\u03B4",
|
|
1126
|
+
epsilon: "\u03B5",
|
|
1127
|
+
zeta: "\u03B6",
|
|
1128
|
+
eta: "\u03B7",
|
|
1129
|
+
theta: "\u03B8",
|
|
1130
|
+
iota: "\u03B9",
|
|
1131
|
+
kappa: "\u03BA",
|
|
1132
|
+
lambda: "\u03BB",
|
|
1133
|
+
mu: "\u03BC",
|
|
1134
|
+
nu: "\u03BD",
|
|
1135
|
+
xi: "\u03BE",
|
|
1136
|
+
pi: "\u03C0",
|
|
1137
|
+
rho: "\u03C1",
|
|
1138
|
+
sigma: "\u03C3",
|
|
1139
|
+
tau: "\u03C4",
|
|
1140
|
+
upsilon: "\u03C5",
|
|
1141
|
+
phi: "\u03C6",
|
|
1142
|
+
chi: "\u03C7",
|
|
1143
|
+
psi: "\u03C8",
|
|
1144
|
+
omega: "\u03C9",
|
|
1145
|
+
// Greek letters (uppercase)
|
|
1146
|
+
Gamma: "\u0393",
|
|
1147
|
+
Delta: "\u0394",
|
|
1148
|
+
Theta: "\u0398",
|
|
1149
|
+
Lambda: "\u039B",
|
|
1150
|
+
Xi: "\u039E",
|
|
1151
|
+
Pi: "\u03A0",
|
|
1152
|
+
Sigma: "\u03A3",
|
|
1153
|
+
Phi: "\u03A6",
|
|
1154
|
+
Psi: "\u03A8",
|
|
1155
|
+
Omega: "\u03A9",
|
|
1156
|
+
// Operators & Relations
|
|
1157
|
+
times: "\xD7",
|
|
1158
|
+
div: "\xF7",
|
|
1159
|
+
pm: "\xB1",
|
|
1160
|
+
mp: "\u2213",
|
|
1161
|
+
le: "\u2264",
|
|
1162
|
+
leq: "\u2264",
|
|
1163
|
+
ge: "\u2265",
|
|
1164
|
+
geq: "\u2265",
|
|
1165
|
+
approx: "\u2248",
|
|
1166
|
+
neq: "\u2260",
|
|
1167
|
+
ne: "\u2260",
|
|
1168
|
+
infty: "\u221E",
|
|
1169
|
+
cdot: "\xB7",
|
|
1170
|
+
circ: "\xB0",
|
|
1171
|
+
partial: "\u2202",
|
|
1172
|
+
nabla: "\u2207",
|
|
1173
|
+
sum: "\u2211",
|
|
1174
|
+
prod: "\u220F",
|
|
1175
|
+
int: "\u222B",
|
|
1176
|
+
sqrt: "\u221A",
|
|
1177
|
+
in: "\u2208",
|
|
1178
|
+
notin: "\u2209",
|
|
1179
|
+
subset: "\u2282",
|
|
1180
|
+
subseteq: "\u2286",
|
|
1181
|
+
cup: "\u222A",
|
|
1182
|
+
cap: "\u2229",
|
|
1183
|
+
to: "\u2192",
|
|
1184
|
+
rightarrow: "\u2192",
|
|
1185
|
+
leftarrow: "\u2190",
|
|
1186
|
+
leftrightarrow: "\u2194",
|
|
1187
|
+
Rightarrow: "\u21D2",
|
|
1188
|
+
Leftarrow: "\u21D0",
|
|
1189
|
+
Leftrightarrow: "\u21D4",
|
|
1190
|
+
forall: "\u2200",
|
|
1191
|
+
exists: "\u2203"
|
|
1192
|
+
};
|
|
1193
|
+
function formatSubSup(text) {
|
|
1194
|
+
const parts = text.split(
|
|
1195
|
+
/(\^\{[^}]+\}|\^[-+]?[a-zA-Z0-9\u0370-\u03FF\u2100-\u214F]|_\{[^}]+\}|_[-+]?[a-zA-Z0-9\u0370-\u03FF\u2100-\u214F])/g
|
|
1196
|
+
);
|
|
1197
|
+
if (parts.length === 1) return text;
|
|
1198
|
+
return parts.map((part, index) => {
|
|
1199
|
+
if (part.startsWith("^")) {
|
|
1200
|
+
const val = part.startsWith("^{") && part.endsWith("}") ? part.slice(2, -1) : part.slice(1);
|
|
1201
|
+
return /* @__PURE__ */ jsx("sup", { className: "text-[0.75em] leading-none", children: val }, index);
|
|
1202
|
+
}
|
|
1203
|
+
if (part.startsWith("_")) {
|
|
1204
|
+
const val = part.startsWith("_{") && part.endsWith("}") ? part.slice(2, -1) : part.slice(1);
|
|
1205
|
+
return /* @__PURE__ */ jsx("sub", { className: "text-[0.75em] leading-none", children: val }, index);
|
|
1206
|
+
}
|
|
1207
|
+
return part;
|
|
1208
|
+
});
|
|
1209
|
+
}
|
|
1210
|
+
function formatMathContent(math) {
|
|
1211
|
+
const text = math.replace(/\\+([a-zA-Z]+)/g, (match, name) => {
|
|
1212
|
+
return GREEK_AND_SYMBOLS[name] ?? match;
|
|
1213
|
+
});
|
|
1214
|
+
const fracRegex = /\\+frac\{([^{}]+)\}\{([^{}]+)\}/g;
|
|
1215
|
+
if (fracRegex.test(text)) {
|
|
1216
|
+
const parts = [];
|
|
1217
|
+
let lastIndex = 0;
|
|
1218
|
+
text.replace(fracRegex, (match, num, den, offset) => {
|
|
1219
|
+
if (offset > lastIndex) {
|
|
1220
|
+
parts.push(formatSubSup(text.slice(lastIndex, offset)));
|
|
1221
|
+
}
|
|
1222
|
+
parts.push(
|
|
1223
|
+
/* @__PURE__ */ jsxs(
|
|
1224
|
+
"span",
|
|
1225
|
+
{
|
|
1226
|
+
className: "inline-flex flex-col items-center align-middle mx-1 text-center text-[0.85em] leading-none not-italic",
|
|
1227
|
+
children: [
|
|
1228
|
+
/* @__PURE__ */ jsx("span", { className: "border-b border-current px-0.5 pb-0.5", children: formatSubSup(num) }),
|
|
1229
|
+
/* @__PURE__ */ jsx("span", { className: "px-0.5 pt-0.5", children: formatSubSup(den) })
|
|
1230
|
+
]
|
|
1231
|
+
},
|
|
1232
|
+
`frac-${offset}`
|
|
1233
|
+
)
|
|
1234
|
+
);
|
|
1235
|
+
lastIndex = offset + match.length;
|
|
1236
|
+
return match;
|
|
1237
|
+
});
|
|
1238
|
+
if (lastIndex < text.length) {
|
|
1239
|
+
parts.push(formatSubSup(text.slice(lastIndex)));
|
|
1240
|
+
}
|
|
1241
|
+
return parts;
|
|
1242
|
+
}
|
|
1243
|
+
return formatSubSup(text);
|
|
1244
|
+
}
|
|
1245
|
+
function InlineMath({ math, className, ...props }) {
|
|
1246
|
+
return /* @__PURE__ */ jsx(
|
|
1247
|
+
"span",
|
|
1248
|
+
{
|
|
1249
|
+
className: clsx(
|
|
1250
|
+
"inline-flex items-center px-1 font-serif italic font-medium text-primary",
|
|
1251
|
+
className
|
|
1252
|
+
),
|
|
1253
|
+
...props,
|
|
1254
|
+
children: formatMathContent(math)
|
|
1255
|
+
}
|
|
1256
|
+
);
|
|
1257
|
+
}
|
|
1258
|
+
function BlockMath({ math, className, ...props }) {
|
|
1259
|
+
return /* @__PURE__ */ jsx(
|
|
1260
|
+
"div",
|
|
1261
|
+
{
|
|
1262
|
+
className: clsx(
|
|
1263
|
+
"my-3 flex justify-center overflow-x-auto rounded-medium bg-surface-container-low/40 px-4 py-2 text-title-medium font-serif italic font-medium text-primary",
|
|
1264
|
+
className
|
|
1265
|
+
),
|
|
1266
|
+
...props,
|
|
1267
|
+
children: formatMathContent(math)
|
|
1268
|
+
}
|
|
1269
|
+
);
|
|
1270
|
+
}
|
|
1271
|
+
function remarkMathPlugin() {
|
|
1272
|
+
return (tree) => {
|
|
1273
|
+
function transformBlocks(parent) {
|
|
1274
|
+
if (!parent.children) return;
|
|
1275
|
+
const newChildren = [];
|
|
1276
|
+
for (const child of parent.children) {
|
|
1277
|
+
if (child.type === "paragraph" && Array.isArray(child.children)) {
|
|
1278
|
+
const hasBlockMath = child.children.some(
|
|
1279
|
+
(c) => c.type === "text" && /\$\$[\s\S]+?\$\$/.test(c.value)
|
|
1280
|
+
);
|
|
1281
|
+
if (hasBlockMath) {
|
|
1282
|
+
let currentParagraphChildren = [];
|
|
1283
|
+
for (const item of child.children) {
|
|
1284
|
+
if (item.type === "text" && /\$\$[\s\S]+?\$\$/.test(item.value)) {
|
|
1285
|
+
const parts = item.value.split(/(\$\$[\s\S]+?\$\$)/g);
|
|
1286
|
+
for (const part of parts) {
|
|
1287
|
+
if (part.startsWith("$$") && part.endsWith("$$") && part.length >= 4) {
|
|
1288
|
+
if (currentParagraphChildren.length > 0) {
|
|
1289
|
+
newChildren.push({
|
|
1290
|
+
type: "paragraph",
|
|
1291
|
+
children: currentParagraphChildren
|
|
1292
|
+
});
|
|
1293
|
+
currentParagraphChildren = [];
|
|
1294
|
+
}
|
|
1295
|
+
const mathVal = part.slice(2, -2).trim();
|
|
1296
|
+
newChildren.push({
|
|
1297
|
+
type: "mathBlock",
|
|
1298
|
+
data: {
|
|
1299
|
+
hName: "div",
|
|
1300
|
+
hProperties: { className: "math-block", "data-math": mathVal },
|
|
1301
|
+
hChildren: [{ type: "text", value: mathVal }]
|
|
1302
|
+
},
|
|
1303
|
+
children: [{ type: "text", value: mathVal }]
|
|
1304
|
+
});
|
|
1305
|
+
} else if (part.trim().length > 0) {
|
|
1306
|
+
currentParagraphChildren.push({ type: "text", value: part });
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
} else {
|
|
1310
|
+
currentParagraphChildren.push(item);
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
if (currentParagraphChildren.length > 0) {
|
|
1314
|
+
newChildren.push({
|
|
1315
|
+
type: "paragraph",
|
|
1316
|
+
children: currentParagraphChildren
|
|
1317
|
+
});
|
|
1318
|
+
}
|
|
1319
|
+
continue;
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
transformBlocks(child);
|
|
1323
|
+
newChildren.push(child);
|
|
1324
|
+
}
|
|
1325
|
+
parent.children = newChildren;
|
|
1326
|
+
}
|
|
1327
|
+
function transformInlines(node) {
|
|
1328
|
+
if (!node.children) return;
|
|
1329
|
+
const newChildren = [];
|
|
1330
|
+
for (const child of node.children) {
|
|
1331
|
+
if (child.type === "text" && typeof child.value === "string" && child.value.includes("$")) {
|
|
1332
|
+
const parts = child.value.split(/((?<!\\)\$(?!\s)[^$\n]+?(?<!\s)\$(?!\d))/g);
|
|
1333
|
+
for (const part of parts) {
|
|
1334
|
+
if (part.startsWith("$") && part.endsWith("$") && !part.startsWith("$$") && part.length > 2) {
|
|
1335
|
+
const mathVal = part.slice(1, -1).trim();
|
|
1336
|
+
newChildren.push({
|
|
1337
|
+
type: "mathInline",
|
|
1338
|
+
data: {
|
|
1339
|
+
hName: "span",
|
|
1340
|
+
hProperties: { className: "math-inline", "data-math": mathVal },
|
|
1341
|
+
hChildren: [{ type: "text", value: mathVal }]
|
|
1342
|
+
},
|
|
1343
|
+
children: [{ type: "text", value: mathVal }]
|
|
1344
|
+
});
|
|
1345
|
+
} else if (part) {
|
|
1346
|
+
newChildren.push({ type: "text", value: part });
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
} else {
|
|
1350
|
+
transformInlines(child);
|
|
1351
|
+
newChildren.push(child);
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
node.children = newChildren;
|
|
1355
|
+
}
|
|
1356
|
+
transformBlocks(tree);
|
|
1357
|
+
transformInlines(tree);
|
|
1358
|
+
};
|
|
1359
|
+
}
|
|
970
1360
|
function m3Components(size) {
|
|
971
1361
|
const body = bodyClass[size];
|
|
972
1362
|
return {
|
|
@@ -1067,17 +1457,7 @@ function m3Components(size) {
|
|
|
1067
1457
|
...props
|
|
1068
1458
|
}
|
|
1069
1459
|
),
|
|
1070
|
-
pre: ({ node: _node, className,
|
|
1071
|
-
"pre",
|
|
1072
|
-
{
|
|
1073
|
-
className: clsx(
|
|
1074
|
-
"my-3 overflow-x-auto rounded-small bg-surface-container-highest p-3 font-code text-body-small text-on-surface",
|
|
1075
|
-
"[&_code]:bg-transparent [&_code]:p-0 [&_code]:text-[length:inherit]",
|
|
1076
|
-
className
|
|
1077
|
-
),
|
|
1078
|
-
...props
|
|
1079
|
-
}
|
|
1080
|
-
),
|
|
1460
|
+
pre: ({ node: _node, children, className, style }) => /* @__PURE__ */ jsx(CodeBlock, { className, style, children }),
|
|
1081
1461
|
hr: ({ node: _node, className, ...props }) => /* @__PURE__ */ jsx("hr", { className: clsx("my-4 border-outline-variant", className), ...props }),
|
|
1082
1462
|
table: ({ node: _node, className, ...props }) => /* @__PURE__ */ jsx("div", { className: "my-3 overflow-x-auto rounded-small border border-outline-variant", children: /* @__PURE__ */ jsx("table", { className: clsx("w-full border-collapse", body, className), ...props }) }),
|
|
1083
1463
|
thead: ({ node: _node, className, ...props }) => /* @__PURE__ */ jsx("thead", { className: clsx("bg-surface-container", className), ...props }),
|
|
@@ -1106,7 +1486,21 @@ function m3Components(size) {
|
|
|
1106
1486
|
...props
|
|
1107
1487
|
}
|
|
1108
1488
|
),
|
|
1109
|
-
input: ({ node: _node, className, ...props }) => /* @__PURE__ */ jsx("input", { className: clsx("mr-2 accent-primary", className), ...props })
|
|
1489
|
+
input: ({ node: _node, className, ...props }) => /* @__PURE__ */ jsx("input", { className: clsx("mr-2 accent-primary", className), ...props }),
|
|
1490
|
+
div: ({ node: _node, className, children, ...props }) => {
|
|
1491
|
+
if (className?.includes("math-block")) {
|
|
1492
|
+
const math = props["data-math"] ?? extractText(children);
|
|
1493
|
+
return /* @__PURE__ */ jsx(BlockMath, { math, className });
|
|
1494
|
+
}
|
|
1495
|
+
return /* @__PURE__ */ jsx("div", { className, ...props, children });
|
|
1496
|
+
},
|
|
1497
|
+
span: ({ node: _node, className, children, ...props }) => {
|
|
1498
|
+
if (className?.includes("math-inline")) {
|
|
1499
|
+
const math = props["data-math"] ?? extractText(children);
|
|
1500
|
+
return /* @__PURE__ */ jsx(InlineMath, { math, className });
|
|
1501
|
+
}
|
|
1502
|
+
return /* @__PURE__ */ jsx("span", { className, ...props, children });
|
|
1503
|
+
}
|
|
1110
1504
|
};
|
|
1111
1505
|
}
|
|
1112
1506
|
var Markdown = forwardRef(
|
|
@@ -1119,7 +1513,7 @@ var Markdown = forwardRef(
|
|
|
1119
1513
|
children: /* @__PURE__ */ jsx(
|
|
1120
1514
|
ReactMarkdown,
|
|
1121
1515
|
{
|
|
1122
|
-
remarkPlugins: [remarkGfm],
|
|
1516
|
+
remarkPlugins: [remarkGfm, remarkMathPlugin],
|
|
1123
1517
|
rehypePlugins: allowHtml ? [rehypeRaw] : void 0,
|
|
1124
1518
|
components: m3Components(size),
|
|
1125
1519
|
children: content
|
|
@@ -1135,35 +1529,63 @@ function MessageBubble({
|
|
|
1135
1529
|
isUser,
|
|
1136
1530
|
isStreaming = false,
|
|
1137
1531
|
onCopy,
|
|
1532
|
+
onDislike,
|
|
1533
|
+
onFork,
|
|
1534
|
+
variant = "default",
|
|
1138
1535
|
className
|
|
1139
1536
|
}) {
|
|
1537
|
+
const isCodex = variant === "codex";
|
|
1140
1538
|
return /* @__PURE__ */ jsxs(
|
|
1141
1539
|
"div",
|
|
1142
1540
|
{
|
|
1143
|
-
className: clsx("group flex flex-col py-
|
|
1541
|
+
className: clsx("group flex flex-col py-1.5 w-full", isUser ? "items-end" : "items-start", className),
|
|
1144
1542
|
children: [
|
|
1145
1543
|
/* @__PURE__ */ jsx(
|
|
1146
1544
|
"div",
|
|
1147
1545
|
{
|
|
1148
1546
|
className: clsx(
|
|
1149
1547
|
"min-w-0",
|
|
1150
|
-
isUser ? "max-w-[80%] rounded-large rounded-br-extra-small bg-secondary-container px-4 py-2.5 text-body-large text-on-secondary-container" : "w-full max-w-full bg-transparent text-body-large text-on-surface"
|
|
1548
|
+
isUser ? isCodex ? "max-w-[75%] rounded-[28px] bg-surface-container-high px-5 py-3 text-body-large text-on-surface shadow-xs" : "max-w-[80%] rounded-large rounded-br-extra-small bg-secondary-container px-4 py-2.5 text-body-large text-on-secondary-container" : "w-full max-w-full bg-transparent text-body-large text-on-surface"
|
|
1151
1549
|
),
|
|
1152
1550
|
"aria-busy": isStreaming || void 0,
|
|
1153
|
-
children: isUser ? /* @__PURE__ */ jsx("div", { className: "whitespace-pre-wrap break-words", children: content }) : /* @__PURE__ */ jsx(Markdown, { content, size: "large", className: "break-words" })
|
|
1551
|
+
children: isUser ? /* @__PURE__ */ jsx("div", { className: "whitespace-pre-wrap break-words", children: content }) : /* @__PURE__ */ jsx(Markdown, { content, size: "large", className: "break-words font-sans" })
|
|
1154
1552
|
}
|
|
1155
1553
|
),
|
|
1156
|
-
!isUser && onCopy ? /* @__PURE__ */
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1554
|
+
!isUser && (onCopy || onDislike || onFork) ? /* @__PURE__ */ jsxs("div", { className: "mt-1.5 flex items-center gap-1 opacity-0 transition-opacity duration-200 ease-standard group-focus-within:opacity-100 group-hover:opacity-100", children: [
|
|
1555
|
+
onCopy && /* @__PURE__ */ jsx(
|
|
1556
|
+
CircleButton,
|
|
1557
|
+
{
|
|
1558
|
+
icon: "content_copy",
|
|
1559
|
+
variant: "standard",
|
|
1560
|
+
size: "sm",
|
|
1561
|
+
onClick: () => onCopy(content),
|
|
1562
|
+
"aria-label": isStreaming ? "Copy Streaming Message" : "Copy Message",
|
|
1563
|
+
title: isStreaming ? "Copy streaming message" : "Copier"
|
|
1564
|
+
}
|
|
1565
|
+
),
|
|
1566
|
+
onDislike && /* @__PURE__ */ jsx(
|
|
1567
|
+
CircleButton,
|
|
1568
|
+
{
|
|
1569
|
+
icon: "thumb_down",
|
|
1570
|
+
variant: "standard",
|
|
1571
|
+
size: "sm",
|
|
1572
|
+
onClick: () => onDislike(content),
|
|
1573
|
+
"aria-label": "Dislike",
|
|
1574
|
+
title: "Je n'aime pas"
|
|
1575
|
+
}
|
|
1576
|
+
),
|
|
1577
|
+
onFork && /* @__PURE__ */ jsx(
|
|
1578
|
+
CircleButton,
|
|
1579
|
+
{
|
|
1580
|
+
icon: "call_split",
|
|
1581
|
+
variant: "standard",
|
|
1582
|
+
size: "sm",
|
|
1583
|
+
onClick: onFork,
|
|
1584
|
+
"aria-label": "Fork",
|
|
1585
|
+
title: "Bifurquer \xE0 partir de ce tour"
|
|
1586
|
+
}
|
|
1587
|
+
)
|
|
1588
|
+
] }) : null
|
|
1167
1589
|
]
|
|
1168
1590
|
}
|
|
1169
1591
|
);
|
|
@@ -2222,6 +2644,6 @@ function TaskCreateForm({
|
|
|
2222
2644
|
);
|
|
2223
2645
|
}
|
|
2224
2646
|
|
|
2225
|
-
export { ChatComposer, InlineBranchCard, InlineWorkerCard, Markdown, MessageBubble, ModelOptionList, ModelSelector, TASK_PRIORITY_LABEL, TASK_STATUS_LABEL, TASK_STATUS_ORDER, TaskCreateForm, TaskDetail, TaskList, TaskPriorityIcon, TaskRow, TaskStatusIcon, ToolCall, groupModelsByProvider, isErrorResult, pairTranscriptSteps, tryParseJson };
|
|
2647
|
+
export { BlockMath, ChatComposer, CodeBlock, InlineBranchCard, InlineMath, InlineWorkerCard, Markdown, MessageBubble, ModelOptionList, ModelSelector, TASK_PRIORITY_LABEL, TASK_STATUS_LABEL, TASK_STATUS_ORDER, TaskCreateForm, TaskDetail, TaskList, TaskPriorityIcon, TaskRow, TaskStatusIcon, ToolCall, groupModelsByProvider, isErrorResult, pairTranscriptSteps, tryParseJson };
|
|
2226
2648
|
//# sourceMappingURL=index.js.map
|
|
2227
2649
|
//# sourceMappingURL=index.js.map
|