@malette/agent-sdk 0.1.3-beta.6 → 0.1.3-beta.8
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/dist/index.js +1494 -682
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +922 -112
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2,12 +2,12 @@ import Cookies2 from 'js-cookie';
|
|
|
2
2
|
import OSS from 'ali-oss';
|
|
3
3
|
import { create } from 'zustand';
|
|
4
4
|
import { devtools } from 'zustand/middleware';
|
|
5
|
-
import * as
|
|
6
|
-
import
|
|
5
|
+
import * as React16 from 'react';
|
|
6
|
+
import React16__default, { createContext, memo, useState, useEffect, useCallback, useMemo, useRef, useImperativeHandle, useContext } from 'react';
|
|
7
7
|
import { Image, X, Check, Copy, FileText, Code2, FileJson, FileCode, CheckCheck, Eye, ExternalLink, Download, ChevronUp, ChevronDown, Maximize2, Loader2, Clock, Sparkles, Bot, AlertTriangle, Play, Pencil, AlertCircle, Square, RotateCcw, SkipForward, Video, Zap, ChevronRight, CheckCircle2, XCircle, Ban, Users, Volume2, Pause, VolumeX, Lightbulb, RefreshCw, BookmarkPlus, Trash2, PenLine, ImageIcon, GripVertical, Minimize2, Smartphone, Tablet, Monitor, Globe, FileImage, ChevronLeft, LayoutGrid, Undo2, Redo2, Save, PanelLeft, ArrowLeft, Settings, UserCheck, ShieldCheck, Shield, User, Plus, PanelLeftClose, Search, MessageSquare, Unlink, ImagePlus, BookOpen, Send, HelpCircle, Lock, Calendar, Link, Tag, EyeOff, Folder, Share2, Wand2, Mic, CheckCircle, ListOrdered, FileEdit, Edit, ArrowRight } from 'lucide-react';
|
|
8
8
|
import ReactMarkdown from 'react-markdown';
|
|
9
9
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
10
|
-
import 'react-dom';
|
|
10
|
+
import ReactDOM from 'react-dom';
|
|
11
11
|
import { useShallow } from 'zustand/react/shallow';
|
|
12
12
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
13
13
|
import { Slot } from '@radix-ui/react-slot';
|
|
@@ -861,7 +861,7 @@ function getCacheKey(text3) {
|
|
|
861
861
|
return text3.slice(0, 200);
|
|
862
862
|
}
|
|
863
863
|
async function submitGenerateTask(text3) {
|
|
864
|
-
const response = await
|
|
864
|
+
const response = await fetcher("/api/v1/ai/design/generate", {
|
|
865
865
|
method: "POST",
|
|
866
866
|
headers: { "content-type": "application/json" },
|
|
867
867
|
credentials: "include",
|
|
@@ -875,11 +875,10 @@ async function submitGenerateTask(text3) {
|
|
|
875
875
|
version: "0.1.0"
|
|
876
876
|
})
|
|
877
877
|
});
|
|
878
|
-
if (!response.
|
|
878
|
+
if (!response.success) {
|
|
879
879
|
throw new Error(`TTS generate request failed: ${response.status}`);
|
|
880
880
|
}
|
|
881
|
-
const
|
|
882
|
-
const data = result.data ?? result;
|
|
881
|
+
const data = response.data;
|
|
883
882
|
console.log("[TTS] Generate task submitted:", data);
|
|
884
883
|
const publicId = data?.publicId || data?.recordVO?.publicId || (typeof data === "string" ? data : null);
|
|
885
884
|
if (!publicId) {
|
|
@@ -1578,6 +1577,7 @@ var useAgentStore = create()(
|
|
|
1578
1577
|
...state.artifacts,
|
|
1579
1578
|
[artifactId]: {
|
|
1580
1579
|
...existing,
|
|
1580
|
+
source,
|
|
1581
1581
|
currentContent: content,
|
|
1582
1582
|
version: existing.version + 1,
|
|
1583
1583
|
gmtModified: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -5182,7 +5182,7 @@ function remarkGfm(options) {
|
|
|
5182
5182
|
toMarkdownExtensions.push(gfmToMarkdown(settings));
|
|
5183
5183
|
}
|
|
5184
5184
|
|
|
5185
|
-
// node_modules/clsx/dist/clsx.mjs
|
|
5185
|
+
// ../../node_modules/clsx/dist/clsx.mjs
|
|
5186
5186
|
function r(e) {
|
|
5187
5187
|
var t, f, n = "";
|
|
5188
5188
|
if ("string" == typeof e || "number" == typeof e) n += e;
|
|
@@ -7756,7 +7756,7 @@ var MessageImageInternal = memo(function MessageImageInternal2({ src, alt, class
|
|
|
7756
7756
|
const cachedStatus = imageLoadedCache.get(src);
|
|
7757
7757
|
const [loaded, setLoaded] = useState(cachedStatus === "loaded");
|
|
7758
7758
|
const [error, setError] = useState(cachedStatus === "error");
|
|
7759
|
-
const imgRef =
|
|
7759
|
+
const imgRef = React16__default.useRef(null);
|
|
7760
7760
|
const [previewUrl, setPreviewUrl] = useState(null);
|
|
7761
7761
|
const ImagePreviewComp = useComponent("ImagePreview") || ImagePreviewInternal;
|
|
7762
7762
|
useEffect(() => {
|
|
@@ -7824,8 +7824,8 @@ var MessageImageInternal = memo(function MessageImageInternal2({ src, alt, class
|
|
|
7824
7824
|
] });
|
|
7825
7825
|
});
|
|
7826
7826
|
var MessageVideoInternal = memo(function MessageVideoInternal2({ src, className }) {
|
|
7827
|
-
const videoRef =
|
|
7828
|
-
const canvasRef =
|
|
7827
|
+
const videoRef = React16__default.useRef(null);
|
|
7828
|
+
const canvasRef = React16__default.useRef(null);
|
|
7829
7829
|
const [posterUrl, setPosterUrl] = useState(null);
|
|
7830
7830
|
const [isHovering, setIsHovering] = useState(false);
|
|
7831
7831
|
const [isPlaying, setIsPlaying] = useState(false);
|
|
@@ -7833,7 +7833,7 @@ var MessageVideoInternal = memo(function MessageVideoInternal2({ src, className
|
|
|
7833
7833
|
const [duration, setDuration] = useState(0);
|
|
7834
7834
|
const [currentTime, setCurrentTime] = useState(0);
|
|
7835
7835
|
const [isFullPlaying, setIsFullPlaying] = useState(false);
|
|
7836
|
-
const hoverTimerRef =
|
|
7836
|
+
const hoverTimerRef = React16__default.useRef(null);
|
|
7837
7837
|
const VideoPreviewComp = useComponent("VideoPreview") || VideoPreviewInternal;
|
|
7838
7838
|
const [showPreview, setShowPreview] = useState(false);
|
|
7839
7839
|
useEffect(() => {
|
|
@@ -8838,13 +8838,13 @@ var ContentPreviewModal = memo(function ContentPreviewModal2({
|
|
|
8838
8838
|
} catch {
|
|
8839
8839
|
}
|
|
8840
8840
|
}, [parsed.content]);
|
|
8841
|
-
|
|
8841
|
+
React16__default.useEffect(() => {
|
|
8842
8842
|
document.body.style.overflow = "hidden";
|
|
8843
8843
|
return () => {
|
|
8844
8844
|
document.body.style.overflow = "";
|
|
8845
8845
|
};
|
|
8846
8846
|
}, []);
|
|
8847
|
-
|
|
8847
|
+
React16__default.useEffect(() => {
|
|
8848
8848
|
const handleKeyDown = (e) => {
|
|
8849
8849
|
if (e.key === "Escape") {
|
|
8850
8850
|
onClose();
|
|
@@ -8943,13 +8943,13 @@ var ContentPreviewRenderer = memo(function ContentPreviewRenderer2({
|
|
|
8943
8943
|
return /* @__PURE__ */ jsx(SourceCodeViewer, { content: parsed.content, language: parsed.language || parsed.type });
|
|
8944
8944
|
});
|
|
8945
8945
|
var HtmlPreview = memo(function HtmlPreview2({ content }) {
|
|
8946
|
-
const iframeRef =
|
|
8946
|
+
const iframeRef = React16__default.useRef(null);
|
|
8947
8947
|
const [scale, setScale] = useState(0.5);
|
|
8948
8948
|
const blobUrl = useMemo(() => {
|
|
8949
8949
|
const blob = new Blob([content], { type: "text/html" });
|
|
8950
8950
|
return URL.createObjectURL(blob);
|
|
8951
8951
|
}, [content]);
|
|
8952
|
-
|
|
8952
|
+
React16__default.useEffect(() => {
|
|
8953
8953
|
return () => {
|
|
8954
8954
|
URL.revokeObjectURL(blobUrl);
|
|
8955
8955
|
};
|
|
@@ -13333,8 +13333,7 @@ var ToolResultRenderer = memo(function ToolResultRenderer2({
|
|
|
13333
13333
|
if (!toolCallData) return void 0;
|
|
13334
13334
|
const resultAny = toolCallData.result;
|
|
13335
13335
|
const metadata = {};
|
|
13336
|
-
|
|
13337
|
-
if (resultAny?.relation?.toolName) metadata.toolName = resultAny.relation.toolName;
|
|
13336
|
+
metadata.toolName = toolCallData?.displayName || toolCallData?.name || "\u5DE5\u5177\u8C03\u7528";
|
|
13338
13337
|
if (toolCallData.arguments) metadata.generationParams = toolCallData.arguments;
|
|
13339
13338
|
if (resultAny?.relation) metadata.relation = resultAny.relation;
|
|
13340
13339
|
if (resultAny?.taskId) metadata.taskId = resultAny.taskId;
|
|
@@ -13364,8 +13363,7 @@ var ToolResultRenderer = memo(function ToolResultRenderer2({
|
|
|
13364
13363
|
{
|
|
13365
13364
|
onClick: (e) => {
|
|
13366
13365
|
e.stopPropagation();
|
|
13367
|
-
const
|
|
13368
|
-
const displayName = resultAny?.relation?.toolName || toolCallData?.name || "\u89C6\u9891\u751F\u6210";
|
|
13366
|
+
const displayName = toolCallData?.displayName || "\u89C6\u9891\u751F\u6210";
|
|
13369
13367
|
onOpenArtifact({
|
|
13370
13368
|
type: "video",
|
|
13371
13369
|
title: `${displayName} #${i + 1}`,
|
|
@@ -13419,8 +13417,7 @@ var ToolResultRenderer = memo(function ToolResultRenderer2({
|
|
|
13419
13417
|
{
|
|
13420
13418
|
onClick: (e) => {
|
|
13421
13419
|
e.stopPropagation();
|
|
13422
|
-
const
|
|
13423
|
-
const displayName = resultAny?.relation?.toolName || toolCallData?.name || "\u56FE\u7247\u751F\u6210";
|
|
13420
|
+
const displayName = toolCallData?.displayName || "\u56FE\u7247\u751F\u6210";
|
|
13424
13421
|
onOpenArtifact({
|
|
13425
13422
|
type: "image",
|
|
13426
13423
|
title: `${displayName} #${i + 1}`,
|
|
@@ -13589,7 +13586,10 @@ var ToolCallCard = memo(function ToolCallCard2({
|
|
|
13589
13586
|
result: toolCall.result,
|
|
13590
13587
|
mediaUrls,
|
|
13591
13588
|
config,
|
|
13592
|
-
toolCallData:
|
|
13589
|
+
toolCallData: {
|
|
13590
|
+
...toolCall,
|
|
13591
|
+
displayName: toolDisplayName
|
|
13592
|
+
},
|
|
13593
13593
|
defaultExpanded: false,
|
|
13594
13594
|
onOpenArtifact
|
|
13595
13595
|
}
|
|
@@ -13840,9 +13840,9 @@ var ThoughtTimelineCard = memo(function ThoughtTimelineCard2({ thought, config,
|
|
|
13840
13840
|
return null;
|
|
13841
13841
|
}
|
|
13842
13842
|
if (thought?.raw && Array.isArray(thought.raw)) {
|
|
13843
|
-
const hasConfirmationEvent = thought.raw.some((
|
|
13844
|
-
const type =
|
|
13845
|
-
return excludedTypes.includes(type) ||
|
|
13843
|
+
const hasConfirmationEvent = thought.raw.some((r2) => {
|
|
13844
|
+
const type = r2?.type || "";
|
|
13845
|
+
return excludedTypes.includes(type) || r2?.content && (r2.content.includes('"type":"tool_confirmed"') || r2.content.includes('"type":"component_submitted"') || r2.content.includes("\u7528\u6237\u786E\u8BA4\u6267\u884C\u5DE5\u5177\u8C03\u7528"));
|
|
13846
13846
|
});
|
|
13847
13847
|
if (hasConfirmationEvent) {
|
|
13848
13848
|
return null;
|
|
@@ -13853,7 +13853,7 @@ var ThoughtTimelineCard = memo(function ThoughtTimelineCard2({ thought, config,
|
|
|
13853
13853
|
const cleaned = sanitizeMarkdownContent(parseThinkingContent(withoutJsonImages));
|
|
13854
13854
|
if (!cleaned || !cleaned.trim()) return null;
|
|
13855
13855
|
const lineCount = useMemo(() => cleaned.split("\n").length, [cleaned]);
|
|
13856
|
-
|
|
13856
|
+
React16__default.useEffect(() => {
|
|
13857
13857
|
if (isLoading) {
|
|
13858
13858
|
setExpanded(true);
|
|
13859
13859
|
} else {
|
|
@@ -15771,7 +15771,111 @@ function __insertCSS(code3) {
|
|
|
15771
15771
|
head.appendChild(style);
|
|
15772
15772
|
style.styleSheet ? style.styleSheet.cssText = code3 : style.appendChild(document.createTextNode(code3));
|
|
15773
15773
|
}
|
|
15774
|
-
|
|
15774
|
+
var getAsset = (type) => {
|
|
15775
|
+
switch (type) {
|
|
15776
|
+
case "success":
|
|
15777
|
+
return SuccessIcon;
|
|
15778
|
+
case "info":
|
|
15779
|
+
return InfoIcon;
|
|
15780
|
+
case "warning":
|
|
15781
|
+
return WarningIcon;
|
|
15782
|
+
case "error":
|
|
15783
|
+
return ErrorIcon;
|
|
15784
|
+
default:
|
|
15785
|
+
return null;
|
|
15786
|
+
}
|
|
15787
|
+
};
|
|
15788
|
+
var bars = Array(12).fill(0);
|
|
15789
|
+
var Loader = ({ visible, className }) => {
|
|
15790
|
+
return /* @__PURE__ */ React16__default.createElement("div", {
|
|
15791
|
+
className: [
|
|
15792
|
+
"sonner-loading-wrapper",
|
|
15793
|
+
className
|
|
15794
|
+
].filter(Boolean).join(" "),
|
|
15795
|
+
"data-visible": visible
|
|
15796
|
+
}, /* @__PURE__ */ React16__default.createElement("div", {
|
|
15797
|
+
className: "sonner-spinner"
|
|
15798
|
+
}, bars.map((_, i) => /* @__PURE__ */ React16__default.createElement("div", {
|
|
15799
|
+
className: "sonner-loading-bar",
|
|
15800
|
+
key: `spinner-bar-${i}`
|
|
15801
|
+
}))));
|
|
15802
|
+
};
|
|
15803
|
+
var SuccessIcon = /* @__PURE__ */ React16__default.createElement("svg", {
|
|
15804
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
15805
|
+
viewBox: "0 0 20 20",
|
|
15806
|
+
fill: "currentColor",
|
|
15807
|
+
height: "20",
|
|
15808
|
+
width: "20"
|
|
15809
|
+
}, /* @__PURE__ */ React16__default.createElement("path", {
|
|
15810
|
+
fillRule: "evenodd",
|
|
15811
|
+
d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",
|
|
15812
|
+
clipRule: "evenodd"
|
|
15813
|
+
}));
|
|
15814
|
+
var WarningIcon = /* @__PURE__ */ React16__default.createElement("svg", {
|
|
15815
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
15816
|
+
viewBox: "0 0 24 24",
|
|
15817
|
+
fill: "currentColor",
|
|
15818
|
+
height: "20",
|
|
15819
|
+
width: "20"
|
|
15820
|
+
}, /* @__PURE__ */ React16__default.createElement("path", {
|
|
15821
|
+
fillRule: "evenodd",
|
|
15822
|
+
d: "M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",
|
|
15823
|
+
clipRule: "evenodd"
|
|
15824
|
+
}));
|
|
15825
|
+
var InfoIcon = /* @__PURE__ */ React16__default.createElement("svg", {
|
|
15826
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
15827
|
+
viewBox: "0 0 20 20",
|
|
15828
|
+
fill: "currentColor",
|
|
15829
|
+
height: "20",
|
|
15830
|
+
width: "20"
|
|
15831
|
+
}, /* @__PURE__ */ React16__default.createElement("path", {
|
|
15832
|
+
fillRule: "evenodd",
|
|
15833
|
+
d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",
|
|
15834
|
+
clipRule: "evenodd"
|
|
15835
|
+
}));
|
|
15836
|
+
var ErrorIcon = /* @__PURE__ */ React16__default.createElement("svg", {
|
|
15837
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
15838
|
+
viewBox: "0 0 20 20",
|
|
15839
|
+
fill: "currentColor",
|
|
15840
|
+
height: "20",
|
|
15841
|
+
width: "20"
|
|
15842
|
+
}, /* @__PURE__ */ React16__default.createElement("path", {
|
|
15843
|
+
fillRule: "evenodd",
|
|
15844
|
+
d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",
|
|
15845
|
+
clipRule: "evenodd"
|
|
15846
|
+
}));
|
|
15847
|
+
var CloseIcon = /* @__PURE__ */ React16__default.createElement("svg", {
|
|
15848
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
15849
|
+
width: "12",
|
|
15850
|
+
height: "12",
|
|
15851
|
+
viewBox: "0 0 24 24",
|
|
15852
|
+
fill: "none",
|
|
15853
|
+
stroke: "currentColor",
|
|
15854
|
+
strokeWidth: "1.5",
|
|
15855
|
+
strokeLinecap: "round",
|
|
15856
|
+
strokeLinejoin: "round"
|
|
15857
|
+
}, /* @__PURE__ */ React16__default.createElement("line", {
|
|
15858
|
+
x1: "18",
|
|
15859
|
+
y1: "6",
|
|
15860
|
+
x2: "6",
|
|
15861
|
+
y2: "18"
|
|
15862
|
+
}), /* @__PURE__ */ React16__default.createElement("line", {
|
|
15863
|
+
x1: "6",
|
|
15864
|
+
y1: "6",
|
|
15865
|
+
x2: "18",
|
|
15866
|
+
y2: "18"
|
|
15867
|
+
}));
|
|
15868
|
+
var useIsDocumentHidden = () => {
|
|
15869
|
+
const [isDocumentHidden, setIsDocumentHidden] = React16__default.useState(document.hidden);
|
|
15870
|
+
React16__default.useEffect(() => {
|
|
15871
|
+
const callback = () => {
|
|
15872
|
+
setIsDocumentHidden(document.hidden);
|
|
15873
|
+
};
|
|
15874
|
+
document.addEventListener("visibilitychange", callback);
|
|
15875
|
+
return () => window.removeEventListener("visibilitychange", callback);
|
|
15876
|
+
}, []);
|
|
15877
|
+
return isDocumentHidden;
|
|
15878
|
+
};
|
|
15775
15879
|
var toastsCounter = 1;
|
|
15776
15880
|
var Observer = class {
|
|
15777
15881
|
constructor() {
|
|
@@ -15912,7 +16016,7 @@ var Observer = class {
|
|
|
15912
16016
|
"resolve",
|
|
15913
16017
|
response
|
|
15914
16018
|
];
|
|
15915
|
-
const isReactElementResponse =
|
|
16019
|
+
const isReactElementResponse = React16__default.isValidElement(response);
|
|
15916
16020
|
if (isReactElementResponse) {
|
|
15917
16021
|
shouldDismiss = false;
|
|
15918
16022
|
this.create({
|
|
@@ -15924,7 +16028,7 @@ var Observer = class {
|
|
|
15924
16028
|
shouldDismiss = false;
|
|
15925
16029
|
const promiseData = typeof data.error === "function" ? await data.error(`HTTP error! status: ${response.status}`) : data.error;
|
|
15926
16030
|
const description = typeof data.description === "function" ? await data.description(`HTTP error! status: ${response.status}`) : data.description;
|
|
15927
|
-
const isExtendedResult = typeof promiseData === "object" && !
|
|
16031
|
+
const isExtendedResult = typeof promiseData === "object" && !React16__default.isValidElement(promiseData);
|
|
15928
16032
|
const toastSettings = isExtendedResult ? promiseData : {
|
|
15929
16033
|
message: promiseData
|
|
15930
16034
|
};
|
|
@@ -15938,7 +16042,7 @@ var Observer = class {
|
|
|
15938
16042
|
shouldDismiss = false;
|
|
15939
16043
|
const promiseData = typeof data.error === "function" ? await data.error(response) : data.error;
|
|
15940
16044
|
const description = typeof data.description === "function" ? await data.description(response) : data.description;
|
|
15941
|
-
const isExtendedResult = typeof promiseData === "object" && !
|
|
16045
|
+
const isExtendedResult = typeof promiseData === "object" && !React16__default.isValidElement(promiseData);
|
|
15942
16046
|
const toastSettings = isExtendedResult ? promiseData : {
|
|
15943
16047
|
message: promiseData
|
|
15944
16048
|
};
|
|
@@ -15952,7 +16056,7 @@ var Observer = class {
|
|
|
15952
16056
|
shouldDismiss = false;
|
|
15953
16057
|
const promiseData = typeof data.success === "function" ? await data.success(response) : data.success;
|
|
15954
16058
|
const description = typeof data.description === "function" ? await data.description(response) : data.description;
|
|
15955
|
-
const isExtendedResult = typeof promiseData === "object" && !
|
|
16059
|
+
const isExtendedResult = typeof promiseData === "object" && !React16__default.isValidElement(promiseData);
|
|
15956
16060
|
const toastSettings = isExtendedResult ? promiseData : {
|
|
15957
16061
|
message: promiseData
|
|
15958
16062
|
};
|
|
@@ -15972,7 +16076,7 @@ var Observer = class {
|
|
|
15972
16076
|
shouldDismiss = false;
|
|
15973
16077
|
const promiseData = typeof data.error === "function" ? await data.error(error) : data.error;
|
|
15974
16078
|
const description = typeof data.description === "function" ? await data.description(error) : data.description;
|
|
15975
|
-
const isExtendedResult = typeof promiseData === "object" && !
|
|
16079
|
+
const isExtendedResult = typeof promiseData === "object" && !React16__default.isValidElement(promiseData);
|
|
15976
16080
|
const toastSettings = isExtendedResult ? promiseData : {
|
|
15977
16081
|
message: promiseData
|
|
15978
16082
|
};
|
|
@@ -16001,10 +16105,10 @@ var Observer = class {
|
|
|
16001
16105
|
});
|
|
16002
16106
|
}
|
|
16003
16107
|
};
|
|
16004
|
-
this.custom = (
|
|
16108
|
+
this.custom = (jsx63, data) => {
|
|
16005
16109
|
const id = (data == null ? void 0 : data.id) || toastsCounter++;
|
|
16006
16110
|
this.create({
|
|
16007
|
-
jsx:
|
|
16111
|
+
jsx: jsx63(id),
|
|
16008
16112
|
id,
|
|
16009
16113
|
...data
|
|
16010
16114
|
});
|
|
@@ -16049,6 +16153,696 @@ var toast = Object.assign(basicToast, {
|
|
|
16049
16153
|
getToasts
|
|
16050
16154
|
});
|
|
16051
16155
|
__insertCSS("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");
|
|
16156
|
+
function isAction(action) {
|
|
16157
|
+
return action.label !== void 0;
|
|
16158
|
+
}
|
|
16159
|
+
var VISIBLE_TOASTS_AMOUNT = 3;
|
|
16160
|
+
var VIEWPORT_OFFSET = "24px";
|
|
16161
|
+
var MOBILE_VIEWPORT_OFFSET = "16px";
|
|
16162
|
+
var TOAST_LIFETIME = 4e3;
|
|
16163
|
+
var TOAST_WIDTH = 356;
|
|
16164
|
+
var GAP = 14;
|
|
16165
|
+
var SWIPE_THRESHOLD = 45;
|
|
16166
|
+
var TIME_BEFORE_UNMOUNT = 200;
|
|
16167
|
+
function cn2(...classes) {
|
|
16168
|
+
return classes.filter(Boolean).join(" ");
|
|
16169
|
+
}
|
|
16170
|
+
function getDefaultSwipeDirections(position) {
|
|
16171
|
+
const [y, x] = position.split("-");
|
|
16172
|
+
const directions = [];
|
|
16173
|
+
if (y) {
|
|
16174
|
+
directions.push(y);
|
|
16175
|
+
}
|
|
16176
|
+
if (x) {
|
|
16177
|
+
directions.push(x);
|
|
16178
|
+
}
|
|
16179
|
+
return directions;
|
|
16180
|
+
}
|
|
16181
|
+
var Toast = (props) => {
|
|
16182
|
+
var _toast_classNames, _toast_classNames1, _toast_classNames2, _toast_classNames3, _toast_classNames4, _toast_classNames5, _toast_classNames6, _toast_classNames7, _toast_classNames8;
|
|
16183
|
+
const { invert: ToasterInvert, toast: toast2, unstyled, interacting, setHeights, visibleToasts, heights, index, toasts, expanded, removeToast, defaultRichColors, closeButton: closeButtonFromToaster, style, cancelButtonStyle, actionButtonStyle, className = "", descriptionClassName = "", duration: durationFromToaster, position, gap, expandByDefault, classNames, icons, closeButtonAriaLabel = "Close toast" } = props;
|
|
16184
|
+
const [swipeDirection, setSwipeDirection] = React16__default.useState(null);
|
|
16185
|
+
const [swipeOutDirection, setSwipeOutDirection] = React16__default.useState(null);
|
|
16186
|
+
const [mounted, setMounted] = React16__default.useState(false);
|
|
16187
|
+
const [removed, setRemoved] = React16__default.useState(false);
|
|
16188
|
+
const [swiping, setSwiping] = React16__default.useState(false);
|
|
16189
|
+
const [swipeOut, setSwipeOut] = React16__default.useState(false);
|
|
16190
|
+
const [isSwiped, setIsSwiped] = React16__default.useState(false);
|
|
16191
|
+
const [offsetBeforeRemove, setOffsetBeforeRemove] = React16__default.useState(0);
|
|
16192
|
+
const [initialHeight, setInitialHeight] = React16__default.useState(0);
|
|
16193
|
+
const remainingTime = React16__default.useRef(toast2.duration || durationFromToaster || TOAST_LIFETIME);
|
|
16194
|
+
const dragStartTime = React16__default.useRef(null);
|
|
16195
|
+
const toastRef = React16__default.useRef(null);
|
|
16196
|
+
const isFront = index === 0;
|
|
16197
|
+
const isVisible = index + 1 <= visibleToasts;
|
|
16198
|
+
const toastType = toast2.type;
|
|
16199
|
+
const dismissible = toast2.dismissible !== false;
|
|
16200
|
+
const toastClassname = toast2.className || "";
|
|
16201
|
+
const toastDescriptionClassname = toast2.descriptionClassName || "";
|
|
16202
|
+
const heightIndex = React16__default.useMemo(() => heights.findIndex((height) => height.toastId === toast2.id) || 0, [
|
|
16203
|
+
heights,
|
|
16204
|
+
toast2.id
|
|
16205
|
+
]);
|
|
16206
|
+
const closeButton = React16__default.useMemo(() => {
|
|
16207
|
+
var _toast_closeButton;
|
|
16208
|
+
return (_toast_closeButton = toast2.closeButton) != null ? _toast_closeButton : closeButtonFromToaster;
|
|
16209
|
+
}, [
|
|
16210
|
+
toast2.closeButton,
|
|
16211
|
+
closeButtonFromToaster
|
|
16212
|
+
]);
|
|
16213
|
+
const duration = React16__default.useMemo(() => toast2.duration || durationFromToaster || TOAST_LIFETIME, [
|
|
16214
|
+
toast2.duration,
|
|
16215
|
+
durationFromToaster
|
|
16216
|
+
]);
|
|
16217
|
+
const closeTimerStartTimeRef = React16__default.useRef(0);
|
|
16218
|
+
const offset = React16__default.useRef(0);
|
|
16219
|
+
const lastCloseTimerStartTimeRef = React16__default.useRef(0);
|
|
16220
|
+
const pointerStartRef = React16__default.useRef(null);
|
|
16221
|
+
const [y, x] = position.split("-");
|
|
16222
|
+
const toastsHeightBefore = React16__default.useMemo(() => {
|
|
16223
|
+
return heights.reduce((prev, curr, reducerIndex) => {
|
|
16224
|
+
if (reducerIndex >= heightIndex) {
|
|
16225
|
+
return prev;
|
|
16226
|
+
}
|
|
16227
|
+
return prev + curr.height;
|
|
16228
|
+
}, 0);
|
|
16229
|
+
}, [
|
|
16230
|
+
heights,
|
|
16231
|
+
heightIndex
|
|
16232
|
+
]);
|
|
16233
|
+
const isDocumentHidden = useIsDocumentHidden();
|
|
16234
|
+
const invert = toast2.invert || ToasterInvert;
|
|
16235
|
+
const disabled = toastType === "loading";
|
|
16236
|
+
offset.current = React16__default.useMemo(() => heightIndex * gap + toastsHeightBefore, [
|
|
16237
|
+
heightIndex,
|
|
16238
|
+
toastsHeightBefore
|
|
16239
|
+
]);
|
|
16240
|
+
React16__default.useEffect(() => {
|
|
16241
|
+
remainingTime.current = duration;
|
|
16242
|
+
}, [
|
|
16243
|
+
duration
|
|
16244
|
+
]);
|
|
16245
|
+
React16__default.useEffect(() => {
|
|
16246
|
+
setMounted(true);
|
|
16247
|
+
}, []);
|
|
16248
|
+
React16__default.useEffect(() => {
|
|
16249
|
+
const toastNode = toastRef.current;
|
|
16250
|
+
if (toastNode) {
|
|
16251
|
+
const height = toastNode.getBoundingClientRect().height;
|
|
16252
|
+
setInitialHeight(height);
|
|
16253
|
+
setHeights((h) => [
|
|
16254
|
+
{
|
|
16255
|
+
toastId: toast2.id,
|
|
16256
|
+
height,
|
|
16257
|
+
position: toast2.position
|
|
16258
|
+
},
|
|
16259
|
+
...h
|
|
16260
|
+
]);
|
|
16261
|
+
return () => setHeights((h) => h.filter((height2) => height2.toastId !== toast2.id));
|
|
16262
|
+
}
|
|
16263
|
+
}, [
|
|
16264
|
+
setHeights,
|
|
16265
|
+
toast2.id
|
|
16266
|
+
]);
|
|
16267
|
+
React16__default.useLayoutEffect(() => {
|
|
16268
|
+
if (!mounted) return;
|
|
16269
|
+
const toastNode = toastRef.current;
|
|
16270
|
+
const originalHeight = toastNode.style.height;
|
|
16271
|
+
toastNode.style.height = "auto";
|
|
16272
|
+
const newHeight = toastNode.getBoundingClientRect().height;
|
|
16273
|
+
toastNode.style.height = originalHeight;
|
|
16274
|
+
setInitialHeight(newHeight);
|
|
16275
|
+
setHeights((heights2) => {
|
|
16276
|
+
const alreadyExists = heights2.find((height) => height.toastId === toast2.id);
|
|
16277
|
+
if (!alreadyExists) {
|
|
16278
|
+
return [
|
|
16279
|
+
{
|
|
16280
|
+
toastId: toast2.id,
|
|
16281
|
+
height: newHeight,
|
|
16282
|
+
position: toast2.position
|
|
16283
|
+
},
|
|
16284
|
+
...heights2
|
|
16285
|
+
];
|
|
16286
|
+
} else {
|
|
16287
|
+
return heights2.map((height) => height.toastId === toast2.id ? {
|
|
16288
|
+
...height,
|
|
16289
|
+
height: newHeight
|
|
16290
|
+
} : height);
|
|
16291
|
+
}
|
|
16292
|
+
});
|
|
16293
|
+
}, [
|
|
16294
|
+
mounted,
|
|
16295
|
+
toast2.title,
|
|
16296
|
+
toast2.description,
|
|
16297
|
+
setHeights,
|
|
16298
|
+
toast2.id,
|
|
16299
|
+
toast2.jsx,
|
|
16300
|
+
toast2.action,
|
|
16301
|
+
toast2.cancel
|
|
16302
|
+
]);
|
|
16303
|
+
const deleteToast = React16__default.useCallback(() => {
|
|
16304
|
+
setRemoved(true);
|
|
16305
|
+
setOffsetBeforeRemove(offset.current);
|
|
16306
|
+
setHeights((h) => h.filter((height) => height.toastId !== toast2.id));
|
|
16307
|
+
setTimeout(() => {
|
|
16308
|
+
removeToast(toast2);
|
|
16309
|
+
}, TIME_BEFORE_UNMOUNT);
|
|
16310
|
+
}, [
|
|
16311
|
+
toast2,
|
|
16312
|
+
removeToast,
|
|
16313
|
+
setHeights,
|
|
16314
|
+
offset
|
|
16315
|
+
]);
|
|
16316
|
+
React16__default.useEffect(() => {
|
|
16317
|
+
if (toast2.promise && toastType === "loading" || toast2.duration === Infinity || toast2.type === "loading") return;
|
|
16318
|
+
let timeoutId;
|
|
16319
|
+
const pauseTimer = () => {
|
|
16320
|
+
if (lastCloseTimerStartTimeRef.current < closeTimerStartTimeRef.current) {
|
|
16321
|
+
const elapsedTime = (/* @__PURE__ */ new Date()).getTime() - closeTimerStartTimeRef.current;
|
|
16322
|
+
remainingTime.current = remainingTime.current - elapsedTime;
|
|
16323
|
+
}
|
|
16324
|
+
lastCloseTimerStartTimeRef.current = (/* @__PURE__ */ new Date()).getTime();
|
|
16325
|
+
};
|
|
16326
|
+
const startTimer = () => {
|
|
16327
|
+
if (remainingTime.current === Infinity) return;
|
|
16328
|
+
closeTimerStartTimeRef.current = (/* @__PURE__ */ new Date()).getTime();
|
|
16329
|
+
timeoutId = setTimeout(() => {
|
|
16330
|
+
toast2.onAutoClose == null ? void 0 : toast2.onAutoClose.call(toast2, toast2);
|
|
16331
|
+
deleteToast();
|
|
16332
|
+
}, remainingTime.current);
|
|
16333
|
+
};
|
|
16334
|
+
if (expanded || interacting || isDocumentHidden) {
|
|
16335
|
+
pauseTimer();
|
|
16336
|
+
} else {
|
|
16337
|
+
startTimer();
|
|
16338
|
+
}
|
|
16339
|
+
return () => clearTimeout(timeoutId);
|
|
16340
|
+
}, [
|
|
16341
|
+
expanded,
|
|
16342
|
+
interacting,
|
|
16343
|
+
toast2,
|
|
16344
|
+
toastType,
|
|
16345
|
+
isDocumentHidden,
|
|
16346
|
+
deleteToast
|
|
16347
|
+
]);
|
|
16348
|
+
React16__default.useEffect(() => {
|
|
16349
|
+
if (toast2.delete) {
|
|
16350
|
+
deleteToast();
|
|
16351
|
+
toast2.onDismiss == null ? void 0 : toast2.onDismiss.call(toast2, toast2);
|
|
16352
|
+
}
|
|
16353
|
+
}, [
|
|
16354
|
+
deleteToast,
|
|
16355
|
+
toast2.delete
|
|
16356
|
+
]);
|
|
16357
|
+
function getLoadingIcon() {
|
|
16358
|
+
var _toast_classNames9;
|
|
16359
|
+
if (icons == null ? void 0 : icons.loading) {
|
|
16360
|
+
var _toast_classNames12;
|
|
16361
|
+
return /* @__PURE__ */ React16__default.createElement("div", {
|
|
16362
|
+
className: cn2(classNames == null ? void 0 : classNames.loader, toast2 == null ? void 0 : (_toast_classNames12 = toast2.classNames) == null ? void 0 : _toast_classNames12.loader, "sonner-loader"),
|
|
16363
|
+
"data-visible": toastType === "loading"
|
|
16364
|
+
}, icons.loading);
|
|
16365
|
+
}
|
|
16366
|
+
return /* @__PURE__ */ React16__default.createElement(Loader, {
|
|
16367
|
+
className: cn2(classNames == null ? void 0 : classNames.loader, toast2 == null ? void 0 : (_toast_classNames9 = toast2.classNames) == null ? void 0 : _toast_classNames9.loader),
|
|
16368
|
+
visible: toastType === "loading"
|
|
16369
|
+
});
|
|
16370
|
+
}
|
|
16371
|
+
const icon = toast2.icon || (icons == null ? void 0 : icons[toastType]) || getAsset(toastType);
|
|
16372
|
+
var _toast_richColors, _icons_close;
|
|
16373
|
+
return /* @__PURE__ */ React16__default.createElement("li", {
|
|
16374
|
+
tabIndex: 0,
|
|
16375
|
+
ref: toastRef,
|
|
16376
|
+
className: cn2(className, toastClassname, classNames == null ? void 0 : classNames.toast, toast2 == null ? void 0 : (_toast_classNames = toast2.classNames) == null ? void 0 : _toast_classNames.toast, classNames == null ? void 0 : classNames.default, classNames == null ? void 0 : classNames[toastType], toast2 == null ? void 0 : (_toast_classNames1 = toast2.classNames) == null ? void 0 : _toast_classNames1[toastType]),
|
|
16377
|
+
"data-sonner-toast": "",
|
|
16378
|
+
"data-rich-colors": (_toast_richColors = toast2.richColors) != null ? _toast_richColors : defaultRichColors,
|
|
16379
|
+
"data-styled": !Boolean(toast2.jsx || toast2.unstyled || unstyled),
|
|
16380
|
+
"data-mounted": mounted,
|
|
16381
|
+
"data-promise": Boolean(toast2.promise),
|
|
16382
|
+
"data-swiped": isSwiped,
|
|
16383
|
+
"data-removed": removed,
|
|
16384
|
+
"data-visible": isVisible,
|
|
16385
|
+
"data-y-position": y,
|
|
16386
|
+
"data-x-position": x,
|
|
16387
|
+
"data-index": index,
|
|
16388
|
+
"data-front": isFront,
|
|
16389
|
+
"data-swiping": swiping,
|
|
16390
|
+
"data-dismissible": dismissible,
|
|
16391
|
+
"data-type": toastType,
|
|
16392
|
+
"data-invert": invert,
|
|
16393
|
+
"data-swipe-out": swipeOut,
|
|
16394
|
+
"data-swipe-direction": swipeOutDirection,
|
|
16395
|
+
"data-expanded": Boolean(expanded || expandByDefault && mounted),
|
|
16396
|
+
"data-testid": toast2.testId,
|
|
16397
|
+
style: {
|
|
16398
|
+
"--index": index,
|
|
16399
|
+
"--toasts-before": index,
|
|
16400
|
+
"--z-index": toasts.length - index,
|
|
16401
|
+
"--offset": `${removed ? offsetBeforeRemove : offset.current}px`,
|
|
16402
|
+
"--initial-height": expandByDefault ? "auto" : `${initialHeight}px`,
|
|
16403
|
+
...style,
|
|
16404
|
+
...toast2.style
|
|
16405
|
+
},
|
|
16406
|
+
onDragEnd: () => {
|
|
16407
|
+
setSwiping(false);
|
|
16408
|
+
setSwipeDirection(null);
|
|
16409
|
+
pointerStartRef.current = null;
|
|
16410
|
+
},
|
|
16411
|
+
onPointerDown: (event) => {
|
|
16412
|
+
if (event.button === 2) return;
|
|
16413
|
+
if (disabled || !dismissible) return;
|
|
16414
|
+
dragStartTime.current = /* @__PURE__ */ new Date();
|
|
16415
|
+
setOffsetBeforeRemove(offset.current);
|
|
16416
|
+
event.target.setPointerCapture(event.pointerId);
|
|
16417
|
+
if (event.target.tagName === "BUTTON") return;
|
|
16418
|
+
setSwiping(true);
|
|
16419
|
+
pointerStartRef.current = {
|
|
16420
|
+
x: event.clientX,
|
|
16421
|
+
y: event.clientY
|
|
16422
|
+
};
|
|
16423
|
+
},
|
|
16424
|
+
onPointerUp: () => {
|
|
16425
|
+
var _toastRef_current, _toastRef_current1, _dragStartTime_current;
|
|
16426
|
+
if (swipeOut || !dismissible) return;
|
|
16427
|
+
pointerStartRef.current = null;
|
|
16428
|
+
const swipeAmountX = Number(((_toastRef_current = toastRef.current) == null ? void 0 : _toastRef_current.style.getPropertyValue("--swipe-amount-x").replace("px", "")) || 0);
|
|
16429
|
+
const swipeAmountY = Number(((_toastRef_current1 = toastRef.current) == null ? void 0 : _toastRef_current1.style.getPropertyValue("--swipe-amount-y").replace("px", "")) || 0);
|
|
16430
|
+
const timeTaken = (/* @__PURE__ */ new Date()).getTime() - ((_dragStartTime_current = dragStartTime.current) == null ? void 0 : _dragStartTime_current.getTime());
|
|
16431
|
+
const swipeAmount = swipeDirection === "x" ? swipeAmountX : swipeAmountY;
|
|
16432
|
+
const velocity = Math.abs(swipeAmount) / timeTaken;
|
|
16433
|
+
if (Math.abs(swipeAmount) >= SWIPE_THRESHOLD || velocity > 0.11) {
|
|
16434
|
+
setOffsetBeforeRemove(offset.current);
|
|
16435
|
+
toast2.onDismiss == null ? void 0 : toast2.onDismiss.call(toast2, toast2);
|
|
16436
|
+
if (swipeDirection === "x") {
|
|
16437
|
+
setSwipeOutDirection(swipeAmountX > 0 ? "right" : "left");
|
|
16438
|
+
} else {
|
|
16439
|
+
setSwipeOutDirection(swipeAmountY > 0 ? "down" : "up");
|
|
16440
|
+
}
|
|
16441
|
+
deleteToast();
|
|
16442
|
+
setSwipeOut(true);
|
|
16443
|
+
return;
|
|
16444
|
+
} else {
|
|
16445
|
+
var _toastRef_current2, _toastRef_current3;
|
|
16446
|
+
(_toastRef_current2 = toastRef.current) == null ? void 0 : _toastRef_current2.style.setProperty("--swipe-amount-x", `0px`);
|
|
16447
|
+
(_toastRef_current3 = toastRef.current) == null ? void 0 : _toastRef_current3.style.setProperty("--swipe-amount-y", `0px`);
|
|
16448
|
+
}
|
|
16449
|
+
setIsSwiped(false);
|
|
16450
|
+
setSwiping(false);
|
|
16451
|
+
setSwipeDirection(null);
|
|
16452
|
+
},
|
|
16453
|
+
onPointerMove: (event) => {
|
|
16454
|
+
var _window_getSelection, _toastRef_current, _toastRef_current1;
|
|
16455
|
+
if (!pointerStartRef.current || !dismissible) return;
|
|
16456
|
+
const isHighlighted = ((_window_getSelection = window.getSelection()) == null ? void 0 : _window_getSelection.toString().length) > 0;
|
|
16457
|
+
if (isHighlighted) return;
|
|
16458
|
+
const yDelta = event.clientY - pointerStartRef.current.y;
|
|
16459
|
+
const xDelta = event.clientX - pointerStartRef.current.x;
|
|
16460
|
+
var _props_swipeDirections;
|
|
16461
|
+
const swipeDirections = (_props_swipeDirections = props.swipeDirections) != null ? _props_swipeDirections : getDefaultSwipeDirections(position);
|
|
16462
|
+
if (!swipeDirection && (Math.abs(xDelta) > 1 || Math.abs(yDelta) > 1)) {
|
|
16463
|
+
setSwipeDirection(Math.abs(xDelta) > Math.abs(yDelta) ? "x" : "y");
|
|
16464
|
+
}
|
|
16465
|
+
let swipeAmount = {
|
|
16466
|
+
x: 0,
|
|
16467
|
+
y: 0
|
|
16468
|
+
};
|
|
16469
|
+
const getDampening = (delta) => {
|
|
16470
|
+
const factor = Math.abs(delta) / 20;
|
|
16471
|
+
return 1 / (1.5 + factor);
|
|
16472
|
+
};
|
|
16473
|
+
if (swipeDirection === "y") {
|
|
16474
|
+
if (swipeDirections.includes("top") || swipeDirections.includes("bottom")) {
|
|
16475
|
+
if (swipeDirections.includes("top") && yDelta < 0 || swipeDirections.includes("bottom") && yDelta > 0) {
|
|
16476
|
+
swipeAmount.y = yDelta;
|
|
16477
|
+
} else {
|
|
16478
|
+
const dampenedDelta = yDelta * getDampening(yDelta);
|
|
16479
|
+
swipeAmount.y = Math.abs(dampenedDelta) < Math.abs(yDelta) ? dampenedDelta : yDelta;
|
|
16480
|
+
}
|
|
16481
|
+
}
|
|
16482
|
+
} else if (swipeDirection === "x") {
|
|
16483
|
+
if (swipeDirections.includes("left") || swipeDirections.includes("right")) {
|
|
16484
|
+
if (swipeDirections.includes("left") && xDelta < 0 || swipeDirections.includes("right") && xDelta > 0) {
|
|
16485
|
+
swipeAmount.x = xDelta;
|
|
16486
|
+
} else {
|
|
16487
|
+
const dampenedDelta = xDelta * getDampening(xDelta);
|
|
16488
|
+
swipeAmount.x = Math.abs(dampenedDelta) < Math.abs(xDelta) ? dampenedDelta : xDelta;
|
|
16489
|
+
}
|
|
16490
|
+
}
|
|
16491
|
+
}
|
|
16492
|
+
if (Math.abs(swipeAmount.x) > 0 || Math.abs(swipeAmount.y) > 0) {
|
|
16493
|
+
setIsSwiped(true);
|
|
16494
|
+
}
|
|
16495
|
+
(_toastRef_current = toastRef.current) == null ? void 0 : _toastRef_current.style.setProperty("--swipe-amount-x", `${swipeAmount.x}px`);
|
|
16496
|
+
(_toastRef_current1 = toastRef.current) == null ? void 0 : _toastRef_current1.style.setProperty("--swipe-amount-y", `${swipeAmount.y}px`);
|
|
16497
|
+
}
|
|
16498
|
+
}, closeButton && !toast2.jsx && toastType !== "loading" ? /* @__PURE__ */ React16__default.createElement("button", {
|
|
16499
|
+
"aria-label": closeButtonAriaLabel,
|
|
16500
|
+
"data-disabled": disabled,
|
|
16501
|
+
"data-close-button": true,
|
|
16502
|
+
onClick: disabled || !dismissible ? () => {
|
|
16503
|
+
} : () => {
|
|
16504
|
+
deleteToast();
|
|
16505
|
+
toast2.onDismiss == null ? void 0 : toast2.onDismiss.call(toast2, toast2);
|
|
16506
|
+
},
|
|
16507
|
+
className: cn2(classNames == null ? void 0 : classNames.closeButton, toast2 == null ? void 0 : (_toast_classNames2 = toast2.classNames) == null ? void 0 : _toast_classNames2.closeButton)
|
|
16508
|
+
}, (_icons_close = icons == null ? void 0 : icons.close) != null ? _icons_close : CloseIcon) : null, (toastType || toast2.icon || toast2.promise) && toast2.icon !== null && ((icons == null ? void 0 : icons[toastType]) !== null || toast2.icon) ? /* @__PURE__ */ React16__default.createElement("div", {
|
|
16509
|
+
"data-icon": "",
|
|
16510
|
+
className: cn2(classNames == null ? void 0 : classNames.icon, toast2 == null ? void 0 : (_toast_classNames3 = toast2.classNames) == null ? void 0 : _toast_classNames3.icon)
|
|
16511
|
+
}, toast2.promise || toast2.type === "loading" && !toast2.icon ? toast2.icon || getLoadingIcon() : null, toast2.type !== "loading" ? icon : null) : null, /* @__PURE__ */ React16__default.createElement("div", {
|
|
16512
|
+
"data-content": "",
|
|
16513
|
+
className: cn2(classNames == null ? void 0 : classNames.content, toast2 == null ? void 0 : (_toast_classNames4 = toast2.classNames) == null ? void 0 : _toast_classNames4.content)
|
|
16514
|
+
}, /* @__PURE__ */ React16__default.createElement("div", {
|
|
16515
|
+
"data-title": "",
|
|
16516
|
+
className: cn2(classNames == null ? void 0 : classNames.title, toast2 == null ? void 0 : (_toast_classNames5 = toast2.classNames) == null ? void 0 : _toast_classNames5.title)
|
|
16517
|
+
}, toast2.jsx ? toast2.jsx : typeof toast2.title === "function" ? toast2.title() : toast2.title), toast2.description ? /* @__PURE__ */ React16__default.createElement("div", {
|
|
16518
|
+
"data-description": "",
|
|
16519
|
+
className: cn2(descriptionClassName, toastDescriptionClassname, classNames == null ? void 0 : classNames.description, toast2 == null ? void 0 : (_toast_classNames6 = toast2.classNames) == null ? void 0 : _toast_classNames6.description)
|
|
16520
|
+
}, typeof toast2.description === "function" ? toast2.description() : toast2.description) : null), /* @__PURE__ */ React16__default.isValidElement(toast2.cancel) ? toast2.cancel : toast2.cancel && isAction(toast2.cancel) ? /* @__PURE__ */ React16__default.createElement("button", {
|
|
16521
|
+
"data-button": true,
|
|
16522
|
+
"data-cancel": true,
|
|
16523
|
+
style: toast2.cancelButtonStyle || cancelButtonStyle,
|
|
16524
|
+
onClick: (event) => {
|
|
16525
|
+
if (!isAction(toast2.cancel)) return;
|
|
16526
|
+
if (!dismissible) return;
|
|
16527
|
+
toast2.cancel.onClick == null ? void 0 : toast2.cancel.onClick.call(toast2.cancel, event);
|
|
16528
|
+
deleteToast();
|
|
16529
|
+
},
|
|
16530
|
+
className: cn2(classNames == null ? void 0 : classNames.cancelButton, toast2 == null ? void 0 : (_toast_classNames7 = toast2.classNames) == null ? void 0 : _toast_classNames7.cancelButton)
|
|
16531
|
+
}, toast2.cancel.label) : null, /* @__PURE__ */ React16__default.isValidElement(toast2.action) ? toast2.action : toast2.action && isAction(toast2.action) ? /* @__PURE__ */ React16__default.createElement("button", {
|
|
16532
|
+
"data-button": true,
|
|
16533
|
+
"data-action": true,
|
|
16534
|
+
style: toast2.actionButtonStyle || actionButtonStyle,
|
|
16535
|
+
onClick: (event) => {
|
|
16536
|
+
if (!isAction(toast2.action)) return;
|
|
16537
|
+
toast2.action.onClick == null ? void 0 : toast2.action.onClick.call(toast2.action, event);
|
|
16538
|
+
if (event.defaultPrevented) return;
|
|
16539
|
+
deleteToast();
|
|
16540
|
+
},
|
|
16541
|
+
className: cn2(classNames == null ? void 0 : classNames.actionButton, toast2 == null ? void 0 : (_toast_classNames8 = toast2.classNames) == null ? void 0 : _toast_classNames8.actionButton)
|
|
16542
|
+
}, toast2.action.label) : null);
|
|
16543
|
+
};
|
|
16544
|
+
function getDocumentDirection() {
|
|
16545
|
+
if (typeof window === "undefined") return "ltr";
|
|
16546
|
+
if (typeof document === "undefined") return "ltr";
|
|
16547
|
+
const dirAttribute = document.documentElement.getAttribute("dir");
|
|
16548
|
+
if (dirAttribute === "auto" || !dirAttribute) {
|
|
16549
|
+
return window.getComputedStyle(document.documentElement).direction;
|
|
16550
|
+
}
|
|
16551
|
+
return dirAttribute;
|
|
16552
|
+
}
|
|
16553
|
+
function assignOffset(defaultOffset, mobileOffset) {
|
|
16554
|
+
const styles = {};
|
|
16555
|
+
[
|
|
16556
|
+
defaultOffset,
|
|
16557
|
+
mobileOffset
|
|
16558
|
+
].forEach((offset, index) => {
|
|
16559
|
+
const isMobile = index === 1;
|
|
16560
|
+
const prefix = isMobile ? "--mobile-offset" : "--offset";
|
|
16561
|
+
const defaultValue = isMobile ? MOBILE_VIEWPORT_OFFSET : VIEWPORT_OFFSET;
|
|
16562
|
+
function assignAll(offset2) {
|
|
16563
|
+
[
|
|
16564
|
+
"top",
|
|
16565
|
+
"right",
|
|
16566
|
+
"bottom",
|
|
16567
|
+
"left"
|
|
16568
|
+
].forEach((key) => {
|
|
16569
|
+
styles[`${prefix}-${key}`] = typeof offset2 === "number" ? `${offset2}px` : offset2;
|
|
16570
|
+
});
|
|
16571
|
+
}
|
|
16572
|
+
if (typeof offset === "number" || typeof offset === "string") {
|
|
16573
|
+
assignAll(offset);
|
|
16574
|
+
} else if (typeof offset === "object") {
|
|
16575
|
+
[
|
|
16576
|
+
"top",
|
|
16577
|
+
"right",
|
|
16578
|
+
"bottom",
|
|
16579
|
+
"left"
|
|
16580
|
+
].forEach((key) => {
|
|
16581
|
+
if (offset[key] === void 0) {
|
|
16582
|
+
styles[`${prefix}-${key}`] = defaultValue;
|
|
16583
|
+
} else {
|
|
16584
|
+
styles[`${prefix}-${key}`] = typeof offset[key] === "number" ? `${offset[key]}px` : offset[key];
|
|
16585
|
+
}
|
|
16586
|
+
});
|
|
16587
|
+
} else {
|
|
16588
|
+
assignAll(defaultValue);
|
|
16589
|
+
}
|
|
16590
|
+
});
|
|
16591
|
+
return styles;
|
|
16592
|
+
}
|
|
16593
|
+
var Toaster = /* @__PURE__ */ React16__default.forwardRef(function Toaster2(props, ref) {
|
|
16594
|
+
const { id, invert, position = "bottom-right", hotkey = [
|
|
16595
|
+
"altKey",
|
|
16596
|
+
"KeyT"
|
|
16597
|
+
], expand, closeButton, className, offset, mobileOffset, theme = "light", richColors, duration, style, visibleToasts = VISIBLE_TOASTS_AMOUNT, toastOptions, dir = getDocumentDirection(), gap = GAP, icons, containerAriaLabel = "Notifications" } = props;
|
|
16598
|
+
const [toasts, setToasts] = React16__default.useState([]);
|
|
16599
|
+
const filteredToasts = React16__default.useMemo(() => {
|
|
16600
|
+
if (id) {
|
|
16601
|
+
return toasts.filter((toast2) => toast2.toasterId === id);
|
|
16602
|
+
}
|
|
16603
|
+
return toasts.filter((toast2) => !toast2.toasterId);
|
|
16604
|
+
}, [
|
|
16605
|
+
toasts,
|
|
16606
|
+
id
|
|
16607
|
+
]);
|
|
16608
|
+
const possiblePositions = React16__default.useMemo(() => {
|
|
16609
|
+
return Array.from(new Set([
|
|
16610
|
+
position
|
|
16611
|
+
].concat(filteredToasts.filter((toast2) => toast2.position).map((toast2) => toast2.position))));
|
|
16612
|
+
}, [
|
|
16613
|
+
filteredToasts,
|
|
16614
|
+
position
|
|
16615
|
+
]);
|
|
16616
|
+
const [heights, setHeights] = React16__default.useState([]);
|
|
16617
|
+
const [expanded, setExpanded] = React16__default.useState(false);
|
|
16618
|
+
const [interacting, setInteracting] = React16__default.useState(false);
|
|
16619
|
+
const [actualTheme, setActualTheme] = React16__default.useState(theme !== "system" ? theme : typeof window !== "undefined" ? window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : "light");
|
|
16620
|
+
const listRef = React16__default.useRef(null);
|
|
16621
|
+
const hotkeyLabel = hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, "");
|
|
16622
|
+
const lastFocusedElementRef = React16__default.useRef(null);
|
|
16623
|
+
const isFocusWithinRef = React16__default.useRef(false);
|
|
16624
|
+
const removeToast = React16__default.useCallback((toastToRemove) => {
|
|
16625
|
+
setToasts((toasts2) => {
|
|
16626
|
+
var _toasts_find;
|
|
16627
|
+
if (!((_toasts_find = toasts2.find((toast2) => toast2.id === toastToRemove.id)) == null ? void 0 : _toasts_find.delete)) {
|
|
16628
|
+
ToastState.dismiss(toastToRemove.id);
|
|
16629
|
+
}
|
|
16630
|
+
return toasts2.filter(({ id: id2 }) => id2 !== toastToRemove.id);
|
|
16631
|
+
});
|
|
16632
|
+
}, []);
|
|
16633
|
+
React16__default.useEffect(() => {
|
|
16634
|
+
return ToastState.subscribe((toast2) => {
|
|
16635
|
+
if (toast2.dismiss) {
|
|
16636
|
+
requestAnimationFrame(() => {
|
|
16637
|
+
setToasts((toasts2) => toasts2.map((t) => t.id === toast2.id ? {
|
|
16638
|
+
...t,
|
|
16639
|
+
delete: true
|
|
16640
|
+
} : t));
|
|
16641
|
+
});
|
|
16642
|
+
return;
|
|
16643
|
+
}
|
|
16644
|
+
setTimeout(() => {
|
|
16645
|
+
ReactDOM.flushSync(() => {
|
|
16646
|
+
setToasts((toasts2) => {
|
|
16647
|
+
const indexOfExistingToast = toasts2.findIndex((t) => t.id === toast2.id);
|
|
16648
|
+
if (indexOfExistingToast !== -1) {
|
|
16649
|
+
return [
|
|
16650
|
+
...toasts2.slice(0, indexOfExistingToast),
|
|
16651
|
+
{
|
|
16652
|
+
...toasts2[indexOfExistingToast],
|
|
16653
|
+
...toast2
|
|
16654
|
+
},
|
|
16655
|
+
...toasts2.slice(indexOfExistingToast + 1)
|
|
16656
|
+
];
|
|
16657
|
+
}
|
|
16658
|
+
return [
|
|
16659
|
+
toast2,
|
|
16660
|
+
...toasts2
|
|
16661
|
+
];
|
|
16662
|
+
});
|
|
16663
|
+
});
|
|
16664
|
+
});
|
|
16665
|
+
});
|
|
16666
|
+
}, [
|
|
16667
|
+
toasts
|
|
16668
|
+
]);
|
|
16669
|
+
React16__default.useEffect(() => {
|
|
16670
|
+
if (theme !== "system") {
|
|
16671
|
+
setActualTheme(theme);
|
|
16672
|
+
return;
|
|
16673
|
+
}
|
|
16674
|
+
if (theme === "system") {
|
|
16675
|
+
if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {
|
|
16676
|
+
setActualTheme("dark");
|
|
16677
|
+
} else {
|
|
16678
|
+
setActualTheme("light");
|
|
16679
|
+
}
|
|
16680
|
+
}
|
|
16681
|
+
if (typeof window === "undefined") return;
|
|
16682
|
+
const darkMediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
16683
|
+
try {
|
|
16684
|
+
darkMediaQuery.addEventListener("change", ({ matches }) => {
|
|
16685
|
+
if (matches) {
|
|
16686
|
+
setActualTheme("dark");
|
|
16687
|
+
} else {
|
|
16688
|
+
setActualTheme("light");
|
|
16689
|
+
}
|
|
16690
|
+
});
|
|
16691
|
+
} catch (error) {
|
|
16692
|
+
darkMediaQuery.addListener(({ matches }) => {
|
|
16693
|
+
try {
|
|
16694
|
+
if (matches) {
|
|
16695
|
+
setActualTheme("dark");
|
|
16696
|
+
} else {
|
|
16697
|
+
setActualTheme("light");
|
|
16698
|
+
}
|
|
16699
|
+
} catch (e) {
|
|
16700
|
+
console.error(e);
|
|
16701
|
+
}
|
|
16702
|
+
});
|
|
16703
|
+
}
|
|
16704
|
+
}, [
|
|
16705
|
+
theme
|
|
16706
|
+
]);
|
|
16707
|
+
React16__default.useEffect(() => {
|
|
16708
|
+
if (toasts.length <= 1) {
|
|
16709
|
+
setExpanded(false);
|
|
16710
|
+
}
|
|
16711
|
+
}, [
|
|
16712
|
+
toasts
|
|
16713
|
+
]);
|
|
16714
|
+
React16__default.useEffect(() => {
|
|
16715
|
+
const handleKeyDown = (event) => {
|
|
16716
|
+
var _listRef_current;
|
|
16717
|
+
const isHotkeyPressed = hotkey.every((key) => event[key] || event.code === key);
|
|
16718
|
+
if (isHotkeyPressed) {
|
|
16719
|
+
var _listRef_current1;
|
|
16720
|
+
setExpanded(true);
|
|
16721
|
+
(_listRef_current1 = listRef.current) == null ? void 0 : _listRef_current1.focus();
|
|
16722
|
+
}
|
|
16723
|
+
if (event.code === "Escape" && (document.activeElement === listRef.current || ((_listRef_current = listRef.current) == null ? void 0 : _listRef_current.contains(document.activeElement)))) {
|
|
16724
|
+
setExpanded(false);
|
|
16725
|
+
}
|
|
16726
|
+
};
|
|
16727
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
16728
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
16729
|
+
}, [
|
|
16730
|
+
hotkey
|
|
16731
|
+
]);
|
|
16732
|
+
React16__default.useEffect(() => {
|
|
16733
|
+
if (listRef.current) {
|
|
16734
|
+
return () => {
|
|
16735
|
+
if (lastFocusedElementRef.current) {
|
|
16736
|
+
lastFocusedElementRef.current.focus({
|
|
16737
|
+
preventScroll: true
|
|
16738
|
+
});
|
|
16739
|
+
lastFocusedElementRef.current = null;
|
|
16740
|
+
isFocusWithinRef.current = false;
|
|
16741
|
+
}
|
|
16742
|
+
};
|
|
16743
|
+
}
|
|
16744
|
+
}, [
|
|
16745
|
+
listRef.current
|
|
16746
|
+
]);
|
|
16747
|
+
return (
|
|
16748
|
+
// Remove item from normal navigation flow, only available via hotkey
|
|
16749
|
+
/* @__PURE__ */ React16__default.createElement("section", {
|
|
16750
|
+
ref,
|
|
16751
|
+
"aria-label": `${containerAriaLabel} ${hotkeyLabel}`,
|
|
16752
|
+
tabIndex: -1,
|
|
16753
|
+
"aria-live": "polite",
|
|
16754
|
+
"aria-relevant": "additions text",
|
|
16755
|
+
"aria-atomic": "false",
|
|
16756
|
+
suppressHydrationWarning: true
|
|
16757
|
+
}, possiblePositions.map((position2, index) => {
|
|
16758
|
+
var _heights_;
|
|
16759
|
+
const [y, x] = position2.split("-");
|
|
16760
|
+
if (!filteredToasts.length) return null;
|
|
16761
|
+
return /* @__PURE__ */ React16__default.createElement("ol", {
|
|
16762
|
+
key: position2,
|
|
16763
|
+
dir: dir === "auto" ? getDocumentDirection() : dir,
|
|
16764
|
+
tabIndex: -1,
|
|
16765
|
+
ref: listRef,
|
|
16766
|
+
className,
|
|
16767
|
+
"data-sonner-toaster": true,
|
|
16768
|
+
"data-sonner-theme": actualTheme,
|
|
16769
|
+
"data-y-position": y,
|
|
16770
|
+
"data-x-position": x,
|
|
16771
|
+
style: {
|
|
16772
|
+
"--front-toast-height": `${((_heights_ = heights[0]) == null ? void 0 : _heights_.height) || 0}px`,
|
|
16773
|
+
"--width": `${TOAST_WIDTH}px`,
|
|
16774
|
+
"--gap": `${gap}px`,
|
|
16775
|
+
...style,
|
|
16776
|
+
...assignOffset(offset, mobileOffset)
|
|
16777
|
+
},
|
|
16778
|
+
onBlur: (event) => {
|
|
16779
|
+
if (isFocusWithinRef.current && !event.currentTarget.contains(event.relatedTarget)) {
|
|
16780
|
+
isFocusWithinRef.current = false;
|
|
16781
|
+
if (lastFocusedElementRef.current) {
|
|
16782
|
+
lastFocusedElementRef.current.focus({
|
|
16783
|
+
preventScroll: true
|
|
16784
|
+
});
|
|
16785
|
+
lastFocusedElementRef.current = null;
|
|
16786
|
+
}
|
|
16787
|
+
}
|
|
16788
|
+
},
|
|
16789
|
+
onFocus: (event) => {
|
|
16790
|
+
const isNotDismissible = event.target instanceof HTMLElement && event.target.dataset.dismissible === "false";
|
|
16791
|
+
if (isNotDismissible) return;
|
|
16792
|
+
if (!isFocusWithinRef.current) {
|
|
16793
|
+
isFocusWithinRef.current = true;
|
|
16794
|
+
lastFocusedElementRef.current = event.relatedTarget;
|
|
16795
|
+
}
|
|
16796
|
+
},
|
|
16797
|
+
onMouseEnter: () => setExpanded(true),
|
|
16798
|
+
onMouseMove: () => setExpanded(true),
|
|
16799
|
+
onMouseLeave: () => {
|
|
16800
|
+
if (!interacting) {
|
|
16801
|
+
setExpanded(false);
|
|
16802
|
+
}
|
|
16803
|
+
},
|
|
16804
|
+
onDragEnd: () => setExpanded(false),
|
|
16805
|
+
onPointerDown: (event) => {
|
|
16806
|
+
const isNotDismissible = event.target instanceof HTMLElement && event.target.dataset.dismissible === "false";
|
|
16807
|
+
if (isNotDismissible) return;
|
|
16808
|
+
setInteracting(true);
|
|
16809
|
+
},
|
|
16810
|
+
onPointerUp: () => setInteracting(false)
|
|
16811
|
+
}, filteredToasts.filter((toast2) => !toast2.position && index === 0 || toast2.position === position2).map((toast2, index2) => {
|
|
16812
|
+
var _toastOptions_duration, _toastOptions_closeButton;
|
|
16813
|
+
return /* @__PURE__ */ React16__default.createElement(Toast, {
|
|
16814
|
+
key: toast2.id,
|
|
16815
|
+
icons,
|
|
16816
|
+
index: index2,
|
|
16817
|
+
toast: toast2,
|
|
16818
|
+
defaultRichColors: richColors,
|
|
16819
|
+
duration: (_toastOptions_duration = toastOptions == null ? void 0 : toastOptions.duration) != null ? _toastOptions_duration : duration,
|
|
16820
|
+
className: toastOptions == null ? void 0 : toastOptions.className,
|
|
16821
|
+
descriptionClassName: toastOptions == null ? void 0 : toastOptions.descriptionClassName,
|
|
16822
|
+
invert,
|
|
16823
|
+
visibleToasts,
|
|
16824
|
+
closeButton: (_toastOptions_closeButton = toastOptions == null ? void 0 : toastOptions.closeButton) != null ? _toastOptions_closeButton : closeButton,
|
|
16825
|
+
interacting,
|
|
16826
|
+
position: position2,
|
|
16827
|
+
style: toastOptions == null ? void 0 : toastOptions.style,
|
|
16828
|
+
unstyled: toastOptions == null ? void 0 : toastOptions.unstyled,
|
|
16829
|
+
classNames: toastOptions == null ? void 0 : toastOptions.classNames,
|
|
16830
|
+
cancelButtonStyle: toastOptions == null ? void 0 : toastOptions.cancelButtonStyle,
|
|
16831
|
+
actionButtonStyle: toastOptions == null ? void 0 : toastOptions.actionButtonStyle,
|
|
16832
|
+
closeButtonAriaLabel: toastOptions == null ? void 0 : toastOptions.closeButtonAriaLabel,
|
|
16833
|
+
removeToast,
|
|
16834
|
+
toasts: filteredToasts.filter((t) => t.position == toast2.position),
|
|
16835
|
+
heights: heights.filter((h) => h.position == toast2.position),
|
|
16836
|
+
setHeights,
|
|
16837
|
+
expandByDefault: expand,
|
|
16838
|
+
gap,
|
|
16839
|
+
expanded,
|
|
16840
|
+
swipeDirections: props.swipeDirections
|
|
16841
|
+
});
|
|
16842
|
+
}));
|
|
16843
|
+
}))
|
|
16844
|
+
);
|
|
16845
|
+
});
|
|
16052
16846
|
var TTSButton = memo(function TTSButton2({
|
|
16053
16847
|
text: text3,
|
|
16054
16848
|
onActiveChange,
|
|
@@ -17609,7 +18403,7 @@ function ToolConfirmDialog({ toolCall }) {
|
|
|
17609
18403
|
}
|
|
17610
18404
|
var Dialog = DialogPrimitive.Root;
|
|
17611
18405
|
var DialogPortal = DialogPrimitive.Portal;
|
|
17612
|
-
var DialogOverlay =
|
|
18406
|
+
var DialogOverlay = React16.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
17613
18407
|
DialogPrimitive.Overlay,
|
|
17614
18408
|
{
|
|
17615
18409
|
ref,
|
|
@@ -17621,7 +18415,7 @@ var DialogOverlay = React24.forwardRef(({ className, ...props }, ref) => /* @__P
|
|
|
17621
18415
|
}
|
|
17622
18416
|
));
|
|
17623
18417
|
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
17624
|
-
var DialogContent =
|
|
18418
|
+
var DialogContent = React16.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(DialogPortal, { children: [
|
|
17625
18419
|
/* @__PURE__ */ jsx(DialogOverlay, {}),
|
|
17626
18420
|
/* @__PURE__ */ jsxs(
|
|
17627
18421
|
DialogPrimitive.Content,
|
|
@@ -17671,7 +18465,7 @@ var DialogFooter = ({
|
|
|
17671
18465
|
}
|
|
17672
18466
|
);
|
|
17673
18467
|
DialogFooter.displayName = "DialogFooter";
|
|
17674
|
-
var DialogTitle =
|
|
18468
|
+
var DialogTitle = React16.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
17675
18469
|
DialogPrimitive.Title,
|
|
17676
18470
|
{
|
|
17677
18471
|
ref,
|
|
@@ -17683,7 +18477,7 @@ var DialogTitle = React24.forwardRef(({ className, ...props }, ref) => /* @__PUR
|
|
|
17683
18477
|
}
|
|
17684
18478
|
));
|
|
17685
18479
|
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
17686
|
-
var DialogDescription =
|
|
18480
|
+
var DialogDescription = React16.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
17687
18481
|
DialogPrimitive.Description,
|
|
17688
18482
|
{
|
|
17689
18483
|
ref,
|
|
@@ -17693,24 +18487,9 @@ var DialogDescription = React24.forwardRef(({ className, ...props }, ref) => /*
|
|
|
17693
18487
|
));
|
|
17694
18488
|
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
17695
18489
|
|
|
17696
|
-
// ../../node_modules/clsx/dist/clsx.mjs
|
|
17697
|
-
function r2(e) {
|
|
17698
|
-
var t, f, n = "";
|
|
17699
|
-
if ("string" == typeof e || "number" == typeof e) n += e;
|
|
17700
|
-
else if ("object" == typeof e) if (Array.isArray(e)) {
|
|
17701
|
-
var o = e.length;
|
|
17702
|
-
for (t = 0; t < o; t++) e[t] && (f = r2(e[t])) && (n && (n += " "), n += f);
|
|
17703
|
-
} else for (f in e) e[f] && (n && (n += " "), n += f);
|
|
17704
|
-
return n;
|
|
17705
|
-
}
|
|
17706
|
-
function clsx2() {
|
|
17707
|
-
for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r2(e)) && (n && (n += " "), n += t);
|
|
17708
|
-
return n;
|
|
17709
|
-
}
|
|
17710
|
-
|
|
17711
18490
|
// ../../node_modules/class-variance-authority/dist/index.mjs
|
|
17712
18491
|
var falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
|
|
17713
|
-
var cx =
|
|
18492
|
+
var cx = clsx;
|
|
17714
18493
|
var cva = (base, config) => (props) => {
|
|
17715
18494
|
var _config_compoundVariants;
|
|
17716
18495
|
if ((config === null || config === void 0 ? void 0 : config.variants) == null) return cx(base, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
|
|
@@ -17774,7 +18553,7 @@ var buttonVariants = cva(
|
|
|
17774
18553
|
}
|
|
17775
18554
|
}
|
|
17776
18555
|
);
|
|
17777
|
-
var Button =
|
|
18556
|
+
var Button = React16.forwardRef(
|
|
17778
18557
|
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
17779
18558
|
const Comp = asChild ? Slot : "button";
|
|
17780
18559
|
return /* @__PURE__ */ jsx(
|
|
@@ -17791,7 +18570,7 @@ Button.displayName = "Button";
|
|
|
17791
18570
|
var Badge = ({ children, className }) => {
|
|
17792
18571
|
return /* @__PURE__ */ jsx("div", { className: cn("inline-flex items-center rounded-md bg-muted px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", className), children });
|
|
17793
18572
|
};
|
|
17794
|
-
var Card =
|
|
18573
|
+
var Card = React16.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
17795
18574
|
"div",
|
|
17796
18575
|
{
|
|
17797
18576
|
ref,
|
|
@@ -17803,7 +18582,7 @@ var Card = React24.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
|
|
|
17803
18582
|
}
|
|
17804
18583
|
));
|
|
17805
18584
|
Card.displayName = "Card";
|
|
17806
|
-
var CardHeader =
|
|
18585
|
+
var CardHeader = React16.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
17807
18586
|
"div",
|
|
17808
18587
|
{
|
|
17809
18588
|
ref,
|
|
@@ -17812,7 +18591,7 @@ var CardHeader = React24.forwardRef(({ className, ...props }, ref) => /* @__PURE
|
|
|
17812
18591
|
}
|
|
17813
18592
|
));
|
|
17814
18593
|
CardHeader.displayName = "CardHeader";
|
|
17815
|
-
var CardTitle =
|
|
18594
|
+
var CardTitle = React16.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
17816
18595
|
"h3",
|
|
17817
18596
|
{
|
|
17818
18597
|
ref,
|
|
@@ -17824,7 +18603,7 @@ var CardTitle = React24.forwardRef(({ className, ...props }, ref) => /* @__PURE_
|
|
|
17824
18603
|
}
|
|
17825
18604
|
));
|
|
17826
18605
|
CardTitle.displayName = "CardTitle";
|
|
17827
|
-
var CardDescription =
|
|
18606
|
+
var CardDescription = React16.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
17828
18607
|
"p",
|
|
17829
18608
|
{
|
|
17830
18609
|
ref,
|
|
@@ -17833,9 +18612,9 @@ var CardDescription = React24.forwardRef(({ className, ...props }, ref) => /* @_
|
|
|
17833
18612
|
}
|
|
17834
18613
|
));
|
|
17835
18614
|
CardDescription.displayName = "CardDescription";
|
|
17836
|
-
var CardContent =
|
|
18615
|
+
var CardContent = React16.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("p-6 pt-0", className), ...props }));
|
|
17837
18616
|
CardContent.displayName = "CardContent";
|
|
17838
|
-
var CardFooter =
|
|
18617
|
+
var CardFooter = React16.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
17839
18618
|
"div",
|
|
17840
18619
|
{
|
|
17841
18620
|
ref,
|
|
@@ -17857,7 +18636,7 @@ var Separator = ({ className, orientation = "horizontal", decorative = true }) =
|
|
|
17857
18636
|
}
|
|
17858
18637
|
);
|
|
17859
18638
|
};
|
|
17860
|
-
var ScrollArea =
|
|
18639
|
+
var ScrollArea = React16.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
17861
18640
|
ScrollAreaPrimitive.Root,
|
|
17862
18641
|
{
|
|
17863
18642
|
ref,
|
|
@@ -17871,7 +18650,7 @@ var ScrollArea = React24.forwardRef(({ className, children, ...props }, ref) =>
|
|
|
17871
18650
|
}
|
|
17872
18651
|
));
|
|
17873
18652
|
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
|
|
17874
|
-
var ScrollBar =
|
|
18653
|
+
var ScrollBar = React16.forwardRef(({ className, orientation = "vertical", ...props }, ref) => /* @__PURE__ */ jsx(
|
|
17875
18654
|
ScrollAreaPrimitive.ScrollAreaScrollbar,
|
|
17876
18655
|
{
|
|
17877
18656
|
ref,
|
|
@@ -18165,7 +18944,7 @@ var PlanProgressPanel = ({
|
|
|
18165
18944
|
] });
|
|
18166
18945
|
};
|
|
18167
18946
|
var PlanProgressPanel_default = PlanProgressPanel;
|
|
18168
|
-
var Textarea =
|
|
18947
|
+
var Textarea = React16.forwardRef(
|
|
18169
18948
|
({ className, theme, ...props }, ref) => {
|
|
18170
18949
|
const themeClass = theme === "dark" ? "bg-gray-800 text-white" : "bg-white text-black";
|
|
18171
18950
|
return /* @__PURE__ */ jsx(
|
|
@@ -20539,7 +21318,7 @@ var VoiceInputButton = ({
|
|
|
20539
21318
|
};
|
|
20540
21319
|
|
|
20541
21320
|
// src/utils/cn.ts
|
|
20542
|
-
function
|
|
21321
|
+
function cn3(...inputs) {
|
|
20543
21322
|
return twMerge(clsx(inputs));
|
|
20544
21323
|
}
|
|
20545
21324
|
function useResizablePanel(defaultWidth, minWidth, maxWidth, onWidthChange) {
|
|
@@ -20626,7 +21405,7 @@ var SidePanel = memo(function SidePanel2({
|
|
|
20626
21405
|
"div",
|
|
20627
21406
|
{
|
|
20628
21407
|
ref: containerRef,
|
|
20629
|
-
className:
|
|
21408
|
+
className: cn3(
|
|
20630
21409
|
"fixed right-0 top-0 h-full z-50 flex flex-col",
|
|
20631
21410
|
"bg-zinc-950 border-l border-zinc-800/50",
|
|
20632
21411
|
"shadow-2xl shadow-black/50",
|
|
@@ -20641,7 +21420,7 @@ var SidePanel = memo(function SidePanel2({
|
|
|
20641
21420
|
resizable && !isFullscreen && /* @__PURE__ */ jsxs(
|
|
20642
21421
|
"div",
|
|
20643
21422
|
{
|
|
20644
|
-
className:
|
|
21423
|
+
className: cn3(
|
|
20645
21424
|
"absolute left-0 top-0 bottom-0 w-4 -translate-x-1/2",
|
|
20646
21425
|
"cursor-col-resize z-10 flex items-center justify-center",
|
|
20647
21426
|
"group hover:bg-zinc-800/50 transition-colors",
|
|
@@ -20649,7 +21428,7 @@ var SidePanel = memo(function SidePanel2({
|
|
|
20649
21428
|
),
|
|
20650
21429
|
onMouseDown: startResize,
|
|
20651
21430
|
children: [
|
|
20652
|
-
/* @__PURE__ */ jsx("div", { className:
|
|
21431
|
+
/* @__PURE__ */ jsx("div", { className: cn3(
|
|
20653
21432
|
"w-1 h-12 rounded-full bg-zinc-700",
|
|
20654
21433
|
"group-hover:bg-zinc-500 transition-colors",
|
|
20655
21434
|
isResizing && "bg-zinc-400"
|
|
@@ -20658,7 +21437,7 @@ var SidePanel = memo(function SidePanel2({
|
|
|
20658
21437
|
GripVertical,
|
|
20659
21438
|
{
|
|
20660
21439
|
size: 14,
|
|
20661
|
-
className:
|
|
21440
|
+
className: cn3(
|
|
20662
21441
|
"absolute text-zinc-600 opacity-0",
|
|
20663
21442
|
"group-hover:opacity-100 transition-opacity",
|
|
20664
21443
|
isResizing && "opacity-100 text-zinc-400"
|
|
@@ -20695,7 +21474,7 @@ var SidePanel = memo(function SidePanel2({
|
|
|
20695
21474
|
)
|
|
20696
21475
|
] })
|
|
20697
21476
|
] }),
|
|
20698
|
-
/* @__PURE__ */ jsx("div", { className:
|
|
21477
|
+
/* @__PURE__ */ jsx("div", { className: cn3(
|
|
20699
21478
|
"flex-1 overflow-hidden flex flex-col",
|
|
20700
21479
|
contentClassName
|
|
20701
21480
|
), children }),
|
|
@@ -20715,7 +21494,7 @@ var ViewTabs = memo(function ViewTabs2({
|
|
|
20715
21494
|
"button",
|
|
20716
21495
|
{
|
|
20717
21496
|
onClick: () => onViewChange(view.id),
|
|
20718
|
-
className:
|
|
21497
|
+
className: cn3(
|
|
20719
21498
|
"flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md transition-colors",
|
|
20720
21499
|
activeView === view.id ? "bg-zinc-700 text-zinc-200" : "text-zinc-400 hover:text-zinc-300"
|
|
20721
21500
|
),
|
|
@@ -20738,7 +21517,7 @@ var ToolbarButton = memo(function ToolbarButton2({
|
|
|
20738
21517
|
{
|
|
20739
21518
|
onClick,
|
|
20740
21519
|
title,
|
|
20741
|
-
className:
|
|
21520
|
+
className: cn3(
|
|
20742
21521
|
"p-2 rounded-lg hover:bg-zinc-800/50 text-zinc-400 hover:text-zinc-200 transition-colors",
|
|
20743
21522
|
className
|
|
20744
21523
|
),
|
|
@@ -20947,7 +21726,7 @@ var HtmlPreview3 = memo(function HtmlPreview4({ content }) {
|
|
|
20947
21726
|
setDeviceMode(mode);
|
|
20948
21727
|
setScale(1);
|
|
20949
21728
|
},
|
|
20950
|
-
className:
|
|
21729
|
+
className: cn3(
|
|
20951
21730
|
"flex items-center gap-1.5 px-2.5 py-1.5 text-xs rounded-md transition-all",
|
|
20952
21731
|
deviceMode === mode ? "bg-zinc-700 text-zinc-200 agent-sdk-light:bg-zinc-200 agent-sdk-light:text-zinc-900" : "text-zinc-500 agent-sdk-light:text-zinc-600 hover:text-zinc-300 agent-sdk-light:hover:text-zinc-900 hover:bg-zinc-800/50 agent-sdk-light:hover:bg-zinc-200/50"
|
|
20953
21732
|
),
|
|
@@ -20966,7 +21745,7 @@ var HtmlPreview3 = memo(function HtmlPreview4({ content }) {
|
|
|
20966
21745
|
"button",
|
|
20967
21746
|
{
|
|
20968
21747
|
onClick: () => setScale(s),
|
|
20969
|
-
className:
|
|
21748
|
+
className: cn3(
|
|
20970
21749
|
"px-2 py-1 text-[10px] rounded transition-colors",
|
|
20971
21750
|
scale === s ? "bg-zinc-700 text-zinc-200 agent-sdk-light:bg-zinc-300 agent-sdk-light:text-zinc-900" : "text-zinc-500 agent-sdk-light:text-zinc-600 hover:text-zinc-300 agent-sdk-light:hover:text-zinc-900"
|
|
20972
21751
|
),
|
|
@@ -21018,7 +21797,7 @@ var HtmlPreview3 = memo(function HtmlPreview4({ content }) {
|
|
|
21018
21797
|
/* @__PURE__ */ jsxs(
|
|
21019
21798
|
"div",
|
|
21020
21799
|
{
|
|
21021
|
-
className:
|
|
21800
|
+
className: cn3(
|
|
21022
21801
|
"bg-white rounded-lg shadow-2xl overflow-hidden transition-all duration-300 relative",
|
|
21023
21802
|
deviceMode !== "responsive" && "border-4 border-zinc-800 agent-sdk-light:border-zinc-300 rounded-xl"
|
|
21024
21803
|
),
|
|
@@ -21264,7 +22043,7 @@ var ImageArtifactPreview = memo(function ImageArtifactPreview2({
|
|
|
21264
22043
|
/* @__PURE__ */ jsx(
|
|
21265
22044
|
"div",
|
|
21266
22045
|
{
|
|
21267
|
-
className:
|
|
22046
|
+
className: cn3(
|
|
21268
22047
|
"relative transition-transform duration-300 cursor-zoom-in z-10",
|
|
21269
22048
|
isZoomed && "cursor-zoom-out scale-[2] z-50"
|
|
21270
22049
|
),
|
|
@@ -21289,7 +22068,7 @@ var ImageArtifactPreview = memo(function ImageArtifactPreview2({
|
|
|
21289
22068
|
"button",
|
|
21290
22069
|
{
|
|
21291
22070
|
onClick: () => setShowInfo((prev) => !prev),
|
|
21292
|
-
className:
|
|
22071
|
+
className: cn3(
|
|
21293
22072
|
"p-2 rounded-lg backdrop-blur-sm transition-colors",
|
|
21294
22073
|
showInfo ? "bg-[#d8ff00]/20 text-[#d8ff00]" : "bg-black/30 text-white/70 hover:text-white hover:bg-black/50"
|
|
21295
22074
|
),
|
|
@@ -21553,7 +22332,7 @@ var VideoArtifactPreview = memo(function VideoArtifactPreview2({
|
|
|
21553
22332
|
onTimeUpdate: handleTimeUpdate,
|
|
21554
22333
|
onEnded: () => setIsPlaying(false),
|
|
21555
22334
|
onClick: togglePlay,
|
|
21556
|
-
className:
|
|
22335
|
+
className: cn3(
|
|
21557
22336
|
"max-w-full max-h-full object-contain cursor-pointer",
|
|
21558
22337
|
!isPlaying && posterUrl && !currentTime && "opacity-0"
|
|
21559
22338
|
)
|
|
@@ -21564,7 +22343,7 @@ var VideoArtifactPreview = memo(function VideoArtifactPreview2({
|
|
|
21564
22343
|
{
|
|
21565
22344
|
className: "absolute inset-0 z-[2] flex items-center justify-center cursor-pointer",
|
|
21566
22345
|
onClick: togglePlay,
|
|
21567
|
-
children: /* @__PURE__ */ jsx("div", { className:
|
|
22346
|
+
children: /* @__PURE__ */ jsx("div", { className: cn3(
|
|
21568
22347
|
"w-16 h-16 rounded-full bg-white/15 backdrop-blur-md",
|
|
21569
22348
|
"flex items-center justify-center",
|
|
21570
22349
|
"transition-all duration-200",
|
|
@@ -21573,7 +22352,7 @@ var VideoArtifactPreview = memo(function VideoArtifactPreview2({
|
|
|
21573
22352
|
), children: /* @__PURE__ */ jsx("svg", { width: "26", height: "26", viewBox: "0 0 24 24", fill: "white", className: "ml-1", children: /* @__PURE__ */ jsx("path", { d: "M8 5v14l11-7z" }) }) })
|
|
21574
22353
|
}
|
|
21575
22354
|
),
|
|
21576
|
-
/* @__PURE__ */ jsxs("div", { className:
|
|
22355
|
+
/* @__PURE__ */ jsxs("div", { className: cn3(
|
|
21577
22356
|
"absolute bottom-0 left-0 right-0 z-[3]",
|
|
21578
22357
|
"bg-gradient-to-t from-black/90 via-black/50 to-transparent",
|
|
21579
22358
|
"px-4 pb-3 pt-10",
|
|
@@ -21842,7 +22621,7 @@ ${codeContent.trim()}
|
|
|
21842
22621
|
rows.push(cells);
|
|
21843
22622
|
});
|
|
21844
22623
|
if (rows.length === 0) return "";
|
|
21845
|
-
const colCount = Math.max(...rows.map((
|
|
22624
|
+
const colCount = Math.max(...rows.map((r2) => r2.length));
|
|
21846
22625
|
const colWidths = Array(colCount).fill(3);
|
|
21847
22626
|
rows.forEach((row) => {
|
|
21848
22627
|
row.forEach((cell, i) => {
|
|
@@ -22066,7 +22845,7 @@ var MarkdownEditor = memo(function MarkdownEditor2({
|
|
|
22066
22845
|
/* @__PURE__ */ jsx("span", { className: "text-[11px] text-[#d8ff00] font-medium whitespace-nowrap", children: isSourceMode ? "Markdown \u6E90\u7801" : "\u5BCC\u6587\u672C\u7F16\u8F91" })
|
|
22067
22846
|
] }),
|
|
22068
22847
|
/* @__PURE__ */ jsx("div", { className: "h-4 w-px bg-zinc-700/50 agent-sdk-light:bg-zinc-300 mx-1" }),
|
|
22069
|
-
!isSourceMode && toolbarGroups.map((group, groupIndex) => /* @__PURE__ */ jsxs(
|
|
22848
|
+
!isSourceMode && toolbarGroups.map((group, groupIndex) => /* @__PURE__ */ jsxs(React16__default.Fragment, { children: [
|
|
22070
22849
|
group.items.map((action, actionIndex) => /* @__PURE__ */ jsx(
|
|
22071
22850
|
"button",
|
|
22072
22851
|
{
|
|
@@ -22084,7 +22863,7 @@ var MarkdownEditor = memo(function MarkdownEditor2({
|
|
|
22084
22863
|
"button",
|
|
22085
22864
|
{
|
|
22086
22865
|
onClick: toggleSourceMode,
|
|
22087
|
-
className:
|
|
22866
|
+
className: cn3(
|
|
22088
22867
|
"p-1.5 flex items-center gap-1 text-[11px] rounded transition-colors whitespace-nowrap",
|
|
22089
22868
|
isSourceMode ? "bg-[#d8ff00]/10 text-[#d8ff00]" : "text-zinc-400 agent-sdk-light:text-zinc-600 hover:text-zinc-100 agent-sdk-light:hover:text-zinc-900 hover:bg-zinc-700/50 agent-sdk-light:hover:bg-zinc-200"
|
|
22090
22869
|
),
|
|
@@ -22158,7 +22937,7 @@ var ArtifactThumbnail = memo(function ArtifactThumbnail2({
|
|
|
22158
22937
|
}
|
|
22159
22938
|
);
|
|
22160
22939
|
}
|
|
22161
|
-
return /* @__PURE__ */ jsx("div", { className:
|
|
22940
|
+
return /* @__PURE__ */ jsx("div", { className: cn3("w-6 h-6 rounded flex items-center justify-center flex-shrink-0", typeConf.bgColor), children: /* @__PURE__ */ jsx(TypeIcon, { size: 12, className: typeConf.color }) });
|
|
22162
22941
|
});
|
|
22163
22942
|
var ArtifactTabs = memo(function ArtifactTabs2({
|
|
22164
22943
|
artifacts,
|
|
@@ -22281,7 +23060,7 @@ var ArtifactTabs = memo(function ArtifactTabs2({
|
|
|
22281
23060
|
onDragEnd: handleDragEnd,
|
|
22282
23061
|
onDrop: (e) => handleDrop(e, artifact.id),
|
|
22283
23062
|
onClick: () => onSwitch(artifact.id),
|
|
22284
|
-
className:
|
|
23063
|
+
className: cn3(
|
|
22285
23064
|
"group/tab flex items-center gap-1 pl-2.5 pr-1 py-1 text-xs rounded-md transition-all whitespace-nowrap flex-shrink-0 cursor-pointer select-none",
|
|
22286
23065
|
isActive ? "bg-zinc-800 text-zinc-100 agent-sdk-light:bg-zinc-200 agent-sdk-light:text-zinc-900" : "text-zinc-500 agent-sdk-light:text-zinc-600 hover:text-zinc-300 agent-sdk-light:hover:text-zinc-900 hover:bg-zinc-800/50 agent-sdk-light:hover:bg-zinc-200/50",
|
|
22287
23066
|
isDragging && "opacity-40",
|
|
@@ -22290,13 +23069,13 @@ var ArtifactTabs = memo(function ArtifactTabs2({
|
|
|
22290
23069
|
),
|
|
22291
23070
|
title: artifact.title,
|
|
22292
23071
|
children: [
|
|
22293
|
-
/* @__PURE__ */ jsx(TypeIcon, { size: 12, className:
|
|
23072
|
+
/* @__PURE__ */ jsx(TypeIcon, { size: 12, className: cn3("flex-shrink-0", isActive ? typeConf.color : "") }),
|
|
22294
23073
|
/* @__PURE__ */ jsx("span", { className: "max-w-[120px] truncate", children: artifact.title }),
|
|
22295
23074
|
onClose && /* @__PURE__ */ jsx(
|
|
22296
23075
|
"button",
|
|
22297
23076
|
{
|
|
22298
23077
|
onClick: (e) => handleCloseTab(e, artifact.id),
|
|
22299
|
-
className:
|
|
23078
|
+
className: cn3(
|
|
22300
23079
|
"ml-0.5 p-0.5 rounded transition-colors flex-shrink-0",
|
|
22301
23080
|
isActive ? "text-zinc-400 hover:text-zinc-100 hover:bg-zinc-700" : "text-transparent group-hover/tab:text-zinc-500 hover:!text-zinc-300 hover:!bg-zinc-700"
|
|
22302
23081
|
),
|
|
@@ -22324,7 +23103,7 @@ var ArtifactTabs = memo(function ArtifactTabs2({
|
|
|
22324
23103
|
"button",
|
|
22325
23104
|
{
|
|
22326
23105
|
onClick: () => setShowAllPanel((prev) => !prev),
|
|
22327
|
-
className:
|
|
23106
|
+
className: cn3(
|
|
22328
23107
|
"p-1.5 mr-1 text-zinc-500 hover:text-zinc-300 hover:bg-zinc-800/50 rounded transition-colors",
|
|
22329
23108
|
showAllPanel && "bg-zinc-800 text-zinc-300"
|
|
22330
23109
|
),
|
|
@@ -22349,7 +23128,7 @@ var ArtifactTabs = memo(function ArtifactTabs2({
|
|
|
22349
23128
|
onSwitch(artifact.id);
|
|
22350
23129
|
setShowAllPanel(false);
|
|
22351
23130
|
},
|
|
22352
|
-
className:
|
|
23131
|
+
className: cn3(
|
|
22353
23132
|
"flex items-center gap-2.5 px-2.5 py-2 text-xs rounded-md transition-all w-full text-left",
|
|
22354
23133
|
isActive ? "bg-zinc-800 text-zinc-100 agent-sdk-light:bg-zinc-100 agent-sdk-light:text-zinc-900" : "text-zinc-400 agent-sdk-light:text-zinc-600 hover:text-zinc-200 agent-sdk-light:hover:text-zinc-900 hover:bg-zinc-800/50 agent-sdk-light:hover:bg-zinc-100"
|
|
22355
23134
|
),
|
|
@@ -22693,7 +23472,7 @@ function InformationSupplement({
|
|
|
22693
23472
|
referenceImage,
|
|
22694
23473
|
qrCode
|
|
22695
23474
|
}) {
|
|
22696
|
-
const [open, setOpen] =
|
|
23475
|
+
const [open, setOpen] = React16__default.useState(!confirmed);
|
|
22697
23476
|
const resolvedMain = main_image || mainImage;
|
|
22698
23477
|
const resolvedRef = reference_image || referenceImage;
|
|
22699
23478
|
const resolvedQr = qrcode || qrCode;
|
|
@@ -22847,6 +23626,7 @@ function Sidebar({
|
|
|
22847
23626
|
onNew,
|
|
22848
23627
|
agentName,
|
|
22849
23628
|
agentType,
|
|
23629
|
+
agentIcon,
|
|
22850
23630
|
collapsed,
|
|
22851
23631
|
onToggle
|
|
22852
23632
|
}) {
|
|
@@ -22870,7 +23650,7 @@ function Sidebar({
|
|
|
22870
23650
|
/* @__PURE__ */ jsxs("div", { className: "p-3 border-b border-zinc-800/50", children: [
|
|
22871
23651
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between mb-3", children: [
|
|
22872
23652
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 min-w-0", children: [
|
|
22873
|
-
/* @__PURE__ */ jsx("div", { className: "w-7 h-7 rounded-lg bg-[#d8ff00]/10 flex items-center justify-center flex-shrink-0", children: /* @__PURE__ */ jsx(Bot, { size: 14, className: "text-[#d8ff00]" }) }),
|
|
23653
|
+
/* @__PURE__ */ jsx("div", { className: "w-7 h-7 rounded-lg bg-[#d8ff00]/10 flex items-center justify-center flex-shrink-0", children: agentIcon ? /* @__PURE__ */ jsx("img", { src: getImageUrl(agentIcon), alt: "Agent Icon", className: "w-7 h-7 rounded-lg" }) : /* @__PURE__ */ jsx(Bot, { size: 14, className: "text-[#d8ff00]" }) }),
|
|
22874
23654
|
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium text-white truncate", children: agentName || "Agent" })
|
|
22875
23655
|
] }),
|
|
22876
23656
|
/* @__PURE__ */ jsx("div", { className: "flex gap-0.5", children: /* @__PURE__ */ jsx("button", { onClick: onToggle, className: "p-1.5 text-zinc-500 hover:text-zinc-300 hover:bg-zinc-800 rounded-lg", children: /* @__PURE__ */ jsx(PanelLeftClose, { size: 14 }) }) })
|
|
@@ -22925,7 +23705,7 @@ function Sidebar({
|
|
|
22925
23705
|
] });
|
|
22926
23706
|
}
|
|
22927
23707
|
function WelcomePage({ agentName, welcomeMessage, tools, onNew, onPrompt }) {
|
|
22928
|
-
const quickPrompts =
|
|
23708
|
+
const quickPrompts = React16__default.useMemo(() => {
|
|
22929
23709
|
const prompts = [];
|
|
22930
23710
|
const hasImageTool = tools?.some(
|
|
22931
23711
|
(t) => t.name?.toLowerCase().includes("image") || t.name?.toLowerCase().includes("\u56FE\u7247") || t.type === "COMFY_APP"
|
|
@@ -23244,7 +24024,7 @@ function ChatInputArea({
|
|
|
23244
24024
|
] })
|
|
23245
24025
|
] }) });
|
|
23246
24026
|
}
|
|
23247
|
-
var DragHandle =
|
|
24027
|
+
var DragHandle = React16__default.memo(function DragHandle2({
|
|
23248
24028
|
artifactPanelWidth,
|
|
23249
24029
|
isDragging,
|
|
23250
24030
|
onMouseDown
|
|
@@ -23271,7 +24051,7 @@ var DragHandle = React24__default.memo(function DragHandle2({
|
|
|
23271
24051
|
children: /* @__PURE__ */ jsx(
|
|
23272
24052
|
"div",
|
|
23273
24053
|
{
|
|
23274
|
-
className:
|
|
24054
|
+
className: cn3(
|
|
23275
24055
|
"absolute left-1/2 top-0 bottom-0 -translate-x-1/2",
|
|
23276
24056
|
"transition-all duration-100"
|
|
23277
24057
|
),
|
|
@@ -23350,7 +24130,7 @@ var ArtifactBarMiniThumbnail = memo(function ArtifactBarMiniThumbnail2({
|
|
|
23350
24130
|
}
|
|
23351
24131
|
return /* @__PURE__ */ jsx("div", { className: "w-6 h-6 rounded border border-zinc-700 agent-sdk-light:border-zinc-300 bg-zinc-800 agent-sdk-light:bg-zinc-200 flex items-center justify-center", children: /* @__PURE__ */ jsx(TypeIcon, { size: 10, className: "text-zinc-400" }) });
|
|
23352
24132
|
});
|
|
23353
|
-
var ArtifactBar =
|
|
24133
|
+
var ArtifactBar = React16__default.memo(function ArtifactBar2({
|
|
23354
24134
|
artifacts,
|
|
23355
24135
|
onOpenArtifact,
|
|
23356
24136
|
config
|
|
@@ -23457,7 +24237,7 @@ var ArtifactBar = React24__default.memo(function ArtifactBar2({
|
|
|
23457
24237
|
artifacts.length - 4
|
|
23458
24238
|
] }) })
|
|
23459
24239
|
] }),
|
|
23460
|
-
/* @__PURE__ */ jsx(ChevronUp, { size: 14, className:
|
|
24240
|
+
/* @__PURE__ */ jsx(ChevronUp, { size: 14, className: cn3(
|
|
23461
24241
|
"text-zinc-500 transition-transform flex-shrink-0",
|
|
23462
24242
|
expanded && "rotate-180"
|
|
23463
24243
|
) })
|
|
@@ -23484,7 +24264,7 @@ function useArtifactPanel({ currentSessionId }) {
|
|
|
23484
24264
|
const [isDragging, setIsDragging] = useState(false);
|
|
23485
24265
|
const dragStartRef = useRef(null);
|
|
23486
24266
|
const containerRef = useRef(null);
|
|
23487
|
-
const artifactList =
|
|
24267
|
+
const artifactList = React16__default.useMemo(() => {
|
|
23488
24268
|
const ordered = artifactOrder.map((id) => artifacts[id]).filter(Boolean);
|
|
23489
24269
|
const unordered = Object.values(artifacts).filter(
|
|
23490
24270
|
(a) => !artifactOrder.includes(a.id)
|
|
@@ -23542,7 +24322,11 @@ function useArtifactPanel({ currentSessionId }) {
|
|
|
23542
24322
|
return;
|
|
23543
24323
|
}
|
|
23544
24324
|
const existingArtifact = Object.values(artifacts).find(
|
|
23545
|
-
(a) =>
|
|
24325
|
+
(a) => {
|
|
24326
|
+
const sameContent = a.currentContent === data.content && a.type === data.type;
|
|
24327
|
+
const sameId = a?.metadata?.workId === data.metadata?.workId;
|
|
24328
|
+
return sameContent || sameId;
|
|
24329
|
+
}
|
|
23546
24330
|
);
|
|
23547
24331
|
if (existingArtifact) {
|
|
23548
24332
|
setActiveArtifact(existingArtifact.id);
|
|
@@ -24344,7 +25128,7 @@ function usePlanMode() {
|
|
|
24344
25128
|
handleHumanInput
|
|
24345
25129
|
};
|
|
24346
25130
|
}
|
|
24347
|
-
var AgentChat =
|
|
25131
|
+
var AgentChat = React16__default.forwardRef(({
|
|
24348
25132
|
agentId,
|
|
24349
25133
|
projectId,
|
|
24350
25134
|
agentName,
|
|
@@ -24372,7 +25156,7 @@ var AgentChat = React24__default.forwardRef(({
|
|
|
24372
25156
|
const showSidebar = !embedded && !hideSidebar;
|
|
24373
25157
|
const showHeader = !embedded && !hideHeader;
|
|
24374
25158
|
const outerComponents = useComponents();
|
|
24375
|
-
const mergedComponents =
|
|
25159
|
+
const mergedComponents = React16__default.useMemo(() => {
|
|
24376
25160
|
const configComponents = config?.components || {};
|
|
24377
25161
|
const mergedRegistry = {
|
|
24378
25162
|
InformationSupplement,
|
|
@@ -24390,6 +25174,7 @@ var AgentChat = React24__default.forwardRef(({
|
|
|
24390
25174
|
tools: _tools,
|
|
24391
25175
|
setTools,
|
|
24392
25176
|
setSkills,
|
|
25177
|
+
mainAgentIcon,
|
|
24393
25178
|
setShowItemTime,
|
|
24394
25179
|
setSubAgentConfigs,
|
|
24395
25180
|
setMainAgentPublicId,
|
|
@@ -24682,6 +25467,7 @@ var AgentChat = React24__default.forwardRef(({
|
|
|
24682
25467
|
onNew: handleNew,
|
|
24683
25468
|
agentName,
|
|
24684
25469
|
agentType,
|
|
25470
|
+
agentIcon: mainAgentIcon,
|
|
24685
25471
|
collapsed,
|
|
24686
25472
|
onToggle: () => setCollapsed(!collapsed)
|
|
24687
25473
|
}
|
|
@@ -24723,21 +25509,21 @@ var AgentChat = React24__default.forwardRef(({
|
|
|
24723
25509
|
/* @__PURE__ */ jsxs(
|
|
24724
25510
|
"div",
|
|
24725
25511
|
{
|
|
24726
|
-
className:
|
|
25512
|
+
className: cn3(
|
|
24727
25513
|
"flex flex-col min-h-0 overflow-hidden",
|
|
24728
25514
|
!isDragging && "transition-[width,opacity,transform] duration-300 ease-out",
|
|
24729
25515
|
isArtifactFullscreen ? "w-0 min-w-0 opacity-0 -translate-x-4" : currentArtifact ? "min-w-[350px]" : "w-full"
|
|
24730
25516
|
),
|
|
24731
25517
|
style: currentArtifact && !isArtifactFullscreen ? { width: `${100 - artifactPanelWidth}%` } : void 0,
|
|
24732
25518
|
children: [
|
|
24733
|
-
showHeader
|
|
25519
|
+
showHeader ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 h-12 px-3 border-b border-zinc-800/50 bg-zinc-950/80 backdrop-blur-sm flex-shrink-0", children: [
|
|
24734
25520
|
/* @__PURE__ */ jsx("button", { onClick: () => setMobileOpen(true), className: "lg:hidden p-1.5 text-zinc-500 hover:text-zinc-300 hover:bg-zinc-800 rounded-lg", children: /* @__PURE__ */ jsx(PanelLeft, { size: 18 }) }),
|
|
24735
25521
|
onNavigateBack && /* @__PURE__ */ jsx("button", { onClick: onNavigateBack, className: "p-1.5 text-zinc-500 hover:text-zinc-300 hover:bg-zinc-800 rounded-lg", children: /* @__PURE__ */ jsx(ArrowLeft, { size: 18 }) }),
|
|
24736
25522
|
/* @__PURE__ */ jsx("div", { className: "h-4 w-px bg-zinc-800 mx-1" }),
|
|
24737
25523
|
/* @__PURE__ */ jsx("span", { className: "text-sm text-zinc-300 font-medium", children: agentName || "Agent" }),
|
|
24738
25524
|
agentType && /* @__PURE__ */ jsx("span", { className: "text-[10px] text-zinc-600 bg-zinc-800/50 px-1.5 py-0.5 rounded", children: agentType === "BUILTIN" ? "\u5185\u7F6E" : agentType === "EXTERNAL" ? "\u5916\u90E8" : "\u591AAgent" }),
|
|
24739
25525
|
onNavigateToSettings && /* @__PURE__ */ jsx("button", { onClick: onNavigateToSettings, className: "ml-auto p-1.5 text-zinc-500 hover:text-zinc-300 hover:bg-zinc-800 rounded-lg", children: /* @__PURE__ */ jsx(Settings, { size: 18 }) })
|
|
24740
|
-
] }),
|
|
25526
|
+
] }) : /* @__PURE__ */ jsx("button", { onClick: () => setMobileOpen(true), className: "lg:hidden p-1.5 text-zinc-500 hover:text-zinc-300 hover:bg-zinc-800 rounded-lg w-8", children: /* @__PURE__ */ jsx(PanelLeft, { size: 18 }) }),
|
|
24741
25527
|
/* @__PURE__ */ jsx(
|
|
24742
25528
|
ChatWindow_default,
|
|
24743
25529
|
{
|
|
@@ -24814,7 +25600,7 @@ var AgentChat = React24__default.forwardRef(({
|
|
|
24814
25600
|
/* @__PURE__ */ jsxs(
|
|
24815
25601
|
"div",
|
|
24816
25602
|
{
|
|
24817
|
-
className:
|
|
25603
|
+
className: cn3(
|
|
24818
25604
|
"flex-shrink-0 overflow-hidden h-full relative",
|
|
24819
25605
|
!isDragging && "transition-[width,opacity] duration-300 ease-out",
|
|
24820
25606
|
currentArtifact ? isArtifactFullscreen ? "w-full min-w-0 border-l-0" : "min-w-[400px]" : "w-0 min-w-0 opacity-0"
|
|
@@ -24847,21 +25633,18 @@ var AgentChat = React24__default.forwardRef(({
|
|
|
24847
25633
|
}
|
|
24848
25634
|
},
|
|
24849
25635
|
onReorderArtifacts: (fromIndex, toIndex) => {
|
|
24850
|
-
|
|
24851
|
-
const [moved] = newOrder.splice(fromIndex, 1);
|
|
24852
|
-
newOrder.splice(toIndex, 0, moved);
|
|
24853
|
-
reorderArtifacts(newOrder);
|
|
25636
|
+
reorderArtifacts(fromIndex, toIndex);
|
|
24854
25637
|
},
|
|
24855
25638
|
onContentChange: (content) => {
|
|
24856
25639
|
if (activeArtifact) {
|
|
24857
|
-
updateArtifactContent(activeArtifact.id, content);
|
|
25640
|
+
updateArtifactContent(activeArtifact.id, content, "user");
|
|
24858
25641
|
}
|
|
24859
25642
|
},
|
|
24860
25643
|
onSave: async (artifactId, content) => {
|
|
24861
25644
|
try {
|
|
24862
25645
|
const res = await artifactService.updateContent(artifactId, content);
|
|
24863
25646
|
if (res.success) {
|
|
24864
|
-
updateArtifactContent(artifactId, content);
|
|
25647
|
+
updateArtifactContent(artifactId, content, "user");
|
|
24865
25648
|
toast.success("\u4EA7\u7269\u5DF2\u4FDD\u5B58");
|
|
24866
25649
|
} else {
|
|
24867
25650
|
toast.error("\u4FDD\u5B58\u5931\u8D25");
|
|
@@ -25386,7 +26169,34 @@ function ShareReplayPage({ shareId, onNavigateBack }) {
|
|
|
25386
26169
|
] }) })
|
|
25387
26170
|
] });
|
|
25388
26171
|
}
|
|
26172
|
+
var AgentSDKProvider = ({
|
|
26173
|
+
children,
|
|
26174
|
+
toasterOptions,
|
|
26175
|
+
components
|
|
26176
|
+
}) => {
|
|
26177
|
+
const defaultToastOptions = {
|
|
26178
|
+
position: "top-center",
|
|
26179
|
+
toastOptions: {
|
|
26180
|
+
style: {
|
|
26181
|
+
background: "#27272a",
|
|
26182
|
+
border: "1px solid #3f3f46",
|
|
26183
|
+
color: "#fff"
|
|
26184
|
+
}
|
|
26185
|
+
}
|
|
26186
|
+
};
|
|
26187
|
+
const mergedOptions = toasterOptions ? { ...defaultToastOptions, ...toasterOptions } : defaultToastOptions;
|
|
26188
|
+
return /* @__PURE__ */ jsxs(ComponentProvider, { components, children: [
|
|
26189
|
+
children,
|
|
26190
|
+
/* @__PURE__ */ jsx(
|
|
26191
|
+
Toaster,
|
|
26192
|
+
{
|
|
26193
|
+
position: mergedOptions.position,
|
|
26194
|
+
toastOptions: mergedOptions.toastOptions
|
|
26195
|
+
}
|
|
26196
|
+
)
|
|
26197
|
+
] });
|
|
26198
|
+
};
|
|
25389
26199
|
|
|
25390
|
-
export { AgentChat_default as AgentChat, ChatWindow_default as ChatWindow, ComponentProvider, HumanInputDialog_default as HumanInputDialog, ImagePreview, MAX_RECONNECT_ATTEMPTS2 as MAX_RECONNECT_ATTEMPTS, MessageBubble_default as MessageBubble, MessageImage, MessageVideo, MultiAgentThoughts_default as MultiAgentThoughts, ParameterDisplay, PlanCard_default as PlanCard, PlanConfirmDialog_default as PlanConfirmDialog, PlanProgressPanel_default as PlanProgressPanel, RECONNECT_BASE_DELAY2 as RECONNECT_BASE_DELAY, SSE_HEARTBEAT_TIMEOUT2 as SSE_HEARTBEAT_TIMEOUT, SaveTemplateDialog_default as SaveTemplateDialog, ShareModal, ShareReplayPage, StreamingJsonDisplay, TemplateSelector_default as TemplateSelector, TemplateSourceBadge_default as TemplateSourceBadge, TemplateVariableDialog_default as TemplateVariableDialog, ThinkingProcess, ToolConfirmCard, ToolConfirmDialog, UpdateTemplateDialog_default as UpdateTemplateDialog, VoiceInput, VoiceInputButton, VoiceRecordingModal, VoiceWaveform, agentService, agentSkillService, agentToolService, artifactService, calculateReconnectDelay, componentService, configureTTS, confirmAllPendingToolCalls, createAndStartSession, createHeartbeatManager, createReconnectManager, createStreamReader, embedding, extractJsonContent, extractThinkingContent, extractToolCalls, filterMediaAttachments, findMessageById, findSessionById, formatParameters, generateSSEId, generateSessionTitle, generateToolCallDescription, getCurrentSessionMessages, getFileUrl, getHDImageUrl, getImageUrl, getOSSClient, getParamsSummary, getSessionCurrentThoughts, getSessionPendingToolCalls, getSessionWithMessages, getToolCallDisplayStatus, getToolCallStatusPriority, hasExecutingToolCalls, hasPendingToolCalls, hasWaitingConfirmation, isConversationActive, isCurrentlyThinking, isImageUrl, isMechanicalSummary, isPendingToolCallsForSession, isVideoUrl3 as isVideoUrl, llmService, looksLikeJson, mergeToolCalls, messageService, normalizeToolCall, normalizeToolCalls, parseSSELine2 as parseSSELine, parseThinkingContent2 as parseThinkingContent, parseThoughts, planService, rejectAllPendingToolCalls, resolveMediaUrl, sessionService, shareService, templateService, toolCallService, uploadOSS, useActiveArtifact, useActiveArtifactId, useActiveSubAgent, useAgentStore, useArtifactList, useArtifactOrder, useArtifacts, useCanvasBridge, useChatError, useChatUI, useComponent, useComponents, useCurrentSession, useCurrentThoughts, useCurrentThoughtsSessionId, useIsMultiAgentMode, useIsParallelRunning, useIsStreaming, useIsThinking, useMessages, useMultiAgentState, useParallelSummary, usePendingComponents, usePendingComponentsSessionId, usePendingFrontendToolCalls, usePendingFrontendToolCallsSessionId, usePendingToolCalls, usePendingToolCallsSessionId, useSSE, useSessions, useSessionsLoading, useStreamingContent, useStreamingSessionId, useSubAgentPanels, useSubAgents, useVoiceRecognition };
|
|
26200
|
+
export { AgentChat_default as AgentChat, AgentSDKProvider, ChatWindow_default as ChatWindow, ComponentProvider, HumanInputDialog_default as HumanInputDialog, ImagePreview, MAX_RECONNECT_ATTEMPTS2 as MAX_RECONNECT_ATTEMPTS, MessageBubble_default as MessageBubble, MessageImage, MessageVideo, MultiAgentThoughts_default as MultiAgentThoughts, ParameterDisplay, PlanCard_default as PlanCard, PlanConfirmDialog_default as PlanConfirmDialog, PlanProgressPanel_default as PlanProgressPanel, RECONNECT_BASE_DELAY2 as RECONNECT_BASE_DELAY, SSE_HEARTBEAT_TIMEOUT2 as SSE_HEARTBEAT_TIMEOUT, SaveTemplateDialog_default as SaveTemplateDialog, ShareModal, ShareReplayPage, StreamingJsonDisplay, TemplateSelector_default as TemplateSelector, TemplateSourceBadge_default as TemplateSourceBadge, TemplateVariableDialog_default as TemplateVariableDialog, ThinkingProcess, ToolConfirmCard, ToolConfirmDialog, UpdateTemplateDialog_default as UpdateTemplateDialog, VoiceInput, VoiceInputButton, VoiceRecordingModal, VoiceWaveform, agentService, agentSkillService, agentToolService, artifactService, calculateReconnectDelay, componentService, configureTTS, confirmAllPendingToolCalls, createAndStartSession, createHeartbeatManager, createReconnectManager, createStreamReader, embedding, extractJsonContent, extractThinkingContent, extractToolCalls, filterMediaAttachments, findMessageById, findSessionById, formatParameters, generateSSEId, generateSessionTitle, generateToolCallDescription, getCurrentSessionMessages, getFileUrl, getHDImageUrl, getImageUrl, getOSSClient, getParamsSummary, getSessionCurrentThoughts, getSessionPendingToolCalls, getSessionWithMessages, getToolCallDisplayStatus, getToolCallStatusPriority, hasExecutingToolCalls, hasPendingToolCalls, hasWaitingConfirmation, isConversationActive, isCurrentlyThinking, isImageUrl, isMechanicalSummary, isPendingToolCallsForSession, isVideoUrl3 as isVideoUrl, llmService, looksLikeJson, mergeToolCalls, messageService, normalizeToolCall, normalizeToolCalls, parseSSELine2 as parseSSELine, parseThinkingContent2 as parseThinkingContent, parseThoughts, planService, rejectAllPendingToolCalls, resolveMediaUrl, sessionService, shareService, templateService, toolCallService, uploadOSS, useActiveArtifact, useActiveArtifactId, useActiveSubAgent, useAgentStore, useArtifactList, useArtifactOrder, useArtifacts, useCanvasBridge, useChatError, useChatUI, useComponent, useComponents, useCurrentSession, useCurrentThoughts, useCurrentThoughtsSessionId, useIsMultiAgentMode, useIsParallelRunning, useIsStreaming, useIsThinking, useMessages, useMultiAgentState, useParallelSummary, usePendingComponents, usePendingComponentsSessionId, usePendingFrontendToolCalls, usePendingFrontendToolCallsSessionId, usePendingToolCalls, usePendingToolCallsSessionId, useSSE, useSessions, useSessionsLoading, useStreamingContent, useStreamingSessionId, useSubAgentPanels, useSubAgents, useVoiceRecognition };
|
|
25391
26201
|
//# sourceMappingURL=index.mjs.map
|
|
25392
26202
|
//# sourceMappingURL=index.mjs.map
|