@agg-build/ui 2.1.1 → 2.1.3
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-XHDGSRG7.mjs → chunk-BW7S2YR3.mjs} +1139 -308
- package/dist/{chunk-TERG43WW.mjs → chunk-R2YNZJZ3.mjs} +69 -27
- package/dist/{chunk-RPXRTXCY.mjs → chunk-T4YZGAYS.mjs} +22 -1
- package/dist/{chunk-IQT4I5B4.mjs → chunk-TAGPAADA.mjs} +2108 -767
- package/dist/{chunk-NK57KMYN.mjs → chunk-TBZWRUFB.mjs} +752 -589
- package/dist/{chunk-YJO6LMRT.mjs → chunk-VP76G6PN.mjs} +87 -25
- package/dist/{chunk-WU2C3C6K.mjs → chunk-XHE2VO3S.mjs} +4 -21
- package/dist/events.js +1014 -760
- package/dist/events.mjs +5 -3
- package/dist/index.js +9937 -7880
- package/dist/index.mjs +117 -456
- package/dist/modals.js +1 -1
- package/dist/modals.mjs +3 -3
- package/dist/pages.js +8513 -6380
- package/dist/pages.mjs +6 -6
- package/dist/primitives.js +85 -25
- package/dist/primitives.mjs +1 -1
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +1 -1
- package/dist/trading.js +979 -402
- package/dist/trading.mjs +10 -6
- package/dist/types/events/item/event-list-item.utils.d.mts +1 -25
- package/dist/types/events/item/event-list-item.utils.d.ts +1 -25
- package/dist/types/events/item-details/index.d.mts +2 -1
- package/dist/types/events/item-details/index.d.ts +2 -1
- package/dist/types/events/market-details/market-details-graph-panel.d.mts +39 -0
- package/dist/types/events/market-details/market-details-graph-panel.d.ts +39 -0
- package/dist/types/events/market-details/market-details-outcome-button.d.mts +2 -1
- package/dist/types/events/market-details/market-details-outcome-button.d.ts +2 -1
- package/dist/types/events/market-details/market-details.types.d.mts +31 -0
- package/dist/types/events/market-details/market-details.types.d.ts +31 -0
- package/dist/types/events/market-details/market-details.utils.d.mts +3 -16
- package/dist/types/events/market-details/market-details.utils.d.ts +3 -16
- package/dist/types/events/shared/format-event-title.d.mts +24 -0
- package/dist/types/events/shared/format-event-title.d.ts +24 -0
- package/dist/types/events/shared/format-sports-event-time.d.mts +2 -0
- package/dist/types/events/shared/format-sports-event-time.d.ts +2 -0
- package/dist/types/events/shared/select-best-outcome.d.mts +88 -0
- package/dist/types/events/shared/select-best-outcome.d.ts +88 -0
- package/dist/types/notifications/agg-notification-events-provider.d.mts +10 -1
- package/dist/types/notifications/agg-notification-events-provider.d.ts +10 -1
- package/dist/types/pages/event-market/event-market.shared.d.mts +30 -0
- package/dist/types/pages/event-market/event-market.shared.d.ts +30 -0
- package/dist/types/pages/event-market/event-market.types.d.mts +7 -0
- package/dist/types/pages/event-market/event-market.types.d.ts +7 -0
- package/dist/types/pages/event-market/sports-event-market-page.d.mts +8 -0
- package/dist/types/pages/event-market/sports-event-market-page.d.ts +8 -0
- package/dist/types/pages/event-market/sports-event-market.fixtures.d.mts +13 -0
- package/dist/types/pages/event-market/sports-event-market.fixtures.d.ts +13 -0
- package/dist/types/pages/event-market/sports-event-market.utils.d.mts +156 -0
- package/dist/types/pages/event-market/sports-event-market.utils.d.ts +156 -0
- package/dist/types/pages/event-market/sports-line-rail.d.mts +17 -0
- package/dist/types/pages/event-market/sports-line-rail.d.ts +17 -0
- package/dist/types/pages/event-market/sports-market-card.d.mts +22 -0
- package/dist/types/pages/event-market/sports-market-card.d.ts +22 -0
- package/dist/types/pages/event-market/sports-markets.d.mts +13 -0
- package/dist/types/pages/event-market/sports-markets.d.ts +13 -0
- package/dist/types/primitives/state-message/index.d.mts +1 -1
- package/dist/types/primitives/state-message/index.d.ts +1 -1
- package/dist/types/primitives/state-message/state-message.types.d.mts +1 -1
- package/dist/types/primitives/state-message/state-message.types.d.ts +1 -1
- package/dist/types/trading/index.d.mts +2 -0
- package/dist/types/trading/index.d.ts +2 -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 +30 -1
- package/dist/types/trading/place-order/index.place-order.types.d.ts +30 -1
- package/dist/types/trading/settlement/settlement-text.utils.d.mts +5 -2
- package/dist/types/trading/settlement/settlement-text.utils.d.ts +5 -2
- package/dist/types/trading/use-claim-winnings.d.mts +84 -0
- package/dist/types/trading/use-claim-winnings.d.ts +84 -0
- package/dist/types/trading/use-resolved-market-claim.d.mts +26 -0
- package/dist/types/trading/use-resolved-market-claim.d.ts +26 -0
- package/package.json +3 -3
|
@@ -8,10 +8,11 @@ import {
|
|
|
8
8
|
getTradingValueLabel,
|
|
9
9
|
getTradingVenueLabel,
|
|
10
10
|
resolveOrderEligibilityMessage
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-R2YNZJZ3.mjs";
|
|
12
12
|
import {
|
|
13
|
-
GeoBlockBanner
|
|
14
|
-
|
|
13
|
+
GeoBlockBanner,
|
|
14
|
+
subscribeAggDepositNotification
|
|
15
|
+
} from "./chunk-T4YZGAYS.mjs";
|
|
15
16
|
import {
|
|
16
17
|
AGG_TERMS_OF_SERVICE_URL,
|
|
17
18
|
Button,
|
|
@@ -31,14 +32,18 @@ import {
|
|
|
31
32
|
UserTrustIcon,
|
|
32
33
|
VenueLogo,
|
|
33
34
|
__async,
|
|
35
|
+
__objRest,
|
|
34
36
|
__pow,
|
|
37
|
+
__restKey,
|
|
35
38
|
__spreadProps,
|
|
36
39
|
__spreadValues,
|
|
37
40
|
cn,
|
|
41
|
+
formatSportsEventTimeEt,
|
|
38
42
|
formatUsd,
|
|
39
43
|
getMotionClassName,
|
|
40
|
-
skeletonViews
|
|
41
|
-
|
|
44
|
+
skeletonViews,
|
|
45
|
+
useOptionalToast
|
|
46
|
+
} from "./chunk-VP76G6PN.mjs";
|
|
42
47
|
|
|
43
48
|
// src/trading/types.ts
|
|
44
49
|
import { Venue, enumGuard, isFiniteNonNeg, safeParse } from "@agg-build/sdk";
|
|
@@ -107,7 +112,362 @@ import {
|
|
|
107
112
|
} from "@agg-build/hooks";
|
|
108
113
|
import NumberFlow from "@number-flow/react";
|
|
109
114
|
import * as Dialog from "@radix-ui/react-dialog";
|
|
110
|
-
import { Fragment, useCallback as
|
|
115
|
+
import { Fragment as Fragment2, useCallback as useCallback3, useEffect as useEffect3, useId, useMemo as useMemo2, useRef as useRef3, useState as useState3 } from "react";
|
|
116
|
+
|
|
117
|
+
// src/notifications/agg-notification-events-provider.tsx
|
|
118
|
+
import {
|
|
119
|
+
useAggAuthState,
|
|
120
|
+
useAggLabels,
|
|
121
|
+
useAggUiConfig,
|
|
122
|
+
useOnOrderEvent,
|
|
123
|
+
useOnWithdrawalLifecycle,
|
|
124
|
+
useOptionalAggClient,
|
|
125
|
+
useUserActivity
|
|
126
|
+
} from "@agg-build/hooks";
|
|
127
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
128
|
+
import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
129
|
+
function AggNotificationEventsProvider({
|
|
130
|
+
children,
|
|
131
|
+
enabled = true,
|
|
132
|
+
depositActivityLimit = 25
|
|
133
|
+
}) {
|
|
134
|
+
const aggClient = useOptionalAggClient();
|
|
135
|
+
if (!aggClient) {
|
|
136
|
+
return /* @__PURE__ */ jsx2(Fragment, { children });
|
|
137
|
+
}
|
|
138
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
139
|
+
/* @__PURE__ */ jsx2(AggNotificationEventsBridge, { enabled, depositActivityLimit }),
|
|
140
|
+
children
|
|
141
|
+
] });
|
|
142
|
+
}
|
|
143
|
+
var TERMINAL_ORDER_EVENTS = /* @__PURE__ */ new Set(["filled", "partial_fill", "failed"]);
|
|
144
|
+
var firedOrderNotificationKeys = /* @__PURE__ */ new Set();
|
|
145
|
+
var TERMINAL_WITHDRAWAL_STATUSES = /* @__PURE__ */ new Set([
|
|
146
|
+
"completed",
|
|
147
|
+
"partial",
|
|
148
|
+
"failed"
|
|
149
|
+
]);
|
|
150
|
+
var isTerminalWithdrawalStatus = (value) => TERMINAL_WITHDRAWAL_STATUSES.has(value);
|
|
151
|
+
var MICRO_UNITS_SCALE = 1e6;
|
|
152
|
+
var formatScaledMicroAmount = (value) => {
|
|
153
|
+
if (!value) return void 0;
|
|
154
|
+
if (value.includes(".")) {
|
|
155
|
+
const parsed = Number(value);
|
|
156
|
+
if (!Number.isFinite(parsed)) return void 0;
|
|
157
|
+
return parsed.toLocaleString("en-US", { maximumFractionDigits: 2 });
|
|
158
|
+
}
|
|
159
|
+
try {
|
|
160
|
+
const raw = BigInt(value);
|
|
161
|
+
const whole = raw / BigInt(MICRO_UNITS_SCALE);
|
|
162
|
+
const remainder = raw % BigInt(MICRO_UNITS_SCALE);
|
|
163
|
+
const parsed = Number(whole) + Number(remainder) / MICRO_UNITS_SCALE;
|
|
164
|
+
return parsed.toLocaleString("en-US", { maximumFractionDigits: 2 });
|
|
165
|
+
} catch (e) {
|
|
166
|
+
const parsed = Number(value);
|
|
167
|
+
if (!Number.isFinite(parsed)) return void 0;
|
|
168
|
+
return (parsed / MICRO_UNITS_SCALE).toLocaleString("en-US", { maximumFractionDigits: 2 });
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
var formatDecimalAmount = (value) => {
|
|
172
|
+
if (!value) return void 0;
|
|
173
|
+
const parsed = Number(value.replace(/,/g, ""));
|
|
174
|
+
if (!Number.isFinite(parsed)) return value;
|
|
175
|
+
return parsed.toLocaleString("en-US", { maximumFractionDigits: 2 });
|
|
176
|
+
};
|
|
177
|
+
var formatPriceCents = (value) => {
|
|
178
|
+
if (!value) return void 0;
|
|
179
|
+
const parsed = Number(value);
|
|
180
|
+
if (!Number.isFinite(parsed)) return void 0;
|
|
181
|
+
const cents = parsed * 100;
|
|
182
|
+
const display = cents.toLocaleString("en-US", {
|
|
183
|
+
minimumFractionDigits: 0,
|
|
184
|
+
maximumFractionDigits: 1
|
|
185
|
+
});
|
|
186
|
+
return `${display}\xA2`;
|
|
187
|
+
};
|
|
188
|
+
var formatSharesLabel = (raw) => {
|
|
189
|
+
const formatted = formatScaledMicroAmount(raw);
|
|
190
|
+
if (!formatted) return void 0;
|
|
191
|
+
return `${formatted} shares`;
|
|
192
|
+
};
|
|
193
|
+
var capitalize = (value) => {
|
|
194
|
+
if (!value) return void 0;
|
|
195
|
+
return value.charAt(0).toUpperCase() + value.slice(1).toLowerCase();
|
|
196
|
+
};
|
|
197
|
+
var venueLabelFor = (venueKey, labels) => {
|
|
198
|
+
var _a;
|
|
199
|
+
if (!venueKey) return void 0;
|
|
200
|
+
const normalized = venueKey.toLowerCase();
|
|
201
|
+
const lookup = labels.venues;
|
|
202
|
+
return (_a = lookup[normalized]) != null ? _a : capitalize(venueKey);
|
|
203
|
+
};
|
|
204
|
+
function resetOrderNotificationDedupe() {
|
|
205
|
+
firedOrderNotificationKeys.clear();
|
|
206
|
+
}
|
|
207
|
+
function AggNotificationEventsBridge({ enabled, depositActivityLimit }) {
|
|
208
|
+
var _a;
|
|
209
|
+
const toastCtx = useOptionalToast();
|
|
210
|
+
const { user, isAuthenticated } = useAggAuthState();
|
|
211
|
+
const labels = useAggLabels();
|
|
212
|
+
const { features } = useAggUiConfig();
|
|
213
|
+
const notificationsFeatureEnabled = features.enableNotifications !== false;
|
|
214
|
+
const effectivelyEnabled = enabled && notificationsFeatureEnabled;
|
|
215
|
+
const currentUserId = (_a = user == null ? void 0 : user.id) != null ? _a : null;
|
|
216
|
+
const firedKeysRef = useRef(/* @__PURE__ */ new Set());
|
|
217
|
+
const depositStatusesRef = useRef(/* @__PURE__ */ new Map());
|
|
218
|
+
const hasSeededDepositStatusesRef = useRef(false);
|
|
219
|
+
const recentClientDepositFingerprintsRef = useRef(/* @__PURE__ */ new Map());
|
|
220
|
+
const lastUserIdRef = useRef("uninitialized");
|
|
221
|
+
useEffect(() => {
|
|
222
|
+
if (lastUserIdRef.current === currentUserId) return;
|
|
223
|
+
lastUserIdRef.current = currentUserId;
|
|
224
|
+
firedKeysRef.current = /* @__PURE__ */ new Set();
|
|
225
|
+
resetOrderNotificationDedupe();
|
|
226
|
+
depositStatusesRef.current = /* @__PURE__ */ new Map();
|
|
227
|
+
hasSeededDepositStatusesRef.current = false;
|
|
228
|
+
recentClientDepositFingerprintsRef.current = /* @__PURE__ */ new Map();
|
|
229
|
+
}, [currentUserId]);
|
|
230
|
+
const fireOnce = useCallback(
|
|
231
|
+
(key, tone, title, message, detail) => {
|
|
232
|
+
if (!effectivelyEnabled) return;
|
|
233
|
+
const toast = toastCtx == null ? void 0 : toastCtx.toast;
|
|
234
|
+
if (!toast) return;
|
|
235
|
+
if (firedKeysRef.current.has(key)) return;
|
|
236
|
+
firedKeysRef.current.add(key);
|
|
237
|
+
toast(message, { tone, title, detail });
|
|
238
|
+
},
|
|
239
|
+
[effectivelyEnabled, toastCtx]
|
|
240
|
+
);
|
|
241
|
+
const orderEventCallback = useCallback(
|
|
242
|
+
(event) => {
|
|
243
|
+
if (!effectivelyEnabled || !isAuthenticated) return;
|
|
244
|
+
if (!currentUserId || event.userId !== currentUserId) return;
|
|
245
|
+
if (!TERMINAL_ORDER_EVENTS.has(event.event)) return;
|
|
246
|
+
handleOrderEvent({ event, labels, fireOnce });
|
|
247
|
+
},
|
|
248
|
+
[currentUserId, effectivelyEnabled, fireOnce, isAuthenticated, labels]
|
|
249
|
+
);
|
|
250
|
+
useOnOrderEvent(orderEventCallback);
|
|
251
|
+
const withdrawalCallback = useCallback(
|
|
252
|
+
(event) => {
|
|
253
|
+
if (!effectivelyEnabled || !isAuthenticated) return;
|
|
254
|
+
if (!currentUserId || event.userId !== currentUserId) return;
|
|
255
|
+
if (!event.terminal) return;
|
|
256
|
+
if (!isTerminalWithdrawalStatus(event.status)) return;
|
|
257
|
+
handleWithdrawalEvent({ event, labels, fireOnce });
|
|
258
|
+
},
|
|
259
|
+
[currentUserId, effectivelyEnabled, fireOnce, isAuthenticated, labels]
|
|
260
|
+
);
|
|
261
|
+
useOnWithdrawalLifecycle(withdrawalCallback);
|
|
262
|
+
useEffect(() => {
|
|
263
|
+
if (!effectivelyEnabled || !isAuthenticated || !currentUserId) return;
|
|
264
|
+
return subscribeAggDepositNotification((event) => {
|
|
265
|
+
handleClientDepositNotification({
|
|
266
|
+
event,
|
|
267
|
+
labels,
|
|
268
|
+
fireOnce,
|
|
269
|
+
recentClientDepositFingerprints: recentClientDepositFingerprintsRef.current
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
}, [currentUserId, effectivelyEnabled, fireOnce, isAuthenticated, labels]);
|
|
273
|
+
const depositActivity = useUserActivity({
|
|
274
|
+
type: "deposit",
|
|
275
|
+
limit: depositActivityLimit,
|
|
276
|
+
enabled: effectivelyEnabled && isAuthenticated && currentUserId !== null
|
|
277
|
+
});
|
|
278
|
+
const depositActivities = depositActivity.activities;
|
|
279
|
+
useEffect(() => {
|
|
280
|
+
if (!effectivelyEnabled || !isAuthenticated || !currentUserId) return;
|
|
281
|
+
if (!depositActivity.isSuccess) return;
|
|
282
|
+
handleDepositActivities({
|
|
283
|
+
deposits: depositActivities,
|
|
284
|
+
previousStatuses: depositStatusesRef.current,
|
|
285
|
+
hasSeededStatuses: hasSeededDepositStatusesRef.current,
|
|
286
|
+
labels,
|
|
287
|
+
fireOnce,
|
|
288
|
+
shouldSuppressToast: (status, amountLabel, tokenLabel) => hasRecentClientDepositNotification({
|
|
289
|
+
recentClientDepositFingerprints: recentClientDepositFingerprintsRef.current,
|
|
290
|
+
status,
|
|
291
|
+
amountLabel,
|
|
292
|
+
tokenLabel
|
|
293
|
+
})
|
|
294
|
+
});
|
|
295
|
+
hasSeededDepositStatusesRef.current = true;
|
|
296
|
+
}, [
|
|
297
|
+
currentUserId,
|
|
298
|
+
depositActivities,
|
|
299
|
+
depositActivity.isSuccess,
|
|
300
|
+
effectivelyEnabled,
|
|
301
|
+
fireOnce,
|
|
302
|
+
isAuthenticated,
|
|
303
|
+
labels
|
|
304
|
+
]);
|
|
305
|
+
return null;
|
|
306
|
+
}
|
|
307
|
+
function handleOrderEvent({ event, labels, fireOnce }) {
|
|
308
|
+
var _a, _b;
|
|
309
|
+
const venueLabel = venueLabelFor(event.venue, labels);
|
|
310
|
+
const amountLabel = formatSharesLabel((_a = event.actualSharesRaw) != null ? _a : event.filledAmountRaw);
|
|
311
|
+
const priceLabel = formatPriceCents((_b = event.executionPriceRaw) != null ? _b : event.quotedPriceRaw);
|
|
312
|
+
const fireOrderOnce = (key, tone, title, message, detail) => {
|
|
313
|
+
if (firedOrderNotificationKeys.has(key)) return;
|
|
314
|
+
firedOrderNotificationKeys.add(key);
|
|
315
|
+
fireOnce(key, tone, title, message, detail);
|
|
316
|
+
};
|
|
317
|
+
if (event.event === "filled") {
|
|
318
|
+
fireOrderOnce(
|
|
319
|
+
`order:${event.orderId}:filled`,
|
|
320
|
+
"success",
|
|
321
|
+
labels.notifications.order.filledTitle,
|
|
322
|
+
labels.notifications.order.filledMessage({ venueLabel, amountLabel, priceLabel })
|
|
323
|
+
);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
if (event.event === "partial_fill") {
|
|
327
|
+
fireOrderOnce(
|
|
328
|
+
`order:${event.orderId}:partial_fill`,
|
|
329
|
+
"warning",
|
|
330
|
+
labels.notifications.order.partialFilledTitle,
|
|
331
|
+
labels.notifications.order.partialFilledMessage({ venueLabel, amountLabel, priceLabel })
|
|
332
|
+
);
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
if (event.event === "failed") {
|
|
336
|
+
fireOrderOnce(
|
|
337
|
+
`order:${event.orderId}:failed`,
|
|
338
|
+
"error",
|
|
339
|
+
labels.notifications.order.failedTitle,
|
|
340
|
+
labels.notifications.order.failedMessage(event.errorReason),
|
|
341
|
+
venueLabel
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
function handleWithdrawalEvent({ event, labels, fireOnce }) {
|
|
346
|
+
var _a;
|
|
347
|
+
const amountLabel = formatScaledMicroAmount((_a = event.completedAmountRaw) != null ? _a : event.requestedAmountRaw);
|
|
348
|
+
if (event.status === "completed") {
|
|
349
|
+
fireOnce(
|
|
350
|
+
`withdrawal:${event.withdrawalId}:completed`,
|
|
351
|
+
"success",
|
|
352
|
+
labels.notifications.withdrawal.completedTitle,
|
|
353
|
+
labels.notifications.withdrawal.completedMessage({ amountLabel })
|
|
354
|
+
);
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
if (event.status === "partial") {
|
|
358
|
+
fireOnce(
|
|
359
|
+
`withdrawal:${event.withdrawalId}:partial`,
|
|
360
|
+
"warning",
|
|
361
|
+
labels.notifications.withdrawal.partialTitle,
|
|
362
|
+
labels.notifications.withdrawal.partialMessage({ amountLabel })
|
|
363
|
+
);
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
if (event.status === "failed") {
|
|
367
|
+
fireOnce(
|
|
368
|
+
`withdrawal:${event.withdrawalId}:failed`,
|
|
369
|
+
"error",
|
|
370
|
+
labels.notifications.withdrawal.failedTitle,
|
|
371
|
+
labels.notifications.withdrawal.failedMessage(event.errorMessage)
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
var DEPOSIT_COMPLETED_STATUSES = /* @__PURE__ */ new Set(["completed", "confirmed", "succeeded", "success"]);
|
|
376
|
+
var DEPOSIT_FAILED_STATUSES = /* @__PURE__ */ new Set(["failed", "errored", "rejected"]);
|
|
377
|
+
var CLIENT_DEPOSIT_ACTIVITY_SUPPRESSION_MS = 2 * 60 * 1e3;
|
|
378
|
+
var isTerminalDepositStatus = (status) => DEPOSIT_COMPLETED_STATUSES.has(status) || DEPOSIT_FAILED_STATUSES.has(status);
|
|
379
|
+
var getDepositNotificationFingerprint = ({
|
|
380
|
+
status,
|
|
381
|
+
amountLabel,
|
|
382
|
+
tokenLabel
|
|
383
|
+
}) => `${status}:${amountLabel != null ? amountLabel : ""}:${tokenLabel != null ? tokenLabel : ""}`.toLowerCase();
|
|
384
|
+
var hasRecentClientDepositNotification = ({
|
|
385
|
+
recentClientDepositFingerprints,
|
|
386
|
+
status,
|
|
387
|
+
amountLabel,
|
|
388
|
+
tokenLabel
|
|
389
|
+
}) => {
|
|
390
|
+
const fingerprint = getDepositNotificationFingerprint({ status, amountLabel, tokenLabel });
|
|
391
|
+
const lastNotifiedAt = recentClientDepositFingerprints.get(fingerprint);
|
|
392
|
+
if (!lastNotifiedAt) return false;
|
|
393
|
+
if (Date.now() - lastNotifiedAt <= CLIENT_DEPOSIT_ACTIVITY_SUPPRESSION_MS) {
|
|
394
|
+
return true;
|
|
395
|
+
}
|
|
396
|
+
recentClientDepositFingerprints.delete(fingerprint);
|
|
397
|
+
return false;
|
|
398
|
+
};
|
|
399
|
+
function handleClientDepositNotification({
|
|
400
|
+
event,
|
|
401
|
+
labels,
|
|
402
|
+
fireOnce,
|
|
403
|
+
recentClientDepositFingerprints
|
|
404
|
+
}) {
|
|
405
|
+
var _a, _b, _c;
|
|
406
|
+
const amountLabel = formatDecimalAmount(event.amount);
|
|
407
|
+
const tokenLabel = event.tokenSymbol;
|
|
408
|
+
const fingerprint = getDepositNotificationFingerprint({
|
|
409
|
+
status: event.status,
|
|
410
|
+
amountLabel,
|
|
411
|
+
tokenLabel
|
|
412
|
+
});
|
|
413
|
+
recentClientDepositFingerprints.set(fingerprint, Date.now());
|
|
414
|
+
if (event.status === "completed") {
|
|
415
|
+
fireOnce(
|
|
416
|
+
`deposit-client:${(_a = event.id) != null ? _a : fingerprint}:completed`,
|
|
417
|
+
"success",
|
|
418
|
+
labels.notifications.deposit.completedTitle,
|
|
419
|
+
labels.notifications.deposit.completedMessage({ amountLabel, tokenLabel })
|
|
420
|
+
);
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
fireOnce(
|
|
424
|
+
`deposit-client:${(_b = event.id) != null ? _b : fingerprint}:failed`,
|
|
425
|
+
"error",
|
|
426
|
+
labels.notifications.deposit.failedTitle,
|
|
427
|
+
(_c = event.errorMessage) != null ? _c : labels.notifications.deposit.failedMessage({ amountLabel, tokenLabel })
|
|
428
|
+
);
|
|
429
|
+
}
|
|
430
|
+
function handleDepositActivities({
|
|
431
|
+
deposits,
|
|
432
|
+
previousStatuses,
|
|
433
|
+
hasSeededStatuses,
|
|
434
|
+
labels,
|
|
435
|
+
fireOnce,
|
|
436
|
+
shouldSuppressToast
|
|
437
|
+
}) {
|
|
438
|
+
for (const item of deposits) {
|
|
439
|
+
if (item.type !== "deposit") continue;
|
|
440
|
+
const deposit = item;
|
|
441
|
+
const status = deposit.status.toLowerCase();
|
|
442
|
+
const isCompleted = DEPOSIT_COMPLETED_STATUSES.has(status);
|
|
443
|
+
const isFailed = DEPOSIT_FAILED_STATUSES.has(status);
|
|
444
|
+
const previousStatus = previousStatuses.get(deposit.id);
|
|
445
|
+
previousStatuses.set(deposit.id, status);
|
|
446
|
+
if (!hasSeededStatuses) continue;
|
|
447
|
+
if (!previousStatus) continue;
|
|
448
|
+
if (isTerminalDepositStatus(previousStatus)) continue;
|
|
449
|
+
if (!isCompleted && !isFailed) continue;
|
|
450
|
+
const amountLabel = formatScaledMicroAmount(deposit.amountRaw);
|
|
451
|
+
const tokenLabel = deposit.tokenSymbol;
|
|
452
|
+
const terminalStatus = isCompleted ? "completed" : "failed";
|
|
453
|
+
if (shouldSuppressToast == null ? void 0 : shouldSuppressToast(terminalStatus, amountLabel, tokenLabel)) continue;
|
|
454
|
+
if (isCompleted) {
|
|
455
|
+
fireOnce(
|
|
456
|
+
`deposit:${deposit.id}:completed`,
|
|
457
|
+
"success",
|
|
458
|
+
labels.notifications.deposit.completedTitle,
|
|
459
|
+
labels.notifications.deposit.completedMessage({ amountLabel, tokenLabel })
|
|
460
|
+
);
|
|
461
|
+
} else {
|
|
462
|
+
fireOnce(
|
|
463
|
+
`deposit:${deposit.id}:failed`,
|
|
464
|
+
"error",
|
|
465
|
+
labels.notifications.deposit.failedTitle,
|
|
466
|
+
labels.notifications.deposit.failedMessage({ amountLabel, tokenLabel })
|
|
467
|
+
);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}
|
|
111
471
|
|
|
112
472
|
// src/shared/deposit-modal-events.ts
|
|
113
473
|
var DEPOSIT_MODAL_OPEN_EVENT = "agg-deposit:open-modal";
|
|
@@ -123,7 +483,7 @@ var requestAggWithdrawModalOpen = () => {
|
|
|
123
483
|
|
|
124
484
|
// src/trading/use-kalshi-kyc-flow.ts
|
|
125
485
|
import { useAggClient, useDepositAddresses } from "@agg-build/hooks";
|
|
126
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
486
|
+
import { useCallback as useCallback2, useEffect as useEffect2, useMemo, useRef as useRef2, useState } from "react";
|
|
127
487
|
var KYC_PENDING_STORAGE_KEY = "agg_kyc_pending";
|
|
128
488
|
var getKycPendingState = () => {
|
|
129
489
|
var _a, _b;
|
|
@@ -158,7 +518,7 @@ var useKalshiKycFlow = ({
|
|
|
158
518
|
const [showSuccessModal, setShowSuccessModal] = useState(false);
|
|
159
519
|
const [isInitiating, setIsInitiating] = useState(false);
|
|
160
520
|
const [needsDepositAddress, setNeedsDepositAddress] = useState(false);
|
|
161
|
-
const initiationAttemptRef =
|
|
521
|
+
const initiationAttemptRef = useRef2(0);
|
|
162
522
|
const { isReady, isTimedOut } = useDepositAddresses({ enabled: needsDepositAddress, poll: true });
|
|
163
523
|
const pendingState = useMemo(
|
|
164
524
|
() => ({
|
|
@@ -168,28 +528,28 @@ var useKalshiKycFlow = ({
|
|
|
168
528
|
}),
|
|
169
529
|
[userId, walletAddress]
|
|
170
530
|
);
|
|
171
|
-
const resetInitiation =
|
|
531
|
+
const resetInitiation = useCallback2(() => {
|
|
172
532
|
setIsInitiating(false);
|
|
173
533
|
setNeedsDepositAddress(false);
|
|
174
534
|
}, []);
|
|
175
|
-
const closeVerifyModal =
|
|
535
|
+
const closeVerifyModal = useCallback2(() => {
|
|
176
536
|
initiationAttemptRef.current += 1;
|
|
177
537
|
clearKycPendingState();
|
|
178
538
|
resetInitiation();
|
|
179
539
|
setIsVerifyModalOpen(false);
|
|
180
540
|
}, [resetInitiation]);
|
|
181
|
-
const closeSuccessModal =
|
|
541
|
+
const closeSuccessModal = useCallback2(() => {
|
|
182
542
|
setShowSuccessModal(false);
|
|
183
543
|
}, []);
|
|
184
|
-
const openVerifyModal =
|
|
544
|
+
const openVerifyModal = useCallback2(() => {
|
|
185
545
|
setIsVerifyModalOpen(true);
|
|
186
546
|
}, []);
|
|
187
|
-
const startVerification =
|
|
547
|
+
const startVerification = useCallback2(() => {
|
|
188
548
|
initiationAttemptRef.current += 1;
|
|
189
549
|
setIsInitiating(true);
|
|
190
550
|
setNeedsDepositAddress(true);
|
|
191
551
|
}, []);
|
|
192
|
-
|
|
552
|
+
useEffect2(() => {
|
|
193
553
|
if (!isInitiating || !isReady) return;
|
|
194
554
|
const attemptId = initiationAttemptRef.current;
|
|
195
555
|
const redirectUri = window.location.href;
|
|
@@ -206,14 +566,14 @@ var useKalshiKycFlow = ({
|
|
|
206
566
|
resetInitiation();
|
|
207
567
|
});
|
|
208
568
|
}, [client, isInitiating, isReady, onError, pendingState, resetInitiation]);
|
|
209
|
-
|
|
569
|
+
useEffect2(() => {
|
|
210
570
|
if (isTimedOut && isInitiating) {
|
|
211
571
|
clearKycPendingState();
|
|
212
572
|
resetInitiation();
|
|
213
573
|
onError == null ? void 0 : onError(new Error("Deposit address provisioning timed out"));
|
|
214
574
|
}
|
|
215
575
|
}, [isInitiating, isTimedOut, onError, resetInitiation]);
|
|
216
|
-
|
|
576
|
+
useEffect2(() => {
|
|
217
577
|
const storedPendingState = getKycPendingState();
|
|
218
578
|
const isMatchingSession = (storedPendingState == null ? void 0 : storedPendingState.venue) === "kalshi" && storedPendingState.userId === pendingState.userId && storedPendingState.walletAddress === pendingState.walletAddress;
|
|
219
579
|
if (isKalshiVerified && isMatchingSession) {
|
|
@@ -1803,7 +2163,7 @@ var isPercentageBelowMinimum = (value, minimumValue) => {
|
|
|
1803
2163
|
};
|
|
1804
2164
|
|
|
1805
2165
|
// src/trading/place-order/index.place-order.failure.tsx
|
|
1806
|
-
import { jsx as
|
|
2166
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1807
2167
|
var resolveFailureActionHandler = ({
|
|
1808
2168
|
action,
|
|
1809
2169
|
onDone,
|
|
@@ -1816,12 +2176,12 @@ var resolveFailureActionHandler = ({
|
|
|
1816
2176
|
};
|
|
1817
2177
|
var renderPartialFailureStep = (step) => {
|
|
1818
2178
|
const isWarningStep = step.tone === "warning" || step.tone === "error";
|
|
1819
|
-
return /* @__PURE__ */
|
|
2179
|
+
return /* @__PURE__ */ jsxs2(
|
|
1820
2180
|
"div",
|
|
1821
2181
|
{
|
|
1822
2182
|
className: "flex items-center gap-2 text-agg-sm leading-agg-5 text-agg-foreground",
|
|
1823
2183
|
children: [
|
|
1824
|
-
/* @__PURE__ */
|
|
2184
|
+
/* @__PURE__ */ jsx3(
|
|
1825
2185
|
Icon,
|
|
1826
2186
|
{
|
|
1827
2187
|
name: isWarningStep ? "warning-filled" : "check-circle",
|
|
@@ -1830,8 +2190,8 @@ var renderPartialFailureStep = (step) => {
|
|
|
1830
2190
|
"aria-hidden": "true"
|
|
1831
2191
|
}
|
|
1832
2192
|
),
|
|
1833
|
-
/* @__PURE__ */
|
|
1834
|
-
step.venue ? /* @__PURE__ */
|
|
2193
|
+
/* @__PURE__ */ jsx3("p", { className: "min-w-0 flex-1", children: step.label }),
|
|
2194
|
+
step.venue ? /* @__PURE__ */ jsx3(VenueLogo, { venue: step.venue, size: "small", className: "h-4 w-4 shrink-0" }) : null
|
|
1835
2195
|
]
|
|
1836
2196
|
},
|
|
1837
2197
|
step.id
|
|
@@ -1850,10 +2210,10 @@ var PlaceOrderFailureView = ({
|
|
|
1850
2210
|
const shouldShowPartialFailureLayout = summary.kind === "partial_fill";
|
|
1851
2211
|
const failureStepGroups = shouldShowPartialFailureLayout ? groupPlaceOrderFailureSteps(summary.steps) : [];
|
|
1852
2212
|
if (shouldShowPartialFailureLayout) {
|
|
1853
|
-
return /* @__PURE__ */
|
|
1854
|
-
/* @__PURE__ */
|
|
1855
|
-
/* @__PURE__ */
|
|
1856
|
-
/* @__PURE__ */
|
|
2213
|
+
return /* @__PURE__ */ jsx3(Card, { className: cn("group/agg-order-panel", getPlaceOrderContainerClassName(), className), children: /* @__PURE__ */ jsxs2("div", { className: "agg-order-failure-body flex flex-col gap-6 p-5", children: [
|
|
2214
|
+
/* @__PURE__ */ jsxs2("div", { className: "agg-order-failure-header flex flex-col gap-2", children: [
|
|
2215
|
+
/* @__PURE__ */ jsxs2("div", { className: "agg-order-failure-market flex items-center gap-3", children: [
|
|
2216
|
+
/* @__PURE__ */ jsx3(
|
|
1857
2217
|
RemoteImage,
|
|
1858
2218
|
{
|
|
1859
2219
|
src: (_a = summary.eventImage) != null ? _a : null,
|
|
@@ -1861,12 +2221,12 @@ var PlaceOrderFailureView = ({
|
|
|
1861
2221
|
className: "h-12 w-12 shrink-0 overflow-hidden rounded-agg-lg object-cover"
|
|
1862
2222
|
}
|
|
1863
2223
|
),
|
|
1864
|
-
/* @__PURE__ */
|
|
2224
|
+
/* @__PURE__ */ jsx3("p", { className: "min-w-0 flex-1 text-agg-base font-agg-bold leading-agg-6 text-agg-foreground line-clamp-2", children: summary.eventTitle })
|
|
1865
2225
|
] }),
|
|
1866
|
-
summary.eventSubtitle ? /* @__PURE__ */
|
|
2226
|
+
summary.eventSubtitle ? /* @__PURE__ */ jsx3("p", { className: "text-agg-base leading-agg-6 text-agg-foreground", children: summary.eventSubtitle }) : null
|
|
1867
2227
|
] }),
|
|
1868
|
-
/* @__PURE__ */
|
|
1869
|
-
/* @__PURE__ */
|
|
2228
|
+
/* @__PURE__ */ jsx3("div", { className: "flex flex-col gap-4", children: failureStepGroups.map((group, groupIndex) => /* @__PURE__ */ jsx3("div", { className: "flex flex-col gap-2", children: group.map((step) => renderPartialFailureStep(step)) }, `failure-group-${groupIndex}`)) }),
|
|
2229
|
+
/* @__PURE__ */ jsx3("div", { className: "flex items-center gap-4", children: summary.actions.map((action) => /* @__PURE__ */ jsx3(
|
|
1870
2230
|
Button,
|
|
1871
2231
|
{
|
|
1872
2232
|
variant: "tertiary",
|
|
@@ -1880,10 +2240,10 @@ var PlaceOrderFailureView = ({
|
|
|
1880
2240
|
)) })
|
|
1881
2241
|
] }) });
|
|
1882
2242
|
}
|
|
1883
|
-
return /* @__PURE__ */
|
|
1884
|
-
/* @__PURE__ */
|
|
1885
|
-
/* @__PURE__ */
|
|
1886
|
-
/* @__PURE__ */
|
|
2243
|
+
return /* @__PURE__ */ jsx3(Card, { className: cn("group/agg-order-panel", getPlaceOrderContainerClassName(), className), children: /* @__PURE__ */ jsxs2("div", { className: "agg-order-failure-body flex flex-col gap-6 p-5", children: [
|
|
2244
|
+
/* @__PURE__ */ jsxs2("div", { className: "agg-order-failure-header flex flex-col gap-2", children: [
|
|
2245
|
+
/* @__PURE__ */ jsxs2("div", { className: "agg-order-failure-market flex items-center gap-3", children: [
|
|
2246
|
+
/* @__PURE__ */ jsx3(
|
|
1887
2247
|
RemoteImage,
|
|
1888
2248
|
{
|
|
1889
2249
|
src: (_b = summary.eventImage) != null ? _b : null,
|
|
@@ -1891,11 +2251,11 @@ var PlaceOrderFailureView = ({
|
|
|
1891
2251
|
className: "h-12 w-12 shrink-0 overflow-hidden rounded-agg-lg object-cover"
|
|
1892
2252
|
}
|
|
1893
2253
|
),
|
|
1894
|
-
/* @__PURE__ */
|
|
2254
|
+
/* @__PURE__ */ jsx3("p", { className: "min-w-0 flex-1 text-agg-base font-agg-bold leading-agg-6 text-agg-foreground line-clamp-2", children: summary.eventTitle })
|
|
1895
2255
|
] }),
|
|
1896
|
-
summary.eventSubtitle ? /* @__PURE__ */
|
|
2256
|
+
summary.eventSubtitle ? /* @__PURE__ */ jsx3("p", { className: "text-agg-base leading-agg-6 text-agg-foreground", children: summary.eventSubtitle }) : null
|
|
1897
2257
|
] }),
|
|
1898
|
-
/* @__PURE__ */
|
|
2258
|
+
/* @__PURE__ */ jsx3(
|
|
1899
2259
|
InlineAlert,
|
|
1900
2260
|
{
|
|
1901
2261
|
tone: "error",
|
|
@@ -1904,7 +2264,7 @@ var PlaceOrderFailureView = ({
|
|
|
1904
2264
|
message: tradingLabels.orderFailureDescription((_c = summary.errorMessage) != null ? _c : "")
|
|
1905
2265
|
}
|
|
1906
2266
|
),
|
|
1907
|
-
/* @__PURE__ */
|
|
2267
|
+
/* @__PURE__ */ jsx3("div", { className: "agg-order-failure-actions flex items-center gap-3", children: summary.actions.map((action) => /* @__PURE__ */ jsx3(
|
|
1908
2268
|
Button,
|
|
1909
2269
|
{
|
|
1910
2270
|
variant: action.variant === "retry" ? "primary" : "secondary",
|
|
@@ -1922,7 +2282,7 @@ PlaceOrderFailureView.displayName = "PlaceOrderFailureView";
|
|
|
1922
2282
|
|
|
1923
2283
|
// src/trading/place-order/index.place-order.success.tsx
|
|
1924
2284
|
import { useState as useState2 } from "react";
|
|
1925
|
-
import { jsx as
|
|
2285
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1926
2286
|
var resolveBuyToWinLabel = (shares) => {
|
|
1927
2287
|
if (!shares) return "$0";
|
|
1928
2288
|
return shares.startsWith("$") ? shares : `$${shares}`;
|
|
@@ -1953,10 +2313,10 @@ var PlaceOrderSuccessView = ({
|
|
|
1953
2313
|
const resolveStepIconClassName = (tone) => {
|
|
1954
2314
|
return tone === "warning" || tone === "error" ? "text-agg-warning" : "text-agg-primary";
|
|
1955
2315
|
};
|
|
1956
|
-
return /* @__PURE__ */
|
|
1957
|
-
summary.eventTitle ? /* @__PURE__ */
|
|
1958
|
-
/* @__PURE__ */
|
|
1959
|
-
/* @__PURE__ */
|
|
2316
|
+
return /* @__PURE__ */ jsx4(Card, { className: cn("group/agg-order-panel", getPlaceOrderContainerClassName(), className), children: /* @__PURE__ */ jsxs3("div", { className: "agg-order-success-body flex flex-col gap-6 p-5", children: [
|
|
2317
|
+
summary.eventTitle ? /* @__PURE__ */ jsxs3("div", { className: "agg-order-success-header flex flex-col gap-2", children: [
|
|
2318
|
+
/* @__PURE__ */ jsxs3("div", { className: "agg-order-success-market flex items-center gap-3", children: [
|
|
2319
|
+
/* @__PURE__ */ jsx4(
|
|
1960
2320
|
RemoteImage,
|
|
1961
2321
|
{
|
|
1962
2322
|
src: (_h = summary.eventImage) != null ? _h : null,
|
|
@@ -1964,12 +2324,12 @@ var PlaceOrderSuccessView = ({
|
|
|
1964
2324
|
className: "h-12 w-12 shrink-0 overflow-hidden rounded-agg-lg object-cover"
|
|
1965
2325
|
}
|
|
1966
2326
|
),
|
|
1967
|
-
/* @__PURE__ */
|
|
2327
|
+
/* @__PURE__ */ jsx4("p", { className: "min-w-0 flex-1 text-agg-base font-agg-bold leading-agg-6 text-agg-foreground line-clamp-2", children: summary.eventTitle })
|
|
1968
2328
|
] }),
|
|
1969
|
-
summary.eventDateLabel ? /* @__PURE__ */
|
|
2329
|
+
summary.eventDateLabel ? /* @__PURE__ */ jsx4("p", { className: "text-agg-base leading-agg-6 text-agg-foreground", children: summary.eventDateLabel }) : null
|
|
1970
2330
|
] }) : null,
|
|
1971
|
-
executionStepGroups.length > 0 ? /* @__PURE__ */
|
|
1972
|
-
/* @__PURE__ */
|
|
2331
|
+
executionStepGroups.length > 0 ? /* @__PURE__ */ jsxs3("div", { className: "agg-order-success-timeline flex flex-col gap-2", children: [
|
|
2332
|
+
/* @__PURE__ */ jsx4(
|
|
1973
2333
|
"div",
|
|
1974
2334
|
{
|
|
1975
2335
|
"aria-hidden": !isExecutionDetailsExpanded,
|
|
@@ -1982,12 +2342,12 @@ var PlaceOrderSuccessView = ({
|
|
|
1982
2342
|
"transition-[grid-template-rows,opacity] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"
|
|
1983
2343
|
)
|
|
1984
2344
|
),
|
|
1985
|
-
children: /* @__PURE__ */
|
|
2345
|
+
children: /* @__PURE__ */ jsx4("div", { className: "min-h-0", children: /* @__PURE__ */ jsx4("div", { className: "flex flex-col gap-4 pb-2", children: detailedStepGroups.map((group, groupIndex) => /* @__PURE__ */ jsx4("div", { className: "flex flex-col gap-2", children: group.map((step) => /* @__PURE__ */ jsxs3(
|
|
1986
2346
|
"div",
|
|
1987
2347
|
{
|
|
1988
2348
|
className: "flex items-center gap-2 text-agg-sm leading-agg-5 text-agg-foreground",
|
|
1989
2349
|
children: [
|
|
1990
|
-
/* @__PURE__ */
|
|
2350
|
+
/* @__PURE__ */ jsx4(
|
|
1991
2351
|
Icon,
|
|
1992
2352
|
{
|
|
1993
2353
|
name: resolveStepIconName(step.tone),
|
|
@@ -1996,8 +2356,8 @@ var PlaceOrderSuccessView = ({
|
|
|
1996
2356
|
"aria-hidden": "true"
|
|
1997
2357
|
}
|
|
1998
2358
|
),
|
|
1999
|
-
/* @__PURE__ */
|
|
2000
|
-
step.venue ? /* @__PURE__ */
|
|
2359
|
+
/* @__PURE__ */ jsx4("p", { className: "min-w-0 flex-1", children: step.label }),
|
|
2360
|
+
step.venue ? /* @__PURE__ */ jsx4(
|
|
2001
2361
|
VenueLogo,
|
|
2002
2362
|
{
|
|
2003
2363
|
venue: step.venue,
|
|
@@ -2011,7 +2371,7 @@ var PlaceOrderSuccessView = ({
|
|
|
2011
2371
|
)) }, `execution-group-${groupIndex}`)) }) })
|
|
2012
2372
|
}
|
|
2013
2373
|
),
|
|
2014
|
-
finalStep ? hasExecutionDetails ? /* @__PURE__ */
|
|
2374
|
+
finalStep ? hasExecutionDetails ? /* @__PURE__ */ jsxs3(
|
|
2015
2375
|
"button",
|
|
2016
2376
|
{
|
|
2017
2377
|
type: "button",
|
|
@@ -2023,7 +2383,7 @@ var PlaceOrderSuccessView = ({
|
|
|
2023
2383
|
),
|
|
2024
2384
|
onClick: () => setIsExecutionDetailsExpanded((currentValue) => !currentValue),
|
|
2025
2385
|
children: [
|
|
2026
|
-
/* @__PURE__ */
|
|
2386
|
+
/* @__PURE__ */ jsx4(
|
|
2027
2387
|
Icon,
|
|
2028
2388
|
{
|
|
2029
2389
|
name: resolveStepIconName(finalStep.tone),
|
|
@@ -2032,8 +2392,8 @@ var PlaceOrderSuccessView = ({
|
|
|
2032
2392
|
"aria-hidden": "true"
|
|
2033
2393
|
}
|
|
2034
2394
|
),
|
|
2035
|
-
/* @__PURE__ */
|
|
2036
|
-
/* @__PURE__ */
|
|
2395
|
+
/* @__PURE__ */ jsx4("p", { className: "min-w-0 flex-1", children: finalStep.label }),
|
|
2396
|
+
/* @__PURE__ */ jsx4(
|
|
2037
2397
|
Icon,
|
|
2038
2398
|
{
|
|
2039
2399
|
name: isExecutionDetailsExpanded ? "chevron-up" : "chevron-down",
|
|
@@ -2044,8 +2404,8 @@ var PlaceOrderSuccessView = ({
|
|
|
2044
2404
|
)
|
|
2045
2405
|
]
|
|
2046
2406
|
}
|
|
2047
|
-
) : /* @__PURE__ */
|
|
2048
|
-
/* @__PURE__ */
|
|
2407
|
+
) : /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2 text-agg-sm leading-agg-5 text-agg-foreground", children: [
|
|
2408
|
+
/* @__PURE__ */ jsx4(
|
|
2049
2409
|
Icon,
|
|
2050
2410
|
{
|
|
2051
2411
|
name: resolveStepIconName(finalStep.tone),
|
|
@@ -2054,34 +2414,34 @@ var PlaceOrderSuccessView = ({
|
|
|
2054
2414
|
"aria-hidden": "true"
|
|
2055
2415
|
}
|
|
2056
2416
|
),
|
|
2057
|
-
/* @__PURE__ */
|
|
2417
|
+
/* @__PURE__ */ jsx4("p", { className: "min-w-0 flex-1", children: finalStep.label })
|
|
2058
2418
|
] }) : null
|
|
2059
2419
|
] }) : null,
|
|
2060
|
-
/* @__PURE__ */
|
|
2420
|
+
/* @__PURE__ */ jsxs3(
|
|
2061
2421
|
"div",
|
|
2062
2422
|
{
|
|
2063
2423
|
className: cn(
|
|
2064
2424
|
"agg-order-success-pill flex min-h-12 w-full items-center justify-center gap-2 rounded-agg-full px-6 py-2.5 text-center text-agg-base font-agg-bold leading-agg-6 text-agg-on-primary bg-agg-success"
|
|
2065
2425
|
),
|
|
2066
2426
|
children: [
|
|
2067
|
-
/* @__PURE__ */
|
|
2068
|
-
/* @__PURE__ */
|
|
2427
|
+
/* @__PURE__ */ jsx4(Icon, { name: "success-check", size: "small", className: "h-4 w-4 shrink-0 text-current" }),
|
|
2428
|
+
/* @__PURE__ */ jsx4("span", { children: resolvedActionLabel })
|
|
2069
2429
|
]
|
|
2070
2430
|
}
|
|
2071
2431
|
),
|
|
2072
|
-
/* @__PURE__ */
|
|
2073
|
-
/* @__PURE__ */
|
|
2074
|
-
/* @__PURE__ */
|
|
2432
|
+
/* @__PURE__ */ jsxs3("div", { className: "agg-order-success-summary flex items-center justify-between gap-4", children: [
|
|
2433
|
+
/* @__PURE__ */ jsx4("p", { className: "text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: tradingLabels.amount(resolvedTradeSide) }),
|
|
2434
|
+
/* @__PURE__ */ jsx4("p", { className: "text-right text-[30px] font-agg-bold leading-[36px] text-agg-foreground", children: resolvedAmountLabel })
|
|
2075
2435
|
] }),
|
|
2076
|
-
/* @__PURE__ */
|
|
2077
|
-
/* @__PURE__ */
|
|
2078
|
-
/* @__PURE__ */
|
|
2436
|
+
/* @__PURE__ */ jsxs3("div", { className: "agg-order-success-summary flex items-center justify-between gap-4", children: [
|
|
2437
|
+
/* @__PURE__ */ jsx4("p", { className: "text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: tradingLabels.toWin(resolvedTradeSide) }),
|
|
2438
|
+
/* @__PURE__ */ jsx4("p", { className: "text-right text-[30px] font-agg-bold leading-[36px] text-agg-success", children: resolvedToWinLabel })
|
|
2079
2439
|
] }),
|
|
2080
|
-
summary.potentialReturnLabel ? /* @__PURE__ */
|
|
2081
|
-
/* @__PURE__ */
|
|
2082
|
-
/* @__PURE__ */
|
|
2440
|
+
summary.potentialReturnLabel ? /* @__PURE__ */ jsxs3("div", { className: "flex w-full flex-col items-center justify-center gap-1 overflow-hidden rounded-agg-lg border border-agg-primary/50 bg-gradient-to-b from-agg-primary/8 to-agg-primary/15 p-3 text-center", children: [
|
|
2441
|
+
/* @__PURE__ */ jsx4("p", { className: "bg-gradient-to-r from-agg-primary to-agg-primary-hover bg-clip-text text-agg-lg font-agg-bold leading-[28px] text-transparent", children: potentialReturnLabel }),
|
|
2442
|
+
/* @__PURE__ */ jsx4("p", { className: "text-agg-xs leading-agg-4 text-agg-foreground", children: (_i = tradingLabels.withSmartRouting) != null ? _i : "with Smart Routing" })
|
|
2083
2443
|
] }) : null,
|
|
2084
|
-
/* @__PURE__ */
|
|
2444
|
+
/* @__PURE__ */ jsx4("div", { className: "agg-order-success-actions flex gap-3", children: /* @__PURE__ */ jsx4(
|
|
2085
2445
|
Button,
|
|
2086
2446
|
{
|
|
2087
2447
|
variant: "secondary",
|
|
@@ -2097,7 +2457,23 @@ var PlaceOrderSuccessView = ({
|
|
|
2097
2457
|
PlaceOrderSuccessView.displayName = "PlaceOrderSuccessView";
|
|
2098
2458
|
|
|
2099
2459
|
// src/trading/place-order/index.tsx
|
|
2100
|
-
import { Fragment as
|
|
2460
|
+
import { Fragment as Fragment3, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
2461
|
+
var SELL_SHARE_INPUT_DECIMALS = 6;
|
|
2462
|
+
var SELL_SHARE_DISPLAY_DECIMALS = 2;
|
|
2463
|
+
var floorToDecimals = (value, decimals) => {
|
|
2464
|
+
if (!Number.isFinite(value) || value <= 0) return 0;
|
|
2465
|
+
const scale = __pow(10, decimals);
|
|
2466
|
+
return Math.trunc(value * scale) / scale;
|
|
2467
|
+
};
|
|
2468
|
+
var formatFlooredShareAmount = (value, decimals) => {
|
|
2469
|
+
const flooredValue = floorToDecimals(value, decimals);
|
|
2470
|
+
if (flooredValue <= 0) return "0";
|
|
2471
|
+
const formattedValue = flooredValue.toLocaleString("en-US", {
|
|
2472
|
+
minimumFractionDigits: 0,
|
|
2473
|
+
maximumFractionDigits: decimals
|
|
2474
|
+
});
|
|
2475
|
+
return formattedValue.replace(/(\.\d*?[1-9])0+$/u, "$1").replace(/\.0+$/u, "");
|
|
2476
|
+
};
|
|
2101
2477
|
var resolveRefetchedQuoteData = (result) => {
|
|
2102
2478
|
if (!result || typeof result !== "object" || !("data" in result)) return null;
|
|
2103
2479
|
const data = result.data;
|
|
@@ -2116,7 +2492,7 @@ var LoadingGlyph = ({
|
|
|
2116
2492
|
className,
|
|
2117
2493
|
enableAnimations
|
|
2118
2494
|
}) => {
|
|
2119
|
-
return /* @__PURE__ */
|
|
2495
|
+
return /* @__PURE__ */ jsx5(
|
|
2120
2496
|
"span",
|
|
2121
2497
|
{
|
|
2122
2498
|
"aria-hidden": "true",
|
|
@@ -2137,9 +2513,9 @@ var PlaceOrderSlippageControl = ({
|
|
|
2137
2513
|
}) => {
|
|
2138
2514
|
var _a, _b;
|
|
2139
2515
|
const labels = useLabels();
|
|
2140
|
-
const containerRef =
|
|
2141
|
-
const triggerRef =
|
|
2142
|
-
const inputRef =
|
|
2516
|
+
const containerRef = useRef3(null);
|
|
2517
|
+
const triggerRef = useRef3(null);
|
|
2518
|
+
const inputRef = useRef3(null);
|
|
2143
2519
|
const warningId = useId();
|
|
2144
2520
|
const defaultValue = finalizePercentageValue(slippageDefaultValue);
|
|
2145
2521
|
const committedValue = finalizePercentageValue(slippageValue) || defaultValue;
|
|
@@ -2148,13 +2524,13 @@ var PlaceOrderSlippageControl = ({
|
|
|
2148
2524
|
() => isPercentageBelowMinimum(committedValue, slippageMinimumValue)
|
|
2149
2525
|
);
|
|
2150
2526
|
const [shouldFocusInput, setShouldFocusInput] = useState3(false);
|
|
2151
|
-
|
|
2527
|
+
useEffect3(() => {
|
|
2152
2528
|
setDraftValue(committedValue);
|
|
2153
2529
|
if (isPercentageBelowMinimum(committedValue, slippageMinimumValue)) {
|
|
2154
2530
|
setIsEditing(true);
|
|
2155
2531
|
}
|
|
2156
2532
|
}, [committedValue, slippageMinimumValue]);
|
|
2157
|
-
|
|
2533
|
+
useEffect3(() => {
|
|
2158
2534
|
if (!shouldFocusInput) return;
|
|
2159
2535
|
requestAnimationFrame(() => {
|
|
2160
2536
|
var _a2, _b2;
|
|
@@ -2234,8 +2610,8 @@ var PlaceOrderSlippageControl = ({
|
|
|
2234
2610
|
if (!isEditing) return;
|
|
2235
2611
|
handleCommitDraft(false);
|
|
2236
2612
|
};
|
|
2237
|
-
return /* @__PURE__ */
|
|
2238
|
-
/* @__PURE__ */
|
|
2613
|
+
return /* @__PURE__ */ jsxs4("div", { ref: containerRef, className: "agg-slippage-control w-full", onBlur: handleContainerBlur, children: [
|
|
2614
|
+
/* @__PURE__ */ jsxs4(
|
|
2239
2615
|
"button",
|
|
2240
2616
|
{
|
|
2241
2617
|
ref: triggerRef,
|
|
@@ -2253,8 +2629,8 @@ var PlaceOrderSlippageControl = ({
|
|
|
2253
2629
|
),
|
|
2254
2630
|
onClick: handleToggleEditing,
|
|
2255
2631
|
children: [
|
|
2256
|
-
/* @__PURE__ */
|
|
2257
|
-
/* @__PURE__ */
|
|
2632
|
+
/* @__PURE__ */ jsx5("span", { className: "agg-slippage-label", children: collapsedLabel }),
|
|
2633
|
+
/* @__PURE__ */ jsx5(
|
|
2258
2634
|
Icon,
|
|
2259
2635
|
{
|
|
2260
2636
|
name: isEditing ? "chevron-up" : "pencil",
|
|
@@ -2266,7 +2642,7 @@ var PlaceOrderSlippageControl = ({
|
|
|
2266
2642
|
]
|
|
2267
2643
|
}
|
|
2268
2644
|
),
|
|
2269
|
-
/* @__PURE__ */
|
|
2645
|
+
/* @__PURE__ */ jsx5(
|
|
2270
2646
|
"div",
|
|
2271
2647
|
{
|
|
2272
2648
|
"aria-hidden": !isEditing,
|
|
@@ -2280,10 +2656,10 @@ var PlaceOrderSlippageControl = ({
|
|
|
2280
2656
|
"transition-[grid-template-rows,opacity,margin-top] duration-300 ease-[cubic-bezier(0.22,1,0.36,1)]"
|
|
2281
2657
|
)
|
|
2282
2658
|
),
|
|
2283
|
-
children: /* @__PURE__ */
|
|
2284
|
-
/* @__PURE__ */
|
|
2285
|
-
/* @__PURE__ */
|
|
2286
|
-
/* @__PURE__ */
|
|
2659
|
+
children: /* @__PURE__ */ jsx5("div", { className: "min-h-0", children: /* @__PURE__ */ jsxs4("div", { className: "agg-slippage-editor-body flex flex-col gap-2", children: [
|
|
2660
|
+
/* @__PURE__ */ jsxs4("div", { className: "agg-slippage-input-row flex h-9 overflow-hidden rounded-agg-sm border border-agg-separator", children: [
|
|
2661
|
+
/* @__PURE__ */ jsxs4("div", { className: "agg-slippage-input-group flex min-w-0 flex-1 items-center gap-2 bg-agg-secondary px-3", children: [
|
|
2662
|
+
/* @__PURE__ */ jsx5(
|
|
2287
2663
|
"input",
|
|
2288
2664
|
{
|
|
2289
2665
|
ref: inputRef,
|
|
@@ -2298,7 +2674,7 @@ var PlaceOrderSlippageControl = ({
|
|
|
2298
2674
|
onKeyDown: handleInputKeyDown
|
|
2299
2675
|
}
|
|
2300
2676
|
),
|
|
2301
|
-
/* @__PURE__ */
|
|
2677
|
+
/* @__PURE__ */ jsx5(
|
|
2302
2678
|
"button",
|
|
2303
2679
|
{
|
|
2304
2680
|
type: "button",
|
|
@@ -2316,8 +2692,8 @@ var PlaceOrderSlippageControl = ({
|
|
|
2316
2692
|
}
|
|
2317
2693
|
)
|
|
2318
2694
|
] }),
|
|
2319
|
-
/* @__PURE__ */
|
|
2320
|
-
/* @__PURE__ */
|
|
2695
|
+
/* @__PURE__ */ jsx5("div", { className: "h-full w-px bg-agg-separator", "aria-hidden": "true" }),
|
|
2696
|
+
/* @__PURE__ */ jsx5(
|
|
2321
2697
|
"div",
|
|
2322
2698
|
{
|
|
2323
2699
|
className: "agg-slippage-suffix flex w-9 items-center justify-center bg-agg-secondary-hover text-agg-sm leading-agg-5 text-agg-muted-foreground",
|
|
@@ -2326,7 +2702,7 @@ var PlaceOrderSlippageControl = ({
|
|
|
2326
2702
|
}
|
|
2327
2703
|
)
|
|
2328
2704
|
] }),
|
|
2329
|
-
/* @__PURE__ */
|
|
2705
|
+
/* @__PURE__ */ jsx5(
|
|
2330
2706
|
"div",
|
|
2331
2707
|
{
|
|
2332
2708
|
"aria-hidden": !resolvedWarningMessage,
|
|
@@ -2340,13 +2716,13 @@ var PlaceOrderSlippageControl = ({
|
|
|
2340
2716
|
"transition-[grid-template-rows,opacity] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"
|
|
2341
2717
|
)
|
|
2342
2718
|
),
|
|
2343
|
-
children: /* @__PURE__ */
|
|
2719
|
+
children: /* @__PURE__ */ jsx5("div", { className: "min-h-0", children: /* @__PURE__ */ jsxs4(
|
|
2344
2720
|
"div",
|
|
2345
2721
|
{
|
|
2346
2722
|
id: warningId,
|
|
2347
2723
|
className: "agg-slippage-warning-message flex items-start gap-2 text-agg-sm leading-agg-5 text-agg-foreground",
|
|
2348
2724
|
children: [
|
|
2349
|
-
/* @__PURE__ */
|
|
2725
|
+
/* @__PURE__ */ jsx5(
|
|
2350
2726
|
Icon,
|
|
2351
2727
|
{
|
|
2352
2728
|
name: "warning-filled",
|
|
@@ -2355,7 +2731,7 @@ var PlaceOrderSlippageControl = ({
|
|
|
2355
2731
|
color: "currentColor"
|
|
2356
2732
|
}
|
|
2357
2733
|
),
|
|
2358
|
-
/* @__PURE__ */
|
|
2734
|
+
/* @__PURE__ */ jsx5("p", { children: resolvedWarningMessage != null ? resolvedWarningMessage : "" })
|
|
2359
2735
|
]
|
|
2360
2736
|
}
|
|
2361
2737
|
) })
|
|
@@ -2375,9 +2751,9 @@ var renderCardHeader = ({
|
|
|
2375
2751
|
onClose
|
|
2376
2752
|
}) => {
|
|
2377
2753
|
if (!headerTitle) return null;
|
|
2378
|
-
return /* @__PURE__ */
|
|
2379
|
-
/* @__PURE__ */
|
|
2380
|
-
/* @__PURE__ */
|
|
2754
|
+
return /* @__PURE__ */ jsxs4("div", { className: cn("agg-order-panel-header flex flex-col gap-2", className), children: [
|
|
2755
|
+
/* @__PURE__ */ jsxs4("div", { className: "agg-order-market-summary flex items-center gap-3", children: [
|
|
2756
|
+
/* @__PURE__ */ jsx5(
|
|
2381
2757
|
RemoteImage,
|
|
2382
2758
|
{
|
|
2383
2759
|
src: headerImage,
|
|
@@ -2385,32 +2761,78 @@ var renderCardHeader = ({
|
|
|
2385
2761
|
className: "agg-order-market-image h-12 w-12 shrink-0 overflow-hidden rounded-agg-lg object-cover"
|
|
2386
2762
|
}
|
|
2387
2763
|
),
|
|
2388
|
-
/* @__PURE__ */
|
|
2389
|
-
onClose ? /* @__PURE__ */
|
|
2764
|
+
/* @__PURE__ */ jsx5("p", { className: "agg-order-market-title min-w-0 flex-1 text-agg-base font-agg-bold leading-agg-6 text-agg-foreground line-clamp-2", children: headerTitle }),
|
|
2765
|
+
onClose ? /* @__PURE__ */ jsx5(
|
|
2390
2766
|
"button",
|
|
2391
2767
|
{
|
|
2392
2768
|
type: "button",
|
|
2393
2769
|
className: "agg-order-close -mr-1 -mt-1 hidden shrink-0 cursor-pointer items-center justify-center p-1 text-agg-muted-foreground hover:text-agg-foreground sm:flex",
|
|
2394
2770
|
"aria-label": "Close",
|
|
2395
2771
|
onClick: onClose,
|
|
2396
|
-
children: /* @__PURE__ */
|
|
2772
|
+
children: /* @__PURE__ */ jsx5(CloseIcon, { className: "h-5 w-5" })
|
|
2397
2773
|
}
|
|
2398
2774
|
) : null
|
|
2399
2775
|
] }),
|
|
2400
|
-
headerSubtitle ? /* @__PURE__ */
|
|
2776
|
+
headerSubtitle ? /* @__PURE__ */ jsx5("p", { className: "agg-order-market-subtitle text-agg-base leading-agg-6 text-agg-foreground", children: headerSubtitle }) : null
|
|
2401
2777
|
] });
|
|
2402
2778
|
};
|
|
2403
2779
|
var PlaceOrderResolvedView = ({
|
|
2404
2780
|
classNames,
|
|
2405
2781
|
tradingState,
|
|
2782
|
+
resolutionTimestamp,
|
|
2406
2783
|
resolvedClaim,
|
|
2407
|
-
className
|
|
2784
|
+
className,
|
|
2785
|
+
isSportsEvent = false
|
|
2408
2786
|
}) => {
|
|
2409
|
-
var _a
|
|
2787
|
+
var _a;
|
|
2410
2788
|
const labels = useLabels();
|
|
2411
2789
|
const tradingLabels = labels.trading;
|
|
2412
|
-
const
|
|
2413
|
-
|
|
2790
|
+
const resolvingTimestamp = (_a = resolutionTimestamp != null ? resolutionTimestamp : tradingState.resolvesAt) != null ? _a : tradingState.endsAt;
|
|
2791
|
+
const isResolvingMarket = false;
|
|
2792
|
+
const resolvingSubtitle = tradingState.market ? (() => {
|
|
2793
|
+
const endDateLabel = isSportsEvent ? formatSportsEventTimeEt(resolvingTimestamp != null ? resolvingTimestamp : "") : getTradingDateLabel(resolvingTimestamp != null ? resolvingTimestamp : "");
|
|
2794
|
+
return endDateLabel ? `${tradingState.market.question} \xB7 ${endDateLabel}` : tradingState.market.question;
|
|
2795
|
+
})() : "";
|
|
2796
|
+
if (isResolvingMarket) {
|
|
2797
|
+
return /* @__PURE__ */ jsx5(
|
|
2798
|
+
Card,
|
|
2799
|
+
{
|
|
2800
|
+
className: cn(
|
|
2801
|
+
"group/agg-order-panel",
|
|
2802
|
+
getPlaceOrderContainerClassName(),
|
|
2803
|
+
classNames == null ? void 0 : classNames.root,
|
|
2804
|
+
className
|
|
2805
|
+
),
|
|
2806
|
+
role: "status",
|
|
2807
|
+
"aria-label": labels.marketDetails.resolvingTitle,
|
|
2808
|
+
children: /* @__PURE__ */ jsxs4(
|
|
2809
|
+
"div",
|
|
2810
|
+
{
|
|
2811
|
+
className: cn(
|
|
2812
|
+
"agg-order-panel-body flex flex-col items-center justify-center gap-6 px-5 py-10 text-center",
|
|
2813
|
+
classNames == null ? void 0 : classNames.body
|
|
2814
|
+
),
|
|
2815
|
+
children: [
|
|
2816
|
+
/* @__PURE__ */ jsx5("div", { className: "flex h-[60px] w-[60px] items-center justify-center rounded-full bg-agg-primary/10", children: /* @__PURE__ */ jsx5(LoadingIcon, { variant: "prominent" }) }),
|
|
2817
|
+
/* @__PURE__ */ jsxs4("div", { className: cn("flex w-full flex-col items-center gap-1", classNames == null ? void 0 : classNames.content), children: [
|
|
2818
|
+
/* @__PURE__ */ jsx5(Typography, { variant: "body-large-strong", children: labels.marketDetails.resolvingTitle }),
|
|
2819
|
+
resolvingSubtitle ? /* @__PURE__ */ jsx5(Typography, { variant: "body", className: "text-center", children: resolvingSubtitle }) : null
|
|
2820
|
+
] }),
|
|
2821
|
+
/* @__PURE__ */ jsx5(
|
|
2822
|
+
Typography,
|
|
2823
|
+
{
|
|
2824
|
+
variant: "label",
|
|
2825
|
+
className: "max-w-[300px] text-center text-agg-muted-foreground",
|
|
2826
|
+
children: labels.marketDetails.resolvingDescription
|
|
2827
|
+
}
|
|
2828
|
+
)
|
|
2829
|
+
]
|
|
2830
|
+
}
|
|
2831
|
+
)
|
|
2832
|
+
}
|
|
2833
|
+
);
|
|
2834
|
+
}
|
|
2835
|
+
return /* @__PURE__ */ jsx5(
|
|
2414
2836
|
Card,
|
|
2415
2837
|
{
|
|
2416
2838
|
className: cn(
|
|
@@ -2419,19 +2841,19 @@ var PlaceOrderResolvedView = ({
|
|
|
2419
2841
|
classNames == null ? void 0 : classNames.root,
|
|
2420
2842
|
className
|
|
2421
2843
|
),
|
|
2422
|
-
children: /* @__PURE__ */
|
|
2423
|
-
/* @__PURE__ */
|
|
2424
|
-
/* @__PURE__ */
|
|
2844
|
+
children: /* @__PURE__ */ jsxs4("div", { className: cn("agg-order-panel-body flex flex-col", classNames == null ? void 0 : classNames.body), children: [
|
|
2845
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex flex-col items-center gap-6 p-8", children: [
|
|
2846
|
+
/* @__PURE__ */ jsx5(
|
|
2425
2847
|
"div",
|
|
2426
2848
|
{
|
|
2427
2849
|
className: cn(
|
|
2428
2850
|
"flex h-15 w-15 items-center justify-center rounded-full",
|
|
2429
2851
|
"bg-agg-primary/15"
|
|
2430
2852
|
),
|
|
2431
|
-
children: /* @__PURE__ */
|
|
2853
|
+
children: /* @__PURE__ */ jsx5(Icon, { name: "success-check", className: cn("h-6 w-6", "text-agg-primary") })
|
|
2432
2854
|
}
|
|
2433
2855
|
),
|
|
2434
|
-
/* @__PURE__ */
|
|
2856
|
+
/* @__PURE__ */ jsxs4(
|
|
2435
2857
|
"div",
|
|
2436
2858
|
{
|
|
2437
2859
|
className: cn(
|
|
@@ -2439,31 +2861,31 @@ var PlaceOrderResolvedView = ({
|
|
|
2439
2861
|
classNames == null ? void 0 : classNames.content
|
|
2440
2862
|
),
|
|
2441
2863
|
children: [
|
|
2442
|
-
tradingState.market ? /* @__PURE__ */
|
|
2443
|
-
tradingState.winningOutcome ? /* @__PURE__ */
|
|
2864
|
+
tradingState.market ? /* @__PURE__ */ jsx5(Typography, { variant: "body", className: "text-center", children: tradingState.market.question }) : null,
|
|
2865
|
+
tradingState.winningOutcome ? /* @__PURE__ */ jsx5(Typography, { variant: "body-large-strong", children: tradingLabels.outcome(tradingState.winningOutcome.label) }) : null
|
|
2444
2866
|
]
|
|
2445
2867
|
}
|
|
2446
2868
|
)
|
|
2447
2869
|
] }),
|
|
2448
|
-
resolvedClaim ? /* @__PURE__ */
|
|
2449
|
-
/* @__PURE__ */
|
|
2450
|
-
/* @__PURE__ */
|
|
2451
|
-
/* @__PURE__ */
|
|
2452
|
-
/* @__PURE__ */
|
|
2453
|
-
resolvedClaim.resolutionDateLabel ? /* @__PURE__ */
|
|
2454
|
-
/* @__PURE__ */
|
|
2455
|
-
/* @__PURE__ */
|
|
2870
|
+
resolvedClaim ? /* @__PURE__ */ jsxs4(Fragment3, { children: [
|
|
2871
|
+
/* @__PURE__ */ jsx5("div", { className: "h-px w-full bg-agg-separator" }),
|
|
2872
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex w-full flex-col gap-5 p-6", children: [
|
|
2873
|
+
/* @__PURE__ */ jsx5(Typography, { variant: "body-strong", className: "text-center", children: tradingLabels.resolvedEarningsTitle }),
|
|
2874
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-3 text-agg-sm leading-agg-5 text-agg-foreground", children: [
|
|
2875
|
+
resolvedClaim.resolutionDateLabel ? /* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between gap-4", children: [
|
|
2876
|
+
/* @__PURE__ */ jsx5("span", { children: tradingLabels.resolvedResolutionDateLabel }),
|
|
2877
|
+
/* @__PURE__ */ jsx5("span", { className: "font-agg-bold", children: resolvedClaim.resolutionDateLabel })
|
|
2456
2878
|
] }) : null,
|
|
2457
|
-
/* @__PURE__ */
|
|
2458
|
-
/* @__PURE__ */
|
|
2459
|
-
/* @__PURE__ */
|
|
2879
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between gap-4", children: [
|
|
2880
|
+
/* @__PURE__ */ jsx5("span", { children: tradingLabels.resolvedSharesLabel }),
|
|
2881
|
+
/* @__PURE__ */ jsx5("span", { className: "font-agg-bold", children: resolvedClaim.sharesLabel })
|
|
2460
2882
|
] }),
|
|
2461
|
-
/* @__PURE__ */
|
|
2462
|
-
/* @__PURE__ */
|
|
2463
|
-
/* @__PURE__ */
|
|
2883
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between gap-4", children: [
|
|
2884
|
+
/* @__PURE__ */ jsx5("span", { children: tradingLabels.resolvedTotalPayoutLabel }),
|
|
2885
|
+
/* @__PURE__ */ jsx5("span", { className: "font-agg-bold", children: resolvedClaim.totalPayoutLabel })
|
|
2464
2886
|
] })
|
|
2465
2887
|
] }),
|
|
2466
|
-
resolvedClaim.onClaim ? /* @__PURE__ */
|
|
2888
|
+
resolvedClaim.onClaim ? /* @__PURE__ */ jsx5(
|
|
2467
2889
|
Button,
|
|
2468
2890
|
{
|
|
2469
2891
|
size: "large",
|
|
@@ -2471,7 +2893,7 @@ var PlaceOrderResolvedView = ({
|
|
|
2471
2893
|
onClick: resolvedClaim.onClaim,
|
|
2472
2894
|
isLoading: resolvedClaim.isClaiming,
|
|
2473
2895
|
disabled: resolvedClaim.isClaiming,
|
|
2474
|
-
children:
|
|
2896
|
+
children: tradingLabels.claimWinnings
|
|
2475
2897
|
}
|
|
2476
2898
|
) : null
|
|
2477
2899
|
] })
|
|
@@ -2484,18 +2906,18 @@ var renderRouteBreakdownRow = (row) => {
|
|
|
2484
2906
|
var _a, _b;
|
|
2485
2907
|
const venueLabel = getTradingVenueLabel(row.venue);
|
|
2486
2908
|
const rowKey = `${row.venue}-${row.label}-${row.priceLabel}-${(_a = row.resultLabel) != null ? _a : ""}`;
|
|
2487
|
-
return /* @__PURE__ */
|
|
2909
|
+
return /* @__PURE__ */ jsxs4(
|
|
2488
2910
|
"div",
|
|
2489
2911
|
{
|
|
2490
2912
|
className: "agg-route-breakdown-row flex items-center justify-between gap-4 text-left",
|
|
2491
2913
|
children: [
|
|
2492
|
-
/* @__PURE__ */
|
|
2493
|
-
/* @__PURE__ */
|
|
2494
|
-
/* @__PURE__ */
|
|
2914
|
+
/* @__PURE__ */ jsxs4("div", { className: "agg-route-breakdown-market flex min-w-0 items-center gap-2", children: [
|
|
2915
|
+
/* @__PURE__ */ jsx5(VenueLogo, { venue: row.venue, className: "size-3!", ariaLabel: venueLabel }),
|
|
2916
|
+
/* @__PURE__ */ jsx5("p", { className: "agg-route-breakdown-label truncate text-agg-sm leading-agg-5 text-agg-foreground", children: row.label })
|
|
2495
2917
|
] }),
|
|
2496
|
-
/* @__PURE__ */
|
|
2497
|
-
/* @__PURE__ */
|
|
2498
|
-
/* @__PURE__ */
|
|
2918
|
+
/* @__PURE__ */ jsxs4("div", { className: "agg-route-breakdown-value flex shrink-0 items-center gap-2 text-agg-sm leading-agg-5", children: [
|
|
2919
|
+
/* @__PURE__ */ jsx5("p", { className: "text-agg-muted-foreground", children: row.priceLabel }),
|
|
2920
|
+
/* @__PURE__ */ jsx5("p", { className: "text-agg-foreground", children: (_b = row.resultLabel) != null ? _b : "" })
|
|
2499
2921
|
] })
|
|
2500
2922
|
]
|
|
2501
2923
|
},
|
|
@@ -2513,7 +2935,7 @@ var renderRouteCard = ({
|
|
|
2513
2935
|
var _a, _b;
|
|
2514
2936
|
const showSplitDetails = isSelected && isExpanded && card.kind === "split" && !!((_a = card.rows) == null ? void 0 : _a.length);
|
|
2515
2937
|
const ariaLabel = [card.label, card.hint, card.value].filter(Boolean).join(" ");
|
|
2516
|
-
return /* @__PURE__ */
|
|
2938
|
+
return /* @__PURE__ */ jsx5(
|
|
2517
2939
|
"button",
|
|
2518
2940
|
{
|
|
2519
2941
|
type: "button",
|
|
@@ -2532,10 +2954,10 @@ var renderRouteCard = ({
|
|
|
2532
2954
|
isSelected && !card.isUnavailable ? "border border-agg-trade-highlight-border bg-linear-to-b from-agg-trade-highlight-surface-from to-agg-trade-highlight-surface-to" : "border-transparent bg-agg-secondary-hover"
|
|
2533
2955
|
),
|
|
2534
2956
|
onClick: () => onSelect(card.id),
|
|
2535
|
-
children: /* @__PURE__ */
|
|
2536
|
-
/* @__PURE__ */
|
|
2537
|
-
/* @__PURE__ */
|
|
2538
|
-
card.kind === "split" ? /* @__PURE__ */
|
|
2957
|
+
children: /* @__PURE__ */ jsxs4("div", { className: "agg-route-card-content relative z-10 flex flex-col gap-3", children: [
|
|
2958
|
+
/* @__PURE__ */ jsxs4("div", { className: "agg-route-card-header flex items-center justify-between gap-4", children: [
|
|
2959
|
+
/* @__PURE__ */ jsxs4("div", { className: "agg-route-card-meta flex min-w-0 gap-3 items-center", children: [
|
|
2960
|
+
card.kind === "split" ? /* @__PURE__ */ jsx5(
|
|
2539
2961
|
Icon,
|
|
2540
2962
|
{
|
|
2541
2963
|
name: "sparkles-filled",
|
|
@@ -2546,7 +2968,7 @@ var renderRouteCard = ({
|
|
|
2546
2968
|
),
|
|
2547
2969
|
"aria-hidden": "true"
|
|
2548
2970
|
}
|
|
2549
|
-
) : card.venue ? /* @__PURE__ */
|
|
2971
|
+
) : card.venue ? /* @__PURE__ */ jsx5(
|
|
2550
2972
|
VenueLogo,
|
|
2551
2973
|
{
|
|
2552
2974
|
venue: card.venue,
|
|
@@ -2554,10 +2976,10 @@ var renderRouteCard = ({
|
|
|
2554
2976
|
ariaLabel: getTradingVenueLabel(card.venue)
|
|
2555
2977
|
}
|
|
2556
2978
|
) : null,
|
|
2557
|
-
/* @__PURE__ */
|
|
2558
|
-
/* @__PURE__ */
|
|
2559
|
-
/* @__PURE__ */
|
|
2560
|
-
card.isUnavailable ? /* @__PURE__ */
|
|
2979
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-1 min-w-0", children: [
|
|
2980
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-1.5", children: [
|
|
2981
|
+
/* @__PURE__ */ jsx5("p", { className: "agg-route-card-title truncate text-agg-sm leading-agg-5 text-agg-foreground", children: card.label }),
|
|
2982
|
+
card.isUnavailable ? /* @__PURE__ */ jsx5(
|
|
2561
2983
|
Icon,
|
|
2562
2984
|
{
|
|
2563
2985
|
name: "lock",
|
|
@@ -2565,7 +2987,7 @@ var renderRouteCard = ({
|
|
|
2565
2987
|
className: "shrink-0 text-agg-muted-foreground",
|
|
2566
2988
|
"aria-hidden": "true"
|
|
2567
2989
|
}
|
|
2568
|
-
) : card.kind === "split" && isSelected ? /* @__PURE__ */
|
|
2990
|
+
) : card.kind === "split" && isSelected ? /* @__PURE__ */ jsx5(
|
|
2569
2991
|
Icon,
|
|
2570
2992
|
{
|
|
2571
2993
|
name: showSplitDetails ? "chevron-up" : "chevron-down",
|
|
@@ -2575,10 +2997,10 @@ var renderRouteCard = ({
|
|
|
2575
2997
|
}
|
|
2576
2998
|
) : null
|
|
2577
2999
|
] }),
|
|
2578
|
-
card.hint ? /* @__PURE__ */
|
|
3000
|
+
card.hint ? /* @__PURE__ */ jsx5("p", { className: "agg-route-card-hint text-agg-xs leading-agg-4 text-agg-muted-foreground", children: card.hint }) : null
|
|
2579
3001
|
] })
|
|
2580
3002
|
] }),
|
|
2581
|
-
/* @__PURE__ */
|
|
3003
|
+
/* @__PURE__ */ jsx5(
|
|
2582
3004
|
"p",
|
|
2583
3005
|
{
|
|
2584
3006
|
className: cn(
|
|
@@ -2590,9 +3012,9 @@ var renderRouteCard = ({
|
|
|
2590
3012
|
}
|
|
2591
3013
|
)
|
|
2592
3014
|
] }),
|
|
2593
|
-
showSplitDetails ? /* @__PURE__ */
|
|
2594
|
-
/* @__PURE__ */
|
|
2595
|
-
/* @__PURE__ */
|
|
3015
|
+
showSplitDetails ? /* @__PURE__ */ jsxs4(Fragment3, { children: [
|
|
3016
|
+
/* @__PURE__ */ jsx5("p", { className: "agg-route-card-description text-agg-xs leading-agg-4 text-agg-foreground", children: tradingLabels.splitOrderDescription }),
|
|
3017
|
+
/* @__PURE__ */ jsx5("div", { className: "agg-route-breakdown flex flex-col gap-3", children: (_b = card.rows) == null ? void 0 : _b.map((row) => renderRouteBreakdownRow(row)) })
|
|
2596
3018
|
] }) : null
|
|
2597
3019
|
] })
|
|
2598
3020
|
}
|
|
@@ -2615,7 +3037,7 @@ var renderSubmissionSurface = ({
|
|
|
2615
3037
|
executionVenue: progressState.executionVenue,
|
|
2616
3038
|
labels: tradingLabels
|
|
2617
3039
|
});
|
|
2618
|
-
return /* @__PURE__ */
|
|
3040
|
+
return /* @__PURE__ */ jsx5(
|
|
2619
3041
|
Card,
|
|
2620
3042
|
{
|
|
2621
3043
|
className: cn(
|
|
@@ -2624,31 +3046,31 @@ var renderSubmissionSurface = ({
|
|
|
2624
3046
|
classNames == null ? void 0 : classNames.root,
|
|
2625
3047
|
className
|
|
2626
3048
|
),
|
|
2627
|
-
children: /* @__PURE__ */
|
|
3049
|
+
children: /* @__PURE__ */ jsxs4("div", { className: cn("agg-order-submission-body flex flex-col gap-6 p-5", classNames == null ? void 0 : classNames.body), children: [
|
|
2628
3050
|
renderCardHeader({
|
|
2629
3051
|
className: classNames == null ? void 0 : classNames.header,
|
|
2630
3052
|
headerSubtitle,
|
|
2631
3053
|
headerImage,
|
|
2632
3054
|
headerTitle
|
|
2633
3055
|
}),
|
|
2634
|
-
/* @__PURE__ */
|
|
2635
|
-
/* @__PURE__ */
|
|
2636
|
-
/* @__PURE__ */
|
|
2637
|
-
/* @__PURE__ */
|
|
3056
|
+
/* @__PURE__ */ jsxs4("div", { className: cn("agg-order-panel-content flex flex-col gap-6", classNames == null ? void 0 : classNames.content), children: [
|
|
3057
|
+
/* @__PURE__ */ jsxs4("div", { className: "agg-order-submission-status flex h-12 w-full items-center justify-center gap-3 rounded-agg-full bg-agg-primary-hover px-8 text-agg-base font-agg-bold leading-agg-6 text-agg-on-primary", children: [
|
|
3058
|
+
/* @__PURE__ */ jsx5(LoadingGlyph, { enableAnimations, className: "h-4 w-4 text-current" }),
|
|
3059
|
+
/* @__PURE__ */ jsx5("span", { children: actionLabel })
|
|
2638
3060
|
] }),
|
|
2639
|
-
/* @__PURE__ */
|
|
3061
|
+
/* @__PURE__ */ jsx5(
|
|
2640
3062
|
"div",
|
|
2641
3063
|
{
|
|
2642
3064
|
className: "agg-order-submission-steps agg-order-submission-group flex flex-col gap-2",
|
|
2643
3065
|
"data-testid": "agg-order-submission-steps",
|
|
2644
3066
|
children: displayRows.map((step) => {
|
|
2645
|
-
return /* @__PURE__ */
|
|
3067
|
+
return /* @__PURE__ */ jsxs4(
|
|
2646
3068
|
"div",
|
|
2647
3069
|
{
|
|
2648
3070
|
className: "agg-order-submission-step flex items-center gap-2 text-agg-sm leading-agg-5 text-agg-foreground",
|
|
2649
3071
|
"data-status": step.status,
|
|
2650
3072
|
children: [
|
|
2651
|
-
step.status === "complete" ? /* @__PURE__ */
|
|
3073
|
+
step.status === "complete" ? /* @__PURE__ */ jsx5(
|
|
2652
3074
|
Icon,
|
|
2653
3075
|
{
|
|
2654
3076
|
name: "check-circle",
|
|
@@ -2656,15 +3078,15 @@ var renderSubmissionSurface = ({
|
|
|
2656
3078
|
className: "h-3 w-3 shrink-0 text-agg-primary",
|
|
2657
3079
|
"aria-hidden": "true"
|
|
2658
3080
|
}
|
|
2659
|
-
) : /* @__PURE__ */
|
|
3081
|
+
) : /* @__PURE__ */ jsx5(
|
|
2660
3082
|
LoadingGlyph,
|
|
2661
3083
|
{
|
|
2662
3084
|
enableAnimations,
|
|
2663
3085
|
className: "h-3 w-3 shrink-0 text-agg-primary"
|
|
2664
3086
|
}
|
|
2665
3087
|
),
|
|
2666
|
-
/* @__PURE__ */
|
|
2667
|
-
step.venue ? /* @__PURE__ */
|
|
3088
|
+
/* @__PURE__ */ jsx5("p", { className: "min-w-0 flex-1", children: step.label }),
|
|
3089
|
+
step.venue ? /* @__PURE__ */ jsx5(
|
|
2668
3090
|
VenueLogo,
|
|
2669
3091
|
{
|
|
2670
3092
|
venue: step.venue,
|
|
@@ -2685,7 +3107,7 @@ var renderSubmissionSurface = ({
|
|
|
2685
3107
|
}
|
|
2686
3108
|
);
|
|
2687
3109
|
};
|
|
2688
|
-
var InitiateKycButton = ({ label, onOpen }) => /* @__PURE__ */
|
|
3110
|
+
var InitiateKycButton = ({ label, onOpen }) => /* @__PURE__ */ jsx5(
|
|
2689
3111
|
Button,
|
|
2690
3112
|
{
|
|
2691
3113
|
size: "large",
|
|
@@ -2702,35 +3124,35 @@ var KycVerifyModal = ({
|
|
|
2702
3124
|
isInitiating,
|
|
2703
3125
|
labels
|
|
2704
3126
|
}) => {
|
|
2705
|
-
return /* @__PURE__ */
|
|
3127
|
+
return /* @__PURE__ */ jsx5(
|
|
2706
3128
|
Modal,
|
|
2707
3129
|
{
|
|
2708
3130
|
open,
|
|
2709
3131
|
onOpenChange: (next) => {
|
|
2710
3132
|
onOpenChange(next);
|
|
2711
3133
|
},
|
|
2712
|
-
children: /* @__PURE__ */
|
|
2713
|
-
/* @__PURE__ */
|
|
2714
|
-
/* @__PURE__ */
|
|
2715
|
-
/* @__PURE__ */
|
|
2716
|
-
/* @__PURE__ */
|
|
3134
|
+
children: /* @__PURE__ */ jsxs4(Modal.Container, { maxWidth: "480px", "aria-label": labels.title, children: [
|
|
3135
|
+
/* @__PURE__ */ jsx5(Dialog.Title, { className: "sr-only", children: labels.title }),
|
|
3136
|
+
/* @__PURE__ */ jsx5(Dialog.Description, { className: "sr-only", children: labels.description }),
|
|
3137
|
+
/* @__PURE__ */ jsxs4(Modal.Body, { classNames: { root: "sm:px-10 sm:py-12" }, children: [
|
|
3138
|
+
/* @__PURE__ */ jsx5(
|
|
2717
3139
|
"button",
|
|
2718
3140
|
{
|
|
2719
3141
|
type: "button",
|
|
2720
3142
|
className: "absolute right-8 top-7 flex items-center justify-center text-agg-foreground transition-colors hover:text-agg-foreground/80",
|
|
2721
3143
|
onClick: () => onOpenChange(false),
|
|
2722
3144
|
"aria-label": "Close",
|
|
2723
|
-
children: /* @__PURE__ */
|
|
3145
|
+
children: /* @__PURE__ */ jsx5(CloseIcon, { className: "h-6 w-6" })
|
|
2724
3146
|
}
|
|
2725
3147
|
),
|
|
2726
|
-
/* @__PURE__ */
|
|
2727
|
-
/* @__PURE__ */
|
|
2728
|
-
/* @__PURE__ */
|
|
2729
|
-
/* @__PURE__ */
|
|
2730
|
-
/* @__PURE__ */
|
|
3148
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex flex-col items-center gap-8 text-center", children: [
|
|
3149
|
+
/* @__PURE__ */ jsx5("div", { className: "flex h-[60px] w-[60px] items-center justify-center text-agg-muted-foreground", children: /* @__PURE__ */ jsx5(UserTrustIcon, { className: "h-[60px] w-[60px]" }) }),
|
|
3150
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex flex-col items-center gap-3", children: [
|
|
3151
|
+
/* @__PURE__ */ jsx5("h3", { className: "text-agg-2xl leading-agg-8 font-agg-bold text-agg-foreground", children: labels.title }),
|
|
3152
|
+
/* @__PURE__ */ jsx5("p", { className: "agg-type-body text-agg-foreground", children: labels.description })
|
|
2731
3153
|
] }),
|
|
2732
|
-
/* @__PURE__ */
|
|
2733
|
-
/* @__PURE__ */
|
|
3154
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex w-full flex-col items-center gap-5", children: [
|
|
3155
|
+
/* @__PURE__ */ jsx5(
|
|
2734
3156
|
Button,
|
|
2735
3157
|
{
|
|
2736
3158
|
size: "large",
|
|
@@ -2741,7 +3163,7 @@ var KycVerifyModal = ({
|
|
|
2741
3163
|
children: labels.startVerification
|
|
2742
3164
|
}
|
|
2743
3165
|
),
|
|
2744
|
-
/* @__PURE__ */
|
|
3166
|
+
/* @__PURE__ */ jsx5(
|
|
2745
3167
|
"button",
|
|
2746
3168
|
{
|
|
2747
3169
|
type: "button",
|
|
@@ -2761,27 +3183,27 @@ var KycSuccessModal = ({
|
|
|
2761
3183
|
open,
|
|
2762
3184
|
onOpenChange,
|
|
2763
3185
|
labels
|
|
2764
|
-
}) => /* @__PURE__ */
|
|
2765
|
-
/* @__PURE__ */
|
|
2766
|
-
/* @__PURE__ */
|
|
2767
|
-
/* @__PURE__ */
|
|
2768
|
-
/* @__PURE__ */
|
|
3186
|
+
}) => /* @__PURE__ */ jsx5(Modal, { open, onOpenChange, children: /* @__PURE__ */ jsxs4(Modal.Container, { maxWidth: "480px", "aria-label": labels.title, children: [
|
|
3187
|
+
/* @__PURE__ */ jsx5(Dialog.Title, { className: "sr-only", children: labels.title }),
|
|
3188
|
+
/* @__PURE__ */ jsx5(Dialog.Description, { className: "sr-only", children: labels.description }),
|
|
3189
|
+
/* @__PURE__ */ jsxs4(Modal.Body, { classNames: { root: "px-10 py-12" }, children: [
|
|
3190
|
+
/* @__PURE__ */ jsx5(
|
|
2769
3191
|
"button",
|
|
2770
3192
|
{
|
|
2771
3193
|
type: "button",
|
|
2772
3194
|
className: "absolute right-8 top-7 flex items-center justify-center text-agg-foreground transition-colors hover:text-agg-foreground/80",
|
|
2773
3195
|
onClick: () => onOpenChange(false),
|
|
2774
3196
|
"aria-label": "Close",
|
|
2775
|
-
children: /* @__PURE__ */
|
|
3197
|
+
children: /* @__PURE__ */ jsx5(CloseIcon, { className: "h-6 w-6" })
|
|
2776
3198
|
}
|
|
2777
3199
|
),
|
|
2778
|
-
/* @__PURE__ */
|
|
2779
|
-
/* @__PURE__ */
|
|
2780
|
-
/* @__PURE__ */
|
|
2781
|
-
/* @__PURE__ */
|
|
2782
|
-
/* @__PURE__ */
|
|
3200
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex flex-col items-center gap-8 text-center", children: [
|
|
3201
|
+
/* @__PURE__ */ jsx5("div", { className: "flex h-[60px] w-[60px] items-center justify-center rounded-full bg-agg-success/15", children: /* @__PURE__ */ jsx5(SuccessCheckIcon, { className: "h-6 w-6 text-agg-success" }) }),
|
|
3202
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex flex-col items-center gap-3", children: [
|
|
3203
|
+
/* @__PURE__ */ jsx5("h3", { className: "text-agg-2xl leading-agg-8 font-agg-bold text-agg-foreground", children: labels.title }),
|
|
3204
|
+
/* @__PURE__ */ jsx5("p", { className: "agg-type-body text-agg-foreground", children: labels.description })
|
|
2783
3205
|
] }),
|
|
2784
|
-
/* @__PURE__ */
|
|
3206
|
+
/* @__PURE__ */ jsx5(
|
|
2785
3207
|
Button,
|
|
2786
3208
|
{
|
|
2787
3209
|
variant: "secondary",
|
|
@@ -2802,11 +3224,13 @@ var PlaceOrder = ({
|
|
|
2802
3224
|
isLoading = false,
|
|
2803
3225
|
isPrimaryActionDisabled = false,
|
|
2804
3226
|
isPrimaryActionLoading = false,
|
|
3227
|
+
isQuotePanelActive = true,
|
|
2805
3228
|
chainBalancesOverride,
|
|
2806
3229
|
onAmountChange,
|
|
2807
3230
|
onClose,
|
|
2808
3231
|
onOutcomeChange,
|
|
2809
3232
|
onPrimaryAction,
|
|
3233
|
+
onBeforePrimaryAction,
|
|
2810
3234
|
onTabChange,
|
|
2811
3235
|
onSuccess,
|
|
2812
3236
|
onError,
|
|
@@ -2814,7 +3238,7 @@ var PlaceOrder = ({
|
|
|
2814
3238
|
resolvedClaim,
|
|
2815
3239
|
midpointsResult
|
|
2816
3240
|
}) => {
|
|
2817
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E;
|
|
3241
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G;
|
|
2818
3242
|
const {
|
|
2819
3243
|
enableDebug: isExecutionDebugEnabled,
|
|
2820
3244
|
features: { enableAnimations, showFeesBreakdown },
|
|
@@ -2823,6 +3247,7 @@ var PlaceOrder = ({
|
|
|
2823
3247
|
} = useSdkUiConfig();
|
|
2824
3248
|
const labels = useLabels();
|
|
2825
3249
|
const tradingLabels = labels.trading;
|
|
3250
|
+
const toastCtx = useOptionalToast();
|
|
2826
3251
|
const { isTradingBlocked } = useGeoBlock();
|
|
2827
3252
|
const tradingContext = useEventTradingContext2();
|
|
2828
3253
|
const selectedEvent = (_a = tradingContext == null ? void 0 : tradingContext.selectedEvent) != null ? _a : null;
|
|
@@ -2873,6 +3298,7 @@ var PlaceOrder = ({
|
|
|
2873
3298
|
const resolvedReadOnlyTradingState = useMemo2(() => {
|
|
2874
3299
|
return resolveMarketTradingState(resolvedReadOnlyMarket);
|
|
2875
3300
|
}, [resolvedReadOnlyMarket]);
|
|
3301
|
+
const isEndedWithoutKnownWinner = false;
|
|
2876
3302
|
const orderEligibility = useMemo2(
|
|
2877
3303
|
() => resolveOrderEligibility({
|
|
2878
3304
|
event: scopedSelectedEvent,
|
|
@@ -2934,8 +3360,8 @@ var PlaceOrder = ({
|
|
|
2934
3360
|
() => mapVenueMarketOutcomesToPlaceOrderOutcomes(scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.venueMarketOutcomes),
|
|
2935
3361
|
[scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.venueMarketOutcomes]
|
|
2936
3362
|
);
|
|
2937
|
-
const buyTabRef =
|
|
2938
|
-
const sellTabRef =
|
|
3363
|
+
const buyTabRef = useRef3(null);
|
|
3364
|
+
const sellTabRef = useRef3(null);
|
|
2939
3365
|
const [internalTab, setInternalTab] = useState3("buy");
|
|
2940
3366
|
const [internalAmount, setInternalAmount] = useState3(PLACE_ORDER_DEFAULT_AMOUNT);
|
|
2941
3367
|
const [sellFilledForOutcomeId, setSellFilledForOutcomeId] = useState3(null);
|
|
@@ -2945,17 +3371,18 @@ var PlaceOrder = ({
|
|
|
2945
3371
|
const [isSplitDetailOpen, setIsSplitDetailOpen] = useState3(false);
|
|
2946
3372
|
const [submissionFeedback, setSubmissionFeedback] = useState3(null);
|
|
2947
3373
|
const [submissionProgressState, setSubmissionProgressState] = useState3(null);
|
|
2948
|
-
const
|
|
2949
|
-
const
|
|
2950
|
-
const
|
|
2951
|
-
|
|
3374
|
+
const [isBeforeActionPending, setIsBeforeActionPending] = useState3(false);
|
|
3375
|
+
const executionDebugStoreRef = useRef3(null);
|
|
3376
|
+
const executionDebugAttemptIdRef = useRef3(null);
|
|
3377
|
+
const submittedSelectionRef = useRef3(null);
|
|
3378
|
+
useEffect3(() => {
|
|
2952
3379
|
if (!isExecutionDebugEnabled) {
|
|
2953
3380
|
executionDebugStoreRef.current = null;
|
|
2954
3381
|
return;
|
|
2955
3382
|
}
|
|
2956
3383
|
executionDebugStoreRef.current = enableExecutionDebugInBrowser();
|
|
2957
3384
|
}, [isExecutionDebugEnabled]);
|
|
2958
|
-
|
|
3385
|
+
useEffect3(() => {
|
|
2959
3386
|
if (!isExecutionDebugEnabled) return;
|
|
2960
3387
|
const store = executionDebugStoreRef.current;
|
|
2961
3388
|
if (!store) return;
|
|
@@ -2968,6 +3395,7 @@ var PlaceOrder = ({
|
|
|
2968
3395
|
scopedSelectedOutcomeId
|
|
2969
3396
|
]);
|
|
2970
3397
|
const debouncedAmount = useDebouncedValue(internalAmount, 300);
|
|
3398
|
+
const isQuoteInputEditing = internalAmount !== debouncedAmount;
|
|
2971
3399
|
const isSell = useMemo2(() => internalTab === "sell", [internalTab]);
|
|
2972
3400
|
const {
|
|
2973
3401
|
positions: executionPositions,
|
|
@@ -2989,7 +3417,19 @@ var PlaceOrder = ({
|
|
|
2989
3417
|
compareVenues: true,
|
|
2990
3418
|
tradeSide: isSell ? "sell" : "buy",
|
|
2991
3419
|
mode: isPaperMode ? "paper" : void 0,
|
|
2992
|
-
enabled: debouncedAmount > 0 && orderEligibility.canPlaceOrder
|
|
3420
|
+
enabled: isQuotePanelActive && !isEndedWithoutKnownWinner && !submissionProgressState && !isBeforeActionPending && !executeManaged.isPending && debouncedAmount > 0 && orderEligibility.canPlaceOrder && // On the sell tab, hold the quote until the amount has been initialized
|
|
3421
|
+
// from the user's position for THIS outcome AND the debounced value has
|
|
3422
|
+
// caught up to it. The amount input is shared with the buy tab, so right
|
|
3423
|
+
// after switching to sell the debounced value still holds the buy default
|
|
3424
|
+
// (PLACE_ORDER_DEFAULT_AMOUNT) for ~300ms — without this gate it leaks into
|
|
3425
|
+
// the first sell quote as `sellShares` (e.g. sellShares=20).
|
|
3426
|
+
(!isSell || sellFilledForOutcomeId === scopedSelectedOutcomeId && !isQuoteInputEditing),
|
|
3427
|
+
refreshContext: {
|
|
3428
|
+
isEditing: isQuoteInputEditing,
|
|
3429
|
+
isMarketOpen: resolvedTradingState.kind === "open" && !isEndedWithoutKnownWinner,
|
|
3430
|
+
isPanelActive: isQuotePanelActive,
|
|
3431
|
+
isSubmitting: submissionProgressState != null || isBeforeActionPending || executeManaged.isPending
|
|
3432
|
+
}
|
|
2993
3433
|
});
|
|
2994
3434
|
const currentSellableShares = useMemo2(() => {
|
|
2995
3435
|
var _a2, _b2, _c2, _d2, _e2, _f2, _g2;
|
|
@@ -3005,15 +3445,13 @@ var PlaceOrder = ({
|
|
|
3005
3445
|
(_d2 = scopedSelectedMarket.externalIdentifier) != null ? _d2 : void 0
|
|
3006
3446
|
].filter((value) => Boolean(value));
|
|
3007
3447
|
const selectedMarketIdSet = new Set(selectedMarketIds);
|
|
3008
|
-
const selectedVenue = scopedSelectedMarket.venue;
|
|
3009
3448
|
let resolvedShares = 0;
|
|
3010
3449
|
for (const group of executionPositions) {
|
|
3011
3450
|
const groupOutcomes = (_f2 = (_e2 = group.venueMarket) == null ? void 0 : _e2.venueMarketOutcomes) != null ? _f2 : [];
|
|
3012
3451
|
for (const outcome of groupOutcomes) {
|
|
3013
3452
|
if (outcome.label.trim().toLowerCase() !== normalizedSelectedOutcomeLabel) continue;
|
|
3014
3453
|
for (const breakdown of (_g2 = outcome.venueBreakdown) != null ? _g2 : []) {
|
|
3015
|
-
|
|
3016
|
-
const matchesMarketId = selectedMarketIdSet.size === 0 || selectedMarketIdSet.has(breakdown.venueMarketId) || selectedMarketIdSet.has(group.targetMarketId);
|
|
3454
|
+
const matchesMarketId = selectedMarketIdSet.size === 0 || selectedMarketIdSet.has(group.targetMarketId) || selectedMarketIdSet.has(breakdown.venueMarketId);
|
|
3017
3455
|
if (!matchesMarketId) continue;
|
|
3018
3456
|
resolvedShares += Number.isFinite(breakdown.size) ? breakdown.size : 0;
|
|
3019
3457
|
}
|
|
@@ -3027,25 +3465,33 @@ var PlaceOrder = ({
|
|
|
3027
3465
|
scopedSelectedOutcome,
|
|
3028
3466
|
(_k = (_j = smartRoute.data) == null ? void 0 : _j.positionAvailability) == null ? void 0 : _k.totalSellableShares
|
|
3029
3467
|
]);
|
|
3468
|
+
const maxSellableShares = useMemo2(
|
|
3469
|
+
() => floorToDecimals(currentSellableShares, SELL_SHARE_INPUT_DECIMALS),
|
|
3470
|
+
[currentSellableShares]
|
|
3471
|
+
);
|
|
3030
3472
|
const isCurrentSellableSharesLoading = isSell && isAuthenticated && !(typeof ((_m = (_l = smartRoute.data) == null ? void 0 : _l.positionAvailability) == null ? void 0 : _m.totalSellableShares) === "number") && (isExecutionPositionsLoading || isExecutionPositionsFetching);
|
|
3031
3473
|
const displayedCurrentSellableShares = useMemo2(() => {
|
|
3032
3474
|
if (!Number.isFinite(currentSellableShares) || currentSellableShares <= 0) return 0;
|
|
3033
|
-
return
|
|
3475
|
+
return floorToDecimals(currentSellableShares, SELL_SHARE_DISPLAY_DECIMALS);
|
|
3034
3476
|
}, [currentSellableShares]);
|
|
3035
|
-
const
|
|
3036
|
-
|
|
3477
|
+
const displayedCurrentSellableSharesLabel = useMemo2(
|
|
3478
|
+
() => `${formatFlooredShareAmount(maxSellableShares, SELL_SHARE_DISPLAY_DECIMALS)} shares`,
|
|
3479
|
+
[maxSellableShares]
|
|
3480
|
+
);
|
|
3481
|
+
const isAtMaxSellableShares = isSell && maxSellableShares > 0 && Math.abs(internalAmount - maxSellableShares) < 1e-9;
|
|
3482
|
+
useEffect3(() => {
|
|
3037
3483
|
if (submissionProgressState != null) return;
|
|
3038
3484
|
if (!isSell || isCurrentSellableSharesLoading) return;
|
|
3039
3485
|
if (scopedSelectedOutcomeId === sellFilledForOutcomeId) return;
|
|
3040
|
-
setInternalAmount(
|
|
3486
|
+
setInternalAmount(maxSellableShares);
|
|
3041
3487
|
setSellFilledForOutcomeId(scopedSelectedOutcomeId != null ? scopedSelectedOutcomeId : null);
|
|
3042
|
-
onAmountChange == null ? void 0 : onAmountChange(
|
|
3488
|
+
onAmountChange == null ? void 0 : onAmountChange(maxSellableShares);
|
|
3043
3489
|
}, [
|
|
3044
3490
|
isSell,
|
|
3045
3491
|
isCurrentSellableSharesLoading,
|
|
3046
3492
|
scopedSelectedOutcomeId,
|
|
3047
3493
|
sellFilledForOutcomeId,
|
|
3048
|
-
|
|
3494
|
+
maxSellableShares,
|
|
3049
3495
|
onAmountChange,
|
|
3050
3496
|
submissionProgressState
|
|
3051
3497
|
]);
|
|
@@ -3066,7 +3512,7 @@ var PlaceOrder = ({
|
|
|
3066
3512
|
}
|
|
3067
3513
|
return (_d2 = (_c2 = (_a2 = routeCards.find((card) => !card.isUnavailable)) == null ? void 0 : _a2.id) != null ? _c2 : (_b2 = routeCards[0]) == null ? void 0 : _b2.id) != null ? _d2 : null;
|
|
3068
3514
|
}, [routeCards, selectedRouteCardId]);
|
|
3069
|
-
|
|
3515
|
+
useEffect3(() => {
|
|
3070
3516
|
if (routeCards.length === 0) {
|
|
3071
3517
|
setSelectedRouteCardId(null);
|
|
3072
3518
|
setIsRoutesExpanded(false);
|
|
@@ -3078,9 +3524,9 @@ var PlaceOrder = ({
|
|
|
3078
3524
|
}
|
|
3079
3525
|
}, [resolvedSelectedRouteCardId, routeCards.length, selectedRouteCardId]);
|
|
3080
3526
|
const isSubmissionLocked = submissionProgressState != null;
|
|
3081
|
-
const isSubmissionLockedRef =
|
|
3527
|
+
const isSubmissionLockedRef = useRef3(isSubmissionLocked);
|
|
3082
3528
|
isSubmissionLockedRef.current = isSubmissionLocked;
|
|
3083
|
-
|
|
3529
|
+
useEffect3(() => {
|
|
3084
3530
|
if (isSubmissionLockedRef.current) return;
|
|
3085
3531
|
setSubmissionFeedback(null);
|
|
3086
3532
|
setSubmissionProgressState(null);
|
|
@@ -3113,7 +3559,7 @@ var PlaceOrder = ({
|
|
|
3113
3559
|
walletAddress: (_p = getWalletAddressFromUserProfile(user)) != null ? _p : null,
|
|
3114
3560
|
onError
|
|
3115
3561
|
});
|
|
3116
|
-
const handleRouteCardSelect =
|
|
3562
|
+
const handleRouteCardSelect = useCallback3(
|
|
3117
3563
|
(cardId) => {
|
|
3118
3564
|
if (cardId === resolvedSelectedRouteCardId) {
|
|
3119
3565
|
const card = routeCards.find((c) => c.id === cardId);
|
|
@@ -3128,14 +3574,15 @@ var PlaceOrder = ({
|
|
|
3128
3574
|
);
|
|
3129
3575
|
const executionProgress = useExecutionProgress({
|
|
3130
3576
|
orderIds: (_q = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) != null ? _q : null,
|
|
3577
|
+
quoteId: (_r = submissionProgressState == null ? void 0 : submissionProgressState.quoteId) != null ? _r : null,
|
|
3131
3578
|
mode: isPaperMode ? "paper" : void 0,
|
|
3132
|
-
enabled: ((submissionProgressState == null ? void 0 : submissionProgressState.phase) === "submitting" || (submissionProgressState == null ? void 0 : submissionProgressState.phase) === "executing") && !!((
|
|
3579
|
+
enabled: ((submissionProgressState == null ? void 0 : submissionProgressState.phase) === "submitting" || (submissionProgressState == null ? void 0 : submissionProgressState.phase) === "executing") && !!((_s = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) == null ? void 0 : _s.length)
|
|
3133
3580
|
});
|
|
3134
|
-
const selectedOutcomeLabel = (
|
|
3135
|
-
const headerImage = (
|
|
3136
|
-
const headerTitle = (
|
|
3137
|
-
const headerSubtitle = (
|
|
3138
|
-
const buildExecutionSummary =
|
|
3581
|
+
const selectedOutcomeLabel = (_v = (_u = (_t = outcomes.find((outcome) => outcome.id === scopedSelectedOutcomeId)) == null ? void 0 : _t.label) != null ? _u : scopedSelectedOutcome == null ? void 0 : scopedSelectedOutcome.label) != null ? _v : "";
|
|
3582
|
+
const headerImage = (_x = (_w = scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.image) != null ? _w : scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.image) != null ? _x : null;
|
|
3583
|
+
const headerTitle = (_z = (_y = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.title) != null ? _y : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _z : "";
|
|
3584
|
+
const headerSubtitle = (_A = scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _A : "";
|
|
3585
|
+
const buildExecutionSummary = useCallback3(
|
|
3139
3586
|
(quoteData, executionVenue, orderId, partialFillSummary) => {
|
|
3140
3587
|
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2;
|
|
3141
3588
|
if (!quoteData) return void 0;
|
|
@@ -3211,7 +3658,7 @@ var PlaceOrder = ({
|
|
|
3211
3658
|
tradingLabels
|
|
3212
3659
|
]
|
|
3213
3660
|
);
|
|
3214
|
-
|
|
3661
|
+
useEffect3(() => {
|
|
3215
3662
|
if (executionProgress.phase === "order_submitted") {
|
|
3216
3663
|
const submittedOrder = executionProgress.submittedOrders[0];
|
|
3217
3664
|
setSubmissionProgressState((prev) => {
|
|
@@ -3224,7 +3671,7 @@ var PlaceOrder = ({
|
|
|
3224
3671
|
});
|
|
3225
3672
|
}
|
|
3226
3673
|
}, [executionProgress.phase, executionProgress.submittedOrders]);
|
|
3227
|
-
|
|
3674
|
+
useEffect3(() => {
|
|
3228
3675
|
var _a2, _b2;
|
|
3229
3676
|
const dp = executionProgress.dagProgress;
|
|
3230
3677
|
if (!dp) return;
|
|
@@ -3275,7 +3722,7 @@ var PlaceOrder = ({
|
|
|
3275
3722
|
return __spreadProps(__spreadValues({}, prev), { dagProgress: dp });
|
|
3276
3723
|
});
|
|
3277
3724
|
}, [executionProgress.dagProgress, tradingLabels]);
|
|
3278
|
-
|
|
3725
|
+
useEffect3(() => {
|
|
3279
3726
|
const orderIds = submissionProgressState == null ? void 0 : submissionProgressState.orderIds;
|
|
3280
3727
|
if (!(orderIds == null ? void 0 : orderIds.length)) return;
|
|
3281
3728
|
const aggregateStatus = deriveAggregateOrderStatus(
|
|
@@ -3336,7 +3783,7 @@ var PlaceOrder = ({
|
|
|
3336
3783
|
tradingLabels
|
|
3337
3784
|
]);
|
|
3338
3785
|
const estDurationMs = (selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData) && typeof selectedRouteCard.quoteData.estDurationMs === "number" ? selectedRouteCard.quoteData.estDurationMs : 6e4;
|
|
3339
|
-
|
|
3786
|
+
useEffect3(() => {
|
|
3340
3787
|
const phase = submissionProgressState == null ? void 0 : submissionProgressState.phase;
|
|
3341
3788
|
if (phase !== "submitting" && phase !== "executing") return;
|
|
3342
3789
|
const timeoutMs = Math.max(6e4, 2 * estDurationMs);
|
|
@@ -3351,7 +3798,36 @@ var PlaceOrder = ({
|
|
|
3351
3798
|
}, timeoutMs);
|
|
3352
3799
|
return () => clearTimeout(id);
|
|
3353
3800
|
}, [submissionProgressState == null ? void 0 : submissionProgressState.phase, estDurationMs]);
|
|
3354
|
-
|
|
3801
|
+
const emitTerminalOrderNotifications = useCallback3(() => {
|
|
3802
|
+
const toast = toastCtx == null ? void 0 : toastCtx.toast;
|
|
3803
|
+
if (!toast) return;
|
|
3804
|
+
for (const event of executionProgress.terminalOrderEvents) {
|
|
3805
|
+
handleOrderEvent({
|
|
3806
|
+
event: {
|
|
3807
|
+
type: "order_event",
|
|
3808
|
+
userId: "",
|
|
3809
|
+
orderId: event.orderId,
|
|
3810
|
+
venue: event.venue,
|
|
3811
|
+
event: event.event,
|
|
3812
|
+
filledAmountRaw: event.filledAmountRaw,
|
|
3813
|
+
remainingAmountRaw: event.remainingAmountRaw,
|
|
3814
|
+
actualSharesRaw: event.actualSharesRaw,
|
|
3815
|
+
actualToWinRaw: event.actualToWinRaw,
|
|
3816
|
+
quotedSharesRaw: event.quotedSharesRaw,
|
|
3817
|
+
quotedToWinRaw: event.quotedToWinRaw,
|
|
3818
|
+
executionPriceRaw: event.executionPriceRaw,
|
|
3819
|
+
quotedPriceRaw: event.quotedPriceRaw,
|
|
3820
|
+
errorReason: event.errorReason,
|
|
3821
|
+
timestamp: event.timestamp
|
|
3822
|
+
},
|
|
3823
|
+
labels,
|
|
3824
|
+
fireOnce: (key, tone, title, message, detail) => {
|
|
3825
|
+
toast(message, { tone, title, detail });
|
|
3826
|
+
}
|
|
3827
|
+
});
|
|
3828
|
+
}
|
|
3829
|
+
}, [executionProgress.terminalOrderEvents, labels, toastCtx]);
|
|
3830
|
+
useEffect3(() => {
|
|
3355
3831
|
var _a2, _b2;
|
|
3356
3832
|
if (!submissionProgressState) return;
|
|
3357
3833
|
onExecutionStateChange == null ? void 0 : onExecutionStateChange(submissionProgressState);
|
|
@@ -3370,6 +3846,7 @@ var PlaceOrder = ({
|
|
|
3370
3846
|
});
|
|
3371
3847
|
}
|
|
3372
3848
|
if (submissionProgressState.phase === "success" && submissionProgressState.summary) {
|
|
3849
|
+
emitTerminalOrderNotifications();
|
|
3373
3850
|
invalidateBalanceQueries(queryClient);
|
|
3374
3851
|
invalidatePositionQueries(queryClient);
|
|
3375
3852
|
if (debugStore && debugAttemptId) {
|
|
@@ -3381,6 +3858,7 @@ var PlaceOrder = ({
|
|
|
3381
3858
|
onSuccess == null ? void 0 : onSuccess(submissionProgressState.summary);
|
|
3382
3859
|
}
|
|
3383
3860
|
if (submissionProgressState.phase === "failed" && submissionProgressState.errorMessage) {
|
|
3861
|
+
emitTerminalOrderNotifications();
|
|
3384
3862
|
if (debugStore && debugAttemptId) {
|
|
3385
3863
|
debugStore.appendError(debugAttemptId, {
|
|
3386
3864
|
message: submissionProgressState.errorMessage,
|
|
@@ -3393,8 +3871,15 @@ var PlaceOrder = ({
|
|
|
3393
3871
|
}
|
|
3394
3872
|
onError == null ? void 0 : onError(new Error(submissionProgressState.errorMessage));
|
|
3395
3873
|
}
|
|
3396
|
-
}, [
|
|
3397
|
-
|
|
3874
|
+
}, [
|
|
3875
|
+
emitTerminalOrderNotifications,
|
|
3876
|
+
onError,
|
|
3877
|
+
onExecutionStateChange,
|
|
3878
|
+
onSuccess,
|
|
3879
|
+
queryClient,
|
|
3880
|
+
submissionProgressState
|
|
3881
|
+
]);
|
|
3882
|
+
const activeQuoteData = (_C = (_B = selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData) != null ? _B : smartRoute.data) != null ? _C : null;
|
|
3398
3883
|
const visibleRouteCards = orderedRouteCards.length > PLACE_ORDER_ROUTE_COLLAPSED_CARD_COUNT && !isRoutesExpanded ? orderedRouteCards.slice(0, PLACE_ORDER_ROUTE_COLLAPSED_CARD_COUNT) : orderedRouteCards;
|
|
3399
3884
|
const hasEnteredAmount = internalAmount > 0;
|
|
3400
3885
|
const isQuoteLoading = hasEnteredAmount && (smartRoute.isFetching || smartRoute.isLoading);
|
|
@@ -3489,7 +3974,7 @@ var PlaceOrder = ({
|
|
|
3489
3974
|
}
|
|
3490
3975
|
return (_d2 = selectedRouteCard.hint) != null ? _d2 : "";
|
|
3491
3976
|
}, [selectedRouteCard, tradingLabels]);
|
|
3492
|
-
const displayedToWinValue = (
|
|
3977
|
+
const displayedToWinValue = (_D = selectedRouteCard == null ? void 0 : selectedRouteCard.numericValue) != null ? _D : 0;
|
|
3493
3978
|
const activeFeeBreakdown = activeQuoteData == null ? void 0 : activeQuoteData.feeBreakdown;
|
|
3494
3979
|
const estimatedFeesValue = useMemo2(() => {
|
|
3495
3980
|
if (!activeFeeBreakdown) return null;
|
|
@@ -3530,14 +4015,14 @@ var PlaceOrder = ({
|
|
|
3530
4015
|
}
|
|
3531
4016
|
];
|
|
3532
4017
|
}, [activeFeeBreakdown, tradingLabels]);
|
|
3533
|
-
const isActionLoading = isPrimaryActionLoading || executeManaged.isPending;
|
|
3534
|
-
const selectedRouteGeoBlocked = (
|
|
4018
|
+
const isActionLoading = isPrimaryActionLoading || executeManaged.isPending || isBeforeActionPending;
|
|
4019
|
+
const selectedRouteGeoBlocked = (_E = selectedRouteCard == null ? void 0 : selectedRouteCard.isUnavailable) != null ? _E : false;
|
|
3535
4020
|
const geoBlockedVenuesFromWarnings = useMemo2(
|
|
3536
4021
|
() => {
|
|
3537
4022
|
var _a2;
|
|
3538
4023
|
return extractGeoBlockedVenues((_a2 = smartRoute.data) == null ? void 0 : _a2.warnings);
|
|
3539
4024
|
},
|
|
3540
|
-
[(
|
|
4025
|
+
[(_F = smartRoute.data) == null ? void 0 : _F.warnings]
|
|
3541
4026
|
);
|
|
3542
4027
|
const isPrimaryVenueGeoBlocked = useMemo2(() => {
|
|
3543
4028
|
var _a2, _b2;
|
|
@@ -3550,7 +4035,7 @@ var PlaceOrder = ({
|
|
|
3550
4035
|
const isActionDisabled = isPrimaryActionDisabled || !orderEligibility.canPlaceOrder || isActionLoading || !hasEnteredAmount || !scopedSelectedMarket || isInsufficientBalance || isQuoteInsufficientBalance || isBelowMinimum || isQuoteLoading || !selectedRouteCard || !selectedRouteCard.quoteData.quoteId || selectedRouteGeoBlocked || !isAuthenticated || quoteStatus !== void 0;
|
|
3551
4036
|
const shouldShowSmartRouting = orderEligibility.canPlaceOrder && hasEnteredAmount && !isBelowMinimum && (orderedRouteCards.length > 0 || smartRoute.isFetching || smartRoute.isLoading);
|
|
3552
4037
|
const shouldShowRouteToggle = !isQuoteLoading && orderedRouteCards.length > PLACE_ORDER_ROUTE_COLLAPSED_CARD_COUNT;
|
|
3553
|
-
const handleReturnToOrderForm =
|
|
4038
|
+
const handleReturnToOrderForm = useCallback3(() => {
|
|
3554
4039
|
const submittedSelection = submittedSelectionRef.current;
|
|
3555
4040
|
submittedSelectionRef.current = null;
|
|
3556
4041
|
setSubmissionProgressState(null);
|
|
@@ -3571,7 +4056,7 @@ var PlaceOrder = ({
|
|
|
3571
4056
|
const shareUrl = `https://twitter.com/intent/tweet?text=${encodeURIComponent(shareText)}`;
|
|
3572
4057
|
window.open(shareUrl, "_blank", "noopener,noreferrer");
|
|
3573
4058
|
};
|
|
3574
|
-
const handleExecuteQuote =
|
|
4059
|
+
const handleExecuteQuote = useCallback3(
|
|
3575
4060
|
(quoteData) => __async(null, null, function* () {
|
|
3576
4061
|
var _a2, _b2, _c2;
|
|
3577
4062
|
const quoteId = quoteData == null ? void 0 : quoteData.quoteId;
|
|
@@ -3630,6 +4115,7 @@ var PlaceOrder = ({
|
|
|
3630
4115
|
executionVenue: resolveExecutionVenueFromQuote(quoteData),
|
|
3631
4116
|
orderId: response.orderIds[0],
|
|
3632
4117
|
orderIds: response.orderIds,
|
|
4118
|
+
quoteId: response.quoteId,
|
|
3633
4119
|
phase: "submitting"
|
|
3634
4120
|
});
|
|
3635
4121
|
} catch (error) {
|
|
@@ -3669,7 +4155,7 @@ var PlaceOrder = ({
|
|
|
3669
4155
|
tradingLabels.quoteUnavailable
|
|
3670
4156
|
]
|
|
3671
4157
|
);
|
|
3672
|
-
const handleSkipToSuccess =
|
|
4158
|
+
const handleSkipToSuccess = useCallback3(() => {
|
|
3673
4159
|
const primaryFilledEvent = executionProgress.terminalOrderEvents.find(
|
|
3674
4160
|
(e) => e.event === "filled" || e.event === "partial_fill"
|
|
3675
4161
|
);
|
|
@@ -3694,7 +4180,7 @@ var PlaceOrder = ({
|
|
|
3694
4180
|
failureSummary,
|
|
3695
4181
|
selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData
|
|
3696
4182
|
]);
|
|
3697
|
-
|
|
4183
|
+
useEffect3(() => {
|
|
3698
4184
|
if ((submissionProgressState == null ? void 0 : submissionProgressState.phase) !== "failed") return;
|
|
3699
4185
|
if ((failureSummary == null ? void 0 : failureSummary.kind) !== "partial_fill") return;
|
|
3700
4186
|
if (!shouldAutoSkipPartialFill) return;
|
|
@@ -3705,7 +4191,7 @@ var PlaceOrder = ({
|
|
|
3705
4191
|
shouldAutoSkipPartialFill,
|
|
3706
4192
|
submissionProgressState == null ? void 0 : submissionProgressState.phase
|
|
3707
4193
|
]);
|
|
3708
|
-
const handleRetrySubmission =
|
|
4194
|
+
const handleRetrySubmission = useCallback3(() => __async(null, null, function* () {
|
|
3709
4195
|
var _a2, _b2, _c2;
|
|
3710
4196
|
if (!orderEligibility.canPlaceOrder || (failureSummary == null ? void 0 : failureSummary.kind) === "generic") {
|
|
3711
4197
|
handleReturnToOrderForm();
|
|
@@ -3799,7 +4285,7 @@ var PlaceOrder = ({
|
|
|
3799
4285
|
]);
|
|
3800
4286
|
const resolvedStatusClassName = cn(classNames == null ? void 0 : classNames.root, className);
|
|
3801
4287
|
if (isLoading) {
|
|
3802
|
-
return /* @__PURE__ */
|
|
4288
|
+
return /* @__PURE__ */ jsx5(
|
|
3803
4289
|
Skeleton,
|
|
3804
4290
|
{
|
|
3805
4291
|
ariaLabel: labels.common.loading,
|
|
@@ -3810,7 +4296,7 @@ var PlaceOrder = ({
|
|
|
3810
4296
|
}
|
|
3811
4297
|
if (submissionProgressState) {
|
|
3812
4298
|
if (submissionProgressState.phase === "success" && submissionProgressState.summary) {
|
|
3813
|
-
return /* @__PURE__ */
|
|
4299
|
+
return /* @__PURE__ */ jsx5(
|
|
3814
4300
|
PlaceOrderSuccessView,
|
|
3815
4301
|
{
|
|
3816
4302
|
className: resolvedStatusClassName,
|
|
@@ -3822,7 +4308,7 @@ var PlaceOrder = ({
|
|
|
3822
4308
|
);
|
|
3823
4309
|
}
|
|
3824
4310
|
if (submissionProgressState.phase === "failed") {
|
|
3825
|
-
return /* @__PURE__ */
|
|
4311
|
+
return /* @__PURE__ */ jsx5(
|
|
3826
4312
|
PlaceOrderFailureView,
|
|
3827
4313
|
{
|
|
3828
4314
|
className: resolvedStatusClassName,
|
|
@@ -3877,8 +4363,8 @@ var PlaceOrder = ({
|
|
|
3877
4363
|
};
|
|
3878
4364
|
const handleFillSellableShares = () => {
|
|
3879
4365
|
if (!isSell) return;
|
|
3880
|
-
if (
|
|
3881
|
-
handleAmountChange(
|
|
4366
|
+
if (maxSellableShares <= 0) return;
|
|
4367
|
+
handleAmountChange(maxSellableShares);
|
|
3882
4368
|
};
|
|
3883
4369
|
const handleDepositRequiredClick = () => {
|
|
3884
4370
|
if (!isInsufficientBalance) return;
|
|
@@ -3896,7 +4382,7 @@ var PlaceOrder = ({
|
|
|
3896
4382
|
});
|
|
3897
4383
|
};
|
|
3898
4384
|
const handlePrimaryAction = () => __async(null, null, function* () {
|
|
3899
|
-
var _a2;
|
|
4385
|
+
var _a2, _b2, _c2;
|
|
3900
4386
|
if (!orderEligibility.canPlaceOrder) {
|
|
3901
4387
|
setSubmissionFeedback({
|
|
3902
4388
|
message: (_a2 = resolveOrderEligibilityMessage(labels, orderEligibility.reason)) != null ? _a2 : tradingLabels.orderFailed,
|
|
@@ -3906,6 +4392,26 @@ var PlaceOrder = ({
|
|
|
3906
4392
|
}
|
|
3907
4393
|
if (!selectedRouteCard) return;
|
|
3908
4394
|
setSubmissionFeedback(null);
|
|
4395
|
+
if (onBeforePrimaryAction) {
|
|
4396
|
+
const beforeContext = isPaperMode ? { quoteId: (_b2 = selectedRouteCard.quoteData) == null ? void 0 : _b2.quoteId, mode: "paper" } : { quoteId: (_c2 = selectedRouteCard.quoteData) == null ? void 0 : _c2.quoteId };
|
|
4397
|
+
setIsBeforeActionPending(true);
|
|
4398
|
+
try {
|
|
4399
|
+
const proceed = yield onBeforePrimaryAction(beforeContext);
|
|
4400
|
+
if (proceed === false) return;
|
|
4401
|
+
} catch (error) {
|
|
4402
|
+
setSubmissionFeedback({
|
|
4403
|
+
message: normalizePlaceOrderErrorMessage({
|
|
4404
|
+
errorMessage: error instanceof Error ? error.message : String(error),
|
|
4405
|
+
fallbackMessage: tradingLabels.orderFailed,
|
|
4406
|
+
labels: tradingLabels
|
|
4407
|
+
}),
|
|
4408
|
+
tone: "error"
|
|
4409
|
+
});
|
|
4410
|
+
return;
|
|
4411
|
+
} finally {
|
|
4412
|
+
setIsBeforeActionPending(false);
|
|
4413
|
+
}
|
|
4414
|
+
}
|
|
3909
4415
|
if (scopedSelectedMarket && scopedSelectedOutcomeId) {
|
|
3910
4416
|
submittedSelectionRef.current = {
|
|
3911
4417
|
marketId: scopedSelectedMarket.id,
|
|
@@ -3927,19 +4433,21 @@ var PlaceOrder = ({
|
|
|
3927
4433
|
});
|
|
3928
4434
|
}
|
|
3929
4435
|
});
|
|
3930
|
-
if (!orderEligibility.canPlaceOrder && resolvedReadOnlyTradingState.kind !== "open") {
|
|
3931
|
-
return /* @__PURE__ */
|
|
4436
|
+
if (isEndedWithoutKnownWinner || !orderEligibility.canPlaceOrder && resolvedReadOnlyTradingState.kind !== "open") {
|
|
4437
|
+
return /* @__PURE__ */ jsx5(
|
|
3932
4438
|
PlaceOrderResolvedView,
|
|
3933
4439
|
{
|
|
3934
4440
|
tradingState: resolvedReadOnlyTradingState,
|
|
4441
|
+
resolutionTimestamp: (_G = resolvedEventTradingState.resolvesAt) != null ? _G : resolvedReadOnlyTradingState.resolvesAt,
|
|
3935
4442
|
resolvedClaim,
|
|
3936
4443
|
classNames,
|
|
3937
|
-
className
|
|
4444
|
+
className,
|
|
4445
|
+
isSportsEvent: (scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.structureType) === "sport" && !!(scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.sport) && scopedSelectedEvent.sport !== "other_sport"
|
|
3938
4446
|
}
|
|
3939
4447
|
);
|
|
3940
4448
|
}
|
|
3941
|
-
return /* @__PURE__ */
|
|
3942
|
-
/* @__PURE__ */
|
|
4449
|
+
return /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
4450
|
+
/* @__PURE__ */ jsxs4(
|
|
3943
4451
|
Card,
|
|
3944
4452
|
{
|
|
3945
4453
|
className: cn(
|
|
@@ -3956,8 +4464,8 @@ var PlaceOrder = ({
|
|
|
3956
4464
|
headerTitle,
|
|
3957
4465
|
onClose
|
|
3958
4466
|
}),
|
|
3959
|
-
/* @__PURE__ */
|
|
3960
|
-
/* @__PURE__ */
|
|
4467
|
+
/* @__PURE__ */ jsxs4("div", { className: cn("agg-order-panel-content flex flex-col gap-6", classNames == null ? void 0 : classNames.content), children: [
|
|
4468
|
+
/* @__PURE__ */ jsx5(
|
|
3961
4469
|
"div",
|
|
3962
4470
|
{
|
|
3963
4471
|
className: "agg-order-tabs flex items-end border-b border-agg-separator",
|
|
@@ -3968,7 +4476,7 @@ var PlaceOrder = ({
|
|
|
3968
4476
|
{ value: "sell", label: tradingLabels.sell, ref: sellTabRef }
|
|
3969
4477
|
].map((tabItem) => {
|
|
3970
4478
|
const isActive = internalTab === tabItem.value;
|
|
3971
|
-
return /* @__PURE__ */
|
|
4479
|
+
return /* @__PURE__ */ jsxs4(
|
|
3972
4480
|
"button",
|
|
3973
4481
|
{
|
|
3974
4482
|
ref: tabItem.ref,
|
|
@@ -3992,7 +4500,7 @@ var PlaceOrder = ({
|
|
|
3992
4500
|
onKeyDown: (event) => handleTabKeyDown(event, tabItem.value),
|
|
3993
4501
|
children: [
|
|
3994
4502
|
tabItem.label,
|
|
3995
|
-
/* @__PURE__ */
|
|
4503
|
+
/* @__PURE__ */ jsx5(
|
|
3996
4504
|
"span",
|
|
3997
4505
|
{
|
|
3998
4506
|
"aria-hidden": "true",
|
|
@@ -4014,7 +4522,7 @@ var PlaceOrder = ({
|
|
|
4014
4522
|
})
|
|
4015
4523
|
}
|
|
4016
4524
|
),
|
|
4017
|
-
outcomes.length >= 2 ? /* @__PURE__ */
|
|
4525
|
+
outcomes.length >= 2 ? /* @__PURE__ */ jsx5("div", { className: "agg-outcomes flex w-full max-w-full gap-2", children: outcomes.map((outcome, index) => {
|
|
4018
4526
|
var _a2, _b2, _c2;
|
|
4019
4527
|
const price = getDisplayOutcomePrice({
|
|
4020
4528
|
outcomeId: outcome.id,
|
|
@@ -4028,7 +4536,7 @@ var PlaceOrder = ({
|
|
|
4028
4536
|
});
|
|
4029
4537
|
const isActive = outcome.id === scopedSelectedOutcomeId;
|
|
4030
4538
|
const isPositive = resolveIsPositiveOutcome(outcome, index);
|
|
4031
|
-
return /* @__PURE__ */
|
|
4539
|
+
return /* @__PURE__ */ jsxs4(
|
|
4032
4540
|
"button",
|
|
4033
4541
|
{
|
|
4034
4542
|
"data-id": outcome.id,
|
|
@@ -4048,7 +4556,7 @@ var PlaceOrder = ({
|
|
|
4048
4556
|
disabled: !orderEligibility.canPlaceOrder || isResolvedOutcomeCtaLocked,
|
|
4049
4557
|
onClick: () => handleOutcomeChange(outcome.id),
|
|
4050
4558
|
children: [
|
|
4051
|
-
/* @__PURE__ */
|
|
4559
|
+
/* @__PURE__ */ jsx5(
|
|
4052
4560
|
Typography,
|
|
4053
4561
|
{
|
|
4054
4562
|
as: "span",
|
|
@@ -4057,18 +4565,18 @@ var PlaceOrder = ({
|
|
|
4057
4565
|
children: (_c2 = outcome.title) != null ? _c2 : outcome.label
|
|
4058
4566
|
}
|
|
4059
4567
|
),
|
|
4060
|
-
/* @__PURE__ */
|
|
4568
|
+
/* @__PURE__ */ jsx5(Typography, { as: "span", variant: isActive ? "body-strong" : "body", children: formatProbabilityCents(price) })
|
|
4061
4569
|
]
|
|
4062
4570
|
},
|
|
4063
4571
|
outcome.id
|
|
4064
4572
|
);
|
|
4065
4573
|
}) }) : null,
|
|
4066
|
-
/* @__PURE__ */
|
|
4067
|
-
/* @__PURE__ */
|
|
4068
|
-
/* @__PURE__ */
|
|
4069
|
-
isAuthenticated ? isSell ? /* @__PURE__ */
|
|
4070
|
-
/* @__PURE__ */
|
|
4071
|
-
displayedCurrentSellableShares > 0 ? /* @__PURE__ */
|
|
4574
|
+
/* @__PURE__ */ jsxs4("div", { className: "agg-order-amount-section flex items-start justify-between gap-4", children: [
|
|
4575
|
+
/* @__PURE__ */ jsxs4("div", { className: "agg-order-amount-meta flex flex-col", children: [
|
|
4576
|
+
/* @__PURE__ */ jsx5("p", { className: "agg-order-amount-label text-agg-base font-agg-bold leading-agg-6 text-agg-foreground whitespace-nowrap", children: tradingLabels.amount(internalTab) }),
|
|
4577
|
+
isAuthenticated ? isSell ? /* @__PURE__ */ jsx5("div", { className: "agg-balance-value flex items-baseline gap-1.5 text-agg-sm leading-agg-5 text-agg-muted-foreground", children: isCurrentSellableSharesLoading ? /* @__PURE__ */ jsx5(LoadingIcon, { size: "small" }) : /* @__PURE__ */ jsxs4(Fragment3, { children: [
|
|
4578
|
+
/* @__PURE__ */ jsx5("span", { className: "whitespace-pre", children: displayedCurrentSellableSharesLabel }),
|
|
4579
|
+
displayedCurrentSellableShares > 0 ? /* @__PURE__ */ jsx5(
|
|
4072
4580
|
"button",
|
|
4073
4581
|
{
|
|
4074
4582
|
type: "button",
|
|
@@ -4084,9 +4592,9 @@ var PlaceOrder = ({
|
|
|
4084
4592
|
children: tradingLabels.maxShares
|
|
4085
4593
|
}
|
|
4086
4594
|
) : null
|
|
4087
|
-
] }) }) : /* @__PURE__ */
|
|
4595
|
+
] }) }) : /* @__PURE__ */ jsx5("p", { className: "agg-balance-value flex items-center gap-2 text-agg-sm leading-agg-5 text-agg-muted-foreground", children: isBalanceLoading ? /* @__PURE__ */ jsx5(LoadingIcon, { size: "small" }) : tradingLabels.balance(formatUsd(totalBalance)) }) : null
|
|
4088
4596
|
] }),
|
|
4089
|
-
/* @__PURE__ */
|
|
4597
|
+
/* @__PURE__ */ jsx5(
|
|
4090
4598
|
CurrencyInput,
|
|
4091
4599
|
{
|
|
4092
4600
|
value: internalAmount,
|
|
@@ -4095,7 +4603,7 @@ var PlaceOrder = ({
|
|
|
4095
4603
|
isInvalid: isInsufficientBalance || isBelowMinimum,
|
|
4096
4604
|
disabled: !orderEligibility.canPlaceOrder,
|
|
4097
4605
|
prefix: internalTab === "buy" ? "$" : "",
|
|
4098
|
-
decimalPlaces: isSell ?
|
|
4606
|
+
decimalPlaces: isSell ? SELL_SHARE_INPUT_DECIMALS : 2,
|
|
4099
4607
|
classNames: {
|
|
4100
4608
|
input: cn(
|
|
4101
4609
|
"agg-order-amount-input",
|
|
@@ -4106,9 +4614,9 @@ var PlaceOrder = ({
|
|
|
4106
4614
|
}
|
|
4107
4615
|
)
|
|
4108
4616
|
] }),
|
|
4109
|
-
showFeesBreakdown && hasEnteredAmount && !isBelowMinimum && estimatedFeesValue ? /* @__PURE__ */
|
|
4110
|
-
/* @__PURE__ */
|
|
4111
|
-
/* @__PURE__ */
|
|
4617
|
+
showFeesBreakdown && hasEnteredAmount && !isBelowMinimum && estimatedFeesValue ? /* @__PURE__ */ jsxs4("div", { className: "agg-order-fees-section flex items-center justify-between gap-4", children: [
|
|
4618
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-1.5", children: [
|
|
4619
|
+
/* @__PURE__ */ jsx5(
|
|
4112
4620
|
Typography,
|
|
4113
4621
|
{
|
|
4114
4622
|
variant: "text-sm",
|
|
@@ -4116,7 +4624,7 @@ var PlaceOrder = ({
|
|
|
4116
4624
|
children: tradingLabels.estimatedFees
|
|
4117
4625
|
}
|
|
4118
4626
|
),
|
|
4119
|
-
feeBreakdownRows.length > 0 ? /* @__PURE__ */
|
|
4627
|
+
feeBreakdownRows.length > 0 ? /* @__PURE__ */ jsx5(
|
|
4120
4628
|
Tooltip,
|
|
4121
4629
|
{
|
|
4122
4630
|
"aria-label": tradingLabels.estimatedFeesTooltipAria,
|
|
@@ -4128,13 +4636,13 @@ var PlaceOrder = ({
|
|
|
4128
4636
|
icon: "h-3 w-3 text-agg-muted-foreground",
|
|
4129
4637
|
trigger: "h-3 w-3 text-agg-muted-foreground"
|
|
4130
4638
|
},
|
|
4131
|
-
content: /* @__PURE__ */
|
|
4639
|
+
content: /* @__PURE__ */ jsx5("div", { className: "flex w-full flex-col gap-2", children: feeBreakdownRows.map((row) => /* @__PURE__ */ jsxs4(
|
|
4132
4640
|
"div",
|
|
4133
4641
|
{
|
|
4134
4642
|
className: "flex items-center justify-between gap-3 text-agg-sm font-agg-normal leading-agg-5 text-agg-foreground",
|
|
4135
4643
|
children: [
|
|
4136
|
-
/* @__PURE__ */
|
|
4137
|
-
row.kind === "badge" ? /* @__PURE__ */
|
|
4644
|
+
/* @__PURE__ */ jsx5("span", { children: row.label }),
|
|
4645
|
+
row.kind === "badge" ? /* @__PURE__ */ jsx5(
|
|
4138
4646
|
"span",
|
|
4139
4647
|
{
|
|
4140
4648
|
className: cn(
|
|
@@ -4144,7 +4652,7 @@ var PlaceOrder = ({
|
|
|
4144
4652
|
),
|
|
4145
4653
|
children: row.badgeLabel
|
|
4146
4654
|
}
|
|
4147
|
-
) : /* @__PURE__ */
|
|
4655
|
+
) : /* @__PURE__ */ jsx5("span", { className: "text-right", children: row.value })
|
|
4148
4656
|
]
|
|
4149
4657
|
},
|
|
4150
4658
|
row.label
|
|
@@ -4152,12 +4660,12 @@ var PlaceOrder = ({
|
|
|
4152
4660
|
}
|
|
4153
4661
|
) : null
|
|
4154
4662
|
] }),
|
|
4155
|
-
/* @__PURE__ */
|
|
4663
|
+
/* @__PURE__ */ jsx5("p", { className: "text-agg-sm leading-agg-5 text-agg-foreground", children: estimatedFeesValue })
|
|
4156
4664
|
] }) : null,
|
|
4157
|
-
shouldShowSmartRouting ? /* @__PURE__ */
|
|
4158
|
-
/* @__PURE__ */
|
|
4159
|
-
/* @__PURE__ */
|
|
4160
|
-
shouldShowRouteToggle && !isRoutesExpanded ? /* @__PURE__ */
|
|
4665
|
+
shouldShowSmartRouting ? /* @__PURE__ */ jsxs4("div", { className: "agg-route-panel flex flex-col gap-3", children: [
|
|
4666
|
+
/* @__PURE__ */ jsxs4("div", { className: "agg-route-panel-header flex items-center justify-between gap-4", children: [
|
|
4667
|
+
/* @__PURE__ */ jsx5("p", { className: "agg-route-panel-title text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: tradingLabels.smartRouting }),
|
|
4668
|
+
shouldShowRouteToggle && !isRoutesExpanded ? /* @__PURE__ */ jsxs4(
|
|
4161
4669
|
"button",
|
|
4162
4670
|
{
|
|
4163
4671
|
type: "button",
|
|
@@ -4165,8 +4673,8 @@ var PlaceOrder = ({
|
|
|
4165
4673
|
"aria-label": tradingLabels.viewAllRoutes(orderedRouteCards.length),
|
|
4166
4674
|
onClick: () => setIsRoutesExpanded((currentValue) => !currentValue),
|
|
4167
4675
|
children: [
|
|
4168
|
-
/* @__PURE__ */
|
|
4169
|
-
/* @__PURE__ */
|
|
4676
|
+
/* @__PURE__ */ jsx5("span", { children: tradingLabels.viewAllRoutes(orderedRouteCards.length) }),
|
|
4677
|
+
/* @__PURE__ */ jsx5(
|
|
4170
4678
|
Icon,
|
|
4171
4679
|
{
|
|
4172
4680
|
name: "chevron-down",
|
|
@@ -4179,11 +4687,11 @@ var PlaceOrder = ({
|
|
|
4179
4687
|
}
|
|
4180
4688
|
) : null
|
|
4181
4689
|
] }),
|
|
4182
|
-
/* @__PURE__ */
|
|
4183
|
-
/* @__PURE__ */
|
|
4184
|
-
/* @__PURE__ */
|
|
4690
|
+
/* @__PURE__ */ jsx5("div", { className: "agg-route-list flex flex-col gap-2", children: isQuoteLoading ? /* @__PURE__ */ jsxs4("div", { className: "agg-route-loading flex flex-col gap-2", "aria-hidden": "true", children: [
|
|
4691
|
+
/* @__PURE__ */ jsx5(PlaceOrderRouteCardSkeleton, {}),
|
|
4692
|
+
/* @__PURE__ */ jsx5(PlaceOrderRouteCardSkeleton, {})
|
|
4185
4693
|
] }) : visibleRouteCards.length > 0 ? visibleRouteCards.map((card) => {
|
|
4186
|
-
return /* @__PURE__ */
|
|
4694
|
+
return /* @__PURE__ */ jsx5(Fragment2, { children: renderRouteCard({
|
|
4187
4695
|
card,
|
|
4188
4696
|
enableAnimations,
|
|
4189
4697
|
isExpanded: card.kind === "split" ? isSplitDetailOpen : isRoutesExpanded,
|
|
@@ -4193,12 +4701,12 @@ var PlaceOrder = ({
|
|
|
4193
4701
|
}) }, card.id);
|
|
4194
4702
|
}) : null })
|
|
4195
4703
|
] }) : null,
|
|
4196
|
-
hasEnteredAmount && selectedRouteCard && !isQuoteLoading && !isBelowMinimum && orderEligibility.canPlaceOrder ? /* @__PURE__ */
|
|
4197
|
-
/* @__PURE__ */
|
|
4198
|
-
/* @__PURE__ */
|
|
4199
|
-
/* @__PURE__ */
|
|
4704
|
+
hasEnteredAmount && selectedRouteCard && !isQuoteLoading && !isBelowMinimum && orderEligibility.canPlaceOrder ? /* @__PURE__ */ jsxs4("div", { className: "agg-order-summary flex items-start justify-between gap-4", children: [
|
|
4705
|
+
/* @__PURE__ */ jsxs4("div", { className: "agg-order-summary-meta flex flex-col", children: [
|
|
4706
|
+
/* @__PURE__ */ jsx5("p", { className: "agg-order-summary-label text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: tradingLabels.toWin(internalTab) }),
|
|
4707
|
+
/* @__PURE__ */ jsx5("p", { className: "agg-order-summary-hint text-agg-sm leading-agg-5 text-agg-muted-foreground", children: displayedToWinHint })
|
|
4200
4708
|
] }),
|
|
4201
|
-
/* @__PURE__ */
|
|
4709
|
+
/* @__PURE__ */ jsx5(
|
|
4202
4710
|
NumberFlow,
|
|
4203
4711
|
{
|
|
4204
4712
|
value: displayedToWinValue,
|
|
@@ -4213,7 +4721,7 @@ var PlaceOrder = ({
|
|
|
4213
4721
|
}
|
|
4214
4722
|
)
|
|
4215
4723
|
] }) : null,
|
|
4216
|
-
/* @__PURE__ */
|
|
4724
|
+
/* @__PURE__ */ jsxs4(
|
|
4217
4725
|
"div",
|
|
4218
4726
|
{
|
|
4219
4727
|
className: cn(
|
|
@@ -4221,17 +4729,17 @@ var PlaceOrder = ({
|
|
|
4221
4729
|
classNames == null ? void 0 : classNames.footer
|
|
4222
4730
|
),
|
|
4223
4731
|
children: [
|
|
4224
|
-
!shouldShowGeoBlockBanner ? /* @__PURE__ */
|
|
4225
|
-
submissionFeedback ? /* @__PURE__ */
|
|
4732
|
+
!shouldShowGeoBlockBanner ? /* @__PURE__ */ jsxs4("div", { className: "agg-order-alerts flex flex-col gap-3 empty:hidden mb-3", children: [
|
|
4733
|
+
submissionFeedback ? /* @__PURE__ */ jsx5(
|
|
4226
4734
|
InlineAlert,
|
|
4227
4735
|
{
|
|
4228
4736
|
tone: submissionFeedback.tone,
|
|
4229
4737
|
message: submissionFeedback.message
|
|
4230
4738
|
}
|
|
4231
4739
|
) : null,
|
|
4232
|
-
!submissionFeedback && orderEligibility.canPlaceOrder && !isInsufficientBalance && isBelowMinimum ? /* @__PURE__ */
|
|
4233
|
-
!submissionFeedback && orderEligibility.canPlaceOrder && !isInsufficientBalance && !isBelowMinimum && quoteStatus ? /* @__PURE__ */
|
|
4234
|
-
!submissionFeedback && orderEligibility.canPlaceOrder && !isInsufficientBalance && !isBelowMinimum && !quoteStatus && isAuthenticated && hasEnteredAmount && smartRouteErrorMessage ? /* @__PURE__ */
|
|
4740
|
+
!submissionFeedback && orderEligibility.canPlaceOrder && !isInsufficientBalance && isBelowMinimum ? /* @__PURE__ */ jsx5(InlineAlert, { tone: "error", message: belowMinimumMessage }) : null,
|
|
4741
|
+
!submissionFeedback && orderEligibility.canPlaceOrder && !isInsufficientBalance && !isBelowMinimum && quoteStatus ? /* @__PURE__ */ jsx5(InlineAlert, { tone: quoteStatus.tone, message: quoteStatus.message }) : null,
|
|
4742
|
+
!submissionFeedback && orderEligibility.canPlaceOrder && !isInsufficientBalance && !isBelowMinimum && !quoteStatus && isAuthenticated && hasEnteredAmount && smartRouteErrorMessage ? /* @__PURE__ */ jsx5(
|
|
4235
4743
|
InlineAlert,
|
|
4236
4744
|
{
|
|
4237
4745
|
tone: "error",
|
|
@@ -4243,14 +4751,14 @@ var PlaceOrder = ({
|
|
|
4243
4751
|
}
|
|
4244
4752
|
) : null
|
|
4245
4753
|
] }) : null,
|
|
4246
|
-
!submissionFeedback && !shouldShowGeoBlockBanner && orderEligibility.canPlaceOrder && shouldShowInsufficientBalanceAlert ? /* @__PURE__ */
|
|
4754
|
+
!submissionFeedback && !shouldShowGeoBlockBanner && orderEligibility.canPlaceOrder && shouldShowInsufficientBalanceAlert ? /* @__PURE__ */ jsxs4(
|
|
4247
4755
|
"div",
|
|
4248
4756
|
{
|
|
4249
4757
|
className: "agg-order-insufficient-balance-alert flex items-center justify-center gap-2",
|
|
4250
4758
|
role: "status",
|
|
4251
4759
|
"aria-live": "polite",
|
|
4252
4760
|
children: [
|
|
4253
|
-
/* @__PURE__ */
|
|
4761
|
+
/* @__PURE__ */ jsx5(
|
|
4254
4762
|
Icon,
|
|
4255
4763
|
{
|
|
4256
4764
|
name: "warning-filled",
|
|
@@ -4259,11 +4767,11 @@ var PlaceOrder = ({
|
|
|
4259
4767
|
"aria-hidden": "true"
|
|
4260
4768
|
}
|
|
4261
4769
|
),
|
|
4262
|
-
/* @__PURE__ */
|
|
4770
|
+
/* @__PURE__ */ jsx5("span", { className: "text-agg-sm text-agg-foreground", children: tradingLabels.insufficientBalance })
|
|
4263
4771
|
]
|
|
4264
4772
|
}
|
|
4265
4773
|
) : null,
|
|
4266
|
-
!submissionFeedback && !shouldShowGeoBlockBanner && isInsufficientBalance ? /* @__PURE__ */
|
|
4774
|
+
!submissionFeedback && !shouldShowGeoBlockBanner && isInsufficientBalance ? /* @__PURE__ */ jsx5(
|
|
4267
4775
|
Button,
|
|
4268
4776
|
{
|
|
4269
4777
|
size: "large",
|
|
@@ -4273,7 +4781,7 @@ var PlaceOrder = ({
|
|
|
4273
4781
|
onClick: handleDepositRequiredClick,
|
|
4274
4782
|
children: tradingLabels.deposit
|
|
4275
4783
|
}
|
|
4276
|
-
) : needsKycVerification && !submissionFeedback && !shouldShowGeoBlockBanner ? /* @__PURE__ */
|
|
4784
|
+
) : needsKycVerification && !submissionFeedback && !shouldShowGeoBlockBanner ? /* @__PURE__ */ jsx5(InitiateKycButton, { label: tradingLabels.kycRequired, onOpen: openVerifyModal }) : isQuoteLoading && !isActionLoading ? /* @__PURE__ */ jsx5(
|
|
4277
4785
|
Button,
|
|
4278
4786
|
{
|
|
4279
4787
|
size: "large",
|
|
@@ -4282,7 +4790,7 @@ var PlaceOrder = ({
|
|
|
4282
4790
|
disabled: true,
|
|
4283
4791
|
"aria-live": "polite",
|
|
4284
4792
|
"aria-label": routeLoadingMessage != null ? routeLoadingMessage : labels.common.loading,
|
|
4285
|
-
prefix: /* @__PURE__ */
|
|
4793
|
+
prefix: /* @__PURE__ */ jsx5(
|
|
4286
4794
|
"span",
|
|
4287
4795
|
{
|
|
4288
4796
|
className: cn(
|
|
@@ -4294,7 +4802,7 @@ var PlaceOrder = ({
|
|
|
4294
4802
|
),
|
|
4295
4803
|
children: routeLoadingMessage
|
|
4296
4804
|
}
|
|
4297
|
-
) : !isAuthenticated ? /* @__PURE__ */
|
|
4805
|
+
) : !isAuthenticated ? /* @__PURE__ */ jsx5(
|
|
4298
4806
|
Button,
|
|
4299
4807
|
{
|
|
4300
4808
|
size: "large",
|
|
@@ -4305,7 +4813,7 @@ var PlaceOrder = ({
|
|
|
4305
4813
|
onClick: requestAggAuthChooserOpen,
|
|
4306
4814
|
children: tradingLabels.signInToTrade
|
|
4307
4815
|
}
|
|
4308
|
-
) : /* @__PURE__ */
|
|
4816
|
+
) : /* @__PURE__ */ jsx5(
|
|
4309
4817
|
Button,
|
|
4310
4818
|
{
|
|
4311
4819
|
size: "large",
|
|
@@ -4320,8 +4828,8 @@ var PlaceOrder = ({
|
|
|
4320
4828
|
children: actionLabel
|
|
4321
4829
|
}
|
|
4322
4830
|
),
|
|
4323
|
-
!shouldShowGeoBlockBanner && internalTab === "buy" && showFeesBreakdown ? /* @__PURE__ */
|
|
4324
|
-
/* @__PURE__ */
|
|
4831
|
+
!shouldShowGeoBlockBanner && internalTab === "buy" && showFeesBreakdown ? /* @__PURE__ */ jsxs4("div", { className: "agg-order-platform-fee mt-1 flex items-center justify-center gap-1.5 text-agg-sm leading-agg-5 text-agg-muted-foreground", children: [
|
|
4832
|
+
/* @__PURE__ */ jsx5(
|
|
4325
4833
|
Icon,
|
|
4326
4834
|
{
|
|
4327
4835
|
name: "shield-trust",
|
|
@@ -4330,10 +4838,10 @@ var PlaceOrder = ({
|
|
|
4330
4838
|
"aria-hidden": "true"
|
|
4331
4839
|
}
|
|
4332
4840
|
),
|
|
4333
|
-
/* @__PURE__ */
|
|
4841
|
+
/* @__PURE__ */ jsx5(Typography, { variant: "text-xs-caps", className: "text-agg-primary", children: tradingLabels.platformFee })
|
|
4334
4842
|
] }) : null,
|
|
4335
|
-
shouldShowGeoBlockBanner ? /* @__PURE__ */
|
|
4336
|
-
!shouldShowGeoBlockBanner ? /* @__PURE__ */
|
|
4843
|
+
shouldShowGeoBlockBanner ? /* @__PURE__ */ jsx5(GeoBlockBanner, { termsUrl: AGG_TERMS_OF_SERVICE_URL }) : null,
|
|
4844
|
+
!shouldShowGeoBlockBanner ? /* @__PURE__ */ jsx5("p", { className: "agg-order-disclaimer text-center text-agg-xs leading-agg-4 text-agg-muted-foreground", children: tradingLabels.disclaimer }) : null
|
|
4337
4845
|
]
|
|
4338
4846
|
}
|
|
4339
4847
|
)
|
|
@@ -4341,7 +4849,7 @@ var PlaceOrder = ({
|
|
|
4341
4849
|
]
|
|
4342
4850
|
}
|
|
4343
4851
|
),
|
|
4344
|
-
/* @__PURE__ */
|
|
4852
|
+
/* @__PURE__ */ jsx5(
|
|
4345
4853
|
KycVerifyModal,
|
|
4346
4854
|
{
|
|
4347
4855
|
open: isKycVerifyModalOpen,
|
|
@@ -4358,7 +4866,7 @@ var PlaceOrder = ({
|
|
|
4358
4866
|
}
|
|
4359
4867
|
}
|
|
4360
4868
|
),
|
|
4361
|
-
/* @__PURE__ */
|
|
4869
|
+
/* @__PURE__ */ jsx5(
|
|
4362
4870
|
KycSuccessModal,
|
|
4363
4871
|
{
|
|
4364
4872
|
open: showKycSuccessModal,
|
|
@@ -4376,7 +4884,328 @@ var PlaceOrder = ({
|
|
|
4376
4884
|
};
|
|
4377
4885
|
PlaceOrder.displayName = "PlaceOrder";
|
|
4378
4886
|
|
|
4887
|
+
// src/trading/use-claim-winnings.ts
|
|
4888
|
+
import {
|
|
4889
|
+
executionKeys,
|
|
4890
|
+
invalidateBalanceQueries as invalidateBalanceQueries2,
|
|
4891
|
+
invalidatePositionQueries as invalidatePositionQueries2,
|
|
4892
|
+
invalidateUserActivityQueries,
|
|
4893
|
+
useLabels as useLabels2,
|
|
4894
|
+
useQueryClient as useQueryClient2,
|
|
4895
|
+
useRedeem,
|
|
4896
|
+
useRedeemLifecycles
|
|
4897
|
+
} from "@agg-build/hooks";
|
|
4898
|
+
import { useCallback as useCallback4, useEffect as useEffect4, useMemo as useMemo3, useRef as useRef4, useState as useState4 } from "react";
|
|
4899
|
+
var toClaimError = (err) => {
|
|
4900
|
+
if (err instanceof Error) return err;
|
|
4901
|
+
return new Error(String(err));
|
|
4902
|
+
};
|
|
4903
|
+
function useClaimWinnings(options = {}) {
|
|
4904
|
+
const { onClaim, onClaimResult, onClaimSubmitError, externalClaimingKeys } = options;
|
|
4905
|
+
const labels = useLabels2();
|
|
4906
|
+
const claimNotificationLabels = labels.notifications.claim;
|
|
4907
|
+
const toastCtx = useOptionalToast();
|
|
4908
|
+
const queryClient = useQueryClient2();
|
|
4909
|
+
const redeemMutation = useRedeem();
|
|
4910
|
+
const [activeRedeems, setActiveRedeems] = useState4({});
|
|
4911
|
+
const activeClaimKeysRef = useRef4(/* @__PURE__ */ new Set());
|
|
4912
|
+
const pendingClaimToastIdsRef = useRef4({});
|
|
4913
|
+
const submittedClaimToastKeysRef = useRef4(/* @__PURE__ */ new Set());
|
|
4914
|
+
const [submittingClaimKeys, setSubmittingClaimKeys] = useState4({});
|
|
4915
|
+
const lifecycleInputs = useMemo3(
|
|
4916
|
+
() => Object.values(activeRedeems),
|
|
4917
|
+
[activeRedeems]
|
|
4918
|
+
);
|
|
4919
|
+
const lifecycleStates = useRedeemLifecycles(lifecycleInputs);
|
|
4920
|
+
const internalClaimingIds = useMemo3(() => {
|
|
4921
|
+
const out = __spreadValues({}, submittingClaimKeys);
|
|
4922
|
+
for (const [claimKey, active] of Object.entries(activeRedeems)) {
|
|
4923
|
+
const state = lifecycleStates[active.redeemId];
|
|
4924
|
+
if (!state || !state.terminal) out[claimKey] = true;
|
|
4925
|
+
}
|
|
4926
|
+
return out;
|
|
4927
|
+
}, [activeRedeems, lifecycleStates, submittingClaimKeys]);
|
|
4928
|
+
const claimingKeys = externalClaimingKeys != null ? externalClaimingKeys : internalClaimingIds;
|
|
4929
|
+
const isClaiming = useCallback4(
|
|
4930
|
+
(claimKey) => Boolean(externalClaimingKeys == null ? void 0 : externalClaimingKeys[claimKey]) || Boolean(internalClaimingIds[claimKey]),
|
|
4931
|
+
[externalClaimingKeys, internalClaimingIds]
|
|
4932
|
+
);
|
|
4933
|
+
const invalidateClaimUiState = useCallback4(() => {
|
|
4934
|
+
invalidateBalanceQueries2(queryClient);
|
|
4935
|
+
invalidatePositionQueries2(queryClient);
|
|
4936
|
+
queryClient.invalidateQueries({
|
|
4937
|
+
queryKey: executionKeys.claimablePositionsCount(),
|
|
4938
|
+
refetchType: "active"
|
|
4939
|
+
});
|
|
4940
|
+
invalidateUserActivityQueries(queryClient);
|
|
4941
|
+
}, [queryClient]);
|
|
4942
|
+
const claim = useCallback4(
|
|
4943
|
+
(_0) => __async(null, [_0], function* ({ claimKey, winningOutcomeIds, payload }) {
|
|
4944
|
+
if (activeClaimKeysRef.current.has(claimKey) || Boolean(externalClaimingKeys == null ? void 0 : externalClaimingKeys[claimKey]) || internalClaimingIds[claimKey]) {
|
|
4945
|
+
return;
|
|
4946
|
+
}
|
|
4947
|
+
activeClaimKeysRef.current.add(claimKey);
|
|
4948
|
+
setSubmittingClaimKeys((prev) => __spreadProps(__spreadValues({}, prev), { [claimKey]: true }));
|
|
4949
|
+
const pendingToastId = toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.pendingMessage, {
|
|
4950
|
+
title: claimNotificationLabels.pendingTitle,
|
|
4951
|
+
tone: "info"
|
|
4952
|
+
});
|
|
4953
|
+
if (pendingToastId != null) {
|
|
4954
|
+
pendingClaimToastIdsRef.current[claimKey] = pendingToastId;
|
|
4955
|
+
}
|
|
4956
|
+
if (onClaim) {
|
|
4957
|
+
try {
|
|
4958
|
+
yield onClaim(payload);
|
|
4959
|
+
const pendingId = pendingClaimToastIdsRef.current[claimKey];
|
|
4960
|
+
if (pendingId != null) toastCtx == null ? void 0 : toastCtx.dismiss(pendingId);
|
|
4961
|
+
delete pendingClaimToastIdsRef.current[claimKey];
|
|
4962
|
+
toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.successMessage, {
|
|
4963
|
+
title: claimNotificationLabels.successTitle,
|
|
4964
|
+
tone: "success"
|
|
4965
|
+
});
|
|
4966
|
+
} catch (err) {
|
|
4967
|
+
const error = toClaimError(err);
|
|
4968
|
+
console.error("[useClaimWinnings] redeem failed", error);
|
|
4969
|
+
const pendingId = pendingClaimToastIdsRef.current[claimKey];
|
|
4970
|
+
if (pendingId != null) toastCtx == null ? void 0 : toastCtx.dismiss(pendingId);
|
|
4971
|
+
delete pendingClaimToastIdsRef.current[claimKey];
|
|
4972
|
+
toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.failedMessage(error.message), {
|
|
4973
|
+
title: claimNotificationLabels.failedTitle,
|
|
4974
|
+
tone: "error"
|
|
4975
|
+
});
|
|
4976
|
+
onClaimSubmitError == null ? void 0 : onClaimSubmitError(claimKey, error);
|
|
4977
|
+
throw error;
|
|
4978
|
+
} finally {
|
|
4979
|
+
invalidateClaimUiState();
|
|
4980
|
+
activeClaimKeysRef.current.delete(claimKey);
|
|
4981
|
+
setSubmittingClaimKeys((prev) => {
|
|
4982
|
+
const _a = prev, { [claimKey]: _removed } = _a, rest = __objRest(_a, [__restKey(claimKey)]);
|
|
4983
|
+
return rest;
|
|
4984
|
+
});
|
|
4985
|
+
}
|
|
4986
|
+
return;
|
|
4987
|
+
}
|
|
4988
|
+
if (winningOutcomeIds.length === 0) {
|
|
4989
|
+
const error = new Error(claimNotificationLabels.missingOutcomeMessage);
|
|
4990
|
+
console.error("[useClaimWinnings] redeem failed", error);
|
|
4991
|
+
const pendingId = pendingClaimToastIdsRef.current[claimKey];
|
|
4992
|
+
if (pendingId != null) toastCtx == null ? void 0 : toastCtx.dismiss(pendingId);
|
|
4993
|
+
delete pendingClaimToastIdsRef.current[claimKey];
|
|
4994
|
+
toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.failedMessage(error.message), {
|
|
4995
|
+
title: claimNotificationLabels.failedTitle,
|
|
4996
|
+
tone: "error"
|
|
4997
|
+
});
|
|
4998
|
+
onClaimSubmitError == null ? void 0 : onClaimSubmitError(claimKey, error);
|
|
4999
|
+
invalidateClaimUiState();
|
|
5000
|
+
activeClaimKeysRef.current.delete(claimKey);
|
|
5001
|
+
setSubmittingClaimKeys((prev) => {
|
|
5002
|
+
const _a = prev, { [claimKey]: _removed } = _a, rest = __objRest(_a, [__restKey(claimKey)]);
|
|
5003
|
+
return rest;
|
|
5004
|
+
});
|
|
5005
|
+
throw error;
|
|
5006
|
+
}
|
|
5007
|
+
try {
|
|
5008
|
+
const response = yield redeemMutation.mutateAsync({
|
|
5009
|
+
venueMarketOutcomeIds: winningOutcomeIds
|
|
5010
|
+
});
|
|
5011
|
+
const expectedOutcomeIds = [];
|
|
5012
|
+
const preFailedOutcomeIds = [];
|
|
5013
|
+
const preFailedReasons = {};
|
|
5014
|
+
const preConfirmedOutcomeIds = [];
|
|
5015
|
+
const preConfirmedTxHashes = {};
|
|
5016
|
+
for (const result of response.results) {
|
|
5017
|
+
if (result.status === "submitted") {
|
|
5018
|
+
expectedOutcomeIds.push(result.venueMarketOutcomeId);
|
|
5019
|
+
} else if (result.status === "confirmed") {
|
|
5020
|
+
preConfirmedOutcomeIds.push(result.venueMarketOutcomeId);
|
|
5021
|
+
preConfirmedTxHashes[result.venueMarketOutcomeId] = result.txHash;
|
|
5022
|
+
} else if (result.status === "ineligible" || result.status === "rejected") {
|
|
5023
|
+
preFailedOutcomeIds.push(result.venueMarketOutcomeId);
|
|
5024
|
+
preFailedReasons[result.venueMarketOutcomeId] = result.reason;
|
|
5025
|
+
}
|
|
5026
|
+
}
|
|
5027
|
+
if (expectedOutcomeIds.length > 0) {
|
|
5028
|
+
const pendingId = pendingClaimToastIdsRef.current[claimKey];
|
|
5029
|
+
if (pendingId != null) toastCtx == null ? void 0 : toastCtx.dismiss(pendingId);
|
|
5030
|
+
delete pendingClaimToastIdsRef.current[claimKey];
|
|
5031
|
+
submittedClaimToastKeysRef.current.add(claimKey);
|
|
5032
|
+
toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.submittedMessage, {
|
|
5033
|
+
title: claimNotificationLabels.submittedTitle,
|
|
5034
|
+
tone: "success"
|
|
5035
|
+
});
|
|
5036
|
+
}
|
|
5037
|
+
setActiveRedeems((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
5038
|
+
[claimKey]: {
|
|
5039
|
+
redeemId: response.redeemId,
|
|
5040
|
+
expectedOutcomeIds,
|
|
5041
|
+
preFailedOutcomeIds,
|
|
5042
|
+
preFailedReasons,
|
|
5043
|
+
preConfirmedOutcomeIds,
|
|
5044
|
+
preConfirmedTxHashes
|
|
5045
|
+
}
|
|
5046
|
+
}));
|
|
5047
|
+
yield queryClient.invalidateQueries({ queryKey: ["current-user"] });
|
|
5048
|
+
} catch (err) {
|
|
5049
|
+
const error = toClaimError(err);
|
|
5050
|
+
console.error("[useClaimWinnings] redeem failed", error);
|
|
5051
|
+
const pendingId = pendingClaimToastIdsRef.current[claimKey];
|
|
5052
|
+
if (pendingId != null) toastCtx == null ? void 0 : toastCtx.dismiss(pendingId);
|
|
5053
|
+
delete pendingClaimToastIdsRef.current[claimKey];
|
|
5054
|
+
toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.failedMessage(error.message), {
|
|
5055
|
+
title: claimNotificationLabels.failedTitle,
|
|
5056
|
+
tone: "error"
|
|
5057
|
+
});
|
|
5058
|
+
onClaimSubmitError == null ? void 0 : onClaimSubmitError(claimKey, error);
|
|
5059
|
+
throw error;
|
|
5060
|
+
} finally {
|
|
5061
|
+
activeClaimKeysRef.current.delete(claimKey);
|
|
5062
|
+
setSubmittingClaimKeys((prev) => {
|
|
5063
|
+
const _a = prev, { [claimKey]: _removed } = _a, rest = __objRest(_a, [__restKey(claimKey)]);
|
|
5064
|
+
return rest;
|
|
5065
|
+
});
|
|
5066
|
+
}
|
|
5067
|
+
}),
|
|
5068
|
+
[
|
|
5069
|
+
claimNotificationLabels,
|
|
5070
|
+
externalClaimingKeys,
|
|
5071
|
+
internalClaimingIds,
|
|
5072
|
+
invalidateClaimUiState,
|
|
5073
|
+
onClaim,
|
|
5074
|
+
onClaimSubmitError,
|
|
5075
|
+
queryClient,
|
|
5076
|
+
redeemMutation,
|
|
5077
|
+
toastCtx
|
|
5078
|
+
]
|
|
5079
|
+
);
|
|
5080
|
+
const firedTerminalRef = useRef4({});
|
|
5081
|
+
useEffect4(() => {
|
|
5082
|
+
var _a, _b;
|
|
5083
|
+
for (const [claimKey, active] of Object.entries(activeRedeems)) {
|
|
5084
|
+
const state = lifecycleStates[active.redeemId];
|
|
5085
|
+
if (!state || !state.terminal) continue;
|
|
5086
|
+
if (firedTerminalRef.current[active.redeemId]) continue;
|
|
5087
|
+
firedTerminalRef.current[active.redeemId] = true;
|
|
5088
|
+
onClaimResult == null ? void 0 : onClaimResult(claimKey, {
|
|
5089
|
+
allConfirmed: state.allConfirmed,
|
|
5090
|
+
anyFailed: state.anyFailed,
|
|
5091
|
+
errorMessage: state.errorMessage
|
|
5092
|
+
});
|
|
5093
|
+
const pendingId = pendingClaimToastIdsRef.current[claimKey];
|
|
5094
|
+
if (pendingId != null) toastCtx == null ? void 0 : toastCtx.dismiss(pendingId);
|
|
5095
|
+
delete pendingClaimToastIdsRef.current[claimKey];
|
|
5096
|
+
if (state.allConfirmed) {
|
|
5097
|
+
if (!submittedClaimToastKeysRef.current.has(claimKey)) {
|
|
5098
|
+
toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.successMessage, {
|
|
5099
|
+
title: claimNotificationLabels.successTitle,
|
|
5100
|
+
tone: "success"
|
|
5101
|
+
});
|
|
5102
|
+
}
|
|
5103
|
+
} else if (state.anyFailed) {
|
|
5104
|
+
const hasConfirmedLeg = Object.values(state.legs).some((leg) => leg.status === "confirmed");
|
|
5105
|
+
if (hasConfirmedLeg) {
|
|
5106
|
+
toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.partialMessage((_a = state.errorMessage) != null ? _a : void 0), {
|
|
5107
|
+
title: claimNotificationLabels.partialTitle,
|
|
5108
|
+
tone: "warning"
|
|
5109
|
+
});
|
|
5110
|
+
} else {
|
|
5111
|
+
toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.failedMessage((_b = state.errorMessage) != null ? _b : void 0), {
|
|
5112
|
+
title: claimNotificationLabels.failedTitle,
|
|
5113
|
+
tone: "error"
|
|
5114
|
+
});
|
|
5115
|
+
}
|
|
5116
|
+
}
|
|
5117
|
+
submittedClaimToastKeysRef.current.delete(claimKey);
|
|
5118
|
+
invalidateClaimUiState();
|
|
5119
|
+
delete firedTerminalRef.current[active.redeemId];
|
|
5120
|
+
setActiveRedeems((prev) => {
|
|
5121
|
+
const _a2 = prev, { [claimKey]: _removed } = _a2, rest = __objRest(_a2, [__restKey(claimKey)]);
|
|
5122
|
+
return rest;
|
|
5123
|
+
});
|
|
5124
|
+
}
|
|
5125
|
+
}, [
|
|
5126
|
+
activeRedeems,
|
|
5127
|
+
claimNotificationLabels,
|
|
5128
|
+
invalidateClaimUiState,
|
|
5129
|
+
lifecycleStates,
|
|
5130
|
+
onClaimResult,
|
|
5131
|
+
toastCtx
|
|
5132
|
+
]);
|
|
5133
|
+
return { claim, claimingKeys, isClaiming };
|
|
5134
|
+
}
|
|
5135
|
+
|
|
5136
|
+
// src/trading/use-resolved-market-claim.ts
|
|
5137
|
+
import {
|
|
5138
|
+
computeClosedPositionTotals,
|
|
5139
|
+
resolveMarketTradingState as resolveMarketTradingState2,
|
|
5140
|
+
useAggAuthState as useAggAuthState2,
|
|
5141
|
+
useExecutionPositions as useExecutionPositions2
|
|
5142
|
+
} from "@agg-build/hooks";
|
|
5143
|
+
import { useMemo as useMemo4 } from "react";
|
|
5144
|
+
var sharesFormatter = new Intl.NumberFormat("en-US", { maximumFractionDigits: 2 });
|
|
5145
|
+
var dateFormatter = new Intl.DateTimeFormat("en-US", {
|
|
5146
|
+
month: "short",
|
|
5147
|
+
day: "numeric",
|
|
5148
|
+
year: "numeric"
|
|
5149
|
+
});
|
|
5150
|
+
var formatResolutionDate = (value) => {
|
|
5151
|
+
if (!value) return "";
|
|
5152
|
+
const date = new Date(value);
|
|
5153
|
+
if (Number.isNaN(date.getTime())) return "";
|
|
5154
|
+
return dateFormatter.format(date);
|
|
5155
|
+
};
|
|
5156
|
+
function useResolvedMarketClaim(options = {}) {
|
|
5157
|
+
var _a;
|
|
5158
|
+
const { market, enabled = true, executionMode } = options;
|
|
5159
|
+
const { isAuthenticated } = useAggAuthState2();
|
|
5160
|
+
const tradingState = useMemo4(() => resolveMarketTradingState2(market), [market]);
|
|
5161
|
+
const isResolved = tradingState.kind === "resolved";
|
|
5162
|
+
const marketId = (_a = market == null ? void 0 : market.id) != null ? _a : null;
|
|
5163
|
+
const shouldFetch = Boolean(enabled && isAuthenticated && isResolved && marketId);
|
|
5164
|
+
const { positions } = useExecutionPositions2(__spreadValues({
|
|
5165
|
+
enabled: shouldFetch,
|
|
5166
|
+
status: "active",
|
|
5167
|
+
limit: 50
|
|
5168
|
+
}, executionMode === "paper" ? { mode: "paper" } : {}));
|
|
5169
|
+
const claimWinnings = useClaimWinnings();
|
|
5170
|
+
return useMemo4(() => {
|
|
5171
|
+
var _a2, _b, _c;
|
|
5172
|
+
if (!shouldFetch || !marketId) return void 0;
|
|
5173
|
+
const group = positions.find(
|
|
5174
|
+
(candidate) => candidate.targetMarketId === marketId
|
|
5175
|
+
);
|
|
5176
|
+
if (!group || group.venueMarket.status !== "resolved") return void 0;
|
|
5177
|
+
const winningOutcomes = group.venueMarket.venueMarketOutcomes.filter(
|
|
5178
|
+
(outcome) => outcome.winner === true && outcome.totalSize > 0
|
|
5179
|
+
);
|
|
5180
|
+
if (winningOutcomes.length === 0) return void 0;
|
|
5181
|
+
const totals = computeClosedPositionTotals(group);
|
|
5182
|
+
const winningShares = winningOutcomes.reduce((sum, outcome) => sum + outcome.totalSize, 0);
|
|
5183
|
+
const winningOutcomeLabel = ((_b = (_a2 = winningOutcomes[0]) == null ? void 0 : _a2.title) == null ? void 0 : _b.trim()) || ((_c = winningOutcomes[0]) == null ? void 0 : _c.label) || "";
|
|
5184
|
+
const claimKey = group.targetMarketId;
|
|
5185
|
+
const canClaim = group.redeemStatus === "eligible" && totals.winningOutcomeIds.length > 0;
|
|
5186
|
+
return {
|
|
5187
|
+
resolutionDateLabel: formatResolutionDate(group.resolutionDate),
|
|
5188
|
+
winningOutcomeLabel,
|
|
5189
|
+
sharesLabel: `${sharesFormatter.format(winningShares)} ${winningOutcomeLabel}`.trim(),
|
|
5190
|
+
// Payout is always shown with 2 decimals (e.g. "$8.50"), matching the
|
|
5191
|
+
// resolved-earnings design and the profile positions list.
|
|
5192
|
+
totalPayoutLabel: formatUsd(totals.amountWon, {
|
|
5193
|
+
minimumFractionDigits: 2,
|
|
5194
|
+
maximumFractionDigits: 2
|
|
5195
|
+
}),
|
|
5196
|
+
isClaiming: claimWinnings.isClaiming(claimKey),
|
|
5197
|
+
onClaim: canClaim ? () => {
|
|
5198
|
+
void claimWinnings.claim({
|
|
5199
|
+
claimKey,
|
|
5200
|
+
winningOutcomeIds: totals.winningOutcomeIds
|
|
5201
|
+
});
|
|
5202
|
+
} : void 0
|
|
5203
|
+
};
|
|
5204
|
+
}, [claimWinnings, marketId, positions, shouldFetch]);
|
|
5205
|
+
}
|
|
5206
|
+
|
|
4379
5207
|
export {
|
|
5208
|
+
AggNotificationEventsProvider,
|
|
4380
5209
|
parseVenue,
|
|
4381
5210
|
parseAmount,
|
|
4382
5211
|
SettlementDetails,
|
|
@@ -4386,5 +5215,7 @@ export {
|
|
|
4386
5215
|
requestAggWithdrawModalOpen,
|
|
4387
5216
|
PlaceOrderFailureView,
|
|
4388
5217
|
PlaceOrderSuccessView,
|
|
4389
|
-
PlaceOrder
|
|
5218
|
+
PlaceOrder,
|
|
5219
|
+
useClaimWinnings,
|
|
5220
|
+
useResolvedMarketClaim
|
|
4390
5221
|
};
|