@agg-build/ui 2.4.9 → 2.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/chunk-AHQA3B7D.mjs +947 -0
  2. package/dist/{chunk-CXSIXL7M.mjs → chunk-AJJ73RM4.mjs} +698 -257
  3. package/dist/{chunk-TEBAR55W.mjs → chunk-EDQ64EKO.mjs} +339 -1084
  4. package/dist/{chunk-GWRFSQQK.mjs → chunk-FAU2VOL6.mjs} +1594 -700
  5. package/dist/{chunk-PTNFXXOV.mjs → chunk-FMYYPNZZ.mjs} +904 -788
  6. package/dist/{chunk-UH3DUTMG.mjs → chunk-JQKJDSTW.mjs} +1 -1
  7. package/dist/{chunk-I4X5UNCT.mjs → chunk-XAG432PJ.mjs} +12 -6
  8. package/dist/events.js +1077 -999
  9. package/dist/events.mjs +3 -3
  10. package/dist/index.js +16499 -14884
  11. package/dist/index.mjs +56 -18
  12. package/dist/modals.js +1292 -1084
  13. package/dist/modals.mjs +10 -10
  14. package/dist/pages.js +4954 -2639
  15. package/dist/pages.mjs +6 -6
  16. package/dist/primitives.js +905 -788
  17. package/dist/primitives.mjs +3 -1
  18. package/dist/styles.css +1 -1
  19. package/dist/tailwind.css +1 -1
  20. package/dist/trading.js +3383 -1508
  21. package/dist/trading.mjs +6 -4
  22. package/dist/types/auth/connect-button-view/connect-button-view.types.d.mts +2 -0
  23. package/dist/types/auth/connect-button-view/connect-button-view.types.d.ts +2 -0
  24. package/dist/types/auth/connect-button-view/index.d.mts +1 -1
  25. package/dist/types/auth/connect-button-view/index.d.ts +1 -1
  26. package/dist/types/onboarding/steps/connect-kalshi-modal.d.mts +1 -1
  27. package/dist/types/onboarding/steps/connect-kalshi-modal.d.ts +1 -1
  28. package/dist/types/pages/user-profile/components/available-balance-card.d.mts +2 -1
  29. package/dist/types/pages/user-profile/components/available-balance-card.d.ts +2 -1
  30. package/dist/types/pages/user-profile/components/open-order-row.d.mts +10 -1
  31. package/dist/types/pages/user-profile/components/open-order-row.d.ts +10 -1
  32. package/dist/types/pages/user-profile/components/positions-activity.d.mts +4 -1
  33. package/dist/types/pages/user-profile/components/positions-activity.d.ts +4 -1
  34. package/dist/types/pages/user-profile/components/positions-value-card.d.mts +4 -2
  35. package/dist/types/pages/user-profile/components/positions-value-card.d.ts +4 -2
  36. package/dist/types/pages/user-profile/index.d.mts +2 -2
  37. package/dist/types/pages/user-profile/index.d.ts +2 -2
  38. package/dist/types/pages/user-profile/user-profile.types.d.mts +12 -0
  39. package/dist/types/pages/user-profile/user-profile.types.d.ts +12 -0
  40. package/dist/types/primitives/calendar/index.d.mts +8 -0
  41. package/dist/types/primitives/calendar/index.d.ts +8 -0
  42. package/dist/types/primitives/icon/registry.d.mts +3 -0
  43. package/dist/types/primitives/icon/registry.d.ts +3 -0
  44. package/dist/types/primitives/icon/svg/calendar.d.mts +2 -0
  45. package/dist/types/primitives/icon/svg/calendar.d.ts +2 -0
  46. package/dist/types/primitives/icon/svg/minus.d.mts +2 -0
  47. package/dist/types/primitives/icon/svg/minus.d.ts +2 -0
  48. package/dist/types/primitives/icon/svg/plus.d.mts +2 -0
  49. package/dist/types/primitives/icon/svg/plus.d.ts +2 -0
  50. package/dist/types/primitives/index.d.mts +1 -0
  51. package/dist/types/primitives/index.d.ts +1 -0
  52. package/dist/types/profile/index.d.mts +1 -1
  53. package/dist/types/profile/index.d.ts +1 -1
  54. package/dist/types/profile/profile-modal.types.d.mts +6 -0
  55. package/dist/types/profile/profile-modal.types.d.ts +6 -0
  56. package/dist/types/profile/tabs/trading-access-tab.d.mts +3 -1
  57. package/dist/types/profile/tabs/trading-access-tab.d.ts +3 -1
  58. package/dist/types/trading/fund-kalshi-modal.d.mts +8 -0
  59. package/dist/types/trading/fund-kalshi-modal.d.ts +8 -0
  60. package/dist/types/trading/index.d.mts +1 -0
  61. package/dist/types/trading/index.d.ts +1 -0
  62. package/dist/types/trading/place-order/index.d.mts +1 -1
  63. package/dist/types/trading/place-order/index.d.ts +1 -1
  64. package/dist/types/trading/place-order/index.place-order.types.d.mts +13 -1
  65. package/dist/types/trading/place-order/index.place-order.types.d.ts +13 -1
  66. package/dist/types/trading/place-order/index.place-order.utils.d.mts +18 -1
  67. package/dist/types/trading/place-order/index.place-order.utils.d.ts +18 -1
  68. package/package.json +7 -4
  69. package/dist/chunk-JVRTJQPZ.mjs +0 -59
@@ -9,14 +9,16 @@ import {
9
9
  getTradingVenueLabel,
10
10
  prepareSettlementDifferences,
11
11
  resolveOrderEligibilityMessage
12
- } from "./chunk-UH3DUTMG.mjs";
12
+ } from "./chunk-JQKJDSTW.mjs";
13
13
  import {
14
+ ConnectKalshiModal,
14
15
  GeoBlockBanner,
15
16
  subscribeAggDepositNotification
16
- } from "./chunk-JVRTJQPZ.mjs";
17
+ } from "./chunk-AHQA3B7D.mjs";
17
18
  import {
18
19
  AGG_TERMS_OF_SERVICE_URL,
19
20
  Button,
21
+ Calendar,
20
22
  Card,
21
23
  CloseIcon,
22
24
  CurrencyInput,
@@ -27,10 +29,8 @@ import {
27
29
  PlaceOrderRouteCardSkeleton,
28
30
  RemoteImage,
29
31
  Skeleton,
30
- SuccessCheckIcon,
31
32
  Tooltip,
32
33
  Typography,
33
- UserTrustIcon,
34
34
  VenueLogo,
35
35
  __async,
36
36
  __objRest,
@@ -46,7 +46,7 @@ import {
46
46
  resolveResolvedOutcomeLabel,
47
47
  skeletonViews,
48
48
  useOptionalToast
49
- } from "./chunk-PTNFXXOV.mjs";
49
+ } from "./chunk-FMYYPNZZ.mjs";
50
50
 
51
51
  // src/trading/types.ts
52
52
  import { Venue, enumGuard, isFiniteNonNeg, safeParse } from "@agg-build/sdk";
@@ -128,7 +128,7 @@ SettlementDetails.displayName = "SettlementDetails";
128
128
 
129
129
  // src/trading/place-order/index.tsx
130
130
  import {
131
- getWalletAddressFromUserProfile,
131
+ getVenueAvailabilityState,
132
132
  invalidateBalanceQueries,
133
133
  invalidatePositionQueries,
134
134
  mergeBestPricesPreferringLive,
@@ -138,25 +138,34 @@ import {
138
138
  resolveOrderEligibility,
139
139
  useAggAuthContext,
140
140
  useAggBalanceState,
141
- useAggClient as useAggClient2,
141
+ useAggClient,
142
+ useAppConfig,
142
143
  useDebouncedValue,
143
144
  useEventTradingContext as useEventTradingContext2,
144
145
  useExecuteManaged,
145
146
  useExecutionPositions,
146
147
  useExecutionProgress,
147
148
  useGeoBlock,
148
- useLabels,
149
+ useLabels as useLabels2,
149
150
  useLiveBestPrices,
150
151
  useLiveOutcomePrices,
151
152
  useManagedBalances,
152
153
  useMidpoints,
154
+ usePlaceLimitOrder,
153
155
  useQueryClient,
154
156
  useSdkUiConfig,
155
- useSmartRoute
157
+ useSmartRoute,
158
+ useVenueKeyStatus,
159
+ useVenueSellQuotes
156
160
  } from "@agg-build/hooks";
161
+ import { Venue as Venue4 } from "@agg-build/sdk";
157
162
  import NumberFlow from "@number-flow/react";
158
- import * as Dialog from "@radix-ui/react-dialog";
159
- import { Fragment as Fragment2, useCallback as useCallback3, useEffect as useEffect3, useId, useMemo as useMemo2, useRef as useRef3, useState as useState3 } from "react";
163
+ import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
164
+ import * as Popover from "@radix-ui/react-popover";
165
+ import dayjs from "dayjs";
166
+ import timezone from "dayjs/plugin/timezone";
167
+ import utc from "dayjs/plugin/utc";
168
+ import { Fragment as Fragment2, useCallback as useCallback2, useEffect as useEffect2, useId, useMemo, useRef as useRef2, useState as useState2 } from "react";
160
169
 
161
170
  // src/notifications/agg-notification-events-provider.tsx
162
171
  import {
@@ -525,116 +534,76 @@ var requestAggWithdrawModalOpen = () => {
525
534
  window.dispatchEvent(new Event(WITHDRAW_MODAL_OPEN_EVENT));
526
535
  };
527
536
 
528
- // src/trading/use-kalshi-kyc-flow.ts
529
- import { useAggClient, useDepositAddresses } from "@agg-build/hooks";
530
- import { useCallback as useCallback2, useEffect as useEffect2, useMemo, useRef as useRef2, useState } from "react";
531
- var KYC_PENDING_STORAGE_KEY = "agg_kyc_pending";
532
- var getKycPendingState = () => {
533
- var _a, _b;
534
- const rawValue = sessionStorage.getItem(KYC_PENDING_STORAGE_KEY);
535
- if (!rawValue) return null;
536
- try {
537
- const parsed = JSON.parse(rawValue);
538
- if (parsed.venue !== "kalshi") return null;
539
- return {
540
- venue: "kalshi",
541
- userId: (_a = parsed.userId) != null ? _a : null,
542
- walletAddress: (_b = parsed.walletAddress) != null ? _b : null
543
- };
544
- } catch (e) {
545
- return null;
546
- }
547
- };
548
- var setKycPendingState = (state) => {
549
- sessionStorage.setItem(KYC_PENDING_STORAGE_KEY, JSON.stringify(state));
550
- };
551
- var clearKycPendingState = () => {
552
- sessionStorage.removeItem(KYC_PENDING_STORAGE_KEY);
553
- };
554
- var useKalshiKycFlow = ({
555
- isKalshiVerified,
556
- userId,
557
- walletAddress,
558
- onError
559
- }) => {
560
- const client = useAggClient();
561
- const [isVerifyModalOpen, setIsVerifyModalOpen] = useState(false);
562
- const [showSuccessModal, setShowSuccessModal] = useState(false);
563
- const [isInitiating, setIsInitiating] = useState(false);
564
- const [needsDepositAddress, setNeedsDepositAddress] = useState(false);
565
- const initiationAttemptRef = useRef2(0);
566
- const { isReady, isTimedOut } = useDepositAddresses({ enabled: needsDepositAddress, poll: true });
567
- const pendingState = useMemo(
568
- () => ({
569
- venue: "kalshi",
570
- userId: userId != null ? userId : null,
571
- walletAddress: walletAddress != null ? walletAddress : null
572
- }),
573
- [userId, walletAddress]
574
- );
575
- const resetInitiation = useCallback2(() => {
576
- setIsInitiating(false);
577
- setNeedsDepositAddress(false);
578
- }, []);
579
- const closeVerifyModal = useCallback2(() => {
580
- initiationAttemptRef.current += 1;
581
- clearKycPendingState();
582
- resetInitiation();
583
- setIsVerifyModalOpen(false);
584
- }, [resetInitiation]);
585
- const closeSuccessModal = useCallback2(() => {
586
- setShowSuccessModal(false);
587
- }, []);
588
- const openVerifyModal = useCallback2(() => {
589
- setIsVerifyModalOpen(true);
590
- }, []);
591
- const startVerification = useCallback2(() => {
592
- initiationAttemptRef.current += 1;
593
- setIsInitiating(true);
594
- setNeedsDepositAddress(true);
595
- }, []);
596
- useEffect2(() => {
597
- if (!isInitiating || !isReady) return;
598
- const attemptId = initiationAttemptRef.current;
599
- const redirectUri = window.location.href;
600
- setKycPendingState(pendingState);
601
- client.initiateKyc("kalshi", redirectUri).then((res) => {
602
- if (initiationAttemptRef.current !== attemptId) return;
603
- if (res.kycUrl) window.location.assign(res.kycUrl);
604
- }).catch((err) => {
605
- if (initiationAttemptRef.current !== attemptId) return;
606
- clearKycPendingState();
607
- onError == null ? void 0 : onError(err instanceof Error ? err : new Error(String(err)));
608
- }).finally(() => {
609
- if (initiationAttemptRef.current !== attemptId) return;
610
- resetInitiation();
611
- });
612
- }, [client, isInitiating, isReady, onError, pendingState, resetInitiation]);
613
- useEffect2(() => {
614
- if (isTimedOut && isInitiating) {
615
- clearKycPendingState();
616
- resetInitiation();
617
- onError == null ? void 0 : onError(new Error("Deposit address provisioning timed out"));
618
- }
619
- }, [isInitiating, isTimedOut, onError, resetInitiation]);
620
- useEffect2(() => {
621
- const storedPendingState = getKycPendingState();
622
- const isMatchingSession = (storedPendingState == null ? void 0 : storedPendingState.venue) === "kalshi" && storedPendingState.userId === pendingState.userId && storedPendingState.walletAddress === pendingState.walletAddress;
623
- if (isKalshiVerified && isMatchingSession) {
624
- clearKycPendingState();
625
- setShowSuccessModal(true);
537
+ // src/trading/fund-kalshi-modal.tsx
538
+ import { useLabels } from "@agg-build/hooks";
539
+ import { Venue as Venue2 } from "@agg-build/sdk";
540
+ import * as Dialog from "@radix-ui/react-dialog";
541
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
542
+ var FundKalshiModal = ({ open, onOpenChange }) => {
543
+ const labels = useLabels();
544
+ const modalLabels = labels.trading.fundKalshiModal;
545
+ return /* @__PURE__ */ jsx3(Modal, { open, onOpenChange, children: /* @__PURE__ */ jsxs2(
546
+ Modal.Container,
547
+ {
548
+ maxWidth: "600px",
549
+ "aria-label": modalLabels.ariaLabel,
550
+ classNames: { container: "relative !rounded-agg-2xl" },
551
+ children: [
552
+ /* @__PURE__ */ jsx3(
553
+ Dialog.Close,
554
+ {
555
+ "aria-label": labels.common.close,
556
+ className: "absolute right-6 top-6 z-10 flex size-11 cursor-pointer items-center justify-center rounded-agg-full text-agg-secondary transition-colors hover:bg-agg-quaternary hover:text-agg-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-accent sm:right-7 sm:top-7",
557
+ children: /* @__PURE__ */ jsx3(Icon, { name: "close", size: "medium" })
558
+ }
559
+ ),
560
+ /* @__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: [
561
+ /* @__PURE__ */ jsx3(VenueLogo, { venue: Venue2.kalshi, variant: "logo", size: "large", className: "size-[60px]" }),
562
+ /* @__PURE__ */ jsxs2("div", { className: "flex flex-col items-center gap-4", children: [
563
+ /* @__PURE__ */ jsx3(Dialog.Title, { className: "text-agg-2xl font-agg-bold leading-agg-8 text-agg-foreground", children: modalLabels.title }),
564
+ /* @__PURE__ */ jsx3(Dialog.Description, { className: "max-w-[520px] text-agg-base leading-agg-6 text-agg-foreground", children: modalLabels.description })
565
+ ] }),
566
+ /* @__PURE__ */ jsxs2("div", { className: "flex w-full flex-col gap-3 rounded-agg-xl bg-agg-secondary-hover p-4 text-left", children: [
567
+ /* @__PURE__ */ jsx3("p", { className: "text-agg-xs font-agg-bold uppercase leading-agg-4 text-agg-muted-foreground", children: modalLabels.howItWorks }),
568
+ /* @__PURE__ */ jsxs2("ol", { className: "list-decimal space-y-0 pl-5 text-agg-sm leading-agg-5 text-agg-foreground", children: [
569
+ /* @__PURE__ */ jsxs2("li", { children: [
570
+ modalLabels.firstStepPrefix,
571
+ " ",
572
+ /* @__PURE__ */ jsx3(
573
+ "a",
574
+ {
575
+ href: modalLabels.kalshiUrl,
576
+ target: "_blank",
577
+ rel: "noreferrer",
578
+ className: "cursor-pointer underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary",
579
+ children: modalLabels.kalshiLinkLabel
580
+ }
581
+ ),
582
+ " ",
583
+ modalLabels.firstStepSuffix
584
+ ] }),
585
+ modalLabels.remainingSteps.map((step) => /* @__PURE__ */ jsx3("li", { children: step }, step))
586
+ ] })
587
+ ] }),
588
+ /* @__PURE__ */ jsxs2("div", { className: "flex flex-wrap items-center justify-center gap-3", children: [
589
+ /* @__PURE__ */ jsx3(Button, { variant: "secondary", size: "large", onClick: () => onOpenChange(false), children: modalLabels.doItLater }),
590
+ /* @__PURE__ */ jsx3(
591
+ Button,
592
+ {
593
+ variant: "primary",
594
+ size: "large",
595
+ className: "min-w-[100px]",
596
+ onClick: () => onOpenChange(false),
597
+ children: modalLabels.done
598
+ }
599
+ )
600
+ ] })
601
+ ] }) })
602
+ ]
626
603
  }
627
- }, [isKalshiVerified, pendingState]);
628
- return {
629
- isVerifyModalOpen,
630
- showSuccessModal,
631
- isInitiating,
632
- openVerifyModal,
633
- closeVerifyModal,
634
- closeSuccessModal,
635
- startVerification
636
- };
604
+ ) });
637
605
  };
606
+ FundKalshiModal.displayName = "FundKalshiModal";
638
607
 
639
608
  // src/trading/place-order/index.place-order.constants.ts
640
609
  var PLACE_ORDER_DEFAULT_AMOUNT = 20;
@@ -923,7 +892,7 @@ var enableExecutionDebugInBrowser = (initial) => {
923
892
  };
924
893
 
925
894
  // src/trading/place-order/index.place-order.execution-steps.ts
926
- import { Venue as Venue2 } from "@agg-build/sdk";
895
+ import { Venue as Venue3 } from "@agg-build/sdk";
927
896
  var WAIT_STEP_TYPES = /* @__PURE__ */ new Set(["_wait", "wait"]);
