@agg-build/ui 4.7.3 → 4.9.0

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.
Files changed (80) hide show
  1. package/dist/{chunk-2347CDTT.mjs → chunk-GG57TRNE.mjs} +393 -155
  2. package/dist/{chunk-SQ4BA3CC.mjs → chunk-GKYBQEBC.mjs} +465 -172
  3. package/dist/{chunk-3X5ICUUC.mjs → chunk-GVIS3YXU.mjs} +2 -2
  4. package/dist/{chunk-XR6C3MZX.mjs → chunk-H7L4HDXS.mjs} +266 -162
  5. package/dist/{chunk-UQ7XJIAZ.mjs → chunk-NYL6A6AD.mjs} +953 -785
  6. package/dist/{chunk-MAQ52KM5.mjs → chunk-TNNLRRHC.mjs} +1 -1
  7. package/dist/{chunk-G5PNGOTL.mjs → chunk-XQLLZTEW.mjs} +296 -166
  8. package/dist/events.js +1195 -1041
  9. package/dist/events.mjs +3 -3
  10. package/dist/index.js +4729 -3773
  11. package/dist/index.mjs +58 -19
  12. package/dist/modals.js +1886 -1181
  13. package/dist/modals.mjs +12 -4
  14. package/dist/pages.js +3554 -2873
  15. package/dist/pages.mjs +6 -6
  16. package/dist/primitives.js +953 -785
  17. package/dist/primitives.mjs +1 -1
  18. package/dist/styles.css +1 -1
  19. package/dist/tailwind.css +1 -1
  20. package/dist/trading.js +2258 -1711
  21. package/dist/trading.mjs +10 -6
  22. package/dist/types/index.d.mts +1 -0
  23. package/dist/types/index.d.ts +1 -0
  24. package/dist/types/kyc/index.d.mts +3 -0
  25. package/dist/types/kyc/index.d.ts +3 -0
  26. package/dist/types/kyc/shared-kyc-modal.d.mts +12 -0
  27. package/dist/types/kyc/shared-kyc-modal.d.ts +12 -0
  28. package/dist/types/kyc/shared-kyc.d.mts +31 -0
  29. package/dist/types/kyc/shared-kyc.d.ts +31 -0
  30. package/dist/types/kyc/use-shared-kyc-flow.d.mts +19 -0
  31. package/dist/types/kyc/use-shared-kyc-flow.d.ts +19 -0
  32. package/dist/types/modals/index.d.mts +2 -0
  33. package/dist/types/modals/index.d.ts +2 -0
  34. package/dist/types/pages/event-market/event-market.shared.d.mts +2 -1
  35. package/dist/types/pages/event-market/event-market.shared.d.ts +2 -1
  36. package/dist/types/pages/event-market/event-market.types.d.mts +2 -0
  37. package/dist/types/pages/event-market/event-market.types.d.ts +2 -0
  38. package/dist/types/pages/event-market/sports-event-market-page.d.mts +1 -1
  39. package/dist/types/pages/event-market/sports-event-market-page.d.ts +1 -1
  40. package/dist/types/pages/user-profile/components/positions-value-card.d.mts +17 -1
  41. package/dist/types/pages/user-profile/components/positions-value-card.d.ts +17 -1
  42. package/dist/types/pages/user-profile/components/user-info-card.d.mts +11 -1
  43. package/dist/types/pages/user-profile/components/user-info-card.d.ts +11 -1
  44. package/dist/types/paper-trading/index.d.mts +6 -0
  45. package/dist/types/paper-trading/index.d.ts +6 -0
  46. package/dist/types/paper-trading/paper-onboarding-modal.d.mts +15 -0
  47. package/dist/types/paper-trading/paper-onboarding-modal.d.ts +15 -0
  48. package/dist/types/paper-trading/paper-onboarding-modal.types.d.mts +33 -0
  49. package/dist/types/paper-trading/paper-onboarding-modal.types.d.ts +33 -0
  50. package/dist/types/paper-trading/paper-trading-badge.d.mts +50 -0
  51. package/dist/types/paper-trading/paper-trading-badge.d.ts +50 -0
  52. package/dist/types/paper-trading/paper-trading-onboarding.d.mts +16 -0
  53. package/dist/types/paper-trading/paper-trading-onboarding.d.ts +16 -0
  54. package/dist/types/primitives/header/header.types.d.mts +16 -0
  55. package/dist/types/primitives/header/header.types.d.ts +16 -0
  56. package/dist/types/primitives/header/index.d.mts +1 -1
  57. package/dist/types/primitives/header/index.d.ts +1 -1
  58. package/dist/types/primitives/icon/registry.d.mts +20 -0
  59. package/dist/types/primitives/icon/registry.d.ts +20 -0
  60. package/dist/types/primitives/icon/svg/paper-buying-power.d.mts +11 -0
  61. package/dist/types/primitives/icon/svg/paper-buying-power.d.ts +11 -0
  62. package/dist/types/primitives/icon/svg/paper-earnings.d.mts +11 -0
  63. package/dist/types/primitives/icon/svg/paper-earnings.d.ts +11 -0
  64. package/dist/types/primitives/icon/svg/paper-onboarding-funds.d.mts +12 -0
  65. package/dist/types/primitives/icon/svg/paper-onboarding-funds.d.ts +12 -0
  66. package/dist/types/primitives/icon/svg/paper-onboarding-markets.d.mts +12 -0
  67. package/dist/types/primitives/icon/svg/paper-onboarding-markets.d.ts +12 -0
  68. package/dist/types/primitives/icon/svg/paper-onboarding-performance.d.mts +12 -0
  69. package/dist/types/primitives/icon/svg/paper-onboarding-performance.d.ts +12 -0
  70. package/dist/types/primitives/modal/modal.types.d.mts +6 -0
  71. package/dist/types/primitives/modal/modal.types.d.ts +6 -0
  72. package/dist/types/trading/index.d.mts +1 -0
  73. package/dist/types/trading/index.d.ts +1 -0
  74. package/dist/types/trading/place-order/index.d.mts +1 -1
  75. package/dist/types/trading/place-order/index.d.ts +1 -1
  76. package/dist/types/trading/place-order/index.place-order.types.d.mts +8 -0
  77. package/dist/types/trading/place-order/index.place-order.types.d.ts +8 -0
  78. package/dist/types/trading/types.d.mts +2 -0
  79. package/dist/types/trading/types.d.ts +2 -0
  80. package/package.json +3 -3
@@ -9,12 +9,13 @@ import {
9
9
  getTradingVenueLabel,
10
10
  prepareSettlementDifferences,
11
11
  resolveOrderEligibilityMessage
12
- } from "./chunk-MAQ52KM5.mjs";
12
+ } from "./chunk-TNNLRRHC.mjs";
13
13
  import {
14
14
  ConnectKalshiModal,
15
15
  GeoBlockBanner,
16
+ SharedKycModal,
16
17
  subscribeAggDepositNotification
17
- } from "./chunk-XR6C3MZX.mjs";
18
+ } from "./chunk-H7L4HDXS.mjs";
18
19
  import {
19
20
  AGG_TERMS_OF_SERVICE_URL,
20
21
  Button,
@@ -47,7 +48,7 @@ import {
47
48
  resolveResolvedOutcomeLabel,
48
49
  skeletonViews,
49
50
  useOptionalToast
50
- } from "./chunk-UQ7XJIAZ.mjs";
51
+ } from "./chunk-NYL6A6AD.mjs";
51
52
 
52
53
  // src/trading/types.ts
53
54
  import { Venue, enumGuard, isFiniteNonNeg, safeParse } from "@agg-build/sdk";
@@ -158,19 +159,221 @@ import {
158
159
  useSdkUiConfig,
159
160
  useSmartRoute,
160
161
  useVenueKeyStatus,
161
- useVenueSellQuotes
162
+ useVenueSellQuotes,
163
+ useResolvedExecutionMode
162
164
  } from "@agg-build/hooks";
163
165
  import {
164
166
  adjustLimitPriceRawToTick,
165
167
  LIMIT_PRICE_RAW_SCALE as LIMIT_ORDER_RAW_SCALE,
166
- Venue as Venue3
168
+ Venue as Venue4
167
169
  } from "@agg-build/sdk";
168
170
  import NumberFlow from "@number-flow/react";
169
171
  import * as Popover from "@radix-ui/react-popover";
170
172
  import dayjs from "dayjs";
171
173
  import timezone from "dayjs/plugin/timezone";
172
174
  import utc from "dayjs/plugin/utc";
