@agg-build/ui 2.4.9 → 2.5.2
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/chunk-AHQA3B7D.mjs +947 -0
- package/dist/{chunk-CXSIXL7M.mjs → chunk-AJJ73RM4.mjs} +698 -257
- package/dist/{chunk-TEBAR55W.mjs → chunk-EDQ64EKO.mjs} +339 -1084
- package/dist/{chunk-GWRFSQQK.mjs → chunk-FAU2VOL6.mjs} +1594 -700
- package/dist/{chunk-PTNFXXOV.mjs → chunk-FMYYPNZZ.mjs} +904 -788
- package/dist/{chunk-UH3DUTMG.mjs → chunk-JQKJDSTW.mjs} +1 -1
- package/dist/{chunk-I4X5UNCT.mjs → chunk-XAG432PJ.mjs} +12 -6
- package/dist/events.js +1077 -999
- package/dist/events.mjs +3 -3
- package/dist/index.js +16499 -14884
- package/dist/index.mjs +56 -18
- package/dist/modals.js +1292 -1084
- package/dist/modals.mjs +10 -10
- package/dist/pages.js +4954 -2639
- package/dist/pages.mjs +6 -6
- package/dist/primitives.js +905 -788
- package/dist/primitives.mjs +3 -1
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +1 -1
- package/dist/trading.js +3383 -1508
- package/dist/trading.mjs +6 -4
- package/dist/types/auth/connect-button-view/connect-button-view.types.d.mts +2 -0
- package/dist/types/auth/connect-button-view/connect-button-view.types.d.ts +2 -0
- package/dist/types/auth/connect-button-view/index.d.mts +1 -1
- package/dist/types/auth/connect-button-view/index.d.ts +1 -1
- package/dist/types/onboarding/steps/connect-kalshi-modal.d.mts +1 -1
- package/dist/types/onboarding/steps/connect-kalshi-modal.d.ts +1 -1
- package/dist/types/pages/user-profile/components/available-balance-card.d.mts +2 -1
- package/dist/types/pages/user-profile/components/available-balance-card.d.ts +2 -1
- package/dist/types/pages/user-profile/components/open-order-row.d.mts +10 -1
- package/dist/types/pages/user-profile/components/open-order-row.d.ts +10 -1
- package/dist/types/pages/user-profile/components/positions-activity.d.mts +4 -1
- package/dist/types/pages/user-profile/components/positions-activity.d.ts +4 -1
- package/dist/types/pages/user-profile/components/positions-value-card.d.mts +4 -2
- package/dist/types/pages/user-profile/components/positions-value-card.d.ts +4 -2
- package/dist/types/pages/user-profile/index.d.mts +2 -2
- package/dist/types/pages/user-profile/index.d.ts +2 -2
- package/dist/types/pages/user-profile/user-profile.types.d.mts +12 -0
- package/dist/types/pages/user-profile/user-profile.types.d.ts +12 -0
- package/dist/types/primitives/calendar/index.d.mts +8 -0
- package/dist/types/primitives/calendar/index.d.ts +8 -0
- package/dist/types/primitives/icon/registry.d.mts +3 -0
- package/dist/types/primitives/icon/registry.d.ts +3 -0
- package/dist/types/primitives/icon/svg/calendar.d.mts +2 -0
- package/dist/types/primitives/icon/svg/calendar.d.ts +2 -0
- package/dist/types/primitives/icon/svg/minus.d.mts +2 -0
- package/dist/types/primitives/icon/svg/minus.d.ts +2 -0
- package/dist/types/primitives/icon/svg/plus.d.mts +2 -0
- package/dist/types/primitives/icon/svg/plus.d.ts +2 -0
- package/dist/types/primitives/index.d.mts +1 -0
- package/dist/types/primitives/index.d.ts +1 -0
- package/dist/types/profile/index.d.mts +1 -1
- package/dist/types/profile/index.d.ts +1 -1
- package/dist/types/profile/profile-modal.types.d.mts +6 -0
- package/dist/types/profile/profile-modal.types.d.ts +6 -0
- package/dist/types/profile/tabs/trading-access-tab.d.mts +3 -1
- package/dist/types/profile/tabs/trading-access-tab.d.ts +3 -1
- package/dist/types/trading/fund-kalshi-modal.d.mts +8 -0
- package/dist/types/trading/fund-kalshi-modal.d.ts +8 -0
- package/dist/types/trading/index.d.mts +1 -0
- package/dist/types/trading/index.d.ts +1 -0
- package/dist/types/trading/place-order/index.d.mts +1 -1
- package/dist/types/trading/place-order/index.d.ts +1 -1
- package/dist/types/trading/place-order/index.place-order.types.d.mts +13 -1
- package/dist/types/trading/place-order/index.place-order.types.d.ts +13 -1
- package/dist/types/trading/place-order/index.place-order.utils.d.mts +18 -1
- package/dist/types/trading/place-order/index.place-order.utils.d.ts +18 -1
- package/package.json +7 -4
- package/dist/chunk-JVRTJQPZ.mjs +0 -59
|
@@ -0,0 +1,947 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
AGG_TERMS_OF_SERVICE_URL,
|
|
4
|
+
BestPricesIcon,
|
|
5
|
+
Button,
|
|
6
|
+
CheckCircleIcon,
|
|
7
|
+
ChevronRightIcon,
|
|
8
|
+
CreateAccountIcon,
|
|
9
|
+
Icon,
|
|
10
|
+
LinkAccountsIcon,
|
|
11
|
+
Modal,
|
|
12
|
+
ProfileIcon,
|
|
13
|
+
RemoteImage,
|
|
14
|
+
StayInControlIcon,
|
|
15
|
+
VenueLogo,
|
|
16
|
+
WarningIcon,
|
|
17
|
+
__async,
|
|
18
|
+
__spreadProps,
|
|
19
|
+
__spreadValues,
|
|
20
|
+
cn
|
|
21
|
+
} from "./chunk-FMYYPNZZ.mjs";
|
|
22
|
+
|
|
23
|
+
// src/geo-block-banner/index.tsx
|
|
24
|
+
import { useLabels } from "@agg-build/hooks";
|
|
25
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
26
|
+
var GeoBlockBanner = ({
|
|
27
|
+
venue,
|
|
28
|
+
termsUrl = AGG_TERMS_OF_SERVICE_URL,
|
|
29
|
+
className
|
|
30
|
+
}) => {
|
|
31
|
+
const labels = useLabels();
|
|
32
|
+
const message = venue ? labels.trading.geoBlockVenueMessage(venue) : labels.trading.geoBlockGenericMessage;
|
|
33
|
+
return /* @__PURE__ */ jsxs(
|
|
34
|
+
"div",
|
|
35
|
+
{
|
|
36
|
+
className: cn("flex items-center gap-5 rounded-agg-lg bg-agg-secondary-hover p-3", className),
|
|
37
|
+
role: "status",
|
|
38
|
+
children: [
|
|
39
|
+
/* @__PURE__ */ jsxs("p", { className: "min-w-0 flex-1 text-agg-xs leading-agg-4 text-agg-foreground", children: [
|
|
40
|
+
message,
|
|
41
|
+
/* @__PURE__ */ jsx("a", { href: termsUrl, className: "underline", target: "_blank", rel: "noreferrer noopener", children: labels.trading.geoBlockTermsLink }),
|
|
42
|
+
labels.trading.geoBlockMessageSuffix
|
|
43
|
+
] }),
|
|
44
|
+
/* @__PURE__ */ jsx(Icon, { name: "internet-security", className: "h-6 w-6 shrink-0 text-agg-muted-foreground" })
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
GeoBlockBanner.displayName = "GeoBlockBanner";
|
|
50
|
+
|
|
51
|
+
// src/onboarding/steps/how-it-works.tsx
|
|
52
|
+
import { useCallback, useRef, useState } from "react";
|
|
53
|
+
import { useLabels as useLabels2 } from "@agg-build/hooks";
|
|
54
|
+
|
|
55
|
+
// src/onboarding/onboarding-modal.constants.ts
|
|
56
|
+
import { isVenueActive, Venue } from "@agg-build/sdk";
|
|
57
|
+
var HOW_IT_WORKS_FEATURE_KEYS = [
|
|
58
|
+
"createAccount",
|
|
59
|
+
"linkAccounts",
|
|
60
|
+
"bestPrices",
|
|
61
|
+
"stayInControl"
|
|
62
|
+
];
|
|
63
|
+
var ONBOARDING_STEPS = {
|
|
64
|
+
HOW_IT_WORKS: 0,
|
|
65
|
+
PROFILE_SETUP: 1,
|
|
66
|
+
CONNECT_ACCOUNTS: 2
|
|
67
|
+
};
|
|
68
|
+
var ONCHAIN_VENUES = [
|
|
69
|
+
Venue.polymarket,
|
|
70
|
+
Venue.opinion,
|
|
71
|
+
Venue.predict
|
|
72
|
+
].filter(isVenueActive);
|
|
73
|
+
|
|
74
|
+
// src/onboarding/steps/how-it-works.tsx
|
|
75
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
76
|
+
var defaultIcons = {
|
|
77
|
+
createAccount: /* @__PURE__ */ jsx2(CreateAccountIcon, { className: "h-[28px] w-[28px] text-agg-muted-foreground" }),
|
|
78
|
+
linkAccounts: /* @__PURE__ */ jsx2(LinkAccountsIcon, { className: "h-[28px] w-[28px] text-agg-muted-foreground" }),
|
|
79
|
+
bestPrices: /* @__PURE__ */ jsx2(BestPricesIcon, { className: "h-[28px] w-[28px] text-agg-muted-foreground" }),
|
|
80
|
+
stayInControl: /* @__PURE__ */ jsx2(StayInControlIcon, { className: "h-[28px] w-[28px] text-agg-muted-foreground" })
|
|
81
|
+
};
|
|
82
|
+
var HowItWorksStep = ({ onContinue, icons }) => {
|
|
83
|
+
const labels = useLabels2();
|
|
84
|
+
const scrollRef = useRef(null);
|
|
85
|
+
const [showTopGradient, setShowTopGradient] = useState(false);
|
|
86
|
+
const [showBottomGradient, setShowBottomGradient] = useState(true);
|
|
87
|
+
const handleScroll = useCallback(() => {
|
|
88
|
+
const el = scrollRef.current;
|
|
89
|
+
if (!el) return;
|
|
90
|
+
setShowTopGradient(el.scrollTop > 0);
|
|
91
|
+
setShowBottomGradient(el.scrollTop + el.clientHeight < el.scrollHeight - 1);
|
|
92
|
+
}, []);
|
|
93
|
+
return /* @__PURE__ */ jsxs2("div", { className: "flex flex-col gap-6 h-[600px] sm:h-auto", children: [
|
|
94
|
+
/* @__PURE__ */ jsx2("h2", { className: "text-center text-agg-2xl font-agg-bold text-agg-foreground", children: labels.onboarding.howItWorks.title }),
|
|
95
|
+
/* @__PURE__ */ jsxs2("div", { className: "relative flex-1 min-h-0 sm:flex-initial", children: [
|
|
96
|
+
/* @__PURE__ */ jsx2(
|
|
97
|
+
"div",
|
|
98
|
+
{
|
|
99
|
+
ref: scrollRef,
|
|
100
|
+
onScroll: handleScroll,
|
|
101
|
+
className: "flex flex-col gap-4 overflow-y-auto sm:overflow-visible h-full",
|
|
102
|
+
children: HOW_IT_WORKS_FEATURE_KEYS.map((featureKey) => {
|
|
103
|
+
var _a;
|
|
104
|
+
const icon = (_a = icons == null ? void 0 : icons[featureKey]) != null ? _a : defaultIcons[featureKey];
|
|
105
|
+
const feature = labels.onboarding.howItWorks.features[featureKey];
|
|
106
|
+
return /* @__PURE__ */ jsxs2(
|
|
107
|
+
"div",
|
|
108
|
+
{
|
|
109
|
+
className: cn(
|
|
110
|
+
"flex items-center gap-4 py-4 px-5 sm:px-4",
|
|
111
|
+
"rounded-agg-md",
|
|
112
|
+
"bg-agg-secondary-hover"
|
|
113
|
+
),
|
|
114
|
+
children: [
|
|
115
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex flex-col flex-1 min-w-0 gap-[6px]", children: [
|
|
116
|
+
/* @__PURE__ */ jsx2("p", { className: "text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: feature.title }),
|
|
117
|
+
/* @__PURE__ */ jsx2("p", { className: "text-agg-sm leading-agg-5 text-agg-foreground", children: feature.description })
|
|
118
|
+
] }),
|
|
119
|
+
icon ? /* @__PURE__ */ jsx2("div", { className: "hidden shrink-0 items-center justify-center text-agg-muted-foreground sm:flex", children: icon }) : null
|
|
120
|
+
]
|
|
121
|
+
},
|
|
122
|
+
featureKey
|
|
123
|
+
);
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
),
|
|
127
|
+
/* @__PURE__ */ jsx2(
|
|
128
|
+
"div",
|
|
129
|
+
{
|
|
130
|
+
className: cn(
|
|
131
|
+
"pointer-events-none absolute inset-x-0 top-0 h-20",
|
|
132
|
+
"bg-gradient-to-b from-agg-secondary to-transparent",
|
|
133
|
+
"sm:hidden transition-opacity",
|
|
134
|
+
showTopGradient ? "opacity-100" : "opacity-0"
|
|
135
|
+
)
|
|
136
|
+
}
|
|
137
|
+
),
|
|
138
|
+
/* @__PURE__ */ jsx2(
|
|
139
|
+
"div",
|
|
140
|
+
{
|
|
141
|
+
className: cn(
|
|
142
|
+
"pointer-events-none absolute inset-x-0 bottom-0 h-20",
|
|
143
|
+
"bg-gradient-to-t from-agg-secondary to-transparent",
|
|
144
|
+
"sm:hidden transition-opacity",
|
|
145
|
+
showBottomGradient ? "opacity-100" : "opacity-0"
|
|
146
|
+
)
|
|
147
|
+
}
|
|
148
|
+
)
|
|
149
|
+
] }),
|
|
150
|
+
/* @__PURE__ */ jsx2(Button, { variant: "primary", size: "large", className: "w-full", onClick: onContinue, children: labels.onboarding.howItWorks.continue })
|
|
151
|
+
] });
|
|
152
|
+
};
|
|
153
|
+
HowItWorksStep.displayName = "HowItWorksStep";
|
|
154
|
+
|
|
155
|
+
// src/onboarding/steps/profile-setup.tsx
|
|
156
|
+
import { useCallback as useCallback2, useRef as useRef2, useState as useState2 } from "react";
|
|
157
|
+
import { useLabels as useLabels3 } from "@agg-build/hooks";
|
|
158
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
159
|
+
var ProfileSetupStep = ({ onContinue }) => {
|
|
160
|
+
const labels = useLabels3();
|
|
161
|
+
const [username, setUsername] = useState2("");
|
|
162
|
+
const [avatarFile, setAvatarFile] = useState2();
|
|
163
|
+
const [avatarPreview, setAvatarPreview] = useState2();
|
|
164
|
+
const fileInputRef = useRef2(null);
|
|
165
|
+
const handleAvatarClick = useCallback2(() => {
|
|
166
|
+
var _a;
|
|
167
|
+
(_a = fileInputRef.current) == null ? void 0 : _a.click();
|
|
168
|
+
}, []);
|
|
169
|
+
const handleFileChange = useCallback2((e) => {
|
|
170
|
+
var _a;
|
|
171
|
+
const file = (_a = e.target.files) == null ? void 0 : _a[0];
|
|
172
|
+
if (!file) return;
|
|
173
|
+
setAvatarFile(file);
|
|
174
|
+
const reader = new FileReader();
|
|
175
|
+
reader.onload = (event) => {
|
|
176
|
+
var _a2;
|
|
177
|
+
setAvatarPreview((_a2 = event.target) == null ? void 0 : _a2.result);
|
|
178
|
+
};
|
|
179
|
+
reader.readAsDataURL(file);
|
|
180
|
+
}, []);
|
|
181
|
+
const handleContinue = useCallback2(() => {
|
|
182
|
+
onContinue({
|
|
183
|
+
username,
|
|
184
|
+
avatarFile,
|
|
185
|
+
avatarPreview
|
|
186
|
+
});
|
|
187
|
+
}, [username, avatarFile, avatarPreview, onContinue]);
|
|
188
|
+
return /* @__PURE__ */ jsxs3("div", { className: "flex flex-col gap-7", children: [
|
|
189
|
+
/* @__PURE__ */ jsx3("h2", { className: "text-center text-agg-2xl font-agg-bold text-agg-foreground", children: labels.onboarding.profileSetup.title }),
|
|
190
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex flex-col gap-5 items-center w-full", children: [
|
|
191
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex justify-center", children: [
|
|
192
|
+
/* @__PURE__ */ jsxs3(
|
|
193
|
+
"button",
|
|
194
|
+
{
|
|
195
|
+
type: "button",
|
|
196
|
+
onClick: handleAvatarClick,
|
|
197
|
+
className: cn(
|
|
198
|
+
"group relative flex items-center justify-center",
|
|
199
|
+
"h-[80px] w-[80px]",
|
|
200
|
+
"rounded-agg-full",
|
|
201
|
+
"bg-agg-secondary-hover",
|
|
202
|
+
!avatarPreview && "hover:bg-agg-tertiary",
|
|
203
|
+
"transition-colors cursor-pointer",
|
|
204
|
+
"overflow-hidden"
|
|
205
|
+
),
|
|
206
|
+
"aria-label": labels.onboarding.profileSetup.uploadProfilePictureAria,
|
|
207
|
+
children: [
|
|
208
|
+
!avatarPreview ? /* @__PURE__ */ jsx3(
|
|
209
|
+
"svg",
|
|
210
|
+
{
|
|
211
|
+
"aria-hidden": true,
|
|
212
|
+
viewBox: "0 0 80 80",
|
|
213
|
+
className: "pointer-events-none absolute inset-0 h-full w-full text-agg-separator group-hover:text-agg-muted-foreground",
|
|
214
|
+
children: /* @__PURE__ */ jsx3(
|
|
215
|
+
"circle",
|
|
216
|
+
{
|
|
217
|
+
cx: "40",
|
|
218
|
+
cy: "40",
|
|
219
|
+
r: "39.5",
|
|
220
|
+
fill: "none",
|
|
221
|
+
stroke: "currentColor",
|
|
222
|
+
strokeWidth: "1",
|
|
223
|
+
strokeDasharray: "8 8"
|
|
224
|
+
}
|
|
225
|
+
)
|
|
226
|
+
}
|
|
227
|
+
) : null,
|
|
228
|
+
avatarPreview ? /* @__PURE__ */ jsx3(
|
|
229
|
+
RemoteImage,
|
|
230
|
+
{
|
|
231
|
+
src: avatarPreview,
|
|
232
|
+
alt: labels.onboarding.profileSetup.profilePreviewAlt,
|
|
233
|
+
className: "h-full w-full object-cover"
|
|
234
|
+
}
|
|
235
|
+
) : /* @__PURE__ */ jsx3(ProfileIcon, { className: "h-7 w-7 text-agg-muted-foreground" })
|
|
236
|
+
]
|
|
237
|
+
}
|
|
238
|
+
),
|
|
239
|
+
/* @__PURE__ */ jsx3(
|
|
240
|
+
"input",
|
|
241
|
+
{
|
|
242
|
+
ref: fileInputRef,
|
|
243
|
+
type: "file",
|
|
244
|
+
accept: "image/*",
|
|
245
|
+
onChange: handleFileChange,
|
|
246
|
+
className: "hidden",
|
|
247
|
+
"aria-hidden": "true"
|
|
248
|
+
}
|
|
249
|
+
)
|
|
250
|
+
] }),
|
|
251
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex flex-col gap-2 w-full", children: [
|
|
252
|
+
/* @__PURE__ */ jsx3(
|
|
253
|
+
"label",
|
|
254
|
+
{
|
|
255
|
+
htmlFor: "onboarding-username",
|
|
256
|
+
className: "text-agg-sm font-agg-bold text-agg-foreground",
|
|
257
|
+
children: labels.onboarding.profileSetup.usernameLabel
|
|
258
|
+
}
|
|
259
|
+
),
|
|
260
|
+
/* @__PURE__ */ jsx3(
|
|
261
|
+
"input",
|
|
262
|
+
{
|
|
263
|
+
id: "onboarding-username",
|
|
264
|
+
type: "text",
|
|
265
|
+
value: username,
|
|
266
|
+
onChange: (e) => setUsername(e.target.value),
|
|
267
|
+
placeholder: labels.onboarding.profileSetup.usernamePlaceholder,
|
|
268
|
+
className: cn(
|
|
269
|
+
"w-full px-3 py-2.5",
|
|
270
|
+
"rounded-[4px]",
|
|
271
|
+
"border border-agg-separator",
|
|
272
|
+
"bg-agg-secondary text-agg-foreground",
|
|
273
|
+
"placeholder:text-agg-muted-foreground",
|
|
274
|
+
"outline-none",
|
|
275
|
+
"hover:bg-agg-secondary-hover",
|
|
276
|
+
"focus:border-agg-primary focus:ring-1 focus:ring-agg-primary",
|
|
277
|
+
"transition-colors",
|
|
278
|
+
"text-agg-sm sm:text-agg-base"
|
|
279
|
+
)
|
|
280
|
+
}
|
|
281
|
+
)
|
|
282
|
+
] })
|
|
283
|
+
] }),
|
|
284
|
+
/* @__PURE__ */ jsx3(Button, { variant: "primary", size: "large", className: "w-full", onClick: handleContinue, children: labels.onboarding.profileSetup.continue })
|
|
285
|
+
] });
|
|
286
|
+
};
|
|
287
|
+
ProfileSetupStep.displayName = "ProfileSetupStep";
|
|
288
|
+
|
|
289
|
+
// src/onboarding/steps/connect-accounts.tsx
|
|
290
|
+
import { useLabels as useLabels4 } from "@agg-build/hooks";
|
|
291
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
292
|
+
var OnchainVenueLogos = () => {
|
|
293
|
+
return /* @__PURE__ */ jsx4("div", { className: "flex gap-1 sm:gap-0 sm:-space-x-5", children: ONCHAIN_VENUES.map((venue, index) => /* @__PURE__ */ jsx4("div", { style: { zIndex: ONCHAIN_VENUES.length - index }, children: /* @__PURE__ */ jsx4(VenueLogo, { venue, variant: "logo", size: "medium", className: "sm:h-8 sm:w-8" }) }, venue)) });
|
|
294
|
+
};
|
|
295
|
+
var VenueCard = ({
|
|
296
|
+
logos,
|
|
297
|
+
title,
|
|
298
|
+
mobileTitle,
|
|
299
|
+
description,
|
|
300
|
+
mobileDescription,
|
|
301
|
+
onConnect,
|
|
302
|
+
connected = false
|
|
303
|
+
}) => {
|
|
304
|
+
const labels = useLabels4();
|
|
305
|
+
const action = connected ? /* @__PURE__ */ jsx4(CheckCircleIcon, { className: "h-6 w-6 text-agg-success" }) : /* @__PURE__ */ jsx4(
|
|
306
|
+
Button,
|
|
307
|
+
{
|
|
308
|
+
variant: "tertiary",
|
|
309
|
+
size: "large",
|
|
310
|
+
className: "!h-auto !px-0 !py-0 text-agg-primary hover:bg-transparent hover:text-agg-primary-hover",
|
|
311
|
+
onClick: onConnect,
|
|
312
|
+
children: labels.onboarding.connectAccounts.connect
|
|
313
|
+
}
|
|
314
|
+
);
|
|
315
|
+
const mobileAction = connected ? /* @__PURE__ */ jsx4(CheckCircleIcon, { className: "h-6 w-6 text-agg-success" }) : /* @__PURE__ */ jsx4(
|
|
316
|
+
Button,
|
|
317
|
+
{
|
|
318
|
+
variant: "tertiary",
|
|
319
|
+
size: "medium",
|
|
320
|
+
className: "!h-auto !px-0 !py-0 text-agg-primary hover:bg-transparent hover:text-agg-primary-hover",
|
|
321
|
+
onClick: onConnect,
|
|
322
|
+
suffix: /* @__PURE__ */ jsx4(ChevronRightIcon, { className: "h-4 w-4" }),
|
|
323
|
+
children: labels.onboarding.connectAccounts.connectAccount
|
|
324
|
+
}
|
|
325
|
+
);
|
|
326
|
+
return /* @__PURE__ */ jsxs4(
|
|
327
|
+
"div",
|
|
328
|
+
{
|
|
329
|
+
className: cn(
|
|
330
|
+
"rounded-agg-md p-5 transition-colors",
|
|
331
|
+
connected ? "bg-agg-success/5" : "bg-agg-secondary-hover hover:bg-agg-tertiary"
|
|
332
|
+
),
|
|
333
|
+
children: [
|
|
334
|
+
/* @__PURE__ */ jsxs4("div", { className: "hidden sm:flex items-center justify-between", children: [
|
|
335
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-5", children: [
|
|
336
|
+
/* @__PURE__ */ jsx4("div", { className: "shrink-0", children: logos }),
|
|
337
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-[2px]", children: [
|
|
338
|
+
/* @__PURE__ */ jsx4("p", { className: "text-agg-base font-agg-bold text-agg-foreground", children: title }),
|
|
339
|
+
/* @__PURE__ */ jsx4("p", { className: "text-agg-sm text-agg-foreground", children: description })
|
|
340
|
+
] })
|
|
341
|
+
] }),
|
|
342
|
+
/* @__PURE__ */ jsx4("div", { className: "shrink-0", children: action })
|
|
343
|
+
] }),
|
|
344
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-3 sm:hidden", children: [
|
|
345
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-3", children: [
|
|
346
|
+
/* @__PURE__ */ jsx4("div", { className: "shrink-0", children: logos }),
|
|
347
|
+
/* @__PURE__ */ jsx4("p", { className: "text-agg-lg font-agg-bold text-agg-foreground", children: mobileTitle != null ? mobileTitle : title })
|
|
348
|
+
] }),
|
|
349
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex flex-col items-start gap-2", children: [
|
|
350
|
+
/* @__PURE__ */ jsx4("p", { className: "text-agg-base text-agg-foreground", children: mobileDescription != null ? mobileDescription : description }),
|
|
351
|
+
mobileAction
|
|
352
|
+
] })
|
|
353
|
+
] })
|
|
354
|
+
]
|
|
355
|
+
}
|
|
356
|
+
);
|
|
357
|
+
};
|
|
358
|
+
var ConnectAccountsStep = ({
|
|
359
|
+
onConnectOnchain,
|
|
360
|
+
onContinue,
|
|
361
|
+
connectedOnchain = false
|
|
362
|
+
}) => {
|
|
363
|
+
const labels = useLabels4();
|
|
364
|
+
const canContinue = connectedOnchain;
|
|
365
|
+
return /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-6", children: [
|
|
366
|
+
/* @__PURE__ */ jsx4("h2", { className: "text-center text-agg-2xl font-agg-bold text-agg-foreground", children: labels.onboarding.connectAccounts.title }),
|
|
367
|
+
/* @__PURE__ */ jsx4("div", { className: "flex flex-col gap-4", children: /* @__PURE__ */ jsx4(
|
|
368
|
+
VenueCard,
|
|
369
|
+
{
|
|
370
|
+
logos: /* @__PURE__ */ jsx4(OnchainVenueLogos, {}),
|
|
371
|
+
title: labels.onboarding.connectAccounts.onchainTitle,
|
|
372
|
+
mobileTitle: labels.onboarding.connectAccounts.onchainMobileTitle(
|
|
373
|
+
ONCHAIN_VENUES.length - 1
|
|
374
|
+
),
|
|
375
|
+
description: labels.onboarding.connectAccounts.onchainDescription,
|
|
376
|
+
mobileDescription: labels.onboarding.connectAccounts.onchainMobileDescription,
|
|
377
|
+
onConnect: onConnectOnchain,
|
|
378
|
+
connected: connectedOnchain
|
|
379
|
+
}
|
|
380
|
+
) }),
|
|
381
|
+
/* @__PURE__ */ jsx4(
|
|
382
|
+
Button,
|
|
383
|
+
{
|
|
384
|
+
variant: "primary",
|
|
385
|
+
size: "large",
|
|
386
|
+
className: "w-full",
|
|
387
|
+
onClick: onContinue,
|
|
388
|
+
disabled: !canContinue,
|
|
389
|
+
children: labels.onboarding.connectAccounts.continue
|
|
390
|
+
}
|
|
391
|
+
)
|
|
392
|
+
] });
|
|
393
|
+
};
|
|
394
|
+
ConnectAccountsStep.displayName = "ConnectAccountsStep";
|
|
395
|
+
|
|
396
|
+
// src/onboarding/steps/connect-onchain-modal.tsx
|
|
397
|
+
import { useCallback as useCallback3, useState as useState3 } from "react";
|
|
398
|
+
import { useLabels as useLabels5 } from "@agg-build/hooks";
|
|
399
|
+
import * as Dialog from "@radix-ui/react-dialog";
|
|
400
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
401
|
+
var ConnectOnchainModal = ({
|
|
402
|
+
open,
|
|
403
|
+
onOpenChange,
|
|
404
|
+
onConnect
|
|
405
|
+
}) => {
|
|
406
|
+
const labels = useLabels5();
|
|
407
|
+
const [connecting, setConnecting] = useState3(false);
|
|
408
|
+
const [error, setError] = useState3();
|
|
409
|
+
const handleCancel = useCallback3(() => {
|
|
410
|
+
onOpenChange(false);
|
|
411
|
+
}, [onOpenChange]);
|
|
412
|
+
const handleConnect = useCallback3(() => __async(null, null, function* () {
|
|
413
|
+
if (connecting) return;
|
|
414
|
+
setConnecting(true);
|
|
415
|
+
setError(void 0);
|
|
416
|
+
try {
|
|
417
|
+
yield onConnect();
|
|
418
|
+
onOpenChange(false);
|
|
419
|
+
} catch (err) {
|
|
420
|
+
setError(
|
|
421
|
+
err instanceof Error ? err.message : labels.onboarding.connectOnchainModal.fallbackError
|
|
422
|
+
);
|
|
423
|
+
} finally {
|
|
424
|
+
setConnecting(false);
|
|
425
|
+
}
|
|
426
|
+
}), [connecting, labels.onboarding.connectOnchainModal.fallbackError, onConnect, onOpenChange]);
|
|
427
|
+
const handleOpenChange = useCallback3(
|
|
428
|
+
(value) => {
|
|
429
|
+
if (value) {
|
|
430
|
+
setError(void 0);
|
|
431
|
+
setConnecting(false);
|
|
432
|
+
}
|
|
433
|
+
onOpenChange(value);
|
|
434
|
+
},
|
|
435
|
+
[onOpenChange]
|
|
436
|
+
);
|
|
437
|
+
return /* @__PURE__ */ jsx5(Modal, { open, onOpenChange: handleOpenChange, children: /* @__PURE__ */ jsxs5(
|
|
438
|
+
Modal.Container,
|
|
439
|
+
{
|
|
440
|
+
maxWidth: "600px",
|
|
441
|
+
"aria-label": labels.onboarding.connectOnchainModal.ariaLabel,
|
|
442
|
+
classNames: { container: "!rounded-agg-lg" },
|
|
443
|
+
children: [
|
|
444
|
+
/* @__PURE__ */ jsx5(Dialog.Title, { className: "sr-only", children: labels.onboarding.connectOnchainModal.title }),
|
|
445
|
+
/* @__PURE__ */ jsx5(
|
|
446
|
+
Modal.Header,
|
|
447
|
+
{
|
|
448
|
+
hideClose: false,
|
|
449
|
+
hideBorder: true,
|
|
450
|
+
classNames: {
|
|
451
|
+
root: "!min-h-0",
|
|
452
|
+
container: "!py-[18px] !px-8"
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
),
|
|
456
|
+
/* @__PURE__ */ jsx5(Modal.Body, { classNames: { root: "!px-5 !pt-0 !pb-[60px] sm:!px-8" }, children: /* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-8 items-center", children: [
|
|
457
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-4 items-center text-center", children: [
|
|
458
|
+
/* @__PURE__ */ jsx5("h2", { className: "text-agg-2xl font-agg-bold text-agg-foreground", children: labels.onboarding.connectOnchainModal.title }),
|
|
459
|
+
/* @__PURE__ */ jsx5("p", { className: "text-agg-base text-center leading-agg-6 text-agg-foreground whitespace-pre-line", children: labels.onboarding.connectOnchainModal.description })
|
|
460
|
+
] }),
|
|
461
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex w-full flex-col items-center gap-4 rounded-agg-xl bg-agg-secondary-hover p-6", children: [
|
|
462
|
+
/* @__PURE__ */ jsx5("p", { className: "text-agg-sm font-agg-bold uppercase leading-agg-5 text-agg-muted-foreground", children: labels.onboarding.connectOnchainModal.supportedVenuesLabel }),
|
|
463
|
+
/* @__PURE__ */ jsx5("div", { className: "flex flex-wrap items-center justify-center gap-x-4 gap-y-3", children: ONCHAIN_VENUES.map((venue, index) => /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-[6px]", children: [
|
|
464
|
+
index > 0 && /* @__PURE__ */ jsx5("span", { className: "mr-2.5 h-3 w-px bg-agg-separator" }),
|
|
465
|
+
/* @__PURE__ */ jsx5(VenueLogo, { venue, size: "medium" }),
|
|
466
|
+
/* @__PURE__ */ jsx5("span", { className: "text-agg-base text-agg-foreground", children: labels.venues[venue] })
|
|
467
|
+
] }, venue)) })
|
|
468
|
+
] }),
|
|
469
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-6 items-center", children: [
|
|
470
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-3 items-center", children: [
|
|
471
|
+
error ? /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2", children: [
|
|
472
|
+
/* @__PURE__ */ jsx5(WarningIcon, { className: "h-3.5 w-3.5 shrink-0 text-agg-error" }),
|
|
473
|
+
/* @__PURE__ */ jsx5("p", { className: "text-agg-sm leading-agg-5 text-agg-error", children: error })
|
|
474
|
+
] }) : null,
|
|
475
|
+
/* @__PURE__ */ jsx5(
|
|
476
|
+
Button,
|
|
477
|
+
{
|
|
478
|
+
variant: "primary",
|
|
479
|
+
size: "large",
|
|
480
|
+
onClick: handleConnect,
|
|
481
|
+
isLoading: connecting,
|
|
482
|
+
children: labels.onboarding.connectOnchainModal.connect
|
|
483
|
+
}
|
|
484
|
+
)
|
|
485
|
+
] }),
|
|
486
|
+
/* @__PURE__ */ jsx5(
|
|
487
|
+
Button,
|
|
488
|
+
{
|
|
489
|
+
variant: "tertiary",
|
|
490
|
+
size: "medium",
|
|
491
|
+
className: "!h-auto !px-0 !py-0 text-agg-primary hover:bg-transparent hover:text-agg-primary-hover",
|
|
492
|
+
onClick: handleCancel,
|
|
493
|
+
children: labels.onboarding.connectOnchainModal.cancel
|
|
494
|
+
}
|
|
495
|
+
)
|
|
496
|
+
] })
|
|
497
|
+
] }) })
|
|
498
|
+
]
|
|
499
|
+
}
|
|
500
|
+
) });
|
|
501
|
+
};
|
|
502
|
+
ConnectOnchainModal.displayName = "ConnectOnchainModal";
|
|
503
|
+
|
|
504
|
+
// src/onboarding/steps/connect-kalshi-modal.tsx
|
|
505
|
+
import { getVenueAvailabilityState, useAppConfig, useLabels as useLabels6 } from "@agg-build/hooks";
|
|
506
|
+
import { Venue as Venue2 } from "@agg-build/sdk";
|
|
507
|
+
import * as Dialog2 from "@radix-ui/react-dialog";
|
|
508
|
+
import { useCallback as useCallback4, useEffect, useId, useMemo, useRef as useRef3, useState as useState4 } from "react";
|
|
509
|
+
import { z } from "zod";
|
|
510
|
+
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
511
|
+
var kalshiCredentialsSchema = z.object({
|
|
512
|
+
apiKeyId: z.string().trim().min(1),
|
|
513
|
+
privateKey: z.string().trim().min(1)
|
|
514
|
+
});
|
|
515
|
+
var getSafeConnectionError = ({
|
|
516
|
+
apiKeyId,
|
|
517
|
+
error,
|
|
518
|
+
fallback,
|
|
519
|
+
privateKey
|
|
520
|
+
}) => {
|
|
521
|
+
if (!(error instanceof Error) || !error.message.trim()) return fallback;
|
|
522
|
+
return [apiKeyId, privateKey].filter(Boolean).reduce(
|
|
523
|
+
(message, sensitiveValue) => message.split(sensitiveValue).join("[redacted]"),
|
|
524
|
+
error.message
|
|
525
|
+
).trim();
|
|
526
|
+
};
|
|
527
|
+
var ConnectKalshiModal = ({
|
|
528
|
+
open,
|
|
529
|
+
onOpenChange,
|
|
530
|
+
onVerify
|
|
531
|
+
}) => {
|
|
532
|
+
const labels = useLabels6();
|
|
533
|
+
const { disabledVenues, isLoading: isAppConfigLoading } = useAppConfig();
|
|
534
|
+
const apiKeyInputRef = useRef3(null);
|
|
535
|
+
const errorId = useId();
|
|
536
|
+
const [apiKeyId, setApiKeyId] = useState4("");
|
|
537
|
+
const [privateKey, setPrivateKey] = useState4("");
|
|
538
|
+
const [isVerifying, setIsVerifying] = useState4(false);
|
|
539
|
+
const [isConnected, setIsConnected] = useState4(false);
|
|
540
|
+
const [error, setError] = useState4();
|
|
541
|
+
const availabilityState = getVenueAvailabilityState({
|
|
542
|
+
venueId: Venue2.kalshi,
|
|
543
|
+
disabledVenues,
|
|
544
|
+
isConfigLoading: isAppConfigLoading
|
|
545
|
+
});
|
|
546
|
+
const parsedCredentials = useMemo(
|
|
547
|
+
() => kalshiCredentialsSchema.safeParse({ apiKeyId, privateKey }),
|
|
548
|
+
[apiKeyId, privateKey]
|
|
549
|
+
);
|
|
550
|
+
useEffect(() => {
|
|
551
|
+
if (!open) return;
|
|
552
|
+
setApiKeyId("");
|
|
553
|
+
setPrivateKey("");
|
|
554
|
+
setError(void 0);
|
|
555
|
+
setIsVerifying(false);
|
|
556
|
+
setIsConnected(false);
|
|
557
|
+
const animationFrame = window.requestAnimationFrame(() => {
|
|
558
|
+
var _a;
|
|
559
|
+
return (_a = apiKeyInputRef.current) == null ? void 0 : _a.focus();
|
|
560
|
+
});
|
|
561
|
+
return () => window.cancelAnimationFrame(animationFrame);
|
|
562
|
+
}, [open]);
|
|
563
|
+
const handleOpenChange = useCallback4(
|
|
564
|
+
(nextOpen) => {
|
|
565
|
+
if (isVerifying && !nextOpen) return;
|
|
566
|
+
onOpenChange(nextOpen);
|
|
567
|
+
},
|
|
568
|
+
[isVerifying, onOpenChange]
|
|
569
|
+
);
|
|
570
|
+
const handleVerify = useCallback4(() => __async(null, null, function* () {
|
|
571
|
+
if (!parsedCredentials.success || isVerifying || isConnected) return;
|
|
572
|
+
const credentials = parsedCredentials.data;
|
|
573
|
+
setIsVerifying(true);
|
|
574
|
+
setError(void 0);
|
|
575
|
+
try {
|
|
576
|
+
yield onVerify(credentials);
|
|
577
|
+
setApiKeyId("");
|
|
578
|
+
setPrivateKey("");
|
|
579
|
+
setIsConnected(true);
|
|
580
|
+
} catch (verificationError) {
|
|
581
|
+
setError(
|
|
582
|
+
getSafeConnectionError(__spreadProps(__spreadValues({}, credentials), {
|
|
583
|
+
error: verificationError,
|
|
584
|
+
fallback: labels.onboarding.connectKalshiModal.fallbackError
|
|
585
|
+
}))
|
|
586
|
+
);
|
|
587
|
+
} finally {
|
|
588
|
+
setIsVerifying(false);
|
|
589
|
+
}
|
|
590
|
+
}), [
|
|
591
|
+
isConnected,
|
|
592
|
+
isVerifying,
|
|
593
|
+
labels.onboarding.connectKalshiModal.fallbackError,
|
|
594
|
+
onVerify,
|
|
595
|
+
parsedCredentials
|
|
596
|
+
]);
|
|
597
|
+
const handleSubmit = useCallback4(
|
|
598
|
+
(event) => {
|
|
599
|
+
event.preventDefault();
|
|
600
|
+
void handleVerify();
|
|
601
|
+
},
|
|
602
|
+
[handleVerify]
|
|
603
|
+
);
|
|
604
|
+
if (availabilityState === "hidden") return null;
|
|
605
|
+
return /* @__PURE__ */ jsx6(Modal, { open, onOpenChange: handleOpenChange, children: /* @__PURE__ */ jsxs6(
|
|
606
|
+
Modal.Container,
|
|
607
|
+
{
|
|
608
|
+
maxWidth: "600px",
|
|
609
|
+
"aria-label": labels.onboarding.connectKalshiModal.ariaLabel,
|
|
610
|
+
classNames: { container: "!rounded-agg-2xl" },
|
|
611
|
+
children: [
|
|
612
|
+
/* @__PURE__ */ jsx6("div", { className: "flex h-[60px] shrink-0 items-center justify-end px-8", children: /* @__PURE__ */ jsx6(
|
|
613
|
+
Dialog2.Close,
|
|
614
|
+
{
|
|
615
|
+
"aria-label": labels.common.close,
|
|
616
|
+
className: "flex size-10 cursor-pointer items-center justify-center rounded-agg-full text-agg-secondary transition-colors hover:bg-agg-quaternary hover:text-agg-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-accent disabled:cursor-default disabled:opacity-50",
|
|
617
|
+
disabled: isVerifying,
|
|
618
|
+
children: /* @__PURE__ */ jsx6(Icon, { name: "close", size: "medium" })
|
|
619
|
+
}
|
|
620
|
+
) }),
|
|
621
|
+
/* @__PURE__ */ jsx6(Modal.Body, { classNames: { root: "!px-5 !pb-12 !pt-0 sm:!px-10" }, children: isConnected ? /* @__PURE__ */ jsxs6(
|
|
622
|
+
"div",
|
|
623
|
+
{
|
|
624
|
+
className: "flex flex-col items-center gap-8 pb-3 text-center",
|
|
625
|
+
role: "status",
|
|
626
|
+
"aria-live": "polite",
|
|
627
|
+
children: [
|
|
628
|
+
/* @__PURE__ */ jsx6("div", { className: "flex size-[60px] items-center justify-center rounded-agg-full bg-agg-success", children: /* @__PURE__ */ jsx6(
|
|
629
|
+
Icon,
|
|
630
|
+
{
|
|
631
|
+
name: "success-check",
|
|
632
|
+
className: "size-7 text-agg-on-primary",
|
|
633
|
+
"aria-hidden": "true"
|
|
634
|
+
}
|
|
635
|
+
) }),
|
|
636
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex flex-col items-center gap-4", children: [
|
|
637
|
+
/* @__PURE__ */ jsx6(Dialog2.Title, { className: "text-agg-2xl font-agg-bold leading-agg-8 text-agg-foreground", children: labels.onboarding.connectKalshiModal.success.title }),
|
|
638
|
+
/* @__PURE__ */ jsx6(Dialog2.Description, { className: "max-w-[480px] text-agg-base leading-agg-6 text-agg-foreground", children: labels.onboarding.connectKalshiModal.success.description })
|
|
639
|
+
] }),
|
|
640
|
+
/* @__PURE__ */ jsx6(
|
|
641
|
+
Button,
|
|
642
|
+
{
|
|
643
|
+
variant: "primary",
|
|
644
|
+
size: "large",
|
|
645
|
+
className: "min-w-[120px]",
|
|
646
|
+
onClick: () => handleOpenChange(false),
|
|
647
|
+
children: labels.onboarding.connectKalshiModal.success.done
|
|
648
|
+
}
|
|
649
|
+
)
|
|
650
|
+
]
|
|
651
|
+
}
|
|
652
|
+
) : /* @__PURE__ */ jsxs6("form", { className: "flex flex-col items-center gap-8", onSubmit: handleSubmit, children: [
|
|
653
|
+
/* @__PURE__ */ jsx6(VenueLogo, { venue: Venue2.kalshi, variant: "logo", size: "large", className: "size-[60px]" }),
|
|
654
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex flex-col items-center gap-4 text-center", children: [
|
|
655
|
+
/* @__PURE__ */ jsx6(Dialog2.Title, { className: "text-agg-2xl font-agg-bold leading-agg-8 text-agg-foreground", children: labels.onboarding.connectKalshiModal.title }),
|
|
656
|
+
/* @__PURE__ */ jsx6(Dialog2.Description, { className: "max-w-[520px] text-agg-base leading-agg-6 text-agg-foreground", children: labels.onboarding.connectKalshiModal.description })
|
|
657
|
+
] }),
|
|
658
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex w-full flex-col gap-4", children: [
|
|
659
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex flex-col gap-3 rounded-agg-xl bg-agg-secondary-hover p-4", children: [
|
|
660
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex flex-col gap-1", children: [
|
|
661
|
+
/* @__PURE__ */ jsx6("p", { className: "text-agg-xs font-agg-bold uppercase leading-agg-4 text-agg-muted-foreground", children: labels.onboarding.connectKalshiModal.stepOne.label }),
|
|
662
|
+
/* @__PURE__ */ jsx6("p", { className: "text-agg-sm font-agg-bold leading-agg-5 text-agg-foreground", children: labels.onboarding.connectKalshiModal.stepOne.title })
|
|
663
|
+
] }),
|
|
664
|
+
/* @__PURE__ */ jsxs6("div", { className: "text-agg-sm leading-agg-5 text-agg-foreground", children: [
|
|
665
|
+
/* @__PURE__ */ jsx6("p", { children: labels.onboarding.connectKalshiModal.stepOne.instructions.signIn }),
|
|
666
|
+
/* @__PURE__ */ jsxs6("p", { children: [
|
|
667
|
+
labels.onboarding.connectKalshiModal.stepOne.instructions.goToProfilePrefix,
|
|
668
|
+
" ",
|
|
669
|
+
/* @__PURE__ */ jsx6("span", { className: "font-agg-bold", children: labels.onboarding.connectKalshiModal.stepOne.instructions.profileText }),
|
|
670
|
+
labels.onboarding.connectKalshiModal.stepOne.instructions.goToProfileSeparator,
|
|
671
|
+
" ",
|
|
672
|
+
/* @__PURE__ */ jsx6(
|
|
673
|
+
"a",
|
|
674
|
+
{
|
|
675
|
+
href: labels.onboarding.connectKalshiModal.stepOne.instructions.profileUrl,
|
|
676
|
+
target: "_blank",
|
|
677
|
+
rel: "noreferrer",
|
|
678
|
+
className: "cursor-pointer underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary",
|
|
679
|
+
children: labels.onboarding.connectKalshiModal.stepOne.instructions.profileUrl
|
|
680
|
+
}
|
|
681
|
+
)
|
|
682
|
+
] }),
|
|
683
|
+
/* @__PURE__ */ jsxs6("p", { children: [
|
|
684
|
+
labels.onboarding.connectKalshiModal.stepOne.instructions.clickCreateKeyPrefix,
|
|
685
|
+
" ",
|
|
686
|
+
/* @__PURE__ */ jsx6("span", { className: "font-agg-bold", children: labels.onboarding.connectKalshiModal.stepOne.instructions.createKeyText }),
|
|
687
|
+
labels.onboarding.connectKalshiModal.stepOne.instructions.clickCreateKeySuffix
|
|
688
|
+
] }),
|
|
689
|
+
/* @__PURE__ */ jsxs6("p", { children: [
|
|
690
|
+
labels.onboarding.connectKalshiModal.stepOne.instructions.selectPermissionsPrefix,
|
|
691
|
+
" ",
|
|
692
|
+
/* @__PURE__ */ jsx6("span", { className: "font-agg-bold", children: labels.onboarding.connectKalshiModal.stepOne.instructions.readWriteText }),
|
|
693
|
+
labels.onboarding.connectKalshiModal.stepOne.instructions.selectPermissionsSuffix
|
|
694
|
+
] }),
|
|
695
|
+
/* @__PURE__ */ jsx6("p", { children: labels.onboarding.connectKalshiModal.stepOne.instructions.createKey })
|
|
696
|
+
] }),
|
|
697
|
+
/* @__PURE__ */ jsxs6("p", { className: "text-agg-sm leading-agg-5 text-agg-foreground", children: [
|
|
698
|
+
labels.onboarding.connectKalshiModal.stepOne.footerLineOne,
|
|
699
|
+
/* @__PURE__ */ jsx6("br", {}),
|
|
700
|
+
labels.onboarding.connectKalshiModal.stepOne.footerLineTwo
|
|
701
|
+
] })
|
|
702
|
+
] }),
|
|
703
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex flex-col gap-3 rounded-agg-xl bg-agg-secondary-hover p-4", children: [
|
|
704
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex flex-col gap-1", children: [
|
|
705
|
+
/* @__PURE__ */ jsx6("p", { className: "text-agg-xs font-agg-bold uppercase leading-agg-4 text-agg-muted-foreground", children: labels.onboarding.connectKalshiModal.stepTwo.label }),
|
|
706
|
+
/* @__PURE__ */ jsx6("p", { className: "text-agg-sm font-agg-bold leading-agg-5 text-agg-foreground", children: labels.onboarding.connectKalshiModal.stepTwo.title })
|
|
707
|
+
] }),
|
|
708
|
+
/* @__PURE__ */ jsx6("p", { className: "text-agg-sm leading-agg-5 text-agg-foreground", children: labels.onboarding.connectKalshiModal.stepTwo.description }),
|
|
709
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex flex-col gap-2", children: [
|
|
710
|
+
/* @__PURE__ */ jsx6(
|
|
711
|
+
"label",
|
|
712
|
+
{
|
|
713
|
+
htmlFor: "kalshi-api-key-id",
|
|
714
|
+
className: "text-agg-sm font-agg-bold text-agg-foreground",
|
|
715
|
+
children: labels.onboarding.connectKalshiModal.stepTwo.apiKeyIdLabel
|
|
716
|
+
}
|
|
717
|
+
),
|
|
718
|
+
/* @__PURE__ */ jsx6(
|
|
719
|
+
"input",
|
|
720
|
+
{
|
|
721
|
+
ref: apiKeyInputRef,
|
|
722
|
+
id: "kalshi-api-key-id",
|
|
723
|
+
type: "text",
|
|
724
|
+
autoComplete: "off",
|
|
725
|
+
value: apiKeyId,
|
|
726
|
+
onChange: (event) => setApiKeyId(event.target.value),
|
|
727
|
+
placeholder: labels.onboarding.connectKalshiModal.stepTwo.apiKeyIdPlaceholder,
|
|
728
|
+
disabled: isVerifying,
|
|
729
|
+
"aria-invalid": !!error,
|
|
730
|
+
"aria-describedby": error ? errorId : void 0,
|
|
731
|
+
className: cn(
|
|
732
|
+
"h-10 w-full rounded-agg-md border border-agg-separator bg-agg-secondary px-3 py-2.5",
|
|
733
|
+
"text-agg-base text-agg-foreground placeholder:text-agg-muted-foreground",
|
|
734
|
+
"outline-none transition-colors focus:border-agg-primary focus:ring-1 focus:ring-agg-primary",
|
|
735
|
+
"disabled:cursor-not-allowed disabled:opacity-60"
|
|
736
|
+
)
|
|
737
|
+
}
|
|
738
|
+
)
|
|
739
|
+
] }),
|
|
740
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex flex-col gap-2", children: [
|
|
741
|
+
/* @__PURE__ */ jsx6(
|
|
742
|
+
"label",
|
|
743
|
+
{
|
|
744
|
+
htmlFor: "kalshi-private-key",
|
|
745
|
+
className: "text-agg-sm font-agg-bold text-agg-foreground",
|
|
746
|
+
children: labels.onboarding.connectKalshiModal.stepTwo.privateKeyLabel
|
|
747
|
+
}
|
|
748
|
+
),
|
|
749
|
+
/* @__PURE__ */ jsx6(
|
|
750
|
+
"textarea",
|
|
751
|
+
{
|
|
752
|
+
id: "kalshi-private-key",
|
|
753
|
+
autoComplete: "off",
|
|
754
|
+
value: privateKey,
|
|
755
|
+
onChange: (event) => setPrivateKey(event.target.value),
|
|
756
|
+
placeholder: labels.onboarding.connectKalshiModal.stepTwo.privateKeyPlaceholder,
|
|
757
|
+
rows: 3,
|
|
758
|
+
disabled: isVerifying,
|
|
759
|
+
"aria-invalid": !!error,
|
|
760
|
+
"aria-describedby": error ? errorId : void 0,
|
|
761
|
+
className: cn(
|
|
762
|
+
"w-full resize-none rounded-agg-md border border-agg-separator bg-agg-secondary px-3 py-2.5",
|
|
763
|
+
"text-agg-base text-agg-foreground placeholder:text-agg-muted-foreground",
|
|
764
|
+
"outline-none transition-colors focus:border-agg-primary focus:ring-1 focus:ring-agg-primary",
|
|
765
|
+
"disabled:cursor-not-allowed disabled:opacity-60"
|
|
766
|
+
)
|
|
767
|
+
}
|
|
768
|
+
)
|
|
769
|
+
] })
|
|
770
|
+
] })
|
|
771
|
+
] }),
|
|
772
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex w-full items-center justify-between gap-4", children: [
|
|
773
|
+
/* @__PURE__ */ jsx6("p", { className: "text-agg-base text-agg-foreground", children: labels.onboarding.connectKalshiModal.help.label }),
|
|
774
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-3", children: [
|
|
775
|
+
/* @__PURE__ */ jsxs6("span", { className: "flex items-center gap-2 text-agg-base font-agg-bold text-agg-primary", children: [
|
|
776
|
+
/* @__PURE__ */ jsx6(Icon, { name: "document", size: "small", className: "size-4 text-agg-primary" }),
|
|
777
|
+
labels.onboarding.connectKalshiModal.help.docsLinkLabel
|
|
778
|
+
] }),
|
|
779
|
+
/* @__PURE__ */ jsx6("span", { className: "h-3 w-px bg-agg-separator" }),
|
|
780
|
+
/* @__PURE__ */ jsxs6("span", { className: "flex items-center gap-2 text-agg-base font-agg-bold text-agg-primary", children: [
|
|
781
|
+
/* @__PURE__ */ jsx6(Icon, { name: "play-square", size: "small", className: "size-4 text-agg-primary" }),
|
|
782
|
+
labels.onboarding.connectKalshiModal.help.tutorialLinkLabel
|
|
783
|
+
] })
|
|
784
|
+
] })
|
|
785
|
+
] }),
|
|
786
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex flex-col items-center gap-5", children: [
|
|
787
|
+
error ? /* @__PURE__ */ jsxs6(
|
|
788
|
+
"div",
|
|
789
|
+
{
|
|
790
|
+
id: errorId,
|
|
791
|
+
className: "flex items-center gap-2",
|
|
792
|
+
role: "alert",
|
|
793
|
+
"aria-live": "assertive",
|
|
794
|
+
children: [
|
|
795
|
+
/* @__PURE__ */ jsx6(Icon, { name: "warning", size: "small", className: "size-3.5 text-agg-error" }),
|
|
796
|
+
/* @__PURE__ */ jsx6("p", { className: "text-agg-sm leading-agg-5 text-agg-error", children: error })
|
|
797
|
+
]
|
|
798
|
+
}
|
|
799
|
+
) : null,
|
|
800
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex items-center justify-center gap-3", children: [
|
|
801
|
+
/* @__PURE__ */ jsx6(
|
|
802
|
+
Button,
|
|
803
|
+
{
|
|
804
|
+
variant: "secondary",
|
|
805
|
+
size: "large",
|
|
806
|
+
onClick: () => handleOpenChange(false),
|
|
807
|
+
disabled: isVerifying,
|
|
808
|
+
children: labels.onboarding.connectKalshiModal.actions.cancel
|
|
809
|
+
}
|
|
810
|
+
),
|
|
811
|
+
/* @__PURE__ */ jsx6(
|
|
812
|
+
Button,
|
|
813
|
+
{
|
|
814
|
+
type: "submit",
|
|
815
|
+
variant: "primary",
|
|
816
|
+
size: "large",
|
|
817
|
+
disabled: !parsedCredentials.success || isVerifying,
|
|
818
|
+
isLoading: isVerifying,
|
|
819
|
+
children: labels.onboarding.connectKalshiModal.actions.verifyConnection
|
|
820
|
+
}
|
|
821
|
+
)
|
|
822
|
+
] })
|
|
823
|
+
] })
|
|
824
|
+
] }) })
|
|
825
|
+
]
|
|
826
|
+
}
|
|
827
|
+
) });
|
|
828
|
+
};
|
|
829
|
+
ConnectKalshiModal.displayName = "ConnectKalshiModal";
|
|
830
|
+
|
|
831
|
+
// src/onboarding/index.tsx
|
|
832
|
+
import { useCallback as useCallback5, useEffect as useEffect2, useState as useState5 } from "react";
|
|
833
|
+
import { useLabels as useLabels7 } from "@agg-build/hooks";
|
|
834
|
+
import * as Dialog3 from "@radix-ui/react-dialog";
|
|
835
|
+
import { Fragment, jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
836
|
+
var OnboardingModal = ({
|
|
837
|
+
open,
|
|
838
|
+
onOpenChange,
|
|
839
|
+
onProfileSubmit,
|
|
840
|
+
onConnectOnchain,
|
|
841
|
+
onComplete,
|
|
842
|
+
howItWorksIcons,
|
|
843
|
+
connectedOnchain = false
|
|
844
|
+
}) => {
|
|
845
|
+
var _a;
|
|
846
|
+
const labels = useLabels7();
|
|
847
|
+
const [step, setStep] = useState5(ONBOARDING_STEPS.HOW_IT_WORKS);
|
|
848
|
+
const stepLabels = {
|
|
849
|
+
[ONBOARDING_STEPS.HOW_IT_WORKS]: labels.onboarding.modal.stepHowItWorks,
|
|
850
|
+
[ONBOARDING_STEPS.PROFILE_SETUP]: labels.onboarding.modal.stepProfileSetup,
|
|
851
|
+
[ONBOARDING_STEPS.CONNECT_ACCOUNTS]: labels.onboarding.modal.stepConnectAccounts
|
|
852
|
+
};
|
|
853
|
+
const resolvedTitle = (_a = stepLabels[step]) != null ? _a : labels.onboarding.modal.title;
|
|
854
|
+
const [onchainModalOpen, setOnchainModalOpen] = useState5(false);
|
|
855
|
+
const [onchainConnected, setOnchainConnected] = useState5(false);
|
|
856
|
+
useEffect2(() => {
|
|
857
|
+
if (open) {
|
|
858
|
+
setStep(ONBOARDING_STEPS.HOW_IT_WORKS);
|
|
859
|
+
setOnchainConnected(false);
|
|
860
|
+
}
|
|
861
|
+
}, [open]);
|
|
862
|
+
const handleHowItWorksContinue = useCallback5(() => {
|
|
863
|
+
setStep(ONBOARDING_STEPS.PROFILE_SETUP);
|
|
864
|
+
}, []);
|
|
865
|
+
const handleProfileContinue = useCallback5(
|
|
866
|
+
(data) => {
|
|
867
|
+
onProfileSubmit == null ? void 0 : onProfileSubmit(data);
|
|
868
|
+
setStep(ONBOARDING_STEPS.CONNECT_ACCOUNTS);
|
|
869
|
+
},
|
|
870
|
+
[onProfileSubmit]
|
|
871
|
+
);
|
|
872
|
+
const handleConnectContinue = useCallback5(() => {
|
|
873
|
+
onComplete == null ? void 0 : onComplete();
|
|
874
|
+
}, [onComplete]);
|
|
875
|
+
const handleOpenOnchainModal = useCallback5(() => {
|
|
876
|
+
setOnchainModalOpen(true);
|
|
877
|
+
}, []);
|
|
878
|
+
const handleOnchainConnect = useCallback5(() => __async(null, null, function* () {
|
|
879
|
+
yield onConnectOnchain == null ? void 0 : onConnectOnchain();
|
|
880
|
+
setOnchainConnected(true);
|
|
881
|
+
}), [onConnectOnchain]);
|
|
882
|
+
return /* @__PURE__ */ jsxs7(Fragment, { children: [
|
|
883
|
+
/* @__PURE__ */ jsx7(Modal, { open, onOpenChange, children: /* @__PURE__ */ jsxs7(
|
|
884
|
+
Modal.Container,
|
|
885
|
+
{
|
|
886
|
+
maxWidth: "600px",
|
|
887
|
+
"aria-label": resolvedTitle,
|
|
888
|
+
classNames: { container: "!rounded-agg-lg" },
|
|
889
|
+
children: [
|
|
890
|
+
/* @__PURE__ */ jsx7(Dialog3.Title, { className: "sr-only", children: resolvedTitle }),
|
|
891
|
+
/* @__PURE__ */ jsxs7(Modal.Body, { classNames: { root: "px-5 py-6 sm:px-10 sm:py-8" }, children: [
|
|
892
|
+
step === ONBOARDING_STEPS.HOW_IT_WORKS && /* @__PURE__ */ jsx7(HowItWorksStep, { onContinue: handleHowItWorksContinue, icons: howItWorksIcons }),
|
|
893
|
+
step === ONBOARDING_STEPS.PROFILE_SETUP && /* @__PURE__ */ jsx7(ProfileSetupStep, { onContinue: handleProfileContinue }),
|
|
894
|
+
step === ONBOARDING_STEPS.CONNECT_ACCOUNTS && /* @__PURE__ */ jsx7(
|
|
895
|
+
ConnectAccountsStep,
|
|
896
|
+
{
|
|
897
|
+
onConnectOnchain: handleOpenOnchainModal,
|
|
898
|
+
onContinue: handleConnectContinue,
|
|
899
|
+
connectedOnchain: connectedOnchain || onchainConnected
|
|
900
|
+
}
|
|
901
|
+
)
|
|
902
|
+
] })
|
|
903
|
+
]
|
|
904
|
+
}
|
|
905
|
+
) }),
|
|
906
|
+
/* @__PURE__ */ jsx7(
|
|
907
|
+
ConnectOnchainModal,
|
|
908
|
+
{
|
|
909
|
+
open: onchainModalOpen,
|
|
910
|
+
onOpenChange: setOnchainModalOpen,
|
|
911
|
+
onConnect: handleOnchainConnect
|
|
912
|
+
}
|
|
913
|
+
)
|
|
914
|
+
] });
|
|
915
|
+
};
|
|
916
|
+
OnboardingModal.displayName = "OnboardingModal";
|
|
917
|
+
|
|
918
|
+
// src/notifications/deposit-notification-events.ts
|
|
919
|
+
var AGG_DEPOSIT_NOTIFICATION_EVENT = "agg:deposit-notification";
|
|
920
|
+
var dispatchAggDepositNotification = (detail) => {
|
|
921
|
+
if (typeof window === "undefined") return;
|
|
922
|
+
window.dispatchEvent(new CustomEvent(AGG_DEPOSIT_NOTIFICATION_EVENT, { detail }));
|
|
923
|
+
};
|
|
924
|
+
var subscribeAggDepositNotification = (handler) => {
|
|
925
|
+
if (typeof window === "undefined") return () => {
|
|
926
|
+
};
|
|
927
|
+
const handleDepositNotification = (event) => {
|
|
928
|
+
if (!(event instanceof CustomEvent)) return;
|
|
929
|
+
handler(event.detail);
|
|
930
|
+
};
|
|
931
|
+
window.addEventListener(AGG_DEPOSIT_NOTIFICATION_EVENT, handleDepositNotification);
|
|
932
|
+
return () => {
|
|
933
|
+
window.removeEventListener(AGG_DEPOSIT_NOTIFICATION_EVENT, handleDepositNotification);
|
|
934
|
+
};
|
|
935
|
+
};
|
|
936
|
+
|
|
937
|
+
export {
|
|
938
|
+
dispatchAggDepositNotification,
|
|
939
|
+
subscribeAggDepositNotification,
|
|
940
|
+
GeoBlockBanner,
|
|
941
|
+
HowItWorksStep,
|
|
942
|
+
ProfileSetupStep,
|
|
943
|
+
ConnectAccountsStep,
|
|
944
|
+
ConnectOnchainModal,
|
|
945
|
+
ConnectKalshiModal,
|
|
946
|
+
OnboardingModal
|
|
947
|
+
};
|