928
897
  var CHECKING_BALANCE_STEP_TYPES = /* @__PURE__ */ new Set([
929
898
  "check-balance",
@@ -934,14 +903,14 @@ var CHECKING_BALANCE_STEP_TYPES = /* @__PURE__ */ new Set([
934
903
  var VENUE_BUY_SELL_REGEX = /^(?:buy|sell)-([a-z]+)$/;
935
904
  var VENUE_FINALIZE_REGEX = /^([a-z]+)-finalize$/;
936
905
  var VENUE_NAME_MAP = {
937
- kalshi: Venue2.kalshi,
938
- polymarket: Venue2.polymarket,
939
- limitless: Venue2.limitless,
940
- opinion: Venue2.opinion,
941
- predict: Venue2.predict,
942
- probable: Venue2.probable,
943
- myriad: Venue2.myriad,
944
- hyperliquid: Venue2.hyperliquid
906
+ kalshi: Venue3.kalshi,
907
+ polymarket: Venue3.polymarket,
908
+ limitless: Venue3.limitless,
909
+ opinion: Venue3.opinion,
910
+ predict: Venue3.predict,
911
+ probable: Venue3.probable,
912
+ myriad: Venue3.myriad,
913
+ hyperliquid: Venue3.hyperliquid
945
914
  };
946
915
  var parseVenueName = (raw) => VENUE_NAME_MAP[raw];
947
916
  var NON_VENUE_FINALIZE_PREFIXES = /* @__PURE__ */ new Set(["bridge"]);
@@ -1110,6 +1079,7 @@ var buildSubmissionDisplayRows = ({
1110
1079
 
1111
1080
  // src/trading/place-order/index.place-order.utils.ts
1112
1081
  var ATOMIC_UNITS = 1e6;
1082
+ var ATOMIC_UNITS_BIGINT = BigInt(ATOMIC_UNITS);
1113
1083
  var routePriceLabelFormatter = new Intl.NumberFormat("en-US", {
1114
1084
  minimumFractionDigits: 0,
1115
1085
  maximumFractionDigits: 1
@@ -1325,10 +1295,14 @@ var buildLiveRouteCards = ({
1325
1295
  labels,
1326
1296
  quoteData,
1327
1297
  tradeSide,
1328
- eventVenues = []
1298
+ eventVenues = [],
1299
+ geoBlockedVenues: inheritedGeoBlockedVenues
1329
1300
  }) => {
1330
1301
  var _a, _b, _c;
1331
1302
  const geoBlockedVenues = extractGeoBlockedVenues(quoteData.warnings);
1303
+ for (const venue of inheritedGeoBlockedVenues != null ? inheritedGeoBlockedVenues : []) {
1304
+ geoBlockedVenues.add(venue);
1305
+ }
1332
1306
  const eventVenueSet = new Set(eventVenues);
1333
1307
  const primaryResult = resolvePlaceOrderQuoteResult({ labels, quoteData, tradeSide });
1334
1308
  const primaryVenue = (_a = quoteData.fills[0]) == null ? void 0 : _a.venue;
@@ -1362,7 +1336,14 @@ var buildLiveRouteCards = ({
1362
1336
  venue: isSplit ? void 0 : parsedPrimaryVenue.success ? parsedPrimaryVenue.data : void 0
1363
1337
  } : null;
1364
1338
  const soloCards = ((_b = quoteData.venueSoloQuotes) != null ? _b : []).filter(
1365
- (sq) => sq.status === "ok" && sq.avgPrice !== null && sq.filledQty > 0 && (sq.quoteId || quoteData.status === "insufficient_balance") && sq.venue !== primaryWinnerVenue
1339
+ (sq) => sq.status === "ok" && sq.avgPrice !== null && sq.filledQty > 0 && // No `sq.quoteId` requirement: a solo is preview-only whenever its own
1340
+ // funding lane is short (API nulls the quoteId), which is NOT always the
1341
+ // whole-quote `insufficient_balance` case — an off-chain winner (Kalshi
1342
+ // settles from venue cash) keeps the quote `ok` while the on-chain solo
1343
+ // stays unfunded. Gating on the quoteId silently hid that venue from the
1344
+ // comparison list entirely. The panel's Deposit CTA fires off the same
1345
+ // balance condition, and `handleExecuteQuote` rejects an empty quoteId.
1346
+ sq.venue !== primaryWinnerVenue
1366
1347
  ).map((sq) => {
1367
1348
  var _a2;
1368
1349
  const parsedVenue = parseVenue(sq.venue);
@@ -1386,9 +1367,9 @@ var buildLiveRouteCards = ({
1386
1367
  }
1387
1368
  const avgPrice = sq.avgPrice;
1388
1369
  const soloQuoteData = __spreadProps(__spreadValues({}, quoteData), {
1389
- // Preview-only solos from `insufficient_balance` intentionally carry
1390
- // no executable quoteId; the card should still render for comparison,
1391
- // while the CTA stays disabled until the user is funded and requotes.
1370
+ // Preview-only solos intentionally carry no executable quoteId; the card
1371
+ // should still render for comparison, while the CTA stays disabled until
1372
+ // the user is funded and requotes.
1392
1373
  quoteId: (_a2 = sq.quoteId) != null ? _a2 : "",
1393
1374
  fills: sq.fills.map((f) => __spreadValues({}, f)),
1394
1375
  totalFilled: sq.filledQty,
@@ -1454,6 +1435,108 @@ var buildLiveRouteCards = ({
1454
1435
  })() : [];
1455
1436
  return [...baseCards, ...unavailableCards, ...warningOnlyUnavailableCards];
1456
1437
  };
1438
+ var sellSharesToAtomicUnits = (shares) => {
1439
+ if (!Number.isFinite(shares) || shares <= 0) return BigInt(0);
1440
+ const [whole = "0", fraction = ""] = shares.toFixed(12).split(".");
1441
+ const atomicFraction = fraction.padEnd(6, "0").slice(0, 6);
1442
+ return BigInt(whole) * ATOMIC_UNITS_BIGINT + BigInt(atomicFraction);
1443
+ };
1444
+ var atomicUnitsToSellShares = (atomicShares) => {
1445
+ if (atomicShares <= 0) return 0;
1446
+ const whole = atomicShares / ATOMIC_UNITS_BIGINT;
1447
+ const fraction = (atomicShares % ATOMIC_UNITS_BIGINT).toString().padStart(6, "0");
1448
+ return Number(`${whole}.${fraction}`);
1449
+ };
1450
+ var clampSellSharesToAvailability = (requestedSellShares, availableShares) => {
1451
+ const requestedAtomicShares = sellSharesToAtomicUnits(requestedSellShares);
1452
+ const availableAtomicShares = sellSharesToAtomicUnits(availableShares);
1453
+ return atomicUnitsToSellShares(
1454
+ requestedAtomicShares < availableAtomicShares ? requestedAtomicShares : availableAtomicShares
1455
+ );
1456
+ };
1457
+ var getRemainingVenueSellShares = (availableShares, filledShares) => {
1458
+ const availableAtomicShares = sellSharesToAtomicUnits(availableShares);
1459
+ const filledAtomicShares = sellSharesToAtomicUnits(filledShares);
1460
+ return atomicUnitsToSellShares(
1461
+ availableAtomicShares > filledAtomicShares ? availableAtomicShares - filledAtomicShares : BigInt(0)
1462
+ );
1463
+ };
1464
+ var buildVenueSellQuoteRequests = ({
1465
+ quoteData,
1466
+ requestedSellShares
1467
+ }) => {
1468
+ var _a, _b, _c;
1469
+ const requestedAtomicShares = sellSharesToAtomicUnits(requestedSellShares);
1470
+ if (requestedAtomicShares <= 0) return [];
1471
+ const availableAtomicSharesByVenue = /* @__PURE__ */ new Map();
1472
+ for (const position of (_b = (_a = quoteData == null ? void 0 : quoteData.positionAvailability) == null ? void 0 : _a.venueMarketOutcomes) != null ? _b : []) {
1473
+ const parsedVenue = parseVenue(position.venue);
1474
+ if (!parsedVenue.success) continue;
1475
+ const availableAtomicShares = sellSharesToAtomicUnits(position.availableShares);
1476
+ if (availableAtomicShares <= 0) continue;
1477
+ availableAtomicSharesByVenue.set(
1478
+ parsedVenue.data,
1479
+ ((_c = availableAtomicSharesByVenue.get(parsedVenue.data)) != null ? _c : BigInt(0)) + availableAtomicShares
1480
+ );
1481
+ }
1482
+ return [...availableAtomicSharesByVenue.entries()].sort(([leftVenue], [rightVenue]) => leftVenue.localeCompare(rightVenue)).map(([venue, availableAtomicShares]) => ({
1483
+ venue,
1484
+ requestedSellShares: atomicUnitsToSellShares(requestedAtomicShares),
1485
+ sellShares: atomicUnitsToSellShares(
1486
+ requestedAtomicShares < availableAtomicShares ? requestedAtomicShares : availableAtomicShares
1487
+ ),
1488
+ availableShares: atomicUnitsToSellShares(availableAtomicShares)
1489
+ }));
1490
+ };
1491
+ var buildLiveSellRouteCards = ({
1492
+ labels,
1493
+ smartQuoteData,
1494
+ venueQuotes,
1495
+ eventVenues = [],
1496
+ geoBlockedVenues
1497
+ }) => {
1498
+ var _a;
1499
+ const smartRouteCards = smartQuoteData ? buildLiveRouteCards({
1500
+ labels,
1501
+ quoteData: __spreadProps(__spreadValues({}, smartQuoteData), {
1502
+ venueSoloQuotes: void 0
1503
+ }),
1504
+ tradeSide: "sell",
1505
+ eventVenues,
1506
+ geoBlockedVenues
1507
+ }) : [];
1508
+ const smartRouteVenue = (smartQuoteData == null ? void 0 : smartQuoteData.status) === "ok" && smartQuoteData.fills.length === 1 ? parseVenue((_a = smartQuoteData.fills[0]) == null ? void 0 : _a.venue) : null;
1509
+ const independentVenueCards = /* @__PURE__ */ new Map();
1510
+ for (const venueQuote of venueQuotes) {
1511
+ const quoteData = venueQuote.quoteData;
1512
+ if (!(quoteData == null ? void 0 : quoteData.quoteId) || quoteData.status !== "ok" || quoteData.fills.length === 0 || quoteData.fills.some((fill) => fill.venue !== venueQuote.venue) || (smartRouteVenue == null ? void 0 : smartRouteVenue.success) && smartRouteVenue.data === venueQuote.venue) {
1513
+ continue;
1514
+ }
1515
+ const [venueCard] = buildLiveRouteCards({
1516
+ labels,
1517
+ quoteData: __spreadProps(__spreadValues({}, quoteData), {
1518
+ venueSoloQuotes: void 0
1519
+ }),
1520
+ tradeSide: "sell",
1521
+ geoBlockedVenues
1522
+ });
1523
+ if (!venueCard || venueCard.kind !== "venue" || venueCard.venue !== venueQuote.venue) {
1524
+ continue;
1525
+ }
1526
+ independentVenueCards.set(venueQuote.venue, __spreadProps(__spreadValues({}, venueCard), {
1527
+ id: `live-solo-${venueQuote.venue}`
1528
+ }));
1529
+ }
1530
+ const deduplicatedSmartRouteCards = smartRouteCards.filter(
1531
+ (card) => !card.venue || !independentVenueCards.has(card.venue)
1532
+ );
1533
+ return [...deduplicatedSmartRouteCards, ...independentVenueCards.values()].sort((left, right) => {
1534
+ if (!!left.isUnavailable !== !!right.isUnavailable) {
1535
+ return left.isUnavailable ? 1 : -1;
1536
+ }
1537
+ return right.numericValue - left.numericValue;
1538
+ });
1539
+ };
1457
1540
  var resolveExecutionVenueFromQuote = (quoteData) => {
1458
1541
  if (!(quoteData == null ? void 0 : quoteData.fills.length)) return void 0;
1459
1542
  const dominantFill = [...quoteData.fills].sort((a, b) => b.venueQty - a.venueQty)[0];
@@ -2211,7 +2294,7 @@ var isPercentageBelowMinimum = (value, minimumValue) => {
2211
2294
  };
2212
2295
 
2213
2296
  // src/trading/place-order/index.place-order.failure.tsx
2214
- import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
2297
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
2215
2298
  var resolveFailureActionHandler = ({
2216
2299
  action,
2217
2300
  onDone,
@@ -2224,12 +2307,12 @@ var resolveFailureActionHandler = ({
2224
2307
  };
2225
2308
  var renderPartialFailureStep = (step) => {
2226
2309
  const isWarningStep = step.tone === "warning" || step.tone === "error";
2227
- return /* @__PURE__ */ jsxs2(
2310
+ return /* @__PURE__ */ jsxs3(
2228
2311
  "div",
2229
2312
  {
2230
2313
  className: "flex items-center gap-2 text-agg-sm leading-agg-5 text-agg-foreground",
2231
2314
  children: [
2232
- /* @__PURE__ */ jsx3(
2315
+ /* @__PURE__ */ jsx4(
2233
2316
  Icon,
2234
2317
  {
2235
2318
  name: isWarningStep ? "warning-filled" : "check-circle",
@@ -2238,8 +2321,8 @@ var renderPartialFailureStep = (step) => {
2238
2321
  "aria-hidden": "true"
2239
2322
  }
2240
2323
  ),
2241
- /* @__PURE__ */ jsx3("p", { className: "min-w-0 flex-1", children: step.label }),
2242
- step.venue ? /* @__PURE__ */ jsx3(VenueLogo, { venue: step.venue, size: "small", className: "h-4 w-4 shrink-0" }) : null
2324
+ /* @__PURE__ */ jsx4("p", { className: "min-w-0 flex-1", children: step.label }),
2325
+ step.venue ? /* @__PURE__ */ jsx4(VenueLogo, { venue: step.venue, size: "small", className: "h-4 w-4 shrink-0" }) : null
2243
2326
  ]
2244
2327
  },
2245
2328
  step.id
@@ -2258,10 +2341,10 @@ var PlaceOrderFailureView = ({
2258
2341
  const shouldShowPartialFailureLayout = summary.kind === "partial_fill";
2259
2342
  const failureStepGroups = shouldShowPartialFailureLayout ? groupPlaceOrderFailureSteps(summary.steps) : [];
2260
2343
  if (shouldShowPartialFailureLayout) {
2261
- 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: [
2262
- /* @__PURE__ */ jsxs2("div", { className: "agg-order-failure-header flex flex-col gap-2", children: [
2263
- /* @__PURE__ */ jsxs2("div", { className: "agg-order-failure-market flex items-center gap-3", children: [
2264
- /* @__PURE__ */ jsx3(
2344
+ return /* @__PURE__ */ jsx4(Card, { className: cn("group/agg-order-panel", getPlaceOrderContainerClassName(), className), children: /* @__PURE__ */ jsxs3("div", { className: "agg-order-failure-body flex flex-col gap-6 p-5", children: [
2345
+ /* @__PURE__ */ jsxs3("div", { className: "agg-order-failure-header flex flex-col gap-2", children: [
2346
+ /* @__PURE__ */ jsxs3("div", { className: "agg-order-failure-market flex items-center gap-3", children: [
2347
+ /* @__PURE__ */ jsx4(
2265
2348
  RemoteImage,
2266
2349
  {
2267
2350
  src: (_a = summary.eventImage) != null ? _a : null,
@@ -2269,12 +2352,12 @@ var PlaceOrderFailureView = ({
2269
2352
  className: "h-12 w-12 shrink-0 overflow-hidden rounded-agg-lg object-cover"
2270
2353
  }
2271
2354
  ),
2272
- /* @__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 })
2355
+ /* @__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 })
2273
2356
  ] }),
2274
- summary.eventSubtitle ? /* @__PURE__ */ jsx3("p", { className: "text-agg-base leading-agg-6 text-agg-foreground", children: summary.eventSubtitle }) : null
2357
+ summary.eventSubtitle ? /* @__PURE__ */ jsx4("p", { className: "text-agg-base leading-agg-6 text-agg-foreground", children: summary.eventSubtitle }) : null
2275
2358
  ] }),
2276
- /* @__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}`)) }),
2277
- /* @__PURE__ */ jsx3("div", { className: "flex items-center gap-4", children: summary.actions.map((action) => /* @__PURE__ */ jsx3(
2359
+ /* @__PURE__ */ jsx4("div", { className: "flex flex-col gap-4", children: failureStepGroups.map((group, groupIndex) => /* @__PURE__ */ jsx4("div", { className: "flex flex-col gap-2", children: group.map((step) => renderPartialFailureStep(step)) }, `failure-group-${groupIndex}`)) }),
2360
+ /* @__PURE__ */ jsx4("div", { className: "flex items-center gap-4", children: summary.actions.map((action) => /* @__PURE__ */ jsx4(
2278
2361
  Button,
2279
2362
  {
2280
2363
  variant: "tertiary",
@@ -2288,10 +2371,10 @@ var PlaceOrderFailureView = ({
2288
2371
  )) })
2289
2372
  ] }) });
2290
2373
  }
2291
- 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: [
2292
- /* @__PURE__ */ jsxs2("div", { className: "agg-order-failure-header flex flex-col gap-2", children: [
2293
- /* @__PURE__ */ jsxs2("div", { className: "agg-order-failure-market flex items-center gap-3", children: [
2294
- /* @__PURE__ */ jsx3(
2374
+ return /* @__PURE__ */ jsx4(Card, { className: cn("group/agg-order-panel", getPlaceOrderContainerClassName(), className), children: /* @__PURE__ */ jsxs3("div", { className: "agg-order-failure-body flex flex-col gap-6 p-5", children: [
2375
+ /* @__PURE__ */ jsxs3("div", { className: "agg-order-failure-header flex flex-col gap-2", children: [
2376
+ /* @__PURE__ */ jsxs3("div", { className: "agg-order-failure-market flex items-center gap-3", children: [
2377
+ /* @__PURE__ */ jsx4(
2295
2378
  RemoteImage,
2296
2379
  {
2297
2380
  src: (_b = summary.eventImage) != null ? _b : null,
@@ -2299,11 +2382,11 @@ var PlaceOrderFailureView = ({
2299
2382
  className: "h-12 w-12 shrink-0 overflow-hidden rounded-agg-lg object-cover"
2300
2383
  }
2301
2384
  ),
2302
- /* @__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 })
2385
+ /* @__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 })
2303
2386
  ] }),
2304
- summary.eventSubtitle ? /* @__PURE__ */ jsx3("p", { className: "text-agg-base leading-agg-6 text-agg-foreground", children: summary.eventSubtitle }) : null
2387
+ summary.eventSubtitle ? /* @__PURE__ */ jsx4("p", { className: "text-agg-base leading-agg-6 text-agg-foreground", children: summary.eventSubtitle }) : null
2305
2388
  ] }),
2306
- /* @__PURE__ */ jsx3(
2389
+ /* @__PURE__ */ jsx4(
2307
2390
  InlineAlert,
2308
2391
  {
2309
2392
  tone: "error",
@@ -2312,7 +2395,7 @@ var PlaceOrderFailureView = ({
2312
2395
  message: tradingLabels.orderFailureDescription((_c = summary.errorMessage) != null ? _c : "")
2313
2396
  }
2314
2397
  ),
2315
- /* @__PURE__ */ jsx3("div", { className: "agg-order-failure-actions flex items-center gap-3", children: summary.actions.map((action) => /* @__PURE__ */ jsx3(
2398
+ /* @__PURE__ */ jsx4("div", { className: "agg-order-failure-actions flex items-center gap-3", children: summary.actions.map((action) => /* @__PURE__ */ jsx4(
2316
2399
  Button,
2317
2400
  {
2318
2401
  variant: action.variant === "retry" ? "primary" : "secondary",
@@ -2329,8 +2412,8 @@ var PlaceOrderFailureView = ({
2329
2412
  PlaceOrderFailureView.displayName = "PlaceOrderFailureView";
2330
2413
 
2331
2414
  // src/trading/place-order/index.place-order.success.tsx
2332
- import { useState as useState2 } from "react";
2333
- import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
2415
+ import { useState } from "react";
2416
+ import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
2334
2417
  var resolveBuyToWinLabel = (shares) => {
2335
2418
  if (!shares) return "$0";
2336
2419
  return shares.startsWith("$") ? shares : `$${shares}`;
@@ -2343,7 +2426,7 @@ var PlaceOrderSuccessView = ({
2343
2426
  onShare: _onShare
2344
2427
  }) => {
2345
2428
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2346
- const [isExecutionDetailsExpanded, setIsExecutionDetailsExpanded] = useState2(true);
2429
+ const [isExecutionDetailsExpanded, setIsExecutionDetailsExpanded] = useState(true);
2347
2430
  const doneLabel = tradingLabels.orderDone;
2348
2431
  const _shareLabel = (_a = tradingLabels.orderShare) != null ? _a : "Share";
2349
2432
  const potentialReturnLabel = summary.potentialReturnLabel && tradingLabels.potentialReturnBonus ? tradingLabels.potentialReturnBonus(summary.potentialReturnLabel) : summary.potentialReturnLabel ? `+${summary.potentialReturnLabel} Better Payout` : null;
@@ -2361,10 +2444,10 @@ var PlaceOrderSuccessView = ({
2361
2444
  const resolveStepIconClassName = (tone) => {
2362
2445
  return tone === "warning" || tone === "error" ? "text-agg-warning" : "text-agg-primary";
2363
2446
  };
2364
- 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: [
2365
- summary.eventTitle ? /* @__PURE__ */ jsxs3("div", { className: "agg-order-success-header flex flex-col gap-2", children: [
2366
- /* @__PURE__ */ jsxs3("div", { className: "agg-order-success-market flex items-center gap-3", children: [
2367
- /* @__PURE__ */ jsx4(
2447
+ return /* @__PURE__ */ jsx5(Card, { className: cn("group/agg-order-panel", getPlaceOrderContainerClassName(), className), children: /* @__PURE__ */ jsxs4("div", { className: "agg-order-success-body flex flex-col gap-6 p-5", children: [
2448
+ summary.eventTitle ? /* @__PURE__ */ jsxs4("div", { className: "agg-order-success-header flex flex-col gap-2", children: [
2449
+ /* @__PURE__ */ jsxs4("div", { className: "agg-order-success-market flex items-center gap-3", children: [
2450
+ /* @__PURE__ */ jsx5(
2368
2451
  RemoteImage,
2369
2452
  {
2370
2453
  src: (_h = summary.eventImage) != null ? _h : null,
@@ -2372,12 +2455,12 @@ var PlaceOrderSuccessView = ({
2372
2455
  className: "h-12 w-12 shrink-0 overflow-hidden rounded-agg-lg object-cover"
2373
2456
  }
2374
2457
  ),
2375
- /* @__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 })
2458
+ /* @__PURE__ */ jsx5("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 })
2376
2459
  ] }),
2377
- summary.eventDateLabel ? /* @__PURE__ */ jsx4("p", { className: "text-agg-base leading-agg-6 text-agg-foreground", children: summary.eventDateLabel }) : null
2460
+ summary.eventDateLabel ? /* @__PURE__ */ jsx5("p", { className: "text-agg-base leading-agg-6 text-agg-foreground", children: summary.eventDateLabel }) : null
2378
2461
  ] }) : null,
2379
- executionStepGroups.length > 0 ? /* @__PURE__ */ jsxs3("div", { className: "agg-order-success-timeline flex flex-col gap-2", children: [
2380
- /* @__PURE__ */ jsx4(
2462
+ executionStepGroups.length > 0 ? /* @__PURE__ */ jsxs4("div", { className: "agg-order-success-timeline flex flex-col gap-2", children: [
2463
+ /* @__PURE__ */ jsx5(
2381
2464
  "div",
2382
2465
  {
2383
2466
  "aria-hidden": !isExecutionDetailsExpanded,
@@ -2390,12 +2473,12 @@ var PlaceOrderSuccessView = ({
2390
2473
  "transition-[grid-template-rows,opacity] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"
2391
2474
  )
2392
2475
  ),
2393
- 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(
2476
+ children: /* @__PURE__ */ jsx5("div", { className: "min-h-0", children: /* @__PURE__ */ jsx5("div", { className: "flex flex-col gap-4 pb-2", children: detailedStepGroups.map((group, groupIndex) => /* @__PURE__ */ jsx5("div", { className: "flex flex-col gap-2", children: group.map((step) => /* @__PURE__ */ jsxs4(
2394
2477
  "div",
2395
2478
  {
2396
2479
  className: "flex items-center gap-2 text-agg-sm leading-agg-5 text-agg-foreground",
2397
2480
  children: [
2398
- /* @__PURE__ */ jsx4(
2481
+ /* @__PURE__ */ jsx5(
2399
2482
  Icon,
2400
2483
  {
2401
2484
  name: resolveStepIconName(step.tone),
@@ -2404,8 +2487,8 @@ var PlaceOrderSuccessView = ({
2404
2487
  "aria-hidden": "true"
2405
2488
  }
2406
2489
  ),
2407
- /* @__PURE__ */ jsx4("p", { className: "min-w-0 flex-1", children: step.label }),
2408
- step.venue ? /* @__PURE__ */ jsx4(
2490
+ /* @__PURE__ */ jsx5("p", { className: "min-w-0 flex-1", children: step.label }),
2491
+ step.venue ? /* @__PURE__ */ jsx5(
2409
2492
  VenueLogo,
2410
2493
  {
2411
2494
  venue: step.venue,
@@ -2419,7 +2502,7 @@ var PlaceOrderSuccessView = ({
2419
2502
  )) }, `execution-group-${groupIndex}`)) }) })
2420
2503
  }
2421
2504
  ),
2422
- finalStep ? hasExecutionDetails ? /* @__PURE__ */ jsxs3(
2505
+ finalStep ? hasExecutionDetails ? /* @__PURE__ */ jsxs4(
2423
2506
  "button",
2424
2507
  {
2425
2508
  type: "button",
@@ -2431,7 +2514,7 @@ var PlaceOrderSuccessView = ({
2431
2514
  ),
2432
2515
  onClick: () => setIsExecutionDetailsExpanded((currentValue) => !currentValue),
2433
2516
  children: [
2434
- /* @__PURE__ */ jsx4(
2517
+ /* @__PURE__ */ jsx5(
2435
2518
  Icon,
2436
2519
  {
2437
2520
  name: resolveStepIconName(finalStep.tone),
@@ -2440,8 +2523,8 @@ var PlaceOrderSuccessView = ({
2440
2523
  "aria-hidden": "true"
2441
2524
  }
2442
2525
  ),
2443
- /* @__PURE__ */ jsx4("p", { className: "min-w-0 flex-1", children: finalStep.label }),
2444
- /* @__PURE__ */ jsx4(
2526
+ /* @__PURE__ */ jsx5("p", { className: "min-w-0 flex-1", children: finalStep.label }),
2527
+ /* @__PURE__ */ jsx5(
2445
2528
  Icon,
2446
2529
  {
2447
2530
  name: isExecutionDetailsExpanded ? "chevron-up" : "chevron-down",
@@ -2452,8 +2535,8 @@ var PlaceOrderSuccessView = ({
2452
2535
  )
2453
2536
  ]
2454
2537
  }
2455
- ) : /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2 text-agg-sm leading-agg-5 text-agg-foreground", children: [
2456
- /* @__PURE__ */ jsx4(
2538
+ ) : /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-2 text-agg-sm leading-agg-5 text-agg-foreground", children: [
2539
+ /* @__PURE__ */ jsx5(
2457
2540
  Icon,
2458
2541
  {
2459
2542
  name: resolveStepIconName(finalStep.tone),
@@ -2462,34 +2545,34 @@ var PlaceOrderSuccessView = ({
2462
2545
  "aria-hidden": "true"
2463
2546
  }
2464
2547
  ),
2465
- /* @__PURE__ */ jsx4("p", { className: "min-w-0 flex-1", children: finalStep.label })
2548
+ /* @__PURE__ */ jsx5("p", { className: "min-w-0 flex-1", children: finalStep.label })
2466
2549
  ] }) : null
2467
2550
  ] }) : null,
2468
- /* @__PURE__ */ jsxs3(
2551
+ /* @__PURE__ */ jsxs4(
2469
2552
  "div",
2470
2553
  {
2471
2554
  className: cn(
2472
2555
  "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"
2473
2556
  ),
2474
2557
  children: [
2475
- /* @__PURE__ */ jsx4(Icon, { name: "success-check", size: "small", className: "h-4 w-4 shrink-0 text-current" }),
2476
- /* @__PURE__ */ jsx4("span", { children: resolvedActionLabel })
2558
+ /* @__PURE__ */ jsx5(Icon, { name: "success-check", size: "small", className: "h-4 w-4 shrink-0 text-current" }),
2559
+ /* @__PURE__ */ jsx5("span", { children: resolvedActionLabel })
2477
2560
  ]
2478
2561
  }
2479
2562
  ),
2480
- /* @__PURE__ */ jsxs3("div", { className: "agg-order-success-summary flex items-center justify-between gap-4", children: [
2481
- /* @__PURE__ */ jsx4("p", { className: "text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: tradingLabels.amount(resolvedTradeSide) }),
2482
- /* @__PURE__ */ jsx4("p", { className: "text-right text-[30px] font-agg-bold leading-[36px] text-agg-foreground", children: resolvedAmountLabel })
2563
+ /* @__PURE__ */ jsxs4("div", { className: "agg-order-success-summary flex items-center justify-between gap-4", children: [
2564
+ /* @__PURE__ */ jsx5("p", { className: "text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: tradingLabels.amount(resolvedTradeSide) }),
2565
+ /* @__PURE__ */ jsx5("p", { className: "text-right text-[30px] font-agg-bold leading-[36px] text-agg-foreground", children: resolvedAmountLabel })
2483
2566
  ] }),
2484
- /* @__PURE__ */ jsxs3("div", { className: "agg-order-success-summary flex items-center justify-between gap-4", children: [
2485
- /* @__PURE__ */ jsx4("p", { className: "text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: tradingLabels.toWin(resolvedTradeSide) }),
2486
- /* @__PURE__ */ jsx4("p", { className: "text-right text-[30px] font-agg-bold leading-[36px] text-agg-success", children: resolvedToWinLabel })
2567
+ /* @__PURE__ */ jsxs4("div", { className: "agg-order-success-summary flex items-center justify-between gap-4", children: [
2568
+ /* @__PURE__ */ jsx5("p", { className: "text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: tradingLabels.toWin(resolvedTradeSide) }),
2569
+ /* @__PURE__ */ jsx5("p", { className: "text-right text-[30px] font-agg-bold leading-[36px] text-agg-success", children: resolvedToWinLabel })
2487
2570
  ] }),
2488
- 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: [
2489
- /* @__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 }),
2490
- /* @__PURE__ */ jsx4("p", { className: "text-agg-xs leading-agg-4 text-agg-foreground", children: (_i = tradingLabels.withSmartRouting) != null ? _i : "with Smart Routing" })
2571
+ summary.potentialReturnLabel ? /* @__PURE__ */ jsxs4("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: [
2572
+ /* @__PURE__ */ jsx5("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 }),
2573
+ /* @__PURE__ */ jsx5("p", { className: "text-agg-xs leading-agg-4 text-agg-foreground", children: (_i = tradingLabels.withSmartRouting) != null ? _i : "with Smart Routing" })
2491
2574
  ] }) : null,
2492
- /* @__PURE__ */ jsx4("div", { className: "agg-order-success-actions flex gap-3", children: /* @__PURE__ */ jsx4(
2575
+ /* @__PURE__ */ jsx5("div", { className: "agg-order-success-actions flex gap-3", children: /* @__PURE__ */ jsx5(
2493
2576
  Button,
2494
2577
  {
2495
2578
  variant: "secondary",
@@ -2505,13 +2588,22 @@ var PlaceOrderSuccessView = ({
2505
2588
  PlaceOrderSuccessView.displayName = "PlaceOrderSuccessView";
2506
2589
 
2507
2590
  // src/trading/place-order/index.tsx
2508
- import { Fragment as Fragment3, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
2591
+ import { Fragment as Fragment3, jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
2509
2592
  var SELL_SHARE_INPUT_DECIMALS = 6;
2510
2593
  var SELL_SHARE_DISPLAY_DECIMALS = 2;
2511
2594
  var floorToDecimals = (value, decimals) => {
2512
2595
  if (!Number.isFinite(value) || value <= 0) return 0;
2513
- const scale = __pow(10, decimals);
2514
- return Math.trunc(value * scale) / scale;
2596
+ const [coefficient = "0", exponentText = "0"] = value.toString().toLowerCase().split("e");
2597
+ const [whole = "0", fraction = ""] = coefficient.split(".");
2598
+ const exponent = Number(exponentText);
2599
+ const digits = `${whole}${fraction}`;
2600
+ const decimalIndex = whole.length + exponent;
2601
+ const normalized = decimalIndex <= 0 ? `0.${"0".repeat(-decimalIndex)}${digits}` : decimalIndex >= digits.length ? `${digits}${"0".repeat(decimalIndex - digits.length)}` : `${digits.slice(0, decimalIndex)}.${digits.slice(decimalIndex)}`;
2602
+ const [normalizedWhole = "0", normalizedFraction = ""] = normalized.split(".");
2603
+ const truncatedFraction = normalizedFraction.slice(0, decimals);
2604
+ return Number(
2605
+ truncatedFraction.length > 0 ? `${normalizedWhole}.${truncatedFraction}` : normalizedWhole
2606
+ );
2515
2607
  };
2516
2608
  var formatFlooredShareAmount = (value, decimals) => {
2517
2609
  const flooredValue = floorToDecimals(value, decimals);
@@ -2522,6 +2614,86 @@ var formatFlooredShareAmount = (value, decimals) => {
2522
2614
  });
2523
2615
  return formattedValue.replace(/(\.\d*?[1-9])0+$/u, "$1").replace(/\.0+$/u, "");
2524
2616
  };
2617
+ var resolvePlaceOrderPortalContainer = (triggerElement) => {
2618
+ var _a;
2619
+ return (_a = triggerElement == null ? void 0 : triggerElement.closest(".agg-modal-center")) != null ? _a : void 0;
2620
+ };
2621
+ var LIMIT_EXPIRATION_OPTION_COUNT = 5;
2622
+ dayjs.extend(utc);
2623
+ dayjs.extend(timezone);
2624
+ var LIMIT_ORDER_RAW_SCALE = BigInt(1e6);
2625
+ var LIMIT_PRICE_STEP = 1e-3;
2626
+ var LIMIT_PRICE_MIN = 1e-3;
2627
+ var LIMIT_PRICE_MAX = 0.999;
2628
+ var ceilDiv = (numerator, denominator) => {
2629
+ return (numerator + denominator - BigInt(1)) / denominator;
2630
+ };
2631
+ var toRaw6 = (value) => {
2632
+ const normalizedValue = Number.isFinite(value) ? Math.max(0, value) : 0;
2633
+ return Math.ceil(normalizedValue * Number(LIMIT_ORDER_RAW_SCALE)).toString();
2634
+ };
2635
+ var toLimitPriceRaw = (value) => {
2636
+ const clampedValue = Math.min(LIMIT_PRICE_MAX, Math.max(LIMIT_PRICE_MIN, value));
2637
+ return Math.round(clampedValue * Number(LIMIT_ORDER_RAW_SCALE)).toString();
2638
+ };
2639
+ var toLimitSizeRaw = ({
2640
+ amount,
2641
+ limitPriceRaw,
2642
+ side
2643
+ }) => {
2644
+ if (side === "sell") return toRaw6(amount);
2645
+ const spendRaw = BigInt(toRaw6(amount));
2646
+ const priceRaw = BigInt(limitPriceRaw);
2647
+ return ceilDiv(spendRaw * LIMIT_ORDER_RAW_SCALE, priceRaw).toString();
2648
+ };
2649
+ var formatLimitPriceLabel = (value) => {
2650
+ return `${(value * 100).toLocaleString("en-US", {
2651
+ minimumFractionDigits: 1,
2652
+ maximumFractionDigits: 1
2653
+ })}\xA2`;
2654
+ };
2655
+ var normalizeLimitPrice = (value) => {
2656
+ if (!Number.isFinite(value)) return LIMIT_PRICE_MIN;
2657
+ return Math.min(LIMIT_PRICE_MAX, Math.max(LIMIT_PRICE_MIN, Number(value.toFixed(3))));
2658
+ };
2659
+ var formatLimitPriceInputValue = (value) => {
2660
+ return (value * 100).toLocaleString("en-US", {
2661
+ minimumFractionDigits: 1,
2662
+ maximumFractionDigits: 1
2663
+ });
2664
+ };
2665
+ var parseLimitPriceInputValue = (value) => {
2666
+ const normalizedValue = value.replace(/¢/g, "").trim();
2667
+ if (!normalizedValue) return null;
2668
+ const parsedValue = Number(normalizedValue);
2669
+ if (!Number.isFinite(parsedValue)) return null;
2670
+ if (parsedValue <= 0 || parsedValue >= 100) return null;
2671
+ return parsedValue / 100;
2672
+ };
2673
+ var resolveEndOfDayEastern = () => {
2674
+ const easternEndOfDay = dayjs().tz("America/New_York").endOf("day");
2675
+ return easternEndOfDay.isAfter(dayjs()) ? easternEndOfDay.toDate() : easternEndOfDay.add(1, "day").toDate();
2676
+ };
2677
+ var resolveLimitExpirationDate = ({
2678
+ expirationType,
2679
+ customDate,
2680
+ customTime
2681
+ }) => {
2682
+ if (expirationType === "GTC") return void 0;
2683
+ if (expirationType === "FIVE_MINUTES") return dayjs().add(5, "minute").toDate();
2684
+ if (expirationType === "ONE_HOUR") return dayjs().add(1, "hour").toDate();
2685
+ if (expirationType === "END_OF_DAY") return resolveEndOfDayEastern();
2686
+ if (!customDate) return void 0;
2687
+ return dayjs(customDate).hour(Number(customTime.slice(0, 2))).minute(Number(customTime.slice(3, 5))).second(0).millisecond(0).toDate();
2688
+ };
2689
+ var serializeLimitOrderExpiration = (expirationDate) => {
2690
+ return dayjs(expirationDate).utc().format("YYYY-MM-DDTHH:mm:ss[Z]");
2691
+ };
2692
+ var isFutureLimitExpiration = (expirationDate) => {
2693
+ if (!expirationDate) return false;
2694
+ const parsedExpirationDate = dayjs(expirationDate);
2695
+ return parsedExpirationDate.isValid() && parsedExpirationDate.isAfter(dayjs());
2696
+ };
2525
2697
  var resolveRefetchedQuoteData = (result) => {
2526
2698
  if (!result || typeof result !== "object" || !("data" in result)) return null;
2527
2699
  const data = result.data;
@@ -2540,7 +2712,7 @@ var LoadingGlyph = ({
2540
2712
  className,
2541
2713
  enableAnimations
2542
2714
  }) => {
2543
- return /* @__PURE__ */ jsx5(
2715
+ return /* @__PURE__ */ jsx6(
2544
2716
  "span",
2545
2717
  {
2546
2718
  "aria-hidden": "true",
@@ -2560,25 +2732,25 @@ var PlaceOrderSlippageControl = ({
2560
2732
  minimumValue: slippageMinimumValue
2561
2733
  }) => {
2562
2734
  var _a, _b;
2563
- const labels = useLabels();
2564
- const containerRef = useRef3(null);
2565
- const triggerRef = useRef3(null);
2566
- const inputRef = useRef3(null);
2735
+ const labels = useLabels2();
2736
+ const containerRef = useRef2(null);
2737
+ const triggerRef = useRef2(null);
2738
+ const inputRef = useRef2(null);
2567
2739
  const warningId = useId();
2568
2740
  const defaultValue = finalizePercentageValue(slippageDefaultValue);
2569
2741
  const committedValue = finalizePercentageValue(slippageValue) || defaultValue;
2570
- const [draftValue, setDraftValue] = useState3(committedValue);
2571
- const [isEditing, setIsEditing] = useState3(
2742
+ const [draftValue, setDraftValue] = useState2(committedValue);
2743
+ const [isEditing, setIsEditing] = useState2(
2572
2744
  () => isPercentageBelowMinimum(committedValue, slippageMinimumValue)
2573
2745
  );
2574
- const [shouldFocusInput, setShouldFocusInput] = useState3(false);
2575
- useEffect3(() => {
2746
+ const [shouldFocusInput, setShouldFocusInput] = useState2(false);
2747
+ useEffect2(() => {
2576
2748
  setDraftValue(committedValue);
2577
2749
  if (isPercentageBelowMinimum(committedValue, slippageMinimumValue)) {
2578
2750
  setIsEditing(true);
2579
2751
  }
2580
2752
  }, [committedValue, slippageMinimumValue]);
2581
- useEffect3(() => {
2753
+ useEffect2(() => {
2582
2754
  if (!shouldFocusInput) return;
2583
2755
  requestAnimationFrame(() => {
2584
2756
  var _a2, _b2;
@@ -2595,7 +2767,7 @@ var PlaceOrderSlippageControl = ({
2595
2767
  Number(committedValue || slippageDefaultValue || DEFAULT_SLIPPAGE_VALUE)
2596
2768
  );
2597
2769
  const resolvedAutoLabel = labels.trading.resetSlippage;
2598
- const resolvedWarningMessage = useMemo2(() => {
2770
+ const resolvedWarningMessage = useMemo(() => {
2599
2771
  if (isLowSlippage) {
2600
2772
  return labels.trading.slippageLow(slippageMinimumValue);
2601
2773
  }
@@ -2658,8 +2830,8 @@ var PlaceOrderSlippageControl = ({
2658
2830
  if (!isEditing) return;
2659
2831
  handleCommitDraft(false);
2660
2832
  };
2661
- return /* @__PURE__ */ jsxs4("div", { ref: containerRef, className: "agg-slippage-control w-full", onBlur: handleContainerBlur, children: [
2662
- /* @__PURE__ */ jsxs4(
2833
+ return /* @__PURE__ */ jsxs5("div", { ref: containerRef, className: "agg-slippage-control w-full", onBlur: handleContainerBlur, children: [
2834
+ /* @__PURE__ */ jsxs5(
2663
2835
  "button",
2664
2836
  {
2665
2837
  ref: triggerRef,
@@ -2677,8 +2849,8 @@ var PlaceOrderSlippageControl = ({
2677
2849
  ),
2678
2850
  onClick: handleToggleEditing,
2679
2851
  children: [
2680
- /* @__PURE__ */ jsx5("span", { className: "agg-slippage-label", children: collapsedLabel }),
2681
- /* @__PURE__ */ jsx5(
2852
+ /* @__PURE__ */ jsx6("span", { className: "agg-slippage-label", children: collapsedLabel }),
2853
+ /* @__PURE__ */ jsx6(
2682
2854
  Icon,
2683
2855
  {
2684
2856
  name: isEditing ? "chevron-up" : "pencil",
@@ -2690,7 +2862,7 @@ var PlaceOrderSlippageControl = ({
2690
2862
  ]
2691
2863
  }
2692
2864
  ),
2693
- /* @__PURE__ */ jsx5(
2865
+ /* @__PURE__ */ jsx6(
2694
2866
  "div",
2695
2867
  {
2696
2868
  "aria-hidden": !isEditing,
@@ -2704,10 +2876,10 @@ var PlaceOrderSlippageControl = ({
2704
2876
  "transition-[grid-template-rows,opacity,margin-top] duration-300 ease-[cubic-bezier(0.22,1,0.36,1)]"
2705
2877
  )
2706
2878
  ),
2707
- children: /* @__PURE__ */ jsx5("div", { className: "min-h-0", children: /* @__PURE__ */ jsxs4("div", { className: "agg-slippage-editor-body flex flex-col gap-2", children: [
2708
- /* @__PURE__ */ jsxs4("div", { className: "agg-slippage-input-row flex h-9 overflow-hidden rounded-agg-sm border border-agg-separator", children: [
2709
- /* @__PURE__ */ jsxs4("div", { className: "agg-slippage-input-group flex min-w-0 flex-1 items-center gap-2 bg-agg-secondary px-3", children: [
2710
- /* @__PURE__ */ jsx5(
2879
+ children: /* @__PURE__ */ jsx6("div", { className: "min-h-0", children: /* @__PURE__ */ jsxs5("div", { className: "agg-slippage-editor-body flex flex-col gap-2", children: [
2880
+ /* @__PURE__ */ jsxs5("div", { className: "agg-slippage-input-row flex h-9 overflow-hidden rounded-agg-sm border border-agg-separator", children: [
2881
+ /* @__PURE__ */ jsxs5("div", { className: "agg-slippage-input-group flex min-w-0 flex-1 items-center gap-2 bg-agg-secondary px-3", children: [
2882
+ /* @__PURE__ */ jsx6(
2711
2883
  "input",
2712
2884
  {
2713
2885
  ref: inputRef,
@@ -2722,7 +2894,7 @@ var PlaceOrderSlippageControl = ({
2722
2894
  onKeyDown: handleInputKeyDown
2723
2895
  }
2724
2896
  ),
2725
- /* @__PURE__ */ jsx5(
2897
+ /* @__PURE__ */ jsx6(
2726
2898
  "button",
2727
2899
  {
2728
2900
  type: "button",
@@ -2740,8 +2912,8 @@ var PlaceOrderSlippageControl = ({
2740
2912
  }
2741
2913
  )
2742
2914
  ] }),
2743
- /* @__PURE__ */ jsx5("div", { className: "h-full w-px bg-agg-separator", "aria-hidden": "true" }),
2744
- /* @__PURE__ */ jsx5(
2915
+ /* @__PURE__ */ jsx6("div", { className: "h-full w-px bg-agg-separator", "aria-hidden": "true" }),
2916
+ /* @__PURE__ */ jsx6(
2745
2917
  "div",
2746
2918
  {
2747
2919
  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",
@@ -2750,7 +2922,7 @@ var PlaceOrderSlippageControl = ({
2750
2922
  }
2751
2923
  )
2752
2924
  ] }),
2753
- /* @__PURE__ */ jsx5(
2925
+ /* @__PURE__ */ jsx6(
2754
2926
  "div",
2755
2927
  {
2756
2928
  "aria-hidden": !resolvedWarningMessage,
@@ -2764,13 +2936,13 @@ var PlaceOrderSlippageControl = ({
2764
2936
  "transition-[grid-template-rows,opacity] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"
2765
2937
  )
2766
2938
  ),
2767
- children: /* @__PURE__ */ jsx5("div", { className: "min-h-0", children: /* @__PURE__ */ jsxs4(
2939
+ children: /* @__PURE__ */ jsx6("div", { className: "min-h-0", children: /* @__PURE__ */ jsxs5(
2768
2940
  "div",
2769
2941
  {
2770
2942
  id: warningId,
2771
2943
  className: "agg-slippage-warning-message flex items-start gap-2 text-agg-sm leading-agg-5 text-agg-foreground",
2772
2944
  children: [
2773
- /* @__PURE__ */ jsx5(
2945
+ /* @__PURE__ */ jsx6(
2774
2946
  Icon,
2775
2947
  {
2776
2948
  name: "warning-filled",
@@ -2779,7 +2951,7 @@ var PlaceOrderSlippageControl = ({
2779
2951
  color: "currentColor"
2780
2952
  }
2781
2953
  ),
2782
- /* @__PURE__ */ jsx5("p", { children: resolvedWarningMessage != null ? resolvedWarningMessage : "" })
2954
+ /* @__PURE__ */ jsx6("p", { children: resolvedWarningMessage != null ? resolvedWarningMessage : "" })
2783
2955
  ]
2784
2956
  }
2785
2957
  ) })
@@ -2799,9 +2971,9 @@ var renderCardHeader = ({
2799
2971
  onClose
2800
2972
  }) => {
2801
2973
  if (!headerTitle) return null;
2802
- return /* @__PURE__ */ jsxs4("div", { className: cn("agg-order-panel-header flex flex-col gap-2", className), children: [
2803
- /* @__PURE__ */ jsxs4("div", { className: "agg-order-market-summary flex items-center gap-3", children: [
2804
- /* @__PURE__ */ jsx5(
2974
+ return /* @__PURE__ */ jsxs5("div", { className: cn("agg-order-panel-header flex flex-col gap-2", className), children: [
2975
+ /* @__PURE__ */ jsxs5("div", { className: "agg-order-market-summary flex items-center gap-3", children: [
2976
+ /* @__PURE__ */ jsx6(
2805
2977
  RemoteImage,
2806
2978
  {
2807
2979
  src: headerImage,
@@ -2809,19 +2981,19 @@ var renderCardHeader = ({
2809
2981
  className: "agg-order-market-image h-12 w-12 shrink-0 overflow-hidden rounded-agg-lg object-cover"
2810
2982
  }
2811
2983
  ),
2812
- /* @__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 }),
2813
- onClose ? /* @__PURE__ */ jsx5(
2984
+ /* @__PURE__ */ jsx6("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 }),
2985
+ onClose ? /* @__PURE__ */ jsx6(
2814
2986
  "button",
2815
2987
  {
2816
2988
  type: "button",
2817
2989
  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",
2818
2990
  "aria-label": "Close",
2819
2991
  onClick: onClose,
2820
- children: /* @__PURE__ */ jsx5(CloseIcon, { className: "h-5 w-5" })
2992
+ children: /* @__PURE__ */ jsx6(CloseIcon, { className: "h-5 w-5" })
2821
2993
  }
2822
2994
  ) : null
2823
2995
  ] }),
2824
- headerSubtitle ? /* @__PURE__ */ jsx5("p", { className: "agg-order-market-subtitle text-agg-base leading-agg-6 text-agg-foreground", children: headerSubtitle }) : null
2996
+ headerSubtitle ? /* @__PURE__ */ jsx6("p", { className: "agg-order-market-subtitle text-agg-base leading-agg-6 text-agg-foreground", children: headerSubtitle }) : null
2825
2997
  ] });
2826
2998
  };
2827
2999
  var PlaceOrderResolvedView = ({
@@ -2833,7 +3005,7 @@ var PlaceOrderResolvedView = ({
2833
3005
  isSportsEvent = false
2834
3006
  }) => {
2835
3007
  var _a, _b;
2836
- const labels = useLabels();
3008
+ const labels = useLabels2();
2837
3009
  const tradingLabels = labels.trading;
2838
3010
  const resolvingTimestamp = (_a = resolutionTimestamp != null ? resolutionTimestamp : tradingState.resolvesAt) != null ? _a : tradingState.endsAt;
2839
3011
  const isResolvingMarket = false;
@@ -2842,7 +3014,7 @@ var PlaceOrderResolvedView = ({
2842
3014
  return endDateLabel ? `${tradingState.market.question} \xB7 ${endDateLabel}` : tradingState.market.question;
2843
3015
  })() : "";
2844
3016
  if (isResolvingMarket) {
2845
- return /* @__PURE__ */ jsx5(
3017
+ return /* @__PURE__ */ jsx6(
2846
3018
  Card,
2847
3019
  {
2848
3020
  className: cn(
@@ -2853,7 +3025,7 @@ var PlaceOrderResolvedView = ({
2853
3025
  ),
2854
3026
  role: "status",
2855
3027
  "aria-label": labels.marketDetails.resolvingTitle,
2856
- children: /* @__PURE__ */ jsxs4(
3028
+ children: /* @__PURE__ */ jsxs5(
2857
3029
  "div",
2858
3030
  {
2859
3031
  className: cn(
@@ -2861,12 +3033,12 @@ var PlaceOrderResolvedView = ({
2861
3033
  classNames == null ? void 0 : classNames.body
2862
3034
  ),
2863
3035
  children: [
2864
- /* @__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" }) }),
2865
- /* @__PURE__ */ jsxs4("div", { className: cn("flex w-full flex-col items-center gap-1", classNames == null ? void 0 : classNames.content), children: [
2866
- /* @__PURE__ */ jsx5(Typography, { variant: "body-large-strong", children: labels.marketDetails.resolvingTitle }),
2867
- resolvingSubtitle ? /* @__PURE__ */ jsx5(Typography, { variant: "body", className: "text-center", children: resolvingSubtitle }) : null
3036
+ /* @__PURE__ */ jsx6("div", { className: "flex h-[60px] w-[60px] items-center justify-center rounded-full bg-agg-primary/10", children: /* @__PURE__ */ jsx6(LoadingIcon, { variant: "prominent" }) }),
3037
+ /* @__PURE__ */ jsxs5("div", { className: cn("flex w-full flex-col items-center gap-1", classNames == null ? void 0 : classNames.content), children: [
3038
+ /* @__PURE__ */ jsx6(Typography, { variant: "body-large-strong", children: labels.marketDetails.resolvingTitle }),
3039
+ resolvingSubtitle ? /* @__PURE__ */ jsx6(Typography, { variant: "body", className: "text-center", children: resolvingSubtitle }) : null
2868
3040
  ] }),
2869
- /* @__PURE__ */ jsx5(
3041
+ /* @__PURE__ */ jsx6(
2870
3042
  Typography,
2871
3043
  {
2872
3044
  variant: "label",
@@ -2880,7 +3052,7 @@ var PlaceOrderResolvedView = ({
2880
3052
  }
2881
3053
  );
2882
3054
  }
2883
- return /* @__PURE__ */ jsx5(
3055
+ return /* @__PURE__ */ jsx6(
2884
3056
  Card,
2885
3057
  {
2886
3058
  className: cn(
@@ -2889,19 +3061,19 @@ var PlaceOrderResolvedView = ({
2889
3061
  classNames == null ? void 0 : classNames.root,
2890
3062
  className
2891
3063
  ),
2892
- children: /* @__PURE__ */ jsxs4("div", { className: cn("agg-order-panel-body flex flex-col", classNames == null ? void 0 : classNames.body), children: [
2893
- /* @__PURE__ */ jsxs4("div", { className: "flex flex-col items-center gap-6 p-8", children: [
2894
- /* @__PURE__ */ jsx5(
3064
+ children: /* @__PURE__ */ jsxs5("div", { className: cn("agg-order-panel-body flex flex-col", classNames == null ? void 0 : classNames.body), children: [
3065
+ /* @__PURE__ */ jsxs5("div", { className: "flex flex-col items-center gap-6 p-8", children: [
3066
+ /* @__PURE__ */ jsx6(
2895
3067
  "div",
2896
3068
  {
2897
3069
  className: cn(
2898
3070
  "flex h-15 w-15 items-center justify-center rounded-full",
2899
3071
  "bg-agg-primary/15"
2900
3072
  ),
2901
- children: /* @__PURE__ */ jsx5(Icon, { name: "success-check", className: cn("h-6 w-6", "text-agg-primary") })
3073
+ children: /* @__PURE__ */ jsx6(Icon, { name: "success-check", className: cn("h-6 w-6", "text-agg-primary") })
2902
3074
  }
2903
3075
  ),
2904
- /* @__PURE__ */ jsxs4(
3076
+ /* @__PURE__ */ jsxs5(
2905
3077
  "div",
2906
3078
  {
2907
3079
  className: cn(
@@ -2909,8 +3081,8 @@ var PlaceOrderResolvedView = ({
2909
3081
  classNames == null ? void 0 : classNames.content
2910
3082
  ),
2911
3083
  children: [
2912
- tradingState.market ? /* @__PURE__ */ jsx5(Typography, { variant: "body", className: "text-center", children: tradingState.market.question }) : null,
2913
- tradingState.winningOutcome ? /* @__PURE__ */ jsx5(Typography, { variant: "body-large-strong", children: tradingLabels.outcome(
3084
+ tradingState.market ? /* @__PURE__ */ jsx6(Typography, { variant: "body", className: "text-center", children: tradingState.market.question }) : null,
3085
+ tradingState.winningOutcome ? /* @__PURE__ */ jsx6(Typography, { variant: "body-large-strong", children: tradingLabels.outcome(
2914
3086
  shouldUseRawResolvedPlaceOrderOutcomeLabel(
2915
3087
  tradingState.market,
2916
3088
  tradingState.winningOutcome
@@ -2924,25 +3096,25 @@ var PlaceOrderResolvedView = ({
2924
3096
  }
2925
3097
  )
2926
3098
  ] }),
2927
- resolvedClaim ? /* @__PURE__ */ jsxs4(Fragment3, { children: [
2928
- /* @__PURE__ */ jsx5("div", { className: "h-px w-full bg-agg-separator" }),
2929
- /* @__PURE__ */ jsxs4("div", { className: "flex w-full flex-col gap-5 p-6", children: [
2930
- /* @__PURE__ */ jsx5(Typography, { variant: "body-strong", className: "text-center", children: tradingLabels.resolvedEarningsTitle }),
2931
- /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-3 text-agg-sm leading-agg-5 text-agg-foreground", children: [
2932
- resolvedClaim.resolutionDateLabel ? /* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between gap-4", children: [
2933
- /* @__PURE__ */ jsx5("span", { children: tradingLabels.resolvedResolutionDateLabel }),
2934
- /* @__PURE__ */ jsx5("span", { className: "font-agg-bold", children: resolvedClaim.resolutionDateLabel })
3099
+ resolvedClaim ? /* @__PURE__ */ jsxs5(Fragment3, { children: [
3100
+ /* @__PURE__ */ jsx6("div", { className: "h-px w-full bg-agg-separator" }),
3101
+ /* @__PURE__ */ jsxs5("div", { className: "flex w-full flex-col gap-5 p-6", children: [
3102
+ /* @__PURE__ */ jsx6(Typography, { variant: "body-strong", className: "text-center", children: tradingLabels.resolvedEarningsTitle }),
3103
+ /* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-3 text-agg-sm leading-agg-5 text-agg-foreground", children: [
3104
+ resolvedClaim.resolutionDateLabel ? /* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-between gap-4", children: [
3105
+ /* @__PURE__ */ jsx6("span", { children: tradingLabels.resolvedResolutionDateLabel }),
3106
+ /* @__PURE__ */ jsx6("span", { className: "font-agg-bold", children: resolvedClaim.resolutionDateLabel })
2935
3107
  ] }) : null,
2936
- /* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between gap-4", children: [
2937
- /* @__PURE__ */ jsx5("span", { children: tradingLabels.resolvedSharesLabel }),
2938
- /* @__PURE__ */ jsx5("span", { className: "font-agg-bold", children: resolvedClaim.sharesLabel })
3108
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-between gap-4", children: [
3109
+ /* @__PURE__ */ jsx6("span", { children: tradingLabels.resolvedSharesLabel }),
3110
+ /* @__PURE__ */ jsx6("span", { className: "font-agg-bold", children: resolvedClaim.sharesLabel })
2939
3111
  ] }),
2940
- /* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between gap-4", children: [
2941
- /* @__PURE__ */ jsx5("span", { children: tradingLabels.resolvedTotalPayoutLabel }),
2942
- /* @__PURE__ */ jsx5("span", { className: "font-agg-bold", children: resolvedClaim.totalPayoutLabel })
3112
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-between gap-4", children: [
3113
+ /* @__PURE__ */ jsx6("span", { children: tradingLabels.resolvedTotalPayoutLabel }),
3114
+ /* @__PURE__ */ jsx6("span", { className: "font-agg-bold", children: resolvedClaim.totalPayoutLabel })
2943
3115
  ] })
2944
3116
  ] }),
2945
- resolvedClaim.onClaim ? /* @__PURE__ */ jsx5(
3117
+ resolvedClaim.onClaim ? /* @__PURE__ */ jsx6(
2946
3118
  Button,
2947
3119
  {
2948
3120
  size: "large",
@@ -2963,18 +3135,18 @@ var renderRouteBreakdownRow = (row) => {
2963
3135
  var _a, _b;
2964
3136
  const venueLabel = getTradingVenueLabel(row.venue);
2965
3137
  const rowKey = `${row.venue}-${row.label}-${row.priceLabel}-${(_a = row.resultLabel) != null ? _a : ""}`;
2966
- return /* @__PURE__ */ jsxs4(
3138
+ return /* @__PURE__ */ jsxs5(
2967
3139
  "div",
2968
3140
  {
2969
3141
  className: "agg-route-breakdown-row flex items-center justify-between gap-4 text-left",
2970
3142
  children: [
2971
- /* @__PURE__ */ jsxs4("div", { className: "agg-route-breakdown-market flex min-w-0 items-center gap-2", children: [
2972
- /* @__PURE__ */ jsx5(VenueLogo, { venue: row.venue, className: "size-3!", ariaLabel: venueLabel }),
2973
- /* @__PURE__ */ jsx5("p", { className: "agg-route-breakdown-label truncate text-agg-sm leading-agg-5 text-agg-foreground", children: row.label })
3143
+ /* @__PURE__ */ jsxs5("div", { className: "agg-route-breakdown-market flex min-w-0 items-center gap-2", children: [
3144
+ /* @__PURE__ */ jsx6(VenueLogo, { venue: row.venue, className: "size-3!", ariaLabel: venueLabel }),
3145
+ /* @__PURE__ */ jsx6("p", { className: "agg-route-breakdown-label truncate text-agg-sm leading-agg-5 text-agg-foreground", children: row.label })
2974
3146
  ] }),
2975
- /* @__PURE__ */ jsxs4("div", { className: "agg-route-breakdown-value flex shrink-0 items-center gap-2 text-agg-sm leading-agg-5", children: [
2976
- /* @__PURE__ */ jsx5("p", { className: "text-agg-muted-foreground", children: row.priceLabel }),
2977
- /* @__PURE__ */ jsx5("p", { className: "text-agg-foreground", children: (_b = row.resultLabel) != null ? _b : "" })
3147
+ /* @__PURE__ */ jsxs5("div", { className: "agg-route-breakdown-value flex shrink-0 items-center gap-2 text-agg-sm leading-agg-5", children: [
3148
+ /* @__PURE__ */ jsx6("p", { className: "text-agg-muted-foreground", children: row.priceLabel }),
3149
+ /* @__PURE__ */ jsx6("p", { className: "text-agg-foreground", children: (_b = row.resultLabel) != null ? _b : "" })
2978
3150
  ] })
2979
3151
  ]
2980
3152
  },
@@ -3002,7 +3174,7 @@ var renderRouteCard = ({
3002
3174
  var _a, _b;
3003
3175
  const showSplitDetails = isSelected && isExpanded && card.kind === "split" && !!((_a = card.rows) == null ? void 0 : _a.length);
3004
3176
  const ariaLabel = [card.label, card.hint, card.value].filter(Boolean).join(" ");
3005
- return /* @__PURE__ */ jsx5(
3177
+ return /* @__PURE__ */ jsx6(
3006
3178
  "button",
3007
3179
  {
3008
3180
  type: "button",
@@ -3021,10 +3193,10 @@ var renderRouteCard = ({
3021
3193
  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"
3022
3194
  ),
3023
3195
  onClick: () => onSelect(card.id),
3024
- children: /* @__PURE__ */ jsxs4("div", { className: "agg-route-card-content relative z-10 flex flex-col gap-3", children: [
3025
- /* @__PURE__ */ jsxs4("div", { className: "agg-route-card-header flex items-center justify-between gap-4", children: [
3026
- /* @__PURE__ */ jsxs4("div", { className: "agg-route-card-meta flex min-w-0 gap-3 items-center", children: [
3027
- card.kind === "split" ? /* @__PURE__ */ jsx5(
3196
+ children: /* @__PURE__ */ jsxs5("div", { className: "agg-route-card-content relative z-10 flex flex-col gap-3", children: [
3197
+ /* @__PURE__ */ jsxs5("div", { className: "agg-route-card-header flex items-center justify-between gap-4", children: [
3198
+ /* @__PURE__ */ jsxs5("div", { className: "agg-route-card-meta flex min-w-0 gap-3 items-center", children: [
3199
+ card.kind === "split" ? /* @__PURE__ */ jsx6(
3028
3200
  Icon,
3029
3201
  {
3030
3202
  name: "sparkles-filled",
@@ -3035,7 +3207,7 @@ var renderRouteCard = ({
3035
3207
  ),
3036
3208
  "aria-hidden": "true"
3037
3209
  }
3038
- ) : card.venue ? /* @__PURE__ */ jsx5(
3210
+ ) : card.venue ? /* @__PURE__ */ jsx6(
3039
3211
  VenueLogo,
3040
3212
  {
3041
3213
  venue: card.venue,
@@ -3043,10 +3215,10 @@ var renderRouteCard = ({
3043
3215
  ariaLabel: getTradingVenueLabel(card.venue)
3044
3216
  }
3045
3217
  ) : null,
3046
- /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-1 min-w-0", children: [
3047
- /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-1.5", children: [
3048
- /* @__PURE__ */ jsx5("p", { className: "agg-route-card-title truncate text-agg-sm leading-agg-5 text-agg-foreground", children: card.label }),
3049
- card.isUnavailable ? /* @__PURE__ */ jsx5(
3218
+ /* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-1 min-w-0", children: [
3219
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-1.5", children: [
3220
+ /* @__PURE__ */ jsx6("p", { className: "agg-route-card-title truncate text-agg-sm leading-agg-5 text-agg-foreground", children: card.label }),
3221
+ card.isUnavailable ? /* @__PURE__ */ jsx6(
3050
3222
  Icon,
3051
3223
  {
3052
3224
  name: "lock",
@@ -3054,7 +3226,7 @@ var renderRouteCard = ({
3054
3226
  className: "shrink-0 text-agg-muted-foreground",
3055
3227
  "aria-hidden": "true"
3056
3228
  }
3057
- ) : card.kind === "split" && isSelected ? /* @__PURE__ */ jsx5(
3229
+ ) : card.kind === "split" && isSelected ? /* @__PURE__ */ jsx6(
3058
3230
  Icon,
3059
3231
  {
3060
3232
  name: showSplitDetails ? "chevron-up" : "chevron-down",
@@ -3064,10 +3236,10 @@ var renderRouteCard = ({
3064
3236
  }
3065
3237
  ) : null
3066
3238
  ] }),
3067
- card.hint ? /* @__PURE__ */ jsx5("p", { className: "agg-route-card-hint text-agg-xs leading-agg-4 text-agg-muted-foreground", children: card.hint }) : null
3239
+ card.hint ? /* @__PURE__ */ jsx6("p", { className: "agg-route-card-hint text-agg-xs leading-agg-4 text-agg-muted-foreground", children: card.hint }) : null
3068
3240
  ] })
3069
3241
  ] }),
3070
- /* @__PURE__ */ jsx5(
3242
+ /* @__PURE__ */ jsx6(
3071
3243
  "p",
3072
3244
  {
3073
3245
  className: cn(
@@ -3079,9 +3251,9 @@ var renderRouteCard = ({
3079
3251
  }
3080
3252
  )
3081
3253
  ] }),
3082
- showSplitDetails ? /* @__PURE__ */ jsxs4(Fragment3, { children: [
3083
- /* @__PURE__ */ jsx5("p", { className: "agg-route-card-description text-agg-xs leading-agg-4 text-agg-foreground", children: tradingLabels.splitOrderDescription }),
3084
- /* @__PURE__ */ jsx5("div", { className: "agg-route-breakdown flex flex-col gap-3", children: (_b = card.rows) == null ? void 0 : _b.map((row) => renderRouteBreakdownRow(row)) })
3254
+ showSplitDetails ? /* @__PURE__ */ jsxs5(Fragment3, { children: [
3255
+ /* @__PURE__ */ jsx6("p", { className: "agg-route-card-description text-agg-xs leading-agg-4 text-agg-foreground", children: tradingLabels.splitOrderDescription }),
3256
+ /* @__PURE__ */ jsx6("div", { className: "agg-route-breakdown flex flex-col gap-3", children: (_b = card.rows) == null ? void 0 : _b.map((row) => renderRouteBreakdownRow(row)) })
3085
3257
  ] }) : null
3086
3258
  ] })
3087
3259
  }
@@ -3104,7 +3276,7 @@ var renderSubmissionSurface = ({
3104
3276
  executionVenue: progressState.executionVenue,
3105
3277
  labels: tradingLabels
3106
3278
  });
3107
- return /* @__PURE__ */ jsx5(
3279
+ return /* @__PURE__ */ jsx6(
3108
3280
  Card,
3109
3281
  {
3110
3282
  className: cn(
@@ -3113,31 +3285,31 @@ var renderSubmissionSurface = ({
3113
3285
  classNames == null ? void 0 : classNames.root,
3114
3286
  className
3115
3287
  ),
3116
- children: /* @__PURE__ */ jsxs4("div", { className: cn("agg-order-submission-body flex flex-col gap-6 p-5", classNames == null ? void 0 : classNames.body), children: [
3288
+ children: /* @__PURE__ */ jsxs5("div", { className: cn("agg-order-submission-body flex flex-col gap-6 p-5", classNames == null ? void 0 : classNames.body), children: [
3117
3289
  renderCardHeader({
3118
3290
  className: classNames == null ? void 0 : classNames.header,
3119
3291
  headerSubtitle,
3120
3292
  headerImage,
3121
3293
  headerTitle
3122
3294
  }),
3123
- /* @__PURE__ */ jsxs4("div", { className: cn("agg-order-panel-content flex flex-col gap-6", classNames == null ? void 0 : classNames.content), children: [
3124
- /* @__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: [
3125
- /* @__PURE__ */ jsx5(LoadingGlyph, { enableAnimations, className: "h-4 w-4 text-current" }),
3126
- /* @__PURE__ */ jsx5("span", { children: actionLabel })
3295
+ /* @__PURE__ */ jsxs5("div", { className: cn("agg-order-panel-content flex flex-col gap-6", classNames == null ? void 0 : classNames.content), children: [
3296
+ /* @__PURE__ */ jsxs5("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: [
3297
+ /* @__PURE__ */ jsx6(LoadingGlyph, { enableAnimations, className: "h-4 w-4 text-current" }),
3298
+ /* @__PURE__ */ jsx6("span", { children: actionLabel })
3127
3299
  ] }),
3128
- /* @__PURE__ */ jsx5(
3300
+ /* @__PURE__ */ jsx6(
3129
3301
  "div",
3130
3302
  {
3131
3303
  className: "agg-order-submission-steps agg-order-submission-group flex flex-col gap-2",
3132
3304
  "data-testid": "agg-order-submission-steps",
3133
3305
  children: displayRows.map((step) => {
3134
- return /* @__PURE__ */ jsxs4(
3306
+ return /* @__PURE__ */ jsxs5(
3135
3307
  "div",
3136
3308
  {
3137
3309
  className: "agg-order-submission-step flex items-center gap-2 text-agg-sm leading-agg-5 text-agg-foreground",
3138
3310
  "data-status": step.status,
3139
3311
  children: [
3140
- step.status === "complete" ? /* @__PURE__ */ jsx5(
3312
+ step.status === "complete" ? /* @__PURE__ */ jsx6(
3141
3313
  Icon,
3142
3314
  {
3143
3315
  name: "check-circle",
@@ -3145,15 +3317,15 @@ var renderSubmissionSurface = ({
3145
3317
  className: "h-3 w-3 shrink-0 text-agg-primary",
3146
3318
  "aria-hidden": "true"
3147
3319
  }
3148
- ) : /* @__PURE__ */ jsx5(
3320
+ ) : /* @__PURE__ */ jsx6(
3149
3321
  LoadingGlyph,
3150
3322
  {
3151
3323
  enableAnimations,
3152
3324
  className: "h-3 w-3 shrink-0 text-agg-primary"
3153
3325
  }
3154
3326
  ),
3155
- /* @__PURE__ */ jsx5("p", { className: "min-w-0 flex-1", children: step.label }),
3156
- step.venue ? /* @__PURE__ */ jsx5(
3327
+ /* @__PURE__ */ jsx6("p", { className: "min-w-0 flex-1", children: step.label }),
3328
+ step.venue ? /* @__PURE__ */ jsx6(
3157
3329
  VenueLogo,
3158
3330
  {
3159
3331
  venue: step.venue,
@@ -3174,115 +3346,6 @@ var renderSubmissionSurface = ({
3174
3346
  }
3175
3347
  );
3176
3348
  };
3177
- var InitiateKycButton = ({ label, onOpen }) => /* @__PURE__ */ jsx5(
3178
- Button,
3179
- {
3180
- size: "large",
3181
- variant: "primary",
3182
- onClick: onOpen,
3183
- className: "agg-order-kyc-action h-12 w-full px-8 text-agg-base leading-agg-6 shadow-none",
3184
- children: label
3185
- }
3186
- );
3187
- var KycVerifyModal = ({
3188
- open,
3189
- onOpenChange,
3190
- onStartVerification,
3191
- isInitiating,
3192
- labels
3193
- }) => {
3194
- return /* @__PURE__ */ jsx5(
3195
- Modal,
3196
- {
3197
- open,
3198
- onOpenChange: (next) => {
3199
- onOpenChange(next);
3200
- },
3201
- children: /* @__PURE__ */ jsxs4(Modal.Container, { maxWidth: "480px", "aria-label": labels.title, children: [
3202
- /* @__PURE__ */ jsx5(Dialog.Title, { className: "sr-only", children: labels.title }),
3203
- /* @__PURE__ */ jsx5(Dialog.Description, { className: "sr-only", children: labels.description }),
3204
- /* @__PURE__ */ jsxs4(Modal.Body, { classNames: { root: "sm:px-10 sm:py-12" }, children: [
3205
- /* @__PURE__ */ jsx5(
3206
- "button",
3207
- {
3208
- type: "button",
3209
- className: "absolute right-8 top-7 flex items-center justify-center text-agg-foreground transition-colors hover:text-agg-foreground/80",
3210
- onClick: () => onOpenChange(false),
3211
- "aria-label": "Close",
3212
- children: /* @__PURE__ */ jsx5(CloseIcon, { className: "h-6 w-6" })
3213
- }
3214
- ),
3215
- /* @__PURE__ */ jsxs4("div", { className: "flex flex-col items-center gap-8 text-center", children: [
3216
- /* @__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]" }) }),
3217
- /* @__PURE__ */ jsxs4("div", { className: "flex flex-col items-center gap-3", children: [
3218
- /* @__PURE__ */ jsx5("h3", { className: "text-agg-2xl leading-agg-8 font-agg-bold text-agg-foreground", children: labels.title }),
3219
- /* @__PURE__ */ jsx5("p", { className: "agg-type-body text-agg-foreground", children: labels.description })
3220
- ] }),
3221
- /* @__PURE__ */ jsxs4("div", { className: "flex w-full flex-col items-center gap-5", children: [
3222
- /* @__PURE__ */ jsx5(
3223
- Button,
3224
- {
3225
- size: "large",
3226
- variant: "primary",
3227
- disabled: isInitiating,
3228
- isLoading: isInitiating,
3229
- onClick: onStartVerification,
3230
- children: labels.startVerification
3231
- }
3232
- ),
3233
- /* @__PURE__ */ jsx5(
3234
- "button",
3235
- {
3236
- type: "button",
3237
- className: "cursor-pointer text-agg-base font-agg-bold text-agg-primary hover:text-agg-primary/80 transition-colors",
3238
- onClick: () => onOpenChange(false),
3239
- children: labels.doItLater
3240
- }
3241
- )
3242
- ] })
3243
- ] })
3244
- ] })
3245
- ] })
3246
- }
3247
- );
3248
- };
3249
- var KycSuccessModal = ({
3250
- open,
3251
- onOpenChange,
3252
- labels
3253
- }) => /* @__PURE__ */ jsx5(Modal, { open, onOpenChange, children: /* @__PURE__ */ jsxs4(Modal.Container, { maxWidth: "480px", "aria-label": labels.title, children: [
3254
- /* @__PURE__ */ jsx5(Dialog.Title, { className: "sr-only", children: labels.title }),
3255
- /* @__PURE__ */ jsx5(Dialog.Description, { className: "sr-only", children: labels.description }),
3256
- /* @__PURE__ */ jsxs4(Modal.Body, { classNames: { root: "px-10 py-12" }, children: [
3257
- /* @__PURE__ */ jsx5(
3258
- "button",
3259
- {
3260
- type: "button",
3261
- className: "absolute right-8 top-7 flex items-center justify-center text-agg-foreground transition-colors hover:text-agg-foreground/80",
3262
- onClick: () => onOpenChange(false),
3263
- "aria-label": "Close",
3264
- children: /* @__PURE__ */ jsx5(CloseIcon, { className: "h-6 w-6" })
3265
- }
3266
- ),
3267
- /* @__PURE__ */ jsxs4("div", { className: "flex flex-col items-center gap-8 text-center", children: [
3268
- /* @__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" }) }),
3269
- /* @__PURE__ */ jsxs4("div", { className: "flex flex-col items-center gap-3", children: [
3270
- /* @__PURE__ */ jsx5("h3", { className: "text-agg-2xl leading-agg-8 font-agg-bold text-agg-foreground", children: labels.title }),
3271
- /* @__PURE__ */ jsx5("p", { className: "agg-type-body text-agg-foreground", children: labels.description })
3272
- ] }),
3273
- /* @__PURE__ */ jsx5(
3274
- Button,
3275
- {
3276
- variant: "secondary",
3277
- size: "large",
3278
- className: "w-[120px]",
3279
- onClick: () => onOpenChange(false),
3280
- children: labels.done
3281
- }
3282
- )
3283
- ] })
3284
- ] })
3285
- ] }) });
3286
3349
  var PlaceOrder = ({
3287
3350
  className,
3288
3351
  classNames,
@@ -3295,6 +3358,7 @@ var PlaceOrder = ({
3295
3358
  chainBalancesOverride,
3296
3359
  onAmountChange,
3297
3360
  onClose,
3361
+ onConnectKalshi,
3298
3362
  onOutcomeChange,
3299
3363
  onPrimaryAction,
3300
3364
  onBeforePrimaryAction,
@@ -3305,14 +3369,14 @@ var PlaceOrder = ({
3305
3369
  resolvedClaim,
3306
3370
  midpointsResult
3307
3371
  }) => {
3308
- 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;
3372
+ 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;
3309
3373
  const {
3310
3374
  enableDebug: isExecutionDebugEnabled,
3311
- features: { enableAnimations, showFeesBreakdown },
3375
+ features: { enableAnimations, showFeesBreakdown, showLimitOrders },
3312
3376
  general: { locale },
3313
3377
  trading: { executionMode: configuredExecutionMode = "live" } = { executionMode: "live" }
3314
3378
  } = useSdkUiConfig();
3315
- const labels = useLabels();
3379
+ const labels = useLabels2();
3316
3380
  const tradingLabels = labels.trading;
3317
3381
  const toastCtx = useOptionalToast();
3318
3382
  const { isTradingBlocked } = useGeoBlock();
@@ -3320,10 +3384,10 @@ var PlaceOrder = ({
3320
3384
  const selectedEvent = (_a = tradingContext == null ? void 0 : tradingContext.selectedEvent) != null ? _a : null;
3321
3385
  const selectedMarket = (_b = tradingContext == null ? void 0 : tradingContext.selectedMarket) != null ? _b : null;
3322
3386
  const selectedOutcomeId = (_c = tradingContext == null ? void 0 : tradingContext.selectedOutcomeId) != null ? _c : null;
3323
- const resolvedEventTradingState = useMemo2(() => {
3387
+ const resolvedEventTradingState = useMemo(() => {
3324
3388
  return eventTradingState != null ? eventTradingState : resolveEventTradingState(selectedEvent);
3325
3389
  }, [eventTradingState, selectedEvent]);
3326
- const scopedSelectedEvent = useMemo2(() => {
3390
+ const scopedSelectedEvent = useMemo(() => {
3327
3391
  var _a2;
3328
3392
  if (!selectedEvent) return null;
3329
3393
  const primaryMarketId = (_a2 = resolvedEventTradingState.primaryMarket) == null ? void 0 : _a2.id;
@@ -3333,7 +3397,7 @@ var PlaceOrder = ({
3333
3397
  );
3334
3398
  return isSelectedEventInScope ? selectedEvent : null;
3335
3399
  }, [(_d = resolvedEventTradingState.primaryMarket) == null ? void 0 : _d.id, selectedEvent]);
3336
- const scopedSelectedMarket = useMemo2(() => {
3400
+ const scopedSelectedMarket = useMemo(() => {
3337
3401
  if (!selectedMarket) return resolvedEventTradingState.primaryMarket;
3338
3402
  const isSelectedMarketInScope = resolvedEventTradingState.marketStates.some(
3339
3403
  (item) => item.market.id === selectedMarket.id
@@ -3348,10 +3412,10 @@ var PlaceOrder = ({
3348
3412
  (outcome) => outcome.label.trim().toLowerCase() === "yes"
3349
3413
  )) != null ? _f : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.venueMarketOutcomes[0]) != null ? _g : null;
3350
3414
  const scopedSelectedOutcomeId = (_h = scopedSelectedOutcome == null ? void 0 : scopedSelectedOutcome.id) != null ? _h : null;
3351
- const resolvedTradingState = useMemo2(() => {
3415
+ const resolvedTradingState = useMemo(() => {
3352
3416
  return resolveMarketTradingState(scopedSelectedMarket);
3353
3417
  }, [scopedSelectedMarket]);
3354
- const resolvedReadOnlyMarket = useMemo2(() => {
3418
+ const resolvedReadOnlyMarket = useMemo(() => {
3355
3419
  var _a2;
3356
3420
  if (resolvedEventTradingState.kind !== "resolved") {
3357
3421
  return scopedSelectedMarket;
@@ -3362,11 +3426,11 @@ var PlaceOrder = ({
3362
3426
  resolvedEventTradingState.primaryMarket,
3363
3427
  scopedSelectedMarket
3364
3428
  ]);
3365
- const resolvedReadOnlyTradingState = useMemo2(() => {
3429
+ const resolvedReadOnlyTradingState = useMemo(() => {
3366
3430
  return resolveMarketTradingState(resolvedReadOnlyMarket);
3367
3431
  }, [resolvedReadOnlyMarket]);
3368
3432
  const isEndedWithoutKnownWinner = false;
3369
- const orderEligibility = useMemo2(
3433
+ const orderEligibility = useMemo(
3370
3434
  () => resolveOrderEligibility({
3371
3435
  event: scopedSelectedEvent,
3372
3436
  market: scopedSelectedMarket,
@@ -3384,7 +3448,7 @@ var PlaceOrder = ({
3384
3448
  enabled: Boolean(isAuthenticated && isPaperMode),
3385
3449
  mode: "paper"
3386
3450
  });
3387
- const paperTotalBalance = useMemo2(() => {
3451
+ const paperTotalBalance = useMemo(() => {
3388
3452
  var _a2, _b2;
3389
3453
  const cash = (_b2 = (_a2 = paperBalancesQuery.balances) == null ? void 0 : _a2.cash) != null ? _b2 : [];
3390
3454
  return cash.reduce((sum, token) => {
@@ -3397,11 +3461,20 @@ var PlaceOrder = ({
3397
3461
  }, 0);
3398
3462
  }, 0);
3399
3463
  }, [paperBalancesQuery.balances]);
3400
- const totalBalance = isPaperMode ? paperTotalBalance : liveBalanceState.totalBalance;
3464
+ const liveAvailableBalance = (_i = liveBalanceState.availableBalance) != null ? _i : liveBalanceState.totalBalance;
3465
+ const totalBalance = isPaperMode ? paperTotalBalance : liveAvailableBalance;
3401
3466
  const isBalanceLoading = isPaperMode ? paperBalancesQuery.isLoading : liveBalanceState.isLoading;
3402
3467
  const executeManaged = useExecuteManaged();
3403
- const aggClient = useAggClient2();
3468
+ const placeLimitOrder = usePlaceLimitOrder();
3469
+ const aggClient = useAggClient();
3404
3470
  const queryClient = useQueryClient();
3471
+ const { disabledVenues, isLoading: isAppConfigLoading } = useAppConfig();
3472
+ const { data: kalshiKeyStatus, refetch: refetchKalshiKeyStatus } = useVenueKeyStatus(
3473
+ Venue4.kalshi,
3474
+ isAuthenticated
3475
+ );
3476
+ const [isConnectKalshiModalOpen, setIsConnectKalshiModalOpen] = useState2(false);
3477
+ const [isFundKalshiModalOpen, setIsFundKalshiModalOpen] = useState2(false);
3405
3478
  const livePrices = useLiveOutcomePrices(
3406
3479
  scopedSelectedMarket ? [scopedSelectedMarket] : void 0
3407
3480
  );
@@ -3410,40 +3483,90 @@ var PlaceOrder = ({
3410
3483
  midpointsResult ? [] : scopedSelectedMarket ? [scopedSelectedMarket] : []
3411
3484
  );
3412
3485
  const clusterMidpointResult = midpointsResult != null ? midpointsResult : fetchedClusterMidpointResult;
3413
- const clusterBestMidpointsByOutcomeId = (_i = clusterMidpointResult.bestMidpointsByOutcomeId) != null ? _i : clusterMidpointResult.prices;
3486
+ const clusterBestMidpointsByOutcomeId = (_j = clusterMidpointResult.bestMidpointsByOutcomeId) != null ? _j : clusterMidpointResult.prices;
3414
3487
  const clusterBestMidpoint = clusterMidpointResult.bestMidpoint;
3415
3488
  const clusterBestPricesRest = clusterMidpointResult.bestPrices;
3416
- const clusterBestPrices = useMemo2(
3489
+ const clusterBestPrices = useMemo(
3417
3490
  () => mergeBestPricesPreferringLive(clusterBestPricesRest, wsBestPrices),
3418
3491
  [clusterBestPricesRest, wsBestPrices]
3419
3492
  );
3420
- const outcomes = useMemo2(
3493
+ const [internalTab, setInternalTab] = useState2("buy");
3494
+ const [executionType, setExecutionType] = useState2("market");
3495
+ const [isExecutionTypeMenuOpen, setIsExecutionTypeMenuOpen] = useState2(false);
3496
+ const [limitPrice, setLimitPrice] = useState2(0.5);
3497
+ const [limitPriceInputValue, setLimitPriceInputValue] = useState2(formatLimitPriceInputValue(0.5));
3498
+ const [limitPriceInputError, setLimitPriceInputError] = useState2(null);
3499
+ const [limitExpirationType, setLimitExpirationType] = useState2("GTC");
3500
+ const [limitExpirationDate, setLimitExpirationDate] = useState2(void 0);
3501
+ const [limitExpirationTime, setLimitExpirationTime] = useState2("17:00");
3502
+ const [limitExpirationDraftDate, setLimitExpirationDraftDate] = useState2();
3503
+ const [limitExpirationDraftTime, setLimitExpirationDraftTime] = useState2("17:00");
3504
+ const [limitExpirationPickerView, setLimitExpirationPickerView] = useState2("options");
3505
+ const [isLimitExpirationPickerOpen, setIsLimitExpirationPickerOpen] = useState2(false);
3506
+ const [internalAmount, setInternalAmount] = useState2(PLACE_ORDER_DEFAULT_AMOUNT);
3507
+ const [sellFilledForOutcomeId, setSellFilledForOutcomeId] = useState2(null);
3508
+ const [internalSlippage] = useState2(DEFAULT_SLIPPAGE_VALUE);
3509
+ const [isRoutesExpanded, setIsRoutesExpanded] = useState2(false);
3510
+ const [selectedRouteCardId, setSelectedRouteCardId] = useState2(null);
3511
+ const [isSplitDetailOpen, setIsSplitDetailOpen] = useState2(false);
3512
+ const [buyGeoBlockSnapshot, setBuyGeoBlockSnapshot] = useState2(null);
3513
+ const [submissionFeedback, setSubmissionFeedback] = useState2(null);
3514
+ const [submissionProgressState, setSubmissionProgressState] = useState2(null);
3515
+ const [isBeforeActionPending, setIsBeforeActionPending] = useState2(false);
3516
+ const outcomes = useMemo(
3421
3517
  () => mapVenueMarketOutcomesToPlaceOrderOutcomes(scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.venueMarketOutcomes),
3422
3518
  [scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.venueMarketOutcomes]
3423
3519
  );
3424
- const buyTabRef = useRef3(null);
3425
- const sellTabRef = useRef3(null);
3426
- const [internalTab, setInternalTab] = useState3("buy");
3427
- const [internalAmount, setInternalAmount] = useState3(PLACE_ORDER_DEFAULT_AMOUNT);
3428
- const [sellFilledForOutcomeId, setSellFilledForOutcomeId] = useState3(null);
3429
- const [internalSlippage] = useState3(DEFAULT_SLIPPAGE_VALUE);
3430
- const [isRoutesExpanded, setIsRoutesExpanded] = useState3(false);
3431
- const [selectedRouteCardId, setSelectedRouteCardId] = useState3(null);
3432
- const [isSplitDetailOpen, setIsSplitDetailOpen] = useState3(false);
3433
- const [submissionFeedback, setSubmissionFeedback] = useState3(null);
3434
- const [submissionProgressState, setSubmissionProgressState] = useState3(null);
3435
- const [isBeforeActionPending, setIsBeforeActionPending] = useState3(false);
3436
- const executionDebugStoreRef = useRef3(null);
3437
- const executionDebugAttemptIdRef = useRef3(null);
3438
- const submittedSelectionRef = useRef3(null);
3439
- useEffect3(() => {
3520
+ const selectedOutcomeDisplayPrice = useMemo(() => {
3521
+ var _a2;
3522
+ if (!scopedSelectedOutcomeId || !scopedSelectedOutcome) return 0.5;
3523
+ return getDisplayOutcomePrice({
3524
+ outcomeId: scopedSelectedOutcomeId,
3525
+ outcomeLabel: scopedSelectedOutcome.label,
3526
+ selection: (_a2 = tradingContext == null ? void 0 : tradingContext.tradeSide) != null ? _a2 : internalTab === "sell" ? "sell" : "buy",
3527
+ bestPrices: clusterBestPrices,
3528
+ bestMidpoint: clusterBestMidpoint,
3529
+ bestMidpointsByOutcomeId: clusterBestMidpointsByOutcomeId,
3530
+ livePrices,
3531
+ fallbackPrice: scopedSelectedOutcome.price
3532
+ });
3533
+ }, [
3534
+ clusterBestMidpoint,
3535
+ clusterBestMidpointsByOutcomeId,
3536
+ clusterBestPrices,
3537
+ internalTab,
3538
+ livePrices,
3539
+ scopedSelectedOutcome,
3540
+ scopedSelectedOutcomeId,
3541
+ tradingContext == null ? void 0 : tradingContext.tradeSide
3542
+ ]);
3543
+ const buyTabRef = useRef2(null);
3544
+ const sellTabRef = useRef2(null);
3545
+ const executionTypeTriggerRef = useRef2(null);
3546
+ const expirationTriggerRef = useRef2(null);
3547
+ const limitPriceInitializedForOutcomeRef = useRef2(void 0);
3548
+ const expirationOptionRefs = useRef2([]);
3549
+ const shouldFocusExpirationOptionsRef = useRef2(false);
3550
+ const expirationTimeInputId = useId();
3551
+ const executionDebugStoreRef = useRef2(null);
3552
+ const executionDebugAttemptIdRef = useRef2(null);
3553
+ const submittedSelectionRef = useRef2(null);
3554
+ useEffect2(() => {
3440
3555
  if (!isExecutionDebugEnabled) {
3441
3556
  executionDebugStoreRef.current = null;
3442
3557
  return;
3443
3558
  }
3444
3559
  executionDebugStoreRef.current = enableExecutionDebugInBrowser();
3445
3560
  }, [isExecutionDebugEnabled]);
3446
- useEffect3(() => {
3561
+ useEffect2(() => {
3562
+ var _a2;
3563
+ if (!isLimitExpirationPickerOpen) return;
3564
+ if (limitExpirationPickerView !== "options") return;
3565
+ if (!shouldFocusExpirationOptionsRef.current) return;
3566
+ (_a2 = expirationOptionRefs.current[LIMIT_EXPIRATION_OPTION_COUNT - 1]) == null ? void 0 : _a2.focus();
3567
+ shouldFocusExpirationOptionsRef.current = false;
3568
+ }, [isLimitExpirationPickerOpen, limitExpirationPickerView]);
3569
+ useEffect2(() => {
3447
3570
  if (!isExecutionDebugEnabled) return;
3448
3571
  const store = executionDebugStoreRef.current;
3449
3572
  if (!store) return;
@@ -3457,16 +3580,31 @@ var PlaceOrder = ({
3457
3580
  ]);
3458
3581
  const debouncedAmount = useDebouncedValue(internalAmount, 300);
3459
3582
  const isQuoteInputEditing = internalAmount !== debouncedAmount;
3460
- const isSell = useMemo2(() => internalTab === "sell", [internalTab]);
3583
+ const isLimitOrder = showLimitOrders && executionType === "limit";
3584
+ const isSell = useMemo(() => internalTab === "sell", [internalTab]);
3461
3585
  const {
3462
3586
  positions: executionPositions,
3587
+ dataUpdatedAt: executionPositionsUpdatedAt,
3463
3588
  isLoading: isExecutionPositionsLoading,
3464
3589
  isFetching: isExecutionPositionsFetching
3465
3590
  } = useExecutionPositions({
3466
3591
  enabled: Boolean(isAuthenticated && isSell),
3467
3592
  mode: isPaperMode ? "paper" : void 0
3468
3593
  });
3469
- const smartRoute = useSmartRoute({
3594
+ const isSmartRouteEnabled = !isLimitOrder && isQuotePanelActive && !isEndedWithoutKnownWinner && !submissionProgressState && !isBeforeActionPending && !executeManaged.isPending && debouncedAmount > 0 && orderEligibility.canPlaceOrder && // On the sell tab, hold the quote until the amount has been initialized
3595
+ // from the user's position for THIS outcome AND the debounced value has
3596
+ // caught up to it. The amount input is shared with the buy tab, so right
3597
+ // after switching to sell the debounced value still holds the buy default
3598
+ // (PLACE_ORDER_DEFAULT_AMOUNT) for ~300ms — without this gate it leaks into
3599
+ // the first sell quote as `sellShares` (e.g. sellShares=20).
3600
+ (!isSell || sellFilledForOutcomeId === scopedSelectedOutcomeId && !isQuoteInputEditing);
3601
+ const smartRouteRefreshContext = {
3602
+ isEditing: isQuoteInputEditing,
3603
+ isMarketOpen: resolvedTradingState.kind === "open" && !isEndedWithoutKnownWinner,
3604
+ isPanelActive: isQuotePanelActive,
3605
+ isSubmitting: submissionProgressState != null || isBeforeActionPending || executeManaged.isPending
3606
+ };
3607
+ const smartRoute = useSmartRoute(__spreadProps(__spreadValues({
3470
3608
  venueMarketOutcomeId: scopedSelectedOutcomeId,
3471
3609
  maxSpend: isSell ? void 0 : debouncedAmount,
3472
3610
  sellShares: isSell ? debouncedAmount : void 0,
@@ -3478,21 +3616,74 @@ var PlaceOrder = ({
3478
3616
  compareVenues: true,
3479
3617
  tradeSide: isSell ? "sell" : "buy",
3480
3618
  mode: isPaperMode ? "paper" : void 0,
3481
- enabled: isQuotePanelActive && !isEndedWithoutKnownWinner && !submissionProgressState && !isBeforeActionPending && !executeManaged.isPending && debouncedAmount > 0 && orderEligibility.canPlaceOrder && // On the sell tab, hold the quote until the amount has been initialized
3482
- // from the user's position for THIS outcome AND the debounced value has
3483
- // caught up to it. The amount input is shared with the buy tab, so right
3484
- // after switching to sell the debounced value still holds the buy default
3485
- // (PLACE_ORDER_DEFAULT_AMOUNT) for ~300ms — without this gate it leaks into
3486
- // the first sell quote as `sellShares` (e.g. sellShares=20).
3487
- (!isSell || sellFilledForOutcomeId === scopedSelectedOutcomeId && !isQuoteInputEditing),
3488
- refreshContext: {
3489
- isEditing: isQuoteInputEditing,
3490
- isMarketOpen: resolvedTradingState.kind === "open" && !isEndedWithoutKnownWinner,
3491
- isPanelActive: isQuotePanelActive,
3492
- isSubmitting: submissionProgressState != null || isBeforeActionPending || executeManaged.isPending
3619
+ enabled: isSmartRouteEnabled
3620
+ }, isSell ? {
3621
+ sellCacheScope: {
3622
+ accountId: (_k = user == null ? void 0 : user.id) != null ? _k : null,
3623
+ positionVersion: executionPositionsUpdatedAt
3493
3624
  }
3625
+ } : {}), {
3626
+ refreshContext: smartRouteRefreshContext
3627
+ }));
3628
+ useEffect2(() => {
3629
+ var _a2, _b2, _c2;
3630
+ if (isSell || smartRoute.isFetching || ((_a2 = smartRoute.data) == null ? void 0 : _a2.venueMarketOutcomeId) !== scopedSelectedOutcomeId) {
3631
+ return;
3632
+ }
3633
+ if (!scopedSelectedOutcomeId) return;
3634
+ setBuyGeoBlockSnapshot({
3635
+ eventId: (_b2 = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.id) != null ? _b2 : null,
3636
+ executionMode: resolvedExecutionMode,
3637
+ outcomeId: scopedSelectedOutcomeId,
3638
+ userId: (_c2 = user == null ? void 0 : user.id) != null ? _c2 : null,
3639
+ venues: [...extractGeoBlockedVenues(smartRoute.data.warnings)].sort()
3640
+ });
3641
+ }, [
3642
+ isSell,
3643
+ resolvedExecutionMode,
3644
+ scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.id,
3645
+ scopedSelectedOutcomeId,
3646
+ smartRoute.data,
3647
+ smartRoute.isFetching,
3648
+ user == null ? void 0 : user.id
3649
+ ]);
3650
+ const inheritedBuyGeoBlockedVenues = useMemo(() => {
3651
+ var _a2, _b2;
3652
+ if (!isSell || !buyGeoBlockSnapshot || !scopedSelectedOutcomeId) return void 0;
3653
+ if (buyGeoBlockSnapshot.eventId !== ((_a2 = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.id) != null ? _a2 : null)) return void 0;
3654
+ if (buyGeoBlockSnapshot.executionMode !== resolvedExecutionMode) return void 0;
3655
+ if (buyGeoBlockSnapshot.outcomeId !== scopedSelectedOutcomeId) return void 0;
3656
+ if (buyGeoBlockSnapshot.userId !== ((_b2 = user == null ? void 0 : user.id) != null ? _b2 : null)) return void 0;
3657
+ return new Set(buyGeoBlockSnapshot.venues);
3658
+ }, [
3659
+ buyGeoBlockSnapshot,
3660
+ isSell,
3661
+ resolvedExecutionMode,
3662
+ scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.id,
3663
+ scopedSelectedOutcomeId,
3664
+ user == null ? void 0 : user.id
3665
+ ]);
3666
+ const venueSellQuoteRequests = useMemo(
3667
+ () => {
3668
+ var _a2;
3669
+ return isSell && !smartRoute.isLoading && ((_a2 = smartRoute.data) == null ? void 0 : _a2.venueMarketOutcomeId) === scopedSelectedOutcomeId ? buildVenueSellQuoteRequests({
3670
+ quoteData: smartRoute.data,
3671
+ requestedSellShares: debouncedAmount
3672
+ }) : [];
3673
+ },
3674
+ [debouncedAmount, isSell, scopedSelectedOutcomeId, smartRoute.data, smartRoute.isLoading]
3675
+ );
3676
+ const venueSellQuotes = useVenueSellQuotes({
3677
+ venueMarketOutcomeId: scopedSelectedOutcomeId,
3678
+ accountId: (_l = user == null ? void 0 : user.id) != null ? _l : null,
3679
+ positionVersion: executionPositionsUpdatedAt,
3680
+ requests: venueSellQuoteRequests,
3681
+ mode: isPaperMode ? "paper" : void 0,
3682
+ slipCapBps: 1e6,
3683
+ enabled: isSell && isSmartRouteEnabled && !smartRoute.isLoading && ((_m = smartRoute.data) == null ? void 0 : _m.venueMarketOutcomeId) === scopedSelectedOutcomeId,
3684
+ refreshContext: smartRouteRefreshContext
3494
3685
  });
3495
- const currentSellableShares = useMemo2(() => {
3686
+ const currentSellableShares = useMemo(() => {
3496
3687
  var _a2, _b2, _c2, _d2, _e2, _f2, _g2;
3497
3688
  const sharesFromQuote = (_b2 = (_a2 = smartRoute.data) == null ? void 0 : _a2.positionAvailability) == null ? void 0 : _b2.totalSellableShares;
3498
3689
  if (typeof sharesFromQuote === "number" && Number.isFinite(sharesFromQuote)) {
@@ -3524,23 +3715,24 @@ var PlaceOrder = ({
3524
3715
  isSell,
3525
3716
  scopedSelectedMarket,
3526
3717
  scopedSelectedOutcome,
3527
- (_k = (_j = smartRoute.data) == null ? void 0 : _j.positionAvailability) == null ? void 0 : _k.totalSellableShares
3718
+ (_o = (_n = smartRoute.data) == null ? void 0 : _n.positionAvailability) == null ? void 0 : _o.totalSellableShares
3528
3719
  ]);
3529
- const maxSellableShares = useMemo2(
3720
+ const maxSellableShares = useMemo(
3530
3721
  () => floorToDecimals(currentSellableShares, SELL_SHARE_INPUT_DECIMALS),
3531
3722
  [currentSellableShares]
3532
3723
  );
3533
- const isCurrentSellableSharesLoading = isSell && isAuthenticated && !(typeof ((_m = (_l = smartRoute.data) == null ? void 0 : _l.positionAvailability) == null ? void 0 : _m.totalSellableShares) === "number") && (isExecutionPositionsLoading || isExecutionPositionsFetching);
3534
- const displayedCurrentSellableShares = useMemo2(() => {
3724
+ const isCurrentSellableSharesLoading = isSell && isAuthenticated && !(typeof ((_q = (_p = smartRoute.data) == null ? void 0 : _p.positionAvailability) == null ? void 0 : _q.totalSellableShares) === "number") && (isExecutionPositionsLoading || isExecutionPositionsFetching);
3725
+ const displayedCurrentSellableShares = useMemo(() => {
3535
3726
  if (!Number.isFinite(currentSellableShares) || currentSellableShares <= 0) return 0;
3536
3727
  return floorToDecimals(currentSellableShares, SELL_SHARE_DISPLAY_DECIMALS);
3537
3728
  }, [currentSellableShares]);
3538
- const displayedCurrentSellableSharesLabel = useMemo2(
3729
+ const displayedCurrentSellableSharesLabel = useMemo(
3539
3730
  () => `${formatFlooredShareAmount(maxSellableShares, SELL_SHARE_DISPLAY_DECIMALS)} shares`,
3540
3731
  [maxSellableShares]
3541
3732
  );
3542
3733
  const isAtMaxSellableShares = isSell && maxSellableShares > 0 && Math.abs(internalAmount - maxSellableShares) < 1e-9;
3543
- useEffect3(() => {
3734
+ const isSellAmountAboveAvailability = isSell && ((_r = smartRoute.data) == null ? void 0 : _r.venueMarketOutcomeId) === scopedSelectedOutcomeId && typeof ((_s = smartRoute.data.positionAvailability) == null ? void 0 : _s.totalSellableShares) === "number" && internalAmount > maxSellableShares;
3735
+ useEffect2(() => {
3544
3736
  if (submissionProgressState != null) return;
3545
3737
  if (!isSell || isCurrentSellableSharesLoading) return;
3546
3738
  if (scopedSelectedOutcomeId === sellFilledForOutcomeId) return;
@@ -3556,16 +3748,58 @@ var PlaceOrder = ({
3556
3748
  onAmountChange,
3557
3749
  submissionProgressState
3558
3750
  ]);
3559
- const routeCards = useMemo2(
3560
- () => smartRoute.data ? buildLiveRouteCards({
3561
- eventVenues: scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.venueMarkets.map((market) => market.venue),
3751
+ useEffect2(() => {
3752
+ var _a2, _b2;
3753
+ if (submissionProgressState != null || !isSell) return;
3754
+ if (((_a2 = smartRoute.data) == null ? void 0 : _a2.venueMarketOutcomeId) !== scopedSelectedOutcomeId) return;
3755
+ const quotedSellableShares = (_b2 = smartRoute.data.positionAvailability) == null ? void 0 : _b2.totalSellableShares;
3756
+ if (typeof quotedSellableShares !== "number" || !Number.isFinite(quotedSellableShares)) return;
3757
+ const authoritativeMaxSellableShares = floorToDecimals(
3758
+ Math.max(0, quotedSellableShares),
3759
+ SELL_SHARE_INPUT_DECIMALS
3760
+ );
3761
+ if (internalAmount <= authoritativeMaxSellableShares) return;
3762
+ setInternalAmount(authoritativeMaxSellableShares);
3763
+ setSellFilledForOutcomeId(scopedSelectedOutcomeId != null ? scopedSelectedOutcomeId : null);
3764
+ onAmountChange == null ? void 0 : onAmountChange(authoritativeMaxSellableShares);
3765
+ }, [
3766
+ internalAmount,
3767
+ isSell,
3768
+ onAmountChange,
3769
+ scopedSelectedOutcomeId,
3770
+ (_u = (_t = smartRoute.data) == null ? void 0 : _t.positionAvailability) == null ? void 0 : _u.totalSellableShares,
3771
+ (_v = smartRoute.data) == null ? void 0 : _v.venueMarketOutcomeId,
3772
+ submissionProgressState
3773
+ ]);
3774
+ const routeCards = useMemo(() => {
3775
+ const eventVenues = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.venueMarkets.map((market) => market.venue);
3776
+ if (isSell) {
3777
+ return buildLiveSellRouteCards({
3778
+ eventVenues,
3779
+ geoBlockedVenues: inheritedBuyGeoBlockedVenues,
3780
+ labels: tradingLabels,
3781
+ smartQuoteData: smartRoute.data,
3782
+ venueQuotes: venueSellQuotes.quotes.map((venueQuote) => ({
3783
+ venue: venueQuote.request.venue,
3784
+ quoteData: venueQuote.data
3785
+ }))
3786
+ });
3787
+ }
3788
+ return smartRoute.data ? buildLiveRouteCards({
3789
+ eventVenues,
3562
3790
  labels: tradingLabels,
3563
3791
  quoteData: smartRoute.data,
3564
- tradeSide: isSell ? "sell" : "buy"
3565
- }) : [],
3566
- [smartRoute.data, tradingLabels, isSell, scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.venueMarkets]
3567
- );
3568
- const resolvedSelectedRouteCardId = useMemo2(() => {
3792
+ tradeSide: "buy"
3793
+ }) : [];
3794
+ }, [
3795
+ smartRoute.data,
3796
+ tradingLabels,
3797
+ inheritedBuyGeoBlockedVenues,
3798
+ isSell,
3799
+ scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.venueMarkets,
3800
+ venueSellQuotes.quotes
3801
+ ]);
3802
+ const resolvedSelectedRouteCardId = useMemo(() => {
3569
3803
  var _a2, _b2, _c2, _d2;
3570
3804
  if (routeCards.length === 0) return null;
3571
3805
  if (selectedRouteCardId && routeCards.some((card) => card.id === selectedRouteCardId && !card.isUnavailable)) {
@@ -3573,7 +3807,7 @@ var PlaceOrder = ({
3573
3807
  }
3574
3808
  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;
3575
3809
  }, [routeCards, selectedRouteCardId]);
3576
- useEffect3(() => {
3810
+ useEffect2(() => {
3577
3811
  if (routeCards.length === 0) {
3578
3812
  setSelectedRouteCardId(null);
3579
3813
  setIsRoutesExpanded(false);
@@ -3585,42 +3819,78 @@ var PlaceOrder = ({
3585
3819
  }
3586
3820
  }, [resolvedSelectedRouteCardId, routeCards.length, selectedRouteCardId]);
3587
3821
  const isSubmissionLocked = submissionProgressState != null;
3588
- const isSubmissionLockedRef = useRef3(isSubmissionLocked);
3822
+ const isSubmissionLockedRef = useRef2(isSubmissionLocked);
3589
3823
  isSubmissionLockedRef.current = isSubmissionLocked;
3590
- useEffect3(() => {
3824
+ useEffect2(() => {
3591
3825
  if (isSubmissionLockedRef.current) return;
3592
3826
  setSubmissionFeedback(null);
3593
3827
  setSubmissionProgressState(null);
3594
- }, [internalAmount, internalSlippage, internalTab, scopedSelectedOutcomeId]);
3828
+ }, [executionType, internalAmount, internalSlippage, internalTab, scopedSelectedOutcomeId]);
3829
+ useEffect2(() => {
3830
+ if (showLimitOrders || executionType !== "limit") return;
3831
+ setExecutionType("market");
3832
+ setIsExecutionTypeMenuOpen(false);
3833
+ setIsLimitExpirationPickerOpen(false);
3834
+ }, [executionType, showLimitOrders]);
3835
+ useEffect2(() => {
3836
+ if (executionType !== "limit") {
3837
+ limitPriceInitializedForOutcomeRef.current = void 0;
3838
+ return;
3839
+ }
3840
+ if (isSubmissionLockedRef.current) return;
3841
+ if (limitPriceInitializedForOutcomeRef.current === scopedSelectedOutcomeId) return;
3842
+ limitPriceInitializedForOutcomeRef.current = scopedSelectedOutcomeId;
3843
+ const nextLimitPrice = normalizeLimitPrice(selectedOutcomeDisplayPrice != null ? selectedOutcomeDisplayPrice : 50);
3844
+ setLimitPrice(nextLimitPrice);
3845
+ setLimitPriceInputValue(formatLimitPriceInputValue(nextLimitPrice));
3846
+ setLimitPriceInputError(null);
3847
+ }, [executionType, scopedSelectedOutcomeId, selectedOutcomeDisplayPrice]);
3595
3848
  const orderedRouteCards = routeCards;
3596
- const selectedRouteCard = (_o = (_n = orderedRouteCards.find((card) => card.id === resolvedSelectedRouteCardId)) != null ? _n : orderedRouteCards[0]) != null ? _o : null;
3597
- const isKalshiRoute = useMemo2(() => {
3849
+ const selectedRouteCard = (_x = (_w = orderedRouteCards.find((card) => card.id === resolvedSelectedRouteCardId)) != null ? _w : orderedRouteCards[0]) != null ? _x : null;
3850
+ const isKalshiRoute = useMemo(() => {
3598
3851
  if (selectedRouteCard) {
3599
3852
  return selectedRouteCard.venue === "kalshi" || selectedRouteCard.quoteData.fills.some((f) => f.venue === "kalshi");
3600
3853
  }
3601
3854
  return (scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.venue) === "kalshi";
3602
3855
  }, [selectedRouteCard, scopedSelectedMarket]);
3603
- const isKalshiVerified = useMemo2(() => {
3604
- var _a2;
3605
- const kalshiAccount = (_a2 = user == null ? void 0 : user.venueAccounts) == null ? void 0 : _a2.find((va) => va.venue === "kalshi");
3606
- return (kalshiAccount == null ? void 0 : kalshiAccount.kycStatus) === "verified";
3607
- }, [user == null ? void 0 : user.venueAccounts]);
3608
- const needsKycVerification = isAuthenticated && (user == null ? void 0 : user.venueAccounts) != null && isKalshiRoute && !isKalshiVerified;
3609
- const {
3610
- isVerifyModalOpen: isKycVerifyModalOpen,
3611
- showSuccessModal: showKycSuccessModal,
3612
- isInitiating: isKycInitiating,
3613
- openVerifyModal,
3614
- closeVerifyModal,
3615
- closeSuccessModal,
3616
- startVerification
3617
- } = useKalshiKycFlow({
3618
- isKalshiVerified,
3619
- userId: user == null ? void 0 : user.id,
3620
- walletAddress: (_p = getWalletAddressFromUserProfile(user)) != null ? _p : null,
3621
- onError
3622
- });
3623
- const handleRouteCardSelect = useCallback3(
3856
+ const displayedBalance = isPaperMode ? paperTotalBalance : isKalshiRoute ? (_y = liveBalanceState.kalshiBalance) != null ? _y : 0 : liveAvailableBalance;
3857
+ const legacyKalshiAccount = useMemo(
3858
+ () => {
3859
+ var _a2;
3860
+ return (_a2 = user == null ? void 0 : user.venueAccounts) == null ? void 0 : _a2.find((venueAccount) => venueAccount.venue === "kalshi");
3861
+ },
3862
+ [user == null ? void 0 : user.venueAccounts]
3863
+ );
3864
+ const isKalshiAccountActive = (_z = kalshiKeyStatus == null ? void 0 : kalshiKeyStatus.connected) != null ? _z : (legacyKalshiAccount == null ? void 0 : legacyKalshiAccount.status) === "active";
3865
+ const isKalshiVerified = ((_A = kalshiKeyStatus == null ? void 0 : kalshiKeyStatus.kycStatus) != null ? _A : legacyKalshiAccount == null ? void 0 : legacyKalshiAccount.kycStatus) === "verified";
3866
+ const hasKalshiConnectionState = kalshiKeyStatus !== void 0 || (user == null ? void 0 : user.venueAccounts) != null;
3867
+ const isKalshiAvailable = getVenueAvailabilityState({
3868
+ venueId: "kalshi",
3869
+ disabledVenues,
3870
+ isConfigLoading: isAppConfigLoading
3871
+ }) === "available";
3872
+ const needsKalshiConnection = isAuthenticated && hasKalshiConnectionState && isKalshiAvailable && isKalshiRoute && !isKalshiAccountActive;
3873
+ const handleVerifyKalshi = useCallback2(
3874
+ (credentials) => __async(null, null, function* () {
3875
+ if (onConnectKalshi) {
3876
+ yield onConnectKalshi(credentials);
3877
+ } else {
3878
+ yield aggClient.upsertVenueKey({
3879
+ venue: Venue4.kalshi,
3880
+ credentials: {
3881
+ keyId: credentials.apiKeyId,
3882
+ privateKey: credentials.privateKey
3883
+ }
3884
+ });
3885
+ }
3886
+ yield refetchKalshiKeyStatus();
3887
+ yield aggClient.getCurrentUser();
3888
+ }),
3889
+ [aggClient, onConnectKalshi, refetchKalshiKeyStatus]
3890
+ );
3891
+ const needsKycVerification = isAuthenticated && hasKalshiConnectionState && isKalshiRoute && isKalshiAccountActive && !isKalshiVerified;
3892
+ const verifyKalshiConnectionLabel = (_E = (_D = (_C = (_B = labels.onboarding) == null ? void 0 : _B.connectKalshiModal) == null ? void 0 : _C.actions) == null ? void 0 : _D.verifyConnection) != null ? _E : tradingLabels.kycRequired;
3893
+ const handleRouteCardSelect = useCallback2(
3624
3894
  (cardId) => {
3625
3895
  if (cardId === resolvedSelectedRouteCardId) {
3626
3896
  const card = routeCards.find((c) => c.id === cardId);
@@ -3634,16 +3904,16 @@ var PlaceOrder = ({
3634
3904
  [resolvedSelectedRouteCardId, routeCards]
3635
3905
  );
3636
3906
  const executionProgress = useExecutionProgress({
3637
- orderIds: (_q = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) != null ? _q : null,
3638
- quoteId: (_r = submissionProgressState == null ? void 0 : submissionProgressState.quoteId) != null ? _r : null,
3907
+ orderIds: (_F = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) != null ? _F : null,
3908
+ quoteId: (_G = submissionProgressState == null ? void 0 : submissionProgressState.quoteId) != null ? _G : null,
3639
3909
  mode: isPaperMode ? "paper" : void 0,
3640
- 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)
3910
+ enabled: ((submissionProgressState == null ? void 0 : submissionProgressState.phase) === "submitting" || (submissionProgressState == null ? void 0 : submissionProgressState.phase) === "executing") && !!((_H = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) == null ? void 0 : _H.length)
3641
3911
  });
3642
- 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 : "";
3643
- const headerImage = (_x = (_w = scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.image) != null ? _w : scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.image) != null ? _x : null;
3644
- const headerTitle = (_z = (_y = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.title) != null ? _y : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _z : "";
3645
- const headerSubtitle = (_A = scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _A : "";
3646
- const buildExecutionSummary = useCallback3(
3912
+ const selectedOutcomeLabel = (_K = (_J = (_I = outcomes.find((outcome) => outcome.id === scopedSelectedOutcomeId)) == null ? void 0 : _I.label) != null ? _J : scopedSelectedOutcome == null ? void 0 : scopedSelectedOutcome.label) != null ? _K : "";
3913
+ const headerImage = (_M = (_L = scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.image) != null ? _L : scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.image) != null ? _M : null;
3914
+ const headerTitle = (_O = (_N = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.title) != null ? _N : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _O : "";
3915
+ const headerSubtitle = (_P = scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _P : "";
3916
+ const buildExecutionSummary = useCallback2(
3647
3917
  (quoteData, executionVenue, orderId, partialFillSummary) => {
3648
3918
  var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2;
3649
3919
  if (!quoteData) return void 0;
@@ -3719,7 +3989,7 @@ var PlaceOrder = ({
3719
3989
  tradingLabels
3720
3990
  ]
3721
3991
  );
3722
- useEffect3(() => {
3992
+ useEffect2(() => {
3723
3993
  if (executionProgress.phase === "order_submitted") {
3724
3994
  const submittedOrder = executionProgress.submittedOrders[0];
3725
3995
  setSubmissionProgressState((prev) => {
@@ -3732,7 +4002,7 @@ var PlaceOrder = ({
3732
4002
  });
3733
4003
  }
3734
4004
  }, [executionProgress.phase, executionProgress.submittedOrders]);
3735
- useEffect3(() => {
4005
+ useEffect2(() => {
3736
4006
  var _a2, _b2;
3737
4007
  const dp = executionProgress.dagProgress;
3738
4008
  if (!dp) return;
@@ -3783,7 +4053,7 @@ var PlaceOrder = ({
3783
4053
  return __spreadProps(__spreadValues({}, prev), { dagProgress: dp });
3784
4054
  });
3785
4055
  }, [executionProgress.dagProgress, tradingLabels]);
3786
- useEffect3(() => {
4056
+ useEffect2(() => {
3787
4057
  const orderIds = submissionProgressState == null ? void 0 : submissionProgressState.orderIds;
3788
4058
  if (!(orderIds == null ? void 0 : orderIds.length)) return;
3789
4059
  const aggregateStatus = deriveAggregateOrderStatus(
@@ -3844,7 +4114,7 @@ var PlaceOrder = ({
3844
4114
  tradingLabels
3845
4115
  ]);
3846
4116
  const estDurationMs = (selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData) && typeof selectedRouteCard.quoteData.estDurationMs === "number" ? selectedRouteCard.quoteData.estDurationMs : 6e4;
3847
- useEffect3(() => {
4117
+ useEffect2(() => {
3848
4118
  const phase = submissionProgressState == null ? void 0 : submissionProgressState.phase;
3849
4119
  if (phase !== "submitting" && phase !== "executing") return;
3850
4120
  const timeoutMs = Math.max(6e4, 2 * estDurationMs);
@@ -3859,7 +4129,7 @@ var PlaceOrder = ({
3859
4129
  }, timeoutMs);
3860
4130
  return () => clearTimeout(id);
3861
4131
  }, [submissionProgressState == null ? void 0 : submissionProgressState.phase, estDurationMs]);
3862
- const emitTerminalOrderNotifications = useCallback3(() => {
4132
+ const emitTerminalOrderNotifications = useCallback2(() => {
3863
4133
  const toast = toastCtx == null ? void 0 : toastCtx.toast;
3864
4134
  if (!toast) return;
3865
4135
  for (const event of executionProgress.terminalOrderEvents) {
@@ -3888,7 +4158,7 @@ var PlaceOrder = ({
3888
4158
  });
3889
4159
  }
3890
4160
  }, [executionProgress.terminalOrderEvents, labels, toastCtx]);
3891
- useEffect3(() => {
4161
+ useEffect2(() => {
3892
4162
  var _a2, _b2;
3893
4163
  if (!submissionProgressState) return;
3894
4164
  onExecutionStateChange == null ? void 0 : onExecutionStateChange(submissionProgressState);
@@ -3940,19 +4210,28 @@ var PlaceOrder = ({
3940
4210
  queryClient,
3941
4211
  submissionProgressState
3942
4212
  ]);
3943
- const activeQuoteData = (_C = (_B = selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData) != null ? _B : smartRoute.data) != null ? _C : null;
4213
+ const activeQuoteData = (_R = (_Q = selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData) != null ? _Q : smartRoute.data) != null ? _R : null;
3944
4214
  const visibleRouteCards = orderedRouteCards.length > PLACE_ORDER_ROUTE_COLLAPSED_CARD_COUNT && !isRoutesExpanded ? orderedRouteCards.slice(0, PLACE_ORDER_ROUTE_COLLAPSED_CARD_COUNT) : orderedRouteCards;
3945
4215
  const hasEnteredAmount = internalAmount > 0;
3946
- const isQuoteLoading = hasEnteredAmount && (smartRoute.isFetching || smartRoute.isLoading);
4216
+ const isQuoteLoading = !isLimitOrder && hasEnteredAmount && (smartRoute.isFetching || smartRoute.isLoading || isSell && (venueSellQuotes.isFetching || venueSellQuotes.isLoading));
3947
4217
  const routeLoadingMessage = isQuoteLoading ? smartRoute.loadingReason === "updating-route" ? tradingLabels.updatingRoute : smartRoute.loadingReason === "refreshing-quotes" ? tradingLabels.refreshingQuotes : tradingLabels.findingBestOdds : null;
3948
- const isInsufficientBalance = !isSell && isAuthenticated && hasEnteredAmount && !isBalanceLoading && internalAmount > totalBalance;
3949
- const isQuoteInsufficientBalance = (activeQuoteData == null ? void 0 : activeQuoteData.status) === "insufficient_balance";
4218
+ const selectedRouteFills = (_S = selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData.fills) != null ? _S : [];
4219
+ const isKalshiOnlyRoute = isKalshiRoute && ((selectedRouteCard == null ? void 0 : selectedRouteCard.venue) === Venue4.kalshi || selectedRouteFills.length > 0 && selectedRouteFills.every((fill) => fill.venue === Venue4.kalshi));
4220
+ const isOnchainOnlyRoute = !isKalshiRoute || selectedRouteFills.length > 0 && selectedRouteFills.every((fill) => fill.venue !== Venue4.kalshi);
4221
+ const kalshiRequiredAmount = isSell ? 0 : selectedRouteFills.filter((fill) => fill.venue === Venue4.kalshi).reduce((total, fill) => total + fill.venueQty * fill.avgPrice, 0);
4222
+ const onchainRequiredAmount = isSell ? 0 : selectedRouteFills.filter((fill) => fill.venue !== Venue4.kalshi).reduce((total, fill) => total + fill.venueQty * fill.avgPrice, 0);
4223
+ const resolvedKalshiRequiredAmount = isKalshiOnlyRoute || isKalshiRoute && selectedRouteFills.length === 0 ? internalAmount : kalshiRequiredAmount;
4224
+ const resolvedOnchainRequiredAmount = isOnchainOnlyRoute || !isKalshiRoute && selectedRouteFills.length === 0 ? internalAmount : onchainRequiredAmount;
4225
+ const isKalshiBalanceInsufficient = !isPaperMode && isKalshiRoute && resolvedKalshiRequiredAmount > ((_T = liveBalanceState.kalshiBalance) != null ? _T : 0);
4226
+ const isOnchainBalanceInsufficient = resolvedOnchainRequiredAmount > liveAvailableBalance;
4227
+ const isInsufficientBalance = !isSell && isAuthenticated && hasEnteredAmount && !isBalanceLoading && (isLimitOrder ? internalAmount > totalBalance : isPaperMode ? internalAmount > paperTotalBalance : isKalshiBalanceInsufficient || isOnchainBalanceInsufficient);
4228
+ const isQuoteInsufficientBalance = !isLimitOrder && (activeQuoteData == null ? void 0 : activeQuoteData.status) === "insufficient_balance";
3950
4229
  const shouldShowInsufficientBalanceAlert = isInsufficientBalance || isQuoteInsufficientBalance;
3951
4230
  const isBelowClientMinimum = !isSell && hasEnteredAmount && internalAmount < MIN_BUY_ORDER_AMOUNT;
3952
4231
  const isBelowVenueMinimumFromQuote = isQuoteBelowVenueMinimum(activeQuoteData);
3953
4232
  const isBelowMinimum = isBelowClientMinimum || isBelowVenueMinimumFromQuote;
3954
4233
  const belowMinimumMessage = isBelowClientMinimum ? tradingLabels.minimumOrderAmount(MIN_BUY_ORDER_AMOUNT) : tradingLabels.minOrderSizeViolated;
3955
- const quoteStatus = useMemo2(() => {
4234
+ const quoteStatus = useMemo(() => {
3956
4235
  if (!orderEligibility.canPlaceOrder) return void 0;
3957
4236
  return resolvePlaceOrderQuoteStatus({
3958
4237
  amount: internalAmount,
@@ -3967,16 +4246,18 @@ var PlaceOrder = ({
3967
4246
  scopedSelectedMarket,
3968
4247
  tradingLabels
3969
4248
  ]);
3970
- const smartRouteErrorMessage = useMemo2(() => {
3971
- if (!smartRoute.error) return null;
4249
+ const smartRouteErrorMessage = useMemo(() => {
4250
+ var _a2;
4251
+ const quoteError = (_a2 = smartRoute.error) != null ? _a2 : isSell ? venueSellQuotes.error : null;
4252
+ if (!quoteError || orderedRouteCards.length > 0) return null;
3972
4253
  return normalizePlaceOrderErrorMessage({
3973
- errorMessage: smartRoute.error.message,
4254
+ errorMessage: quoteError.message,
3974
4255
  fallbackMessage: tradingLabels.quoteUnavailable,
3975
4256
  labels: tradingLabels
3976
4257
  });
3977
- }, [smartRoute.error, tradingLabels]);
4258
+ }, [isSell, orderedRouteCards.length, smartRoute.error, tradingLabels, venueSellQuotes.error]);
3978
4259
  const progressActionLabel = (internalTab === "buy" ? tradingLabels.buyingOutcome(selectedOutcomeLabel) : tradingLabels.sellingOutcome(selectedOutcomeLabel)).trim();
3979
- const canRetryRemaining = useMemo2(() => {
4260
+ const canRetryRemaining = useMemo(() => {
3980
4261
  const remaining = getPlaceOrderUnfilledRemaining({
3981
4262
  originalAmount: internalAmount,
3982
4263
  tradeSide: internalTab,
@@ -3986,7 +4267,7 @@ var PlaceOrder = ({
3986
4267
  return remaining >= minRemainder;
3987
4268
  }, [executionProgress.terminalOrderEvents, internalAmount, internalTab, isSell]);
3988
4269
  const PARTIAL_FILL_AUTO_SUCCESS_THRESHOLD = 0.95;
3989
- const shouldAutoSkipPartialFill = useMemo2(() => {
4270
+ const shouldAutoSkipPartialFill = useMemo(() => {
3990
4271
  if (internalAmount <= 0) return false;
3991
4272
  const remaining = getPlaceOrderUnfilledRemaining({
3992
4273
  originalAmount: internalAmount,
@@ -3997,7 +4278,7 @@ var PlaceOrder = ({
3997
4278
  const fillRatio = filled / internalAmount;
3998
4279
  return fillRatio >= PARTIAL_FILL_AUTO_SUCCESS_THRESHOLD || !canRetryRemaining;
3999
4280
  }, [canRetryRemaining, executionProgress.terminalOrderEvents, internalAmount, internalTab]);
4000
- const failureSummary = useMemo2(() => {
4281
+ const failureSummary = useMemo(() => {
4001
4282
  var _a2;
4002
4283
  if ((submissionProgressState == null ? void 0 : submissionProgressState.phase) !== "failed") return void 0;
4003
4284
  return buildPlaceOrderFailureSummary({
@@ -4026,7 +4307,7 @@ var PlaceOrder = ({
4026
4307
  submissionProgressState,
4027
4308
  tradingLabels
4028
4309
  ]);
4029
- const displayedToWinHint = useMemo2(() => {
4310
+ const displayedToWinHint = useMemo(() => {
4030
4311
  var _a2, _b2, _c2, _d2;
4031
4312
  if (!selectedRouteCard) return "";
4032
4313
  if (selectedRouteCard.isUnavailable) {
@@ -4035,14 +4316,91 @@ var PlaceOrder = ({
4035
4316
  }
4036
4317
  return (_d2 = selectedRouteCard.hint) != null ? _d2 : "";
4037
4318
  }, [selectedRouteCard, tradingLabels]);
4038
- const displayedToWinValue = (_D = selectedRouteCard == null ? void 0 : selectedRouteCard.numericValue) != null ? _D : 0;
4319
+ const displayedToWinValue = (_U = selectedRouteCard == null ? void 0 : selectedRouteCard.numericValue) != null ? _U : 0;
4320
+ const limitOrderPayload = useMemo(() => {
4321
+ if (!scopedSelectedMarket || !scopedSelectedOutcomeId || internalAmount <= 0) return null;
4322
+ if (limitPriceInputError) return null;
4323
+ const expirationDate = resolveLimitExpirationDate({
4324
+ expirationType: limitExpirationType,
4325
+ customDate: limitExpirationDate,
4326
+ customTime: limitExpirationTime
4327
+ });
4328
+ if (limitExpirationType !== "GTC" && !expirationDate) return null;
4329
+ const limitPriceRaw = toLimitPriceRaw(limitPrice);
4330
+ const sizeRaw = toLimitSizeRaw({
4331
+ amount: internalAmount,
4332
+ limitPriceRaw,
4333
+ side: internalTab
4334
+ });
4335
+ const expiresAt = expirationDate ? serializeLimitOrderExpiration(expirationDate) : void 0;
4336
+ return __spreadValues({
4337
+ venue: scopedSelectedMarket.venue,
4338
+ venueMarketOutcomeId: scopedSelectedOutcomeId,
4339
+ side: internalTab,
4340
+ limitPriceRaw,
4341
+ sizeRaw,
4342
+ timeInForce: limitExpirationType === "GTC" ? "GTC" : "GTD"
4343
+ }, expiresAt ? { expiresAt } : {});
4344
+ }, [
4345
+ internalAmount,
4346
+ internalTab,
4347
+ limitExpirationDate,
4348
+ limitExpirationTime,
4349
+ limitExpirationType,
4350
+ limitPrice,
4351
+ limitPriceInputError,
4352
+ scopedSelectedMarket,
4353
+ scopedSelectedOutcomeId
4354
+ ]);
4355
+ const resolvedLimitExpirationDraftDate = useMemo(() => {
4356
+ return resolveLimitExpirationDate({
4357
+ expirationType: "CUSTOM",
4358
+ customDate: limitExpirationDraftDate,
4359
+ customTime: limitExpirationDraftTime
4360
+ });
4361
+ }, [limitExpirationDraftDate, limitExpirationDraftTime]);
4362
+ const isLimitExpirationDraftValid = isFutureLimitExpiration(resolvedLimitExpirationDraftDate);
4363
+ const resolvedCustomExpirationDate = useMemo(() => {
4364
+ return resolveLimitExpirationDate({
4365
+ expirationType: "CUSTOM",
4366
+ customDate: limitExpirationDate,
4367
+ customTime: limitExpirationTime
4368
+ });
4369
+ }, [limitExpirationDate, limitExpirationTime]);
4370
+ const buildLimitOrderPayloadForSubmission = () => {
4371
+ if (!limitOrderPayload) return null;
4372
+ const submissionPayload = __spreadValues({}, limitOrderPayload);
4373
+ delete submissionPayload.expiresAt;
4374
+ if (limitExpirationType === "GTC") return submissionPayload;
4375
+ const expirationDate = resolveLimitExpirationDate({
4376
+ expirationType: limitExpirationType,
4377
+ customDate: limitExpirationDate,
4378
+ customTime: limitExpirationTime
4379
+ });
4380
+ if (!expirationDate || expirationDate.getTime() <= Date.now()) return null;
4381
+ return __spreadProps(__spreadValues({}, submissionPayload), {
4382
+ expiresAt: serializeLimitOrderExpiration(expirationDate)
4383
+ });
4384
+ };
4385
+ const displayedLimitToWinValue = useMemo(() => {
4386
+ if (!limitOrderPayload) return 0;
4387
+ const size = Number(BigInt(limitOrderPayload.sizeRaw)) / Number(LIMIT_ORDER_RAW_SCALE);
4388
+ if (internalTab === "buy") return size;
4389
+ return Number(
4390
+ ceilDiv(
4391
+ BigInt(limitOrderPayload.limitPriceRaw) * BigInt(limitOrderPayload.sizeRaw),
4392
+ LIMIT_ORDER_RAW_SCALE
4393
+ )
4394
+ ) / Number(LIMIT_ORDER_RAW_SCALE);
4395
+ }, [internalTab, limitOrderPayload]);
4396
+ const displayedLimitToWinHint = formatLimitPriceLabel(limitPrice);
4039
4397
  const activeFeeBreakdown = activeQuoteData == null ? void 0 : activeQuoteData.feeBreakdown;
4040
- const estimatedFeesValue = useMemo2(() => {
4398
+ const estimatedFeesValue = useMemo(() => {
4041
4399
  if (!activeFeeBreakdown) return null;
4042
4400
  const totalFees = activeFeeBreakdown.venueFees + activeFeeBreakdown.bridgeFees + activeFeeBreakdown.executionGas;
4043
4401
  return formatUsd(totalFees, { minimumFractionDigits: 2, maximumFractionDigits: 2 });
4044
4402
  }, [activeFeeBreakdown]);
4045
- const feeBreakdownRows = useMemo2(() => {
4403
+ const feeBreakdownRows = useMemo(() => {
4046
4404
  if (!activeFeeBreakdown) return [];
4047
4405
  return [
4048
4406
  {
@@ -4076,16 +4434,16 @@ var PlaceOrder = ({
4076
4434
  }
4077
4435
  ];
4078
4436
  }, [activeFeeBreakdown, tradingLabels]);
4079
- const isActionLoading = isPrimaryActionLoading || executeManaged.isPending || isBeforeActionPending;
4080
- const selectedRouteGeoBlocked = (_E = selectedRouteCard == null ? void 0 : selectedRouteCard.isUnavailable) != null ? _E : false;
4081
- const geoBlockedVenuesFromWarnings = useMemo2(
4437
+ const isActionLoading = isPrimaryActionLoading || executeManaged.isPending || placeLimitOrder.isPending || isBeforeActionPending;
4438
+ const selectedRouteGeoBlocked = (_V = selectedRouteCard == null ? void 0 : selectedRouteCard.isUnavailable) != null ? _V : false;
4439
+ const geoBlockedVenuesFromWarnings = useMemo(
4082
4440
  () => {
4083
4441
  var _a2;
4084
4442
  return extractGeoBlockedVenues((_a2 = smartRoute.data) == null ? void 0 : _a2.warnings);
4085
4443
  },
4086
- [(_F = smartRoute.data) == null ? void 0 : _F.warnings]
4444
+ [(_W = smartRoute.data) == null ? void 0 : _W.warnings]
4087
4445
  );
4088
- const isPrimaryVenueGeoBlocked = useMemo2(() => {
4446
+ const isPrimaryVenueGeoBlocked = useMemo(() => {
4089
4447
  var _a2, _b2;
4090
4448
  if (!selectedRouteCard || selectedRouteCard.isUnavailable) return false;
4091
4449
  const fills = (_b2 = (_a2 = selectedRouteCard.quoteData) == null ? void 0 : _a2.fills) != null ? _b2 : [];
@@ -4094,10 +4452,10 @@ var PlaceOrder = ({
4094
4452
  const shouldShowGeoBlockBanner = isTradingBlocked || selectedRouteGeoBlocked || isPrimaryVenueGeoBlocked;
4095
4453
  const shouldShowLowLiquidityWarning = !isQuoteInputEditing && !isQuoteLoading && (activeQuoteData == null ? void 0 : activeQuoteData.venueMarketOutcomeId) === scopedSelectedOutcomeId && hasLowLiquidityWarning(activeQuoteData.warnings);
4096
4454
  const actionLabel = `${internalTab === "buy" ? tradingLabels.buy : tradingLabels.sell} ${selectedOutcomeLabel}`.trim();
4097
- const isActionDisabled = isPrimaryActionDisabled || !orderEligibility.canPlaceOrder || isActionLoading || !hasEnteredAmount || !scopedSelectedMarket || isInsufficientBalance || isQuoteInsufficientBalance || isBelowMinimum || isQuoteLoading || !selectedRouteCard || !selectedRouteCard.quoteData.quoteId || selectedRouteGeoBlocked || !isAuthenticated || quoteStatus !== void 0;
4098
- const shouldShowSmartRouting = orderEligibility.canPlaceOrder && hasEnteredAmount && !isBelowMinimum && (orderedRouteCards.length > 0 || smartRoute.isFetching || smartRoute.isLoading);
4455
+ const isActionDisabled = isPrimaryActionDisabled || !orderEligibility.canPlaceOrder || isActionLoading || !hasEnteredAmount || !scopedSelectedMarket || isInsufficientBalance || isQuoteInsufficientBalance || isSell && isQuoteInputEditing || isSellAmountAboveAvailability || isBelowMinimum || !isLimitOrder && isQuoteLoading || (isLimitOrder ? !limitOrderPayload : !selectedRouteCard || !selectedRouteCard.quoteData.quoteId) || selectedRouteGeoBlocked || !isAuthenticated || !isLimitOrder && quoteStatus !== void 0;
4456
+ const shouldShowSmartRouting = !isLimitOrder && orderEligibility.canPlaceOrder && hasEnteredAmount && !isBelowMinimum && (orderedRouteCards.length > 0 || smartRoute.isFetching || smartRoute.isLoading || isSell && (venueSellQuotes.isFetching || venueSellQuotes.isLoading));
4099
4457
  const shouldShowRouteToggle = !isQuoteLoading && orderedRouteCards.length > PLACE_ORDER_ROUTE_COLLAPSED_CARD_COUNT;
4100
- const handleReturnToOrderForm = useCallback3(() => {
4458
+ const handleReturnToOrderForm = useCallback2(() => {
4101
4459
  const submittedSelection = submittedSelectionRef.current;
4102
4460
  submittedSelectionRef.current = null;
4103
4461
  setSubmissionProgressState(null);
@@ -4118,7 +4476,7 @@ var PlaceOrder = ({
4118
4476
  const shareUrl = `https://twitter.com/intent/tweet?text=${encodeURIComponent(shareText)}`;
4119
4477
  window.open(shareUrl, "_blank", "noopener,noreferrer");
4120
4478
  };
4121
- const handleExecuteQuote = useCallback3(
4479
+ const handleExecuteQuote = useCallback2(
4122
4480
  (quoteData) => __async(null, null, function* () {
4123
4481
  var _a2, _b2, _c2;
4124
4482
  const quoteId = quoteData == null ? void 0 : quoteData.quoteId;
@@ -4196,7 +4554,17 @@ var PlaceOrder = ({
4196
4554
  }
4197
4555
  if (isFillRejection400(error)) {
4198
4556
  try {
4199
- yield smartRoute.refetch();
4557
+ const rejectedVenueQuote = venueSellQuotes.quotes.find(
4558
+ (venueQuote) => {
4559
+ var _a3;
4560
+ return ((_a3 = venueQuote.data) == null ? void 0 : _a3.quoteId) === quoteId;
4561
+ }
4562
+ );
4563
+ if (isSell && rejectedVenueQuote) {
4564
+ yield rejectedVenueQuote.refetch();
4565
+ } else {
4566
+ yield smartRoute.refetch();
4567
+ }
4200
4568
  } catch (e) {
4201
4569
  }
4202
4570
  }
@@ -4214,10 +4582,95 @@ var PlaceOrder = ({
4214
4582
  scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.id,
4215
4583
  scopedSelectedOutcomeId,
4216
4584
  smartRoute,
4217
- tradingLabels.quoteUnavailable
4585
+ tradingLabels.quoteUnavailable,
4586
+ venueSellQuotes.quotes
4218
4587
  ]
4219
4588
  );
4220
- const handleSkipToSuccess = useCallback3(() => {
4589
+ const handlePlaceLimitOrder = useCallback2(
4590
+ (submissionLimitOrderPayload) => __async(null, null, function* () {
4591
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2;
4592
+ if (!showLimitOrders) return;
4593
+ if (onPrimaryAction) {
4594
+ onPrimaryAction({
4595
+ mode: isPaperMode ? "paper" : void 0,
4596
+ orderType: "limit",
4597
+ limitOrder: submissionLimitOrderPayload
4598
+ });
4599
+ return;
4600
+ }
4601
+ if (process.env.NODE_ENV === "development") {
4602
+ console.debug("Limit order request", {
4603
+ expiresAt: submissionLimitOrderPayload.expiresAt,
4604
+ expiresAtType: typeof submissionLimitOrderPayload.expiresAt,
4605
+ payload: submissionLimitOrderPayload
4606
+ });
4607
+ }
4608
+ const response = yield placeLimitOrder.mutateAsync(submissionLimitOrderPayload);
4609
+ const limitPriceLabel = formatLimitPriceLabel(limitPrice);
4610
+ const size = Number(BigInt(submissionLimitOrderPayload.sizeRaw)) / Number(LIMIT_ORDER_RAW_SCALE);
4611
+ const sizeLabel = size.toLocaleString("en-US", {
4612
+ minimumFractionDigits: 2,
4613
+ maximumFractionDigits: 2
4614
+ });
4615
+ const estimatedCost = internalTab === "buy" ? formatUsd(
4616
+ Number(
4617
+ ceilDiv(
4618
+ BigInt(submissionLimitOrderPayload.limitPriceRaw) * BigInt(submissionLimitOrderPayload.sizeRaw),
4619
+ LIMIT_ORDER_RAW_SCALE
4620
+ )
4621
+ ) / Number(LIMIT_ORDER_RAW_SCALE)
4622
+ ) : sizeLabel;
4623
+ const eventTitle = (_b2 = (_a2 = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.title) != null ? _a2 : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _b2 : "";
4624
+ const eventDateSource = (_c2 = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.endDate) != null ? _c2 : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.endDate;
4625
+ const responseVenue = Venue4[response.venue];
4626
+ setSubmissionProgressState({
4627
+ orderId: response.orderId,
4628
+ orderIds: [response.orderId],
4629
+ executionVenue: responseVenue,
4630
+ phase: "success",
4631
+ summary: {
4632
+ tradeSide: internalTab,
4633
+ shares: sizeLabel,
4634
+ avgPrice: limitPriceLabel,
4635
+ estimatedCost,
4636
+ venue: getTradingVenueLabel(responseVenue),
4637
+ eventTitle,
4638
+ eventDateLabel: eventDateSource ? getTradingDateLabel(eventDateSource) : "",
4639
+ eventImage: headerImage,
4640
+ actionLabel: internalTab === "buy" ? (_e2 = (_d2 = tradingLabels.boughtOutcomeAtPrice) == null ? void 0 : _d2.call(tradingLabels, selectedOutcomeLabel, limitPriceLabel)) != null ? _e2 : `Bought ${selectedOutcomeLabel} at ${limitPriceLabel}` : (_g2 = (_f2 = tradingLabels.soldOutcomeAtPrice) == null ? void 0 : _f2.call(tradingLabels, selectedOutcomeLabel, limitPriceLabel)) != null ? _g2 : `Sold ${selectedOutcomeLabel} at ${limitPriceLabel}`,
4641
+ amountLabel: internalTab === "sell" ? sizeLabel : estimatedCost,
4642
+ toWinLabel: internalTab === "sell" ? estimatedCost : sizeLabel,
4643
+ potentialReturnLabel: void 0,
4644
+ executionStepGroups: [
4645
+ [
4646
+ {
4647
+ id: "limit-order-placed",
4648
+ label: tradingLabels.limitOrderPlacedDescription,
4649
+ tone: "complete",
4650
+ venue: responseVenue
4651
+ }
4652
+ ]
4653
+ ]
4654
+ }
4655
+ });
4656
+ }),
4657
+ [
4658
+ headerImage,
4659
+ internalTab,
4660
+ isPaperMode,
4661
+ limitPrice,
4662
+ onPrimaryAction,
4663
+ placeLimitOrder,
4664
+ scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.endDate,
4665
+ scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.title,
4666
+ scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.endDate,
4667
+ scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question,
4668
+ selectedOutcomeLabel,
4669
+ showLimitOrders,
4670
+ tradingLabels
4671
+ ]
4672
+ );
4673
+ const handleSkipToSuccess = useCallback2(() => {
4221
4674
  const primaryFilledEvent = executionProgress.terminalOrderEvents.find(
4222
4675
  (e) => e.event === "filled" || e.event === "partial_fill"
4223
4676
  );
@@ -4242,7 +4695,7 @@ var PlaceOrder = ({
4242
4695
  failureSummary,
4243
4696
  selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData
4244
4697
  ]);
4245
- useEffect3(() => {
4698
+ useEffect2(() => {
4246
4699
  if ((submissionProgressState == null ? void 0 : submissionProgressState.phase) !== "failed") return;
4247
4700
  if ((failureSummary == null ? void 0 : failureSummary.kind) !== "partial_fill") return;
4248
4701
  if (!shouldAutoSkipPartialFill) return;
@@ -4253,8 +4706,8 @@ var PlaceOrder = ({
4253
4706
  shouldAutoSkipPartialFill,
4254
4707
  submissionProgressState == null ? void 0 : submissionProgressState.phase
4255
4708
  ]);
4256
- const handleRetrySubmission = useCallback3(() => __async(null, null, function* () {
4257
- var _a2, _b2, _c2;
4709
+ const handleRetrySubmission = useCallback2(() => __async(null, null, function* () {
4710
+ var _a2, _b2, _c2, _d2, _e2;
4258
4711
  if (!orderEligibility.canPlaceOrder || (failureSummary == null ? void 0 : failureSummary.kind) === "generic") {
4259
4712
  handleReturnToOrderForm();
4260
4713
  return;
@@ -4275,10 +4728,51 @@ var PlaceOrder = ({
4275
4728
  onAmountChange == null ? void 0 : onAmountChange(retryAmount);
4276
4729
  }
4277
4730
  }
4731
+ const originalSelectedCard = selectedRouteCardId ? orderedRouteCards.find((card) => card.id === selectedRouteCardId) : void 0;
4732
+ const selectedVenueQuote = isSell && (originalSelectedCard == null ? void 0 : originalSelectedCard.id.startsWith("live-solo-")) && originalSelectedCard.venue ? venueSellQuotes.quotes.find(
4733
+ (venueQuote) => {
4734
+ var _a3;
4735
+ return venueQuote.request.venue === originalSelectedCard.venue && ((_a3 = venueQuote.data) == null ? void 0 : _a3.quoteId) === originalSelectedCard.quoteData.quoteId;
4736
+ }
4737
+ ) : void 0;
4738
+ if (isSell && (originalSelectedCard == null ? void 0 : originalSelectedCard.id.startsWith("live-solo-")) && !selectedVenueQuote) {
4739
+ setSubmissionProgressState(null);
4740
+ setSubmissionFeedback({
4741
+ message: tradingLabels.selectedVenueUnavailable,
4742
+ tone: "error"
4743
+ });
4744
+ return;
4745
+ }
4278
4746
  setSubmissionProgressState({ phase: "finding-route" });
4279
4747
  try {
4280
4748
  let refetchedQuoteData;
4281
- if (useRemainderRoute && scopedSelectedOutcomeId) {
4749
+ if (selectedVenueQuote && useRemainderRoute && scopedSelectedOutcomeId) {
4750
+ const filledShares = Math.max(0, internalAmount - retryAmount);
4751
+ const remainingVenueShares = getRemainingVenueSellShares(
4752
+ selectedVenueQuote.request.availableShares,
4753
+ filledShares
4754
+ );
4755
+ const venueRetryAmount = clampSellSharesToAvailability(retryAmount, remainingVenueShares);
4756
+ if (venueRetryAmount <= 0) {
4757
+ setSubmissionProgressState(null);
4758
+ setSubmissionFeedback({
4759
+ message: tradingLabels.selectedVenueUnavailable,
4760
+ tone: "error"
4761
+ });
4762
+ return;
4763
+ }
4764
+ refetchedQuoteData = yield aggClient.getSmartRoute({
4765
+ venueMarketOutcomeId: scopedSelectedOutcomeId,
4766
+ sellShares: venueRetryAmount,
4767
+ slipCapBps: 1e6,
4768
+ tradeSide: "sell",
4769
+ mode: isPaperMode ? "paper" : void 0,
4770
+ allowedVenues: [selectedVenueQuote.request.venue]
4771
+ });
4772
+ } else if (selectedVenueQuote) {
4773
+ const refetchedQuoteResult = yield selectedVenueQuote.refetch();
4774
+ refetchedQuoteData = (_b2 = (_a2 = resolveRefetchedQuoteData(refetchedQuoteResult)) != null ? _a2 : selectedVenueQuote.data) != null ? _b2 : null;
4775
+ } else if (useRemainderRoute && scopedSelectedOutcomeId) {
4282
4776
  refetchedQuoteData = yield aggClient.getSmartRoute({
4283
4777
  venueMarketOutcomeId: scopedSelectedOutcomeId,
4284
4778
  maxSpend: isSell ? void 0 : retryAmount,
@@ -4291,18 +4785,31 @@ var PlaceOrder = ({
4291
4785
  });
4292
4786
  } else {
4293
4787
  const refetchedQuoteResult = yield smartRoute.refetch();
4294
- refetchedQuoteData = (_b2 = (_a2 = resolveRefetchedQuoteData(refetchedQuoteResult)) != null ? _a2 : smartRoute.data) != null ? _b2 : null;
4788
+ refetchedQuoteData = (_d2 = (_c2 = resolveRefetchedQuoteData(refetchedQuoteResult)) != null ? _c2 : smartRoute.data) != null ? _d2 : null;
4295
4789
  }
4296
4790
  if (!(refetchedQuoteData == null ? void 0 : refetchedQuoteData.quoteId)) {
4297
4791
  throw new Error(tradingLabels.quoteUnavailable);
4298
4792
  }
4299
- const refreshedCards = buildLiveRouteCards({
4793
+ const refreshedCards = selectedVenueQuote ? buildLiveSellRouteCards({
4794
+ labels: tradingLabels,
4795
+ smartQuoteData: null,
4796
+ venueQuotes: [
4797
+ {
4798
+ venue: selectedVenueQuote.request.venue,
4799
+ quoteData: refetchedQuoteData
4800
+ }
4801
+ ]
4802
+ }) : isSell ? buildLiveSellRouteCards({
4803
+ eventVenues: scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.venueMarkets.map((market) => market.venue),
4804
+ labels: tradingLabels,
4805
+ smartQuoteData: refetchedQuoteData,
4806
+ venueQuotes: []
4807
+ }) : buildLiveRouteCards({
4300
4808
  eventVenues: scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.venueMarkets.map((market) => market.venue),
4301
4809
  labels: tradingLabels,
4302
4810
  quoteData: refetchedQuoteData,
4303
4811
  tradeSide: internalTab
4304
4812
  });
4305
- const originalSelectedCard = selectedRouteCardId ? orderedRouteCards.find((card) => card.id === selectedRouteCardId) : void 0;
4306
4813
  const refreshedSelectedCard = selectedRouteCardId ? refreshedCards.find((card) => card.id === selectedRouteCardId) : void 0;
4307
4814
  const venueIdentityChanged = !!originalSelectedCard && !!refreshedSelectedCard && !routeCardsHaveSameVenueIdentity(originalSelectedCard, refreshedSelectedCard);
4308
4815
  if (selectedRouteCardId && (!refreshedSelectedCard || venueIdentityChanged)) {
@@ -4313,7 +4820,7 @@ var PlaceOrder = ({
4313
4820
  });
4314
4821
  return;
4315
4822
  }
4316
- yield handleExecuteQuote((_c2 = refreshedSelectedCard == null ? void 0 : refreshedSelectedCard.quoteData) != null ? _c2 : refetchedQuoteData);
4823
+ yield handleExecuteQuote((_e2 = refreshedSelectedCard == null ? void 0 : refreshedSelectedCard.quoteData) != null ? _e2 : refetchedQuoteData);
4317
4824
  } catch (error) {
4318
4825
  const errorMessage = normalizePlaceOrderErrorMessage({
4319
4826
  errorMessage: error instanceof Error ? error.message : String(error),
@@ -4343,11 +4850,12 @@ var PlaceOrder = ({
4343
4850
  scopedSelectedOutcomeId,
4344
4851
  selectedRouteCardId,
4345
4852
  smartRoute,
4346
- tradingLabels
4853
+ tradingLabels,
4854
+ venueSellQuotes.quotes
4347
4855
  ]);
4348
4856
  const resolvedStatusClassName = cn(classNames == null ? void 0 : classNames.root, className);
4349
4857
  if (isLoading) {
4350
- return /* @__PURE__ */ jsx5(
4858
+ return /* @__PURE__ */ jsx6(
4351
4859
  Skeleton,
4352
4860
  {
4353
4861
  ariaLabel: labels.common.loading,
@@ -4358,7 +4866,7 @@ var PlaceOrder = ({
4358
4866
  }
4359
4867
  if (submissionProgressState) {
4360
4868
  if (submissionProgressState.phase === "success" && submissionProgressState.summary) {
4361
- return /* @__PURE__ */ jsx5(
4869
+ return /* @__PURE__ */ jsx6(
4362
4870
  PlaceOrderSuccessView,
4363
4871
  {
4364
4872
  className: resolvedStatusClassName,
@@ -4370,7 +4878,7 @@ var PlaceOrder = ({
4370
4878
  );
4371
4879
  }
4372
4880
  if (submissionProgressState.phase === "failed") {
4373
- return /* @__PURE__ */ jsx5(
4881
+ return /* @__PURE__ */ jsx6(
4374
4882
  PlaceOrderFailureView,
4375
4883
  {
4376
4884
  className: resolvedStatusClassName,
@@ -4428,8 +4936,89 @@ var PlaceOrder = ({
4428
4936
  if (maxSellableShares <= 0) return;
4429
4937
  handleAmountChange(maxSellableShares);
4430
4938
  };
4939
+ const handleExecutionTypeChange = (nextType) => {
4940
+ if (!orderEligibility.canPlaceOrder) return;
4941
+ if (nextType === "limit" && !showLimitOrders) return;
4942
+ setExecutionType(nextType);
4943
+ };
4944
+ const applyLimitPrice = (nextPrice) => {
4945
+ const normalizedPrice = normalizeLimitPrice(nextPrice);
4946
+ setLimitPrice(normalizedPrice);
4947
+ setLimitPriceInputValue(formatLimitPriceInputValue(normalizedPrice));
4948
+ setLimitPriceInputError(null);
4949
+ };
4950
+ const handleLimitPriceInputChange = (event) => {
4951
+ const nextValue = event.target.value;
4952
+ setLimitPriceInputValue(nextValue);
4953
+ const parsedPrice = parseLimitPriceInputValue(nextValue);
4954
+ if (parsedPrice === null) {
4955
+ setLimitPriceInputError(tradingLabels.limitPriceInvalid);
4956
+ return;
4957
+ }
4958
+ setLimitPriceInputError(null);
4959
+ setLimitPrice(parsedPrice);
4960
+ };
4961
+ const handleLimitPriceInputBlur = () => {
4962
+ const parsedPrice = parseLimitPriceInputValue(limitPriceInputValue);
4963
+ if (parsedPrice === null) {
4964
+ setLimitPriceInputError(tradingLabels.limitPriceInvalid);
4965
+ return;
4966
+ }
4967
+ applyLimitPrice(parsedPrice);
4968
+ };
4969
+ const handleLimitPriceStep = (direction) => {
4970
+ applyLimitPrice(limitPrice + (direction === "increase" ? LIMIT_PRICE_STEP : -LIMIT_PRICE_STEP));
4971
+ };
4972
+ const handleLimitExpirationDateSelect = (date) => {
4973
+ setLimitExpirationDraftDate(date);
4974
+ };
4975
+ const handleLimitExpirationPickerOpenChange = (isOpen) => {
4976
+ setIsLimitExpirationPickerOpen(isOpen);
4977
+ setLimitExpirationPickerView("options");
4978
+ if (!isOpen) return;
4979
+ setLimitExpirationDraftDate(limitExpirationDate);
4980
+ setLimitExpirationDraftTime(limitExpirationTime);
4981
+ };
4982
+ const handleLimitExpirationTypeChange = (nextType) => {
4983
+ if (nextType === "CUSTOM") {
4984
+ setLimitExpirationPickerView("calendar");
4985
+ return;
4986
+ }
4987
+ setLimitExpirationType(nextType);
4988
+ setLimitExpirationPickerView("options");
4989
+ setIsLimitExpirationPickerOpen(false);
4990
+ };
4991
+ const handleLimitExpirationOptionKeyDown = (event, optionIndex) => {
4992
+ var _a2;
4993
+ const previousKeys = ["ArrowUp", "ArrowLeft"];
4994
+ const nextKeys = ["ArrowDown", "ArrowRight"];
4995
+ if (![...previousKeys, ...nextKeys, "Home", "End"].includes(event.key)) return;
4996
+ event.preventDefault();
4997
+ const nextIndex = event.key === "Home" ? 0 : event.key === "End" ? LIMIT_EXPIRATION_OPTION_COUNT - 1 : previousKeys.includes(event.key) ? (optionIndex - 1 + LIMIT_EXPIRATION_OPTION_COUNT) % LIMIT_EXPIRATION_OPTION_COUNT : (optionIndex + 1) % LIMIT_EXPIRATION_OPTION_COUNT;
4998
+ (_a2 = expirationOptionRefs.current[nextIndex]) == null ? void 0 : _a2.focus();
4999
+ };
5000
+ const handleLimitExpirationBack = () => {
5001
+ shouldFocusExpirationOptionsRef.current = true;
5002
+ setLimitExpirationPickerView("options");
5003
+ };
5004
+ const handleLimitExpirationCancel = () => {
5005
+ setLimitExpirationPickerView("options");
5006
+ setIsLimitExpirationPickerOpen(false);
5007
+ };
5008
+ const handleLimitExpirationApply = () => {
5009
+ if (!isFutureLimitExpiration(resolvedLimitExpirationDraftDate)) return;
5010
+ setLimitExpirationDate(resolvedLimitExpirationDraftDate);
5011
+ setLimitExpirationTime(limitExpirationDraftTime);
5012
+ setLimitExpirationType("CUSTOM");
5013
+ setLimitExpirationPickerView("options");
5014
+ setIsLimitExpirationPickerOpen(false);
5015
+ };
4431
5016
  const handleDepositRequiredClick = () => {
4432
5017
  if (!isInsufficientBalance) return;
5018
+ if (isKalshiBalanceInsufficient) {
5019
+ setIsFundKalshiModalOpen(true);
5020
+ return;
5021
+ }
4433
5022
  requestAggDepositModalOpen();
4434
5023
  };
4435
5024
  const handleTabKeyDown = (event, currentTab) => {
@@ -4445,6 +5034,7 @@ var PlaceOrder = ({
4445
5034
  };
4446
5035
  const handlePrimaryAction = () => __async(null, null, function* () {
4447
5036
  var _a2, _b2, _c2;
5037
+ if (executionType === "limit" && !showLimitOrders) return;
4448
5038
  if (!orderEligibility.canPlaceOrder) {
4449
5039
  setSubmissionFeedback({
4450
5040
  message: (_a2 = resolveOrderEligibilityMessage(labels, orderEligibility.reason)) != null ? _a2 : tradingLabels.orderFailed,
@@ -4452,10 +5042,15 @@ var PlaceOrder = ({
4452
5042
  });
4453
5043
  return;
4454
5044
  }
4455
- if (!selectedRouteCard) return;
5045
+ if (!isLimitOrder && !selectedRouteCard) return;
5046
+ const submissionLimitOrderPayload = isLimitOrder ? buildLimitOrderPayloadForSubmission() : null;
5047
+ if (isLimitOrder && !submissionLimitOrderPayload) return;
4456
5048
  setSubmissionFeedback(null);
4457
5049
  if (onBeforePrimaryAction) {
4458
- const beforeContext = isPaperMode ? { quoteId: (_b2 = selectedRouteCard.quoteData) == null ? void 0 : _b2.quoteId, mode: "paper" } : { quoteId: (_c2 = selectedRouteCard.quoteData) == null ? void 0 : _c2.quoteId };
5050
+ const beforeContext = isLimitOrder ? __spreadValues({
5051
+ orderType: "limit",
5052
+ limitOrder: submissionLimitOrderPayload != null ? submissionLimitOrderPayload : void 0
5053
+ }, isPaperMode ? { mode: "paper" } : {}) : isPaperMode ? { quoteId: (_b2 = selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData) == null ? void 0 : _b2.quoteId, mode: "paper" } : { quoteId: (_c2 = selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData) == null ? void 0 : _c2.quoteId };
4459
5054
  setIsBeforeActionPending(true);
4460
5055
  try {
4461
5056
  const proceed = yield onBeforePrimaryAction(beforeContext);
@@ -4482,6 +5077,10 @@ var PlaceOrder = ({
4482
5077
  }
4483
5078
  try {
4484
5079
  setSubmissionProgressState({ phase: "finding-route" });
5080
+ if (isLimitOrder) {
5081
+ yield handlePlaceLimitOrder(submissionLimitOrderPayload);
5082
+ return;
5083
+ }
4485
5084
  yield handleExecuteQuote(selectedRouteCard.quoteData);
4486
5085
  } catch (error) {
4487
5086
  const errorMessage = normalizePlaceOrderErrorMessage({
@@ -4496,11 +5095,11 @@ var PlaceOrder = ({
4496
5095
  }
4497
5096
  });
4498
5097
  if (isEndedWithoutKnownWinner || !orderEligibility.canPlaceOrder && resolvedReadOnlyTradingState.kind !== "open") {
4499
- return /* @__PURE__ */ jsx5(
5098
+ return /* @__PURE__ */ jsx6(
4500
5099
  PlaceOrderResolvedView,
4501
5100
  {
4502
5101
  tradingState: resolvedReadOnlyTradingState,
4503
- resolutionTimestamp: (_G = resolvedEventTradingState.resolvesAt) != null ? _G : resolvedReadOnlyTradingState.resolvesAt,
5102
+ resolutionTimestamp: (_X = resolvedEventTradingState.resolvesAt) != null ? _X : resolvedReadOnlyTradingState.resolvesAt,
4504
5103
  resolvedClaim,
4505
5104
  classNames,
4506
5105
  className,
@@ -4508,8 +5107,8 @@ var PlaceOrder = ({
4508
5107
  }
4509
5108
  );
4510
5109
  }
4511
- return /* @__PURE__ */ jsxs4(Fragment2, { children: [
4512
- /* @__PURE__ */ jsxs4(
5110
+ return /* @__PURE__ */ jsxs5(Fragment2, { children: [
5111
+ /* @__PURE__ */ jsxs5(
4513
5112
  Card,
4514
5113
  {
4515
5114
  className: cn(
@@ -4526,65 +5125,121 @@ var PlaceOrder = ({
4526
5125
  headerTitle,
4527
5126
  onClose
4528
5127
  }),
4529
- /* @__PURE__ */ jsxs4("div", { className: cn("agg-order-panel-content flex flex-col gap-6", classNames == null ? void 0 : classNames.content), children: [
4530
- /* @__PURE__ */ jsx5(
5128
+ /* @__PURE__ */ jsxs5("div", { className: cn("agg-order-panel-content flex flex-col gap-6", classNames == null ? void 0 : classNames.content), children: [
5129
+ /* @__PURE__ */ jsxs5(
4531
5130
  "div",
4532
5131
  {
4533
5132
  className: "agg-order-tabs flex items-end border-b border-agg-separator",
4534
5133
  role: "tablist",
4535
5134
  "aria-label": labels.common.tabsAria,
4536
5135
  children: [
4537
- { value: "buy", label: tradingLabels.buy, ref: buyTabRef },
4538
- { value: "sell", label: tradingLabels.sell, ref: sellTabRef }
4539
- ].map((tabItem) => {
4540
- const isActive = internalTab === tabItem.value;
4541
- return /* @__PURE__ */ jsxs4(
4542
- "button",
5136
+ /* @__PURE__ */ jsx6("div", { className: "flex min-w-0 flex-1 items-end", children: [
5137
+ { value: "buy", label: tradingLabels.buy, ref: buyTabRef },
5138
+ { value: "sell", label: tradingLabels.sell, ref: sellTabRef }
5139
+ ].map((tabItem) => {
5140
+ const isActive = internalTab === tabItem.value;
5141
+ return /* @__PURE__ */ jsxs5(
5142
+ "button",
5143
+ {
5144
+ ref: tabItem.ref,
5145
+ type: "button",
5146
+ role: "tab",
5147
+ "aria-selected": isActive,
5148
+ tabIndex: isActive ? 0 : -1,
5149
+ className: cn(
5150
+ "agg-order-tab-trigger",
5151
+ "relative -mb-px cursor-pointer px-5 pb-2 text-agg-base leading-agg-6",
5152
+ "disabled:cursor-not-allowed disabled:opacity-60",
5153
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-0 focus-visible:ring-offset-agg-secondary",
5154
+ isActive ? "text-agg-primary" : "text-agg-foreground",
5155
+ getMotionClassName(
5156
+ enableAnimations,
5157
+ "transition-[color,opacity] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"
5158
+ )
5159
+ ),
5160
+ disabled: !orderEligibility.canPlaceOrder,
5161
+ onClick: () => handleTabChange(tabItem.value),
5162
+ onKeyDown: (event) => handleTabKeyDown(event, tabItem.value),
5163
+ children: [
5164
+ tabItem.label,
5165
+ /* @__PURE__ */ jsx6(
5166
+ "span",
5167
+ {
5168
+ "aria-hidden": "true",
5169
+ className: cn(
5170
+ "agg-order-tab-indicator",
5171
+ "pointer-events-none absolute inset-x-0 bottom-0 h-0.5 rounded-t-agg-sm bg-agg-primary",
5172
+ isActive ? "opacity-100" : "opacity-0",
5173
+ getMotionClassName(
5174
+ enableAnimations,
5175
+ "transition-opacity duration-200 ease-in-out"
5176
+ )
5177
+ )
5178
+ }
5179
+ )
5180
+ ]
5181
+ },
5182
+ tabItem.value
5183
+ );
5184
+ }) }),
5185
+ showLimitOrders ? /* @__PURE__ */ jsxs5(
5186
+ DropdownMenu.Root,
4543
5187
  {
4544
- ref: tabItem.ref,
4545
- type: "button",
4546
- role: "tab",
4547
- "aria-selected": isActive,
4548
- tabIndex: isActive ? 0 : -1,
4549
- className: cn(
4550
- "agg-order-tab-trigger",
4551
- "relative -mb-px cursor-pointer px-5 pb-2 text-agg-base leading-agg-6",
4552
- "disabled:cursor-not-allowed disabled:opacity-60",
4553
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-0 focus-visible:ring-offset-agg-secondary",
4554
- isActive ? "text-agg-primary" : "text-agg-foreground",
4555
- getMotionClassName(
4556
- enableAnimations,
4557
- "transition-[color,opacity] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"
4558
- )
4559
- ),
4560
- disabled: !orderEligibility.canPlaceOrder,
4561
- onClick: () => handleTabChange(tabItem.value),
4562
- onKeyDown: (event) => handleTabKeyDown(event, tabItem.value),
5188
+ open: isExecutionTypeMenuOpen,
5189
+ onOpenChange: setIsExecutionTypeMenuOpen,
4563
5190
  children: [
4564
- tabItem.label,
4565
- /* @__PURE__ */ jsx5(
4566
- "span",
5191
+ /* @__PURE__ */ jsx6(DropdownMenu.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs5(
5192
+ "button",
4567
5193
  {
4568
- "aria-hidden": "true",
5194
+ ref: executionTypeTriggerRef,
5195
+ type: "button",
4569
5196
  className: cn(
4570
- "agg-order-tab-indicator",
4571
- "pointer-events-none absolute inset-x-0 bottom-0 h-0.5 rounded-t-agg-sm bg-agg-primary",
4572
- isActive ? "opacity-100" : "opacity-0",
4573
- getMotionClassName(
4574
- enableAnimations,
4575
- "transition-opacity duration-200 ease-in-out"
4576
- )
5197
+ "agg-order-type-trigger mb-2 flex cursor-pointer items-center gap-2 rounded-agg-sm px-2 py-1 text-agg-base leading-agg-6 text-agg-foreground",
5198
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-0 focus-visible:ring-offset-agg-secondary"
5199
+ ),
5200
+ "aria-label": tradingLabels.orderTypeAria,
5201
+ children: [
5202
+ /* @__PURE__ */ jsx6("span", { children: isLimitOrder ? tradingLabels.orderTypeLimit : tradingLabels.orderTypeMarket }),
5203
+ /* @__PURE__ */ jsx6(Icon, { name: "chevron-down", size: "small", className: "h-4 w-4", "aria-hidden": true })
5204
+ ]
5205
+ }
5206
+ ) }),
5207
+ /* @__PURE__ */ jsx6(
5208
+ DropdownMenu.Portal,
5209
+ {
5210
+ container: resolvePlaceOrderPortalContainer(executionTypeTriggerRef.current),
5211
+ children: /* @__PURE__ */ jsx6(
5212
+ DropdownMenu.Content,
5213
+ {
5214
+ align: "end",
5215
+ sideOffset: 8,
5216
+ className: "z-50 min-w-[140px] rounded-agg-lg border border-agg-separator bg-agg-secondary p-1 shadow-[0_8px_16px_rgba(0,0,0,0.12)]",
5217
+ children: [
5218
+ { value: "market", label: tradingLabels.orderTypeMarket },
5219
+ { value: "limit", label: tradingLabels.orderTypeLimit }
5220
+ ].map((item) => /* @__PURE__ */ jsx6(
5221
+ DropdownMenu.Item,
5222
+ {
5223
+ className: cn(
5224
+ "cursor-pointer rounded-agg-sm px-3 py-2 text-agg-sm leading-agg-5 text-agg-foreground outline-none hover:bg-agg-secondary-hover focus:bg-agg-secondary-hover",
5225
+ executionType === item.value && "font-agg-bold text-agg-primary"
5226
+ ),
5227
+ onSelect: () => handleExecutionTypeChange(item.value),
5228
+ children: item.label
5229
+ },
5230
+ item.value
5231
+ ))
5232
+ }
4577
5233
  )
4578
5234
  }
4579
5235
  )
4580
5236
  ]
4581
- },
4582
- tabItem.value
4583
- );
4584
- })
5237
+ }
5238
+ ) : null
5239
+ ]
4585
5240
  }
4586
5241
  ),
4587
- outcomes.length >= 2 ? /* @__PURE__ */ jsx5("div", { className: "agg-outcomes flex w-full max-w-full gap-2", children: outcomes.map((outcome, index) => {
5242
+ outcomes.length >= 2 ? /* @__PURE__ */ jsx6("div", { className: "agg-outcomes flex w-full max-w-full gap-2", children: outcomes.map((outcome, index) => {
4588
5243
  var _a2, _b2, _c2;
4589
5244
  const price = getDisplayOutcomePrice({
4590
5245
  outcomeId: outcome.id,
@@ -4598,7 +5253,7 @@ var PlaceOrder = ({
4598
5253
  const isActive = outcome.id === scopedSelectedOutcomeId;
4599
5254
  const isPositive = resolveIsPositiveOutcome(outcome, index);
4600
5255
  const isPriceLoading = clusterMidpointResult.isLoading && price == null;
4601
- return /* @__PURE__ */ jsxs4(
5256
+ return /* @__PURE__ */ jsxs5(
4602
5257
  "button",
4603
5258
  {
4604
5259
  "data-id": outcome.id,
@@ -4618,7 +5273,7 @@ var PlaceOrder = ({
4618
5273
  disabled: !orderEligibility.canPlaceOrder || isResolvedOutcomeCtaLocked,
4619
5274
  onClick: () => handleOutcomeChange(outcome.id),
4620
5275
  children: [
4621
- /* @__PURE__ */ jsx5(
5276
+ /* @__PURE__ */ jsx6(
4622
5277
  Typography,
4623
5278
  {
4624
5279
  as: "span",
@@ -4627,7 +5282,7 @@ var PlaceOrder = ({
4627
5282
  children: (_c2 = outcome.title) != null ? _c2 : outcome.label
4628
5283
  }
4629
5284
  ),
4630
- isPriceLoading ? /* @__PURE__ */ jsx5(
5285
+ isPriceLoading ? /* @__PURE__ */ jsx6(
4631
5286
  "span",
4632
5287
  {
4633
5288
  "aria-hidden": "true",
@@ -4636,18 +5291,66 @@ var PlaceOrder = ({
4636
5291
  "h-4 w-10 shrink-0 rounded-agg-sm bg-agg-separator animate-pulse"
4637
5292
  )
4638
5293
  }
4639
- ) : /* @__PURE__ */ jsx5(Typography, { as: "span", variant: isActive ? "body-strong" : "body", children: formatProbabilityCents(price) })
5294
+ ) : /* @__PURE__ */ jsx6(Typography, { as: "span", variant: isActive ? "body-strong" : "body", children: formatProbabilityCents(price) })
4640
5295
  ]
4641
5296
  },
4642
5297
  outcome.id
4643
5298
  );
4644
5299
  }) }) : null,
4645
- /* @__PURE__ */ jsxs4("div", { className: "agg-order-amount-section flex items-start justify-between gap-4", children: [
4646
- /* @__PURE__ */ jsxs4("div", { className: "agg-order-amount-meta flex flex-col", children: [
4647
- /* @__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) }),
4648
- 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: [
4649
- /* @__PURE__ */ jsx5("span", { className: "whitespace-pre", children: displayedCurrentSellableSharesLabel }),
4650
- displayedCurrentSellableShares > 0 ? /* @__PURE__ */ jsx5(
5300
+ isLimitOrder ? /* @__PURE__ */ jsxs5("div", { className: "agg-limit-price-section flex items-center justify-between gap-4", children: [
5301
+ /* @__PURE__ */ jsx6("p", { className: "text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: tradingLabels.limitPrice }),
5302
+ /* @__PURE__ */ jsxs5("div", { className: "flex min-w-0 flex-col items-end gap-1", children: [
5303
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2", children: [
5304
+ /* @__PURE__ */ jsxs5("label", { className: "relative flex items-center", children: [
5305
+ /* @__PURE__ */ jsx6(
5306
+ "input",
5307
+ {
5308
+ type: "text",
5309
+ inputMode: "decimal",
5310
+ "aria-label": tradingLabels.limitPriceInputAria,
5311
+ "aria-invalid": Boolean(limitPriceInputError),
5312
+ value: limitPriceInputValue,
5313
+ onChange: handleLimitPriceInputChange,
5314
+ onBlur: handleLimitPriceInputBlur,
5315
+ className: cn(
5316
+ "h-9 w-[108px] rounded-agg-sm bg-transparent pr-5 text-right text-agg-3xl font-agg-bold leading-agg-9 text-agg-foreground outline-none",
5317
+ "focus-visible:ring-2 focus-visible:ring-agg-primary",
5318
+ limitPriceInputError && "text-agg-error focus-visible:ring-agg-error"
5319
+ )
5320
+ }
5321
+ ),
5322
+ /* @__PURE__ */ jsx6("span", { className: "pointer-events-none absolute right-1 text-agg-3xl font-agg-bold leading-agg-9 text-agg-foreground", children: "\xA2" })
5323
+ ] }),
5324
+ /* @__PURE__ */ jsx6(
5325
+ "button",
5326
+ {
5327
+ type: "button",
5328
+ className: "flex size-8 cursor-pointer items-center justify-center rounded-agg-lg bg-agg-secondary-hover text-agg-foreground hover:bg-agg-tertiary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary",
5329
+ "aria-label": tradingLabels.limitPriceDecreaseAria,
5330
+ onClick: () => handleLimitPriceStep("decrease"),
5331
+ children: /* @__PURE__ */ jsx6(Icon, { name: "minus", size: "small", className: "h-4 w-4", "aria-hidden": true })
5332
+ }
5333
+ ),
5334
+ /* @__PURE__ */ jsx6(
5335
+ "button",
5336
+ {
5337
+ type: "button",
5338
+ className: "flex size-8 cursor-pointer items-center justify-center rounded-agg-lg bg-agg-secondary-hover text-agg-foreground hover:bg-agg-tertiary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary",
5339
+ "aria-label": tradingLabels.limitPriceIncreaseAria,
5340
+ onClick: () => handleLimitPriceStep("increase"),
5341
+ children: /* @__PURE__ */ jsx6(Icon, { name: "plus", size: "small", className: "h-4 w-4", "aria-hidden": true })
5342
+ }
5343
+ )
5344
+ ] }),
5345
+ limitPriceInputError ? /* @__PURE__ */ jsx6("p", { className: "max-w-[220px] text-right text-agg-xs leading-agg-4 text-agg-error", children: limitPriceInputError }) : null
5346
+ ] })
5347
+ ] }) : null,
5348
+ /* @__PURE__ */ jsxs5("div", { className: "agg-order-amount-section flex items-start justify-between gap-4", children: [
5349
+ /* @__PURE__ */ jsxs5("div", { className: "agg-order-amount-meta flex flex-col", children: [
5350
+ /* @__PURE__ */ jsx6("p", { className: "agg-order-amount-label text-agg-base font-agg-bold leading-agg-6 text-agg-foreground whitespace-nowrap", children: tradingLabels.amount(internalTab) }),
5351
+ isAuthenticated ? isSell ? /* @__PURE__ */ jsx6("div", { className: "agg-balance-value flex items-baseline gap-1.5 text-agg-sm leading-agg-5 text-agg-muted-foreground", children: isCurrentSellableSharesLoading ? /* @__PURE__ */ jsx6(LoadingIcon, { size: "small" }) : /* @__PURE__ */ jsxs5(Fragment3, { children: [
5352
+ /* @__PURE__ */ jsx6("span", { className: "whitespace-pre", children: displayedCurrentSellableSharesLabel }),
5353
+ displayedCurrentSellableShares > 0 ? /* @__PURE__ */ jsx6(
4651
5354
  "button",
4652
5355
  {
4653
5356
  type: "button",
@@ -4663,14 +5366,15 @@ var PlaceOrder = ({
4663
5366
  children: tradingLabels.maxShares
4664
5367
  }
4665
5368
  ) : null
4666
- ] }) }) : /* @__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
5369
+ ] }) }) : /* @__PURE__ */ jsx6("p", { className: "agg-balance-value flex items-center gap-2 text-agg-sm leading-agg-5 text-agg-muted-foreground", children: isBalanceLoading ? /* @__PURE__ */ jsx6(LoadingIcon, { size: "small" }) : tradingLabels.balance(formatUsd(displayedBalance)) }) : null
4667
5370
  ] }),
4668
- /* @__PURE__ */ jsx5(
5371
+ /* @__PURE__ */ jsx6(
4669
5372
  CurrencyInput,
4670
5373
  {
4671
5374
  value: internalAmount,
4672
5375
  onChange: handleAmountChange,
4673
5376
  ariaLabel: tradingLabels.amount(internalTab),
5377
+ max: isLimitOrder && !isSell && isAuthenticated && !isBalanceLoading ? totalBalance : void 0,
4674
5378
  isInvalid: isInsufficientBalance || isBelowMinimum,
4675
5379
  disabled: !orderEligibility.canPlaceOrder,
4676
5380
  prefix: internalTab === "buy" ? "$" : "",
@@ -4685,9 +5389,9 @@ var PlaceOrder = ({
4685
5389
  }
4686
5390
  )
4687
5391
  ] }),
4688
- showFeesBreakdown && hasEnteredAmount && !isBelowMinimum && estimatedFeesValue ? /* @__PURE__ */ jsxs4("div", { className: "agg-order-fees-section flex items-center justify-between gap-4", children: [
4689
- /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-1.5", children: [
4690
- /* @__PURE__ */ jsx5(
5392
+ showFeesBreakdown && hasEnteredAmount && !isBelowMinimum && estimatedFeesValue ? /* @__PURE__ */ jsxs5("div", { className: "agg-order-fees-section flex items-center justify-between gap-4", children: [
5393
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-1.5", children: [
5394
+ /* @__PURE__ */ jsx6(
4691
5395
  Typography,
4692
5396
  {
4693
5397
  variant: "text-sm",
@@ -4695,7 +5399,7 @@ var PlaceOrder = ({
4695
5399
  children: tradingLabels.estimatedFees
4696
5400
  }
4697
5401
  ),
4698
- feeBreakdownRows.length > 0 ? /* @__PURE__ */ jsx5(
5402
+ feeBreakdownRows.length > 0 ? /* @__PURE__ */ jsx6(
4699
5403
  Tooltip,
4700
5404
  {
4701
5405
  "aria-label": tradingLabels.estimatedFeesTooltipAria,
@@ -4707,13 +5411,13 @@ var PlaceOrder = ({
4707
5411
  icon: "h-3 w-3 text-agg-muted-foreground",
4708
5412
  trigger: "h-3 w-3 text-agg-muted-foreground"
4709
5413
  },
4710
- content: /* @__PURE__ */ jsx5("div", { className: "flex w-full flex-col gap-2", children: feeBreakdownRows.map((row) => /* @__PURE__ */ jsxs4(
5414
+ content: /* @__PURE__ */ jsx6("div", { className: "flex w-full flex-col gap-2", children: feeBreakdownRows.map((row) => /* @__PURE__ */ jsxs5(
4711
5415
  "div",
4712
5416
  {
4713
5417
  className: "flex items-center justify-between gap-3 text-agg-sm font-agg-normal leading-agg-5 text-agg-foreground",
4714
5418
  children: [
4715
- /* @__PURE__ */ jsx5("span", { children: row.label }),
4716
- row.kind === "badge" ? /* @__PURE__ */ jsx5(
5419
+ /* @__PURE__ */ jsx6("span", { children: row.label }),
5420
+ row.kind === "badge" ? /* @__PURE__ */ jsx6(
4717
5421
  "span",
4718
5422
  {
4719
5423
  className: cn(
@@ -4723,7 +5427,7 @@ var PlaceOrder = ({
4723
5427
  ),
4724
5428
  children: row.badgeLabel
4725
5429
  }
4726
- ) : /* @__PURE__ */ jsx5("span", { className: "text-right", children: row.value })
5430
+ ) : /* @__PURE__ */ jsx6("span", { className: "text-right", children: row.value })
4727
5431
  ]
4728
5432
  },
4729
5433
  row.label
@@ -4731,12 +5435,12 @@ var PlaceOrder = ({
4731
5435
  }
4732
5436
  ) : null
4733
5437
  ] }),
4734
- /* @__PURE__ */ jsx5("p", { className: "text-agg-sm leading-agg-5 text-agg-foreground", children: estimatedFeesValue })
5438
+ /* @__PURE__ */ jsx6("p", { className: "text-agg-sm leading-agg-5 text-agg-foreground", children: estimatedFeesValue })
4735
5439
  ] }) : null,
4736
- shouldShowSmartRouting ? /* @__PURE__ */ jsxs4("div", { className: "agg-route-panel flex flex-col gap-3", children: [
4737
- /* @__PURE__ */ jsxs4("div", { className: "agg-route-panel-header flex items-center justify-between gap-4", children: [
4738
- /* @__PURE__ */ jsx5("p", { className: "agg-route-panel-title text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: tradingLabels.smartRouting }),
4739
- shouldShowRouteToggle && !isRoutesExpanded ? /* @__PURE__ */ jsxs4(
5440
+ shouldShowSmartRouting ? /* @__PURE__ */ jsxs5("div", { className: "agg-route-panel flex flex-col gap-3", children: [
5441
+ /* @__PURE__ */ jsxs5("div", { className: "agg-route-panel-header flex items-center justify-between gap-4", children: [
5442
+ /* @__PURE__ */ jsx6("p", { className: "agg-route-panel-title text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: tradingLabels.smartRouting }),
5443
+ shouldShowRouteToggle && !isRoutesExpanded ? /* @__PURE__ */ jsxs5(
4740
5444
  "button",
4741
5445
  {
4742
5446
  type: "button",
@@ -4744,8 +5448,8 @@ var PlaceOrder = ({
4744
5448
  "aria-label": tradingLabels.viewAllRoutes(orderedRouteCards.length),
4745
5449
  onClick: () => setIsRoutesExpanded((currentValue) => !currentValue),
4746
5450
  children: [
4747
- /* @__PURE__ */ jsx5("span", { children: tradingLabels.viewAllRoutes(orderedRouteCards.length) }),
4748
- /* @__PURE__ */ jsx5(
5451
+ /* @__PURE__ */ jsx6("span", { children: tradingLabels.viewAllRoutes(orderedRouteCards.length) }),
5452
+ /* @__PURE__ */ jsx6(
4749
5453
  Icon,
4750
5454
  {
4751
5455
  name: "chevron-down",
@@ -4758,11 +5462,11 @@ var PlaceOrder = ({
4758
5462
  }
4759
5463
  ) : null
4760
5464
  ] }),
4761
- /* @__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: [
4762
- /* @__PURE__ */ jsx5(PlaceOrderRouteCardSkeleton, {}),
4763
- /* @__PURE__ */ jsx5(PlaceOrderRouteCardSkeleton, {})
5465
+ /* @__PURE__ */ jsx6("div", { className: "agg-route-list flex flex-col gap-2", children: isQuoteLoading ? /* @__PURE__ */ jsxs5("div", { className: "agg-route-loading flex flex-col gap-2", "aria-hidden": "true", children: [
5466
+ /* @__PURE__ */ jsx6(PlaceOrderRouteCardSkeleton, {}),
5467
+ /* @__PURE__ */ jsx6(PlaceOrderRouteCardSkeleton, {})
4764
5468
  ] }) : visibleRouteCards.length > 0 ? visibleRouteCards.map((card) => {
4765
- return /* @__PURE__ */ jsx5(Fragment2, { children: renderRouteCard({
5469
+ return /* @__PURE__ */ jsx6(Fragment2, { children: renderRouteCard({
4766
5470
  card,
4767
5471
  enableAnimations,
4768
5472
  isExpanded: card.kind === "split" ? isSplitDetailOpen : isRoutesExpanded,
@@ -4772,15 +5476,206 @@ var PlaceOrder = ({
4772
5476
  }) }, card.id);
4773
5477
  }) : null })
4774
5478
  ] }) : null,
4775
- hasEnteredAmount && selectedRouteCard && !isQuoteLoading && !isBelowMinimum && orderEligibility.canPlaceOrder ? /* @__PURE__ */ jsxs4("div", { className: "agg-order-summary flex items-start justify-between gap-4", children: [
4776
- /* @__PURE__ */ jsxs4("div", { className: "agg-order-summary-meta flex flex-col", children: [
4777
- /* @__PURE__ */ jsx5("p", { className: "agg-order-summary-label text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: tradingLabels.toWin(internalTab) }),
4778
- /* @__PURE__ */ jsx5("p", { className: "agg-order-summary-hint text-agg-sm leading-agg-5 text-agg-muted-foreground", children: displayedToWinHint })
5479
+ isLimitOrder ? /* @__PURE__ */ jsxs5("div", { className: "agg-limit-expiration-section flex items-center justify-between gap-4", children: [
5480
+ /* @__PURE__ */ jsx6("p", { className: "text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: tradingLabels.expiration }),
5481
+ /* @__PURE__ */ jsxs5(
5482
+ Popover.Root,
5483
+ {
5484
+ open: isLimitExpirationPickerOpen,
5485
+ onOpenChange: handleLimitExpirationPickerOpenChange,
5486
+ children: [
5487
+ /* @__PURE__ */ jsx6(Popover.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs5(
5488
+ "button",
5489
+ {
5490
+ ref: expirationTriggerRef,
5491
+ type: "button",
5492
+ className: "flex min-w-0 cursor-pointer items-center justify-end gap-2 text-right text-agg-base leading-agg-6 text-agg-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary",
5493
+ "aria-label": tradingLabels.expirationMenuAria,
5494
+ children: [
5495
+ /* @__PURE__ */ jsx6(Icon, { name: "calendar", size: "small", className: "h-4 w-4 shrink-0", "aria-hidden": true }),
5496
+ /* @__PURE__ */ jsx6("span", { className: "min-w-0 truncate", children: limitExpirationType === "GTC" ? tradingLabels.expirationGoodTilCanceled : limitExpirationType === "FIVE_MINUTES" ? tradingLabels.expirationFiveMinutes : limitExpirationType === "ONE_HOUR" ? tradingLabels.expirationOneHour : limitExpirationType === "END_OF_DAY" ? tradingLabels.expirationEndOfDay : resolvedCustomExpirationDate ? dayjs(resolvedCustomExpirationDate).format(
5497
+ "MMM D, YYYY [at] HH:mm"
5498
+ ) : tradingLabels.expirationCustom }),
5499
+ /* @__PURE__ */ jsx6(
5500
+ Icon,
5501
+ {
5502
+ name: isLimitExpirationPickerOpen ? "chevron-up" : "chevron-down",
5503
+ size: "small",
5504
+ className: "h-4 w-4 shrink-0",
5505
+ "aria-hidden": true
5506
+ }
5507
+ )
5508
+ ]
5509
+ }
5510
+ ) }),
5511
+ /* @__PURE__ */ jsx6(
5512
+ Popover.Portal,
5513
+ {
5514
+ container: resolvePlaceOrderPortalContainer(expirationTriggerRef.current),
5515
+ children: /* @__PURE__ */ jsx6(
5516
+ Popover.Content,
5517
+ {
5518
+ align: "end",
5519
+ sideOffset: 8,
5520
+ collisionPadding: 16,
5521
+ role: "dialog",
5522
+ "aria-label": tradingLabels.expirationMenuAria,
5523
+ className: "z-50 max-h-[calc(100dvh-2rem)] w-[min(312px,calc(100vw-2rem))] overflow-y-auto rounded-agg-xl border border-agg-separator bg-agg-secondary p-0 shadow-[0_8px_16px_rgba(0,0,0,0.20)]",
5524
+ children: limitExpirationPickerView === "calendar" ? /* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-3 p-4", children: [
5525
+ /* @__PURE__ */ jsx6(
5526
+ Button,
5527
+ {
5528
+ variant: "tertiary",
5529
+ size: "small",
5530
+ className: "w-fit px-0",
5531
+ prefix: /* @__PURE__ */ jsx6(
5532
+ Icon,
5533
+ {
5534
+ name: "chevron-left",
5535
+ size: "small",
5536
+ className: "h-4 w-4",
5537
+ "aria-hidden": true
5538
+ }
5539
+ ),
5540
+ onClick: handleLimitExpirationBack,
5541
+ children: tradingLabels.expirationOptions
5542
+ }
5543
+ ),
5544
+ /* @__PURE__ */ jsx6(
5545
+ Calendar,
5546
+ {
5547
+ mode: "single",
5548
+ autoFocus: true,
5549
+ selected: limitExpirationDraftDate,
5550
+ onSelect: handleLimitExpirationDateSelect,
5551
+ disabled: { before: dayjs().startOf("day").toDate() },
5552
+ "aria-label": tradingLabels.expirationDateAria,
5553
+ className: "border-0 p-0 shadow-none",
5554
+ classNames: {
5555
+ day: "flex h-10 min-w-0 items-center justify-center text-agg-sm leading-agg-5 text-agg-foreground"
5556
+ }
5557
+ }
5558
+ ),
5559
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-4", children: [
5560
+ /* @__PURE__ */ jsxs5("div", { className: "flex shrink-0 flex-col gap-0.5", children: [
5561
+ /* @__PURE__ */ jsx6(
5562
+ "label",
5563
+ {
5564
+ htmlFor: expirationTimeInputId,
5565
+ className: "text-agg-sm font-agg-bold leading-agg-5 text-agg-foreground",
5566
+ children: tradingLabels.expirationStartTime
5567
+ }
5568
+ ),
5569
+ /* @__PURE__ */ jsx6("span", { className: "text-agg-xs leading-agg-4 text-agg-foreground", children: tradingLabels.expirationStartTimeHint })
5570
+ ] }),
5571
+ /* @__PURE__ */ jsx6(
5572
+ "input",
5573
+ {
5574
+ id: expirationTimeInputId,
5575
+ type: "time",
5576
+ value: limitExpirationDraftTime,
5577
+ onChange: (event) => setLimitExpirationDraftTime(event.target.value),
5578
+ className: "h-10 min-w-0 flex-1 rounded-agg-sm border border-agg-separator bg-agg-secondary px-3 text-agg-base leading-agg-6 text-agg-foreground focus:outline-none focus:ring-2 focus:ring-agg-primary"
5579
+ }
5580
+ )
5581
+ ] }),
5582
+ /* @__PURE__ */ jsxs5("div", { className: "flex gap-2", children: [
5583
+ /* @__PURE__ */ jsx6(
5584
+ Button,
5585
+ {
5586
+ variant: "secondary",
5587
+ size: "small",
5588
+ className: "min-w-0 flex-1",
5589
+ onClick: handleLimitExpirationCancel,
5590
+ children: tradingLabels.expirationCancel
5591
+ }
5592
+ ),
5593
+ /* @__PURE__ */ jsx6(
5594
+ Button,
5595
+ {
5596
+ size: "small",
5597
+ className: "min-w-0 flex-1",
5598
+ disabled: !isLimitExpirationDraftValid,
5599
+ prefix: /* @__PURE__ */ jsx6(
5600
+ Icon,
5601
+ {
5602
+ name: "success-check",
5603
+ size: "small",
5604
+ className: "h-4 w-4",
5605
+ "aria-hidden": true
5606
+ }
5607
+ ),
5608
+ onClick: handleLimitExpirationApply,
5609
+ children: tradingLabels.expirationApply
5610
+ }
5611
+ )
5612
+ ] })
5613
+ ] }) : /* @__PURE__ */ jsx6(
5614
+ "div",
5615
+ {
5616
+ role: "radiogroup",
5617
+ className: "flex flex-col py-1",
5618
+ "aria-label": tradingLabels.expirationMenuAria,
5619
+ children: [
5620
+ {
5621
+ value: "GTC",
5622
+ label: tradingLabels.expirationGoodTilCanceled
5623
+ },
5624
+ {
5625
+ value: "FIVE_MINUTES",
5626
+ label: tradingLabels.expirationFiveMinutes
5627
+ },
5628
+ { value: "ONE_HOUR", label: tradingLabels.expirationOneHour },
5629
+ { value: "END_OF_DAY", label: tradingLabels.expirationEndOfDay },
5630
+ { value: "CUSTOM", label: tradingLabels.expirationCustom }
5631
+ ].map((item, optionIndex) => /* @__PURE__ */ jsxs5(
5632
+ "button",
5633
+ {
5634
+ ref: (element) => {
5635
+ expirationOptionRefs.current[optionIndex] = element;
5636
+ },
5637
+ type: "button",
5638
+ role: "radio",
5639
+ "aria-checked": limitExpirationType === item.value,
5640
+ tabIndex: limitExpirationType === item.value ? 0 : -1,
5641
+ className: cn(
5642
+ "relative flex min-h-11 cursor-pointer items-center px-4 py-2 text-left text-agg-sm leading-agg-5 text-agg-foreground hover:bg-agg-secondary-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-inset",
5643
+ limitExpirationType === item.value && "font-agg-bold"
5644
+ ),
5645
+ onClick: () => handleLimitExpirationTypeChange(item.value),
5646
+ onKeyDown: (event) => handleLimitExpirationOptionKeyDown(event, optionIndex),
5647
+ children: [
5648
+ limitExpirationType === item.value ? /* @__PURE__ */ jsx6(
5649
+ "span",
5650
+ {
5651
+ className: "absolute bottom-2 left-0 top-2 w-1 bg-agg-primary",
5652
+ "aria-hidden": true
5653
+ }
5654
+ ) : null,
5655
+ /* @__PURE__ */ jsx6("span", { className: "truncate", children: item.label })
5656
+ ]
5657
+ },
5658
+ item.value
5659
+ ))
5660
+ }
5661
+ )
5662
+ }
5663
+ )
5664
+ }
5665
+ )
5666
+ ]
5667
+ }
5668
+ )
5669
+ ] }) : null,
5670
+ hasEnteredAmount && (isLimitOrder ? limitOrderPayload : selectedRouteCard) && !isQuoteLoading && !isBelowMinimum && orderEligibility.canPlaceOrder ? /* @__PURE__ */ jsxs5("div", { className: "agg-order-summary flex items-start justify-between gap-4", children: [
5671
+ /* @__PURE__ */ jsxs5("div", { className: "agg-order-summary-meta flex flex-col", children: [
5672
+ /* @__PURE__ */ jsx6("p", { className: "agg-order-summary-label text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: tradingLabels.toWin(internalTab) }),
5673
+ /* @__PURE__ */ jsx6("p", { className: "agg-order-summary-hint text-agg-sm leading-agg-5 text-agg-muted-foreground", children: isLimitOrder ? displayedLimitToWinHint : displayedToWinHint })
4779
5674
  ] }),
4780
- /* @__PURE__ */ jsx5(
5675
+ /* @__PURE__ */ jsx6(
4781
5676
  NumberFlow,
4782
5677
  {
4783
- value: displayedToWinValue,
5678
+ value: isLimitOrder ? displayedLimitToWinValue : displayedToWinValue,
4784
5679
  locales: locale,
4785
5680
  format: {
4786
5681
  currency: "USD",
@@ -4792,7 +5687,7 @@ var PlaceOrder = ({
4792
5687
  }
4793
5688
  )
4794
5689
  ] }) : null,
4795
- /* @__PURE__ */ jsxs4(
5690
+ /* @__PURE__ */ jsxs5(
4796
5691
  "div",
4797
5692
  {
4798
5693
  className: cn(
@@ -4800,17 +5695,17 @@ var PlaceOrder = ({
4800
5695
  classNames == null ? void 0 : classNames.footer
4801
5696
  ),
4802
5697
  children: [
4803
- !shouldShowGeoBlockBanner ? /* @__PURE__ */ jsxs4("div", { className: "agg-order-alerts flex flex-col gap-3 empty:hidden mb-3", children: [
4804
- submissionFeedback ? /* @__PURE__ */ jsx5(
5698
+ !shouldShowGeoBlockBanner ? /* @__PURE__ */ jsxs5("div", { className: "agg-order-alerts flex flex-col gap-3 empty:hidden mb-3", children: [
5699
+ submissionFeedback ? /* @__PURE__ */ jsx6(
4805
5700
  InlineAlert,
4806
5701
  {
4807
5702
  tone: submissionFeedback.tone,
4808
5703
  message: submissionFeedback.message
4809
5704
  }
4810
5705
  ) : null,
4811
- !submissionFeedback && orderEligibility.canPlaceOrder && !isInsufficientBalance && isBelowMinimum ? /* @__PURE__ */ jsx5(InlineAlert, { tone: "error", message: belowMinimumMessage }) : null,
4812
- !submissionFeedback && orderEligibility.canPlaceOrder && !isInsufficientBalance && !isBelowMinimum && quoteStatus ? /* @__PURE__ */ jsx5(InlineAlert, { tone: quoteStatus.tone, message: quoteStatus.message }) : null,
4813
- !submissionFeedback && orderEligibility.canPlaceOrder && !isInsufficientBalance && !isBelowMinimum && !quoteStatus && isAuthenticated && hasEnteredAmount && smartRouteErrorMessage ? /* @__PURE__ */ jsx5(
5706
+ !submissionFeedback && orderEligibility.canPlaceOrder && !isInsufficientBalance && isBelowMinimum ? /* @__PURE__ */ jsx6(InlineAlert, { tone: "error", message: belowMinimumMessage }) : null,
5707
+ !submissionFeedback && orderEligibility.canPlaceOrder && !isInsufficientBalance && !isBelowMinimum && quoteStatus ? /* @__PURE__ */ jsx6(InlineAlert, { tone: quoteStatus.tone, message: quoteStatus.message }) : null,
5708
+ !submissionFeedback && orderEligibility.canPlaceOrder && !isInsufficientBalance && !isBelowMinimum && !quoteStatus && hasEnteredAmount && smartRouteErrorMessage ? /* @__PURE__ */ jsx6(
4814
5709
  InlineAlert,
4815
5710
  {
4816
5711
  tone: "error",
@@ -4822,14 +5717,14 @@ var PlaceOrder = ({
4822
5717
  }
4823
5718
  ) : null
4824
5719
  ] }) : null,
4825
- !submissionFeedback && !shouldShowGeoBlockBanner && orderEligibility.canPlaceOrder && shouldShowInsufficientBalanceAlert ? /* @__PURE__ */ jsxs4(
5720
+ !submissionFeedback && !shouldShowGeoBlockBanner && orderEligibility.canPlaceOrder && !needsKalshiConnection && shouldShowInsufficientBalanceAlert ? /* @__PURE__ */ jsxs5(
4826
5721
  "div",
4827
5722
  {
4828
5723
  className: "agg-order-insufficient-balance-alert flex items-center justify-center gap-2",
4829
5724
  role: "status",
4830
5725
  "aria-live": "polite",
4831
5726
  children: [
4832
- /* @__PURE__ */ jsx5(
5727
+ /* @__PURE__ */ jsx6(
4833
5728
  Icon,
4834
5729
  {
4835
5730
  name: "warning-filled",
@@ -4838,21 +5733,41 @@ var PlaceOrder = ({
4838
5733
  "aria-hidden": "true"
4839
5734
  }
4840
5735
  ),
4841
- /* @__PURE__ */ jsx5("span", { className: "text-agg-sm text-agg-foreground", children: tradingLabels.insufficientBalance })
5736
+ /* @__PURE__ */ jsx6("span", { className: "text-agg-sm text-agg-foreground", children: tradingLabels.insufficientBalance })
4842
5737
  ]
4843
5738
  }
4844
5739
  ) : null,
4845
- !submissionFeedback && !shouldShowGeoBlockBanner && isInsufficientBalance ? /* @__PURE__ */ jsx5(
5740
+ !submissionFeedback && !shouldShowGeoBlockBanner && needsKalshiConnection ? /* @__PURE__ */ jsx6(
5741
+ Button,
5742
+ {
5743
+ size: "large",
5744
+ variant: "primary",
5745
+ className: "agg-order-connect-kalshi h-12 w-full px-8 text-agg-base leading-agg-6 shadow-none",
5746
+ "aria-label": tradingLabels.connectKalshi,
5747
+ onClick: () => setIsConnectKalshiModalOpen(true),
5748
+ children: tradingLabels.connectKalshi
5749
+ }
5750
+ ) : needsKycVerification && !submissionFeedback && !shouldShowGeoBlockBanner ? /* @__PURE__ */ jsx6(
5751
+ Button,
5752
+ {
5753
+ size: "large",
5754
+ variant: "primary",
5755
+ className: "agg-order-kyc-action h-12 w-full px-8 text-agg-base leading-agg-6 shadow-none",
5756
+ "aria-label": verifyKalshiConnectionLabel,
5757
+ onClick: () => setIsConnectKalshiModalOpen(true),
5758
+ children: verifyKalshiConnectionLabel
5759
+ }
5760
+ ) : !submissionFeedback && !shouldShowGeoBlockBanner && isInsufficientBalance ? /* @__PURE__ */ jsx6(
4846
5761
  Button,
4847
5762
  {
4848
5763
  size: "large",
4849
5764
  variant: "primary",
4850
5765
  className: "agg-order-submit h-12 w-full px-8 text-agg-base leading-agg-6 shadow-none",
4851
- "aria-label": tradingLabels.deposit,
5766
+ "aria-label": isKalshiBalanceInsufficient ? tradingLabels.addFundsToKalshi : tradingLabels.deposit,
4852
5767
  onClick: handleDepositRequiredClick,
4853
- children: tradingLabels.deposit
5768
+ children: isKalshiBalanceInsufficient ? tradingLabels.addFundsToKalshi : tradingLabels.deposit
4854
5769
  }
4855
- ) : needsKycVerification && !submissionFeedback && !shouldShowGeoBlockBanner ? /* @__PURE__ */ jsx5(InitiateKycButton, { label: tradingLabels.kycRequired, onOpen: openVerifyModal }) : isQuoteLoading && !isActionLoading ? /* @__PURE__ */ jsx5(
5770
+ ) : isQuoteLoading && !isActionLoading ? /* @__PURE__ */ jsx6(
4856
5771
  Button,
4857
5772
  {
4858
5773
  size: "large",
@@ -4861,7 +5776,7 @@ var PlaceOrder = ({
4861
5776
  disabled: true,
4862
5777
  "aria-live": "polite",
4863
5778
  "aria-label": routeLoadingMessage != null ? routeLoadingMessage : labels.common.loading,
4864
- prefix: /* @__PURE__ */ jsx5(
5779
+ prefix: /* @__PURE__ */ jsx6(
4865
5780
  "span",
4866
5781
  {
4867
5782
  className: cn(
@@ -4873,7 +5788,7 @@ var PlaceOrder = ({
4873
5788
  ),
4874
5789
  children: routeLoadingMessage
4875
5790
  }
4876
- ) : !isAuthenticated ? /* @__PURE__ */ jsx5(
5791
+ ) : !isAuthenticated ? /* @__PURE__ */ jsx6(
4877
5792
  Button,
4878
5793
  {
4879
5794
  size: "large",
@@ -4884,7 +5799,7 @@ var PlaceOrder = ({
4884
5799
  onClick: requestAggAuthChooserOpen,
4885
5800
  children: tradingLabels.signInToTrade
4886
5801
  }
4887
- ) : /* @__PURE__ */ jsx5(
5802
+ ) : /* @__PURE__ */ jsx6(
4888
5803
  Button,
4889
5804
  {
4890
5805
  size: "large",
@@ -4899,13 +5814,13 @@ var PlaceOrder = ({
4899
5814
  children: actionLabel
4900
5815
  }
4901
5816
  ),
4902
- shouldShowLowLiquidityWarning ? /* @__PURE__ */ jsxs4(
5817
+ shouldShowLowLiquidityWarning ? /* @__PURE__ */ jsxs5(
4903
5818
  "div",
4904
5819
  {
4905
5820
  className: "agg-order-low-liquidity-warning flex w-full items-center gap-2 rounded-agg-lg bg-agg-warning/10 px-3 py-2",
4906
5821
  role: "status",
4907
5822
  children: [
4908
- /* @__PURE__ */ jsx5(
5823
+ /* @__PURE__ */ jsx6(
4909
5824
  Icon,
4910
5825
  {
4911
5826
  name: "warning-filled",
@@ -4914,12 +5829,12 @@ var PlaceOrder = ({
4914
5829
  "aria-hidden": "true"
4915
5830
  }
4916
5831
  ),
4917
- /* @__PURE__ */ jsx5("p", { className: "min-w-0 flex-1 wrap-break-word text-agg-sm leading-agg-5 text-agg-foreground", children: tradingLabels.lowLiquidityWarning })
5832
+ /* @__PURE__ */ jsx6("p", { className: "min-w-0 flex-1 wrap-break-word text-agg-sm leading-agg-5 text-agg-foreground", children: tradingLabels.lowLiquidityWarning })
4918
5833
  ]
4919
5834
  }
4920
5835
  ) : null,
4921
- !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: [
4922
- /* @__PURE__ */ jsx5(
5836
+ !shouldShowGeoBlockBanner && internalTab === "buy" && showFeesBreakdown ? /* @__PURE__ */ jsxs5("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: [
5837
+ /* @__PURE__ */ jsx6(
4923
5838
  Icon,
4924
5839
  {
4925
5840
  name: "shield-trust",
@@ -4928,10 +5843,10 @@ var PlaceOrder = ({
4928
5843
  "aria-hidden": "true"
4929
5844
  }
4930
5845
  ),
4931
- /* @__PURE__ */ jsx5(Typography, { variant: "text-xs-caps", className: "text-agg-primary", children: tradingLabels.platformFee })
5846
+ /* @__PURE__ */ jsx6(Typography, { variant: "text-xs-caps", className: "text-agg-primary", children: tradingLabels.platformFee })
4932
5847
  ] }) : null,
4933
- shouldShowGeoBlockBanner ? /* @__PURE__ */ jsx5(GeoBlockBanner, { termsUrl: AGG_TERMS_OF_SERVICE_URL }) : null,
4934
- !shouldShowGeoBlockBanner ? /* @__PURE__ */ jsx5("p", { className: "agg-order-disclaimer text-center text-agg-xs leading-agg-4 text-agg-muted-foreground", children: tradingLabels.disclaimer }) : null
5848
+ shouldShowGeoBlockBanner ? /* @__PURE__ */ jsx6(GeoBlockBanner, { termsUrl: AGG_TERMS_OF_SERVICE_URL }) : null,
5849
+ !shouldShowGeoBlockBanner ? /* @__PURE__ */ jsx6("p", { className: "agg-order-disclaimer text-center text-agg-xs leading-agg-4 text-agg-muted-foreground", children: tradingLabels.disclaimer }) : null
4935
5850
  ]
4936
5851
  }
4937
5852
  )
@@ -4939,37 +5854,15 @@ var PlaceOrder = ({
4939
5854
  ]
4940
5855
  }
4941
5856
  ),
4942
- /* @__PURE__ */ jsx5(
4943
- KycVerifyModal,
5857
+ /* @__PURE__ */ jsx6(
5858
+ ConnectKalshiModal,
4944
5859
  {
4945
- open: isKycVerifyModalOpen,
4946
- onOpenChange: (next) => {
4947
- if (!next) closeVerifyModal();
4948
- },
4949
- onStartVerification: startVerification,
4950
- isInitiating: isKycInitiating,
4951
- labels: {
4952
- title: tradingLabels.kycVerifyModalTitle,
4953
- description: tradingLabels.kycVerifyModalDescription,
4954
- startVerification: tradingLabels.kycStartVerification,
4955
- doItLater: tradingLabels.kycDoItLater
4956
- }
5860
+ open: isConnectKalshiModalOpen,
5861
+ onOpenChange: setIsConnectKalshiModalOpen,
5862
+ onVerify: handleVerifyKalshi
4957
5863
  }
4958
5864
  ),
4959
- /* @__PURE__ */ jsx5(
4960
- KycSuccessModal,
4961
- {
4962
- open: showKycSuccessModal,
4963
- onOpenChange: (next) => {
4964
- if (!next) closeSuccessModal();
4965
- },
4966
- labels: {
4967
- title: tradingLabels.kycSuccessTitle,
4968
- description: tradingLabels.kycSuccessDescription,
4969
- done: tradingLabels.kycSuccessDone
4970
- }
4971
- }
4972
- )
5865
+ /* @__PURE__ */ jsx6(FundKalshiModal, { open: isFundKalshiModalOpen, onOpenChange: setIsFundKalshiModalOpen })
4973
5866
  ] });
4974
5867
  };
4975
5868
  PlaceOrder.displayName = "PlaceOrder";
@@ -4980,34 +5873,34 @@ import {
4980
5873
  invalidateBalanceQueries as invalidateBalanceQueries2,
4981
5874
  invalidatePositionQueries as invalidatePositionQueries2,
4982
5875
  invalidateUserActivityQueries,
4983
- useLabels as useLabels2,
5876
+ useLabels as useLabels3,
4984
5877
  useQueryClient as useQueryClient2,
4985
5878
  useRedeem,
4986
5879
  useRedeemLifecycles
4987
5880
  } from "@agg-build/hooks";
4988
- import { useCallback as useCallback4, useEffect as useEffect4, useMemo as useMemo3, useRef as useRef4, useState as useState4 } from "react";
5881
+ import { useCallback as useCallback3, useEffect as useEffect3, useMemo as useMemo2, useRef as useRef3, useState as useState3 } from "react";
4989
5882
  var toClaimError = (err) => {
4990
5883
  if (err instanceof Error) return err;
4991
5884
  return new Error(String(err));
4992
5885
  };
4993
5886
  function useClaimWinnings(options = {}) {
4994
5887
  const { onClaim, onClaimResult, onClaimSubmitError, externalClaimingKeys } = options;
4995
- const labels = useLabels2();
5888
+ const labels = useLabels3();
4996
5889
  const claimNotificationLabels = labels.notifications.claim;
4997
5890
  const toastCtx = useOptionalToast();
4998
5891
  const queryClient = useQueryClient2();
4999
5892
  const redeemMutation = useRedeem();
5000
- const [activeRedeems, setActiveRedeems] = useState4({});
5001
- const activeClaimKeysRef = useRef4(/* @__PURE__ */ new Set());
5002
- const pendingClaimToastIdsRef = useRef4({});
5003
- const submittedClaimToastKeysRef = useRef4(/* @__PURE__ */ new Set());
5004
- const [submittingClaimKeys, setSubmittingClaimKeys] = useState4({});
5005
- const lifecycleInputs = useMemo3(
5893
+ const [activeRedeems, setActiveRedeems] = useState3({});
5894
+ const activeClaimKeysRef = useRef3(/* @__PURE__ */ new Set());
5895
+ const pendingClaimToastIdsRef = useRef3({});
5896
+ const submittedClaimToastKeysRef = useRef3(/* @__PURE__ */ new Set());
5897
+ const [submittingClaimKeys, setSubmittingClaimKeys] = useState3({});
5898
+ const lifecycleInputs = useMemo2(
5006
5899
  () => Object.values(activeRedeems),
5007
5900
  [activeRedeems]
5008
5901
  );
5009
5902
  const lifecycleStates = useRedeemLifecycles(lifecycleInputs);
5010
- const internalClaimingIds = useMemo3(() => {
5903
+ const internalClaimingIds = useMemo2(() => {
5011
5904
  const out = __spreadValues({}, submittingClaimKeys);
5012
5905
  for (const [claimKey, active] of Object.entries(activeRedeems)) {
5013
5906
  const state = lifecycleStates[active.redeemId];
@@ -5016,11 +5909,11 @@ function useClaimWinnings(options = {}) {
5016
5909
  return out;
5017
5910
  }, [activeRedeems, lifecycleStates, submittingClaimKeys]);
5018
5911
  const claimingKeys = externalClaimingKeys != null ? externalClaimingKeys : internalClaimingIds;
5019
- const isClaiming = useCallback4(
5912
+ const isClaiming = useCallback3(
5020
5913
  (claimKey) => Boolean(externalClaimingKeys == null ? void 0 : externalClaimingKeys[claimKey]) || Boolean(internalClaimingIds[claimKey]),
5021
5914
  [externalClaimingKeys, internalClaimingIds]
5022
5915
  );
5023
- const invalidateClaimUiState = useCallback4(() => {
5916
+ const invalidateClaimUiState = useCallback3(() => {
5024
5917
  invalidateBalanceQueries2(queryClient);
5025
5918
  invalidatePositionQueries2(queryClient);
5026
5919
  queryClient.invalidateQueries({
@@ -5029,7 +5922,7 @@ function useClaimWinnings(options = {}) {
5029
5922
  });
5030
5923
  invalidateUserActivityQueries(queryClient);
5031
5924
  }, [queryClient]);
5032
- const claim = useCallback4(
5925
+ const claim = useCallback3(
5033
5926
  (_0) => __async(null, [_0], function* ({ claimKey, winningOutcomeIds, payload }) {
5034
5927
  if (activeClaimKeysRef.current.has(claimKey) || Boolean(externalClaimingKeys == null ? void 0 : externalClaimingKeys[claimKey]) || internalClaimingIds[claimKey]) {
5035
5928
  return;
@@ -5167,8 +6060,8 @@ function useClaimWinnings(options = {}) {
5167
6060
  toastCtx
5168
6061
  ]
5169
6062
  );
5170
- const firedTerminalRef = useRef4({});
5171
- useEffect4(() => {
6063
+ const firedTerminalRef = useRef3({});
6064
+ useEffect3(() => {
5172
6065
  var _a, _b;
5173
6066
  for (const [claimKey, active] of Object.entries(activeRedeems)) {
5174
6067
  const state = lifecycleStates[active.redeemId];
@@ -5230,7 +6123,7 @@ import {
5230
6123
  useAggAuthState as useAggAuthState2,
5231
6124
  useExecutionPositions as useExecutionPositions2
5232
6125
  } from "@agg-build/hooks";
5233
- import { useMemo as useMemo4 } from "react";
6126
+ import { useMemo as useMemo3 } from "react";
5234
6127
  var sharesFormatter = new Intl.NumberFormat("en-US", { maximumFractionDigits: 2 });
5235
6128
  var dateFormatter = new Intl.DateTimeFormat("en-US", {
5236
6129
  month: "short",
@@ -5247,7 +6140,7 @@ function useResolvedMarketClaim(options = {}) {
5247
6140
  var _a;
5248
6141
  const { market, enabled = true, executionMode } = options;
5249
6142
  const { isAuthenticated } = useAggAuthState2();
5250
- const tradingState = useMemo4(() => resolveMarketTradingState2(market), [market]);
6143
+ const tradingState = useMemo3(() => resolveMarketTradingState2(market), [market]);
5251
6144
  const isResolved = tradingState.kind === "resolved";
5252
6145
  const marketId = (_a = market == null ? void 0 : market.id) != null ? _a : null;
5253
6146
  const shouldFetch = Boolean(enabled && isAuthenticated && isResolved && marketId);
@@ -5257,7 +6150,7 @@ function useResolvedMarketClaim(options = {}) {
5257
6150
  limit: 50
5258
6151
  }, executionMode === "paper" ? { mode: "paper" } : {}));
5259
6152
  const claimWinnings = useClaimWinnings();
5260
- return useMemo4(() => {
6153
+ return useMemo3(() => {
5261
6154
  var _a2;
5262
6155
  if (!shouldFetch || !marketId) return void 0;
5263
6156
  const group = positions.find(
@@ -5306,6 +6199,7 @@ export {
5306
6199
  WITHDRAW_MODAL_OPEN_EVENT,
5307
6200
  requestAggDepositModalOpen,
5308
6201
  requestAggWithdrawModalOpen,
6202
+ FundKalshiModal,
5309
6203
  PlaceOrderFailureView,
5310
6204
  PlaceOrderSuccessView,
5311
6205
  PlaceOrder,