173
- import { Fragment as Fragment2, useCallback as useCallback2, useEffect as useEffect2, useId, useMemo, useRef as useRef2, useState } from "react";
175
+ import { Fragment as Fragment2, useCallback as useCallback3, useEffect as useEffect3, useId, useMemo, useRef as useRef3, useState as useState2 } from "react";
176
+
177
+ // src/kyc/shared-kyc.ts
178
+ import { Venue as Venue2 } from "@agg-build/sdk";
179
+ var TEMPORARY_SHARED_KYC_VENUES = /* @__PURE__ */ new Set([Venue2.novig, Venue2.prophetx]);
180
+ var venueRequiresSharedKyc = ({
181
+ venue,
182
+ requiresKyc
183
+ }) => {
184
+ if (requiresKyc != null) return requiresKyc;
185
+ if (!venue) return false;
186
+ return TEMPORARY_SHARED_KYC_VENUES.has(venue.trim().toLowerCase());
187
+ };
188
+ var createAggClientSharedKycInitiator = (client) => {
189
+ return ({ venue, redirectUri }) => client.initiateKyc(venue, redirectUri);
190
+ };
191
+
192
+ // src/kyc/use-shared-kyc-flow.ts
193
+ import { useCallback, useEffect, useRef, useState } from "react";
194
+ var SHARED_KYC_PENDING_STORAGE_KEY = "agg_shared_kyc_pending";
195
+ var KYC_RETURN_VENUE_PARAM = "venue";
196
+ var KYC_RETURN_STATUS_PARAM = "kyc_status";
197
+ var readPendingState = () => {
198
+ var _a;
199
+ if (typeof window === "undefined") return null;
200
+ const rawValue = window.sessionStorage.getItem(SHARED_KYC_PENDING_STORAGE_KEY);
201
+ if (!rawValue) return null;
202
+ try {
203
+ const parsed = JSON.parse(rawValue);
204
+ if (!parsed.venue) return null;
205
+ return { venue: parsed.venue, userId: (_a = parsed.userId) != null ? _a : null };
206
+ } catch (e) {
207
+ return null;
208
+ }
209
+ };
210
+ var clearPendingState = () => {
211
+ if (typeof window === "undefined") return;
212
+ window.sessionStorage.removeItem(SHARED_KYC_PENDING_STORAGE_KEY);
213
+ };
214
+ var cleanReturnUrl = () => {
215
+ const url = new URL(window.location.href);
216
+ url.searchParams.delete(KYC_RETURN_VENUE_PARAM);
217
+ url.searchParams.delete(KYC_RETURN_STATUS_PARAM);
218
+ window.history.replaceState(null, "", `${url.pathname}${url.search}${url.hash}`);
219
+ };
220
+ var useSharedKycFlow = ({
221
+ integration,
222
+ userId,
223
+ fallbackErrorMessage
224
+ }) => {
225
+ const [activeVenue, setActiveVenue] = useState(null);
226
+ const [errorMessage, setErrorMessage] = useState();
227
+ const [isModalOpen, setIsModalOpen] = useState(false);
228
+ const [modalState, setModalState] = useState("initial");
229
+ const returnRequestRef = useRef(null);
230
+ const ownerId = userId != null ? userId : null;
231
+ const currentUserRef = useRef(ownerId);
232
+ currentUserRef.current = ownerId;
233
+ const modalOwnerRef = useRef(ownerId);
234
+ const inFlightRef = useRef(null);
235
+ const integrationRef = useRef(integration);
236
+ integrationRef.current = integration;
237
+ const fallbackRef = useRef(fallbackErrorMessage);
238
+ fallbackRef.current = fallbackErrorMessage;
239
+ const integrationEnabled = integration !== void 0;
240
+ useEffect(
241
+ () => () => {
242
+ var _a, _b;
243
+ if (((_a = inFlightRef.current) == null ? void 0 : _a.ownerId) === ownerId) inFlightRef.current = null;
244
+ if (currentUserRef.current !== ownerId) {
245
+ if (((_b = returnRequestRef.current) == null ? void 0 : _b.ownerId) === ownerId) returnRequestRef.current = null;
246
+ if (modalOwnerRef.current === ownerId) modalOwnerRef.current = void 0;
247
+ }
248
+ },
249
+ [ownerId]
250
+ );
251
+ const closeModal = useCallback(() => {
252
+ if (modalState === "initiating") return;
253
+ setIsModalOpen(false);
254
+ setErrorMessage(void 0);
255
+ if (modalState !== "success") setModalState("initial");
256
+ }, [modalState]);
257
+ const openForVenue = useCallback(
258
+ (venue) => {
259
+ if ((integration == null ? void 0 : integration.status) === "verified") return;
260
+ modalOwnerRef.current = ownerId;
261
+ setActiveVenue(venue);
262
+ setErrorMessage(void 0);
263
+ setModalState("initial");
264
+ setIsModalOpen(true);
265
+ },
266
+ [integration == null ? void 0 : integration.status, ownerId]
267
+ );
268
+ const startVerification = useCallback(() => __async(null, null, function* () {
269
+ var _a, _b, _c;
270
+ if (!activeVenue || !integration || integration.status === "verified") return;
271
+ if (modalOwnerRef.current !== ownerId || ((_a = inFlightRef.current) == null ? void 0 : _a.ownerId) === ownerId) return;
272
+ const token = /* @__PURE__ */ Symbol("kyc-initiation");
273
+ inFlightRef.current = { ownerId, token };
274
+ const isCurrent = () => {
275
+ var _a2;
276
+ return currentUserRef.current === ownerId && ((_a2 = inFlightRef.current) == null ? void 0 : _a2.token) === token;
277
+ };
278
+ setErrorMessage(void 0);
279
+ setModalState("initiating");
280
+ try {
281
+ if (modalState === "pending") {
282
+ const status = yield integration.refreshStatus();
283
+ if (!isCurrent()) return;
284
+ setModalState(status === "verified" ? "success" : "pending");
285
+ return;
286
+ }
287
+ const redirectUri = window.location.href;
288
+ const result = yield integration.initiateVerification({ venue: activeVenue, redirectUri });
289
+ if (!isCurrent()) return;
290
+ if (!result.kycUrl) {
291
+ const status = yield integration.refreshStatus();
292
+ if (!isCurrent()) return;
293
+ if (status === "verified") {
294
+ clearPendingState();
295
+ setModalState("success");
296
+ return;
297
+ }
298
+ throw new Error(fallbackErrorMessage);
299
+ }
300
+ window.sessionStorage.setItem(
301
+ SHARED_KYC_PENDING_STORAGE_KEY,
302
+ JSON.stringify({ venue: activeVenue, userId: userId != null ? userId : null })
303
+ );
304
+ ((_b = integration.navigate) != null ? _b : window.location.assign.bind(window.location))(result.kycUrl);
305
+ } catch (error) {
306
+ if (!isCurrent()) return;
307
+ clearPendingState();
308
+ setErrorMessage(
309
+ error instanceof Error && error.message ? error.message : fallbackErrorMessage
310
+ );
311
+ setModalState(modalState === "pending" ? "pending" : "error");
312
+ } finally {
313
+ if (((_c = inFlightRef.current) == null ? void 0 : _c.token) === token) inFlightRef.current = null;
314
+ }
315
+ }), [activeVenue, fallbackErrorMessage, integration, modalState, userId, ownerId]);
316
+ useEffect(() => {
317
+ const activeIntegration = integrationRef.current;
318
+ if (!activeIntegration || typeof window === "undefined") return;
319
+ const pendingState = readPendingState();
320
+ if (!pendingState || pendingState.userId !== ownerId) return;
321
+ const url = new URL(window.location.href);
322
+ if (url.searchParams.get(KYC_RETURN_VENUE_PARAM) !== pendingState.venue || !url.searchParams.has(KYC_RETURN_STATUS_PARAM)) {
323
+ return;
324
+ }
325
+ if (!returnRequestRef.current || returnRequestRef.current.ownerId !== ownerId || returnRequestRef.current.venue !== pendingState.venue) {
326
+ returnRequestRef.current = {
327
+ ownerId,
328
+ venue: pendingState.venue,
329
+ promise: Promise.resolve().then(() => activeIntegration.refreshStatus())
330
+ };
331
+ }
332
+ const statusRequest = returnRequestRef.current.promise;
333
+ modalOwnerRef.current = ownerId;
334
+ setActiveVenue(pendingState.venue);
335
+ setIsModalOpen(true);
336
+ setModalState("initiating");
337
+ let cancelled = false;
338
+ const isCurrent = () => !cancelled && currentUserRef.current === ownerId;
339
+ const refreshStatus = () => __async(null, null, function* () {
340
+ try {
341
+ const status = yield statusRequest;
342
+ if (!isCurrent()) return;
343
+ if (status === "verified") {
344
+ setModalState("success");
345
+ } else {
346
+ setModalState("pending");
347
+ }
348
+ } catch (error) {
349
+ if (!isCurrent()) return;
350
+ setErrorMessage(
351
+ error instanceof Error && error.message ? error.message : fallbackRef.current
352
+ );
353
+ setModalState("error");
354
+ } finally {
355
+ if (isCurrent()) {
356
+ clearPendingState();
357
+ cleanReturnUrl();
358
+ }
359
+ }
360
+ });
361
+ void refreshStatus();
362
+ return () => {
363
+ cancelled = true;
364
+ };
365
+ }, [integrationEnabled, ownerId]);
366
+ const isCurrentModalOpen = isModalOpen && modalOwnerRef.current === ownerId;
367
+ return {
368
+ activeVenue: modalOwnerRef.current === ownerId ? activeVenue : null,
369
+ errorMessage: modalOwnerRef.current === ownerId ? errorMessage : void 0,
370
+ isModalOpen: isCurrentModalOpen,
371
+ modalState: modalOwnerRef.current !== ownerId ? "initial" : isCurrentModalOpen && (integration == null ? void 0 : integration.status) === "verified" ? "success" : modalState,
372
+ closeModal,
373
+ openForVenue,
374
+ startVerification
375
+ };
376
+ };
174
377
 
175
378
  // src/notifications/agg-notification-events-provider.tsx
