@dust-tt/sparkle 0.2.502 → 0.2.503-rc-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +1 -1
- package/dist/esm/components/AnchoredPopover.d.ts +13 -0
- package/dist/esm/components/AnchoredPopover.d.ts.map +1 -0
- package/dist/esm/components/AnchoredPopover.js +54 -0
- package/dist/esm/components/AnchoredPopover.js.map +1 -0
- package/dist/esm/components/AnimatedText.d.ts +1 -1
- package/dist/esm/components/Button.d.ts.map +1 -1
- package/dist/esm/components/Dropdown.d.ts +1 -1
- package/dist/esm/components/Popover.d.ts +2 -1
- package/dist/esm/components/Popover.d.ts.map +1 -1
- package/dist/esm/components/Popover.js +3 -2
- package/dist/esm/components/Popover.js.map +1 -1
- package/dist/esm/components/RadioGroup.js +3 -3
- package/dist/esm/components/Resizable.d.ts +1 -1
- package/dist/esm/components/Tabs.d.ts +1 -1
- package/dist/esm/components/index.d.ts +2 -2
- package/dist/esm/components/index.d.ts.map +1 -1
- package/dist/esm/components/index.js +2 -2
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/stories/AnchoredPopover.stories.d.ts +14 -0
- package/dist/esm/stories/AnchoredPopover.stories.d.ts.map +1 -0
- package/dist/esm/stories/AnchoredPopover.stories.js +69 -0
- package/dist/esm/stories/AnchoredPopover.stories.js.map +1 -0
- package/dist/esm/stories/Breadcrumbs.stories.d.ts.map +1 -1
- package/dist/esm/stories/Breadcrumbs.stories.js +1 -3
- package/dist/esm/stories/Breadcrumbs.stories.js.map +1 -1
- package/dist/esm/stories/Chip.stories.d.ts +3 -3
- package/dist/sparkle.css +8 -127
- package/package.json +1 -1
- package/src/components/AnchoredPopover.tsx +98 -0
- package/src/components/Button.tsx +1 -1
- package/src/components/Popover.tsx +10 -4
- package/src/components/RadioGroup.tsx +3 -3
- package/src/components/index.ts +2 -7
- package/src/stories/AnchoredPopover.stories.tsx +115 -0
- package/src/stories/Breadcrumbs.stories.tsx +1 -3
- package/dist/esm/components/TourGuide.d.ts +0 -39
- package/dist/esm/components/TourGuide.d.ts.map +0 -1
- package/dist/esm/components/TourGuide.js +0 -145
- package/dist/esm/components/TourGuide.js.map +0 -1
- package/dist/esm/stories/TourGuide.stories.d.ts +0 -4
- package/dist/esm/stories/TourGuide.stories.d.ts.map +0 -1
- package/dist/esm/stories/TourGuide.stories.js +0 -133
- package/dist/esm/stories/TourGuide.stories.js.map +0 -1
- package/src/components/TourGuide.tsx +0 -316
- package/src/stories/TourGuide.stories.tsx +0 -472
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { __assign, __read, __rest } from "tslib";
|
|
2
|
-
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
3
|
-
import React, { useEffect, useState } from "react";
|
|
4
|
-
import { Button } from "../components/Button";
|
|
5
|
-
import { cn } from "../lib";
|
|
6
|
-
export var TourGuideCardTitle = React.forwardRef(function (_a, ref) {
|
|
7
|
-
var className = _a.className, children = _a.children, props = __rest(_a, ["className", "children"]);
|
|
8
|
-
return (React.createElement("div", __assign({ ref: ref, className: cn("s-heading-lg s-px-3 s-pt-4", className) }, props), children));
|
|
9
|
-
});
|
|
10
|
-
TourGuideCardTitle.displayName = "TourGuideCardTitle";
|
|
11
|
-
export var TourGuideCardContent = React.forwardRef(function (_a, ref) {
|
|
12
|
-
var className = _a.className, children = _a.children, props = __rest(_a, ["className", "children"]);
|
|
13
|
-
return (React.createElement("div", __assign({ ref: ref, className: cn("s-copy-base s-px-3 s-text-muted-foreground dark:s-text-muted-foreground-night", className) }, props), children));
|
|
14
|
-
});
|
|
15
|
-
TourGuideCardContent.displayName = "TourGuideCardContent";
|
|
16
|
-
export var TourGuideCardVisual = React.forwardRef(function (_a, ref) {
|
|
17
|
-
var className = _a.className, children = _a.children, props = __rest(_a, ["className", "children"]);
|
|
18
|
-
return (React.createElement("div", __assign({ ref: ref, className: cn("s-aspect-video s-bg-muted-background dark:s-bg-muted-background-night", className) }, props), children));
|
|
19
|
-
});
|
|
20
|
-
TourGuideCardVisual.displayName = "TourGuideCardVisual";
|
|
21
|
-
export var TourGuideCardActions = React.forwardRef(function (_a, ref) {
|
|
22
|
-
var currentIndex = _a.currentIndex, totalCards = _a.totalCards, onNext = _a.onNext, onDismiss = _a.onDismiss, className = _a.className, children = _a.children, props = __rest(_a, ["currentIndex", "totalCards", "onNext", "onDismiss", "className", "children"]);
|
|
23
|
-
var isFirstCard = currentIndex === 0;
|
|
24
|
-
var isLastCard = currentIndex === totalCards - 1;
|
|
25
|
-
var isSingleCard = totalCards === 1;
|
|
26
|
-
var showDismiss = !isLastCard && !isSingleCard;
|
|
27
|
-
return (React.createElement("div", __assign({ ref: ref, className: cn("s-flex s-justify-end s-space-x-2 s-p-2 s-pt-4", className) }, props), children ? (children) : (React.createElement(React.Fragment, null,
|
|
28
|
-
showDismiss && onDismiss && (React.createElement(Button, { variant: "outline", label: "Dismiss", onClick: onDismiss })),
|
|
29
|
-
onNext && (React.createElement(Button, { onClick: onNext, variant: "highlight", label: isSingleCard
|
|
30
|
-
? "Ok"
|
|
31
|
-
: isFirstCard
|
|
32
|
-
? "Start Tour"
|
|
33
|
-
: isLastCard
|
|
34
|
-
? "Done"
|
|
35
|
-
: "Next" }))))));
|
|
36
|
-
});
|
|
37
|
-
TourGuideCardActions.displayName = "TourGuideCardActions";
|
|
38
|
-
export var TourGuideCard = React.forwardRef(function (_a) {
|
|
39
|
-
var className = _a.className, children = _a.children, _b = _a.align, align = _b === void 0 ? "center" : _b, _c = _a.side, side = _c === void 0 ? "bottom" : _c, _d = _a.sideOffset, sideOffset = _d === void 0 ? 4 : _d, onNext = _a.onNext, onDismiss = _a.onDismiss, _e = _a.currentIndex, currentIndex = _e === void 0 ? 0 : _e, _f = _a.totalCards, totalCards = _f === void 0 ? 1 : _f;
|
|
40
|
-
return (React.createElement(PopoverPrimitive.Content, { align: align, side: side, sideOffset: sideOffset, className: cn("s-z-50 s-w-[420px] s-max-w-xs s-space-y-0.5 s-overflow-hidden s-rounded-2xl s-border s-shadow-xl s-transition-all s-duration-300 s-ease-in-out", "s-border-highlight-400 s-bg-background s-text-foreground s-ring-2 s-ring-highlight-400/30", "dark:s-border-border-night dark:s-bg-background-night dark:s-text-foreground-night", className), onOpenAutoFocus: function (e) { return e.preventDefault(); } },
|
|
41
|
-
children,
|
|
42
|
-
React.createElement(TourGuideCardActions, { currentIndex: currentIndex, totalCards: totalCards, onNext: onNext, onDismiss: onDismiss })));
|
|
43
|
-
});
|
|
44
|
-
TourGuideCard.displayName = "TourGuideCard";
|
|
45
|
-
export function TourGuide(_a) {
|
|
46
|
-
var children = _a.children, _b = _a.autoStart, autoStart = _b === void 0 ? true : _b, onStart = _a.onStart, onEnd = _a.onEnd, onDismiss = _a.onDismiss;
|
|
47
|
-
var _c = __read(useState(0), 2), currentIndex = _c[0], setCurrentIndex = _c[1];
|
|
48
|
-
var _d = __read(useState(autoStart), 2), isActive = _d[0], setIsActive = _d[1];
|
|
49
|
-
var _e = __read(useState({
|
|
50
|
-
top: "50%",
|
|
51
|
-
left: "50%",
|
|
52
|
-
width: "0px",
|
|
53
|
-
height: "0px",
|
|
54
|
-
}), 2), position = _e[0], setPosition = _e[1];
|
|
55
|
-
// Get all TourGuideCard children - memoize to prevent unnecessary re-renders
|
|
56
|
-
var cards = React.useMemo(function () {
|
|
57
|
-
return React.Children.toArray(children).filter(function (child) {
|
|
58
|
-
return React.isValidElement(child) && child.type === TourGuideCard;
|
|
59
|
-
});
|
|
60
|
-
}, [children]);
|
|
61
|
-
// Only run on mount and when autoStart changes
|
|
62
|
-
useEffect(function () {
|
|
63
|
-
if (autoStart) {
|
|
64
|
-
setIsActive(true);
|
|
65
|
-
setCurrentIndex(0);
|
|
66
|
-
onStart === null || onStart === void 0 ? void 0 : onStart();
|
|
67
|
-
}
|
|
68
|
-
}, [autoStart, onStart]);
|
|
69
|
-
// Handle position updates - use requestAnimationFrame to prevent excessive updates
|
|
70
|
-
useEffect(function () {
|
|
71
|
-
var _a;
|
|
72
|
-
if (!isActive) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
var updatePosition = function () {
|
|
76
|
-
var currentCard = cards[currentIndex];
|
|
77
|
-
if (!(currentCard === null || currentCard === void 0 ? void 0 : currentCard.props.anchorRef)) {
|
|
78
|
-
setPosition({
|
|
79
|
-
top: "50%",
|
|
80
|
-
left: "50%",
|
|
81
|
-
width: "0px",
|
|
82
|
-
height: "0px",
|
|
83
|
-
});
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
var element = currentCard.props.anchorRef.current;
|
|
87
|
-
if (!element) {
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
var rect = element.getBoundingClientRect();
|
|
91
|
-
setPosition({
|
|
92
|
-
top: "".concat(rect.top, "px"),
|
|
93
|
-
left: "".concat(rect.left, "px"),
|
|
94
|
-
width: "".concat(rect.width, "px"),
|
|
95
|
-
height: "".concat(rect.height, "px"),
|
|
96
|
-
});
|
|
97
|
-
};
|
|
98
|
-
// Initial update
|
|
99
|
-
updatePosition();
|
|
100
|
-
// Set up resize observer
|
|
101
|
-
var resizeObserver = new ResizeObserver(updatePosition);
|
|
102
|
-
var currentCard = cards[currentIndex];
|
|
103
|
-
if ((_a = currentCard === null || currentCard === void 0 ? void 0 : currentCard.props.anchorRef) === null || _a === void 0 ? void 0 : _a.current) {
|
|
104
|
-
resizeObserver.observe(currentCard.props.anchorRef.current);
|
|
105
|
-
}
|
|
106
|
-
// Set up scroll listener
|
|
107
|
-
window.addEventListener("scroll", updatePosition, true);
|
|
108
|
-
return function () {
|
|
109
|
-
resizeObserver.disconnect();
|
|
110
|
-
window.removeEventListener("scroll", updatePosition, true);
|
|
111
|
-
};
|
|
112
|
-
}, [currentIndex, cards, isActive]);
|
|
113
|
-
var handleNext = function () {
|
|
114
|
-
if (currentIndex + 1 < cards.length) {
|
|
115
|
-
setCurrentIndex(currentIndex + 1);
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
setIsActive(false);
|
|
119
|
-
onEnd === null || onEnd === void 0 ? void 0 : onEnd();
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
var handleDismiss = function () {
|
|
123
|
-
setIsActive(false);
|
|
124
|
-
onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
|
|
125
|
-
};
|
|
126
|
-
if (!isActive || cards.length === 0) {
|
|
127
|
-
return null;
|
|
128
|
-
}
|
|
129
|
-
var currentCard = cards[currentIndex];
|
|
130
|
-
return (React.createElement(PopoverPrimitive.Root, { open: isActive, modal: false },
|
|
131
|
-
React.createElement(PopoverPrimitive.Anchor, { className: "s-fixed s-transition-all s-duration-300 s-ease-in-out", style: {
|
|
132
|
-
top: position.top,
|
|
133
|
-
left: position.left,
|
|
134
|
-
width: position.width,
|
|
135
|
-
height: position.height,
|
|
136
|
-
} }),
|
|
137
|
-
React.cloneElement(currentCard, {
|
|
138
|
-
onNext: handleNext,
|
|
139
|
-
onDismiss: handleDismiss,
|
|
140
|
-
currentIndex: currentIndex,
|
|
141
|
-
totalCards: cards.length,
|
|
142
|
-
className: !currentCard.props.anchorRef ? "s-translate-y-[-50%]" : "",
|
|
143
|
-
})));
|
|
144
|
-
}
|
|
145
|
-
//# sourceMappingURL=TourGuide.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TourGuide.js","sourceRoot":"","sources":["../../../src/components/TourGuide.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,gBAAgB,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAoBlC,MAAM,CAAC,IAAM,kBAAkB,GAAG,KAAK,CAAC,UAAU,CAGhD,UAAC,EAAiC,EAAE,GAAG;IAApC,IAAA,SAAS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AAC,YAAY,CAAC,CAAC;IAExC,OAAO,CACL,oBAAC,gBAAgB,CAAC,IAAI,IAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK;QACjD,oBAAC,gBAAgB,CAAC,MAAM,IACtB,SAAS,EAAC,uDAAuD,EACjE,KAAK,EAAE;gBACL,GAAG,EAAE,QAAQ,CAAC,GAAG;gBACjB,IAAI,EAAE,QAAQ,CAAC,IAAI;gBACnB,KAAK,EAAE,QAAQ,CAAC,KAAK;gBACrB,MAAM,EAAE,QAAQ,CAAC,MAAM;aACxB,GACD;QACD,KAAK,CAAC,YAAY,CAAC,WAAW,EAAE;YAC/B,MAAM,EAAE,UAAU;YAClB,SAAS,EAAE,aAAa;YACxB,YAAY,cAAA;YACZ,UAAU,EAAE,KAAK,CAAC,MAAM;YACxB,SAAS,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,EAAE;SACtE,CAAC,CACoB,CACzB,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
declare const _default: import("@storybook/core/csf").ComponentAnnotations<import("@storybook/react").ReactRenderer, import("@storybook/react").Args>;
|
|
2
|
-
export default _default;
|
|
3
|
-
export declare const Default: import("@storybook/core/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, import("@storybook/react").Args>;
|
|
4
|
-
//# sourceMappingURL=TourGuide.stories.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TourGuide.stories.d.ts","sourceRoot":"","sources":["../../../src/stories/TourGuide.stories.tsx"],"names":[],"mappings":";AA0CA,wBAMU;AAuaV,eAAO,MAAM,OAAO,2HAAoB,CAAC"}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { __read } from "tslib";
|
|
2
|
-
import React, { useRef, useState } from "react";
|
|
3
|
-
import { Avatar, ConfettiBackground, Tooltip, TypingAnimation, } from "../components";
|
|
4
|
-
import { Button } from "../components/Button";
|
|
5
|
-
import { ActionBrainIcon, ActionGlobeIcon, ActionImageIcon, ActionMagnifyingGlassIcon, ActionScanIcon, ActionTableIcon, PlayIcon, } from "../icons";
|
|
6
|
-
import { BigQueryLogo, ConfluenceLogo, DriveLogo, GithubLogo, GongLogo, IntercomLogo, MicrosoftLogo, NotionLogo, SalesforceLogo, SlackLogo, SnowflakeLogo, ZendeskLogo, } from "../logo";
|
|
7
|
-
import { TourGuide, TourGuideCard, TourGuideCardContent, TourGuideCardTitle, TourGuideCardVisual, } from "../components/TourGuide";
|
|
8
|
-
export default {
|
|
9
|
-
title: "Modules/TourGuide",
|
|
10
|
-
component: TourGuide,
|
|
11
|
-
parameters: {
|
|
12
|
-
layout: "fullscreen",
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
var Template = function () {
|
|
16
|
-
var topRightRef = useRef(null);
|
|
17
|
-
var centerRef = useRef(null);
|
|
18
|
-
var bottomLeftRef = useRef(null);
|
|
19
|
-
var _a = __read(useState(0), 2), key = _a[0], setKey = _a[1];
|
|
20
|
-
var handleRestart = function () {
|
|
21
|
-
setKey(function (k) { return k + 1; });
|
|
22
|
-
};
|
|
23
|
-
var referentRef = useRef(null);
|
|
24
|
-
var filteredAgents = [
|
|
25
|
-
{
|
|
26
|
-
name: "Translator",
|
|
27
|
-
emoji: "💬",
|
|
28
|
-
backgroundColor: "s-bg-green-200",
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
name: "TrailblazerGuard",
|
|
32
|
-
emoji: "👮",
|
|
33
|
-
backgroundColor: "s-bg-blue-100",
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
name: "Transport",
|
|
37
|
-
emoji: "🚌",
|
|
38
|
-
backgroundColor: "s-bg-blue-200",
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
name: "TrendTracker",
|
|
42
|
-
emoji: "😻",
|
|
43
|
-
backgroundColor: "s-bg-rose-50",
|
|
44
|
-
},
|
|
45
|
-
];
|
|
46
|
-
return (React.createElement("div", { className: "s-relative s-min-h-screen s-w-full" },
|
|
47
|
-
React.createElement("div", { className: "s-absolute s-left-3 s-top-3" },
|
|
48
|
-
React.createElement(Button, { label: "Restart Tour", onClick: handleRestart })),
|
|
49
|
-
React.createElement("div", { ref: topRightRef, className: "s-absolute s-right-6 s-top-6 s-cursor-pointer s-rounded-lg s-border s-border-blue-100 s-bg-blue-50 s-p-4 s-transition-colors hover:s-bg-blue-100" }, "Top Right Element"),
|
|
50
|
-
React.createElement("div", { ref: centerRef, className: "s-absolute s-left-1/2 s-top-1/2 s--translate-x-1/2 s--translate-y-1/2 s-cursor-pointer s-rounded-lg s-border s-border-green-100 s-bg-green-50 s-p-4 s-transition-colors hover:s-bg-green-100" }, "Centered Element"),
|
|
51
|
-
React.createElement("div", { ref: bottomLeftRef, className: "s-absolute s-bottom-6 s-left-6 s-cursor-pointer s-rounded-lg s-border s-border-red-100 s-bg-red-50 s-p-4 s-transition-colors hover:s-bg-red-100" }, "Bottom Left Element"),
|
|
52
|
-
React.createElement(TourGuide, { key: key, autoStart: true },
|
|
53
|
-
React.createElement(TourGuideCard, null,
|
|
54
|
-
React.createElement(TourGuideCardVisual, { ref: referentRef, className: "s-flex s-items-center s-justify-center s-bg-brand-support-blue s-px-6 s-text-center" },
|
|
55
|
-
React.createElement(ConfettiBackground, { variant: "confetti", referentSize: referentRef }),
|
|
56
|
-
React.createElement("span", { className: "s-heading-3xl" },
|
|
57
|
-
React.createElement(TypingAnimation, { text: "Rise and shine, Edouard! \uD83C\uDF05" }))),
|
|
58
|
-
React.createElement(TourGuideCardTitle, null,
|
|
59
|
-
"Welcome to the",
|
|
60
|
-
" ",
|
|
61
|
-
React.createElement("span", { className: "s-font-semibold s-text-brand-hunter-green" }, "Qonto"),
|
|
62
|
-
" ",
|
|
63
|
-
"workspace."),
|
|
64
|
-
React.createElement(TourGuideCardContent, null,
|
|
65
|
-
" ",
|
|
66
|
-
"Discover the basics of Dust in 3 steps.")),
|
|
67
|
-
React.createElement(TourGuideCard, { anchorRef: centerRef },
|
|
68
|
-
React.createElement(TourGuideCardVisual, { className: "s-relative s-flex s-overflow-hidden s-bg-brand-support-green s-p-4 s-text-center" },
|
|
69
|
-
React.createElement("div", { className: "s-flex s-gap-1" },
|
|
70
|
-
React.createElement("div", { className: "s-flex s-gap-1" },
|
|
71
|
-
React.createElement("div", { className: "s-heading-2xl s-text-highlight" }, "@tra"),
|
|
72
|
-
React.createElement("div", { className: "s-h-[32px] s-w-[3px] s-animate-cursor-blink s-bg-foreground" })),
|
|
73
|
-
React.createElement("div", { className: "s-flex s-h-[240px] s-flex-col s-gap-3 s-rounded-xl s-border s-border-border s-bg-background s-p-3 s-pr-5 s-shadow-xl" }, filteredAgents.map(function (agent) {
|
|
74
|
-
return (React.createElement("div", { key: agent.name, className: "s-heading-base s-flex s-items-center s-gap-2 s-text-foreground" },
|
|
75
|
-
React.createElement(Avatar, { size: "sm", emoji: agent.emoji, backgroundColor: agent.backgroundColor }),
|
|
76
|
-
agent.name));
|
|
77
|
-
})))),
|
|
78
|
-
React.createElement(TourGuideCardTitle, null,
|
|
79
|
-
"Use",
|
|
80
|
-
" ",
|
|
81
|
-
React.createElement("span", { className: "s-font-semibold s-text-highlight" }, "@mentions"),
|
|
82
|
-
" ",
|
|
83
|
-
"to call Agents and\u00A0start a conversation."),
|
|
84
|
-
React.createElement(TourGuideCardContent, { className: "s-py-2" },
|
|
85
|
-
React.createElement(Button, { label: "Watch the full video", icon: PlayIcon, variant: "outline" }))),
|
|
86
|
-
React.createElement(TourGuideCard, { anchorRef: topRightRef },
|
|
87
|
-
React.createElement(TourGuideCardVisual, { className: "s-flex s-flex-col s-items-center s-justify-center s-gap-4 s-bg-brand-support-rose s-px-6 s-text-center" },
|
|
88
|
-
React.createElement("div", { className: "s-grid s-grid-cols-6 s-gap-2" },
|
|
89
|
-
React.createElement(Tooltip, { label: "Google Drive Connection", trigger: React.createElement(Avatar, { size: "md", icon: DriveLogo, backgroundColor: "s-bg-white" }) }),
|
|
90
|
-
React.createElement(Tooltip, { label: "Notion Connection", trigger: React.createElement(Avatar, { size: "md", icon: NotionLogo, backgroundColor: "s-bg-white" }) }),
|
|
91
|
-
React.createElement(Tooltip, { label: "Slack Connection", trigger: React.createElement(Avatar, { size: "md", icon: SlackLogo, backgroundColor: "s-bg-white" }) }),
|
|
92
|
-
React.createElement(Tooltip, { label: "Snowflake Connection", trigger: React.createElement(Avatar, { size: "md", icon: SnowflakeLogo, backgroundColor: "s-bg-white" }) }),
|
|
93
|
-
React.createElement(Tooltip, { label: "BigQuery Connection", trigger: React.createElement(Avatar, { size: "md", icon: BigQueryLogo, backgroundColor: "s-bg-white" }) }),
|
|
94
|
-
React.createElement(Tooltip, { label: "Confluence Connection", trigger: React.createElement(Avatar, { size: "md", icon: ConfluenceLogo, backgroundColor: "s-bg-white" }) }),
|
|
95
|
-
React.createElement(Tooltip, { label: "Intercom Connection", trigger: React.createElement(Avatar, { size: "md", icon: IntercomLogo, backgroundColor: "s-bg-white" }) }),
|
|
96
|
-
React.createElement(Tooltip, { label: "Microsoft Connection", trigger: React.createElement(Avatar, { size: "md", icon: MicrosoftLogo, backgroundColor: "s-bg-white" }) }),
|
|
97
|
-
React.createElement(Tooltip, { label: "Salesforce Connection", trigger: React.createElement(Avatar, { size: "md", icon: SalesforceLogo, backgroundColor: "s-bg-white" }) }),
|
|
98
|
-
React.createElement(Tooltip, { label: "Zendesk Connection", trigger: React.createElement(Avatar, { size: "md", icon: ZendeskLogo, backgroundColor: "s-bg-white" }) }),
|
|
99
|
-
React.createElement(Tooltip, { label: "GitHub Connection", trigger: React.createElement(Avatar, { size: "md", icon: GithubLogo, backgroundColor: "s-bg-white" }) }),
|
|
100
|
-
React.createElement(Tooltip, { label: "Gong Connection", trigger: React.createElement(Avatar, { size: "md", icon: GongLogo, backgroundColor: "s-bg-white" }) }),
|
|
101
|
-
React.createElement(Tooltip, { label: "Search data", trigger: React.createElement(Avatar, { size: "md", icon: ActionMagnifyingGlassIcon, backgroundColor: "s-bg-gray-700", iconColor: "s-text-gray-50" }) }),
|
|
102
|
-
React.createElement(Tooltip, { label: "Quantitative analysis", trigger: React.createElement(Avatar, { size: "md", icon: ActionTableIcon, backgroundColor: "s-bg-gray-700", iconColor: "s-text-gray-50" }) }),
|
|
103
|
-
React.createElement(Tooltip, { label: "Data extraction", trigger: React.createElement(Avatar, { size: "md", icon: ActionScanIcon, backgroundColor: "s-bg-gray-700", iconColor: "s-text-gray-50" }) }),
|
|
104
|
-
React.createElement(Tooltip, { label: "Image generation", trigger: React.createElement(Avatar, { size: "md", icon: ActionImageIcon, backgroundColor: "s-bg-gray-700", iconColor: "s-text-gray-50" }) }),
|
|
105
|
-
React.createElement(Tooltip, { label: "Web search and browsing", trigger: React.createElement(Avatar, { size: "md", icon: ActionGlobeIcon, backgroundColor: "s-bg-gray-700", iconColor: "s-text-gray-50" }) }),
|
|
106
|
-
React.createElement(Tooltip, { label: "Reasoning", trigger: React.createElement(Avatar, { size: "md", icon: ActionBrainIcon, backgroundColor: "s-bg-gray-700", iconColor: "s-text-gray-50" }) }))),
|
|
107
|
-
React.createElement(TourGuideCardTitle, null,
|
|
108
|
-
"Make your agents smarter with\u00A0",
|
|
109
|
-
React.createElement("span", { className: "s-text-brand-red-rose" }, "knowledge and tools"),
|
|
110
|
-
"."),
|
|
111
|
-
React.createElement(TourGuideCardContent, { className: "s-py-2" },
|
|
112
|
-
React.createElement(Button, { label: "Watch the full video", icon: PlayIcon, variant: "outline" }))),
|
|
113
|
-
React.createElement(TourGuideCard, { anchorRef: bottomLeftRef },
|
|
114
|
-
React.createElement(TourGuideCardVisual, { className: "s-flex s-flex-col s-items-center s-justify-center s-gap-0 s-bg-brand-support-golden s-px-6 s-text-center" },
|
|
115
|
-
React.createElement("div", { className: "s-grid s-grid-cols-4 s-gap-2" },
|
|
116
|
-
React.createElement(Tooltip, { label: "FeedbackHelper", trigger: React.createElement(Avatar, { size: "lg", emoji: "\u2764\uFE0F", backgroundColor: "s-bg-rose-100" }) }),
|
|
117
|
-
React.createElement(Tooltip, { label: "RiskAnalyzer", trigger: React.createElement(Avatar, { size: "lg", emoji: "\uD83D\uDC80", backgroundColor: "s-bg-lime-800" }) }),
|
|
118
|
-
React.createElement(Tooltip, { label: "EngagementPro", trigger: React.createElement(Avatar, { size: "lg", emoji: "\uD83D\uDE02", backgroundColor: "s-bg-golden-200" }) }),
|
|
119
|
-
React.createElement(Tooltip, { label: "RunbookMaster", trigger: React.createElement(Avatar, { size: "lg", emoji: "\uD83E\uDDD1\u200D\uD83D\uDE80", backgroundColor: "s-bg-violet-800" }) }),
|
|
120
|
-
React.createElement(Tooltip, { label: "BrandSpecialist", trigger: React.createElement(Avatar, { size: "lg", emoji: "\uD83D\uDC55", backgroundColor: "s-bg-blue-200" }) }),
|
|
121
|
-
React.createElement(Tooltip, { label: "CrisisManager", trigger: React.createElement(Avatar, { size: "lg", emoji: "\uD83D\uDE92", backgroundColor: "s-bg-red-200" }) }),
|
|
122
|
-
React.createElement(Tooltip, { label: "PerformanceCoach", trigger: React.createElement(Avatar, { size: "lg", emoji: "\uD83C\uDFC6", backgroundColor: "s-bg-yellow-200" }) }),
|
|
123
|
-
React.createElement(Tooltip, { label: "StrategyPlanner", trigger: React.createElement(Avatar, { size: "lg", emoji: "\uD83C\uDFAF", backgroundColor: "s-bg-pink-100" }) }))),
|
|
124
|
-
React.createElement(TourGuideCardTitle, null,
|
|
125
|
-
"Create new custom agents",
|
|
126
|
-
" ",
|
|
127
|
-
React.createElement("span", { className: "s-text-brand-orange-golden" }, "designed for your needs"),
|
|
128
|
-
"."),
|
|
129
|
-
React.createElement(TourGuideCardContent, { className: "s-py-2" },
|
|
130
|
-
React.createElement(Button, { label: "Watch the full video", icon: PlayIcon, variant: "outline" }))))));
|
|
131
|
-
};
|
|
132
|
-
export var Default = Template.bind({});
|
|
133
|
-
//# sourceMappingURL=TourGuide.stories.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TourGuide.stories.js","sourceRoot":"","sources":["../../../src/stories/TourGuide.stories.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEhD,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,OAAO,EACP,eAAe,GAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EACL,eAAe,EACf,eAAe,EACf,eAAe,EACf,yBAAyB,EACzB,cAAc,EACd,eAAe,EACf,QAAQ,GACT,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,YAAY,EACZ,cAAc,EACd,SAAS,EACT,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,UAAU,EACV,cAAc,EACd,SAAS,EACT,aAAa,EACb,WAAW,GACZ,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,SAAS,EACT,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AAEjC,eAAe;IACb,KAAK,EAAE,mBAAmB;IAC1B,SAAS,EAAE,SAAS;IACpB,UAAU,EAAE;QACV,MAAM,EAAE,YAAY;KACrB;CACM,CAAC;AAEV,IAAM,QAAQ,GAAY;IACxB,IAAM,WAAW,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IACjD,IAAM,SAAS,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAC/C,IAAM,aAAa,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAC7C,IAAA,KAAA,OAAgB,QAAQ,CAAC,CAAC,CAAC,IAAA,EAA1B,GAAG,QAAA,EAAE,MAAM,QAAe,CAAC;IAElC,IAAM,aAAa,GAAG;QACpB,MAAM,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,GAAG,CAAC,EAAL,CAAK,CAAC,CAAC;IACvB,C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} from "react";
|
|
3
|
-
|
|
4
|
-
import { Button } from "@sparkle/components/Button";
|
|
5
|
-
import { cn } from "@sparkle/lib";
|
|
6
|
-
|
|
7
|
-
interface TourGuideCardProps {
|
|
8
|
-
anchorRef?: React.RefObject<HTMLDivElement>;
|
|
9
|
-
title?: string;
|
|
10
|
-
content?: React.ReactNode;
|
|
11
|
-
visual?: React.ReactNode;
|
|
12
|
-
onNext?: () => void;
|
|
13
|
-
onDismiss?: () => void;
|
|
14
|
-
isLastStep?: boolean;
|
|
15
|
-
className?: string;
|
|
16
|
-
children?: React.ReactNode;
|
|
17
|
-
asPopover?: boolean;
|
|
18
|
-
align?: "start" | "center" | "end";
|
|
19
|
-
side?: "top" | "right" | "bottom" | "left";
|
|
20
|
-
sideOffset?: number;
|
|
21
|
-
currentIndex?: number;
|
|
22
|
-
totalCards?: number;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const TourGuideCardTitle = React.forwardRef<
|
|
26
|
-
HTMLDivElement,
|
|
27
|
-
React.HTMLAttributes<HTMLDivElement>
|
|
28
|
-
>(({ className, children, ...props }, ref) => (
|
|
29
|
-
<div
|
|
30
|
-
ref={ref}
|
|
31
|
-
className={cn("s-heading-lg s-px-3 s-pt-4", className)}
|
|
32
|
-
{...props}
|
|
33
|
-
>
|
|
34
|
-
{children}
|
|
35
|
-
</div>
|
|
36
|
-
));
|
|
37
|
-
TourGuideCardTitle.displayName = "TourGuideCardTitle";
|
|
38
|
-
|
|
39
|
-
export const TourGuideCardContent = React.forwardRef<
|
|
40
|
-
HTMLDivElement,
|
|
41
|
-
React.HTMLAttributes<HTMLDivElement>
|
|
42
|
-
>(({ className, children, ...props }, ref) => (
|
|
43
|
-
<div
|
|
44
|
-
ref={ref}
|
|
45
|
-
className={cn(
|
|
46
|
-
"s-copy-base s-px-3 s-text-muted-foreground dark:s-text-muted-foreground-night",
|
|
47
|
-
className
|
|
48
|
-
)}
|
|
49
|
-
{...props}
|
|
50
|
-
>
|
|
51
|
-
{children}
|
|
52
|
-
</div>
|
|
53
|
-
));
|
|
54
|
-
TourGuideCardContent.displayName = "TourGuideCardContent";
|
|
55
|
-
|
|
56
|
-
export const TourGuideCardVisual = React.forwardRef<
|
|
57
|
-
HTMLDivElement,
|
|
58
|
-
React.HTMLAttributes<HTMLDivElement>
|
|
59
|
-
>(({ className, children, ...props }, ref) => (
|
|
60
|
-
<div
|
|
61
|
-
ref={ref}
|
|
62
|
-
className={cn(
|
|
63
|
-
"s-aspect-video s-bg-muted-background dark:s-bg-muted-background-night",
|
|
64
|
-
className
|
|
65
|
-
)}
|
|
66
|
-
{...props}
|
|
67
|
-
>
|
|
68
|
-
{children}
|
|
69
|
-
</div>
|
|
70
|
-
));
|
|
71
|
-
TourGuideCardVisual.displayName = "TourGuideCardVisual";
|
|
72
|
-
|
|
73
|
-
interface TourGuideCardActionsProps
|
|
74
|
-
extends React.HTMLAttributes<HTMLDivElement> {
|
|
75
|
-
currentIndex: number;
|
|
76
|
-
totalCards: number;
|
|
77
|
-
onNext?: () => void;
|
|
78
|
-
onDismiss?: () => void;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export const TourGuideCardActions = React.forwardRef<
|
|
82
|
-
HTMLDivElement,
|
|
83
|
-
TourGuideCardActionsProps
|
|
84
|
-
>(
|
|
85
|
-
(
|
|
86
|
-
{
|
|
87
|
-
currentIndex,
|
|
88
|
-
totalCards,
|
|
89
|
-
onNext,
|
|
90
|
-
onDismiss,
|
|
91
|
-
className,
|
|
92
|
-
children,
|
|
93
|
-
...props
|
|
94
|
-
},
|
|
95
|
-
ref
|
|
96
|
-
) => {
|
|
97
|
-
const isFirstCard = currentIndex === 0;
|
|
98
|
-
const isLastCard = currentIndex === totalCards - 1;
|
|
99
|
-
const isSingleCard = totalCards === 1;
|
|
100
|
-
const showDismiss = !isLastCard && !isSingleCard;
|
|
101
|
-
|
|
102
|
-
return (
|
|
103
|
-
<div
|
|
104
|
-
ref={ref}
|
|
105
|
-
className={cn(
|
|
106
|
-
"s-flex s-justify-end s-space-x-2 s-p-2 s-pt-4",
|
|
107
|
-
className
|
|
108
|
-
)}
|
|
109
|
-
{...props}
|
|
110
|
-
>
|
|
111
|
-
{children ? (
|
|
112
|
-
children
|
|
113
|
-
) : (
|
|
114
|
-
<>
|
|
115
|
-
{showDismiss && onDismiss && (
|
|
116
|
-
<Button variant="outline" label="Dismiss" onClick={onDismiss} />
|
|
117
|
-
)}
|
|
118
|
-
{onNext && (
|
|
119
|
-
<Button
|
|
120
|
-
onClick={onNext}
|
|
121
|
-
variant="highlight"
|
|
122
|
-
label={
|
|
123
|
-
isSingleCard
|
|
124
|
-
? "Ok"
|
|
125
|
-
: isFirstCard
|
|
126
|
-
? "Start Tour"
|
|
127
|
-
: isLastCard
|
|
128
|
-
? "Done"
|
|
129
|
-
: "Next"
|
|
130
|
-
}
|
|
131
|
-
/>
|
|
132
|
-
)}
|
|
133
|
-
</>
|
|
134
|
-
)}
|
|
135
|
-
</div>
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
);
|
|
139
|
-
TourGuideCardActions.displayName = "TourGuideCardActions";
|
|
140
|
-
|
|
141
|
-
export const TourGuideCard = React.forwardRef<
|
|
142
|
-
HTMLDivElement,
|
|
143
|
-
TourGuideCardProps
|
|
144
|
-
>(
|
|
145
|
-
({
|
|
146
|
-
className,
|
|
147
|
-
children,
|
|
148
|
-
align = "center",
|
|
149
|
-
side = "bottom",
|
|
150
|
-
sideOffset = 4,
|
|
151
|
-
onNext,
|
|
152
|
-
onDismiss,
|
|
153
|
-
currentIndex = 0,
|
|
154
|
-
totalCards = 1,
|
|
155
|
-
}) => {
|
|
156
|
-
return (
|
|
157
|
-
<PopoverPrimitive.Content
|
|
158
|
-
align={align}
|
|
159
|
-
side={side}
|
|
160
|
-
sideOffset={sideOffset}
|
|
161
|
-
className={cn(
|
|
162
|
-
"s-z-50 s-w-[420px] s-max-w-xs s-space-y-0.5 s-overflow-hidden s-rounded-2xl s-border s-shadow-xl s-transition-all s-duration-300 s-ease-in-out",
|
|
163
|
-
"s-border-highlight-400 s-bg-background s-text-foreground s-ring-2 s-ring-highlight-400/30",
|
|
164
|
-
"dark:s-border-border-night dark:s-bg-background-night dark:s-text-foreground-night",
|
|
165
|
-
className
|
|
166
|
-
)}
|
|
167
|
-
onOpenAutoFocus={(e) => e.preventDefault()}
|
|
168
|
-
>
|
|
169
|
-
{children}
|
|
170
|
-
<TourGuideCardActions
|
|
171
|
-
currentIndex={currentIndex}
|
|
172
|
-
totalCards={totalCards}
|
|
173
|
-
onNext={onNext}
|
|
174
|
-
onDismiss={onDismiss}
|
|
175
|
-
/>
|
|
176
|
-
</PopoverPrimitive.Content>
|
|
177
|
-
);
|
|
178
|
-
}
|
|
179
|
-
);
|
|
180
|
-
TourGuideCard.displayName = "TourGuideCard";
|
|
181
|
-
|
|
182
|
-
export interface TourGuideProps {
|
|
183
|
-
children: React.ReactNode;
|
|
184
|
-
autoStart?: boolean;
|
|
185
|
-
onStart?: () => void;
|
|
186
|
-
onEnd?: () => void;
|
|
187
|
-
onDismiss?: () => void;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export function TourGuide({
|
|
191
|
-
children,
|
|
192
|
-
autoStart = true,
|
|
193
|
-
onStart,
|
|
194
|
-
onEnd,
|
|
195
|
-
onDismiss,
|
|
196
|
-
}: TourGuideProps) {
|
|
197
|
-
const [currentIndex, setCurrentIndex] = useState(0);
|
|
198
|
-
const [isActive, setIsActive] = useState(autoStart);
|
|
199
|
-
const [position, setPosition] = useState({
|
|
200
|
-
top: "50%",
|
|
201
|
-
left: "50%",
|
|
202
|
-
width: "0px",
|
|
203
|
-
height: "0px",
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
// Get all TourGuideCard children - memoize to prevent unnecessary re-renders
|
|
207
|
-
const cards = React.useMemo(
|
|
208
|
-
() =>
|
|
209
|
-
React.Children.toArray(children).filter(
|
|
210
|
-
(child): child is React.ReactElement<TourGuideCardProps> =>
|
|
211
|
-
React.isValidElement(child) && child.type === TourGuideCard
|
|
212
|
-
),
|
|
213
|
-
[children]
|
|
214
|
-
);
|
|
215
|
-
|
|
216
|
-
// Only run on mount and when autoStart changes
|
|
217
|
-
useEffect(() => {
|
|
218
|
-
if (autoStart) {
|
|
219
|
-
setIsActive(true);
|
|
220
|
-
setCurrentIndex(0);
|
|
221
|
-
onStart?.();
|
|
222
|
-
}
|
|
223
|
-
}, [autoStart, onStart]);
|
|
224
|
-
|
|
225
|
-
// Handle position updates - use requestAnimationFrame to prevent excessive updates
|
|
226
|
-
useEffect(() => {
|
|
227
|
-
if (!isActive) {
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
const updatePosition = () => {
|
|
232
|
-
const currentCard = cards[currentIndex];
|
|
233
|
-
if (!currentCard?.props.anchorRef) {
|
|
234
|
-
setPosition({
|
|
235
|
-
top: "50%",
|
|
236
|
-
left: "50%",
|
|
237
|
-
width: "0px",
|
|
238
|
-
height: "0px",
|
|
239
|
-
});
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
const element = currentCard.props.anchorRef.current;
|
|
244
|
-
if (!element) {
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
const rect = element.getBoundingClientRect();
|
|
249
|
-
setPosition({
|
|
250
|
-
top: `${rect.top}px`,
|
|
251
|
-
left: `${rect.left}px`,
|
|
252
|
-
width: `${rect.width}px`,
|
|
253
|
-
height: `${rect.height}px`,
|
|
254
|
-
});
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
// Initial update
|
|
258
|
-
updatePosition();
|
|
259
|
-
|
|
260
|
-
// Set up resize observer
|
|
261
|
-
const resizeObserver = new ResizeObserver(updatePosition);
|
|
262
|
-
const currentCard = cards[currentIndex];
|
|
263
|
-
if (currentCard?.props.anchorRef?.current) {
|
|
264
|
-
resizeObserver.observe(currentCard.props.anchorRef.current);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
// Set up scroll listener
|
|
268
|
-
window.addEventListener("scroll", updatePosition, true);
|
|
269
|
-
|
|
270
|
-
return () => {
|
|
271
|
-
resizeObserver.disconnect();
|
|
272
|
-
window.removeEventListener("scroll", updatePosition, true);
|
|
273
|
-
};
|
|
274
|
-
}, [currentIndex, cards, isActive]);
|
|
275
|
-
|
|
276
|
-
const handleNext = () => {
|
|
277
|
-
if (currentIndex + 1 < cards.length) {
|
|
278
|
-
setCurrentIndex(currentIndex + 1);
|
|
279
|
-
} else {
|
|
280
|
-
setIsActive(false);
|
|
281
|
-
onEnd?.();
|
|
282
|
-
}
|
|
283
|
-
};
|
|
284
|
-
|
|
285
|
-
const handleDismiss = () => {
|
|
286
|
-
setIsActive(false);
|
|
287
|
-
onDismiss?.();
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
if (!isActive || cards.length === 0) {
|
|
291
|
-
return null;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
const currentCard = cards[currentIndex];
|
|
295
|
-
|
|
296
|
-
return (
|
|
297
|
-
<PopoverPrimitive.Root open={isActive} modal={false}>
|
|
298
|
-
<PopoverPrimitive.Anchor
|
|
299
|
-
className="s-fixed s-transition-all s-duration-300 s-ease-in-out"
|
|
300
|
-
style={{
|
|
301
|
-
top: position.top,
|
|
302
|
-
left: position.left,
|
|
303
|
-
width: position.width,
|
|
304
|
-
height: position.height,
|
|
305
|
-
}}
|
|
306
|
-
/>
|
|
307
|
-
{React.cloneElement(currentCard, {
|
|
308
|
-
onNext: handleNext,
|
|
309
|
-
onDismiss: handleDismiss,
|
|
310
|
-
currentIndex,
|
|
311
|
-
totalCards: cards.length,
|
|
312
|
-
className: !currentCard.props.anchorRef ? "s-translate-y-[-50%]" : "",
|
|
313
|
-
})}
|
|
314
|
-
</PopoverPrimitive.Root>
|
|
315
|
-
);
|
|
316
|
-
}
|