176
379
  import {
@@ -182,7 +385,7 @@ import {
182
385
  useOptionalAggClient,
183
386
  useUserActivity
184
387
  } from "@agg-build/hooks";
185
- import { useCallback, useEffect, useRef } from "react";
388
+ import { useCallback as useCallback2, useEffect as useEffect2, useRef as useRef2 } from "react";
186
389
  import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
187
390
  function AggNotificationEventsProvider({
188
391
  children,
@@ -271,12 +474,12 @@ function AggNotificationEventsBridge({ enabled, depositActivityLimit }) {
271
474
  const notificationsFeatureEnabled = features.enableNotifications !== false;
272
475
  const effectivelyEnabled = enabled && notificationsFeatureEnabled;
273
476
  const currentUserId = (_a = user == null ? void 0 : user.id) != null ? _a : null;
274
- const firedKeysRef = useRef(/* @__PURE__ */ new Set());
275
- const depositStatusesRef = useRef(/* @__PURE__ */ new Map());
276
- const hasSeededDepositStatusesRef = useRef(false);
277
- const recentClientDepositFingerprintsRef = useRef(/* @__PURE__ */ new Map());
278
- const lastUserIdRef = useRef("uninitialized");
279
- useEffect(() => {
477
+ const firedKeysRef = useRef2(/* @__PURE__ */ new Set());
478
+ const depositStatusesRef = useRef2(/* @__PURE__ */ new Map());
479
+ const hasSeededDepositStatusesRef = useRef2(false);
480
+ const recentClientDepositFingerprintsRef = useRef2(/* @__PURE__ */ new Map());
481
+ const lastUserIdRef = useRef2("uninitialized");
482
+ useEffect2(() => {
280
483
  if (lastUserIdRef.current === currentUserId) return;
281
484
  lastUserIdRef.current = currentUserId;
282
485
  firedKeysRef.current = /* @__PURE__ */ new Set();
@@ -285,7 +488,7 @@ function AggNotificationEventsBridge({ enabled, depositActivityLimit }) {
285
488
  hasSeededDepositStatusesRef.current = false;
286
489
  recentClientDepositFingerprintsRef.current = /* @__PURE__ */ new Map();
287
490
  }, [currentUserId]);
288
- const fireOnce = useCallback(
491
+ const fireOnce = useCallback2(
289
492
  (key, tone, title, message, detail) => {
290
493
  if (!effectivelyEnabled) return;
291
494
  const toast = toastCtx == null ? void 0 : toastCtx.toast;
@@ -296,7 +499,7 @@ function AggNotificationEventsBridge({ enabled, depositActivityLimit }) {
296
499
  },
297
500
  [effectivelyEnabled, toastCtx]
298
501
  );
299
- const orderEventCallback = useCallback(
502
+ const orderEventCallback = useCallback2(
300
503
  (event) => {
301
504
  if (!effectivelyEnabled || !isAuthenticated) return;
302
505
  if (!currentUserId || event.userId !== currentUserId) return;
@@ -306,7 +509,7 @@ function AggNotificationEventsBridge({ enabled, depositActivityLimit }) {
306
509
  [currentUserId, effectivelyEnabled, fireOnce, isAuthenticated, labels]
307
510
  );
308
511
  useOnOrderEvent(orderEventCallback);
309
- const withdrawalCallback = useCallback(
512
+ const withdrawalCallback = useCallback2(
310
513
  (event) => {
311
514
  if (!effectivelyEnabled || !isAuthenticated) return;
312
515
  if (!currentUserId || event.userId !== currentUserId) return;
@@ -317,7 +520,7 @@ function AggNotificationEventsBridge({ enabled, depositActivityLimit }) {
317
520
  [currentUserId, effectivelyEnabled, fireOnce, isAuthenticated, labels]
318
521
  );
319
522
  useOnWithdrawalLifecycle(withdrawalCallback);
320
- useEffect(() => {
523
+ useEffect2(() => {
321
524
  if (!effectivelyEnabled || !isAuthenticated || !currentUserId) return;
322
525
  return subscribeAggDepositNotification((event) => {
323
526
  handleClientDepositNotification({
@@ -334,7 +537,7 @@ function AggNotificationEventsBridge({ enabled, depositActivityLimit }) {
334
537
  enabled: effectivelyEnabled && isAuthenticated && currentUserId !== null
335
538
  });
336
539
  const depositActivities = depositActivity.activities;
337
- useEffect(() => {
540
+ useEffect2(() => {
338
541
  if (!effectivelyEnabled || !isAuthenticated || !currentUserId) return;
339
542
  if (!depositActivity.isSuccess) return;
340
543
  handleDepositActivities({
@@ -541,7 +744,7 @@ var requestAggWithdrawModalOpen = () => {
541
744
 
542
745
  // src/trading/fund-kalshi-modal.tsx
543
746
  import { useLabels } from "@agg-build/hooks";
544
- import { Venue as Venue2 } from "@agg-build/sdk";
747
+ import { Venue as Venue3 } from "@agg-build/sdk";
545
748
  import * as Dialog from "@radix-ui/react-dialog";
546
749
  import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
547
750
  var FundKalshiModal = ({ open, onOpenChange }) => {
@@ -563,7 +766,7 @@ var FundKalshiModal = ({ open, onOpenChange }) => {
563
766
  }
564
767
  ),
565
768
  /* @__PURE__ */ jsx3(Modal.Body, { classNames: { root: "!px-5 !py-12 sm:!px-10" }, children: /* @__PURE__ */ jsxs2("div", { className: "flex flex-col items-center gap-8 text-center", children: [
566
- /* @__PURE__ */ jsx3(VenueLogo, { venue: Venue2.kalshi, variant: "logo", size: "large", className: "size-[60px]" }),
769
+ /* @__PURE__ */ jsx3(VenueLogo, { venue: Venue3.kalshi, variant: "logo", size: "large", className: "size-[60px]" }),
567
770
  /* @__PURE__ */ jsxs2("div", { className: "flex flex-col items-center gap-4", children: [
568
771
  /* @__PURE__ */ jsx3(Dialog.Title, { className: "text-agg-2xl font-agg-bold leading-agg-8 text-agg-foreground", children: modalLabels.title }),
569
772
  /* @__PURE__ */ jsx3(Dialog.Description, { className: "max-w-[520px] text-agg-base leading-agg-6 text-agg-foreground", children: modalLabels.description })
@@ -1162,16 +1365,18 @@ var mapQuoteDataToRoutingRows = (quoteData, tradeSide = "buy") => {
1162
1365
  amount: fill.venueQty * fill.avgPrice
1163
1366
  }, tradeSide === "sell" ? { minimumFractionDigits: 2, maximumFractionDigits: 2 } : {}));
1164
1367
  const allocationSharesLabel = `${formatFlooredShareAmount(fill.venueQty, 2)} shares`;
1165
- return {
1368
+ const requiresSharedKyc = venueRequiresSharedKyc({ venue: fill.venue });
1369
+ return __spreadProps(__spreadValues({
1166
1370
  venue: fill.venue,
1167
1371
  label: tradeSide === "sell" ? allocationSharesLabel : allocationValueLabel,
1168
- priceLabel: getTradingRoutePriceLabel(fill.avgPrice),
1372
+ priceLabel: getTradingRoutePriceLabel(fill.avgPrice)
1373
+ }, requiresSharedKyc ? { requiresSharedKyc: true } : {}), {
1169
1374
  resultLabel: tradeSide === "sell" ? allocationValueLabel : getTradingValueLabel({
1170
1375
  amount: fill.venueQty,
1171
1376
  minimumFractionDigits: 2,
1172
1377
  maximumFractionDigits: 2
1173
1378
  })
1174
- };
1379
+ });
1175
1380
  });
1176
1381
  };
1177
1382
  var deriveAggregateOrderStatus = (orderIds, terminalEvents) => {
@@ -1329,6 +1534,9 @@ var buildLiveRouteCards = ({
1329
1534
  const primaryVenue = (_a = quoteData.fills[0]) == null ? void 0 : _a.venue;
1330
1535
  const parsedPrimaryVenue = parseVenue(primaryVenue);
1331
1536
  const isSplit = quoteData.fills.length > 1;
1537
+ const primaryRequiresSharedKyc = quoteData.fills.some(
1538
+ (fill) => venueRequiresSharedKyc({ venue: fill.venue })
1539
+ );
1332
1540
  const averageExecutionPrice = (_b = getPlaceOrderAverageExecutionPrice(quoteData)) != null ? _b : void 0;
1333
1541
  const primaryWinnerVenue = quoteData.fills.length === 1 ? primaryVenue : void 0;
1334
1542
  const isPrimaryRouteGeoBlocked = quoteData.fills.length > 0 && quoteData.fills.some((f) => geoBlockedVenues.has(f.venue));
@@ -1344,6 +1552,7 @@ var buildLiveRouteCards = ({
1344
1552
  quoteData,
1345
1553
  value: primaryResult.value,
1346
1554
  venue: parsedPrimaryVenue.success ? parsedPrimaryVenue.data : void 0,
1555
+ requiresSharedKyc: primaryRequiresSharedKyc,
1347
1556
  isUnavailable: true
1348
1557
  } : {
1349
1558
  id: "live-route",
@@ -1358,10 +1567,11 @@ var buildLiveRouteCards = ({
1358
1567
  description: labels.splitOrderDescription,
1359
1568
  value: primaryResult.value,
1360
1569
  venue: isSplit ? void 0 : parsedPrimaryVenue.success ? parsedPrimaryVenue.data : void 0,
1361
- executionPrice: averageExecutionPrice
1570
+ executionPrice: averageExecutionPrice,
1571
+ requiresSharedKyc: primaryRequiresSharedKyc
1362
1572
  } : null;
1363
1573
  const soloCards = ((_c = quoteData.venueSoloQuotes) != null ? _c : []).filter(
1364
- (sq) => sq.status === "ok" && sq.avgPrice !== null && sq.filledQty > 0 && // No `sq.quoteId` requirement: a solo is preview-only whenever its own
1574
+ (sq) => sq.status === "ok" && sq.unavailableReason !== "venue_unavailable" && sq.avgPrice !== null && sq.filledQty > 0 && // No `sq.quoteId` requirement: a solo is preview-only whenever its own
1365
1575
  // funding lane is short (API nulls the quoteId), which is NOT always the
1366
1576
  // whole-quote `insufficient_balance` case — an off-chain winner (Kalshi
1367
1577
  // settles from venue cash) keeps the quote `ok` while the on-chain solo
@@ -1387,6 +1597,7 @@ var buildLiveRouteCards = ({
1387
1597
  maximumFractionDigits: 2
1388
1598
  }),
1389
1599
  venue,
1600
+ requiresSharedKyc: venueRequiresSharedKyc({ venue: sq.venue }),
1390
1601
  isUnavailable: true
1391
1602
  };
1392
1603
  }
@@ -1423,23 +1634,32 @@ var buildLiveRouteCards = ({
1423
1634
  minimumFractionDigits: 2,
1424
1635
  maximumFractionDigits: 2
1425
1636
  }),
1426
- venue
1637
+ venue,
1638
+ requiresSharedKyc: venueRequiresSharedKyc({ venue: sq.venue })
1427
1639
  };
1428
1640
  });
1429
- const unavailableCards = ((_d = quoteData.venueSoloQuotes) != null ? _d : []).filter((sq) => sq.status === "unavailable").map((sq) => {
1641
+ const unavailableCards = ((_d = quoteData.venueSoloQuotes) != null ? _d : []).filter((sq) => sq.status === "unavailable" || sq.unavailableReason === "venue_unavailable").map((sq) => {
1430
1642
  const parsedVenue = parseVenue(sq.venue);
1431
1643
  const venue = parsedVenue.success ? parsedVenue.data : void 0;
1432
- return {
1644
+ const temporarilyUnavailable = sq.unavailableReason === "venue_unavailable";
1645
+ const hasPreview = temporarilyUnavailable && sq.filledQty > 0;
1646
+ return __spreadProps(__spreadValues({
1433
1647
  id: `live-unavailable-${sq.venue}`,
1434
- hint: labels.venueUnavailableInRegion,
1648
+ hint: temporarilyUnavailable ? labels.venueTemporarilyUnavailable : labels.venueUnavailableInRegion,
1435
1649
  kind: "venue",
1436
1650
  label: getTradingVenueLabel(venue),
1437
- numericValue: 0,
1438
- quoteData,
1439
- value: "",
1651
+ numericValue: hasPreview ? sq.filledQty : 0,
1652
+ quoteData: __spreadProps(__spreadValues({}, quoteData), { quoteId: "" }),
1653
+ value: hasPreview ? getTradingValueLabel({
1654
+ amount: sq.filledQty,
1655
+ minimumFractionDigits: 2,
1656
+ maximumFractionDigits: 2
1657
+ }) : ""
1658
+ }, hasPreview && isFiniteNonNegativePrice(sq.avgPrice) ? { executionPrice: sq.avgPrice } : {}), {
1440
1659
  venue,
1660
+ requiresSharedKyc: venueRequiresSharedKyc({ venue: sq.venue }),
1441
1661
  isUnavailable: true
1442
- };
1662
+ });
1443
1663
  });
1444
1664
  const baseCards = (primaryCard ? [primaryCard, ...soloCards] : soloCards).sort(
1445
1665
  (left, right) => right.numericValue - left.numericValue
@@ -2741,7 +2961,9 @@ var deriveExecutionOrderGroups = ({
2741
2961
  fallbackDestinationChainId: fill.chain
2742
2962
  });
2743
2963
  const setupCosts = ((_b = (_a = quoteData.feeBreakdown) == null ? void 0 : _a.setupCosts) != null ? _b : []).filter(
2744
- (setupCost) => !setupCost.alreadyPaid && normalizeIdentity(setupCost.venue) === normalizeIdentity(fill.venue)
2964
+ (setupCost) => !setupCost.alreadyPaid && // Hyperliquid's activation fee is deducted inside the bridge leg — no
2965
+ // DAG step ever runs for it, so a "setup" step would never complete.
2966
+ setupCost.kind !== "hyperliquidActivation" && normalizeIdentity(setupCost.venue) === normalizeIdentity(fill.venue)
2745
2967
  );
2746
2968
  const venueRawSteps = rawExecutionSteps.filter(
2747
2969
  (step) => isVenueExecutionRawStep(step, fill.venue)
@@ -3480,24 +3702,24 @@ var PlaceOrderSlippageControl = ({
3480
3702
  }) => {
3481
3703
  var _a, _b;
3482
3704
  const labels = useLabels2();
3483
- const containerRef = useRef2(null);
3484
- const triggerRef = useRef2(null);
3485
- const inputRef = useRef2(null);
3705
+ const containerRef = useRef3(null);
3706
+ const triggerRef = useRef3(null);
3707
+ const inputRef = useRef3(null);
3486
3708
  const warningId = useId();
3487
3709
  const defaultValue = finalizePercentageValue(slippageDefaultValue);
3488
3710
  const committedValue = finalizePercentageValue(slippageValue) || defaultValue;
3489
- const [draftValue, setDraftValue] = useState(committedValue);
3490
- const [isEditing, setIsEditing] = useState(
3711
+ const [draftValue, setDraftValue] = useState2(committedValue);
3712
+ const [isEditing, setIsEditing] = useState2(
3491
3713
  () => isPercentageBelowMinimum(committedValue, slippageMinimumValue)
3492
3714
  );
3493
- const [shouldFocusInput, setShouldFocusInput] = useState(false);
3494
- useEffect2(() => {
3715
+ const [shouldFocusInput, setShouldFocusInput] = useState2(false);
3716
+ useEffect3(() => {
3495
3717
  setDraftValue(committedValue);
3496
3718
  if (isPercentageBelowMinimum(committedValue, slippageMinimumValue)) {
3497
3719
  setIsEditing(true);
3498
3720
  }
3499
3721
  }, [committedValue, slippageMinimumValue]);
3500
- useEffect2(() => {
3722
+ useEffect3(() => {
3501
3723
  if (!shouldFocusInput) return;
3502
3724
  requestAnimationFrame(() => {
3503
3725
  var _a2, _b2;
@@ -3879,10 +4101,11 @@ var PlaceOrderResolvedView = ({
3879
4101
  }
3880
4102
  );
3881
4103
  };
3882
- var renderRouteBreakdownRow = (row) => {
4104
+ var renderRouteBreakdownRow = (row, sharedKycStatus, tradingLabels) => {
3883
4105
  var _a, _b;
3884
4106
  const venueLabel = getTradingVenueLabel(row.venue);
3885
4107
  const rowKey = `${row.venue}-${row.label}-${row.priceLabel}-${(_a = row.resultLabel) != null ? _a : ""}`;
4108
+ const showSharedKycRequirement = row.requiresSharedKyc === true && sharedKycStatus !== void 0 && sharedKycStatus !== "verified";
3886
4109
  return /* @__PURE__ */ jsxs6(
3887
4110
  "div",
3888
4111
  {
@@ -3890,7 +4113,10 @@ var renderRouteBreakdownRow = (row) => {
3890
4113
  children: [
3891
4114
  /* @__PURE__ */ jsxs6("div", { className: "agg-route-breakdown-market flex min-w-0 items-center gap-2", children: [
3892
4115
  /* @__PURE__ */ jsx7(VenueLogo, { venue: row.venue, className: "size-3!", ariaLabel: venueLabel }),
3893
- /* @__PURE__ */ jsx7("p", { className: "agg-route-breakdown-label truncate text-agg-sm leading-agg-5 text-agg-foreground", children: row.label })
4116
+ /* @__PURE__ */ jsxs6("div", { className: "flex min-w-0 flex-col", children: [
4117
+ /* @__PURE__ */ jsx7("p", { className: "agg-route-breakdown-label truncate text-agg-sm leading-agg-5 text-agg-foreground", children: row.label }),
4118
+ showSharedKycRequirement ? /* @__PURE__ */ jsx7("p", { className: "text-agg-xs leading-agg-4 text-agg-muted-foreground", children: tradingLabels.sharedKyc.required }) : null
4119
+ ] })
3894
4120
  ] }),
3895
4121
  /* @__PURE__ */ jsxs6("div", { className: "agg-route-breakdown-value flex shrink-0 items-center gap-2 text-agg-sm leading-agg-5", children: [
3896
4122
  /* @__PURE__ */ jsx7("p", { className: "text-agg-muted-foreground", children: row.priceLabel }),
@@ -3917,11 +4143,14 @@ var renderRouteCard = ({
3917
4143
  isExpanded,
3918
4144
  isSelected,
3919
4145
  onSelect,
4146
+ sharedKycStatus,
3920
4147
  tradingLabels
3921
4148
  }) => {
3922
4149
  var _a, _b, _c;
4150
+ const showSharedKycRequirement = card.requiresSharedKyc === true && sharedKycStatus !== void 0 && sharedKycStatus !== "verified" && !card.isUnavailable;
3923
4151
  const showSplitDetails = isSelected && isExpanded && card.kind === "split" && !!((_a = card.rows) == null ? void 0 : _a.length);
3924
- const ariaLabel = [card.label, card.hint, card.value].filter(Boolean).join(" ");
4152
+ const displayedHint = showSharedKycRequirement ? tradingLabels.sharedKyc.required : card.hint;
4153
+ const ariaLabel = [card.label, displayedHint, card.value].filter(Boolean).join(" ");
3925
4154
  return /* @__PURE__ */ jsx7(
3926
4155
  "button",
3927
4156
  {
@@ -3974,7 +4203,7 @@ var renderRouteCard = ({
3974
4203
  className: "shrink-0 text-agg-muted-foreground",
3975
4204
  "aria-hidden": "true"
3976
4205
  }
3977
- ) : card.insufficientInventory ? /* @__PURE__ */ jsx7(
4206
+ ) : showSharedKycRequirement || card.insufficientInventory ? /* @__PURE__ */ jsx7(
3978
4207
  Icon,
3979
4208
  {
3980
4209
  name: "warning",
@@ -3992,7 +4221,7 @@ var renderRouteCard = ({
3992
4221
  }
3993
4222
  ) : null
3994
4223
  ] }),
3995
- card.hint ? /* @__PURE__ */ jsx7("p", { className: "agg-route-card-hint text-agg-xs leading-agg-4 text-agg-muted-foreground", children: card.hint }) : null
4224
+ card.hint ? /* @__PURE__ */ jsx7("p", { className: "agg-route-card-hint text-agg-xs leading-agg-4 text-agg-muted-foreground", children: displayedHint }) : null
3996
4225
  ] })
3997
4226
  ] }),
3998
4227
  /* @__PURE__ */ jsx7(
@@ -4009,7 +4238,9 @@ var renderRouteCard = ({
4009
4238
  ] }),
4010
4239
  showSplitDetails ? /* @__PURE__ */ jsxs6(Fragment3, { children: [
4011
4240
  /* @__PURE__ */ jsx7("p", { className: "agg-route-card-description text-agg-xs leading-agg-4 text-agg-foreground", children: (_b = card.description) != null ? _b : tradingLabels.splitOrderDescription }),
4012
- /* @__PURE__ */ jsx7("div", { className: "agg-route-breakdown flex flex-col gap-3", children: (_c = card.rows) == null ? void 0 : _c.map((row) => renderRouteBreakdownRow(row)) })
4241
+ /* @__PURE__ */ jsx7("div", { className: "agg-route-breakdown flex flex-col gap-3", children: (_c = card.rows) == null ? void 0 : _c.map(
4242
+ (row) => renderRouteBreakdownRow(row, sharedKycStatus, tradingLabels)
4243
+ ) })
4013
4244
  ] }) : null
4014
4245
  ] })
4015
4246
  }
@@ -4028,6 +4259,7 @@ var PlaceOrder = ({
4028
4259
  onAmountChange,
4029
4260
  onClose,
4030
4261
  onConnectKalshi,
4262
+ sharedKyc,
4031
4263
  onOutcomeChange,
4032
4264
  onPrimaryAction,
4033
4265
  onBeforePrimaryAction,
@@ -4039,13 +4271,12 @@ var PlaceOrder = ({
4039
4271
  showResolvingState = false,
4040
4272
  midpointsResult
4041
4273
  }) => {
4042
- 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, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha;
4274
+ 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, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca;
4043
4275
  const {
4044
4276
  enableDebug: isExecutionDebugEnabled,
4045
- features: { enableAnimations, showFeesBreakdown, showLimitOrders },
4277
+ features: { enableAnimations, showFeesBreakdown, showLimitOrders: limitOrdersFeature },
4046
4278
  formatting: { formatPrice },
4047
- general: { locale },
4048
- trading: { executionMode: configuredExecutionMode = "live" } = { executionMode: "live" }
4279
+ general: { locale }
4049
4280
  } = useSdkUiConfig();
4050
4281
  const labels = useLabels2();
4051
4282
  const tradingLabels = labels.trading;
@@ -4112,8 +4343,13 @@ var PlaceOrder = ({
4112
4343
  );
4113
4344
  const isResolvedOutcomeCtaLocked = resolvedEventTradingState.kind === "resolved" || resolvedTradingState.kind === "resolved";
4114
4345
  const { isAuthenticated, user } = useAggAuthContext();
4115
- const resolvedExecutionMode = executionMode != null ? executionMode : configuredExecutionMode;
4116
- const isPaperMode = resolvedExecutionMode === "paper";
4346
+ const sharedKycFlow = useSharedKycFlow({
4347
+ integration: sharedKyc,
4348
+ userId: isAuthenticated ? user == null ? void 0 : user.id : null,
4349
+ fallbackErrorMessage: tradingLabels.sharedKyc.modal.error
4350
+ });
4351
+ const { executionMode: resolvedExecutionMode, isPaperMode } = useResolvedExecutionMode(executionMode);
4352
+ const showLimitOrders = limitOrdersFeature && !isPaperMode;
4117
4353
  const liveBalanceState = useAggBalanceState();
4118
4354
  const paperBalancesQuery = useManagedBalances({
4119
4355
  enabled: Boolean(isAuthenticated && isPaperMode),
@@ -4141,11 +4377,11 @@ var PlaceOrder = ({
4141
4377
  const queryClient = useQueryClient();
4142
4378
  const { disabledVenues, isLoading: isAppConfigLoading } = useAppConfig();
4143
4379
  const { data: kalshiKeyStatus, refetch: refetchKalshiKeyStatus } = useVenueKeyStatus(
4144
- Venue3.kalshi,
4380
+ Venue4.kalshi,
4145
4381
  isAuthenticated
4146
4382
  );
4147
- const [isConnectKalshiModalOpen, setIsConnectKalshiModalOpen] = useState(false);
4148
- const [isFundKalshiModalOpen, setIsFundKalshiModalOpen] = useState(false);
4383
+ const [isConnectKalshiModalOpen, setIsConnectKalshiModalOpen] = useState2(false);
4384
+ const [isFundKalshiModalOpen, setIsFundKalshiModalOpen] = useState2(false);
4149
4385
  const livePrices = useLiveOutcomePrices(
4150
4386
  scopedSelectedMarket ? [scopedSelectedMarket] : void 0
4151
4387
  );
@@ -4161,32 +4397,32 @@ var PlaceOrder = ({
4161
4397
  () => mergeBestPricesPreferringLive(clusterBestPricesRest, wsBestPrices),
4162
4398
  [clusterBestPricesRest, wsBestPrices]
4163
4399
  );
4164
- const [internalTab, setInternalTab] = useState("buy");
4165
- const [executionType, setExecutionType] = useState("market");
4166
- const [selectedLimitVenue, setSelectedLimitVenue] = useState(null);
4167
- const [limitPrice, setLimitPrice] = useState(0.5);
4168
- const [limitPriceInputValue, setLimitPriceInputValue] = useState(formatLimitPriceInputValue(0.5));
4169
- const [limitPriceInputError, setLimitPriceInputError] = useState(null);
4170
- const [limitExpirationType, setLimitExpirationType] = useState("GTC");
4171
- const [limitExpirationDate, setLimitExpirationDate] = useState(void 0);
4172
- const [limitExpirationTime, setLimitExpirationTime] = useState("17:00");
4173
- const [limitExpirationDraftDate, setLimitExpirationDraftDate] = useState();
4174
- const [limitExpirationDraftTime, setLimitExpirationDraftTime] = useState("17:00");
4175
- const [limitExpirationPickerView, setLimitExpirationPickerView] = useState("options");
4176
- const [isLimitExpirationPickerOpen, setIsLimitExpirationPickerOpen] = useState(false);
4177
- const [internalAmount, setInternalAmount] = useState(PLACE_ORDER_DEFAULT_AMOUNT);
4178
- const [sellFilledForOutcomeId, setSellFilledForOutcomeId] = useState(null);
4179
- const [internalSlippage] = useState(DEFAULT_SLIPPAGE_VALUE);
4180
- const [isRoutesExpanded, setIsRoutesExpanded] = useState(false);
4181
- const [selectedRouteCardId, setSelectedRouteCardId] = useState(null);
4182
- const [manualRouteSelectionIdentity, setManualRouteSelectionIdentity] = useState(
4400
+ const [internalTab, setInternalTab] = useState2("buy");
4401
+ const [executionType, setExecutionType] = useState2("market");
4402
+ const [selectedLimitVenue, setSelectedLimitVenue] = useState2(null);
4403
+ const [limitPrice, setLimitPrice] = useState2(0.5);
4404
+ const [limitPriceInputValue, setLimitPriceInputValue] = useState2(formatLimitPriceInputValue(0.5));
4405
+ const [limitPriceInputError, setLimitPriceInputError] = useState2(null);
4406
+ const [limitExpirationType, setLimitExpirationType] = useState2("GTC");
4407
+ const [limitExpirationDate, setLimitExpirationDate] = useState2(void 0);
4408
+ const [limitExpirationTime, setLimitExpirationTime] = useState2("17:00");
4409
+ const [limitExpirationDraftDate, setLimitExpirationDraftDate] = useState2();
4410
+ const [limitExpirationDraftTime, setLimitExpirationDraftTime] = useState2("17:00");
4411
+ const [limitExpirationPickerView, setLimitExpirationPickerView] = useState2("options");
4412
+ const [isLimitExpirationPickerOpen, setIsLimitExpirationPickerOpen] = useState2(false);
4413
+ const [internalAmount, setInternalAmount] = useState2(PLACE_ORDER_DEFAULT_AMOUNT);
4414
+ const [sellFilledForOutcomeId, setSellFilledForOutcomeId] = useState2(null);
4415
+ const [internalSlippage] = useState2(DEFAULT_SLIPPAGE_VALUE);
4416
+ const [isRoutesExpanded, setIsRoutesExpanded] = useState2(false);
4417
+ const [selectedRouteCardId, setSelectedRouteCardId] = useState2(null);
4418
+ const [manualRouteSelectionIdentity, setManualRouteSelectionIdentity] = useState2(
4183
4419
  null
4184
4420
  );
4185
- const [isSplitDetailOpen, setIsSplitDetailOpen] = useState(false);
4186
- const [buyGeoBlockSnapshot, setBuyGeoBlockSnapshot] = useState(null);
4187
- const [submissionFeedback, setSubmissionFeedback] = useState(null);
4188
- const [submissionProgressState, setSubmissionProgressState] = useState(null);
4189
- const [isBeforeActionPending, setIsBeforeActionPending] = useState(false);
4421
+ const [isSplitDetailOpen, setIsSplitDetailOpen] = useState2(false);
4422
+ const [buyGeoBlockSnapshot, setBuyGeoBlockSnapshot] = useState2(null);
4423
+ const [submissionFeedback, setSubmissionFeedback] = useState2(null);
4424
+ const [submissionProgressState, setSubmissionProgressState] = useState2(null);
4425
+ const [isBeforeActionPending, setIsBeforeActionPending] = useState2(false);
4190
4426
  const outcomes = useMemo(
4191
4427
  () => mapVenueMarketOutcomesToPlaceOrderOutcomes(scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.venueMarketOutcomes),
4192
4428
  [scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.venueMarketOutcomes]
@@ -4214,25 +4450,25 @@ var PlaceOrder = ({
4214
4450
  scopedSelectedOutcomeId,
4215
4451
  tradingContext == null ? void 0 : tradingContext.tradeSide
4216
4452
  ]);
4217
- const buyTabRef = useRef2(null);
4218
- const sellTabRef = useRef2(null);
4219
- const expirationTriggerRef = useRef2(null);
4220
- const limitPriceInitializedForOutcomeRef = useRef2(void 0);
4221
- const expirationOptionRefs = useRef2([]);
4222
- const shouldFocusExpirationOptionsRef = useRef2(false);
4453
+ const buyTabRef = useRef3(null);
4454
+ const sellTabRef = useRef3(null);
4455
+ const expirationTriggerRef = useRef3(null);
4456
+ const limitPriceInitializedForOutcomeRef = useRef3(void 0);
4457
+ const expirationOptionRefs = useRef3([]);
4458
+ const shouldFocusExpirationOptionsRef = useRef3(false);
4223
4459
  const expirationTimeInputId = useId();
4224
- const executionDebugStoreRef = useRef2(null);
4225
- const executionDebugAttemptIdRef = useRef2(null);
4226
- const submittedSelectionRef = useRef2(null);
4227
- const lastValidRouteCardsRef = useRef2(null);
4228
- useEffect2(() => {
4460
+ const executionDebugStoreRef = useRef3(null);
4461
+ const executionDebugAttemptIdRef = useRef3(null);
4462
+ const submittedSelectionRef = useRef3(null);
4463
+ const lastValidRouteCardsRef = useRef3(null);
4464
+ useEffect3(() => {
4229
4465
  if (!isExecutionDebugEnabled) {
4230
4466
  executionDebugStoreRef.current = null;
4231
4467
  return;
4232
4468
  }
4233
4469
  executionDebugStoreRef.current = enableExecutionDebugInBrowser();
4234
4470
  }, [isExecutionDebugEnabled]);
4235
- useEffect2(() => {
4471
+ useEffect3(() => {
4236
4472
  var _a2;
4237
4473
  if (!isLimitExpirationPickerOpen) return;
4238
4474
  if (limitExpirationPickerView !== "options") return;
@@ -4240,7 +4476,7 @@ var PlaceOrder = ({
4240
4476
  (_a2 = expirationOptionRefs.current[LIMIT_EXPIRATION_OPTION_COUNT - 1]) == null ? void 0 : _a2.focus();
4241
4477
  shouldFocusExpirationOptionsRef.current = false;
4242
4478
  }, [isLimitExpirationPickerOpen, limitExpirationPickerView]);
4243
- useEffect2(() => {
4479
+ useEffect3(() => {
4244
4480
  if (!isExecutionDebugEnabled) return;
4245
4481
  const store = executionDebugStoreRef.current;
4246
4482
  if (!store) return;
@@ -4377,7 +4613,7 @@ var PlaceOrder = ({
4377
4613
  }
4378
4614
  return automaticLimitVenueOption;
4379
4615
  }, [automaticLimitVenueOption, availableLimitVenueOptions, selectedLimitVenue]);
4380
- useEffect2(() => {
4616
+ useEffect3(() => {
4381
4617
  if (!selectedLimitVenue || !geoBlockedLimitVenues.has(selectedLimitVenue)) return;
4382
4618
  setSelectedLimitVenue(null);
4383
4619
  }, [geoBlockedLimitVenues, selectedLimitVenue]);
@@ -4406,7 +4642,7 @@ var PlaceOrder = ({
4406
4642
  } : {}), {
4407
4643
  refreshContext: smartRouteRefreshContext
4408
4644
  }));
4409
- useEffect2(() => {
4645
+ useEffect3(() => {
4410
4646
  var _a2, _b2, _c2;
4411
4647
  if (isSell || smartRoute.isFetching || ((_a2 = smartRoute.data) == null ? void 0 : _a2.venueMarketOutcomeId) !== scopedSelectedOutcomeId) {
4412
4648
  return;
@@ -4489,7 +4725,7 @@ var PlaceOrder = ({
4489
4725
  );
4490
4726
  const isAtMaxSellableShares = isSell && maxSellableShares > 0 && Math.abs(internalAmount - maxSellableShares) < 1e-9;
4491
4727
  const isSellAmountAboveAvailability = isSell && ((_t = smartRoute.data) == null ? void 0 : _t.venueMarketOutcomeId) === scopedSelectedOutcomeId && typeof ((_u = smartRoute.data.positionAvailability) == null ? void 0 : _u.totalSellableShares) === "number" && internalAmount > maxSellableShares;
4492
- useEffect2(() => {
4728
+ useEffect3(() => {
4493
4729
  if (submissionProgressState != null) return;
4494
4730
  if (!isSell || isCurrentSellableSharesLoading) return;
4495
4731
  if (scopedSelectedOutcomeId === sellFilledForOutcomeId) return;
@@ -4505,7 +4741,7 @@ var PlaceOrder = ({
4505
4741
  onAmountChange,
4506
4742
  submissionProgressState
4507
4743
  ]);
4508
- useEffect2(() => {
4744
+ useEffect3(() => {
4509
4745
  var _a2, _b2;
4510
4746
  if (submissionProgressState != null || !isSell) return;
4511
4747
  if (((_a2 = smartRoute.data) == null ? void 0 : _a2.venueMarketOutcomeId) !== scopedSelectedOutcomeId) return;
@@ -4592,7 +4828,7 @@ var PlaceOrder = ({
4592
4828
  selectedRouteCardId,
4593
4829
  (_B = smartRoute.data) == null ? void 0 : _B.status
4594
4830
  ]);
4595
- useEffect2(() => {
4831
+ useEffect3(() => {
4596
4832
  if (routeCards.length === 0) {
4597
4833
  if (isRouteCardsTransient) return;
4598
4834
  setSelectedRouteCardId(null);
@@ -4616,19 +4852,19 @@ var PlaceOrder = ({
4616
4852
  selectedRouteCardId
4617
4853
  ]);
4618
4854
  const isSubmissionLocked = submissionProgressState != null;
4619
- const isSubmissionLockedRef = useRef2(isSubmissionLocked);
4855
+ const isSubmissionLockedRef = useRef3(isSubmissionLocked);
4620
4856
  isSubmissionLockedRef.current = isSubmissionLocked;
4621
- useEffect2(() => {
4857
+ useEffect3(() => {
4622
4858
  if (isSubmissionLockedRef.current) return;
4623
4859
  setSubmissionFeedback(null);
4624
4860
  setSubmissionProgressState(null);
4625
4861
  }, [executionType, internalAmount, internalSlippage, internalTab, scopedSelectedOutcomeId]);
4626
- useEffect2(() => {
4862
+ useEffect3(() => {
4627
4863
  if (showLimitOrders || executionType !== "limit") return;
4628
4864
  setExecutionType("market");
4629
4865
  setIsLimitExpirationPickerOpen(false);
4630
4866
  }, [executionType, showLimitOrders]);
4631
- useEffect2(() => {
4867
+ useEffect3(() => {
4632
4868
  if (executionType !== "limit") {
4633
4869
  limitPriceInitializedForOutcomeRef.current = void 0;
4634
4870
  return;
@@ -4641,10 +4877,10 @@ var PlaceOrder = ({
4641
4877
  setLimitPriceInputValue(formatLimitPriceInputValue(nextLimitPrice));
4642
4878
  setLimitPriceInputError(null);
4643
4879
  }, [executionType, scopedSelectedOutcomeId, selectedOutcomeDisplayPrice]);
4644
- useEffect2(() => {
4880
+ useEffect3(() => {
4645
4881
  setSelectedLimitVenue(null);
4646
4882
  }, [scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.id, scopedSelectedOutcomeId]);
4647
- useEffect2(() => {
4883
+ useEffect3(() => {
4648
4884
  setSelectedRouteCardId(null);
4649
4885
  setManualRouteSelectionIdentity(null);
4650
4886
  setIsRoutesExpanded(false);
@@ -4652,8 +4888,18 @@ var PlaceOrder = ({
4652
4888
  }, [executionType, internalTab, scopedSelectedOutcomeId]);
4653
4889
  const orderedRouteCards = routeCards;
4654
4890
  const selectedRouteCard = (_D = (_C = orderedRouteCards.find((card) => card.id === resolvedSelectedRouteCardId)) != null ? _C : orderedRouteCards[0]) != null ? _D : null;
4891
+ const selectedSharedKycVenue = useMemo(() => {
4892
+ var _a2, _b2;
4893
+ const candidateVenue = isLimitOrder ? selectedLimitVenueOption == null ? void 0 : selectedLimitVenueOption.venue : (_b2 = (_a2 = selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData.fills.find(
4894
+ (fill) => venueRequiresSharedKyc({ venue: fill.venue })
4895
+ )) == null ? void 0 : _a2.venue) != null ? _b2 : selectedRouteCard == null ? void 0 : selectedRouteCard.venue;
4896
+ if (!venueRequiresSharedKyc({ venue: candidateVenue })) return null;
4897
+ const parsedVenue = parseVenue(candidateVenue);
4898
+ return parsedVenue.success ? parsedVenue.data : null;
4899
+ }, [isLimitOrder, selectedLimitVenueOption == null ? void 0 : selectedLimitVenueOption.venue, selectedRouteCard]);
4900
+ const needsSharedKycVerification = !isPaperMode && isAuthenticated && sharedKyc !== void 0 && selectedSharedKycVenue !== null && sharedKyc.status !== "verified";
4655
4901
  const isKalshiRoute = useMemo(() => {
4656
- if (isLimitOrder) return (selectedLimitVenueOption == null ? void 0 : selectedLimitVenueOption.venue) === Venue3.kalshi;
4902
+ if (isLimitOrder) return (selectedLimitVenueOption == null ? void 0 : selectedLimitVenueOption.venue) === Venue4.kalshi;
4657
4903
  if (selectedRouteCard) {
4658
4904
  return selectedRouteCard.venue === "kalshi" || selectedRouteCard.quoteData.fills.some((f) => f.venue === "kalshi");
4659
4905
  }
@@ -4668,7 +4914,6 @@ var PlaceOrder = ({
4668
4914
  [user == null ? void 0 : user.venueAccounts]
4669
4915
  );
4670
4916
  const isKalshiAccountActive = (_F = kalshiKeyStatus == null ? void 0 : kalshiKeyStatus.connected) != null ? _F : (legacyKalshiAccount == null ? void 0 : legacyKalshiAccount.status) === "active";
4671
- const isKalshiVerified = ((_G = kalshiKeyStatus == null ? void 0 : kalshiKeyStatus.kycStatus) != null ? _G : legacyKalshiAccount == null ? void 0 : legacyKalshiAccount.kycStatus) === "verified";
4672
4917
  const hasKalshiConnectionState = kalshiKeyStatus !== void 0 || (user == null ? void 0 : user.venueAccounts) != null;
4673
4918
  const isKalshiAvailable = getVenueAvailabilityState({
4674
4919
  venueId: "kalshi",
@@ -4676,13 +4921,13 @@ var PlaceOrder = ({
4676
4921
  isConfigLoading: isAppConfigLoading
4677
4922
  }) === "available";
4678
4923
  const needsKalshiConnection = isAuthenticated && hasKalshiConnectionState && isKalshiAvailable && isKalshiRoute && !isKalshiAccountActive;
4679
- const handleVerifyKalshi = useCallback2(
4924
+ const handleVerifyKalshi = useCallback3(
4680
4925
  (credentials) => __async(null, null, function* () {
4681
4926
  if (onConnectKalshi) {
4682
4927
  yield onConnectKalshi(credentials);
4683
4928
  } else {
4684
4929
  yield aggClient.upsertVenueKey({
4685
- venue: Venue3.kalshi,
4930
+ venue: Venue4.kalshi,
4686
4931
  credentials: {
4687
4932
  keyId: credentials.apiKeyId,
4688
4933
  privateKey: credentials.privateKey
@@ -4694,9 +4939,7 @@ var PlaceOrder = ({
4694
4939
  }),
4695
4940
  [aggClient, onConnectKalshi, refetchKalshiKeyStatus]
4696
4941
  );
4697
- const needsKycVerification = isAuthenticated && hasKalshiConnectionState && isKalshiRoute && isKalshiAccountActive && !isKalshiVerified;
4698
- const verifyKalshiConnectionLabel = (_K = (_J = (_I = (_H = labels.onboarding) == null ? void 0 : _H.connectKalshiModal) == null ? void 0 : _I.actions) == null ? void 0 : _J.verifyConnection) != null ? _K : tradingLabels.kycRequired;
4699
- const handleRouteCardSelect = useCallback2(
4942
+ const handleRouteCardSelect = useCallback3(
4700
4943
  (cardId) => {
4701
4944
  const card = routeCards.find((routeCard) => routeCard.id === cardId);
4702
4945
  if (!card || card.isUnavailable) return;
@@ -4728,22 +4971,22 @@ var PlaceOrder = ({
4728
4971
  ]
4729
4972
  );
4730
4973
  const executionProgress = useExecutionProgress({
4731
- orderIds: (_L = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) != null ? _L : null,
4732
- quoteId: (_M = submissionProgressState == null ? void 0 : submissionProgressState.quoteId) != null ? _M : null,
4974
+ orderIds: (_G = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) != null ? _G : null,
4975
+ quoteId: (_H = submissionProgressState == null ? void 0 : submissionProgressState.quoteId) != null ? _H : null,
4733
4976
  mode: isPaperMode ? "paper" : void 0,
4734
- enabled: ((submissionProgressState == null ? void 0 : submissionProgressState.phase) === "submitting" || (submissionProgressState == null ? void 0 : submissionProgressState.phase) === "executing") && !!((_N = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) == null ? void 0 : _N.length)
4977
+ enabled: ((submissionProgressState == null ? void 0 : submissionProgressState.phase) === "submitting" || (submissionProgressState == null ? void 0 : submissionProgressState.phase) === "executing") && !!((_I = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) == null ? void 0 : _I.length)
4735
4978
  });
4736
- const executionProgressFloorRef = useRef2({
4979
+ const executionProgressFloorRef = useRef3({
4737
4980
  quoteId: null,
4738
4981
  value: 0
4739
4982
  });
4740
- const selectedOutcomeLabel = (_Q = (_P = (_O = outcomes.find((outcome) => outcome.id === scopedSelectedOutcomeId)) == null ? void 0 : _O.label) != null ? _P : scopedSelectedOutcome == null ? void 0 : scopedSelectedOutcome.label) != null ? _Q : "";
4741
- const headerImage = (_S = (_R = scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.image) != null ? _R : scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.image) != null ? _S : null;
4742
- const headerTitle = (_U = (_T = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.title) != null ? _T : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _U : "";
4743
- const headerSubtitle = (_V = scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _V : "";
4744
- const executionDateSource = (_W = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.endDate) != null ? _W : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.endDate;
4983
+ const selectedOutcomeLabel = (_L = (_K = (_J = outcomes.find((outcome) => outcome.id === scopedSelectedOutcomeId)) == null ? void 0 : _J.label) != null ? _K : scopedSelectedOutcome == null ? void 0 : scopedSelectedOutcome.label) != null ? _L : "";
4984
+ const headerImage = (_N = (_M = scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.image) != null ? _M : scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.image) != null ? _N : null;
4985
+ const headerTitle = (_P = (_O = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.title) != null ? _O : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _P : "";
4986
+ const headerSubtitle = (_Q = scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _Q : "";
4987
+ const executionDateSource = (_R = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.endDate) != null ? _R : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.endDate;
4745
4988
  const executionDateLabel = executionDateSource ? getTradingDateLabel(executionDateSource) : "";
4746
- const executionQuoteData = (_Y = (_X = submissionProgressState == null ? void 0 : submissionProgressState.quoteData) != null ? _X : selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData) != null ? _Y : null;
4989
+ const executionQuoteData = (_T = (_S = submissionProgressState == null ? void 0 : submissionProgressState.quoteData) != null ? _S : selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData) != null ? _T : null;
4747
4990
  const executionOrderGroups = useMemo(() => {
4748
4991
  var _a2, _b2, _c2;
4749
4992
  if (!executionQuoteData) return [];
@@ -4764,7 +5007,7 @@ var PlaceOrder = ({
4764
5007
  executionProgress.terminalOrderEvents,
4765
5008
  executionQuoteData,
4766
5009
  internalTab,
4767
- (_Z = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) == null ? void 0 : _Z.length,
5010
+ (_U = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) == null ? void 0 : _U.length,
4768
5011
  tradingLabels
4769
5012
  ]);
4770
5013
  const executionProgressPercent = useMemo(() => {
@@ -4787,7 +5030,7 @@ var PlaceOrder = ({
4787
5030
  submissionProgressState == null ? void 0 : submissionProgressState.orderIds,
4788
5031
  submissionProgressState == null ? void 0 : submissionProgressState.quoteId
4789
5032
  ]);
4790
- const buildExecutionSummary = useCallback2(
5033
+ const buildExecutionSummary = useCallback3(
4791
5034
  (quoteData, executionVenue, orderId, partialFillSummary) => {
4792
5035
  var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2;
4793
5036
  if (!quoteData) return void 0;
@@ -4882,7 +5125,7 @@ var PlaceOrder = ({
4882
5125
  tradingLabels
4883
5126
  ]
4884
5127
  );
4885
- useEffect2(() => {
5128
+ useEffect3(() => {
4886
5129
  if (executionProgress.phase === "order_submitted") {
4887
5130
  const submittedOrder = executionProgress.submittedOrders[0];
4888
5131
  setSubmissionProgressState((prev) => {
@@ -4895,7 +5138,7 @@ var PlaceOrder = ({
4895
5138
  });
4896
5139
  }
4897
5140
  }, [executionProgress.phase, executionProgress.submittedOrders]);
4898
- useEffect2(() => {
5141
+ useEffect3(() => {
4899
5142
  var _a2, _b2;
4900
5143
  const dp = executionProgress.dagProgress;
4901
5144
  if (!dp) return;
@@ -4950,7 +5193,7 @@ var PlaceOrder = ({
4950
5193
  return __spreadProps(__spreadValues({}, prev), { dagProgress: dp });
4951
5194
  });
4952
5195
  }, [executionOrderGroups, executionProgress.dagProgress, tradingLabels]);
4953
- useEffect2(() => {
5196
+ useEffect3(() => {
4954
5197
  const orderIds = submissionProgressState == null ? void 0 : submissionProgressState.orderIds;
4955
5198
  if (!(orderIds == null ? void 0 : orderIds.length)) return;
4956
5199
  const aggregateStatus = deriveAggregateOrderStatus(
@@ -5011,7 +5254,7 @@ var PlaceOrder = ({
5011
5254
  tradingLabels
5012
5255
  ]);
5013
5256
  const estDurationMs = executionQuoteData && typeof executionQuoteData.estDurationMs === "number" ? executionQuoteData.estDurationMs : 6e4;
5014
- useEffect2(() => {
5257
+ useEffect3(() => {
5015
5258
  const phase = submissionProgressState == null ? void 0 : submissionProgressState.phase;
5016
5259
  if (phase !== "submitting" && phase !== "executing") return;
5017
5260
  const timeoutMs = Math.max(6e4, 2 * estDurationMs);
@@ -5026,7 +5269,7 @@ var PlaceOrder = ({
5026
5269
  }, timeoutMs);
5027
5270
  return () => clearTimeout(id);
5028
5271
  }, [submissionProgressState == null ? void 0 : submissionProgressState.phase, estDurationMs]);
5029
- const emitTerminalOrderNotifications = useCallback2(() => {
5272
+ const emitTerminalOrderNotifications = useCallback3(() => {
5030
5273
  const toast = toastCtx == null ? void 0 : toastCtx.toast;
5031
5274
  if (!toast) return;
5032
5275
  for (const event of executionProgress.terminalOrderEvents) {
@@ -5055,7 +5298,7 @@ var PlaceOrder = ({
5055
5298
  });
5056
5299
  }
5057
5300
  }, [executionProgress.terminalOrderEvents, labels, toastCtx]);
5058
- useEffect2(() => {
5301
+ useEffect3(() => {
5059
5302
  var _a2, _b2;
5060
5303
  if (!submissionProgressState) return;
5061
5304
  onExecutionStateChange == null ? void 0 : onExecutionStateChange(submissionProgressState);
@@ -5107,19 +5350,19 @@ var PlaceOrder = ({
5107
5350
  queryClient,
5108
5351
  submissionProgressState
5109
5352
  ]);
5110
- const activeQuoteData = isLimitOrder ? null : (__ = selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData) != null ? __ : scopedSmartRouteData;
5353
+ const activeQuoteData = isLimitOrder ? null : (_V = selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData) != null ? _V : scopedSmartRouteData;
5111
5354
  const visibleMarketRouteCards = displayedRouteCards.length > PLACE_ORDER_ROUTE_COLLAPSED_CARD_COUNT && !isRoutesExpanded ? displayedRouteCards.slice(0, PLACE_ORDER_ROUTE_COLLAPSED_CARD_COUNT) : displayedRouteCards;
5112
5355
  const hasEnteredAmount = internalAmount > 0;
5113
5356
  const isQuoteLoading = !isLimitOrder && hasEnteredAmount && (isSell && isQuoteInputEditing || smartRoute.isLoading || !isSell && smartRoute.isFetching || isSell && venueSellQuotes.isLoading);
5114
5357
  const routeLoadingMessage = isQuoteLoading ? smartRoute.loadingReason === "updating-route" ? tradingLabels.updatingRoute : smartRoute.loadingReason === "refreshing-quotes" ? tradingLabels.refreshingQuotes : tradingLabels.findingBestOdds : null;
5115
- const selectedRouteFills = (_$ = selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData.fills) != null ? _$ : [];
5116
- const isKalshiOnlyRoute = isKalshiRoute && ((selectedRouteCard == null ? void 0 : selectedRouteCard.venue) === Venue3.kalshi || selectedRouteFills.length > 0 && selectedRouteFills.every((fill) => fill.venue === Venue3.kalshi));
5117
- const isOnchainOnlyRoute = !isKalshiRoute || selectedRouteFills.length > 0 && selectedRouteFills.every((fill) => fill.venue !== Venue3.kalshi);
5118
- const kalshiRequiredAmount = isSell ? 0 : selectedRouteFills.filter((fill) => fill.venue === Venue3.kalshi).reduce((total, fill) => total + fill.venueQty * fill.avgPrice, 0);
5119
- const onchainRequiredAmount = isSell ? 0 : selectedRouteFills.filter((fill) => fill.venue !== Venue3.kalshi).reduce((total, fill) => total + fill.venueQty * fill.avgPrice, 0);
5358
+ const selectedRouteFills = (_W = selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData.fills) != null ? _W : [];
5359
+ const isKalshiOnlyRoute = isKalshiRoute && ((selectedRouteCard == null ? void 0 : selectedRouteCard.venue) === Venue4.kalshi || selectedRouteFills.length > 0 && selectedRouteFills.every((fill) => fill.venue === Venue4.kalshi));
5360
+ const isOnchainOnlyRoute = !isKalshiRoute || selectedRouteFills.length > 0 && selectedRouteFills.every((fill) => fill.venue !== Venue4.kalshi);
5361
+ const kalshiRequiredAmount = isSell ? 0 : selectedRouteFills.filter((fill) => fill.venue === Venue4.kalshi).reduce((total, fill) => total + fill.venueQty * fill.avgPrice, 0);
5362
+ const onchainRequiredAmount = isSell ? 0 : selectedRouteFills.filter((fill) => fill.venue !== Venue4.kalshi).reduce((total, fill) => total + fill.venueQty * fill.avgPrice, 0);
5120
5363
  const resolvedKalshiRequiredAmount = isKalshiOnlyRoute || isKalshiRoute && selectedRouteFills.length === 0 ? internalAmount : kalshiRequiredAmount;
5121
5364
  const resolvedOnchainRequiredAmount = isOnchainOnlyRoute || !isKalshiRoute && selectedRouteFills.length === 0 ? internalAmount : onchainRequiredAmount;
5122
- const isKalshiBalanceInsufficient = !isPaperMode && isKalshiRoute && resolvedKalshiRequiredAmount > ((_aa = liveBalanceState.kalshiBalance) != null ? _aa : 0);
5365
+ const isKalshiBalanceInsufficient = !isPaperMode && isKalshiRoute && resolvedKalshiRequiredAmount > ((_X = liveBalanceState.kalshiBalance) != null ? _X : 0);
5123
5366
  const isOnchainBalanceInsufficient = resolvedOnchainRequiredAmount > liveAvailableBalance;
5124
5367
  const isInsufficientBalance = !isSell && isAuthenticated && hasEnteredAmount && !isBalanceLoading && (isLimitOrder ? internalAmount > totalBalance : isPaperMode ? internalAmount > paperTotalBalance : isKalshiBalanceInsufficient || isOnchainBalanceInsufficient);
5125
5368
  const isQuoteInsufficientBalance = !isLimitOrder && (activeQuoteData == null ? void 0 : activeQuoteData.status) === "insufficient_balance";
@@ -5244,7 +5487,7 @@ var PlaceOrder = ({
5244
5487
  const averagePrice = selectedRouteCard.executionPrice;
5245
5488
  return averagePrice == null ? "" : tradingLabels.averagePrice(averagePrice);
5246
5489
  }, [selectedRouteCard, tradingLabels]);
5247
- const displayedToWinValue = (_ba = selectedRouteCard == null ? void 0 : selectedRouteCard.numericValue) != null ? _ba : 0;
5490
+ const displayedToWinValue = (_Y = selectedRouteCard == null ? void 0 : selectedRouteCard.numericValue) != null ? _Y : 0;
5248
5491
  const originalLimitPriceRaw = useMemo(() => toLimitPriceRaw(limitPrice), [limitPrice]);
5249
5492
  const limitPriceAdjustmentByVenue = useMemo(() => {
5250
5493
  var _a2;
@@ -5273,7 +5516,7 @@ var PlaceOrder = ({
5273
5516
  return adjustments;
5274
5517
  }, [internalTab, limitVenueQuoteByVenue, originalLimitPriceRaw, visibleLimitVenueOptions]);
5275
5518
  const selectedLimitPriceAdjustment = selectedLimitVenueOption ? limitPriceAdjustmentByVenue.get(selectedLimitVenueOption.venue) : void 0;
5276
- const selectedLimitPriceRaw = (_ca = selectedLimitPriceAdjustment == null ? void 0 : selectedLimitPriceAdjustment.adjustedPriceRaw) != null ? _ca : originalLimitPriceRaw;
5519
+ const selectedLimitPriceRaw = (_Z = selectedLimitPriceAdjustment == null ? void 0 : selectedLimitPriceAdjustment.adjustedPriceRaw) != null ? _Z : originalLimitPriceRaw;
5277
5520
  const limitPriceAdjustmentMessage = useMemo(() => {
5278
5521
  if (!selectedLimitVenueOption || !(selectedLimitPriceAdjustment == null ? void 0 : selectedLimitPriceAdjustment.adjusted) || !selectedLimitPriceAdjustment.tickSizeRaw) {
5279
5522
  return "";
@@ -5401,7 +5644,8 @@ var PlaceOrder = ({
5401
5644
  maximumFractionDigits: 2,
5402
5645
  minimumFractionDigits: 2
5403
5646
  }),
5404
- venue: option.venue
5647
+ venue: option.venue,
5648
+ requiresSharedKyc: venueRequiresSharedKyc({ venue: option.venue })
5405
5649
  };
5406
5650
  });
5407
5651
  }, [
@@ -5439,6 +5683,8 @@ var PlaceOrder = ({
5439
5683
  };
5440
5684
  const displayedLimitToWinHint = formatLimitPriceRawLabel(selectedLimitPriceRaw);
5441
5685
  const activeFeeBreakdown = activeQuoteData == null ? void 0 : activeQuoteData.feeBreakdown;
5686
+ const executionReserve = activeFeeBreakdown == null ? void 0 : activeFeeBreakdown.executionReserve;
5687
+ const executionReserveValue = typeof executionReserve === "number" && Number.isFinite(executionReserve) && executionReserve > 0 ? formatUsd(executionReserve, { minimumFractionDigits: 2, maximumFractionDigits: 2 }) : null;
5442
5688
  const estimatedFeesValue = useMemo(() => {
5443
5689
  const totalFees = getSmartRouteTotalFees(activeFeeBreakdown);
5444
5690
  if (totalFees == null) return null;
@@ -5480,14 +5726,14 @@ var PlaceOrder = ({
5480
5726
  }, [activeFeeBreakdown, tradingLabels]);
5481
5727
  const isActionLoading = isPrimaryActionLoading || executeManaged.isPending || placeLimitOrder.isPending || isBeforeActionPending;
5482
5728
  const selectedLimitRouteCardId = selectedLimitVenueOption ? `limit-venue-${selectedLimitVenueOption.venue}-${selectedLimitVenueOption.venueMarketOutcomeId}` : null;
5483
- const selectedLimitRouteCard = selectedLimitRouteCardId ? (_da = limitRouteCards.find((card) => card.id === selectedLimitRouteCardId)) != null ? _da : null : null;
5484
- const selectedRouteGeoBlocked = isLimitOrder ? (_ea = selectedLimitRouteCard == null ? void 0 : selectedLimitRouteCard.isUnavailable) != null ? _ea : false : (_fa = selectedRouteCard == null ? void 0 : selectedRouteCard.isUnavailable) != null ? _fa : false;
5729
+ const selectedLimitRouteCard = selectedLimitRouteCardId ? (__ = limitRouteCards.find((card) => card.id === selectedLimitRouteCardId)) != null ? __ : null : null;
5730
+ const selectedRouteGeoBlocked = isLimitOrder ? (_$ = selectedLimitRouteCard == null ? void 0 : selectedLimitRouteCard.isUnavailable) != null ? _$ : false : (_aa = selectedRouteCard == null ? void 0 : selectedRouteCard.isUnavailable) != null ? _aa : false;
5485
5731
  const geoBlockedVenuesFromWarnings = useMemo(
5486
5732
  () => {
5487
5733
  var _a2;
5488
5734
  return extractGeoBlockedVenues((_a2 = smartRoute.data) == null ? void 0 : _a2.warnings);
5489
5735
  },
5490
- [(_ga = smartRoute.data) == null ? void 0 : _ga.warnings]
5736
+ [(_ba = smartRoute.data) == null ? void 0 : _ba.warnings]
5491
5737
  );
5492
5738
  const isPrimaryVenueGeoBlocked = useMemo(() => {
5493
5739
  var _a2, _b2;
@@ -5505,7 +5751,7 @@ var PlaceOrder = ({
5505
5751
  const isActionDisabled = isPrimaryActionDisabled || !orderEligibility.canPlaceOrder || isActionLoading || !hasEnteredAmount || !scopedSelectedMarket || isInsufficientBalance || isQuoteInsufficientBalance || isSell && isQuoteInputEditing || isSellAmountAboveAvailability || isBelowMinimum || !isLimitOrder && isQuoteLoading || isSelectedVenueInventoryInsufficient || (isLimitOrder ? !limitOrderPayload : !selectedRouteCard || !selectedRouteCard.quoteData.quoteId) || selectedRouteGeoBlocked || !isAuthenticated || !isLimitOrder && quoteStatus !== void 0;
5506
5752
  const shouldShowSmartRouting = orderEligibility.canPlaceOrder && hasEnteredAmount && !isBelowMinimum && (isLimitOrder ? limitRouteCards.length > 0 : displayedRouteCards.length > 0 || smartRoute.isFetching || smartRoute.isLoading || isSell && (venueSellQuotes.isFetching || venueSellQuotes.isLoading));
5507
5753
  const shouldShowRouteToggle = !isLimitOrder && !isQuoteLoading && displayedRouteCards.length > PLACE_ORDER_ROUTE_COLLAPSED_CARD_COUNT;
5508
- const handleReturnToOrderForm = useCallback2(() => {
5754
+ const handleReturnToOrderForm = useCallback3(() => {
5509
5755
  const submittedSelection = submittedSelectionRef.current;
5510
5756
  submittedSelectionRef.current = null;
5511
5757
  setSubmissionProgressState(null);
@@ -5527,7 +5773,7 @@ var PlaceOrder = ({
5527
5773
  const shareUrl = `https://twitter.com/intent/tweet?text=${encodeURIComponent(shareText)}`;
5528
5774
  window.open(shareUrl, "_blank", "noopener,noreferrer");
5529
5775
  };
5530
- const handleExecuteQuote = useCallback2(
5776
+ const handleExecuteQuote = useCallback3(
5531
5777
  (quoteData) => __async(null, null, function* () {
5532
5778
  var _a2, _b2, _c2;
5533
5779
  const quoteId = quoteData == null ? void 0 : quoteData.quoteId;
@@ -5644,7 +5890,7 @@ var PlaceOrder = ({
5644
5890
  venueSellQuotes.quotes
5645
5891
  ]
5646
5892
  );
5647
- const handlePlaceLimitOrder = useCallback2(
5893
+ const handlePlaceLimitOrder = useCallback3(
5648
5894
  (submissionLimitOrderPayload) => __async(null, null, function* () {
5649
5895
  var _a2, _b2, _c2, _d2, _e2, _f2, _g2;
5650
5896
  if (!showLimitOrders) return;
@@ -5680,7 +5926,7 @@ var PlaceOrder = ({
5680
5926
  ) : sizeLabel;
5681
5927
  const eventTitle = (_b2 = (_a2 = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.title) != null ? _a2 : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _b2 : "";
5682
5928
  const eventDateSource = (_c2 = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.endDate) != null ? _c2 : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.endDate;
5683
- const responseVenue = Venue3[response.venue];
5929
+ const responseVenue = Venue4[response.venue];
5684
5930
  setSubmissionProgressState({
5685
5931
  orderId: response.orderId,
5686
5932
  orderIds: [response.orderId],
@@ -5727,7 +5973,7 @@ var PlaceOrder = ({
5727
5973
  tradingLabels
5728
5974
  ]
5729
5975
  );
5730
- const handleSkipToSuccess = useCallback2(() => {
5976
+ const handleSkipToSuccess = useCallback3(() => {
5731
5977
  const primaryFilledEvent = executionProgress.terminalOrderEvents.find(
5732
5978
  (e) => e.event === "filled" || e.event === "partial_fill"
5733
5979
  );
@@ -5752,7 +5998,7 @@ var PlaceOrder = ({
5752
5998
  failureSummary,
5753
5999
  selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData
5754
6000
  ]);
5755
- useEffect2(() => {
6001
+ useEffect3(() => {
5756
6002
  if ((submissionProgressState == null ? void 0 : submissionProgressState.phase) !== "failed") return;
5757
6003
  if ((failureSummary == null ? void 0 : failureSummary.kind) !== "partial_fill") return;
5758
6004
  if (!shouldAutoSkipPartialFill) return;
@@ -5763,7 +6009,7 @@ var PlaceOrder = ({
5763
6009
  shouldAutoSkipPartialFill,
5764
6010
  submissionProgressState == null ? void 0 : submissionProgressState.phase
5765
6011
  ]);
5766
- const handleRetrySubmission = useCallback2(() => __async(null, null, function* () {
6012
+ const handleRetrySubmission = useCallback3(() => __async(null, null, function* () {
5767
6013
  var _a2, _b2, _c2, _d2, _e2;
5768
6014
  if (!orderEligibility.canPlaceOrder || !failureSummary || failureSummary.kind === "generic") {
5769
6015
  handleReturnToOrderForm();
@@ -6171,7 +6417,7 @@ var PlaceOrder = ({
6171
6417
  PlaceOrderResolvedView,
6172
6418
  {
6173
6419
  tradingState: resolvedReadOnlyTradingState,
6174
- resolutionTimestamp: (_ha = resolvedEventTradingState.resolvesAt) != null ? _ha : resolvedReadOnlyTradingState.resolvesAt,
6420
+ resolutionTimestamp: (_ca = resolvedEventTradingState.resolvesAt) != null ? _ca : resolvedReadOnlyTradingState.resolvesAt,
6175
6421
  resolvedClaim,
6176
6422
  classNames,
6177
6423
  className,
@@ -6495,6 +6741,31 @@ var PlaceOrder = ({
6495
6741
  ) : null
6496
6742
  ] }),
6497
6743
  /* @__PURE__ */ jsx7("p", { className: "text-agg-sm leading-agg-5 text-agg-foreground", children: estimatedFeesValue })
6744
+ ] }) : null,
6745
+ showFeesBreakdown && hasEnteredAmount && !isBelowMinimum && executionReserveValue ? /* @__PURE__ */ jsxs6("div", { className: "agg-order-reserve-section flex items-center justify-between gap-4", children: [
6746
+ /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-1.5", children: [
6747
+ /* @__PURE__ */ jsx7(
6748
+ Typography,
6749
+ {
6750
+ variant: "text-sm",
6751
+ className: "text-agg-sm leading-agg-5 text-agg-muted-foreground",
6752
+ children: tradingLabels.executionReserve
6753
+ }
6754
+ ),
6755
+ /* @__PURE__ */ jsx7(
6756
+ Tooltip,
6757
+ {
6758
+ "aria-label": tradingLabels.executionReserveTooltipAria,
6759
+ content: tradingLabels.executionReserveDescription,
6760
+ classNames: {
6761
+ content: "max-w-[320px]",
6762
+ icon: "h-3 w-3 text-agg-muted-foreground",
6763
+ trigger: "h-3 w-3 text-agg-muted-foreground"
6764
+ }
6765
+ }
6766
+ )
6767
+ ] }),
6768
+ /* @__PURE__ */ jsx7("p", { className: "text-agg-sm leading-agg-5 text-agg-foreground", children: executionReserveValue })
6498
6769
  ] }) : null
6499
6770
  ] }),
6500
6771
  shouldShowSmartRouting ? /* @__PURE__ */ jsxs6(
@@ -6537,6 +6808,7 @@ var PlaceOrder = ({
6537
6808
  isExpanded: card.kind === "split" ? isSplitDetailOpen : isRoutesExpanded,
6538
6809
  isSelected: !card.isUnavailable && card.id === (isLimitOrder ? selectedLimitRouteCardId : resolvedSelectedRouteCardId),
6539
6810
  onSelect: handleActiveRouteCardSelect,
6811
+ sharedKycStatus: isPaperMode ? void 0 : sharedKyc == null ? void 0 : sharedKyc.status,
6540
6812
  tradingLabels
6541
6813
  }) }, card.id);
6542
6814
  }) : null })
@@ -6783,7 +7055,7 @@ var PlaceOrder = ({
6783
7055
  }
6784
7056
  ) : null
6785
7057
  ] }) : null,
6786
- !submissionFeedback && !shouldShowGeoBlockBanner && orderEligibility.canPlaceOrder && !needsKalshiConnection && shouldShowInsufficientBalanceAlert ? /* @__PURE__ */ jsxs6(
7058
+ !submissionFeedback && !shouldShowGeoBlockBanner && orderEligibility.canPlaceOrder && !needsSharedKycVerification && !needsKalshiConnection && shouldShowInsufficientBalanceAlert ? /* @__PURE__ */ jsxs6(
6787
7059
  "div",
6788
7060
  {
6789
7061
  className: "agg-order-insufficient-balance-alert flex items-center justify-center gap-2",
@@ -6816,25 +7088,29 @@ var PlaceOrder = ({
6816
7088
  ]
6817
7089
  }
6818
7090
  ) : null,
6819
- !submissionFeedback && !shouldShowGeoBlockBanner && needsKalshiConnection ? /* @__PURE__ */ jsx7(
7091
+ !submissionFeedback && !shouldShowGeoBlockBanner && needsSharedKycVerification ? /* @__PURE__ */ jsx7(
6820
7092
  Button,
6821
7093
  {
6822
7094
  size: "large",
6823
7095
  variant: "primary",
6824
- className: "agg-order-connect-kalshi h-12 w-full px-8 text-agg-base leading-agg-6 shadow-none",
6825
- "aria-label": tradingLabels.connectKalshi,
6826
- onClick: () => setIsConnectKalshiModalOpen(true),
6827
- children: tradingLabels.connectKalshi
7096
+ className: "agg-order-shared-kyc-action h-12 w-full px-8 text-agg-base leading-agg-6 shadow-none",
7097
+ "aria-label": sharedKyc.status === "loading" ? tradingLabels.sharedKyc.checkingStatus : tradingLabels.sharedKyc.completeToTrade,
7098
+ disabled: sharedKyc.status === "loading",
7099
+ isLoading: sharedKyc.status === "loading",
7100
+ onClick: () => {
7101
+ if (selectedSharedKycVenue) sharedKycFlow.openForVenue(selectedSharedKycVenue);
7102
+ },
7103
+ children: sharedKyc.status === "loading" ? tradingLabels.sharedKyc.checkingStatus : tradingLabels.sharedKyc.completeToTrade
6828
7104
  }
6829
- ) : needsKycVerification && !submissionFeedback && !shouldShowGeoBlockBanner ? /* @__PURE__ */ jsx7(
7105
+ ) : !submissionFeedback && !shouldShowGeoBlockBanner && needsKalshiConnection ? /* @__PURE__ */ jsx7(
6830
7106
  Button,
6831
7107
  {
6832
7108
  size: "large",
6833
7109
  variant: "primary",
6834
- className: "agg-order-kyc-action h-12 w-full px-8 text-agg-base leading-agg-6 shadow-none",
6835
- "aria-label": verifyKalshiConnectionLabel,
7110
+ className: "agg-order-connect-kalshi h-12 w-full px-8 text-agg-base leading-agg-6 shadow-none",
7111
+ "aria-label": tradingLabels.connectKalshi,
6836
7112
  onClick: () => setIsConnectKalshiModalOpen(true),
6837
- children: verifyKalshiConnectionLabel
7113
+ children: tradingLabels.connectKalshi
6838
7114
  }
6839
7115
  ) : !submissionFeedback && !shouldShowGeoBlockBanner && isInsufficientBalance ? /* @__PURE__ */ jsx7(
6840
7116
  Button,
@@ -6923,6 +7199,20 @@ var PlaceOrder = ({
6923
7199
  ]
6924
7200
  }
6925
7201
  ),
7202
+ /* @__PURE__ */ jsx7(
7203
+ SharedKycModal,
7204
+ {
7205
+ open: sharedKycFlow.isModalOpen,
7206
+ state: sharedKycFlow.modalState,
7207
+ errorMessage: sharedKycFlow.errorMessage,
7208
+ onOpenChange: (nextOpen) => {
7209
+ if (!nextOpen) sharedKycFlow.closeModal();
7210
+ },
7211
+ onStartVerification: () => {
7212
+ void sharedKycFlow.startVerification();
7213
+ }
7214
+ }
7215
+ ),
6926
7216
  /* @__PURE__ */ jsx7(
6927
7217
  ConnectKalshiModal,
6928
7218
  {
@@ -6947,7 +7237,7 @@ import {
6947
7237
  useRedeem,
6948
7238
  useRedeemLifecycles
6949
7239
  } from "@agg-build/hooks";
6950
- import { useCallback as useCallback3, useEffect as useEffect3, useMemo as useMemo2, useRef as useRef3, useState as useState2 } from "react";
7240
+ import { useCallback as useCallback4, useEffect as useEffect4, useMemo as useMemo2, useRef as useRef4, useState as useState3 } from "react";
6951
7241
  var toClaimError = (err) => {
6952
7242
  if (err instanceof Error) return err;
6953
7243
  return new Error(String(err));
@@ -6959,11 +7249,11 @@ function useClaimWinnings(options = {}) {
6959
7249
  const toastCtx = useOptionalToast();
6960
7250
  const queryClient = useQueryClient2();
6961
7251
  const redeemMutation = useRedeem();
6962
- const [activeRedeems, setActiveRedeems] = useState2({});
6963
- const activeClaimKeysRef = useRef3(/* @__PURE__ */ new Set());
6964
- const pendingClaimToastIdsRef = useRef3({});
6965
- const submittedClaimToastKeysRef = useRef3(/* @__PURE__ */ new Set());
6966
- const [submittingClaimKeys, setSubmittingClaimKeys] = useState2({});
7252
+ const [activeRedeems, setActiveRedeems] = useState3({});
7253
+ const activeClaimKeysRef = useRef4(/* @__PURE__ */ new Set());
7254
+ const pendingClaimToastIdsRef = useRef4({});
7255
+ const submittedClaimToastKeysRef = useRef4(/* @__PURE__ */ new Set());
7256
+ const [submittingClaimKeys, setSubmittingClaimKeys] = useState3({});
6967
7257
  const lifecycleInputs = useMemo2(
6968
7258
  () => Object.values(activeRedeems),
6969
7259
  [activeRedeems]
@@ -6978,11 +7268,11 @@ function useClaimWinnings(options = {}) {
6978
7268
  return out;
6979
7269
  }, [activeRedeems, lifecycleStates, submittingClaimKeys]);
6980
7270
  const claimingKeys = externalClaimingKeys != null ? externalClaimingKeys : internalClaimingIds;
6981
- const isClaiming = useCallback3(
7271
+ const isClaiming = useCallback4(
6982
7272
  (claimKey) => Boolean(externalClaimingKeys == null ? void 0 : externalClaimingKeys[claimKey]) || Boolean(internalClaimingIds[claimKey]),
6983
7273
  [externalClaimingKeys, internalClaimingIds]
6984
7274
  );
6985
- const invalidateClaimUiState = useCallback3(() => {
7275
+ const invalidateClaimUiState = useCallback4(() => {
6986
7276
  invalidateBalanceQueries2(queryClient);
6987
7277
  invalidatePositionQueries2(queryClient);
6988
7278
  queryClient.invalidateQueries({
@@ -6991,7 +7281,7 @@ function useClaimWinnings(options = {}) {
6991
7281
  });
6992
7282
  invalidateUserActivityQueries(queryClient);
6993
7283
  }, [queryClient]);
6994
- const claim = useCallback3(
7284
+ const claim = useCallback4(
6995
7285
  (_0) => __async(null, [_0], function* ({ claimKey, winningOutcomeIds, payload }) {
6996
7286
  if (activeClaimKeysRef.current.has(claimKey) || Boolean(externalClaimingKeys == null ? void 0 : externalClaimingKeys[claimKey]) || internalClaimingIds[claimKey]) {
6997
7287
  return;
@@ -7129,8 +7419,8 @@ function useClaimWinnings(options = {}) {
7129
7419
  toastCtx
7130
7420
  ]
7131
7421
  );
7132
- const firedTerminalRef = useRef3({});
7133
- useEffect3(() => {
7422
+ const firedTerminalRef = useRef4({});
7423
+ useEffect4(() => {
7134
7424
  var _a, _b;
7135
7425
  for (const [claimKey, active] of Object.entries(activeRedeems)) {
7136
7426
  const state = lifecycleStates[active.redeemId];
@@ -7264,6 +7554,9 @@ export {
7264
7554
  parseVenue,
7265
7555
  parseAmount,
7266
7556
  SettlementDetails,
7557
+ venueRequiresSharedKyc,
7558
+ createAggClientSharedKycInitiator,
7559
+ useSharedKycFlow,
7267
7560
  DEPOSIT_MODAL_OPEN_EVENT,
7268
7561
  WITHDRAW_MODAL_OPEN_EVENT,
7269
7562
  requestAggDepositModalOpen,