@agg-build/ui 4.17.0 → 4.17.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/{chunk-D2BTU7QI.mjs → chunk-7E4UXCEX.mjs} +223 -169
  2. package/dist/{chunk-QGONLJLE.mjs → chunk-B5ALKYD5.mjs} +210 -184
  3. package/dist/{chunk-RR44PSKH.mjs → chunk-BBDFSTIA.mjs} +3 -1
  4. package/dist/{chunk-M6U2RKBD.mjs → chunk-DSQSQ4RG.mjs} +127 -62
  5. package/dist/{chunk-5SCDQSNA.mjs → chunk-JI5KV4QI.mjs} +2 -2
  6. package/dist/{chunk-NIRCF54M.mjs → chunk-RZLM3M5R.mjs} +2 -2
  7. package/dist/{chunk-HFMKCV4L.mjs → chunk-TK62UB5F.mjs} +27 -16
  8. package/dist/events.js +29 -16
  9. package/dist/events.mjs +3 -3
  10. package/dist/index.js +1060 -930
  11. package/dist/index.mjs +9 -38
  12. package/dist/modals.js +212 -184
  13. package/dist/modals.mjs +3 -3
  14. package/dist/pages.js +841 -684
  15. package/dist/pages.mjs +6 -6
  16. package/dist/primitives.js +3 -1
  17. package/dist/primitives.mjs +1 -1
  18. package/dist/styles.css +1 -1
  19. package/dist/tailwind.css +1 -1
  20. package/dist/trading.js +535 -442
  21. package/dist/trading.mjs +4 -4
  22. package/dist/types/auth/connect-button-view/connect-button-view.types.d.mts +0 -2
  23. package/dist/types/auth/connect-button-view/connect-button-view.types.d.ts +0 -2
  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/pages/user-profile/components/available-balance-card.d.mts +3 -1
  27. package/dist/types/pages/user-profile/components/available-balance-card.d.ts +3 -1
  28. package/dist/types/pages/user-profile/cost-basis-display.d.mts +29 -0
  29. package/dist/types/pages/user-profile/cost-basis-display.d.ts +29 -0
  30. package/dist/types/pages/user-profile/user-profile.types.d.mts +8 -0
  31. package/dist/types/pages/user-profile/user-profile.types.d.ts +8 -0
  32. package/dist/types/primitives/modal/index.d.mts +1 -1
  33. package/dist/types/primitives/modal/index.d.ts +1 -1
  34. package/dist/types/primitives/modal/modal.types.d.mts +6 -0
  35. package/dist/types/primitives/modal/modal.types.d.ts +6 -0
  36. package/dist/types/trading/place-order/index.place-order.utils.d.mts +12 -1
  37. package/dist/types/trading/place-order/index.place-order.utils.d.ts +12 -1
  38. package/package.json +3 -3
package/dist/pages.js CHANGED
@@ -103,7 +103,7 @@ module.exports = __toCommonJS(pages_exports);
103
103
  // src/pages/home/index.tsx
104
104
  var import_hooks75 = require("@agg-build/hooks");
105
105
  var import_sdk25 = require("@agg-build/sdk");
106
- var import_react48 = require("react");
106
+ var import_react49 = require("react");
107
107
 
108
108
  // src/events/item/index.tsx
109
109
  var import_hooks38 = require("@agg-build/hooks");
@@ -8166,7 +8166,8 @@ var ModalContainer = ({
8166
8166
  maxWidth = "600px",
8167
8167
  classNames,
8168
8168
  "aria-label": ariaLabel,
8169
- "aria-labelledby": ariaLabelledBy
8169
+ "aria-labelledby": ariaLabelledBy,
8170
+ onOpenAutoFocus
8170
8171
  }) => {
8171
8172
  const {
8172
8173
  general: { rootClassName },
@@ -8197,6 +8198,7 @@ var ModalContainer = ({
8197
8198
  ),
8198
8199
  "aria-label": ariaLabel,
8199
8200
  "aria-labelledby": ariaLabelledBy,
8201
+ onOpenAutoFocus,
8200
8202
  onCloseAutoFocus: (event) => {
8201
8203
  event.preventDefault();
8202
8204
  },
@@ -11523,7 +11525,7 @@ EventList.displayName = "EventList";
11523
11525
 
11524
11526
  // src/pages/event-market/index.tsx
11525
11527
  var import_hooks74 = require("@agg-build/hooks");
11526
- var import_react45 = require("react");
11528
+ var import_react46 = require("react");
11527
11529
 
11528
11530
  // src/events/item-details/index.tsx
11529
11531
  var import_hooks51 = require("@agg-build/hooks");
@@ -13906,13 +13908,14 @@ var parseSettlementDateMs = (value) => {
13906
13908
  var isDateLikeDifference = (canonicalKey) => {
13907
13909
  return canonicalKey === "resolution_timing" || canonicalKey === "start_date" || canonicalKey === "end_date";
13908
13910
  };
13909
- var hasEqualNormalizedDateValues = (difference, canonicalKey) => {
13910
- if (!isDateLikeDifference(canonicalKey)) return false;
13911
+ var hasEqualValuesAcrossVenues = (difference) => {
13911
13912
  const values = Object.values(difference.perVenue);
13912
13913
  if (values.length < 2) return false;
13913
13914
  const timestamps = values.map(parseSettlementDateMs);
13914
- if (timestamps.some((timestamp) => timestamp === null)) return false;
13915
- return new Set(timestamps).size === 1;
13915
+ if (timestamps.every((timestamp) => timestamp !== null)) {
13916
+ return new Set(timestamps).size === 1;
13917
+ }
13918
+ return new Set(values.map(normalizeSettlementForCompare)).size === 1;
13916
13919
  };
13917
13920
  var resolveDifferenceSeverity = (difference, canonicalKey) => {
13918
13921
  var _a;
@@ -13947,7 +13950,7 @@ var prepareSettlementDifferences = (differences) => {
13947
13950
  if (!title2 || Object.keys(perVenue).length === 0) continue;
13948
13951
  const difference = __spreadProps(__spreadValues({}, rawDifference), { title: title2, perVenue });
13949
13952
  const canonicalKey = resolveCanonicalDifferenceKey(difference);
13950
- if (hasEqualNormalizedDateValues(difference, canonicalKey)) continue;
13953
+ if (hasEqualValuesAcrossVenues(difference)) continue;
13951
13954
  const existing = byCanonicalKey.get(canonicalKey);
13952
13955
  if (existing) {
13953
13956
  byCanonicalKey.set(canonicalKey, __spreadProps(__spreadValues({}, existing), {
@@ -13961,7 +13964,7 @@ var prepareSettlementDifferences = (differences) => {
13961
13964
  originalIndex
13962
13965
  }));
13963
13966
  }
13964
- return Array.from(byCanonicalKey.values()).sort((left, right) => {
13967
+ return Array.from(byCanonicalKey.values()).filter((difference) => !hasEqualValuesAcrossVenues(difference)).sort((left, right) => {
13965
13968
  const severityDelta = Number(right.severity === "critical") - Number(left.severity === "critical");
13966
13969
  if (severityDelta !== 0) return severityDelta;
13967
13970
  return left.originalIndex - right.originalIndex;
@@ -13975,9 +13978,7 @@ var resolveSettlementVenueLabel = (venue, labels) => {
13975
13978
  return (_a = labels.venues[venue]) != null ? _a : formatVenueFallbackLabel(venue);
13976
13979
  };
13977
13980
  var resolveDifferenceVenueKeys = (difference, settlementVenues) => {
13978
- const explicitVenues = Object.keys(difference.perVenue);
13979
- if (!isDateLikeDifference(difference.canonicalKey)) return explicitVenues;
13980
- const allVenues = [...settlementVenues != null ? settlementVenues : [], ...explicitVenues];
13981
+ const allVenues = [...settlementVenues != null ? settlementVenues : [], ...Object.keys(difference.perVenue)];
13981
13982
  return Array.from(new Set(allVenues.filter((venue) => venue.trim().length > 0)));
13982
13983
  };
13983
13984
  var resolveDifferenceIconClassName = (canonicalKey) => {
@@ -14016,6 +14017,12 @@ var buildSettlementVenueRules = ({
14016
14017
  if (!venueRules.includes(content2)) venueRules.push(content2);
14017
14018
  rulesByVenue.set(venue2, venueRules);
14018
14019
  }
14020
+ if (rulesByVenue.size > 0) {
14021
+ for (const venue2 of settlementVenues != null ? settlementVenues : []) {
14022
+ const trimmedVenue = venue2.trim();
14023
+ if (trimmedVenue && !rulesByVenue.has(trimmedVenue)) rulesByVenue.set(trimmedVenue, []);
14024
+ }
14025
+ }
14019
14026
  return Array.from(rulesByVenue, ([venue2, contents]) => ({
14020
14027
  venue: venue2,
14021
14028
  content: contents.join("\n\n")
@@ -14025,6 +14032,11 @@ var buildSettlementVenueRules = ({
14025
14032
  const venue = (_b = settlementVenues == null ? void 0 : settlementVenues.find((candidate) => candidate.trim().length > 0)) == null ? void 0 : _b.trim();
14026
14033
  return content && venue ? [{ venue, content }] : [];
14027
14034
  };
14035
+ var repeatsQuestion = (content, question) => {
14036
+ const normalizedQuestion = normalizeSettlementForCompare(question != null ? question : "");
14037
+ if (!normalizedQuestion) return false;
14038
+ return normalizeSettlementForCompare(content) === normalizedQuestion;
14039
+ };
14028
14040
  var isDuplicatedByVenueRules = (content, venueRules) => {
14029
14041
  const normalizedContent = normalizeSettlementForCompare(content);
14030
14042
  if (!normalizedContent) return false;
@@ -14041,8 +14053,8 @@ var SettlementVenueRules = ({
14041
14053
  /* @__PURE__ */ (0, import_jsx_runtime147.jsx)("p", { className: "text-agg-sm font-agg-bold leading-agg-5 text-agg-foreground", children: labels.trading.settlementFullRulesTitle }),
14042
14054
  /* @__PURE__ */ (0, import_jsx_runtime147.jsx)("div", { className: "flex w-full flex-col items-start gap-4", children: rules.map((rule) => {
14043
14055
  const venueLabel = resolveSettlementVenueLabel(rule.venue, labels);
14044
- return /* @__PURE__ */ (0, import_jsx_runtime147.jsxs)("details", { className: "group/agg-settlement-rule w-full", children: [
14045
- /* @__PURE__ */ (0, import_jsx_runtime147.jsxs)("summary", { className: "flex cursor-pointer list-none items-center gap-2 text-agg-sm font-agg-normal leading-agg-5 text-agg-foreground group-hover/agg-settlement-rule:text-agg-muted-foreground transition-colors marker:hidden", children: [
14056
+ return /* @__PURE__ */ (0, import_jsx_runtime147.jsxs)("details", { className: "w-full", children: [
14057
+ /* @__PURE__ */ (0, import_jsx_runtime147.jsxs)("summary", { className: "group/agg-settlement-rule flex w-fit cursor-pointer list-none items-center gap-2 text-agg-sm font-agg-normal leading-agg-5 text-agg-foreground transition-colors marker:hidden", children: [
14046
14058
  /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
14047
14059
  VenueLogo,
14048
14060
  {
@@ -14066,7 +14078,7 @@ var SettlementVenueRules = ({
14066
14078
  }
14067
14079
  )
14068
14080
  ] }),
14069
- /* @__PURE__ */ (0, import_jsx_runtime147.jsx)("div", { className: "mt-3 pl-6", children: /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(SettlementTextRenderer, { content: rule.content }) })
14081
+ /* @__PURE__ */ (0, import_jsx_runtime147.jsx)("div", { className: "mt-3 pl-6", children: rule.content ? /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(SettlementTextRenderer, { content: rule.content }) : /* @__PURE__ */ (0, import_jsx_runtime147.jsx)("p", { className: "text-agg-sm font-agg-normal leading-agg-5 text-agg-muted-foreground", children: labels.trading.settlementValueUnavailable }) })
14070
14082
  ] }, rule.venue);
14071
14083
  }) })
14072
14084
  ] });
@@ -14094,9 +14106,10 @@ var Settlement = ({
14094
14106
  }),
14095
14107
  [eventDescription, marketDescription, primaryRules]
14096
14108
  );
14109
+ const isSingleVenueCluster = settlementVenues !== void 0 && settlementVenues.length < 2;
14097
14110
  const settlementDifferences = (0, import_react23.useMemo)(
14098
- () => prepareSettlementDifferences(settlementDiff == null ? void 0 : settlementDiff.differences),
14099
- [settlementDiff == null ? void 0 : settlementDiff.differences]
14111
+ () => isSingleVenueCluster ? [] : prepareSettlementDifferences(settlementDiff == null ? void 0 : settlementDiff.differences),
14112
+ [isSingleVenueCluster, settlementDiff == null ? void 0 : settlementDiff.differences]
14100
14113
  );
14101
14114
  const eventBlock = (_a = blocks.find((block) => block.key === "eventDescription")) != null ? _a : null;
14102
14115
  const marketBlock = (_b = blocks.find((block) => block.key === "marketDescription")) != null ? _b : null;
@@ -14112,7 +14125,7 @@ var Settlement = ({
14112
14125
  );
14113
14126
  const hasSettlementDifferences = settlementDifferences.length > 0;
14114
14127
  const hasVenueSettlementRules = venueRuleBlocks.length > 0;
14115
- const standaloneEventBlock = eventBlock && !isDuplicatedByVenueRules(eventBlock.content, venueRuleBlocks) ? eventBlock : null;
14128
+ const standaloneEventBlock = eventBlock && !isDuplicatedByVenueRules(eventBlock.content, venueRuleBlocks) && !repeatsQuestion(eventBlock.content, question) ? eventBlock : null;
14116
14129
  const standaloneMarketBlock = hasVenueSettlementRules ? null : marketBlock;
14117
14130
  const standalonePrimaryRulesBlock = hasVenueSettlementRules ? null : primaryRulesBlock;
14118
14131
  const hasStandaloneSettlementText = hasVenueSettlementRules ? standaloneEventBlock !== null : blocks.length > 0;
@@ -17533,12 +17546,12 @@ SettlementDetails.displayName = "SettlementDetails";
17533
17546
  // src/trading/place-order/index.tsx
17534
17547
  var import_hooks67 = require("@agg-build/hooks");
17535
17548
  var import_sdk24 = require("@agg-build/sdk");
17536
- var import_react37 = __toESM(require("@number-flow/react"));
17549
+ var import_react38 = __toESM(require("@number-flow/react"));
17537
17550
  var Popover = __toESM(require("@radix-ui/react-popover"));
17538
17551
  var import_dayjs8 = __toESM(require("dayjs"));
17539
17552
  var import_timezone2 = __toESM(require("dayjs/plugin/timezone"));
17540
17553
  var import_utc2 = __toESM(require("dayjs/plugin/utc"));
17541
- var import_react38 = require("react");
17554
+ var import_react39 = require("react");
17542
17555
 
17543
17556
  // src/geo-block-banner/index.tsx
17544
17557
  var import_hooks57 = require("@agg-build/hooks");
@@ -18439,6 +18452,27 @@ var getSafeConnectionError = ({
18439
18452
  error.message
18440
18453
  ).trim();
18441
18454
  };
18455
+ var CloseButton = ({
18456
+ className,
18457
+ disabled
18458
+ }) => {
18459
+ const labels = (0, import_hooks64.useLabels)();
18460
+ return /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
18461
+ Dialog5.Close,
18462
+ {
18463
+ "aria-label": labels.common.close,
18464
+ disabled,
18465
+ className: cn(
18466
+ "z-30 flex size-6 cursor-pointer items-center justify-center rounded-agg-full",
18467
+ "text-agg-foreground transition-colors hover:text-agg-foreground/80",
18468
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-accent",
18469
+ "disabled:cursor-not-allowed disabled:opacity-50",
18470
+ className
18471
+ ),
18472
+ children: /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(Icon, { name: "close", size: "medium", className: "!text-agg-foreground" })
18473
+ }
18474
+ );
18475
+ };
18442
18476
  var ConnectKalshiModal = ({
18443
18477
  open,
18444
18478
  onOpenChange,
@@ -18469,12 +18503,12 @@ var ConnectKalshiModal = ({
18469
18503
  setError(void 0);
18470
18504
  setIsVerifying(false);
18471
18505
  setIsConnected(false);
18472
- const animationFrame = window.requestAnimationFrame(() => {
18473
- var _a;
18474
- return (_a = apiKeyInputRef.current) == null ? void 0 : _a.focus();
18475
- });
18476
- return () => window.cancelAnimationFrame(animationFrame);
18477
18506
  }, [open]);
18507
+ const handleOpenAutoFocus = (0, import_react35.useCallback)((event) => {
18508
+ var _a;
18509
+ event.preventDefault();
18510
+ (_a = apiKeyInputRef.current) == null ? void 0 : _a.focus({ preventScroll: true });
18511
+ }, []);
18478
18512
  const handleOpenChange = (0, import_react35.useCallback)(
18479
18513
  (nextOpen) => {
18480
18514
  if (isVerifying && !nextOpen) return;
@@ -18517,207 +18551,211 @@ var ConnectKalshiModal = ({
18517
18551
  [handleVerify]
18518
18552
  );
18519
18553
  if (availabilityState === "hidden") return null;
18520
- return /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(Modal, { open, onOpenChange: handleOpenChange, children: /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)(
18554
+ return /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(Modal, { open, onOpenChange: handleOpenChange, children: /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
18521
18555
  Modal.Container,
18522
18556
  {
18523
- maxWidth: "600px",
18557
+ maxWidth: isConnected ? "480px" : "600px",
18524
18558
  "aria-label": labels.onboarding.connectKalshiModal.ariaLabel,
18525
- classNames: { container: "!rounded-agg-2xl" },
18526
- children: [
18527
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("div", { className: "flex h-[60px] shrink-0 items-center justify-end px-8", children: /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
18528
- Dialog5.Close,
18529
- {
18530
- "aria-label": labels.common.close,
18531
- className: "flex size-10 cursor-pointer items-center justify-center rounded-agg-full text-agg-secondary transition-colors hover:bg-agg-quaternary hover:text-agg-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-accent disabled:cursor-default disabled:opacity-50",
18532
- disabled: isVerifying,
18533
- children: /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(Icon, { name: "close", size: "medium" })
18534
- }
18535
- ) }),
18536
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(Modal.Body, { classNames: { root: "!px-5 !pb-12 !pt-0 sm:!px-10" }, children: isConnected ? /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)(
18559
+ classNames: {
18560
+ container: "!rounded-t-agg-xl !rounded-b-none md:!rounded-agg-2xl"
18561
+ },
18562
+ onOpenAutoFocus: isConnected ? void 0 : handleOpenAutoFocus,
18563
+ children: isConnected ? /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)(Modal.Body, { classNames: { root: "relative !px-5 !py-8 md:!px-10 md:!py-12" }, children: [
18564
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(CloseButton, { className: "absolute right-5 top-5 md:right-8 md:top-8" }),
18565
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)(
18537
18566
  "div",
18538
18567
  {
18539
- className: "flex flex-col items-center gap-8 pb-3 text-center",
18568
+ className: "flex flex-col items-center gap-8 text-center",
18540
18569
  role: "status",
18541
18570
  "aria-live": "polite",
18542
18571
  children: [
18543
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("div", { className: "flex size-[60px] items-center justify-center rounded-agg-full bg-agg-success", children: /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
18544
- Icon,
18545
- {
18546
- name: "success-check",
18547
- className: "size-7 text-agg-on-primary",
18548
- "aria-hidden": "true"
18549
- }
18550
- ) }),
18551
- /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("div", { className: "flex flex-col items-center gap-4", children: [
18572
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("div", { className: "flex size-[60px] items-center justify-center rounded-agg-full bg-agg-success/15", children: /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(Icon, { name: "success-check", className: "size-6 text-agg-success", "aria-hidden": "true" }) }),
18573
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("div", { className: "flex flex-col items-center gap-3", children: [
18552
18574
  /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(Dialog5.Title, { className: "text-agg-2xl font-agg-bold leading-agg-8 text-agg-foreground", children: labels.onboarding.connectKalshiModal.success.title }),
18553
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(Dialog5.Description, { className: "max-w-[480px] text-agg-base leading-agg-6 text-agg-foreground", children: labels.onboarding.connectKalshiModal.success.description })
18575
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(Dialog5.Description, { className: "text-agg-base leading-agg-6 text-agg-foreground", children: labels.onboarding.connectKalshiModal.success.description })
18554
18576
  ] }),
18555
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
18556
- Button,
18557
- {
18558
- variant: "primary",
18559
- size: "large",
18560
- className: "min-w-[120px]",
18561
- onClick: () => handleOpenChange(false),
18562
- children: labels.onboarding.connectKalshiModal.success.done
18563
- }
18564
- )
18577
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(Button, { variant: "secondary", size: "large", onClick: () => handleOpenChange(false), children: labels.onboarding.connectKalshiModal.success.done })
18565
18578
  ]
18566
18579
  }
18567
- ) : /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("form", { className: "flex flex-col items-center gap-8", onSubmit: handleSubmit, children: [
18568
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(VenueLogo, { venue: import_sdk22.Venue.kalshi, variant: "logo", size: "large", className: "size-[60px]" }),
18569
- /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("div", { className: "flex flex-col items-center gap-4 text-center", children: [
18570
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(Dialog5.Title, { className: "text-agg-2xl font-agg-bold leading-agg-8 text-agg-foreground", children: labels.onboarding.connectKalshiModal.title }),
18571
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(Dialog5.Description, { className: "max-w-[520px] text-agg-base leading-agg-6 text-agg-foreground", children: labels.onboarding.connectKalshiModal.description })
18572
- ] }),
18573
- /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("div", { className: "flex w-full flex-col gap-4", children: [
18574
- /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("div", { className: "flex flex-col gap-3 rounded-agg-xl bg-agg-secondary-hover p-4", children: [
18575
- /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("div", { className: "flex flex-col gap-1", children: [
18576
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("p", { className: "text-agg-xs font-agg-bold uppercase leading-agg-4 text-agg-muted-foreground", children: labels.onboarding.connectKalshiModal.stepOne.label }),
18577
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("p", { className: "text-agg-sm font-agg-bold leading-agg-5 text-agg-foreground", children: labels.onboarding.connectKalshiModal.stepOne.title })
18578
- ] }),
18579
- /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("div", { className: "text-agg-sm leading-agg-5 text-agg-foreground", children: [
18580
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("p", { children: labels.onboarding.connectKalshiModal.stepOne.instructions.signIn }),
18581
- /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("p", { children: [
18582
- labels.onboarding.connectKalshiModal.stepOne.instructions.goToProfilePrefix,
18583
- " ",
18584
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("span", { className: "font-agg-bold", children: labels.onboarding.connectKalshiModal.stepOne.instructions.profileText }),
18585
- labels.onboarding.connectKalshiModal.stepOne.instructions.goToProfileSeparator,
18586
- " ",
18580
+ )
18581
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("form", { className: "flex min-h-0 flex-1 flex-col", onSubmit: handleSubmit, children: [
18582
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
18583
+ Modal.Body,
18584
+ {
18585
+ classNames: { root: "relative !px-5 !pb-6 !pt-5 md:!px-10 md:!pb-0 md:!pt-12" },
18586
+ children: /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("div", { className: "flex flex-col gap-6 md:items-center md:gap-0", children: [
18587
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("div", { className: "flex w-full flex-col md:contents", children: [
18588
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("div", { className: "flex items-center gap-3 md:contents", children: [
18587
18589
  /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
18588
- "a",
18590
+ VenueLogo,
18589
18591
  {
18590
- href: labels.onboarding.connectKalshiModal.stepOne.instructions.profileUrl,
18591
- target: "_blank",
18592
- rel: "noreferrer",
18593
- className: "cursor-pointer underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary",
18594
- children: labels.onboarding.connectKalshiModal.stepOne.instructions.profileUrl
18592
+ venue: import_sdk22.Venue.kalshi,
18593
+ variant: "logo",
18594
+ size: "large",
18595
+ className: "!size-10 md:!mb-8 md:!size-[60px]"
18596
+ }
18597
+ ),
18598
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(Dialog5.Title, { className: "text-agg-lg font-agg-bold leading-agg-7 text-agg-foreground md:mb-4 md:text-center md:text-agg-2xl md:leading-agg-8", children: labels.onboarding.connectKalshiModal.title }),
18599
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
18600
+ CloseButton,
18601
+ {
18602
+ disabled: isVerifying,
18603
+ className: "ml-auto shrink-0 md:absolute md:right-8 md:top-8 md:ml-0"
18595
18604
  }
18596
18605
  )
18597
18606
  ] }),
18598
- /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("p", { children: [
18599
- labels.onboarding.connectKalshiModal.stepOne.instructions.clickCreateKeyPrefix,
18600
- " ",
18601
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("span", { className: "font-agg-bold", children: labels.onboarding.connectKalshiModal.stepOne.instructions.createKeyText }),
18602
- labels.onboarding.connectKalshiModal.stepOne.instructions.clickCreateKeySuffix
18603
- ] }),
18604
- /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("p", { children: [
18605
- labels.onboarding.connectKalshiModal.stepOne.instructions.selectPermissionsPrefix,
18606
- " ",
18607
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("span", { className: "font-agg-bold", children: labels.onboarding.connectKalshiModal.stepOne.instructions.readWriteText }),
18608
- labels.onboarding.connectKalshiModal.stepOne.instructions.selectPermissionsSuffix
18609
- ] }),
18610
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("p", { children: labels.onboarding.connectKalshiModal.stepOne.instructions.createKey })
18611
- ] }),
18612
- /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("p", { className: "text-agg-sm leading-agg-5 text-agg-foreground", children: [
18613
- labels.onboarding.connectKalshiModal.stepOne.footerLineOne,
18614
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("br", {}),
18615
- labels.onboarding.connectKalshiModal.stepOne.footerLineTwo
18616
- ] })
18617
- ] }),
18618
- /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("div", { className: "flex flex-col gap-3 rounded-agg-xl bg-agg-secondary-hover p-4", children: [
18619
- /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("div", { className: "flex flex-col gap-1", children: [
18620
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("p", { className: "text-agg-xs font-agg-bold uppercase leading-agg-4 text-agg-muted-foreground", children: labels.onboarding.connectKalshiModal.stepTwo.label }),
18621
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("p", { className: "text-agg-sm font-agg-bold leading-agg-5 text-agg-foreground", children: labels.onboarding.connectKalshiModal.stepTwo.title })
18607
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(Dialog5.Description, { className: "mt-3 text-agg-sm leading-agg-5 text-agg-foreground md:mb-8 md:mt-0 md:text-center md:text-agg-base md:leading-agg-6", children: labels.onboarding.connectKalshiModal.description })
18622
18608
  ] }),
18623
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("p", { className: "text-agg-sm leading-agg-5 text-agg-foreground", children: labels.onboarding.connectKalshiModal.stepTwo.description }),
18624
- /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("div", { className: "flex flex-col gap-2", children: [
18625
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
18626
- "label",
18627
- {
18628
- htmlFor: "kalshi-api-key-id",
18629
- className: "text-agg-sm font-agg-bold text-agg-foreground",
18630
- children: labels.onboarding.connectKalshiModal.stepTwo.apiKeyIdLabel
18631
- }
18632
- ),
18633
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
18634
- "input",
18635
- {
18636
- ref: apiKeyInputRef,
18637
- id: "kalshi-api-key-id",
18638
- type: "text",
18639
- autoComplete: "off",
18640
- value: apiKeyId,
18641
- onChange: (event) => setApiKeyId(event.target.value),
18642
- placeholder: labels.onboarding.connectKalshiModal.stepTwo.apiKeyIdPlaceholder,
18643
- disabled: isVerifying,
18644
- "aria-invalid": !!error,
18645
- "aria-describedby": error ? errorId : void 0,
18646
- className: cn(
18647
- "h-10 w-full rounded-agg-md border border-agg-separator bg-agg-secondary px-3 py-2.5",
18648
- "text-agg-base text-agg-foreground placeholder:text-agg-muted-foreground",
18649
- "outline-none transition-colors focus:border-agg-primary focus:ring-1 focus:ring-agg-primary",
18650
- "disabled:cursor-not-allowed disabled:opacity-60"
18609
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("div", { className: "flex w-full flex-col gap-4", children: [
18610
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("div", { className: "flex flex-col gap-3 rounded-agg-xl bg-agg-secondary-hover p-4", children: [
18611
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("div", { className: "flex flex-col gap-1", children: [
18612
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("p", { className: "text-agg-xs font-agg-bold uppercase leading-agg-4 text-agg-muted-foreground", children: labels.onboarding.connectKalshiModal.stepOne.label }),
18613
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("p", { className: "text-agg-sm font-agg-bold leading-agg-5 text-agg-foreground", children: labels.onboarding.connectKalshiModal.stepOne.title })
18614
+ ] }),
18615
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("div", { className: "text-agg-sm leading-agg-5 text-agg-foreground", children: [
18616
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("p", { children: labels.onboarding.connectKalshiModal.stepOne.instructions.signIn }),
18617
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("p", { children: [
18618
+ labels.onboarding.connectKalshiModal.stepOne.instructions.goToProfilePrefix,
18619
+ " ",
18620
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("span", { className: "font-agg-bold", children: labels.onboarding.connectKalshiModal.stepOne.instructions.profileText }),
18621
+ labels.onboarding.connectKalshiModal.stepOne.instructions.goToProfileSeparator,
18622
+ " ",
18623
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
18624
+ "a",
18625
+ {
18626
+ href: labels.onboarding.connectKalshiModal.stepOne.instructions.profileUrl,
18627
+ target: "_blank",
18628
+ rel: "noreferrer",
18629
+ className: "cursor-pointer underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary",
18630
+ children: labels.onboarding.connectKalshiModal.stepOne.instructions.profileUrl
18631
+ }
18632
+ )
18633
+ ] }),
18634
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("p", { children: [
18635
+ labels.onboarding.connectKalshiModal.stepOne.instructions.clickCreateKeyPrefix,
18636
+ " ",
18637
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("span", { className: "font-agg-bold", children: labels.onboarding.connectKalshiModal.stepOne.instructions.createKeyText }),
18638
+ labels.onboarding.connectKalshiModal.stepOne.instructions.clickCreateKeySuffix
18639
+ ] }),
18640
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("p", { children: [
18641
+ labels.onboarding.connectKalshiModal.stepOne.instructions.selectPermissionsPrefix,
18642
+ " ",
18643
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("span", { className: "font-agg-bold", children: labels.onboarding.connectKalshiModal.stepOne.instructions.readWriteText }),
18644
+ labels.onboarding.connectKalshiModal.stepOne.instructions.selectPermissionsSuffix
18645
+ ] }),
18646
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("p", { children: labels.onboarding.connectKalshiModal.stepOne.instructions.createKey })
18647
+ ] }),
18648
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("p", { className: "text-agg-sm leading-agg-5 text-agg-foreground", children: [
18649
+ labels.onboarding.connectKalshiModal.stepOne.footerLineOne,
18650
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("br", {}),
18651
+ labels.onboarding.connectKalshiModal.stepOne.footerLineTwo
18652
+ ] })
18653
+ ] }),
18654
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("div", { className: "flex flex-col gap-3 rounded-agg-xl bg-agg-secondary-hover p-4", children: [
18655
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("div", { className: "flex flex-col gap-1", children: [
18656
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("p", { className: "text-agg-xs font-agg-bold uppercase leading-agg-4 text-agg-muted-foreground", children: labels.onboarding.connectKalshiModal.stepTwo.label }),
18657
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("p", { className: "text-agg-sm font-agg-bold leading-agg-5 text-agg-foreground", children: labels.onboarding.connectKalshiModal.stepTwo.title })
18658
+ ] }),
18659
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("p", { className: "text-agg-sm leading-agg-5 text-agg-foreground", children: labels.onboarding.connectKalshiModal.stepTwo.description }),
18660
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("div", { className: "flex flex-col gap-2", children: [
18661
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
18662
+ "label",
18663
+ {
18664
+ htmlFor: "kalshi-api-key-id",
18665
+ className: "text-agg-sm font-agg-bold text-agg-foreground",
18666
+ children: labels.onboarding.connectKalshiModal.stepTwo.apiKeyIdLabel
18667
+ }
18668
+ ),
18669
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
18670
+ "input",
18671
+ {
18672
+ ref: apiKeyInputRef,
18673
+ id: "kalshi-api-key-id",
18674
+ type: "text",
18675
+ autoComplete: "off",
18676
+ value: apiKeyId,
18677
+ onChange: (event) => setApiKeyId(event.target.value),
18678
+ placeholder: labels.onboarding.connectKalshiModal.stepTwo.apiKeyIdPlaceholder,
18679
+ disabled: isVerifying,
18680
+ "aria-invalid": !!error,
18681
+ "aria-describedby": error ? errorId : void 0,
18682
+ className: cn(
18683
+ "h-10 w-full rounded-agg-sm border border-agg-separator bg-agg-secondary px-3 py-2.5",
18684
+ "text-agg-base text-agg-foreground placeholder:text-agg-muted-foreground",
18685
+ "outline-none transition-colors focus:border-agg-primary focus:ring-1 focus:ring-agg-primary",
18686
+ "disabled:cursor-not-allowed disabled:opacity-60"
18687
+ )
18688
+ }
18651
18689
  )
18652
- }
18653
- )
18654
- ] }),
18655
- /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("div", { className: "flex flex-col gap-2", children: [
18656
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
18657
- "label",
18658
- {
18659
- htmlFor: "kalshi-private-key",
18660
- className: "text-agg-sm font-agg-bold text-agg-foreground",
18661
- children: labels.onboarding.connectKalshiModal.stepTwo.privateKeyLabel
18662
- }
18663
- ),
18664
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
18665
- "textarea",
18666
- {
18667
- id: "kalshi-private-key",
18668
- autoComplete: "off",
18669
- value: privateKey,
18670
- onChange: (event) => setPrivateKey(event.target.value),
18671
- placeholder: labels.onboarding.connectKalshiModal.stepTwo.privateKeyPlaceholder,
18672
- rows: 3,
18673
- disabled: isVerifying,
18674
- "aria-invalid": !!error,
18675
- "aria-describedby": error ? errorId : void 0,
18676
- className: cn(
18677
- "w-full resize-none rounded-agg-md border border-agg-separator bg-agg-secondary px-3 py-2.5",
18678
- "text-agg-base text-agg-foreground placeholder:text-agg-muted-foreground",
18679
- "outline-none transition-colors focus:border-agg-primary focus:ring-1 focus:ring-agg-primary",
18680
- "disabled:cursor-not-allowed disabled:opacity-60"
18690
+ ] }),
18691
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("div", { className: "flex flex-col gap-2", children: [
18692
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
18693
+ "label",
18694
+ {
18695
+ htmlFor: "kalshi-private-key",
18696
+ className: "text-agg-sm font-agg-bold text-agg-foreground",
18697
+ children: labels.onboarding.connectKalshiModal.stepTwo.privateKeyLabel
18698
+ }
18699
+ ),
18700
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
18701
+ "textarea",
18702
+ {
18703
+ id: "kalshi-private-key",
18704
+ autoComplete: "off",
18705
+ value: privateKey,
18706
+ onChange: (event) => setPrivateKey(event.target.value),
18707
+ placeholder: labels.onboarding.connectKalshiModal.stepTwo.privateKeyPlaceholder,
18708
+ rows: 3,
18709
+ disabled: isVerifying,
18710
+ "aria-invalid": !!error,
18711
+ "aria-describedby": error ? errorId : void 0,
18712
+ className: cn(
18713
+ "w-full resize-none rounded-agg-sm border border-agg-separator bg-agg-secondary px-3 py-2.5",
18714
+ "text-agg-base text-agg-foreground placeholder:text-agg-muted-foreground",
18715
+ "outline-none transition-colors focus:border-agg-primary focus:ring-1 focus:ring-agg-primary",
18716
+ "disabled:cursor-not-allowed disabled:opacity-60"
18717
+ )
18718
+ }
18681
18719
  )
18682
- }
18683
- )
18684
- ] })
18685
- ] })
18686
- ] }),
18687
- /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("div", { className: "flex w-full items-center justify-between gap-4", children: [
18688
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("p", { className: "text-agg-base text-agg-foreground", children: labels.onboarding.connectKalshiModal.help.label }),
18689
- /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("div", { className: "flex items-center gap-3", children: [
18690
- /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("span", { className: "flex items-center gap-2 text-agg-base font-agg-bold text-agg-primary", children: [
18691
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(Icon, { name: "document", size: "small", className: "size-4 text-agg-primary" }),
18692
- labels.onboarding.connectKalshiModal.help.docsLinkLabel
18720
+ ] })
18721
+ ] })
18693
18722
  ] }),
18694
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("span", { className: "h-3 w-px bg-agg-separator" }),
18695
- /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("span", { className: "flex items-center gap-2 text-agg-base font-agg-bold text-agg-primary", children: [
18696
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(Icon, { name: "play-square", size: "small", className: "size-4 text-agg-primary" }),
18697
- labels.onboarding.connectKalshiModal.help.tutorialLinkLabel
18698
- ] })
18723
+ error ? /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)(
18724
+ "div",
18725
+ {
18726
+ id: errorId,
18727
+ className: "flex items-center gap-2 md:justify-center",
18728
+ role: "alert",
18729
+ "aria-live": "assertive",
18730
+ children: [
18731
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(Icon, { name: "warning", size: "small", className: "size-3.5 text-agg-error" }),
18732
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("p", { className: "text-agg-sm leading-agg-5 text-agg-error", children: error })
18733
+ ]
18734
+ }
18735
+ ) : null
18699
18736
  ] })
18700
- ] }),
18701
- /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("div", { className: "flex flex-col items-center gap-5", children: [
18702
- error ? /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)(
18703
- "div",
18704
- {
18705
- id: errorId,
18706
- className: "flex items-center gap-2",
18707
- role: "alert",
18708
- "aria-live": "assertive",
18709
- children: [
18710
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(Icon, { name: "warning", size: "small", className: "size-3.5 text-agg-error" }),
18711
- /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("p", { className: "text-agg-sm leading-agg-5 text-agg-error", children: error })
18712
- ]
18713
- }
18714
- ) : null,
18715
- /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("div", { className: "flex items-center justify-center gap-3", children: [
18737
+ }
18738
+ ),
18739
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)(
18740
+ Modal.Footer,
18741
+ {
18742
+ classNames: {
18743
+ root: "relative !h-auto !gap-3 !p-4 md:!justify-center md:!border-0 md:!px-10 md:!pb-12 md:!pt-8"
18744
+ },
18745
+ children: [
18746
+ /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
18747
+ "div",
18748
+ {
18749
+ "aria-hidden": "true",
18750
+ className: "pointer-events-none absolute inset-x-0 -top-[60px] h-[60px] bg-gradient-to-b from-transparent to-agg-secondary md:hidden"
18751
+ }
18752
+ ),
18716
18753
  /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
18717
18754
  Button,
18718
18755
  {
18719
18756
  variant: "secondary",
18720
18757
  size: "large",
18758
+ className: "shrink-0",
18721
18759
  onClick: () => handleOpenChange(false),
18722
18760
  disabled: isVerifying,
18723
18761
  children: labels.onboarding.connectKalshiModal.actions.cancel
@@ -18729,15 +18767,16 @@ var ConnectKalshiModal = ({
18729
18767
  type: "submit",
18730
18768
  variant: "primary",
18731
18769
  size: "large",
18770
+ className: "flex-1 md:flex-none",
18732
18771
  disabled: !parsedCredentials.success || isVerifying,
18733
18772
  isLoading: isVerifying,
18734
18773
  children: labels.onboarding.connectKalshiModal.actions.verifyConnection
18735
18774
  }
18736
18775
  )
18737
- ] })
18738
- ] })
18739
- ] }) })
18740
- ]
18776
+ ]
18777
+ }
18778
+ )
18779
+ ] })
18741
18780
  }
18742
18781
  ) });
18743
18782
  };
@@ -19225,14 +19264,10 @@ var routePriceLabelFormatter = new Intl.NumberFormat("en-US", {
19225
19264
  minimumFractionDigits: 0,
19226
19265
  maximumFractionDigits: 1
19227
19266
  });
19228
- var PLACE_ORDER_PRICE_DISPLAY_MULTIPLIER = 1e3;
19229
19267
  var GEO_BLOCK_WARNING_PREFIX = "Venue not available in your region";
19230
19268
  var isFiniteNonNegativePrice = (value) => {
19231
19269
  return typeof value === "number" && Number.isFinite(value) && value >= 0;
19232
19270
  };
19233
- var isPredictionMarketPrice = (value) => {
19234
- return isFiniteNonNegativePrice(value) && value <= 1;
19235
- };
19236
19271
  var getPlaceOrderAverageExecutionPrice = (quoteData) => {
19237
19272
  var _a;
19238
19273
  if (!quoteData || quoteData.totalFilled <= 0) return null;
@@ -19243,22 +19278,6 @@ var getPlaceOrderAverageExecutionPrice = (quoteData) => {
19243
19278
  const averageExecutionPrice = quoteData.rawExecCost / quoteData.totalFilled;
19244
19279
  return isFiniteNonNegativePrice(averageExecutionPrice) ? averageExecutionPrice : null;
19245
19280
  };
19246
- var isPlaceOrderAveragePriceWorse = ({
19247
- averageExecutionPrice,
19248
- displayedMarketPrice,
19249
- tradeSide
19250
- }) => {
19251
- if (!isPredictionMarketPrice(averageExecutionPrice) || !isPredictionMarketPrice(displayedMarketPrice)) {
19252
- return false;
19253
- }
19254
- const displayedAveragePrice = Math.round(
19255
- averageExecutionPrice * PLACE_ORDER_PRICE_DISPLAY_MULTIPLIER
19256
- );
19257
- const displayedReferencePrice = Math.round(
19258
- displayedMarketPrice * PLACE_ORDER_PRICE_DISPLAY_MULTIPLIER
19259
- );
19260
- return tradeSide === "buy" ? displayedAveragePrice > displayedReferencePrice : displayedAveragePrice < displayedReferencePrice;
19261
- };
19262
19281
  var floorToDecimals = (value, decimals) => {
19263
19282
  if (!Number.isFinite(value) || value <= 0) return 0;
19264
19283
  const [coefficient = "0", exponentText = "0"] = value.toString().toLowerCase().split("e");
@@ -19869,16 +19888,21 @@ var buildLiveRouteCards = ({
19869
19888
  })() : [];
19870
19889
  return [...baseCards, ...unavailableCards, ...warningOnlyUnavailableCards];
19871
19890
  };
19872
- var resolveDefaultRouteCardId = (routeCards, primaryStatus) => {
19873
- var _a, _b, _c, _d, _e;
19891
+ var routeCardRequiresKalshi = (card) => card.venue === "kalshi" || card.quoteData.fills.some((fill) => fill.venue === "kalshi");
19892
+ var resolveDefaultRouteCardId = (routeCards, primaryStatus, options) => {
19893
+ var _a, _b, _c, _d, _e, _f;
19874
19894
  if (routeCards.length === 0) return null;
19875
- const firstExecutableCard = routeCards.find(
19876
- (card) => !card.isUnavailable && card.quoteData.status === "ok" && card.quoteData.quoteId
19877
- );
19895
+ const isExecutableCard = (card) => !card.isUnavailable && card.quoteData.status === "ok" && !!card.quoteData.quoteId;
19896
+ if (options == null ? void 0 : options.isKalshiDisconnected) {
19897
+ const nonKalshiCards = routeCards.filter((card) => !routeCardRequiresKalshi(card));
19898
+ const preferredCard = (_a = nonKalshiCards.find(isExecutableCard)) != null ? _a : nonKalshiCards.find((card) => !card.isUnavailable);
19899
+ if (preferredCard) return preferredCard.id;
19900
+ }
19901
+ const firstExecutableCard = routeCards.find(isExecutableCard);
19878
19902
  if (primaryStatus === "insufficient_balance") {
19879
19903
  if (firstExecutableCard) return firstExecutableCard.id;
19880
19904
  }
19881
- return (_e = (_d = (_b = firstExecutableCard == null ? void 0 : firstExecutableCard.id) != null ? _b : (_a = routeCards.find((card) => !card.isUnavailable)) == null ? void 0 : _a.id) != null ? _d : (_c = routeCards[0]) == null ? void 0 : _c.id) != null ? _e : null;
19905
+ return (_f = (_e = (_c = firstExecutableCard == null ? void 0 : firstExecutableCard.id) != null ? _c : (_b = routeCards.find((card) => !card.isUnavailable)) == null ? void 0 : _b.id) != null ? _e : (_d = routeCards[0]) == null ? void 0 : _d.id) != null ? _f : null;
19882
19906
  };
19883
19907
  var getPlaceOrderRouteCardIdentity = (card) => {
19884
19908
  var _a;
@@ -21084,9 +21108,9 @@ var deriveBackendExecutionOrderGroups = ({
21084
21108
  return [__spreadProps(__spreadValues({ id: order.orderId }, presentation), { steps })];
21085
21109
  });
21086
21110
  const allOrdersTerminal = executionOrders.every((order) => order.event !== null);
21087
- return deriveSequentialDisplayGroups(realGroups, allOrdersTerminal);
21111
+ return deriveSequentialDisplayGroups(realGroups, allOrdersTerminal, "per-leg");
21088
21112
  };
21089
- var deriveSequentialDisplayGroups = (groups, revealTerminalOutcomes = false) => {
21113
+ var deriveSequentialDisplayGroups = (groups, revealTerminalOutcomes = false, scope = "global") => {
21090
21114
  if (revealTerminalOutcomes) {
21091
21115
  return groups.map((group) => __spreadProps(__spreadValues({}, group), {
21092
21116
  steps: group.steps.map((_a) => {
@@ -21096,19 +21120,22 @@ var deriveSequentialDisplayGroups = (groups, revealTerminalOutcomes = false) =>
21096
21120
  }));
21097
21121
  }
21098
21122
  let hasUnresolvedPredecessor = false;
21099
- return groups.map((group) => __spreadProps(__spreadValues({}, group), {
21100
- steps: group.steps.map((_a) => {
21101
- var _b = _a, { realStatus } = _b, step = __objRest(_b, ["realStatus"]);
21102
- if (hasUnresolvedPredecessor) {
21103
- return __spreadProps(__spreadValues({}, step), { status: "not-started" });
21104
- }
21105
- if (realStatus === "done") {
21106
- return __spreadProps(__spreadValues({}, step), { status: "done" });
21107
- }
21108
- hasUnresolvedPredecessor = true;
21109
- return __spreadProps(__spreadValues({}, step), { status: realStatus });
21110
- })
21111
- }));
21123
+ return groups.map((group) => {
21124
+ if (scope === "per-leg") hasUnresolvedPredecessor = false;
21125
+ return __spreadProps(__spreadValues({}, group), {
21126
+ steps: group.steps.map((_a) => {
21127
+ var _b = _a, { realStatus } = _b, step = __objRest(_b, ["realStatus"]);
21128
+ if (hasUnresolvedPredecessor) {
21129
+ return __spreadProps(__spreadValues({}, step), { status: "not-started" });
21130
+ }
21131
+ if (realStatus === "done") {
21132
+ return __spreadProps(__spreadValues({}, step), { status: "done" });
21133
+ }
21134
+ hasUnresolvedPredecessor = true;
21135
+ return __spreadProps(__spreadValues({}, step), { status: realStatus });
21136
+ })
21137
+ });
21138
+ });
21112
21139
  };
21113
21140
  var deriveExecutionOrderGroups = ({
21114
21141
  quoteData,
@@ -21329,6 +21356,7 @@ var calculateExecutionProgress = ({
21329
21356
  };
21330
21357
 
21331
21358
  // src/trading/place-order/index.place-order.execution-view.tsx
21359
+ var import_react37 = require("react");
21332
21360
  var import_jsx_runtime166 = require("react/jsx-runtime");
21333
21361
  var PlaceOrderExecutionHeader = ({
21334
21362
  className,
@@ -21351,6 +21379,85 @@ var PlaceOrderExecutionHeader = ({
21351
21379
  eventDateLabel ? /* @__PURE__ */ (0, import_jsx_runtime166.jsx)("p", { className: "text-agg-base leading-agg-6 text-agg-foreground", children: eventDateLabel }) : null
21352
21380
  ] });
21353
21381
  };
21382
+ var PROGRESS_TWEEN_MS = 700;
21383
+ var prefersReducedMotion = () => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
21384
+ var useTweenedProgress = (target, enabled) => {
21385
+ const [value, setValue] = (0, import_react37.useState)(target);
21386
+ const valueRef = (0, import_react37.useRef)(target);
21387
+ (0, import_react37.useEffect)(() => {
21388
+ const from = valueRef.current;
21389
+ if (!enabled || from === target || prefersReducedMotion()) {
21390
+ valueRef.current = target;
21391
+ setValue(target);
21392
+ return;
21393
+ }
21394
+ let frame = 0;
21395
+ const start = performance.now();
21396
+ const tick = (now) => {
21397
+ const t = Math.min(1, (now - start) / PROGRESS_TWEEN_MS);
21398
+ const eased = 1 - Math.pow(1 - t, 3);
21399
+ const next = Math.round(from + (target - from) * eased);
21400
+ valueRef.current = next;
21401
+ setValue(next);
21402
+ if (t < 1) frame = requestAnimationFrame(tick);
21403
+ };
21404
+ frame = requestAnimationFrame(tick);
21405
+ return () => cancelAnimationFrame(frame);
21406
+ }, [enabled, target]);
21407
+ return value;
21408
+ };
21409
+ var ExecutionProgressBar = ({
21410
+ enableAnimations,
21411
+ label: label2,
21412
+ progress
21413
+ }) => {
21414
+ const clamped = Math.max(0, Math.min(100, progress));
21415
+ const displayed = useTweenedProgress(clamped, enableAnimations);
21416
+ const isRunning = clamped < 100;
21417
+ return /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)("div", { className: "flex items-center gap-3", children: [
21418
+ /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)("p", { className: "shrink-0 tabular-nums text-agg-sm leading-agg-5 text-agg-muted-foreground", children: [
21419
+ displayed,
21420
+ "%"
21421
+ ] }),
21422
+ /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
21423
+ "div",
21424
+ {
21425
+ role: "progressbar",
21426
+ "aria-label": label2,
21427
+ "aria-valuemin": 0,
21428
+ "aria-valuemax": 100,
21429
+ "aria-valuenow": clamped,
21430
+ className: "relative h-1 min-w-0 flex-1 overflow-hidden rounded-agg-full bg-agg-separator",
21431
+ children: /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
21432
+ "div",
21433
+ {
21434
+ className: cn(
21435
+ "absolute inset-y-0 left-0 overflow-hidden rounded-agg-full bg-agg-primary",
21436
+ getMotionClassName(
21437
+ enableAnimations,
21438
+ "transition-[width] duration-700 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none"
21439
+ )
21440
+ ),
21441
+ style: { width: `${clamped}%` },
21442
+ children: isRunning ? /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
21443
+ "span",
21444
+ {
21445
+ "aria-hidden": "true",
21446
+ className: cn(
21447
+ "absolute inset-0 hidden bg-gradient-to-r from-transparent via-white/40 to-transparent",
21448
+ getMotionClassName(
21449
+ enableAnimations,
21450
+ "motion-safe:block motion-safe:animate-agg-progress-shimmer"
21451
+ )
21452
+ )
21453
+ }
21454
+ ) : null
21455
+ }
21456
+ )
21457
+ }
21458
+ )
21459
+ ] });
21460
+ };
21354
21461
  var ExecutionStepIndicator = ({
21355
21462
  enableAnimations,
21356
21463
  step
@@ -21486,21 +21593,14 @@ var PlaceOrderExecutionView = ({
21486
21593
  }
21487
21594
  ),
21488
21595
  /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)("div", { className: cn("flex flex-col gap-5", classNames == null ? void 0 : classNames.content), children: [
21489
- /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)("div", { className: "flex items-center gap-3", children: [
21490
- /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)("p", { className: "shrink-0 text-agg-sm leading-agg-5 text-agg-muted-foreground", children: [
21491
- progress,
21492
- "%"
21493
- ] }),
21494
- /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
21495
- "progress",
21496
- {
21497
- "aria-label": labels.executingOrder,
21498
- className: "h-1 min-w-0 flex-1 overflow-hidden rounded-agg-full bg-agg-separator text-agg-primary accent-agg-primary [&::-moz-progress-bar]:bg-agg-primary [&::-webkit-progress-bar]:bg-agg-separator [&::-webkit-progress-value]:bg-agg-primary",
21499
- max: 100,
21500
- value: progress
21501
- }
21502
- )
21503
- ] }),
21596
+ /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
21597
+ ExecutionProgressBar,
21598
+ {
21599
+ enableAnimations,
21600
+ label: labels.executingOrder,
21601
+ progress
21602
+ }
21603
+ ),
21504
21604
  /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
21505
21605
  PlaceOrderExecutionGroups,
21506
21606
  {
@@ -21748,7 +21848,7 @@ var PlaceOrderSuccessView = ({
21748
21848
  /* @__PURE__ */ (0, import_jsx_runtime168.jsxs)("div", { className: "flex items-center justify-between gap-4", children: [
21749
21849
  /* @__PURE__ */ (0, import_jsx_runtime168.jsxs)("div", { className: "flex min-w-0 flex-col gap-0.5", children: [
21750
21850
  /* @__PURE__ */ (0, import_jsx_runtime168.jsx)("p", { className: "text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: tradingLabels.orderPayout }),
21751
- potentialReturnLabel ? /* @__PURE__ */ (0, import_jsx_runtime168.jsx)("span", { className: "inline-flex h-5 items-center rounded-agg-sm border border-agg-primary/50 bg-gradient-to-b from-agg-primary/8 to-agg-primary/15 px-2 text-[10px] font-agg-bold uppercase leading-[14px] text-agg-primary", children: potentialReturnLabel }) : null
21851
+ potentialReturnLabel ? /* @__PURE__ */ (0, import_jsx_runtime168.jsx)("span", { className: "agg-type-overline agg-text-brand", children: potentialReturnLabel }) : null
21752
21852
  ] }),
21753
21853
  /* @__PURE__ */ (0, import_jsx_runtime168.jsx)("p", { className: "shrink-0 text-right text-[30px] font-agg-bold leading-[36px] text-agg-success", children: resolvedPayoutLabel })
21754
21854
  ] })
@@ -21890,24 +21990,24 @@ var PlaceOrderSlippageControl = ({
21890
21990
  }) => {
21891
21991
  var _a, _b;
21892
21992
  const labels = (0, import_hooks67.useLabels)();
21893
- const containerRef = (0, import_react38.useRef)(null);
21894
- const triggerRef = (0, import_react38.useRef)(null);
21895
- const inputRef = (0, import_react38.useRef)(null);
21896
- const warningId = (0, import_react38.useId)();
21993
+ const containerRef = (0, import_react39.useRef)(null);
21994
+ const triggerRef = (0, import_react39.useRef)(null);
21995
+ const inputRef = (0, import_react39.useRef)(null);
21996
+ const warningId = (0, import_react39.useId)();
21897
21997
  const defaultValue = finalizePercentageValue(slippageDefaultValue);
21898
21998
  const committedValue = finalizePercentageValue(slippageValue) || defaultValue;
21899
- const [draftValue, setDraftValue] = (0, import_react38.useState)(committedValue);
21900
- const [isEditing, setIsEditing] = (0, import_react38.useState)(
21999
+ const [draftValue, setDraftValue] = (0, import_react39.useState)(committedValue);
22000
+ const [isEditing, setIsEditing] = (0, import_react39.useState)(
21901
22001
  () => isPercentageBelowMinimum(committedValue, slippageMinimumValue)
21902
22002
  );
21903
- const [shouldFocusInput, setShouldFocusInput] = (0, import_react38.useState)(false);
21904
- (0, import_react38.useEffect)(() => {
22003
+ const [shouldFocusInput, setShouldFocusInput] = (0, import_react39.useState)(false);
22004
+ (0, import_react39.useEffect)(() => {
21905
22005
  setDraftValue(committedValue);
21906
22006
  if (isPercentageBelowMinimum(committedValue, slippageMinimumValue)) {
21907
22007
  setIsEditing(true);
21908
22008
  }
21909
22009
  }, [committedValue, slippageMinimumValue]);
21910
- (0, import_react38.useEffect)(() => {
22010
+ (0, import_react39.useEffect)(() => {
21911
22011
  if (!shouldFocusInput) return;
21912
22012
  requestAnimationFrame(() => {
21913
22013
  var _a2, _b2;
@@ -21924,7 +22024,7 @@ var PlaceOrderSlippageControl = ({
21924
22024
  Number(committedValue || slippageDefaultValue || DEFAULT_SLIPPAGE_VALUE)
21925
22025
  );
21926
22026
  const resolvedAutoLabel = labels.trading.resetSlippage;
21927
- const resolvedWarningMessage = (0, import_react38.useMemo)(() => {
22027
+ const resolvedWarningMessage = (0, import_react39.useMemo)(() => {
21928
22028
  if (isLowSlippage) {
21929
22029
  return labels.trading.slippageLow(slippageMinimumValue);
21930
22030
  }
@@ -22331,13 +22431,15 @@ var renderRouteCard = ({
22331
22431
  isExpanded,
22332
22432
  isSelected,
22333
22433
  onSelect,
22434
+ isKalshiDisconnected = false,
22334
22435
  sharedKycStatus,
22335
22436
  tradingLabels
22336
22437
  }) => {
22337
22438
  var _a, _b, _c;
22338
22439
  const showSharedKycRequirement = card.requiresSharedKyc === true && sharedKycStatus !== void 0 && sharedKycStatus !== "verified" && !card.isUnavailable;
22440
+ const showKalshiRequirement = isKalshiDisconnected && card.kind === "venue" && card.venue === "kalshi" && !isSelected && !card.isUnavailable;
22339
22441
  const showSplitDetails = isSelected && isExpanded && card.kind === "split" && !!((_a = card.rows) == null ? void 0 : _a.length);
22340
- const displayedHint = showSharedKycRequirement ? tradingLabels.sharedKyc.required : card.hint;
22442
+ const displayedHint = showKalshiRequirement ? tradingLabels.requiresKalshiAccount : showSharedKycRequirement ? tradingLabels.sharedKyc.required : card.hint;
22341
22443
  const ariaLabel = [card.label, displayedHint, card.value].filter(Boolean).join(" ");
22342
22444
  return /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(
22343
22445
  "button",
@@ -22391,7 +22493,7 @@ var renderRouteCard = ({
22391
22493
  className: "shrink-0 text-agg-muted-foreground",
22392
22494
  "aria-hidden": "true"
22393
22495
  }
22394
- ) : showSharedKycRequirement || card.insufficientInventory ? /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(
22496
+ ) : showKalshiRequirement || showSharedKycRequirement || card.insufficientInventory ? /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(
22395
22497
  Icon,
22396
22498
  {
22397
22499
  name: "warning",
@@ -22474,10 +22576,10 @@ var PlaceOrder = ({
22474
22576
  const selectedEvent = (_a = tradingContext == null ? void 0 : tradingContext.selectedEvent) != null ? _a : null;
22475
22577
  const selectedMarket = (_b = tradingContext == null ? void 0 : tradingContext.selectedMarket) != null ? _b : null;
22476
22578
  const selectedOutcomeId = (_c = tradingContext == null ? void 0 : tradingContext.selectedOutcomeId) != null ? _c : null;
22477
- const resolvedEventTradingState = (0, import_react38.useMemo)(() => {
22579
+ const resolvedEventTradingState = (0, import_react39.useMemo)(() => {
22478
22580
  return eventTradingState != null ? eventTradingState : (0, import_hooks67.resolveEventTradingState)(selectedEvent);
22479
22581
  }, [eventTradingState, selectedEvent]);
22480
- const scopedSelectedEvent = (0, import_react38.useMemo)(() => {
22582
+ const scopedSelectedEvent = (0, import_react39.useMemo)(() => {
22481
22583
  var _a2;
22482
22584
  if (!selectedEvent) return null;
22483
22585
  const primaryMarketId = (_a2 = resolvedEventTradingState.primaryMarket) == null ? void 0 : _a2.id;
@@ -22487,7 +22589,7 @@ var PlaceOrder = ({
22487
22589
  );
22488
22590
  return isSelectedEventInScope ? selectedEvent : null;
22489
22591
  }, [(_d = resolvedEventTradingState.primaryMarket) == null ? void 0 : _d.id, selectedEvent]);
22490
- const scopedSelectedMarket = (0, import_react38.useMemo)(() => {
22592
+ const scopedSelectedMarket = (0, import_react39.useMemo)(() => {
22491
22593
  if (!selectedMarket) return resolvedEventTradingState.primaryMarket;
22492
22594
  const isSelectedMarketInScope = resolvedEventTradingState.marketStates.some(
22493
22595
  (item) => item.market.id === selectedMarket.id
@@ -22502,10 +22604,10 @@ var PlaceOrder = ({
22502
22604
  (outcome) => outcome.label.trim().toLowerCase() === "yes"
22503
22605
  )) != null ? _f : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.venueMarketOutcomes[0]) != null ? _g : null;
22504
22606
  const scopedSelectedOutcomeId = (_h = scopedSelectedOutcome == null ? void 0 : scopedSelectedOutcome.id) != null ? _h : null;
22505
- const resolvedTradingState = (0, import_react38.useMemo)(() => {
22607
+ const resolvedTradingState = (0, import_react39.useMemo)(() => {
22506
22608
  return (0, import_hooks67.resolveMarketTradingState)(scopedSelectedMarket);
22507
22609
  }, [scopedSelectedMarket]);
22508
- const resolvedReadOnlyMarket = (0, import_react38.useMemo)(() => {
22610
+ const resolvedReadOnlyMarket = (0, import_react39.useMemo)(() => {
22509
22611
  var _a2;
22510
22612
  if (resolvedEventTradingState.kind !== "resolved") {
22511
22613
  return scopedSelectedMarket;
@@ -22516,11 +22618,11 @@ var PlaceOrder = ({
22516
22618
  resolvedEventTradingState.primaryMarket,
22517
22619
  scopedSelectedMarket
22518
22620
  ]);
22519
- const resolvedReadOnlyTradingState = (0, import_react38.useMemo)(() => {
22621
+ const resolvedReadOnlyTradingState = (0, import_react39.useMemo)(() => {
22520
22622
  return (0, import_hooks67.resolveMarketTradingState)(resolvedReadOnlyMarket);
22521
22623
  }, [resolvedReadOnlyMarket]);
22522
22624
  const isEndedWithoutKnownWinner = showResolvingState && !resolvedEventTradingState.winningOutcome && !resolvedReadOnlyTradingState.winningOutcome;
22523
- const orderEligibility = (0, import_react38.useMemo)(
22625
+ const orderEligibility = (0, import_react39.useMemo)(
22524
22626
  () => (0, import_hooks67.resolveOrderEligibility)({
22525
22627
  event: scopedSelectedEvent,
22526
22628
  market: scopedSelectedMarket,
@@ -22543,7 +22645,7 @@ var PlaceOrder = ({
22543
22645
  enabled: Boolean(isAuthenticated && isPaperMode),
22544
22646
  mode: "paper"
22545
22647
  });
22546
- const paperTotalBalance = (0, import_react38.useMemo)(() => {
22648
+ const paperTotalBalance = (0, import_react39.useMemo)(() => {
22547
22649
  var _a2, _b2;
22548
22650
  const cash = (_b2 = (_a2 = paperBalancesQuery.balances) == null ? void 0 : _a2.cash) != null ? _b2 : [];
22549
22651
  return cash.reduce((sum, token) => {
@@ -22568,8 +22670,8 @@ var PlaceOrder = ({
22568
22670
  import_sdk24.Venue.kalshi,
22569
22671
  isAuthenticated
22570
22672
  );
22571
- const [isConnectKalshiModalOpen, setIsConnectKalshiModalOpen] = (0, import_react38.useState)(false);
22572
- const [isFundKalshiModalOpen, setIsFundKalshiModalOpen] = (0, import_react38.useState)(false);
22673
+ const [isConnectKalshiModalOpen, setIsConnectKalshiModalOpen] = (0, import_react39.useState)(false);
22674
+ const [isFundKalshiModalOpen, setIsFundKalshiModalOpen] = (0, import_react39.useState)(false);
22573
22675
  const livePrices = (0, import_hooks67.useLiveOutcomePrices)(
22574
22676
  scopedSelectedMarket ? [scopedSelectedMarket] : void 0
22575
22677
  );
@@ -22581,41 +22683,41 @@ var PlaceOrder = ({
22581
22683
  const clusterBestMidpointsByOutcomeId = (_j = clusterMidpointResult.bestMidpointsByOutcomeId) != null ? _j : clusterMidpointResult.prices;
22582
22684
  const clusterBestMidpoint = clusterMidpointResult.bestMidpoint;
22583
22685
  const clusterBestPricesRest = clusterMidpointResult.bestPrices;
22584
- const clusterBestPrices = (0, import_react38.useMemo)(
22686
+ const clusterBestPrices = (0, import_react39.useMemo)(
22585
22687
  () => (0, import_hooks67.mergeBestPricesPreferringLive)(clusterBestPricesRest, wsBestPrices),
22586
22688
  [clusterBestPricesRest, wsBestPrices]
22587
22689
  );
22588
- const [internalTab, setInternalTab] = (0, import_react38.useState)("buy");
22589
- const [executionType, setExecutionType] = (0, import_react38.useState)("market");
22590
- const [selectedLimitVenue, setSelectedLimitVenue] = (0, import_react38.useState)(null);
22591
- const [limitPrice, setLimitPrice] = (0, import_react38.useState)(0.5);
22592
- const [limitPriceInputValue, setLimitPriceInputValue] = (0, import_react38.useState)(formatLimitPriceInputValue(0.5));
22593
- const [limitPriceInputError, setLimitPriceInputError] = (0, import_react38.useState)(null);
22594
- const [limitExpirationType, setLimitExpirationType] = (0, import_react38.useState)("GTC");
22595
- const [limitExpirationDate, setLimitExpirationDate] = (0, import_react38.useState)(void 0);
22596
- const [limitExpirationTime, setLimitExpirationTime] = (0, import_react38.useState)("17:00");
22597
- const [limitExpirationDraftDate, setLimitExpirationDraftDate] = (0, import_react38.useState)();
22598
- const [limitExpirationDraftTime, setLimitExpirationDraftTime] = (0, import_react38.useState)("17:00");
22599
- const [limitExpirationPickerView, setLimitExpirationPickerView] = (0, import_react38.useState)("options");
22600
- const [isLimitExpirationPickerOpen, setIsLimitExpirationPickerOpen] = (0, import_react38.useState)(false);
22601
- const [internalAmount, setInternalAmount] = (0, import_react38.useState)(PLACE_ORDER_DEFAULT_AMOUNT);
22602
- const [sellFilledForOutcomeId, setSellFilledForOutcomeId] = (0, import_react38.useState)(null);
22603
- const [internalSlippage] = (0, import_react38.useState)(DEFAULT_SLIPPAGE_VALUE);
22604
- const [isRoutesExpanded, setIsRoutesExpanded] = (0, import_react38.useState)(false);
22605
- const [selectedRouteCardId, setSelectedRouteCardId] = (0, import_react38.useState)(null);
22606
- const [manualRouteSelectionIdentity, setManualRouteSelectionIdentity] = (0, import_react38.useState)(
22690
+ const [internalTab, setInternalTab] = (0, import_react39.useState)("buy");
22691
+ const [executionType, setExecutionType] = (0, import_react39.useState)("market");
22692
+ const [selectedLimitVenue, setSelectedLimitVenue] = (0, import_react39.useState)(null);
22693
+ const [limitPrice, setLimitPrice] = (0, import_react39.useState)(0.5);
22694
+ const [limitPriceInputValue, setLimitPriceInputValue] = (0, import_react39.useState)(formatLimitPriceInputValue(0.5));
22695
+ const [limitPriceInputError, setLimitPriceInputError] = (0, import_react39.useState)(null);
22696
+ const [limitExpirationType, setLimitExpirationType] = (0, import_react39.useState)("GTC");
22697
+ const [limitExpirationDate, setLimitExpirationDate] = (0, import_react39.useState)(void 0);
22698
+ const [limitExpirationTime, setLimitExpirationTime] = (0, import_react39.useState)("17:00");
22699
+ const [limitExpirationDraftDate, setLimitExpirationDraftDate] = (0, import_react39.useState)();
22700
+ const [limitExpirationDraftTime, setLimitExpirationDraftTime] = (0, import_react39.useState)("17:00");
22701
+ const [limitExpirationPickerView, setLimitExpirationPickerView] = (0, import_react39.useState)("options");
22702
+ const [isLimitExpirationPickerOpen, setIsLimitExpirationPickerOpen] = (0, import_react39.useState)(false);
22703
+ const [internalAmount, setInternalAmount] = (0, import_react39.useState)(PLACE_ORDER_DEFAULT_AMOUNT);
22704
+ const [sellFilledForOutcomeId, setSellFilledForOutcomeId] = (0, import_react39.useState)(null);
22705
+ const [internalSlippage] = (0, import_react39.useState)(DEFAULT_SLIPPAGE_VALUE);
22706
+ const [isRoutesExpanded, setIsRoutesExpanded] = (0, import_react39.useState)(false);
22707
+ const [selectedRouteCardId, setSelectedRouteCardId] = (0, import_react39.useState)(null);
22708
+ const [manualRouteSelectionIdentity, setManualRouteSelectionIdentity] = (0, import_react39.useState)(
22607
22709
  null
22608
22710
  );
22609
- const [isSplitDetailOpen, setIsSplitDetailOpen] = (0, import_react38.useState)(false);
22610
- const [buyGeoBlockSnapshot, setBuyGeoBlockSnapshot] = (0, import_react38.useState)(null);
22611
- const [submissionFeedback, setSubmissionFeedback] = (0, import_react38.useState)(null);
22612
- const [submissionProgressState, setSubmissionProgressState] = (0, import_react38.useState)(null);
22613
- const [isBeforeActionPending, setIsBeforeActionPending] = (0, import_react38.useState)(false);
22614
- const outcomes = (0, import_react38.useMemo)(
22711
+ const [isSplitDetailOpen, setIsSplitDetailOpen] = (0, import_react39.useState)(false);
22712
+ const [buyGeoBlockSnapshot, setBuyGeoBlockSnapshot] = (0, import_react39.useState)(null);
22713
+ const [submissionFeedback, setSubmissionFeedback] = (0, import_react39.useState)(null);
22714
+ const [submissionProgressState, setSubmissionProgressState] = (0, import_react39.useState)(null);
22715
+ const [isBeforeActionPending, setIsBeforeActionPending] = (0, import_react39.useState)(false);
22716
+ const outcomes = (0, import_react39.useMemo)(
22615
22717
  () => mapVenueMarketOutcomesToPlaceOrderOutcomes(scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.venueMarketOutcomes),
22616
22718
  [scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.venueMarketOutcomes]
22617
22719
  );
22618
- const selectedOutcomeDisplayPrice = (0, import_react38.useMemo)(() => {
22720
+ const selectedOutcomeDisplayPrice = (0, import_react39.useMemo)(() => {
22619
22721
  var _a2;
22620
22722
  if (!scopedSelectedOutcomeId || !scopedSelectedOutcome) return 0.5;
22621
22723
  return getDisplayOutcomePrice({
@@ -22638,25 +22740,25 @@ var PlaceOrder = ({
22638
22740
  scopedSelectedOutcomeId,
22639
22741
  tradingContext == null ? void 0 : tradingContext.tradeSide
22640
22742
  ]);
22641
- const buyTabRef = (0, import_react38.useRef)(null);
22642
- const sellTabRef = (0, import_react38.useRef)(null);
22643
- const expirationTriggerRef = (0, import_react38.useRef)(null);
22644
- const limitPriceInitializedForOutcomeRef = (0, import_react38.useRef)(void 0);
22645
- const expirationOptionRefs = (0, import_react38.useRef)([]);
22646
- const shouldFocusExpirationOptionsRef = (0, import_react38.useRef)(false);
22647
- const expirationTimeInputId = (0, import_react38.useId)();
22648
- const executionDebugStoreRef = (0, import_react38.useRef)(null);
22649
- const executionDebugAttemptIdRef = (0, import_react38.useRef)(null);
22650
- const submittedSelectionRef = (0, import_react38.useRef)(null);
22651
- const lastValidRouteCardsRef = (0, import_react38.useRef)(null);
22652
- (0, import_react38.useEffect)(() => {
22743
+ const buyTabRef = (0, import_react39.useRef)(null);
22744
+ const sellTabRef = (0, import_react39.useRef)(null);
22745
+ const expirationTriggerRef = (0, import_react39.useRef)(null);
22746
+ const limitPriceInitializedForOutcomeRef = (0, import_react39.useRef)(void 0);
22747
+ const expirationOptionRefs = (0, import_react39.useRef)([]);
22748
+ const shouldFocusExpirationOptionsRef = (0, import_react39.useRef)(false);
22749
+ const expirationTimeInputId = (0, import_react39.useId)();
22750
+ const executionDebugStoreRef = (0, import_react39.useRef)(null);
22751
+ const executionDebugAttemptIdRef = (0, import_react39.useRef)(null);
22752
+ const submittedSelectionRef = (0, import_react39.useRef)(null);
22753
+ const lastValidRouteCardsRef = (0, import_react39.useRef)(null);
22754
+ (0, import_react39.useEffect)(() => {
22653
22755
  if (!isExecutionDebugEnabled) {
22654
22756
  executionDebugStoreRef.current = null;
22655
22757
  return;
22656
22758
  }
22657
22759
  executionDebugStoreRef.current = enableExecutionDebugInBrowser();
22658
22760
  }, [isExecutionDebugEnabled]);
22659
- (0, import_react38.useEffect)(() => {
22761
+ (0, import_react39.useEffect)(() => {
22660
22762
  var _a2;
22661
22763
  if (!isLimitExpirationPickerOpen) return;
22662
22764
  if (limitExpirationPickerView !== "options") return;
@@ -22664,7 +22766,7 @@ var PlaceOrder = ({
22664
22766
  (_a2 = expirationOptionRefs.current[LIMIT_EXPIRATION_OPTION_COUNT - 1]) == null ? void 0 : _a2.focus();
22665
22767
  shouldFocusExpirationOptionsRef.current = false;
22666
22768
  }, [isLimitExpirationPickerOpen, limitExpirationPickerView]);
22667
- (0, import_react38.useEffect)(() => {
22769
+ (0, import_react39.useEffect)(() => {
22668
22770
  if (!isExecutionDebugEnabled) return;
22669
22771
  const store = executionDebugStoreRef.current;
22670
22772
  if (!store) return;
@@ -22679,8 +22781,8 @@ var PlaceOrder = ({
22679
22781
  const debouncedAmount = (0, import_hooks67.useDebouncedValue)(internalAmount, 300);
22680
22782
  const isQuoteInputEditing = internalAmount !== debouncedAmount;
22681
22783
  const isLimitOrder = showLimitOrders && executionType === "limit";
22682
- const isSell = (0, import_react38.useMemo)(() => internalTab === "sell", [internalTab]);
22683
- const limitVenueOptions = (0, import_react38.useMemo)(
22784
+ const isSell = (0, import_react39.useMemo)(() => internalTab === "sell", [internalTab]);
22785
+ const limitVenueOptions = (0, import_react39.useMemo)(
22684
22786
  () => {
22685
22787
  var _a2;
22686
22788
  return buildLimitOrderVenueOptions({
@@ -22692,7 +22794,7 @@ var PlaceOrder = ({
22692
22794
  },
22693
22795
  [clusterMidpointResult, livePrices, scopedSelectedMarket, scopedSelectedOutcomeId]
22694
22796
  );
22695
- const visibleLimitVenueOptions = (0, import_react38.useMemo)(() => {
22797
+ const visibleLimitVenueOptions = (0, import_react39.useMemo)(() => {
22696
22798
  return limitVenueOptions.filter((option) => {
22697
22799
  return (0, import_hooks67.getVenueAvailabilityState)({
22698
22800
  venueId: option.venue,
@@ -22710,7 +22812,7 @@ var PlaceOrder = ({
22710
22812
  enabled: Boolean(isAuthenticated && isSell),
22711
22813
  mode: isPaperMode ? "paper" : void 0
22712
22814
  });
22713
- const sellableSharesByVenue = (0, import_react38.useMemo)(
22815
+ const sellableSharesByVenue = (0, import_react39.useMemo)(
22714
22816
  () => isSell ? resolveSellableSharesByVenue({
22715
22817
  positions: executionPositions,
22716
22818
  market: scopedSelectedMarket,
@@ -22731,7 +22833,7 @@ var PlaceOrder = ({
22731
22833
  isPanelActive: isQuotePanelActive,
22732
22834
  isSubmitting: submissionProgressState != null || isBeforeActionPending || executeManaged.isPending || placeLimitOrder.isPending
22733
22835
  };
22734
- const limitVenueQuoteRequests = (0, import_react38.useMemo)(
22836
+ const limitVenueQuoteRequests = (0, import_react39.useMemo)(
22735
22837
  () => visibleLimitVenueOptions.map((option) => ({
22736
22838
  venue: option.venue,
22737
22839
  venueMarketOutcomeId: option.venueMarketOutcomeId
@@ -22752,11 +22854,11 @@ var PlaceOrder = ({
22752
22854
  enabled: isLimitVenueQuoteEnabled,
22753
22855
  refreshContext: smartRouteRefreshContext
22754
22856
  });
22755
- const limitVenueQuoteByVenue = (0, import_react38.useMemo)(
22857
+ const limitVenueQuoteByVenue = (0, import_react39.useMemo)(
22756
22858
  () => new Map(limitVenueQuotes.quotes.map((quote) => [quote.request.venue, quote])),
22757
22859
  [limitVenueQuotes.quotes]
22758
22860
  );
22759
- const geoBlockedLimitVenues = (0, import_react38.useMemo)(() => {
22861
+ const geoBlockedLimitVenues = (0, import_react39.useMemo)(() => {
22760
22862
  var _a2;
22761
22863
  const venues = /* @__PURE__ */ new Set();
22762
22864
  for (const quote of limitVenueQuotes.quotes) {
@@ -22766,7 +22868,7 @@ var PlaceOrder = ({
22766
22868
  }
22767
22869
  return venues;
22768
22870
  }, [limitVenueQuotes.quotes]);
22769
- const availableLimitVenueOptions = (0, import_react38.useMemo)(() => {
22871
+ const availableLimitVenueOptions = (0, import_react39.useMemo)(() => {
22770
22872
  return visibleLimitVenueOptions.filter((option) => {
22771
22873
  var _a2;
22772
22874
  return !geoBlockedLimitVenues.has(option.venue) && // A limit SELL rests against shares held at that specific venue, so a
@@ -22788,11 +22890,11 @@ var PlaceOrder = ({
22788
22890
  sellableSharesByVenue,
22789
22891
  visibleLimitVenueOptions
22790
22892
  ]);
22791
- const automaticLimitVenueOption = (0, import_react38.useMemo)(
22893
+ const automaticLimitVenueOption = (0, import_react39.useMemo)(
22792
22894
  () => resolveAutomaticLimitOrderVenueOption(availableLimitVenueOptions, internalTab),
22793
22895
  [availableLimitVenueOptions, internalTab]
22794
22896
  );
22795
- const selectedLimitVenueOption = (0, import_react38.useMemo)(() => {
22897
+ const selectedLimitVenueOption = (0, import_react39.useMemo)(() => {
22796
22898
  if (selectedLimitVenue) {
22797
22899
  const selectedOption = availableLimitVenueOptions.find(
22798
22900
  (option) => option.venue === selectedLimitVenue
@@ -22801,7 +22903,7 @@ var PlaceOrder = ({
22801
22903
  }
22802
22904
  return automaticLimitVenueOption;
22803
22905
  }, [automaticLimitVenueOption, availableLimitVenueOptions, selectedLimitVenue]);
22804
- (0, import_react38.useEffect)(() => {
22906
+ (0, import_react39.useEffect)(() => {
22805
22907
  if (!selectedLimitVenue || !geoBlockedLimitVenues.has(selectedLimitVenue)) return;
22806
22908
  setSelectedLimitVenue(null);
22807
22909
  }, [geoBlockedLimitVenues, selectedLimitVenue]);
@@ -22830,7 +22932,7 @@ var PlaceOrder = ({
22830
22932
  } : {}), {
22831
22933
  refreshContext: smartRouteRefreshContext
22832
22934
  }));
22833
- (0, import_react38.useEffect)(() => {
22935
+ (0, import_react39.useEffect)(() => {
22834
22936
  var _a2, _b2, _c2;
22835
22937
  if (isSell || smartRoute.isFetching || ((_a2 = smartRoute.data) == null ? void 0 : _a2.venueMarketOutcomeId) !== scopedSelectedOutcomeId) {
22836
22938
  return;
@@ -22852,7 +22954,7 @@ var PlaceOrder = ({
22852
22954
  smartRoute.isFetching,
22853
22955
  user == null ? void 0 : user.id
22854
22956
  ]);
22855
- const inheritedBuyGeoBlockedVenues = (0, import_react38.useMemo)(() => {
22957
+ const inheritedBuyGeoBlockedVenues = (0, import_react39.useMemo)(() => {
22856
22958
  var _a2, _b2;
22857
22959
  if (!isSell || !buyGeoBlockSnapshot || !scopedSelectedOutcomeId) return void 0;
22858
22960
  if (buyGeoBlockSnapshot.eventId !== ((_a2 = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.id) != null ? _a2 : null)) return void 0;
@@ -22868,7 +22970,7 @@ var PlaceOrder = ({
22868
22970
  scopedSelectedOutcomeId,
22869
22971
  user == null ? void 0 : user.id
22870
22972
  ]);
22871
- const venueSellQuoteRequests = (0, import_react38.useMemo)(
22973
+ const venueSellQuoteRequests = (0, import_react39.useMemo)(
22872
22974
  () => {
22873
22975
  var _a2;
22874
22976
  return isSell && !smartRoute.isLoading && ((_a2 = smartRoute.data) == null ? void 0 : _a2.venueMarketOutcomeId) === scopedSelectedOutcomeId ? buildVenueSellQuoteRequests({
@@ -22888,7 +22990,7 @@ var PlaceOrder = ({
22888
22990
  enabled: isSell && isSmartRouteEnabled && !smartRoute.isLoading && ((_o = smartRoute.data) == null ? void 0 : _o.venueMarketOutcomeId) === scopedSelectedOutcomeId,
22889
22991
  refreshContext: smartRouteRefreshContext
22890
22992
  });
22891
- const currentSellableShares = (0, import_react38.useMemo)(() => {
22993
+ const currentSellableShares = (0, import_react39.useMemo)(() => {
22892
22994
  var _a2, _b2;
22893
22995
  const sharesFromQuote = (_b2 = (_a2 = smartRoute.data) == null ? void 0 : _a2.positionAvailability) == null ? void 0 : _b2.totalSellableShares;
22894
22996
  if (typeof sharesFromQuote === "number" && Number.isFinite(sharesFromQuote)) {
@@ -22898,22 +23000,22 @@ var PlaceOrder = ({
22898
23000
  for (const size of sellableSharesByVenue.values()) resolvedShares += size;
22899
23001
  return Math.max(0, resolvedShares);
22900
23002
  }, [sellableSharesByVenue, (_q = (_p = smartRoute.data) == null ? void 0 : _p.positionAvailability) == null ? void 0 : _q.totalSellableShares]);
22901
- const maxSellableShares = (0, import_react38.useMemo)(
23003
+ const maxSellableShares = (0, import_react39.useMemo)(
22902
23004
  () => floorToDecimals(currentSellableShares, SELL_SHARE_INPUT_DECIMALS),
22903
23005
  [currentSellableShares]
22904
23006
  );
22905
23007
  const isCurrentSellableSharesLoading = isSell && isAuthenticated && !(typeof ((_s = (_r = smartRoute.data) == null ? void 0 : _r.positionAvailability) == null ? void 0 : _s.totalSellableShares) === "number") && (isExecutionPositionsLoading || isExecutionPositionsFetching);
22906
- const displayedCurrentSellableShares = (0, import_react38.useMemo)(() => {
23008
+ const displayedCurrentSellableShares = (0, import_react39.useMemo)(() => {
22907
23009
  if (!Number.isFinite(currentSellableShares) || currentSellableShares <= 0) return 0;
22908
23010
  return floorToDecimals(currentSellableShares, SELL_SHARE_DISPLAY_DECIMALS);
22909
23011
  }, [currentSellableShares]);
22910
- const displayedCurrentSellableSharesLabel = (0, import_react38.useMemo)(
23012
+ const displayedCurrentSellableSharesLabel = (0, import_react39.useMemo)(
22911
23013
  () => `${formatFlooredShareAmount(maxSellableShares, SELL_SHARE_DISPLAY_DECIMALS)} shares`,
22912
23014
  [maxSellableShares]
22913
23015
  );
22914
23016
  const isAtMaxSellableShares = isSell && maxSellableShares > 0 && Math.abs(internalAmount - maxSellableShares) < 1e-9;
22915
23017
  const isSellAmountAboveAvailability = isSell && ((_t = smartRoute.data) == null ? void 0 : _t.venueMarketOutcomeId) === scopedSelectedOutcomeId && typeof ((_u = smartRoute.data.positionAvailability) == null ? void 0 : _u.totalSellableShares) === "number" && internalAmount > maxSellableShares;
22916
- (0, import_react38.useEffect)(() => {
23018
+ (0, import_react39.useEffect)(() => {
22917
23019
  if (submissionProgressState != null) return;
22918
23020
  if (!isSell || isCurrentSellableSharesLoading) return;
22919
23021
  if (scopedSelectedOutcomeId === sellFilledForOutcomeId) return;
@@ -22929,7 +23031,7 @@ var PlaceOrder = ({
22929
23031
  onAmountChange,
22930
23032
  submissionProgressState
22931
23033
  ]);
22932
- (0, import_react38.useEffect)(() => {
23034
+ (0, import_react39.useEffect)(() => {
22933
23035
  var _a2, _b2;
22934
23036
  if (submissionProgressState != null || !isSell) return;
22935
23037
  if (((_a2 = smartRoute.data) == null ? void 0 : _a2.venueMarketOutcomeId) !== scopedSelectedOutcomeId) return;
@@ -22953,7 +23055,7 @@ var PlaceOrder = ({
22953
23055
  submissionProgressState
22954
23056
  ]);
22955
23057
  const scopedSmartRouteData = ((_y = smartRoute.data) == null ? void 0 : _y.venueMarketOutcomeId) === scopedSelectedOutcomeId ? smartRoute.data : null;
22956
- const routeCards = (0, import_react38.useMemo)(() => {
23058
+ const routeCards = (0, import_react39.useMemo)(() => {
22957
23059
  const eventVenues = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.venueMarkets.map((market) => market.venue);
22958
23060
  if (isSell) {
22959
23061
  return buildLiveSellRouteCards({
@@ -22997,7 +23099,22 @@ var PlaceOrder = ({
22997
23099
  const selectedManualRouteCard = manualRouteSelectionIdentity ? routeCards.find(
22998
23100
  (card) => getPlaceOrderRouteCardIdentity(card) === manualRouteSelectionIdentity
22999
23101
  ) : void 0;
23000
- const resolvedSelectedRouteCardId = (0, import_react38.useMemo)(() => {
23102
+ const legacyKalshiAccount = (0, import_react39.useMemo)(
23103
+ () => {
23104
+ var _a2;
23105
+ return (_a2 = user == null ? void 0 : user.venueAccounts) == null ? void 0 : _a2.find((venueAccount) => venueAccount.venue === "kalshi");
23106
+ },
23107
+ [user == null ? void 0 : user.venueAccounts]
23108
+ );
23109
+ const isKalshiAccountActive = (_B = kalshiKeyStatus == null ? void 0 : kalshiKeyStatus.connected) != null ? _B : (legacyKalshiAccount == null ? void 0 : legacyKalshiAccount.status) === "active";
23110
+ const hasKalshiConnectionState = kalshiKeyStatus !== void 0 || (user == null ? void 0 : user.venueAccounts) != null;
23111
+ const isKalshiAvailable = (0, import_hooks67.getVenueAvailabilityState)({
23112
+ venueId: "kalshi",
23113
+ disabledVenues,
23114
+ isConfigLoading: isAppConfigLoading
23115
+ }) === "available";
23116
+ const isKalshiDisconnected = !isPaperMode && isAuthenticated && hasKalshiConnectionState && isKalshiAvailable && !isKalshiAccountActive;
23117
+ const resolvedSelectedRouteCardId = (0, import_react39.useMemo)(() => {
23001
23118
  var _a2;
23002
23119
  if (selectedManualRouteCard && !selectedManualRouteCard.isUnavailable) {
23003
23120
  return selectedManualRouteCard.id;
@@ -23006,17 +23123,20 @@ var PlaceOrder = ({
23006
23123
  return selectedRouteCardId;
23007
23124
  }
23008
23125
  if (routeCards.length === 0) return null;
23009
- return resolveDefaultRouteCardId(routeCards, isSell ? void 0 : (_a2 = smartRoute.data) == null ? void 0 : _a2.status);
23126
+ return resolveDefaultRouteCardId(routeCards, isSell ? void 0 : (_a2 = smartRoute.data) == null ? void 0 : _a2.status, {
23127
+ isKalshiDisconnected
23128
+ });
23010
23129
  }, [
23130
+ isKalshiDisconnected,
23011
23131
  isSell,
23012
23132
  isRouteCardsTransient,
23013
23133
  manualRouteSelectionIdentity,
23014
23134
  routeCards,
23015
23135
  selectedManualRouteCard,
23016
23136
  selectedRouteCardId,
23017
- (_B = smartRoute.data) == null ? void 0 : _B.status
23137
+ (_C = smartRoute.data) == null ? void 0 : _C.status
23018
23138
  ]);
23019
- (0, import_react38.useEffect)(() => {
23139
+ (0, import_react39.useEffect)(() => {
23020
23140
  if (routeCards.length === 0) {
23021
23141
  if (isRouteCardsTransient) return;
23022
23142
  setSelectedRouteCardId(null);
@@ -23040,19 +23160,19 @@ var PlaceOrder = ({
23040
23160
  selectedRouteCardId
23041
23161
  ]);
23042
23162
  const isSubmissionLocked = submissionProgressState != null;
23043
- const isSubmissionLockedRef = (0, import_react38.useRef)(isSubmissionLocked);
23163
+ const isSubmissionLockedRef = (0, import_react39.useRef)(isSubmissionLocked);
23044
23164
  isSubmissionLockedRef.current = isSubmissionLocked;
23045
- (0, import_react38.useEffect)(() => {
23165
+ (0, import_react39.useEffect)(() => {
23046
23166
  if (isSubmissionLockedRef.current) return;
23047
23167
  setSubmissionFeedback(null);
23048
23168
  setSubmissionProgressState(null);
23049
23169
  }, [executionType, internalAmount, internalSlippage, internalTab, scopedSelectedOutcomeId]);
23050
- (0, import_react38.useEffect)(() => {
23170
+ (0, import_react39.useEffect)(() => {
23051
23171
  if (showLimitOrders || executionType !== "limit") return;
23052
23172
  setExecutionType("market");
23053
23173
  setIsLimitExpirationPickerOpen(false);
23054
23174
  }, [executionType, showLimitOrders]);
23055
- (0, import_react38.useEffect)(() => {
23175
+ (0, import_react39.useEffect)(() => {
23056
23176
  if (executionType !== "limit") {
23057
23177
  limitPriceInitializedForOutcomeRef.current = void 0;
23058
23178
  return;
@@ -23065,18 +23185,18 @@ var PlaceOrder = ({
23065
23185
  setLimitPriceInputValue(formatLimitPriceInputValue(nextLimitPrice));
23066
23186
  setLimitPriceInputError(null);
23067
23187
  }, [executionType, scopedSelectedOutcomeId, selectedOutcomeDisplayPrice]);
23068
- (0, import_react38.useEffect)(() => {
23188
+ (0, import_react39.useEffect)(() => {
23069
23189
  setSelectedLimitVenue(null);
23070
23190
  }, [scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.id, scopedSelectedOutcomeId]);
23071
- (0, import_react38.useEffect)(() => {
23191
+ (0, import_react39.useEffect)(() => {
23072
23192
  setSelectedRouteCardId(null);
23073
23193
  setManualRouteSelectionIdentity(null);
23074
23194
  setIsRoutesExpanded(false);
23075
23195
  setIsSplitDetailOpen(false);
23076
23196
  }, [executionType, internalTab, scopedSelectedOutcomeId]);
23077
23197
  const orderedRouteCards = routeCards;
23078
- const selectedRouteCard = (_D = (_C = orderedRouteCards.find((card) => card.id === resolvedSelectedRouteCardId)) != null ? _C : orderedRouteCards[0]) != null ? _D : null;
23079
- const selectedSharedKycVenue = (0, import_react38.useMemo)(() => {
23198
+ const selectedRouteCard = (_E = (_D = orderedRouteCards.find((card) => card.id === resolvedSelectedRouteCardId)) != null ? _D : orderedRouteCards[0]) != null ? _E : null;
23199
+ const selectedSharedKycVenue = (0, import_react39.useMemo)(() => {
23080
23200
  var _a2, _b2;
23081
23201
  const candidateVenue = isLimitOrder ? selectedLimitVenueOption == null ? void 0 : selectedLimitVenueOption.venue : (_b2 = (_a2 = selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData.fills.find(
23082
23202
  (fill) => venueRequiresSharedKyc({ venue: fill.venue })
@@ -23086,30 +23206,16 @@ var PlaceOrder = ({
23086
23206
  return parsedVenue.success ? parsedVenue.data : null;
23087
23207
  }, [isLimitOrder, selectedLimitVenueOption == null ? void 0 : selectedLimitVenueOption.venue, selectedRouteCard]);
23088
23208
  const needsSharedKycVerification = !isPaperMode && isAuthenticated && sharedKyc !== void 0 && selectedSharedKycVenue !== null && sharedKyc.status !== "verified";
23089
- const isKalshiRoute = (0, import_react38.useMemo)(() => {
23209
+ const isKalshiRoute = (0, import_react39.useMemo)(() => {
23090
23210
  if (isLimitOrder) return (selectedLimitVenueOption == null ? void 0 : selectedLimitVenueOption.venue) === import_sdk24.Venue.kalshi;
23091
23211
  if (selectedRouteCard) {
23092
23212
  return selectedRouteCard.venue === "kalshi" || selectedRouteCard.quoteData.fills.some((f) => f.venue === "kalshi");
23093
23213
  }
23094
23214
  return (scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.venue) === "kalshi";
23095
23215
  }, [isLimitOrder, selectedLimitVenueOption == null ? void 0 : selectedLimitVenueOption.venue, selectedRouteCard, scopedSelectedMarket]);
23096
- const displayedBalance = isPaperMode ? paperTotalBalance : isKalshiRoute ? (_E = liveBalanceState.kalshiBalance) != null ? _E : 0 : liveAvailableBalance;
23097
- const legacyKalshiAccount = (0, import_react38.useMemo)(
23098
- () => {
23099
- var _a2;
23100
- return (_a2 = user == null ? void 0 : user.venueAccounts) == null ? void 0 : _a2.find((venueAccount) => venueAccount.venue === "kalshi");
23101
- },
23102
- [user == null ? void 0 : user.venueAccounts]
23103
- );
23104
- const isKalshiAccountActive = (_F = kalshiKeyStatus == null ? void 0 : kalshiKeyStatus.connected) != null ? _F : (legacyKalshiAccount == null ? void 0 : legacyKalshiAccount.status) === "active";
23105
- const hasKalshiConnectionState = kalshiKeyStatus !== void 0 || (user == null ? void 0 : user.venueAccounts) != null;
23106
- const isKalshiAvailable = (0, import_hooks67.getVenueAvailabilityState)({
23107
- venueId: "kalshi",
23108
- disabledVenues,
23109
- isConfigLoading: isAppConfigLoading
23110
- }) === "available";
23111
- const needsKalshiConnection = !isPaperMode && isAuthenticated && hasKalshiConnectionState && isKalshiAvailable && isKalshiRoute && !isKalshiAccountActive;
23112
- const handleVerifyKalshi = (0, import_react38.useCallback)(
23216
+ const displayedBalance = isPaperMode ? paperTotalBalance : isKalshiRoute ? (_F = liveBalanceState.kalshiBalance) != null ? _F : 0 : liveAvailableBalance;
23217
+ const needsKalshiConnection = isKalshiDisconnected && isKalshiRoute;
23218
+ const handleVerifyKalshi = (0, import_react39.useCallback)(
23113
23219
  (credentials) => __async(null, null, function* () {
23114
23220
  if (onConnectKalshi) {
23115
23221
  yield onConnectKalshi(credentials);
@@ -23127,7 +23233,7 @@ var PlaceOrder = ({
23127
23233
  }),
23128
23234
  [aggClient, onConnectKalshi, refetchKalshiKeyStatus]
23129
23235
  );
23130
- const handleRouteCardSelect = (0, import_react38.useCallback)(
23236
+ const handleRouteCardSelect = (0, import_react39.useCallback)(
23131
23237
  (cardId) => {
23132
23238
  const card = routeCards.find((routeCard) => routeCard.id === cardId);
23133
23239
  if (!card || card.isUnavailable) return;
@@ -23164,7 +23270,7 @@ var PlaceOrder = ({
23164
23270
  mode: isPaperMode ? "paper" : void 0,
23165
23271
  enabled: ((submissionProgressState == null ? void 0 : submissionProgressState.phase) === "submitting" || (submissionProgressState == null ? void 0 : submissionProgressState.phase) === "executing") && !!((_I = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) == null ? void 0 : _I.length)
23166
23272
  });
23167
- const executionProgressFloorRef = (0, import_react38.useRef)({
23273
+ const executionProgressFloorRef = (0, import_react39.useRef)({
23168
23274
  quoteId: null,
23169
23275
  value: 0
23170
23276
  });
@@ -23175,7 +23281,7 @@ var PlaceOrder = ({
23175
23281
  const executionDateSource = (_R = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.endDate) != null ? _R : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.endDate;
23176
23282
  const executionDateLabel = executionDateSource ? getTradingDateLabel(executionDateSource) : "";
23177
23283
  const executionQuoteData = (_T = (_S = submissionProgressState == null ? void 0 : submissionProgressState.quoteData) != null ? _S : selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData) != null ? _T : null;
23178
- const executionOrderGroups = (0, import_react38.useMemo)(() => {
23284
+ const executionOrderGroups = (0, import_react39.useMemo)(() => {
23179
23285
  var _a2, _b2, _c2;
23180
23286
  if (!executionQuoteData) return [];
23181
23287
  return deriveExecutionOrderGroups({
@@ -23198,7 +23304,7 @@ var PlaceOrder = ({
23198
23304
  (_U = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) == null ? void 0 : _U.length,
23199
23305
  tradingLabels
23200
23306
  ]);
23201
- const executionProgressPercent = (0, import_react38.useMemo)(() => {
23307
+ const executionProgressPercent = (0, import_react39.useMemo)(() => {
23202
23308
  var _a2, _b2, _c2;
23203
23309
  const quoteId = (_a2 = submissionProgressState == null ? void 0 : submissionProgressState.quoteId) != null ? _a2 : null;
23204
23310
  const previousProgress = executionProgressFloorRef.current.quoteId === quoteId ? executionProgressFloorRef.current.value : 0;
@@ -23218,7 +23324,7 @@ var PlaceOrder = ({
23218
23324
  submissionProgressState == null ? void 0 : submissionProgressState.orderIds,
23219
23325
  submissionProgressState == null ? void 0 : submissionProgressState.quoteId
23220
23326
  ]);
23221
- const buildExecutionSummary = (0, import_react38.useCallback)(
23327
+ const buildExecutionSummary = (0, import_react39.useCallback)(
23222
23328
  (quoteData, executionVenue, orderId, partialFillSummary) => {
23223
23329
  var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2;
23224
23330
  if (!quoteData) return void 0;
@@ -23322,7 +23428,7 @@ var PlaceOrder = ({
23322
23428
  tradingLabels
23323
23429
  ]
23324
23430
  );
23325
- (0, import_react38.useEffect)(() => {
23431
+ (0, import_react39.useEffect)(() => {
23326
23432
  if (executionProgress.phase === "order_submitted") {
23327
23433
  const submittedOrder = executionProgress.submittedOrders[0];
23328
23434
  setSubmissionProgressState((prev) => {
@@ -23335,7 +23441,7 @@ var PlaceOrder = ({
23335
23441
  });
23336
23442
  }
23337
23443
  }, [executionProgress.phase, executionProgress.submittedOrders]);
23338
- (0, import_react38.useEffect)(() => {
23444
+ (0, import_react39.useEffect)(() => {
23339
23445
  var _a2, _b2;
23340
23446
  const dp = executionProgress.dagProgress;
23341
23447
  if (!dp) return;
@@ -23390,7 +23496,7 @@ var PlaceOrder = ({
23390
23496
  return __spreadProps(__spreadValues({}, prev), { dagProgress: dp });
23391
23497
  });
23392
23498
  }, [executionOrderGroups, executionProgress.dagProgress, tradingLabels]);
23393
- (0, import_react38.useEffect)(() => {
23499
+ (0, import_react39.useEffect)(() => {
23394
23500
  const orderIds = submissionProgressState == null ? void 0 : submissionProgressState.orderIds;
23395
23501
  if (!(orderIds == null ? void 0 : orderIds.length)) return;
23396
23502
  const aggregateStatus = deriveAggregateOrderStatus(
@@ -23451,7 +23557,7 @@ var PlaceOrder = ({
23451
23557
  tradingLabels
23452
23558
  ]);
23453
23559
  const estDurationMs = executionQuoteData && typeof executionQuoteData.estDurationMs === "number" ? executionQuoteData.estDurationMs : 6e4;
23454
- (0, import_react38.useEffect)(() => {
23560
+ (0, import_react39.useEffect)(() => {
23455
23561
  const phase = submissionProgressState == null ? void 0 : submissionProgressState.phase;
23456
23562
  if (phase !== "submitting" && phase !== "executing") return;
23457
23563
  const timeoutMs = Math.max(6e4, 2 * estDurationMs);
@@ -23466,7 +23572,7 @@ var PlaceOrder = ({
23466
23572
  }, timeoutMs);
23467
23573
  return () => clearTimeout(id);
23468
23574
  }, [submissionProgressState == null ? void 0 : submissionProgressState.phase, estDurationMs, tradingLabels.orderStillSettling]);
23469
- const emitTerminalOrderNotifications = (0, import_react38.useCallback)(() => {
23575
+ const emitTerminalOrderNotifications = (0, import_react39.useCallback)(() => {
23470
23576
  const toast = toastCtx == null ? void 0 : toastCtx.toast;
23471
23577
  if (!toast) return;
23472
23578
  for (const event of executionProgress.terminalOrderEvents) {
@@ -23495,7 +23601,7 @@ var PlaceOrder = ({
23495
23601
  });
23496
23602
  }
23497
23603
  }, [executionProgress.terminalOrderEvents, labels, toastCtx]);
23498
- (0, import_react38.useEffect)(() => {
23604
+ (0, import_react39.useEffect)(() => {
23499
23605
  var _a2, _b2;
23500
23606
  if (!submissionProgressState) return;
23501
23607
  onExecutionStateChange == null ? void 0 : onExecutionStateChange(submissionProgressState);
@@ -23570,7 +23676,7 @@ var PlaceOrder = ({
23570
23676
  const isBelowVenueMinimumFromQuote = isQuoteBelowVenueMinimum(activeQuoteData);
23571
23677
  const isBelowMinimum = isBelowClientMinimum || isBelowVenueMinimumFromQuote;
23572
23678
  const belowMinimumMessage = isBelowClientMinimum ? tradingLabels.minimumOrderAmount(MIN_BUY_ORDER_AMOUNT) : tradingLabels.minOrderSizeViolated;
23573
- const quoteStatus = (0, import_react38.useMemo)(() => {
23679
+ const quoteStatus = (0, import_react39.useMemo)(() => {
23574
23680
  if (!orderEligibility.canPlaceOrder) return void 0;
23575
23681
  return resolvePlaceOrderQuoteStatus({
23576
23682
  amount: internalAmount,
@@ -23587,7 +23693,7 @@ var PlaceOrder = ({
23587
23693
  scopedSelectedMarket,
23588
23694
  tradingLabels
23589
23695
  ]);
23590
- const smartRouteErrorMessage = (0, import_react38.useMemo)(() => {
23696
+ const smartRouteErrorMessage = (0, import_react39.useMemo)(() => {
23591
23697
  var _a2;
23592
23698
  const quoteError = (_a2 = smartRoute.error) != null ? _a2 : isSell ? venueSellQuotes.error : null;
23593
23699
  if (!quoteError || orderedRouteCards.length > 0) return null;
@@ -23598,26 +23704,26 @@ var PlaceOrder = ({
23598
23704
  });
23599
23705
  }, [isSell, orderedRouteCards.length, smartRoute.error, tradingLabels, venueSellQuotes.error]);
23600
23706
  const progressActionLabel = (internalTab === "buy" ? tradingLabels.buyingOutcome(selectedOutcomeLabel) : tradingLabels.sellingOutcome(selectedOutcomeLabel)).trim();
23601
- const retryRemainingAmount = (0, import_react38.useMemo)(() => {
23707
+ const retryRemainingAmount = (0, import_react39.useMemo)(() => {
23602
23708
  return getCanonicalPlaceOrderUnfilledRemaining({
23603
23709
  originalAmount: internalAmount,
23604
23710
  tradeSide: internalTab,
23605
23711
  terminalOrderEvents: executionProgress.terminalOrderEvents
23606
23712
  });
23607
23713
  }, [executionProgress.terminalOrderEvents, internalAmount, internalTab]);
23608
- const canRetryRemaining = (0, import_react38.useMemo)(() => {
23714
+ const canRetryRemaining = (0, import_react39.useMemo)(() => {
23609
23715
  if (retryRemainingAmount == null) return false;
23610
23716
  const minRemainder = isSell ? MIN_SELL_ORDER_SHARES : MIN_BUY_ORDER_AMOUNT;
23611
23717
  return retryRemainingAmount >= minRemainder;
23612
23718
  }, [isSell, retryRemainingAmount]);
23613
23719
  const PARTIAL_FILL_AUTO_SUCCESS_THRESHOLD = 0.95;
23614
- const shouldAutoSkipPartialFill = (0, import_react38.useMemo)(() => {
23720
+ const shouldAutoSkipPartialFill = (0, import_react39.useMemo)(() => {
23615
23721
  if (internalAmount <= 0 || retryRemainingAmount == null) return false;
23616
23722
  const filled = Math.max(0, internalAmount - retryRemainingAmount);
23617
23723
  const fillRatio = filled / internalAmount;
23618
23724
  return fillRatio >= PARTIAL_FILL_AUTO_SUCCESS_THRESHOLD || !canRetryRemaining;
23619
23725
  }, [canRetryRemaining, internalAmount, retryRemainingAmount]);
23620
- const failureSummary = (0, import_react38.useMemo)(() => {
23726
+ const failureSummary = (0, import_react39.useMemo)(() => {
23621
23727
  var _a2;
23622
23728
  if ((submissionProgressState == null ? void 0 : submissionProgressState.phase) !== "failed") return void 0;
23623
23729
  const quoteData = (_a2 = selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData) != null ? _a2 : activeQuoteData;
@@ -23690,14 +23796,14 @@ var PlaceOrder = ({
23690
23796
  submissionProgressState,
23691
23797
  tradingLabels
23692
23798
  ]);
23693
- const displayedToWinHint = (0, import_react38.useMemo)(() => {
23799
+ const displayedToWinHint = (0, import_react39.useMemo)(() => {
23694
23800
  if (!selectedRouteCard) return "";
23695
23801
  const averagePrice = selectedRouteCard.executionPrice;
23696
23802
  return averagePrice == null ? "" : tradingLabels.averagePrice(averagePrice);
23697
23803
  }, [selectedRouteCard, tradingLabels]);
23698
23804
  const displayedToWinValue = (_Y = selectedRouteCard == null ? void 0 : selectedRouteCard.numericValue) != null ? _Y : 0;
23699
- const originalLimitPriceRaw = (0, import_react38.useMemo)(() => toLimitPriceRaw(limitPrice), [limitPrice]);
23700
- const limitPriceAdjustmentByVenue = (0, import_react38.useMemo)(() => {
23805
+ const originalLimitPriceRaw = (0, import_react39.useMemo)(() => toLimitPriceRaw(limitPrice), [limitPrice]);
23806
+ const limitPriceAdjustmentByVenue = (0, import_react39.useMemo)(() => {
23701
23807
  var _a2;
23702
23808
  const adjustments = /* @__PURE__ */ new Map();
23703
23809
  for (const option of visibleLimitVenueOptions) {
@@ -23725,7 +23831,7 @@ var PlaceOrder = ({
23725
23831
  }, [internalTab, limitVenueQuoteByVenue, originalLimitPriceRaw, visibleLimitVenueOptions]);
23726
23832
  const selectedLimitPriceAdjustment = selectedLimitVenueOption ? limitPriceAdjustmentByVenue.get(selectedLimitVenueOption.venue) : void 0;
23727
23833
  const selectedLimitPriceRaw = (_Z = selectedLimitPriceAdjustment == null ? void 0 : selectedLimitPriceAdjustment.adjustedPriceRaw) != null ? _Z : originalLimitPriceRaw;
23728
- const limitPriceAdjustmentMessage = (0, import_react38.useMemo)(() => {
23834
+ const limitPriceAdjustmentMessage = (0, import_react39.useMemo)(() => {
23729
23835
  if (!selectedLimitVenueOption || !(selectedLimitPriceAdjustment == null ? void 0 : selectedLimitPriceAdjustment.adjusted) || !selectedLimitPriceAdjustment.tickSizeRaw) {
23730
23836
  return "";
23731
23837
  }
@@ -23743,7 +23849,7 @@ var PlaceOrder = ({
23743
23849
  selectedLimitVenueOption,
23744
23850
  tradingLabels
23745
23851
  ]);
23746
- const limitOrderPayload = (0, import_react38.useMemo)(() => {
23852
+ const limitOrderPayload = (0, import_react39.useMemo)(() => {
23747
23853
  if (!selectedLimitVenueOption || internalAmount <= 0) return null;
23748
23854
  if (limitPriceInputError) return null;
23749
23855
  const effectivePriceRaw = BigInt(selectedLimitPriceRaw);
@@ -23779,7 +23885,7 @@ var PlaceOrder = ({
23779
23885
  selectedLimitVenueOption,
23780
23886
  selectedLimitPriceRaw
23781
23887
  ]);
23782
- const resolvedLimitExpirationDraftDate = (0, import_react38.useMemo)(() => {
23888
+ const resolvedLimitExpirationDraftDate = (0, import_react39.useMemo)(() => {
23783
23889
  return resolveLimitExpirationDate({
23784
23890
  expirationType: "CUSTOM",
23785
23891
  customDate: limitExpirationDraftDate,
@@ -23787,7 +23893,7 @@ var PlaceOrder = ({
23787
23893
  });
23788
23894
  }, [limitExpirationDraftDate, limitExpirationDraftTime]);
23789
23895
  const isLimitExpirationDraftValid = isFutureLimitExpiration(resolvedLimitExpirationDraftDate);
23790
- const resolvedCustomExpirationDate = (0, import_react38.useMemo)(() => {
23896
+ const resolvedCustomExpirationDate = (0, import_react39.useMemo)(() => {
23791
23897
  return resolveLimitExpirationDate({
23792
23898
  expirationType: "CUSTOM",
23793
23899
  customDate: limitExpirationDate,
@@ -23809,7 +23915,7 @@ var PlaceOrder = ({
23809
23915
  expiresAt: serializeLimitOrderExpiration(expirationDate)
23810
23916
  });
23811
23917
  };
23812
- const displayedLimitToWinValue = (0, import_react38.useMemo)(() => {
23918
+ const displayedLimitToWinValue = (0, import_react39.useMemo)(() => {
23813
23919
  if (!limitOrderPayload) return 0;
23814
23920
  const size = Number(BigInt(limitOrderPayload.sizeRaw)) / Number(import_sdk24.LIMIT_PRICE_RAW_SCALE);
23815
23921
  if (internalTab === "buy") return size;
@@ -23820,7 +23926,7 @@ var PlaceOrder = ({
23820
23926
  )
23821
23927
  ) / Number(import_sdk24.LIMIT_PRICE_RAW_SCALE);
23822
23928
  }, [internalTab, limitOrderPayload]);
23823
- const limitRouteCards = (0, import_react38.useMemo)(() => {
23929
+ const limitRouteCards = (0, import_react39.useMemo)(() => {
23824
23930
  return visibleLimitVenueOptions.map((option) => {
23825
23931
  var _a2, _b2, _c2, _d2;
23826
23932
  const effectiveLimitPriceRaw = (_b2 = (_a2 = limitPriceAdjustmentByVenue.get(option.venue)) == null ? void 0 : _a2.adjustedPriceRaw) != null ? _b2 : originalLimitPriceRaw;
@@ -23870,7 +23976,7 @@ var PlaceOrder = ({
23870
23976
  tradingLabels,
23871
23977
  visibleLimitVenueOptions
23872
23978
  ]);
23873
- const limitVenueOptionByCardId = (0, import_react38.useMemo)(() => {
23979
+ const limitVenueOptionByCardId = (0, import_react39.useMemo)(() => {
23874
23980
  return new Map(
23875
23981
  visibleLimitVenueOptions.map((option) => [
23876
23982
  `limit-venue-${option.venue}-${option.venueMarketOutcomeId}`,
@@ -23893,13 +23999,13 @@ var PlaceOrder = ({
23893
23999
  const activeFeeBreakdown = activeQuoteData == null ? void 0 : activeQuoteData.feeBreakdown;
23894
24000
  const executionReserve = activeFeeBreakdown == null ? void 0 : activeFeeBreakdown.executionReserve;
23895
24001
  const executionReserveValue = typeof executionReserve === "number" && Number.isFinite(executionReserve) && executionReserve > 0 ? formatUsd(executionReserve, { minimumFractionDigits: 2, maximumFractionDigits: 2 }) : null;
23896
- const estimatedFeesValue = (0, import_react38.useMemo)(() => {
24002
+ const estimatedFeesValue = (0, import_react39.useMemo)(() => {
23897
24003
  const totalFees = getSmartRouteTotalFees(activeFeeBreakdown);
23898
24004
  if (totalFees == null) return null;
23899
24005
  return formatUsd(totalFees, { minimumFractionDigits: 2, maximumFractionDigits: 2 });
23900
24006
  }, [activeFeeBreakdown]);
23901
24007
  const appFeeValue = (__ = activeFeeBreakdown == null ? void 0 : activeFeeBreakdown.appFee) != null ? __ : 0;
23902
- const feeBreakdownRows = (0, import_react38.useMemo)(() => {
24008
+ const feeBreakdownRows = (0, import_react39.useMemo)(() => {
23903
24009
  var _a2;
23904
24010
  if (!activeFeeBreakdown) return [];
23905
24011
  return [
@@ -23950,30 +24056,25 @@ var PlaceOrder = ({
23950
24056
  const selectedLimitRouteCardId = selectedLimitVenueOption ? `limit-venue-${selectedLimitVenueOption.venue}-${selectedLimitVenueOption.venueMarketOutcomeId}` : null;
23951
24057
  const selectedLimitRouteCard = selectedLimitRouteCardId ? (_$ = limitRouteCards.find((card) => card.id === selectedLimitRouteCardId)) != null ? _$ : null : null;
23952
24058
  const selectedRouteGeoBlocked = isLimitOrder ? (_aa = selectedLimitRouteCard == null ? void 0 : selectedLimitRouteCard.isUnavailable) != null ? _aa : false : (_ba = selectedRouteCard == null ? void 0 : selectedRouteCard.isUnavailable) != null ? _ba : false;
23953
- const geoBlockedVenuesFromWarnings = (0, import_react38.useMemo)(
24059
+ const geoBlockedVenuesFromWarnings = (0, import_react39.useMemo)(
23954
24060
  () => {
23955
24061
  var _a2;
23956
24062
  return extractGeoBlockedVenues((_a2 = smartRoute.data) == null ? void 0 : _a2.warnings);
23957
24063
  },
23958
24064
  [(_ca = smartRoute.data) == null ? void 0 : _ca.warnings]
23959
24065
  );
23960
- const isPrimaryVenueGeoBlocked = (0, import_react38.useMemo)(() => {
24066
+ const isPrimaryVenueGeoBlocked = (0, import_react39.useMemo)(() => {
23961
24067
  var _a2, _b2;
23962
24068
  if (!selectedRouteCard || selectedRouteCard.isUnavailable) return false;
23963
24069
  const fills = (_b2 = (_a2 = selectedRouteCard.quoteData) == null ? void 0 : _a2.fills) != null ? _b2 : [];
23964
24070
  return fills.length > 0 && fills.every((f) => geoBlockedVenuesFromWarnings.has(f.venue));
23965
24071
  }, [selectedRouteCard, geoBlockedVenuesFromWarnings]);
23966
24072
  const shouldShowGeoBlockBanner = isTradingBlocked || selectedRouteGeoBlocked || isPrimaryVenueGeoBlocked || isLimitOrder && limitRouteCards.length > 0 && limitRouteCards.every((card) => card.isUnavailable);
23967
- const shouldShowLowLiquidityWarning = !isQuoteInputEditing && !isQuoteLoading && (activeQuoteData == null ? void 0 : activeQuoteData.venueMarketOutcomeId) === scopedSelectedOutcomeId && !(activeQuoteData == null ? void 0 : activeQuoteData.fills.some((fill) => fill.venue === "prophetx")) && isPlaceOrderAveragePriceWorse({
23968
- averageExecutionPrice: selectedRouteCard == null ? void 0 : selectedRouteCard.executionPrice,
23969
- displayedMarketPrice: selectedOutcomeDisplayPrice,
23970
- tradeSide: internalTab
23971
- });
23972
24073
  const actionLabel = `${internalTab === "buy" ? tradingLabels.buy : tradingLabels.sell} ${selectedOutcomeLabel}`.trim();
23973
24074
  const isActionDisabled = isPrimaryActionDisabled || !orderEligibility.canPlaceOrder || isActionLoading || !hasEnteredAmount || !scopedSelectedMarket || isInsufficientBalance || isQuoteInsufficientBalance || isSell && isQuoteInputEditing || isSellAmountAboveAvailability || isBelowMinimum || !isLimitOrder && isQuoteLoading || isSelectedVenueInventoryInsufficient || (isLimitOrder ? !limitOrderPayload : !selectedRouteCard || !selectedRouteCard.quoteData.quoteId) || selectedRouteGeoBlocked || !isAuthenticated || !isLimitOrder && quoteStatus !== void 0;
23974
24075
  const shouldShowSmartRouting = orderEligibility.canPlaceOrder && hasEnteredAmount && !isBelowMinimum && (isLimitOrder ? limitRouteCards.length > 0 : displayedRouteCards.length > 0 || smartRoute.isFetching || smartRoute.isLoading || isSell && (venueSellQuotes.isFetching || venueSellQuotes.isLoading));
23975
24076
  const shouldShowRouteToggle = !isLimitOrder && !isQuoteLoading && displayedRouteCards.length > PLACE_ORDER_ROUTE_COLLAPSED_CARD_COUNT;
23976
- const handleReturnToOrderForm = (0, import_react38.useCallback)(() => {
24077
+ const handleReturnToOrderForm = (0, import_react39.useCallback)(() => {
23977
24078
  const submittedSelection = submittedSelectionRef.current;
23978
24079
  submittedSelectionRef.current = null;
23979
24080
  setSubmissionProgressState(null);
@@ -23995,7 +24096,7 @@ var PlaceOrder = ({
23995
24096
  const shareUrl = `https://twitter.com/intent/tweet?text=${encodeURIComponent(shareText)}`;
23996
24097
  window.open(shareUrl, "_blank", "noopener,noreferrer");
23997
24098
  };
23998
- const handleExecuteQuote = (0, import_react38.useCallback)(
24099
+ const handleExecuteQuote = (0, import_react39.useCallback)(
23999
24100
  (quoteData) => __async(null, null, function* () {
24000
24101
  var _a2, _b2, _c2;
24001
24102
  const quoteId = quoteData == null ? void 0 : quoteData.quoteId;
@@ -24112,7 +24213,7 @@ var PlaceOrder = ({
24112
24213
  venueSellQuotes.quotes
24113
24214
  ]
24114
24215
  );
24115
- const handlePlaceLimitOrder = (0, import_react38.useCallback)(
24216
+ const handlePlaceLimitOrder = (0, import_react39.useCallback)(
24116
24217
  (submissionLimitOrderPayload) => __async(null, null, function* () {
24117
24218
  var _a2, _b2, _c2, _d2, _e2, _f2, _g2;
24118
24219
  if (!showLimitOrders) return;
@@ -24195,7 +24296,7 @@ var PlaceOrder = ({
24195
24296
  tradingLabels
24196
24297
  ]
24197
24298
  );
24198
- const handleSkipToSuccess = (0, import_react38.useCallback)(() => {
24299
+ const handleSkipToSuccess = (0, import_react39.useCallback)(() => {
24199
24300
  const primaryFilledEvent = executionProgress.terminalOrderEvents.find(
24200
24301
  (e) => e.event === "filled" || e.event === "partial_fill"
24201
24302
  );
@@ -24220,7 +24321,7 @@ var PlaceOrder = ({
24220
24321
  failureSummary,
24221
24322
  selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData
24222
24323
  ]);
24223
- (0, import_react38.useEffect)(() => {
24324
+ (0, import_react39.useEffect)(() => {
24224
24325
  if ((submissionProgressState == null ? void 0 : submissionProgressState.phase) !== "failed") return;
24225
24326
  if ((failureSummary == null ? void 0 : failureSummary.kind) !== "partial_fill") return;
24226
24327
  if (!shouldAutoSkipPartialFill) return;
@@ -24231,7 +24332,7 @@ var PlaceOrder = ({
24231
24332
  shouldAutoSkipPartialFill,
24232
24333
  submissionProgressState == null ? void 0 : submissionProgressState.phase
24233
24334
  ]);
24234
- const handleRetrySubmission = (0, import_react38.useCallback)(() => __async(null, null, function* () {
24335
+ const handleRetrySubmission = (0, import_react39.useCallback)(() => __async(null, null, function* () {
24235
24336
  var _a2, _b2, _c2, _d2, _e2;
24236
24337
  if (!orderEligibility.canPlaceOrder || !failureSummary || failureSummary.kind === "generic") {
24237
24338
  handleReturnToOrderForm();
@@ -24649,7 +24750,7 @@ var PlaceOrder = ({
24649
24750
  }
24650
24751
  );
24651
24752
  }
24652
- return /* @__PURE__ */ (0, import_jsx_runtime169.jsxs)(import_react38.Fragment, { children: [
24753
+ return /* @__PURE__ */ (0, import_jsx_runtime169.jsxs)(import_react39.Fragment, { children: [
24653
24754
  /* @__PURE__ */ (0, import_jsx_runtime169.jsxs)(
24654
24755
  Card,
24655
24756
  {
@@ -25025,12 +25126,13 @@ var PlaceOrder = ({
25025
25126
  /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(PlaceOrderRouteCardSkeleton, {}),
25026
25127
  /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(PlaceOrderRouteCardSkeleton, {})
25027
25128
  ] }) : activeRouteCards.length > 0 ? activeRouteCards.map((card) => {
25028
- return /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(import_react38.Fragment, { children: renderRouteCard({
25129
+ return /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(import_react39.Fragment, { children: renderRouteCard({
25029
25130
  card,
25030
25131
  enableAnimations,
25031
25132
  isExpanded: card.kind === "split" ? isSplitDetailOpen : isRoutesExpanded,
25032
25133
  isSelected: !card.isUnavailable && card.id === (isLimitOrder ? selectedLimitRouteCardId : resolvedSelectedRouteCardId),
25033
25134
  onSelect: handleActiveRouteCardSelect,
25135
+ isKalshiDisconnected,
25034
25136
  sharedKycStatus: isPaperMode ? void 0 : sharedKyc == null ? void 0 : sharedKyc.status,
25035
25137
  tradingLabels
25036
25138
  }) }, card.id);
@@ -25234,7 +25336,7 @@ var PlaceOrder = ({
25234
25336
  /* @__PURE__ */ (0, import_jsx_runtime169.jsx)("p", { className: "agg-order-summary-hint text-agg-sm leading-agg-5 text-agg-muted-foreground", children: isLimitOrder ? displayedLimitToWinHint : displayedToWinHint })
25235
25337
  ] }),
25236
25338
  /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(
25237
- import_react37.default,
25339
+ import_react38.default,
25238
25340
  {
25239
25341
  value: isLimitOrder ? displayedLimitToWinValue : displayedToWinValue,
25240
25342
  locales: locale,
@@ -25392,15 +25494,6 @@ var PlaceOrder = ({
25392
25494
  children: actionLabel
25393
25495
  }
25394
25496
  ),
25395
- shouldShowLowLiquidityWarning ? /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(
25396
- InlineAlert,
25397
- {
25398
- tone: "warning",
25399
- variant: "surface",
25400
- className: "agg-order-low-liquidity-warning justify-start! border-0! bg-agg-warning/10! py-2!",
25401
- message: internalTab === "buy" ? tradingLabels.lowLiquidityWarning : tradingLabels.lowLiquiditySellWarning
25402
- }
25403
- ) : null,
25404
25497
  !shouldShowGeoBlockBanner && internalTab === "buy" && showFeesBreakdown && appFeeValue === 0 ? /* @__PURE__ */ (0, import_jsx_runtime169.jsxs)("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: [
25405
25498
  /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(
25406
25499
  Icon,
@@ -25451,7 +25544,7 @@ PlaceOrder.displayName = "PlaceOrder";
25451
25544
 
25452
25545
  // src/trading/use-claim-winnings.ts
25453
25546
  var import_hooks68 = require("@agg-build/hooks");
25454
- var import_react39 = require("react");
25547
+ var import_react40 = require("react");
25455
25548
  var toClaimError = (err) => {
25456
25549
  if (err instanceof Error) return err;
25457
25550
  return new Error(String(err));
@@ -25463,17 +25556,17 @@ function useClaimWinnings(options = {}) {
25463
25556
  const toastCtx = useOptionalToast();
25464
25557
  const queryClient = (0, import_hooks68.useQueryClient)();
25465
25558
  const redeemMutation = (0, import_hooks68.useRedeem)();
25466
- const [activeRedeems, setActiveRedeems] = (0, import_react39.useState)({});
25467
- const activeClaimKeysRef = (0, import_react39.useRef)(/* @__PURE__ */ new Set());
25468
- const pendingClaimToastIdsRef = (0, import_react39.useRef)({});
25469
- const submittedClaimToastKeysRef = (0, import_react39.useRef)(/* @__PURE__ */ new Set());
25470
- const [submittingClaimKeys, setSubmittingClaimKeys] = (0, import_react39.useState)({});
25471
- const lifecycleInputs = (0, import_react39.useMemo)(
25559
+ const [activeRedeems, setActiveRedeems] = (0, import_react40.useState)({});
25560
+ const activeClaimKeysRef = (0, import_react40.useRef)(/* @__PURE__ */ new Set());
25561
+ const pendingClaimToastIdsRef = (0, import_react40.useRef)({});
25562
+ const submittedClaimToastKeysRef = (0, import_react40.useRef)(/* @__PURE__ */ new Set());
25563
+ const [submittingClaimKeys, setSubmittingClaimKeys] = (0, import_react40.useState)({});
25564
+ const lifecycleInputs = (0, import_react40.useMemo)(
25472
25565
  () => Object.values(activeRedeems),
25473
25566
  [activeRedeems]
25474
25567
  );
25475
25568
  const lifecycleStates = (0, import_hooks68.useRedeemLifecycles)(lifecycleInputs);
25476
- const internalClaimingIds = (0, import_react39.useMemo)(() => {
25569
+ const internalClaimingIds = (0, import_react40.useMemo)(() => {
25477
25570
  const out = __spreadValues({}, submittingClaimKeys);
25478
25571
  for (const [claimKey, active] of Object.entries(activeRedeems)) {
25479
25572
  const state = lifecycleStates[active.redeemId];
@@ -25482,11 +25575,11 @@ function useClaimWinnings(options = {}) {
25482
25575
  return out;
25483
25576
  }, [activeRedeems, lifecycleStates, submittingClaimKeys]);
25484
25577
  const claimingKeys = externalClaimingKeys != null ? externalClaimingKeys : internalClaimingIds;
25485
- const isClaiming = (0, import_react39.useCallback)(
25578
+ const isClaiming = (0, import_react40.useCallback)(
25486
25579
  (claimKey) => Boolean(externalClaimingKeys == null ? void 0 : externalClaimingKeys[claimKey]) || Boolean(internalClaimingIds[claimKey]),
25487
25580
  [externalClaimingKeys, internalClaimingIds]
25488
25581
  );
25489
- const invalidateClaimUiState = (0, import_react39.useCallback)(() => {
25582
+ const invalidateClaimUiState = (0, import_react40.useCallback)(() => {
25490
25583
  (0, import_hooks68.invalidateBalanceQueries)(queryClient);
25491
25584
  (0, import_hooks68.invalidatePositionQueries)(queryClient);
25492
25585
  queryClient.invalidateQueries({
@@ -25495,7 +25588,7 @@ function useClaimWinnings(options = {}) {
25495
25588
  });
25496
25589
  (0, import_hooks68.invalidateUserActivityQueries)(queryClient);
25497
25590
  }, [queryClient]);
25498
- const claim = (0, import_react39.useCallback)(
25591
+ const claim = (0, import_react40.useCallback)(
25499
25592
  (_0) => __async(null, [_0], function* ({ claimKey, winningOutcomeIds, payload }) {
25500
25593
  if (activeClaimKeysRef.current.has(claimKey) || Boolean(externalClaimingKeys == null ? void 0 : externalClaimingKeys[claimKey]) || internalClaimingIds[claimKey]) {
25501
25594
  return;
@@ -25633,8 +25726,8 @@ function useClaimWinnings(options = {}) {
25633
25726
  toastCtx
25634
25727
  ]
25635
25728
  );
25636
- const firedTerminalRef = (0, import_react39.useRef)({});
25637
- (0, import_react39.useEffect)(() => {
25729
+ const firedTerminalRef = (0, import_react40.useRef)({});
25730
+ (0, import_react40.useEffect)(() => {
25638
25731
  var _a, _b;
25639
25732
  for (const [claimKey, active] of Object.entries(activeRedeems)) {
25640
25733
  const state = lifecycleStates[active.redeemId];
@@ -25691,7 +25784,7 @@ function useClaimWinnings(options = {}) {
25691
25784
 
25692
25785
  // src/trading/use-resolved-market-claim.ts
25693
25786
  var import_hooks69 = require("@agg-build/hooks");
25694
- var import_react40 = require("react");
25787
+ var import_react41 = require("react");
25695
25788
  var sharesFormatter = new Intl.NumberFormat("en-US", { maximumFractionDigits: 2 });
25696
25789
  var dateFormatter = new Intl.DateTimeFormat("en-US", {
25697
25790
  month: "short",
@@ -25708,7 +25801,7 @@ function useResolvedMarketClaim(options = {}) {
25708
25801
  var _a;
25709
25802
  const { market, enabled = true, executionMode } = options;
25710
25803
  const { isAuthenticated } = (0, import_hooks69.useAggAuthState)();
25711
- const tradingState = (0, import_react40.useMemo)(() => (0, import_hooks69.resolveMarketTradingState)(market), [market]);
25804
+ const tradingState = (0, import_react41.useMemo)(() => (0, import_hooks69.resolveMarketTradingState)(market), [market]);
25712
25805
  const isResolved = tradingState.kind === "resolved";
25713
25806
  const marketId = (_a = market == null ? void 0 : market.id) != null ? _a : null;
25714
25807
  const shouldFetch = Boolean(enabled && isAuthenticated && isResolved && marketId);
@@ -25718,7 +25811,7 @@ function useResolvedMarketClaim(options = {}) {
25718
25811
  limit: 50
25719
25812
  }, executionMode === "paper" ? { mode: "paper" } : {}));
25720
25813
  const claimWinnings = useClaimWinnings();
25721
- return (0, import_react40.useMemo)(() => {
25814
+ return (0, import_react41.useMemo)(() => {
25722
25815
  var _a2;
25723
25816
  if (!shouldFetch || !marketId) return void 0;
25724
25817
  const group = positions.find(
@@ -25815,7 +25908,7 @@ var resolveEventMarketPageStickyState = ({
25815
25908
  // src/pages/event-market/event-market.shared.tsx
25816
25909
  var import_hooks70 = require("@agg-build/hooks");
25817
25910
  var Dialog8 = __toESM(require("@radix-ui/react-dialog"));
25818
- var import_react41 = require("react");
25911
+ var import_react42 = require("react");
25819
25912
  var import_jsx_runtime170 = require("react/jsx-runtime");
25820
25913
  var MOBILE_EVENT_MARKET_MEDIA_QUERY = "(max-width: 1023px)";
25821
25914
  var SPORTS_EVENT_MARKET_MEDIA_QUERY = "(max-width: 1279px)";
@@ -25825,10 +25918,10 @@ var getIsMobileEventMarketViewport = (mediaQuery = MOBILE_EVENT_MARKET_MEDIA_QUE
25825
25918
  return window.matchMedia(mediaQuery).matches;
25826
25919
  };
25827
25920
  var useIsMobileEventMarketViewport = (mediaQuery = MOBILE_EVENT_MARKET_MEDIA_QUERY) => {
25828
- const [isMobileViewport, setIsMobileViewport] = (0, import_react41.useState)(
25921
+ const [isMobileViewport, setIsMobileViewport] = (0, import_react42.useState)(
25829
25922
  () => getIsMobileEventMarketViewport(mediaQuery)
25830
25923
  );
25831
- (0, import_react41.useEffect)(() => {
25924
+ (0, import_react42.useEffect)(() => {
25832
25925
  if (typeof window === "undefined") return;
25833
25926
  if (typeof window.matchMedia !== "function") return;
25834
25927
  const mediaQueryList = window.matchMedia(mediaQuery);
@@ -26053,11 +26146,11 @@ var EventMarketPageLoadingState = ({
26053
26146
 
26054
26147
  // src/pages/event-market/sports-event-market-page.tsx
26055
26148
  var import_hooks73 = require("@agg-build/hooks");
26056
- var import_react44 = require("react");
26149
+ var import_react45 = require("react");
26057
26150
 
26058
26151
  // src/pages/event-market/sports-markets.tsx
26059
26152
  var import_hooks72 = require("@agg-build/hooks");
26060
- var import_react43 = require("react");
26153
+ var import_react44 = require("react");
26061
26154
 
26062
26155
  // src/pages/event-market/sports-event-market.utils.ts
26063
26156
  var SPORTS_MARKET_TYPE_KEYS = [
@@ -27072,7 +27165,7 @@ var mergeSportsSectionMarketsIntoEvent = ({
27072
27165
 
27073
27166
  // src/pages/event-market/sports-market-card.tsx
27074
27167
  var import_hooks71 = require("@agg-build/hooks");
27075
- var import_react42 = require("react");
27168
+ var import_react43 = require("react");
27076
27169
 
27077
27170
  // src/pages/event-market/sports-line-rail.tsx
27078
27171
  var React = __toESM(require("react"));
@@ -27425,18 +27518,18 @@ var SportsMarketCard = ({
27425
27518
  formatting: { formatCompactCurrency }
27426
27519
  } = (0, import_hooks71.useSdkUiConfig)();
27427
27520
  const tradingContext = (0, import_hooks71.useEventTradingContext)();
27428
- const slide = (0, import_react42.useMemo)(() => buildSportsSlideFromGroup(group), [group]);
27429
- const [selectedLineIndex, setSelectedLineIndex] = (0, import_react42.useState)(slide.defaultStopIndex);
27430
- const combinedLegs = (0, import_react42.useMemo)(() => resolveSportsCombinedLegs(group), [group]);
27521
+ const slide = (0, import_react43.useMemo)(() => buildSportsSlideFromGroup(group), [group]);
27522
+ const [selectedLineIndex, setSelectedLineIndex] = (0, import_react43.useState)(slide.defaultStopIndex);
27523
+ const combinedLegs = (0, import_react43.useMemo)(() => resolveSportsCombinedLegs(group), [group]);
27431
27524
  const isCombinedLegGroup = combinedLegs != null;
27432
- const combinedLegMarkets = (0, import_react42.useMemo)(
27525
+ const combinedLegMarkets = (0, import_react43.useMemo)(
27433
27526
  () => {
27434
27527
  var _a2;
27435
27528
  return (_a2 = combinedLegs == null ? void 0 : combinedLegs.map((leg) => leg.market)) != null ? _a2 : [];
27436
27529
  },
27437
27530
  [combinedLegs]
27438
27531
  );
27439
- const preferredResolvedLegMarket = (0, import_react42.useMemo)(() => {
27532
+ const preferredResolvedLegMarket = (0, import_react43.useMemo)(() => {
27440
27533
  var _a2, _b2;
27441
27534
  const resolvedYesWinnerMarket = (_a2 = combinedLegMarkets.find(
27442
27535
  (market) => market.venueMarketOutcomes.some(
@@ -27448,7 +27541,7 @@ var SportsMarketCard = ({
27448
27541
  (market) => market.venueMarketOutcomes.some((outcome) => outcome.winner === true)
27449
27542
  )) != null ? _b2 : null;
27450
27543
  }, [combinedLegMarkets]);
27451
- (0, import_react42.useEffect)(() => {
27544
+ (0, import_react43.useEffect)(() => {
27452
27545
  if (!slide.hasLadder) return;
27453
27546
  const tradingMarketId = tradingContext == null ? void 0 : tradingContext.selectedMarketId;
27454
27547
  if (!tradingMarketId) return;
@@ -27460,8 +27553,8 @@ var SportsMarketCard = ({
27460
27553
  const activeDefaultOutcome = isCombinedLegGroup && activeMarket ? (_g = activeMarket.venueMarketOutcomes.find(
27461
27554
  (outcome) => outcome.label.trim().toLowerCase() === "yes"
27462
27555
  )) != null ? _g : activeMarket.venueMarketOutcomes[0] : activeMarket == null ? void 0 : activeMarket.venueMarketOutcomes[0];
27463
- const wasExpandedRef = (0, import_react42.useRef)(isExpanded);
27464
- (0, import_react42.useEffect)(() => {
27556
+ const wasExpandedRef = (0, import_react43.useRef)(isExpanded);
27557
+ (0, import_react43.useEffect)(() => {
27465
27558
  const justOpened = isExpanded && !wasExpandedRef.current;
27466
27559
  wasExpandedRef.current = isExpanded;
27467
27560
  if (!justOpened || !activeMarket) return;
@@ -27474,7 +27567,7 @@ var SportsMarketCard = ({
27474
27567
  tradingContext == null ? void 0 : tradingContext.selectMarketAndOutcome(activeMarket.id, firstOutcome.id);
27475
27568
  }
27476
27569
  }, [activeDefaultOutcome, isExpanded, activeMarket, tradingContext]);
27477
- const combinedLegHeaderOutcomeItems = (0, import_react42.useMemo)(() => {
27570
+ const combinedLegHeaderOutcomeItems = (0, import_react43.useMemo)(() => {
27478
27571
  if (!combinedLegs) return void 0;
27479
27572
  return combinedLegs.flatMap(({ label: label2, market }, index) => {
27480
27573
  var _a2;
@@ -27501,7 +27594,7 @@ var SportsMarketCard = ({
27501
27594
  ];
27502
27595
  });
27503
27596
  }, [combinedLegs, midpointsResult]);
27504
- const spreadHeaderOutcomeItems = (0, import_react42.useMemo)(() => {
27597
+ const spreadHeaderOutcomeItems = (0, import_react43.useMemo)(() => {
27505
27598
  if (slide.kind !== "spread" || !activeMarket) return void 0;
27506
27599
  return resolveSpreadHeaderOutcomeItems({
27507
27600
  market: activeMarket,
@@ -27744,7 +27837,7 @@ var SportsMarkets = ({
27744
27837
  isFetchingNextPage: isFetchingNextGameMarketsPage,
27745
27838
  fetchNextPage: fetchNextGameMarketsPage
27746
27839
  } = gameMarketsQuery;
27747
- const tabSourceMarkets = (0, import_react43.useMemo)(() => {
27840
+ const tabSourceMarkets = (0, import_react44.useMemo)(() => {
27748
27841
  const seen = /* @__PURE__ */ new Set();
27749
27842
  const merged = [];
27750
27843
  for (const market of [...event.venueMarkets, ...gameMarkets]) {
@@ -27754,21 +27847,21 @@ var SportsMarkets = ({
27754
27847
  }
27755
27848
  return merged;
27756
27849
  }, [event.venueMarkets, gameMarkets]);
27757
- const visibleTabs = (0, import_react43.useMemo)(
27850
+ const visibleTabs = (0, import_react44.useMemo)(
27758
27851
  () => resolveVisibleSportsSectionTabs(__spreadProps(__spreadValues({}, event), { venueMarkets: tabSourceMarkets })),
27759
27852
  [event, tabSourceMarkets]
27760
27853
  );
27761
27854
  const shouldRenderTabs = visibleTabs.length > 1 && tabSourceMarkets.length > 1;
27762
- const [activeTabKey, setActiveTabKey] = (0, import_react43.useState)((_b = (_a = visibleTabs[0]) == null ? void 0 : _a.key) != null ? _b : "game_lines");
27763
- const activeTab = (0, import_react43.useMemo)(
27855
+ const [activeTabKey, setActiveTabKey] = (0, import_react44.useState)((_b = (_a = visibleTabs[0]) == null ? void 0 : _a.key) != null ? _b : "game_lines");
27856
+ const activeTab = (0, import_react44.useMemo)(
27764
27857
  () => {
27765
27858
  var _a2, _b2;
27766
27859
  return (_b2 = (_a2 = visibleTabs.find((tab) => tab.key === activeTabKey)) != null ? _a2 : visibleTabs[0]) != null ? _b2 : { key: "game_lines", kind: "game_lines" };
27767
27860
  },
27768
27861
  [visibleTabs, activeTabKey]
27769
27862
  );
27770
- const [expandedGroupId, setExpandedGroupId] = (0, import_react43.useState)(null);
27771
- const [stableMarketsByTab, setStableMarketsByTab] = (0, import_react43.useState)({});
27863
+ const [expandedGroupId, setExpandedGroupId] = (0, import_react44.useState)(null);
27864
+ const [stableMarketsByTab, setStableMarketsByTab] = (0, import_react44.useState)({});
27772
27865
  const activeTabLabel = resolveSportsSectionLabel(labels, activeTab);
27773
27866
  const sectionFilters = resolveSportsSectionFilters(activeTab);
27774
27867
  const sectionMarketsQuery = (0, import_hooks72.useVenueMarkets)({
@@ -27791,7 +27884,7 @@ var SportsMarkets = ({
27791
27884
  isFetchingNextPage,
27792
27885
  fetchNextPage
27793
27886
  } = sectionMarketsQuery;
27794
- const resolvedSectionMarkets = (0, import_react43.useMemo)(
27887
+ const resolvedSectionMarkets = (0, import_react44.useMemo)(
27795
27888
  () => resolveSportsSectionMarkets({
27796
27889
  tab: activeTab,
27797
27890
  eventMarkets: tabSourceMarkets,
@@ -27802,29 +27895,29 @@ var SportsMarkets = ({
27802
27895
  );
27803
27896
  const isSectionSettled = !isSectionLoading && !hasNextPage && !isFetchingNextPage;
27804
27897
  const stableSectionMarkets = stableMarketsByTab[activeTabKey];
27805
- const displayedSectionMarkets = (0, import_react43.useMemo)(
27898
+ const displayedSectionMarkets = (0, import_react44.useMemo)(
27806
27899
  () => stableSectionMarkets != null ? stableSectionMarkets : isSectionSettled ? resolvedSectionMarkets : [],
27807
27900
  [stableSectionMarkets, isSectionSettled, resolvedSectionMarkets]
27808
27901
  );
27809
- const periodGroups = (0, import_react43.useMemo)(
27902
+ const periodGroups = (0, import_react44.useMemo)(
27810
27903
  () => groupSportsMarketsByPeriod(displayedSectionMarkets, event.sport),
27811
27904
  [displayedSectionMarkets, event.sport]
27812
27905
  );
27813
- const allGroups = (0, import_react43.useMemo)(
27906
+ const allGroups = (0, import_react44.useMemo)(
27814
27907
  () => periodGroups.flatMap((periodGroup) => periodGroup.groups),
27815
27908
  [periodGroups]
27816
27909
  );
27817
- (0, import_react43.useEffect)(() => {
27910
+ (0, import_react44.useEffect)(() => {
27818
27911
  if (hasNextPage && !isFetchingNextPage) {
27819
27912
  void fetchNextPage();
27820
27913
  }
27821
27914
  }, [hasNextPage, isFetchingNextPage, fetchNextPage]);
27822
- (0, import_react43.useEffect)(() => {
27915
+ (0, import_react44.useEffect)(() => {
27823
27916
  if (hasNextGameMarketsPage && !isFetchingNextGameMarketsPage) {
27824
27917
  void fetchNextGameMarketsPage();
27825
27918
  }
27826
27919
  }, [hasNextGameMarketsPage, isFetchingNextGameMarketsPage, fetchNextGameMarketsPage]);
27827
- (0, import_react43.useEffect)(() => {
27920
+ (0, import_react44.useEffect)(() => {
27828
27921
  if (!isSectionSettled) return;
27829
27922
  setStableMarketsByTab((currentStableMarketsByTab) => {
27830
27923
  var _a2;
@@ -27840,17 +27933,17 @@ var SportsMarkets = ({
27840
27933
  });
27841
27934
  });
27842
27935
  }, [activeTabKey, isSectionSettled, resolvedSectionMarkets]);
27843
- (0, import_react43.useEffect)(() => {
27936
+ (0, import_react44.useEffect)(() => {
27844
27937
  if (!hasAggKey) return;
27845
27938
  onSectionMarketsChange(activeTabKey, displayedSectionMarkets);
27846
27939
  }, [activeTabKey, displayedSectionMarkets, hasAggKey, onSectionMarketsChange]);
27847
- (0, import_react43.useEffect)(() => {
27940
+ (0, import_react44.useEffect)(() => {
27848
27941
  var _a2, _b2;
27849
27942
  if (visibleTabs.some((tab) => tab.key === activeTabKey)) return;
27850
27943
  setActiveTabKey((_b2 = (_a2 = visibleTabs[0]) == null ? void 0 : _a2.key) != null ? _b2 : "game_lines");
27851
27944
  }, [activeTabKey, visibleTabs]);
27852
- const lastActiveTabRef = (0, import_react43.useRef)(null);
27853
- (0, import_react43.useEffect)(() => {
27945
+ const lastActiveTabRef = (0, import_react44.useRef)(null);
27946
+ (0, import_react44.useEffect)(() => {
27854
27947
  if (allGroups.length === 0) return;
27855
27948
  if (lastActiveTabRef.current !== activeTabKey) {
27856
27949
  lastActiveTabRef.current = activeTabKey;
@@ -27976,15 +28069,15 @@ var SportsEventMarketPage = ({
27976
28069
  onBeforePrimaryAction,
27977
28070
  sharedKyc
27978
28071
  }) => {
27979
- const [sectionMarketsByKey, setSectionMarketsByKey] = (0, import_react44.useState)({});
27980
- const composedEvent = (0, import_react44.useMemo)(() => {
28072
+ const [sectionMarketsByKey, setSectionMarketsByKey] = (0, import_react45.useState)({});
28073
+ const composedEvent = (0, import_react45.useMemo)(() => {
27981
28074
  return mergeSportsSectionMarketsIntoEvent({
27982
28075
  event,
27983
28076
  sectionMarketsByKey
27984
28077
  });
27985
28078
  }, [event, sectionMarketsByKey]);
27986
- const eventTradingState = (0, import_react44.useMemo)(() => (0, import_hooks73.resolveEventTradingState)(composedEvent), [composedEvent]);
27987
- const hasSportsSections = (0, import_react44.useMemo)(
28079
+ const eventTradingState = (0, import_react45.useMemo)(() => (0, import_hooks73.resolveEventTradingState)(composedEvent), [composedEvent]);
28080
+ const hasSportsSections = (0, import_react45.useMemo)(
27988
28081
  () => resolveVisibleSportsSectionTabs(event).length > 0,
27989
28082
  [event]
27990
28083
  );
@@ -27992,7 +28085,7 @@ var SportsEventMarketPage = ({
27992
28085
  stickyOrderPanel
27993
28086
  });
27994
28087
  const { executionMode: resolvedExecutionMode } = (0, import_hooks73.useResolvedExecutionMode)(executionMode);
27995
- const [isMobileTradeOpen, setIsMobileTradeOpen] = (0, import_react44.useState)(false);
28088
+ const [isMobileTradeOpen, setIsMobileTradeOpen] = (0, import_react45.useState)(false);
27996
28089
  const isMobileViewport = useIsMobileEventMarketViewport(SPORTS_EVENT_MARKET_MEDIA_QUERY);
27997
28090
  const tradingContext = (0, import_hooks73.useEventTradingContext)();
27998
28091
  const { stateByEventId: sportsLiveStateByEventId } = (0, import_hooks73.useSportsLive)([event.id]);
@@ -28003,15 +28096,15 @@ var SportsEventMarketPage = ({
28003
28096
  executionMode: resolvedExecutionMode
28004
28097
  });
28005
28098
  const effectiveResolvedClaim = resolvedClaim != null ? resolvedClaim : internalResolvedClaim;
28006
- const setTradeSideRef = (0, import_react44.useRef)(tradingContext == null ? void 0 : tradingContext.setTradeSide);
28099
+ const setTradeSideRef = (0, import_react45.useRef)(tradingContext == null ? void 0 : tradingContext.setTradeSide);
28007
28100
  setTradeSideRef.current = tradingContext == null ? void 0 : tradingContext.setTradeSide;
28008
- (0, import_react44.useEffect)(() => {
28101
+ (0, import_react45.useEffect)(() => {
28009
28102
  return () => {
28010
28103
  var _a;
28011
28104
  (_a = setTradeSideRef.current) == null ? void 0 : _a.call(setTradeSideRef, import_hooks73.TradeSide.Buy);
28012
28105
  };
28013
28106
  }, []);
28014
- const handleSectionMarketsChange = (0, import_react44.useCallback)(
28107
+ const handleSectionMarketsChange = (0, import_react45.useCallback)(
28015
28108
  (tabKey, markets) => {
28016
28109
  setSectionMarketsByKey((currentSectionMarketsByKey) => {
28017
28110
  var _a;
@@ -28184,8 +28277,8 @@ var formatRecurringCountdown = (remainingMs) => {
28184
28277
  return hours > 0 ? `${hours}:${minuteSecondLabel}` : minuteSecondLabel;
28185
28278
  };
28186
28279
  var useCurrentTimestamp = (enabled) => {
28187
- const [currentTimestamp, setCurrentTimestamp] = (0, import_react45.useState)(null);
28188
- (0, import_react45.useEffect)(() => {
28280
+ const [currentTimestamp, setCurrentTimestamp] = (0, import_react46.useState)(null);
28281
+ (0, import_react46.useEffect)(() => {
28189
28282
  if (!enabled) {
28190
28283
  setCurrentTimestamp(null);
28191
28284
  return;
@@ -28219,18 +28312,18 @@ var EventMarketPageContent = ({
28219
28312
  onRecurringMarketNavigate
28220
28313
  }) => {
28221
28314
  var _a;
28222
- const eventTradingState = (0, import_react45.useMemo)(() => (0, import_hooks74.resolveEventTradingState)(event), [event]);
28315
+ const eventTradingState = (0, import_react46.useMemo)(() => (0, import_hooks74.resolveEventTradingState)(event), [event]);
28223
28316
  const stickyOrderPanelState = resolveEventMarketPageStickyState({
28224
28317
  stickyOrderPanel
28225
28318
  });
28226
28319
  const { executionMode: resolvedExecutionMode } = (0, import_hooks74.useResolvedExecutionMode)(executionMode);
28227
- const [isMobileTradeOpen, setIsMobileTradeOpen] = (0, import_react45.useState)(false);
28320
+ const [isMobileTradeOpen, setIsMobileTradeOpen] = (0, import_react46.useState)(false);
28228
28321
  const isMobileViewport = useIsMobileEventMarketViewport();
28229
28322
  const tradingContext = (0, import_hooks74.useEventTradingContext)();
28230
28323
  const labels = (0, import_hooks74.useLabels)();
28231
28324
  const recurringQuery = (0, import_hooks74.useRecurringCryptoMarkets)({ event });
28232
28325
  const currentTimestamp = useCurrentTimestamp(recurringQuery.isRecurringCryptoMarket);
28233
- const recurringTimeline = (0, import_react45.useMemo)(
28326
+ const recurringTimeline = (0, import_react46.useMemo)(
28234
28327
  () => currentTimestamp == null ? null : (0, import_hooks74.resolveRecurringCryptoTimeline)(recurringQuery.windows, event, currentTimestamp),
28235
28328
  [currentTimestamp, event, recurringQuery.windows]
28236
28329
  );
@@ -28238,11 +28331,11 @@ var EventMarketPageContent = ({
28238
28331
  const recurringViewedEndTimestamp = (recurringTimeline == null ? void 0 : recurringTimeline.viewed) ? Date.parse(recurringTimeline.viewed.windowEnd) : Number.NaN;
28239
28332
  const hasViewedMarketEnded = currentTimestamp != null && Number.isFinite(recurringViewedEndTimestamp) && currentTimestamp >= recurringViewedEndTimestamp;
28240
28333
  const isRecurringResolvingMarket = recurringQuery.isRecurringCryptoMarket && eventTradingState.kind === "closed";
28241
- const lastBoundaryRefetchRef = (0, import_react45.useRef)(null);
28242
- (0, import_react45.useEffect)(() => {
28334
+ const lastBoundaryRefetchRef = (0, import_react46.useRef)(null);
28335
+ (0, import_react46.useEffect)(() => {
28243
28336
  lastBoundaryRefetchRef.current = null;
28244
28337
  }, [event.id]);
28245
- (0, import_react45.useEffect)(() => {
28338
+ (0, import_react46.useEffect)(() => {
28246
28339
  if (!isRecurringCryptoMarket || !hasViewedMarketEnded || !(recurringTimeline == null ? void 0 : recurringTimeline.viewed)) return;
28247
28340
  const refetchKey = `${event.id}:${recurringTimeline.viewed.windowEnd}`;
28248
28341
  if (lastBoundaryRefetchRef.current === refetchKey) return;
@@ -28255,20 +28348,20 @@ var EventMarketPageContent = ({
28255
28348
  recurringQuery,
28256
28349
  recurringTimeline == null ? void 0 : recurringTimeline.viewed
28257
28350
  ]);
28258
- const handleRecurringMarketSelect = (0, import_react45.useCallback)(
28351
+ const handleRecurringMarketSelect = (0, import_react46.useCallback)(
28259
28352
  (eventId) => {
28260
28353
  if (!onRecurringMarketNavigate || eventId === event.id) return;
28261
28354
  onRecurringMarketNavigate(eventId, { replace: false });
28262
28355
  },
28263
28356
  [event.id, onRecurringMarketNavigate]
28264
28357
  );
28265
- const handleGoToLive = (0, import_react45.useCallback)(() => {
28358
+ const handleGoToLive = (0, import_react46.useCallback)(() => {
28266
28359
  var _a2;
28267
28360
  const liveEventId = (_a2 = recurringTimeline == null ? void 0 : recurringTimeline.live) == null ? void 0 : _a2.venueEventId;
28268
28361
  if (!onRecurringMarketNavigate || !liveEventId || liveEventId === event.id) return;
28269
28362
  onRecurringMarketNavigate(liveEventId, { replace: false });
28270
28363
  }, [event.id, onRecurringMarketNavigate, (_a = recurringTimeline == null ? void 0 : recurringTimeline.live) == null ? void 0 : _a.venueEventId]);
28271
- const recurringMarketsPresentation = (0, import_react45.useMemo)(() => {
28364
+ const recurringMarketsPresentation = (0, import_react46.useMemo)(() => {
28272
28365
  var _a2, _b;
28273
28366
  if (!isRecurringCryptoMarket || !(recurringTimeline == null ? void 0 : recurringTimeline.viewed)) return void 0;
28274
28367
  const toOption = (market) => {
@@ -28307,7 +28400,7 @@ var EventMarketPageContent = ({
28307
28400
  recurringTimeline,
28308
28401
  recurringViewedEndTimestamp
28309
28402
  ]);
28310
- const eventDetailVenueMarkets = (0, import_react45.useMemo)(
28403
+ const eventDetailVenueMarkets = (0, import_react46.useMemo)(
28311
28404
  () => normalizeVenueMarketCluster(event.venueMarkets),
28312
28405
  [event.venueMarkets]
28313
28406
  );
@@ -28320,9 +28413,9 @@ var EventMarketPageContent = ({
28320
28413
  executionMode: resolvedExecutionMode
28321
28414
  });
28322
28415
  const effectiveResolvedClaim = resolvedClaim != null ? resolvedClaim : internalResolvedClaim;
28323
- const setTradeSideRef = (0, import_react45.useRef)(tradingContext == null ? void 0 : tradingContext.setTradeSide);
28416
+ const setTradeSideRef = (0, import_react46.useRef)(tradingContext == null ? void 0 : tradingContext.setTradeSide);
28324
28417
  setTradeSideRef.current = tradingContext == null ? void 0 : tradingContext.setTradeSide;
28325
- (0, import_react45.useEffect)(() => {
28418
+ (0, import_react46.useEffect)(() => {
28326
28419
  return () => {
28327
28420
  var _a2;
28328
28421
  (_a2 = setTradeSideRef.current) == null ? void 0 : _a2.call(setTradeSideRef, import_hooks74.TradeSide.Buy);
@@ -28663,15 +28756,15 @@ var buildEventDiscoveryUrl = ({
28663
28756
  };
28664
28757
 
28665
28758
  // src/pages/home/use-scroll-restoration.ts
28666
- var import_react46 = require("react");
28759
+ var import_react47 = require("react");
28667
28760
  function useScrollRestoration({
28668
28761
  enabled,
28669
28762
  scrollY,
28670
28763
  isReady
28671
28764
  }) {
28672
- const restoredRef = (0, import_react46.useRef)(false);
28673
- const [isRestoring, setIsRestoring] = (0, import_react46.useState)(enabled && scrollY > 0);
28674
- (0, import_react46.useLayoutEffect)(() => {
28765
+ const restoredRef = (0, import_react47.useRef)(false);
28766
+ const [isRestoring, setIsRestoring] = (0, import_react47.useState)(enabled && scrollY > 0);
28767
+ (0, import_react47.useLayoutEffect)(() => {
28675
28768
  if (!enabled || restoredRef.current) return;
28676
28769
  if (!isReady) return;
28677
28770
  restoredRef.current = true;
@@ -28684,15 +28777,15 @@ function useScrollRestoration({
28684
28777
  }
28685
28778
 
28686
28779
  // src/pages/home/use-home-page-modals.ts
28687
- var import_react47 = require("react");
28780
+ var import_react48 = require("react");
28688
28781
  var useHomePageModals = () => {
28689
- const [profileOpen, setProfileOpen] = (0, import_react47.useState)(false);
28690
- const [depositOpen, setDepositOpen] = (0, import_react47.useState)(false);
28691
- const [withdrawOpen, setWithdrawOpen] = (0, import_react47.useState)(false);
28692
- const onProfileClick = (0, import_react47.useCallback)(() => setProfileOpen(true), []);
28693
- const onDepositClick = (0, import_react47.useCallback)(() => setDepositOpen(true), []);
28694
- const onWithdrawClick = (0, import_react47.useCallback)(() => setWithdrawOpen(true), []);
28695
- (0, import_react47.useEffect)(() => {
28782
+ const [profileOpen, setProfileOpen] = (0, import_react48.useState)(false);
28783
+ const [depositOpen, setDepositOpen] = (0, import_react48.useState)(false);
28784
+ const [withdrawOpen, setWithdrawOpen] = (0, import_react48.useState)(false);
28785
+ const onProfileClick = (0, import_react48.useCallback)(() => setProfileOpen(true), []);
28786
+ const onDepositClick = (0, import_react48.useCallback)(() => setDepositOpen(true), []);
28787
+ const onWithdrawClick = (0, import_react48.useCallback)(() => setWithdrawOpen(true), []);
28788
+ (0, import_react48.useEffect)(() => {
28696
28789
  if (typeof window === "undefined") return;
28697
28790
  window.addEventListener(DEPOSIT_MODAL_OPEN_EVENT, onDepositClick);
28698
28791
  window.addEventListener(WITHDRAW_MODAL_OPEN_EVENT, onWithdrawClick);
@@ -28743,17 +28836,17 @@ var HomeSearchResults = ({
28743
28836
  const labels = (0, import_hooks75.useLabels)();
28744
28837
  const { search: searchConfig } = (0, import_hooks75.useSdkUiConfig)();
28745
28838
  const { disabledVenues } = (0, import_hooks75.useAppConfig)();
28746
- const [activeVenueTabValue, setActiveVenueTabValue] = (0, import_react48.useState)("all");
28839
+ const [activeVenueTabValue, setActiveVenueTabValue] = (0, import_react49.useState)("all");
28747
28840
  const eventListTabs = useEventListTabs();
28748
28841
  const { headerRef, titleRef, shouldUseSelectOverflow } = useEventListTabsHeaderOverflow(eventListTabs);
28749
- const visibleVenues = (0, import_react48.useMemo)(
28842
+ const visibleVenues = (0, import_react49.useMemo)(
28750
28843
  () => disabledVenues.length === 0 ? void 0 : (0, import_hooks75.getVisibleVenueIdsByConfig)(import_sdk25.VENUES, disabledVenues),
28751
28844
  [disabledVenues]
28752
28845
  );
28753
- const activeVenueTab = (0, import_react48.useMemo)(() => {
28846
+ const activeVenueTab = (0, import_react49.useMemo)(() => {
28754
28847
  return eventListTabs.find((tab) => tab.value === activeVenueTabValue);
28755
28848
  }, [activeVenueTabValue, eventListTabs]);
28756
- const activeCategoryTab = (0, import_react48.useMemo)(() => {
28849
+ const activeCategoryTab = (0, import_react49.useMemo)(() => {
28757
28850
  return resolvedTabs.find((tab) => tab.value === activeTabValue);
28758
28851
  }, [activeTabValue, resolvedTabs]);
28759
28852
  const activeVenues = resolveTabVenus(activeVenueTab, visibleVenues);
@@ -28777,28 +28870,28 @@ var HomeSearchResults = ({
28777
28870
  // so debounced keystrokes don't pay reranker latency.
28778
28871
  deep: true
28779
28872
  });
28780
- const openEvents = (0, import_react48.useMemo)(() => {
28873
+ const openEvents = (0, import_react49.useMemo)(() => {
28781
28874
  let filtered = filterOpenEvents(searchResults);
28782
28875
  if (activeVenues == null ? void 0 : activeVenues.length) {
28783
28876
  filtered = filtered.filter((e) => activeVenues.includes(e.venue));
28784
28877
  }
28785
28878
  return filtered;
28786
28879
  }, [searchResults, activeVenues]);
28787
- const visibleVenueMarkets = (0, import_react48.useMemo)(() => {
28880
+ const visibleVenueMarkets = (0, import_react49.useMemo)(() => {
28788
28881
  return openEvents.flatMap((event) => {
28789
28882
  var _a;
28790
28883
  return (_a = event.venueMarkets) != null ? _a : [];
28791
28884
  });
28792
28885
  }, [openEvents]);
28793
- const visibleMidpointVenueMarketIds = (0, import_react48.useMemo)(() => {
28886
+ const visibleMidpointVenueMarketIds = (0, import_react49.useMemo)(() => {
28794
28887
  return collectVisibleVenueMarketIds(visibleVenueMarkets);
28795
28888
  }, [visibleVenueMarkets]);
28796
28889
  const { midpointRows: sharedMidpointRows, isLoading: isSharedMidpointsLoading } = (0, import_hooks75.useVenueMarketMidpoints)({
28797
28890
  venueMarketIds: visibleMidpointVenueMarketIds,
28798
28891
  enabled: visibleMidpointVenueMarketIds.length > 0
28799
28892
  });
28800
- const loadMoreRef = (0, import_react48.useRef)(null);
28801
- (0, import_react48.useEffect)(() => {
28893
+ const loadMoreRef = (0, import_react49.useRef)(null);
28894
+ (0, import_react49.useEffect)(() => {
28802
28895
  if (!hasNextPage) return;
28803
28896
  const target = loadMoreRef.current;
28804
28897
  if (!target) return;
@@ -28957,9 +29050,9 @@ var HomePage = ({
28957
29050
  const { isLoading: isAppConfigLoading } = (0, import_hooks75.useAppConfig)();
28958
29051
  const primaryEventListTabs = useEventListTabs();
28959
29052
  const { capture, consume } = (0, import_hooks75.useEventListState)();
28960
- const [snapshot] = (0, import_react48.useState)(() => consume());
28961
- const eventListStateRef = (0, import_react48.useRef)(null);
28962
- const handleSelectEvent = (0, import_react48.useCallback)(
29053
+ const [snapshot] = (0, import_react49.useState)(() => consume());
29054
+ const eventListStateRef = (0, import_react49.useRef)(null);
29055
+ const handleSelectEvent = (0, import_react49.useCallback)(
28963
29056
  (event) => {
28964
29057
  var _a2, _b2, _c2, _d2;
28965
29058
  capture({
@@ -28978,14 +29071,14 @@ var HomePage = ({
28978
29071
  );
28979
29072
  const hasCustomTabs = !!tabs && tabs.length > 0;
28980
29073
  const normalizedSearchValue = searchValue.trim();
28981
- const [stickySelectedEvent, setStickySelectedEvent] = (0, import_react48.useState)(
29074
+ const [stickySelectedEvent, setStickySelectedEvent] = (0, import_react49.useState)(
28982
29075
  selectedEvent
28983
29076
  );
28984
- const [debouncedSearchValue, setDebouncedSearchValue] = (0, import_react48.useState)(() => {
29077
+ const [debouncedSearchValue, setDebouncedSearchValue] = (0, import_react49.useState)(() => {
28985
29078
  return normalizedSearchValue.length >= MIN_SEARCH_LENGTH2 ? normalizedSearchValue : "";
28986
29079
  });
28987
- const [isMobileSearchViewport, setIsMobileSearchViewport] = (0, import_react48.useState)(false);
28988
- (0, import_react48.useEffect)(() => {
29080
+ const [isMobileSearchViewport, setIsMobileSearchViewport] = (0, import_react49.useState)(false);
29081
+ (0, import_react49.useEffect)(() => {
28989
29082
  if (typeof window === "undefined") return;
28990
29083
  const mediaQueryList = window.matchMedia(MOBILE_HOME_SEARCH_MEDIA_QUERY);
28991
29084
  const handleMediaQueryChange = (event) => {
@@ -29003,7 +29096,7 @@ var HomePage = ({
29003
29096
  mediaQueryList.removeListener(handleMediaQueryChange);
29004
29097
  };
29005
29098
  }, []);
29006
- (0, import_react48.useEffect)(() => {
29099
+ (0, import_react49.useEffect)(() => {
29007
29100
  if (normalizedSearchValue.length < MIN_SEARCH_LENGTH2) {
29008
29101
  setDebouncedSearchValue("");
29009
29102
  return;
@@ -29015,7 +29108,7 @@ var HomePage = ({
29015
29108
  window.clearTimeout(timeoutId);
29016
29109
  };
29017
29110
  }, [normalizedSearchValue]);
29018
- (0, import_react48.useEffect)(() => {
29111
+ (0, import_react49.useEffect)(() => {
29019
29112
  if (selectedEvent) {
29020
29113
  setStickySelectedEvent(selectedEvent);
29021
29114
  return;
@@ -29030,30 +29123,30 @@ var HomePage = ({
29030
29123
  limit: categoriesLimit,
29031
29124
  enabled: !hasCustomTabs
29032
29125
  });
29033
- const categoryTabs = (0, import_react48.useMemo)(() => {
29126
+ const categoryTabs = (0, import_react49.useMemo)(() => {
29034
29127
  return resolveCategoryTabs(categories, resolvedAllCategoryTabLabel);
29035
29128
  }, [categories, resolvedAllCategoryTabLabel]);
29036
- const resolvedTabs = (0, import_react48.useMemo)(() => {
29129
+ const resolvedTabs = (0, import_react49.useMemo)(() => {
29037
29130
  if (hasCustomTabs && tabs) return tabs;
29038
29131
  return categoryTabs;
29039
29132
  }, [categoryTabs, hasCustomTabs, tabs]);
29040
- const availableCategoryValues = (0, import_react48.useMemo)(
29133
+ const availableCategoryValues = (0, import_react49.useMemo)(
29041
29134
  () => resolvedTabs.filter((tab) => !tab.disabled).map((tab) => tab.value),
29042
29135
  [resolvedTabs]
29043
29136
  );
29044
29137
  const resolvedDefaultCategory = resolveInitialTabValue(resolvedTabs, defaultActiveTab);
29045
29138
  const defaultCategory = availableCategoryValues.includes(resolvedDefaultCategory) ? resolvedDefaultCategory : (_a = availableCategoryValues[0]) != null ? _a : resolvedDefaultCategory;
29046
- const availableVenueTabs = (0, import_react48.useMemo)(
29139
+ const availableVenueTabs = (0, import_react49.useMemo)(
29047
29140
  () => primaryEventListTabs.filter((tab) => !tab.disabled && !tab.isComingSoon),
29048
29141
  [primaryEventListTabs]
29049
29142
  );
29050
- const availableVenueValues = (0, import_react48.useMemo)(
29143
+ const availableVenueValues = (0, import_react49.useMemo)(
29051
29144
  () => availableVenueTabs.map((tab) => tab.value),
29052
29145
  [availableVenueTabs]
29053
29146
  );
29054
29147
  const defaultVenue = (_c = (_b = availableVenueTabs[0]) == null ? void 0 : _b.value) != null ? _c : "matched";
29055
29148
  const resolvedEventSectionItems = eventSectionItems && eventSectionItems.length > 0 ? eventSectionItems : getDefaultEventSectionItems(labels);
29056
- const [discoveryFilterState, setDiscoveryFilterState] = (0, import_react48.useState)(
29149
+ const [discoveryFilterState, setDiscoveryFilterState] = (0, import_react49.useState)(
29057
29150
  () => {
29058
29151
  var _a2, _b2;
29059
29152
  return {
@@ -29064,12 +29157,12 @@ var HomePage = ({
29064
29157
  };
29065
29158
  }
29066
29159
  );
29067
- const discoveryFilterStateRef = (0, import_react48.useRef)(discoveryFilterState);
29160
+ const discoveryFilterStateRef = (0, import_react49.useRef)(discoveryFilterState);
29068
29161
  discoveryFilterStateRef.current = discoveryFilterState;
29069
- const [isUrlStateReady, setIsUrlStateReady] = (0, import_react48.useState)(!enableEventDiscoveryUrlPersistence);
29070
- const hasInitializedUrlStateRef = (0, import_react48.useRef)(false);
29162
+ const [isUrlStateReady, setIsUrlStateReady] = (0, import_react49.useState)(!enableEventDiscoveryUrlPersistence);
29163
+ const hasInitializedUrlStateRef = (0, import_react49.useRef)(false);
29071
29164
  const activeTabValue = discoveryFilterState.category;
29072
- const resolveCurrentUrlState = (0, import_react48.useCallback)(() => {
29165
+ const resolveCurrentUrlState = (0, import_react49.useCallback)(() => {
29073
29166
  if (typeof window === "undefined") return null;
29074
29167
  const parsedState = readEventDiscoveryUrlState(new URL(window.location.href).searchParams);
29075
29168
  const resolvedState = resolveEventDiscoveryUrlState({
@@ -29093,7 +29186,7 @@ var HomePage = ({
29093
29186
  shouldCanonicalize: resolvedState.shouldCanonicalize
29094
29187
  };
29095
29188
  }, [availableCategoryValues, availableVenueValues, defaultCategory, defaultVenue]);
29096
- const writeFilterStateToHistory = (0, import_react48.useCallback)(
29189
+ const writeFilterStateToHistory = (0, import_react49.useCallback)(
29097
29190
  (state, historyMode) => {
29098
29191
  if (!enableEventDiscoveryUrlPersistence || typeof window === "undefined") return;
29099
29192
  const currentUrl = new URL(window.location.href);
@@ -29115,7 +29208,7 @@ var HomePage = ({
29115
29208
  },
29116
29209
  [defaultCategory, defaultVenue, enableEventDiscoveryUrlPersistence]
29117
29210
  );
29118
- const commitDiscoveryFilterState = (0, import_react48.useCallback)(
29211
+ const commitDiscoveryFilterState = (0, import_react49.useCallback)(
29119
29212
  (state, historyMode) => {
29120
29213
  discoveryFilterStateRef.current = state;
29121
29214
  setDiscoveryFilterState(state);
@@ -29123,7 +29216,7 @@ var HomePage = ({
29123
29216
  },
29124
29217
  [isUrlStateReady, writeFilterStateToHistory]
29125
29218
  );
29126
- (0, import_react48.useEffect)(() => {
29219
+ (0, import_react49.useEffect)(() => {
29127
29220
  if (!enableEventDiscoveryUrlPersistence) {
29128
29221
  hasInitializedUrlStateRef.current = false;
29129
29222
  setIsUrlStateReady(true);
@@ -29162,7 +29255,7 @@ var HomePage = ({
29162
29255
  isCategoriesLoading,
29163
29256
  resolveCurrentUrlState
29164
29257
  ]);
29165
- (0, import_react48.useEffect)(() => {
29258
+ (0, import_react49.useEffect)(() => {
29166
29259
  if (!enableEventDiscoveryUrlPersistence || !isUrlStateReady) return;
29167
29260
  const handlePopState = () => {
29168
29261
  const resolvedUrlState = resolveCurrentUrlState();
@@ -29183,9 +29276,9 @@ var HomePage = ({
29183
29276
  resolveCurrentUrlState,
29184
29277
  writeFilterStateToHistory
29185
29278
  ]);
29186
- const activeTabValueRef = (0, import_react48.useRef)(activeTabValue);
29279
+ const activeTabValueRef = (0, import_react49.useRef)(activeTabValue);
29187
29280
  activeTabValueRef.current = activeTabValue;
29188
- (0, import_react48.useEffect)(() => {
29281
+ (0, import_react49.useEffect)(() => {
29189
29282
  if (enableEventDiscoveryUrlPersistence && !isUrlStateReady) return;
29190
29283
  const currentState = discoveryFilterStateRef.current;
29191
29284
  const categoryIsAvailable = availableCategoryValues.includes(currentState.category);
@@ -29211,7 +29304,7 @@ var HomePage = ({
29211
29304
  enableEventDiscoveryUrlPersistence,
29212
29305
  isUrlStateReady
29213
29306
  ]);
29214
- const tabsItems = (0, import_react48.useMemo)(() => {
29307
+ const tabsItems = (0, import_react49.useMemo)(() => {
29215
29308
  return resolvedTabs.map((tab) => {
29216
29309
  const isActive = tab.value === activeTabValue;
29217
29310
  return {
@@ -29231,10 +29324,10 @@ var HomePage = ({
29231
29324
  };
29232
29325
  });
29233
29326
  }, [activeTabValue, resolvedTabs]);
29234
- const activeTab = (0, import_react48.useMemo)(() => {
29327
+ const activeTab = (0, import_react49.useMemo)(() => {
29235
29328
  return resolvedTabs.find((tab) => tab.value === activeTabValue);
29236
29329
  }, [activeTabValue, resolvedTabs]);
29237
- const resolvedSectionItems = (0, import_react48.useMemo)(() => {
29330
+ const resolvedSectionItems = (0, import_react49.useMemo)(() => {
29238
29331
  var _a2, _b2, _c2;
29239
29332
  if (activeTabValue === ALL_CATEGORIES_TAB_VALUE) {
29240
29333
  return resolvedEventSectionItems;
@@ -29431,7 +29524,25 @@ HomePage.displayName = "HomePage";
29431
29524
  var import_hooks83 = require("@agg-build/hooks");
29432
29525
  var import_sdk29 = require("@agg-build/sdk");
29433
29526
  var import_dayjs9 = __toESM(require("dayjs"));
29434
- var import_react51 = require("react");
29527
+ var import_react52 = require("react");
29528
+
29529
+ // src/pages/user-profile/cost-basis-display.ts
29530
+ function costBasisDisplay(outcome) {
29531
+ if (outcome.costBasisUnknown === true) {
29532
+ return {
29533
+ averagePriceCents: null,
29534
+ averagePrice: null,
29535
+ totalTradedValue: null,
29536
+ costUnknown: true
29537
+ };
29538
+ }
29539
+ return {
29540
+ averagePriceCents: Math.round(outcome.avgEntryPrice * 100),
29541
+ averagePrice: outcome.avgEntryPrice,
29542
+ totalTradedValue: outcome.avgEntryPrice * outcome.totalSize,
29543
+ costUnknown: false
29544
+ };
29545
+ }
29435
29546
 
29436
29547
  // src/pages/user-profile/components/available-balance-card.tsx
29437
29548
  var import_hooks76 = require("@agg-build/hooks");
@@ -29479,6 +29590,7 @@ var AvailableBalanceCard = ({
29479
29590
  label: label2,
29480
29591
  valueLabel,
29481
29592
  reservedValueLabel,
29593
+ kalshiValueLabel,
29482
29594
  chains,
29483
29595
  isLoading = false,
29484
29596
  className,
@@ -29631,6 +29743,13 @@ var AvailableBalanceCard = ({
29631
29743
  }
29632
29744
  )
29633
29745
  ] }),
29746
+ kalshiValueLabel !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime177.jsxs)("div", { className: "agg-balance-kalshi flex items-center justify-between gap-3", children: [
29747
+ /* @__PURE__ */ (0, import_jsx_runtime177.jsx)("div", { className: "font-agg-sans text-agg-base leading-6 font-agg-bold text-agg-foreground", children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime177.jsx)("div", { role: "status", "aria-label": "Loading Kalshi balance", children: /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(SkeletonBlock, { className: "h-6 w-16 rounded-agg-sm" }) }) : kalshiValueLabel }),
29748
+ /* @__PURE__ */ (0, import_jsx_runtime177.jsxs)("span", { className: "flex h-5 shrink-0 items-center gap-1 rounded-[4px] bg-agg-secondary-hover px-1.5", children: [
29749
+ /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(VenueLogo, { venue: "kalshi", size: "small", className: "size-3" }),
29750
+ /* @__PURE__ */ (0, import_jsx_runtime177.jsx)("span", { className: "font-agg-sans text-agg-xs leading-agg-4 font-agg-normal text-agg-muted-foreground", children: labels.venues.kalshi })
29751
+ ] })
29752
+ ] }) : null,
29634
29753
  !isLoading && reservedValueLabel ? /* @__PURE__ */ (0, import_jsx_runtime177.jsx)("p", { className: "font-agg-sans text-agg-xs leading-agg-4 text-agg-muted-foreground", children: balanceLabels.reservedForOpenOrders(reservedValueLabel) }) : null
29635
29754
  ]
29636
29755
  }
@@ -29773,7 +29892,7 @@ var ClaimActivityBreakdownModal = ({
29773
29892
  var import_hooks78 = require("@agg-build/hooks");
29774
29893
  var import_sdk28 = require("@agg-build/sdk");
29775
29894
  var Dialog9 = __toESM(require("@radix-ui/react-dialog"));
29776
- var import_react49 = require("react");
29895
+ var import_react50 = require("react");
29777
29896
  var import_zod3 = require("zod");
29778
29897
  var import_jsx_runtime179 = require("react/jsx-runtime");
29779
29898
  var USDC_DECIMALS = 6;
@@ -29857,16 +29976,16 @@ var ManageBalancesModal = ({
29857
29976
  const depositAddressesQuery = (0, import_hooks78.useDepositAddresses)({ enabled: open });
29858
29977
  const policiesQuery = (0, import_hooks78.useBalanceRefillPolicies)({ enabled: open });
29859
29978
  const toastContext = useOptionalToast();
29860
- const descriptionId = (0, import_react49.useId)();
29861
- const savingRef = (0, import_react49.useRef)(false);
29862
- const [expandedChainIds, setExpandedChainIds] = (0, import_react49.useState)(/* @__PURE__ */ new Set());
29863
- const [resetChainIds, setResetChainIds] = (0, import_react49.useState)(/* @__PURE__ */ new Set());
29864
- const [drafts, setDrafts] = (0, import_react49.useState)({});
29865
- const [initialDrafts, setInitialDrafts] = (0, import_react49.useState)({});
29866
- const [submissionErrors, setSubmissionErrors] = (0, import_react49.useState)({});
29867
- const [isInitialized, setIsInitialized] = (0, import_react49.useState)(false);
29868
- const [isSaving, setIsSaving] = (0, import_react49.useState)(false);
29869
- const networks = (0, import_react49.useMemo)(() => {
29979
+ const descriptionId = (0, import_react50.useId)();
29980
+ const savingRef = (0, import_react50.useRef)(false);
29981
+ const [expandedChainIds, setExpandedChainIds] = (0, import_react50.useState)(/* @__PURE__ */ new Set());
29982
+ const [resetChainIds, setResetChainIds] = (0, import_react50.useState)(/* @__PURE__ */ new Set());
29983
+ const [drafts, setDrafts] = (0, import_react50.useState)({});
29984
+ const [initialDrafts, setInitialDrafts] = (0, import_react50.useState)({});
29985
+ const [submissionErrors, setSubmissionErrors] = (0, import_react50.useState)({});
29986
+ const [isInitialized, setIsInitialized] = (0, import_react50.useState)(false);
29987
+ const [isSaving, setIsSaving] = (0, import_react50.useState)(false);
29988
+ const networks = (0, import_react50.useMemo)(() => {
29870
29989
  var _a, _b, _c;
29871
29990
  const supportedChains = (_a = depositAddressesQuery.supportedChains) != null ? _a : [];
29872
29991
  const availableBalanceBreakdown = (_c = (_b = balanceState.availableBalanceBreakdown) != null ? _b : balanceState.balanceBreakdown) != null ? _c : [];
@@ -29906,7 +30025,7 @@ var ManageBalancesModal = ({
29906
30025
  const hasPoliciesLoadError = policiesQuery.isError && policiesQuery.data === void 0;
29907
30026
  const loadError = hasDepositAddressesLoadError ? depositAddressesQuery.error : hasPoliciesLoadError ? policiesQuery.error : balanceState.error;
29908
30027
  const hasLoadError = hasDepositAddressesLoadError || hasPoliciesLoadError || Boolean(balanceState.error);
29909
- (0, import_react49.useEffect)(() => {
30028
+ (0, import_react50.useEffect)(() => {
29910
30029
  if (open) return;
29911
30030
  setExpandedChainIds(/* @__PURE__ */ new Set());
29912
30031
  setResetChainIds(/* @__PURE__ */ new Set());
@@ -29917,7 +30036,7 @@ var ManageBalancesModal = ({
29917
30036
  setIsSaving(false);
29918
30037
  savingRef.current = false;
29919
30038
  }, [open]);
29920
- (0, import_react49.useEffect)(() => {
30039
+ (0, import_react50.useEffect)(() => {
29921
30040
  if (!open || isLoading || hasLoadError || isInitialized) return;
29922
30041
  const nextDrafts = Object.fromEntries(
29923
30042
  networks.map((network) => [network.chainId, getInitialDraft(network.policy)])
@@ -29926,7 +30045,7 @@ var ManageBalancesModal = ({
29926
30045
  setInitialDrafts(nextDrafts);
29927
30046
  setIsInitialized(true);
29928
30047
  }, [hasLoadError, isInitialized, isLoading, networks, open]);
29929
- const validateDraft = (0, import_react49.useCallback)(
30048
+ const validateDraft = (0, import_react50.useCallback)(
29930
30049
  (network, draft) => {
29931
30050
  const errors = {};
29932
30051
  const minimum = draft.minimum.trim();
@@ -29960,7 +30079,7 @@ var ManageBalancesModal = ({
29960
30079
  },
29961
30080
  [refillLabels]
29962
30081
  );
29963
- const dirtyNetworks = (0, import_react49.useMemo)(
30082
+ const dirtyNetworks = (0, import_react50.useMemo)(
29964
30083
  () => networks.filter((network) => {
29965
30084
  if (!network.canManageBalance) return false;
29966
30085
  if (resetChainIds.has(network.chainId)) return true;
@@ -29971,7 +30090,7 @@ var ManageBalancesModal = ({
29971
30090
  }),
29972
30091
  [drafts, initialDrafts, networks, resetChainIds]
29973
30092
  );
29974
- const validationErrors = (0, import_react49.useMemo)(
30093
+ const validationErrors = (0, import_react50.useMemo)(
29975
30094
  () => Object.fromEntries(
29976
30095
  dirtyNetworks.map((network) => {
29977
30096
  var _a;
@@ -29987,14 +30106,14 @@ var ManageBalancesModal = ({
29987
30106
  (errors) => errors.minimum || errors.refillTo || errors.general
29988
30107
  );
29989
30108
  const isSaveDisabled = dirtyNetworks.length === 0 || hasValidationErrors || isSaving;
29990
- const handleOpenChange = (0, import_react49.useCallback)(
30109
+ const handleOpenChange = (0, import_react50.useCallback)(
29991
30110
  (nextOpen) => {
29992
30111
  if (isSaving && !nextOpen) return;
29993
30112
  onOpenChange(nextOpen);
29994
30113
  },
29995
30114
  [isSaving, onOpenChange]
29996
30115
  );
29997
- const handleToggleNetwork = (0, import_react49.useCallback)((chainId, canManageBalance) => {
30116
+ const handleToggleNetwork = (0, import_react50.useCallback)((chainId, canManageBalance) => {
29998
30117
  if (!canManageBalance) return;
29999
30118
  setExpandedChainIds((current) => {
30000
30119
  const next = new Set(current);
@@ -30003,7 +30122,7 @@ var ManageBalancesModal = ({
30003
30122
  return next;
30004
30123
  });
30005
30124
  }, []);
30006
- const handleDraftChange = (0, import_react49.useCallback)(
30125
+ const handleDraftChange = (0, import_react50.useCallback)(
30007
30126
  (chainId, field, value) => {
30008
30127
  if (!EDITABLE_AMOUNT_PATTERN.test(value)) return;
30009
30128
  setDrafts((current) => {
@@ -30032,7 +30151,7 @@ var ManageBalancesModal = ({
30032
30151
  },
30033
30152
  []
30034
30153
  );
30035
- const handleResetNetwork = (0, import_react49.useCallback)((network) => {
30154
+ const handleResetNetwork = (0, import_react50.useCallback)((network) => {
30036
30155
  setDrafts((current) => __spreadProps(__spreadValues({}, current), {
30037
30156
  [network.chainId]: { minimum: "0", refillTo: "0" }
30038
30157
  }));
@@ -30048,7 +30167,7 @@ var ManageBalancesModal = ({
30048
30167
  return __spreadProps(__spreadValues({}, current), { [network.chainId]: {} });
30049
30168
  });
30050
30169
  }, []);
30051
- const handleAmountBlur = (0, import_react49.useCallback)((chainId, field) => {
30170
+ const handleAmountBlur = (0, import_react50.useCallback)((chainId, field) => {
30052
30171
  setDrafts((current) => {
30053
30172
  const currentDraft = current[chainId];
30054
30173
  if (!currentDraft) return current;
@@ -30059,12 +30178,12 @@ var ManageBalancesModal = ({
30059
30178
  });
30060
30179
  });
30061
30180
  }, []);
30062
- const handleRetry = (0, import_react49.useCallback)(() => {
30181
+ const handleRetry = (0, import_react50.useCallback)(() => {
30063
30182
  void depositAddressesQuery.refetch();
30064
30183
  void policiesQuery.refetch();
30065
30184
  balanceState.refetch();
30066
30185
  }, [balanceState, depositAddressesQuery, policiesQuery]);
30067
- const handleSave = (0, import_react49.useCallback)(() => __async(null, null, function* () {
30186
+ const handleSave = (0, import_react50.useCallback)(() => __async(null, null, function* () {
30068
30187
  if (savingRef.current || isSaveDisabled) return;
30069
30188
  savingRef.current = true;
30070
30189
  setIsSaving(true);
@@ -30477,7 +30596,7 @@ ManageBalancesModal.displayName = "ManageBalancesModal";
30477
30596
 
30478
30597
  // src/pages/user-profile/components/positions-activity.tsx
30479
30598
  var import_hooks81 = require("@agg-build/hooks");
30480
- var import_react50 = require("react");
30599
+ var import_react51 = require("react");
30481
30600
 
30482
30601
  // src/pages/user-profile/user-profile.constants.ts
30483
30602
  var USER_PROFILE_TAB_POSITIONS = "positions";
@@ -30556,6 +30675,7 @@ var resolvePositionStatus = (position) => {
30556
30675
  return "open";
30557
30676
  };
30558
30677
  var resolvePositionBucket = (position) => {
30678
+ if (position.status === "closed") return "closed";
30559
30679
  const status = resolvePositionStatus(position);
30560
30680
  if (status === "won_unclaimed") return "active";
30561
30681
  if (status === "open") return "active";
@@ -31332,6 +31452,18 @@ var OpenOrderRow = ({
31332
31452
  };
31333
31453
  const canCancel = canCancelOpenOrder(order);
31334
31454
  const isPending = isPendingOpenOrder(order);
31455
+ const sideLabel = order.side === "buy" ? labels.buy : order.side === "sell" ? labels.sell : void 0;
31456
+ const outcomePillLabel = sideLabel ? `${sideLabel} ${order.outcomeLabel}` : order.outcomeLabel;
31457
+ const currentPriceLabel = order.currentPriceLabel ? `${labels.nowPrefix} ${order.currentPriceLabel}` : void 0;
31458
+ const mobileStats = [
31459
+ __spreadValues({
31460
+ label: resolvedLimitPriceHeader,
31461
+ value: (_a = order.limitPriceLabel) != null ? _a : "\u2014"
31462
+ }, currentPriceLabel ? { subValue: currentPriceLabel } : {}),
31463
+ { label: resolvedFilledHeader, value: order.filledLabel },
31464
+ { label: resolvedTotalHeader, value: order.valueLabel },
31465
+ { label: resolvedExpirationHeader, value: (_b = order.expirationLabel) != null ? _b : "\u2014" }
31466
+ ];
31335
31467
  const Wrapper = href ? "a" : "div";
31336
31468
  const wrapperProps = href ? {
31337
31469
  href,
@@ -31370,22 +31502,23 @@ var OpenOrderRow = ({
31370
31502
  ) }),
31371
31503
  /* @__PURE__ */ (0, import_jsx_runtime182.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col justify-center gap-2", children: [
31372
31504
  /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("p", { className: "agg-open-order-market min-w-0 overflow-hidden font-agg-sans text-agg-sm leading-agg-5 font-agg-bold text-agg-foreground [display:-webkit-box] [-webkit-line-clamp:2] [-webkit-box-orient:vertical] lg:text-agg-base lg:leading-agg-6 lg:whitespace-nowrap lg:text-ellipsis lg:[-webkit-line-clamp:1] lg:[display:block]", children: order.title }),
31373
- /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("span", { className: "agg-open-order-outcome hidden lg:inline-flex w-fit items-center justify-center rounded-full bg-agg-secondary-hover px-4 py-[6px]", children: /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("span", { className: "font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-agg-foreground whitespace-nowrap", children: order.outcomeLabel }) })
31505
+ /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("span", { className: "agg-open-order-outcome hidden lg:inline-flex w-fit items-center justify-center rounded-full bg-agg-secondary-hover px-4 py-[6px]", children: /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("span", { className: "font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-agg-foreground whitespace-nowrap", children: outcomePillLabel }) })
31374
31506
  ] })
31375
31507
  ] }),
31376
31508
  /* @__PURE__ */ (0, import_jsx_runtime182.jsxs)("div", { className: "flex w-full flex-wrap items-center gap-x-4 gap-y-2 lg:hidden", children: [
31377
- /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("span", { className: "agg-open-order-outcome inline-flex shrink-0 items-center justify-center rounded-full bg-agg-secondary-hover px-4 py-[6px]", children: /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("span", { className: "font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-agg-foreground whitespace-nowrap", children: order.outcomeLabel }) }),
31378
- [
31379
- { label: resolvedLimitPriceHeader, value: (_a = order.limitPriceLabel) != null ? _a : "\u2014" },
31380
- { label: resolvedFilledHeader, value: order.filledLabel },
31381
- { label: resolvedTotalHeader, value: order.valueLabel },
31382
- { label: resolvedExpirationHeader, value: (_b = order.expirationLabel) != null ? _b : "\u2014" }
31383
- ].map(({ label: label2, value }) => /* @__PURE__ */ (0, import_jsx_runtime182.jsxs)("div", { className: "flex items-baseline gap-1.5 whitespace-nowrap", children: [
31384
- /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("span", { className: "font-agg-sans text-agg-lg leading-agg-7 font-agg-normal text-agg-foreground", children: value }),
31385
- /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("span", { className: "font-agg-sans text-[10px] leading-[14px] font-agg-bold uppercase text-agg-muted-foreground", children: label2 })
31509
+ /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("span", { className: "agg-open-order-outcome inline-flex shrink-0 items-center justify-center rounded-full bg-agg-secondary-hover px-4 py-[6px]", children: /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("span", { className: "font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-agg-foreground whitespace-nowrap", children: outcomePillLabel }) }),
31510
+ mobileStats.map(({ label: label2, value, subValue }) => /* @__PURE__ */ (0, import_jsx_runtime182.jsxs)("div", { className: "flex flex-col gap-0.5", children: [
31511
+ /* @__PURE__ */ (0, import_jsx_runtime182.jsxs)("div", { className: "flex items-baseline gap-1.5 whitespace-nowrap", children: [
31512
+ /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("span", { className: "font-agg-sans text-agg-lg leading-agg-7 font-agg-normal text-agg-foreground", children: value }),
31513
+ /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("span", { className: "font-agg-sans text-[10px] leading-[14px] font-agg-bold uppercase text-agg-muted-foreground", children: label2 })
31514
+ ] }),
31515
+ subValue ? /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("span", { className: "agg-open-order-current-price font-agg-sans text-agg-sm leading-agg-5 font-agg-normal whitespace-nowrap text-agg-foreground", children: subValue }) : null
31386
31516
  ] }, label2))
31387
31517
  ] }),
31388
- /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("p", { className: "agg-open-order-limit-price hidden w-[120px] shrink-0 agg-type-body-strong text-agg-foreground lg:block", children: (_c = order.limitPriceLabel) != null ? _c : "\u2014" }),
31518
+ /* @__PURE__ */ (0, import_jsx_runtime182.jsxs)("div", { className: "agg-open-order-limit-price hidden w-[120px] shrink-0 flex-col justify-center gap-0.5 lg:flex", children: [
31519
+ /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("p", { className: "agg-type-body-strong text-agg-foreground", children: (_c = order.limitPriceLabel) != null ? _c : "\u2014" }),
31520
+ currentPriceLabel ? /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("p", { className: "agg-open-order-current-price font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-agg-foreground", children: currentPriceLabel }) : null
31521
+ ] }),
31389
31522
  /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("p", { className: "agg-open-order-filled hidden w-[120px] shrink-0 agg-type-body-strong text-agg-foreground lg:block", children: order.filledLabel }),
31390
31523
  /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("p", { className: "agg-open-order-value hidden w-[120px] shrink-0 agg-type-body-strong text-agg-foreground lg:block", children: order.valueLabel }),
31391
31524
  /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("p", { className: "agg-open-order-expiration hidden w-[140px] shrink-0 agg-type-label text-agg-foreground lg:block", children: (_d = order.expirationLabel) != null ? _d : "\u2014" }),
@@ -31476,8 +31609,8 @@ var ResultBadge = ({
31476
31609
  status,
31477
31610
  labels
31478
31611
  }) => {
31479
- if (status !== "won_claimed" && status !== "lost" && status !== "sold") return null;
31480
- const isWon = status === "won_claimed";
31612
+ const isWon = status === "won_claimed" || status === "won_unclaimed";
31613
+ if (!isWon && status !== "lost" && status !== "sold") return null;
31481
31614
  const isSold = status === "sold";
31482
31615
  return /* @__PURE__ */ (0, import_jsx_runtime183.jsxs)(
31483
31616
  "span",
@@ -31743,7 +31876,7 @@ var getTabItems = (tabsLabels, showOpenOrders) => [
31743
31876
  ...showOpenOrders ? [{ value: USER_PROFILE_TAB_OPEN_ORDERS, label: tabsLabels.openOrders }] : [],
31744
31877
  { value: USER_PROFILE_TAB_ACTIVITY, label: tabsLabels.activity }
31745
31878
  ];
31746
- var TabRowsSkeleton = ({ ariaLabel }) => /* @__PURE__ */ (0, import_jsx_runtime184.jsx)("div", { role: "status", "aria-label": ariaLabel, className: "flex flex-col gap-3 sm:gap-4", children: Array.from({ length: 3 }).map((_, index, acc) => /* @__PURE__ */ (0, import_jsx_runtime184.jsxs)(import_react50.Fragment, { children: [
31879
+ var TabRowsSkeleton = ({ ariaLabel }) => /* @__PURE__ */ (0, import_jsx_runtime184.jsx)("div", { role: "status", "aria-label": ariaLabel, className: "flex flex-col gap-3 sm:gap-4", children: Array.from({ length: 3 }).map((_, index, acc) => /* @__PURE__ */ (0, import_jsx_runtime184.jsxs)(import_react51.Fragment, { children: [
31747
31880
  /* @__PURE__ */ (0, import_jsx_runtime184.jsx)("div", { className: "h-14 rounded-agg-sm bg-agg-secondary-hover/80 sm:h-16" }, index),
31748
31881
  index < acc.length - 1 ? /* @__PURE__ */ (0, import_jsx_runtime184.jsx)("div", { className: "agg-position-divider h-px w-full shrink-0 bg-agg-separator", "aria-hidden": true }) : null
31749
31882
  ] }, index)) });
@@ -31791,12 +31924,12 @@ var PositionsActivity = ({
31791
31924
  const positionsLabels = userProfileLabels.positions;
31792
31925
  const openOrdersLabels = userProfileLabels.openOrders;
31793
31926
  const { formatCurrency: formatCurrency2, formatPrice } = (0, import_hooks81.useAggUiConfig)().formatting;
31794
- const tabItems = (0, import_react50.useMemo)(
31927
+ const tabItems = (0, import_react51.useMemo)(
31795
31928
  () => getTabItems(userProfileLabels.tabs, showOpenOrders),
31796
31929
  [showOpenOrders, userProfileLabels.tabs]
31797
31930
  );
31798
31931
  const isTabControlled = tab !== void 0;
31799
- const [internalActiveTab, setInternalActiveTab] = (0, import_react50.useState)(
31932
+ const [internalActiveTab, setInternalActiveTab] = (0, import_react51.useState)(
31800
31933
  tab != null ? tab : USER_PROFILE_TAB_POSITIONS
31801
31934
  );
31802
31935
  const requestedActiveTab = isTabControlled ? tab : internalActiveTab;
@@ -31806,21 +31939,21 @@ var PositionsActivity = ({
31806
31939
  if (!isTabControlled) setInternalActiveTab(next);
31807
31940
  onTabChange == null ? void 0 : onTabChange(next);
31808
31941
  };
31809
- const [positionFilter, setPositionFilter] = (0, import_react50.useState)(initialPositionFilter);
31810
- const [searchValue, setSearchValue] = (0, import_react50.useState)("");
31811
- const [isSearchFocused, setIsSearchFocused] = (0, import_react50.useState)(false);
31812
- const [locallyClaimedPositionIds, setLocallyClaimedPositionIds] = (0, import_react50.useState)(
31942
+ const [positionFilter, setPositionFilter] = (0, import_react51.useState)(initialPositionFilter);
31943
+ const [searchValue, setSearchValue] = (0, import_react51.useState)("");
31944
+ const [isSearchFocused, setIsSearchFocused] = (0, import_react51.useState)(false);
31945
+ const [locallyClaimedPositionIds, setLocallyClaimedPositionIds] = (0, import_react51.useState)(
31813
31946
  () => /* @__PURE__ */ new Set()
31814
31947
  );
31815
- const positionsLoadMoreRef = (0, import_react50.useRef)(null);
31816
- const openOrdersLoadMoreRef = (0, import_react50.useRef)(null);
31817
- const activitiesLoadMoreRef = (0, import_react50.useRef)(null);
31818
- const rowsScrollRef = (0, import_react50.useRef)(null);
31948
+ const positionsLoadMoreRef = (0, import_react51.useRef)(null);
31949
+ const openOrdersLoadMoreRef = (0, import_react51.useRef)(null);
31950
+ const activitiesLoadMoreRef = (0, import_react51.useRef)(null);
31951
+ const rowsScrollRef = (0, import_react51.useRef)(null);
31819
31952
  const isPositionsTab = activeTab === USER_PROFILE_TAB_POSITIONS;
31820
31953
  const isOpenOrdersTab = activeTab === USER_PROFILE_TAB_OPEN_ORDERS;
31821
31954
  const isActivityTab = activeTab === USER_PROFILE_TAB_ACTIVITY;
31822
31955
  const isClosedPositionsFilter = isPositionsTab && positionFilter === "closed";
31823
- const positionsForCurrentFilter = (0, import_react50.useMemo)(() => {
31956
+ const positionsForCurrentFilter = (0, import_react51.useMemo)(() => {
31824
31957
  if (positionFilter === "active") {
31825
31958
  return activePositions.filter((position) => !locallyClaimedPositionIds.has(position.id));
31826
31959
  }
@@ -31837,7 +31970,7 @@ var PositionsActivity = ({
31837
31970
  }
31838
31971
  return Array.from(byId.values());
31839
31972
  }, [activePositions, closedPositions, locallyClaimedPositionIds, positionFilter]);
31840
- const filteredPositions = (0, import_react50.useMemo)(() => {
31973
+ const filteredPositions = (0, import_react51.useMemo)(() => {
31841
31974
  if (!searchValue.trim()) return positionsForCurrentFilter;
31842
31975
  const q = searchValue.toLowerCase();
31843
31976
  return positionsForCurrentFilter.filter((p) => p.title.toLowerCase().includes(q));
@@ -31862,7 +31995,7 @@ var PositionsActivity = ({
31862
31995
  const isLoadingMorePositions = positionFilter === "active" ? isLoadingMoreActivePositions : isLoadingMoreClosedPositions;
31863
31996
  const loadMorePositions = positionFilter === "active" ? onLoadMoreActivePositions : onLoadMoreClosedPositions;
31864
31997
  const filteredActivities = activities;
31865
- const searchResults = (0, import_react50.useMemo)(() => {
31998
+ const searchResults = (0, import_react51.useMemo)(() => {
31866
31999
  if (!isPositionsTab || !searchValue.trim()) return [];
31867
32000
  return filteredPositions.slice(0, 5).map((position) => ({
31868
32001
  id: position.id,
@@ -31891,11 +32024,11 @@ var PositionsActivity = ({
31891
32024
  const handleSearchChange = (event) => {
31892
32025
  setSearchValue(event.target.value);
31893
32026
  };
31894
- (0, import_react50.useEffect)(() => {
32027
+ (0, import_react51.useEffect)(() => {
31895
32028
  if (isPositionsTab) return;
31896
32029
  setIsSearchFocused(false);
31897
32030
  }, [isPositionsTab]);
31898
- (0, import_react50.useEffect)(() => {
32031
+ (0, import_react51.useEffect)(() => {
31899
32032
  if (!isPositionsTab || !hasMorePositions) return;
31900
32033
  const target = positionsLoadMoreRef.current;
31901
32034
  if (!target || !loadMorePositions) return;
@@ -31917,7 +32050,7 @@ var PositionsActivity = ({
31917
32050
  isPositionsTab,
31918
32051
  loadMorePositions
31919
32052
  ]);
31920
- (0, import_react50.useEffect)(() => {
32053
+ (0, import_react51.useEffect)(() => {
31921
32054
  if (!isActivityTab || !hasMoreActivities) return;
31922
32055
  const target = activitiesLoadMoreRef.current;
31923
32056
  if (!target || !onLoadMoreActivities) return;
@@ -31939,7 +32072,7 @@ var PositionsActivity = ({
31939
32072
  isLoadingMoreActivities,
31940
32073
  onLoadMoreActivities
31941
32074
  ]);
31942
- (0, import_react50.useEffect)(() => {
32075
+ (0, import_react51.useEffect)(() => {
31943
32076
  if (!isOpenOrdersTab || !hasMoreOpenOrders) return;
31944
32077
  const target = openOrdersLoadMoreRef.current;
31945
32078
  if (!target || !onLoadMoreOpenOrders) return;
@@ -32174,7 +32307,7 @@ var PositionsActivity = ({
32174
32307
  }
32175
32308
  ) : filteredPositions.length > 0 ? filteredPositions.map((position, index) => {
32176
32309
  var _a;
32177
- return /* @__PURE__ */ (0, import_jsx_runtime184.jsxs)(import_react50.Fragment, { children: [
32310
+ return /* @__PURE__ */ (0, import_jsx_runtime184.jsxs)(import_react51.Fragment, { children: [
32178
32311
  index > 0 ? /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(
32179
32312
  "div",
32180
32313
  {
@@ -32219,7 +32352,7 @@ var PositionsActivity = ({
32219
32352
  title: openOrdersLabels.errorTitle,
32220
32353
  description: openOrdersLabels.errorDescription
32221
32354
  }
32222
- ) : openOrders.length > 0 ? openOrders.map((order, index) => /* @__PURE__ */ (0, import_jsx_runtime184.jsxs)(import_react50.Fragment, { children: [
32355
+ ) : openOrders.length > 0 ? openOrders.map((order, index) => /* @__PURE__ */ (0, import_jsx_runtime184.jsxs)(import_react51.Fragment, { children: [
32223
32356
  index > 0 ? /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(
32224
32357
  "div",
32225
32358
  {
@@ -32266,7 +32399,7 @@ var PositionsActivity = ({
32266
32399
  title: "Unable to load activity",
32267
32400
  description: "Please try again in a moment."
32268
32401
  }
32269
- ) : filteredActivities.length > 0 ? filteredActivities.map((activity, index) => /* @__PURE__ */ (0, import_jsx_runtime184.jsxs)(import_react50.Fragment, { children: [
32402
+ ) : filteredActivities.length > 0 ? filteredActivities.map((activity, index) => /* @__PURE__ */ (0, import_jsx_runtime184.jsxs)(import_react51.Fragment, { children: [
32270
32403
  index > 0 ? /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(
32271
32404
  "div",
32272
32405
  {
@@ -32699,11 +32832,13 @@ var formatScaledNumberTwoDecimals = (value) => {
32699
32832
  if (parsed == null) return "0.00";
32700
32833
  return twoDecimalNumberFormatter.format(parsed);
32701
32834
  };
32835
+ var formatPriceCentsLabel = (value) => `${limitPriceCentsFormatter.format(value * 100)}\xA2`;
32702
32836
  var formatLimitPriceLabel2 = (value) => {
32703
32837
  const parsed = parseRawMicroValue(value);
32704
32838
  if (parsed == null) return void 0;
32705
- return `${limitPriceCentsFormatter.format(parsed * 100)}\xA2`;
32839
+ return formatPriceCentsLabel(parsed);
32706
32840
  };
32841
+ var normalizeOutcomeMatchLabel = (value) => typeof value === "string" ? value.trim().toLowerCase() : "";
32707
32842
  var formatOpenOrderExpirationLabel = ({
32708
32843
  timeInForce,
32709
32844
  expiresAt,
@@ -33134,8 +33269,8 @@ var UserProfilePage = ({
33134
33269
  onError
33135
33270
  }) => {
33136
33271
  var _a, _b, _c;
33137
- const [isHydrated, setIsHydrated] = (0, import_react51.useState)(false);
33138
- (0, import_react51.useEffect)(() => {
33272
+ const [isHydrated, setIsHydrated] = (0, import_react52.useState)(false);
33273
+ (0, import_react52.useEffect)(() => {
33139
33274
  setIsHydrated(true);
33140
33275
  }, []);
33141
33276
  const { user: currentUser, isAuthenticated } = (0, import_hooks83.useAggAuthState)();
@@ -33148,28 +33283,28 @@ var UserProfilePage = ({
33148
33283
  const client = (0, import_hooks83.useAggClient)();
33149
33284
  const cancelOrderMutation = (0, import_hooks83.useCancelManagedOrder)();
33150
33285
  const toastContext = useOptionalToast();
33151
- const [internalCancellingIds, setInternalCancellingIds] = (0, import_react51.useState)({});
33286
+ const [internalCancellingIds, setInternalCancellingIds] = (0, import_react52.useState)({});
33152
33287
  const { claim: startClaim, claimingKeys } = useClaimWinnings({
33153
33288
  onClaim,
33154
33289
  onClaimResult,
33155
33290
  onClaimSubmitError,
33156
33291
  externalClaimingKeys: claimingPositionKeys
33157
33292
  });
33158
- const [profileUser, setProfileUser] = (0, import_react51.useState)(void 0);
33293
+ const [profileUser, setProfileUser] = (0, import_react52.useState)(void 0);
33159
33294
  const shouldUseHookData = !user;
33160
- const connectedVenues = (0, import_react51.useMemo)(() => {
33295
+ const connectedVenues = (0, import_react52.useMemo)(() => {
33161
33296
  var _a2;
33162
33297
  if (!shouldUseHookData) return [];
33163
33298
  const fromBalance = (_a2 = balanceState.connectedVenues) != null ? _a2 : [];
33164
33299
  return [...new Set(fromBalance)].sort((a, b) => a.localeCompare(b));
33165
33300
  }, [balanceState, shouldUseHookData]);
33166
- const [positionFilter, setPositionFilter] = (0, import_react51.useState)(initialPositionFilter);
33167
- const [selectedClaimActivity, setSelectedClaimActivity] = (0, import_react51.useState)(null);
33168
- const [isManageBalancesOpen, setIsManageBalancesOpen] = (0, import_react51.useState)(false);
33169
- const manageBalancesButtonRef = (0, import_react51.useRef)(null);
33301
+ const [positionFilter, setPositionFilter] = (0, import_react52.useState)(initialPositionFilter);
33302
+ const [selectedClaimActivity, setSelectedClaimActivity] = (0, import_react52.useState)(null);
33303
+ const [isManageBalancesOpen, setIsManageBalancesOpen] = (0, import_react52.useState)(false);
33304
+ const manageBalancesButtonRef = (0, import_react52.useRef)(null);
33170
33305
  const { executionMode: resolvedExecutionMode, isPaperMode } = (0, import_hooks83.useResolvedExecutionMode)(executionMode);
33171
33306
  const queryExecutionMode = resolvedExecutionMode === "paper" ? "paper" : void 0;
33172
- const handleManageBalancesOpenChange = (0, import_react51.useCallback)((open) => {
33307
+ const handleManageBalancesOpenChange = (0, import_react52.useCallback)((open) => {
33173
33308
  setIsManageBalancesOpen(open);
33174
33309
  if (open) return;
33175
33310
  requestAnimationFrame(() => {
@@ -33189,14 +33324,14 @@ var UserProfilePage = ({
33189
33324
  limit: 25,
33190
33325
  mode: queryExecutionMode
33191
33326
  });
33192
- const handlePositionFilterChange = (0, import_react51.useCallback)(
33327
+ const handlePositionFilterChange = (0, import_react52.useCallback)(
33193
33328
  (filter) => {
33194
33329
  setPositionFilter(filter);
33195
33330
  onPositionFilterChangeProp == null ? void 0 : onPositionFilterChangeProp(filter);
33196
33331
  },
33197
33332
  [onPositionFilterChangeProp]
33198
33333
  );
33199
- (0, import_react51.useEffect)(() => {
33334
+ (0, import_react52.useEffect)(() => {
33200
33335
  setPositionFilter(initialPositionFilter);
33201
33336
  }, [initialPositionFilter]);
33202
33337
  const ordersQuery = (0, import_hooks83.useExecutionOrders)({
@@ -33261,7 +33396,7 @@ var UserProfilePage = ({
33261
33396
  limit: 25,
33262
33397
  mode: queryExecutionMode
33263
33398
  });
33264
- const openOrderQueries = (0, import_react51.useMemo)(
33399
+ const openOrderQueries = (0, import_react52.useMemo)(
33265
33400
  () => [
33266
33401
  pendingOpenOrdersQuery,
33267
33402
  signingOpenOrdersQuery,
@@ -33287,7 +33422,7 @@ var UserProfilePage = ({
33287
33422
  enabled: shouldUseHookData && isAuthenticated,
33288
33423
  limit: 25
33289
33424
  });
33290
- const handleCancelOrder = (0, import_react51.useCallback)(
33425
+ const handleCancelOrder = (0, import_react52.useCallback)(
33291
33426
  (order) => __async(null, null, function* () {
33292
33427
  if (onCancelOrder) {
33293
33428
  onCancelOrder(order);
@@ -33320,7 +33455,7 @@ var UserProfilePage = ({
33320
33455
  }),
33321
33456
  [cancelOrderMutation, labels.notifications.order, onCancelOrder, toastContext]
33322
33457
  );
33323
- const handleClaimPosition = (0, import_react51.useCallback)(
33458
+ const handleClaimPosition = (0, import_react52.useCallback)(
33324
33459
  (position) => {
33325
33460
  var _a2, _b2;
33326
33461
  return startClaim({
@@ -33331,7 +33466,7 @@ var UserProfilePage = ({
33331
33466
  },
33332
33467
  [startClaim]
33333
33468
  );
33334
- const handleActivityRowClick = (0, import_react51.useCallback)(
33469
+ const handleActivityRowClick = (0, import_react52.useCallback)(
33335
33470
  (activity) => {
33336
33471
  if (activity.kind === "redeem") {
33337
33472
  setSelectedClaimActivity(activity);
@@ -33341,13 +33476,13 @@ var UserProfilePage = ({
33341
33476
  },
33342
33477
  [onActivityClick]
33343
33478
  );
33344
- const handleClaimTransactionSelect = (0, import_react51.useCallback)((transaction) => {
33479
+ const handleClaimTransactionSelect = (0, import_react52.useCallback)((transaction) => {
33345
33480
  const href = buildAggTxExplorerHref(transaction.chainId, transaction.txHash);
33346
33481
  setSelectedClaimActivity(null);
33347
33482
  if (!href || typeof window === "undefined") return;
33348
33483
  window.open(href, "_blank", "noopener,noreferrer");
33349
33484
  }, []);
33350
- (0, import_react51.useEffect)(() => {
33485
+ (0, import_react52.useEffect)(() => {
33351
33486
  if (!shouldUseHookData || !isAuthenticated) {
33352
33487
  setProfileUser(void 0);
33353
33488
  return;
@@ -33366,7 +33501,7 @@ var UserProfilePage = ({
33366
33501
  isActive = false;
33367
33502
  };
33368
33503
  }, [client, currentUser, isAuthenticated, shouldUseHookData]);
33369
- const resolvedUser = (0, import_react51.useMemo)(() => {
33504
+ const resolvedUser = (0, import_react52.useMemo)(() => {
33370
33505
  var _a2, _b2, _c2, _d, _e, _f;
33371
33506
  if (user) return user;
33372
33507
  const fullUser = profileUser != null ? profileUser : currentUser;
@@ -33400,7 +33535,7 @@ var UserProfilePage = ({
33400
33535
  socialHandle: normalizedTwitterHandle != null ? normalizedTwitterHandle : void 0
33401
33536
  };
33402
33537
  }, [connectedVenues, currentUser, profileUser, user]);
33403
- const _resolvedVenueBalances = (0, import_react51.useMemo)(() => {
33538
+ const _resolvedVenueBalances = (0, import_react52.useMemo)(() => {
33404
33539
  if (_venueBalances) return _venueBalances;
33405
33540
  return balanceState.balanceBreakdown.map((item) => ({
33406
33541
  chain: item.label,
@@ -33408,24 +33543,24 @@ var UserProfilePage = ({
33408
33543
  balanceLabel: formatUsd2(item.balance)
33409
33544
  }));
33410
33545
  }, [_venueBalances, balanceState.balanceBreakdown]);
33411
- const positionsValueLabel = (0, import_react51.useMemo)(() => {
33546
+ const positionsValueLabel = (0, import_react52.useMemo)(() => {
33412
33547
  var _a2;
33413
33548
  if (balance == null ? void 0 : balance.totalLabel) return balance.totalLabel;
33414
33549
  return formatUsd2((_a2 = balanceState.positionsBalanceTotal) != null ? _a2 : 0);
33415
33550
  }, [balance == null ? void 0 : balance.totalLabel, balanceState.positionsBalanceTotal]);
33416
- const availableBalanceLabel = (0, import_react51.useMemo)(() => {
33551
+ const availableBalanceLabel = (0, import_react52.useMemo)(() => {
33417
33552
  var _a2, _b2;
33418
33553
  return formatUsd2((_b2 = (_a2 = balanceState.availableBalance) != null ? _a2 : balanceState.totalBalance) != null ? _b2 : 0);
33419
33554
  }, [balanceState.availableBalance, balanceState.totalBalance]);
33420
33555
  const paperSummary = (_a = balanceState.managedBalances) == null ? void 0 : _a.paper;
33421
- const paperBuyingPowerLabel = (0, import_react51.useMemo)(
33556
+ const paperBuyingPowerLabel = (0, import_react52.useMemo)(
33422
33557
  () => {
33423
33558
  var _a2;
33424
33559
  return formatUsd2((_a2 = paperSummary == null ? void 0 : paperSummary.cashBalance) != null ? _a2 : 0);
33425
33560
  },
33426
33561
  [paperSummary == null ? void 0 : paperSummary.cashBalance]
33427
33562
  );
33428
- const paperEarningsLabel = (0, import_react51.useMemo)(
33563
+ const paperEarningsLabel = (0, import_react52.useMemo)(
33429
33564
  () => {
33430
33565
  var _a2;
33431
33566
  return formatUsd2((_a2 = paperSummary == null ? void 0 : paperSummary.earnings) != null ? _a2 : 0);
@@ -33440,7 +33575,7 @@ var UserProfilePage = ({
33440
33575
  }) === "available";
33441
33576
  const isPositionsValueLoading = !(balance == null ? void 0 : balance.totalLabel) && balanceState.isLoading;
33442
33577
  const isAvailableBalanceLoading = balanceState.isLoading;
33443
- const resolvedActivities = (0, import_react51.useMemo)(() => {
33578
+ const resolvedActivities = (0, import_react52.useMemo)(() => {
33444
33579
  if (activities) return activities.filter(isVisibleUserProfileActivity);
33445
33580
  const formatTime = isHydrated ? toRelativeTimeLabel : toAbsoluteTimeLabel;
33446
33581
  return activityQuery.activities.filter(isVisibleActivityItem).map((item, index) => {
@@ -33591,8 +33726,7 @@ var UserProfilePage = ({
33591
33726
  };
33592
33727
  });
33593
33728
  }, [activities, activityQuery.activities, isHydrated, labels, ordersQuery.orders]);
33594
- const resolvedOpenOrders = (0, import_react51.useMemo)(() => {
33595
- if (openOrders) return openOrders.filter(isUserProfileLimitOrder);
33729
+ const openOrderRows = (0, import_react52.useMemo)(() => {
33596
33730
  const orderRowsById = /* @__PURE__ */ new Map();
33597
33731
  for (const query of openOrderQueries) {
33598
33732
  for (const order of query.orders) {
@@ -33603,7 +33737,47 @@ var UserProfilePage = ({
33603
33737
  (order) => isOpenOrderStatus(order.status) && isExecutionLimitOrder(order)
33604
33738
  ).sort(
33605
33739
  (a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
33606
- ).map((order) => {
33740
+ );
33741
+ }, [openOrderQueries]);
33742
+ const openOrderVenueMarketIds = (0, import_react52.useMemo)(
33743
+ () => openOrderRows.map((order) => {
33744
+ var _a2;
33745
+ return (_a2 = order.venueMarket) == null ? void 0 : _a2.id;
33746
+ }).filter((venueMarketId) => Boolean(venueMarketId)),
33747
+ [openOrderRows]
33748
+ );
33749
+ const openOrderMidpointsQuery = (0, import_hooks83.useVenueMarketMidpoints)({
33750
+ venueMarketIds: openOrderVenueMarketIds,
33751
+ enabled: !openOrders && openOrderVenueMarketIds.length > 0
33752
+ });
33753
+ const openOrderMidpointRows = openOrderMidpointsQuery.midpointRows;
33754
+ const openOrderCurrentPriceLabels = (0, import_react52.useMemo)(() => {
33755
+ var _a2, _b2, _c2, _d;
33756
+ const midpointRowsByVenueMarketId = new Map(
33757
+ openOrderMidpointRows.map((row) => [row.venueMarketId, row])
33758
+ );
33759
+ const labelsByOrderId = /* @__PURE__ */ new Map();
33760
+ for (const order of openOrderRows) {
33761
+ const venueMarketId = (_a2 = order.venueMarket) == null ? void 0 : _a2.id;
33762
+ if (!venueMarketId) continue;
33763
+ const midpointRow = midpointRowsByVenueMarketId.get(venueMarketId);
33764
+ if (!midpointRow) continue;
33765
+ const orderOutcomeLabels = [
33766
+ normalizeOutcomeMatchLabel((_b2 = order.venueMarketOutcome) == null ? void 0 : _b2.label),
33767
+ normalizeOutcomeMatchLabel((_c2 = order.venueMarketOutcome) == null ? void 0 : _c2.title)
33768
+ ].filter(Boolean);
33769
+ if (orderOutcomeLabels.length === 0) continue;
33770
+ const outcomeMidpoint = (_d = midpointRow.outcomes) == null ? void 0 : _d.find(
33771
+ (outcome) => orderOutcomeLabels.includes(normalizeOutcomeMatchLabel(outcome.label))
33772
+ );
33773
+ if ((outcomeMidpoint == null ? void 0 : outcomeMidpoint.midpoint) == null) continue;
33774
+ labelsByOrderId.set(order.id, formatPriceCentsLabel(outcomeMidpoint.midpoint));
33775
+ }
33776
+ return labelsByOrderId;
33777
+ }, [openOrderMidpointRows, openOrderRows]);
33778
+ const resolvedOpenOrders = (0, import_react52.useMemo)(() => {
33779
+ if (openOrders) return openOrders.filter(isUserProfileLimitOrder);
33780
+ return openOrderRows.map((order) => {
33607
33781
  var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k;
33608
33782
  const isLimitOrder = isExecutionLimitOrder(order);
33609
33783
  const filledRaw = isLimitOrder ? order.filledSizeRaw : order.filledAmountRaw;
@@ -33616,15 +33790,17 @@ var UserProfilePage = ({
33616
33790
  goodTilCanceledLabel: labels.userProfile.openOrders.goodTilCanceled,
33617
33791
  expiredLabel: labels.userProfile.openOrders.expired
33618
33792
  });
33619
- return __spreadProps(__spreadValues(__spreadProps(__spreadValues({
33793
+ const currentPriceLabel = openOrderCurrentPriceLabels.get(order.id);
33794
+ return __spreadProps(__spreadValues(__spreadProps(__spreadValues(__spreadValues(__spreadProps(__spreadValues({
33620
33795
  id: order.id,
33621
33796
  eventId: (_c2 = (_b2 = order.venueMarket) == null ? void 0 : _b2.venueEventId) != null ? _c2 : void 0,
33622
33797
  marketId: (_e = (_d = order.venueMarket) == null ? void 0 : _d.id) != null ? _e : void 0,
33623
33798
  thumbnailSrc: (_g = (_f = order.venueMarket) == null ? void 0 : _f.image) != null ? _g : fallbackThumbnailSrc,
33624
33799
  title: ((_h = order.venueMarket) == null ? void 0 : _h.question) || "Market",
33625
- outcomeLabel: ((_i = order.venueMarketOutcome) == null ? void 0 : _i.title) || ((_j = order.venueMarketOutcome) == null ? void 0 : _j.label) || "Outcome",
33800
+ outcomeLabel: ((_i = order.venueMarketOutcome) == null ? void 0 : _i.title) || ((_j = order.venueMarketOutcome) == null ? void 0 : _j.label) || "Outcome"
33801
+ }, order.side === "sell" || order.side === "buy" ? { side: order.side } : {}), {
33626
33802
  venue: order.venue
33627
- }, limitPriceLabel ? { limitPriceLabel } : {}), {
33803
+ }), limitPriceLabel ? { limitPriceLabel } : {}), currentPriceLabel ? { currentPriceLabel } : {}), {
33628
33804
  filledLabel: `${formatScaledNumberTwoDecimals(filledRaw != null ? filledRaw : "0")}/${formatScaledNumberTwoDecimals(totalRaw)}`,
33629
33805
  valueLabel: formatFilledUsdTwoDecimals(totalCostRaw)
33630
33806
  }), expirationLabel ? { expirationLabel } : {}), {
@@ -33633,31 +33809,31 @@ var UserProfilePage = ({
33633
33809
  dagRunId: (_k = order.dagRunId) != null ? _k : null
33634
33810
  });
33635
33811
  });
33636
- }, [labels, openOrderQueries, openOrders]);
33637
- const isOpenOrdersQueryLoading = (0, import_react51.useMemo)(
33812
+ }, [labels, openOrderCurrentPriceLabels, openOrderRows, openOrders]);
33813
+ const isOpenOrdersQueryLoading = (0, import_react52.useMemo)(
33638
33814
  () => openOrderQueries.some((query) => query.isLoading),
33639
33815
  [openOrderQueries]
33640
33816
  );
33641
- const hasOpenOrdersQueryError = (0, import_react51.useMemo)(
33817
+ const hasOpenOrdersQueryError = (0, import_react52.useMemo)(
33642
33818
  () => openOrderQueries.some((query) => query.error),
33643
33819
  [openOrderQueries]
33644
33820
  );
33645
- const hasMoreOpenOrdersQuery = (0, import_react51.useMemo)(
33821
+ const hasMoreOpenOrdersQuery = (0, import_react52.useMemo)(
33646
33822
  () => openOrderQueries.some((query) => query.hasNextPage),
33647
33823
  [openOrderQueries]
33648
33824
  );
33649
- const isLoadingMoreOpenOrdersQuery = (0, import_react51.useMemo)(
33825
+ const isLoadingMoreOpenOrdersQuery = (0, import_react52.useMemo)(
33650
33826
  () => openOrderQueries.some((query) => query.isFetchingNextPage),
33651
33827
  [openOrderQueries]
33652
33828
  );
33653
- const handleLoadMoreOpenOrders = (0, import_react51.useCallback)(() => {
33829
+ const handleLoadMoreOpenOrders = (0, import_react52.useCallback)(() => {
33654
33830
  for (const query of openOrderQueries) {
33655
33831
  if (query.hasNextPage) {
33656
33832
  void query.fetchNextPage();
33657
33833
  }
33658
33834
  }
33659
33835
  }, [openOrderQueries]);
33660
- const adaptPositionGroups = (0, import_react51.useCallback)(
33836
+ const adaptPositionGroups = (0, import_react52.useCallback)(
33661
33837
  (groups) => {
33662
33838
  return groups.flatMap((group) => {
33663
33839
  var _a2, _b2, _c2, _d;
@@ -33674,16 +33850,15 @@ var UserProfilePage = ({
33674
33850
  const outcomeId = (_b3 = (_a3 = outcome.venueBreakdown.find((row) => row.venueMarketOutcomeId)) == null ? void 0 : _a3.venueMarketOutcomeId) != null ? _b3 : void 0;
33675
33851
  const isResolved = group.venueMarket.status === "resolved";
33676
33852
  const isUnpriced = outcome.priceSource === "entry";
33677
- const averagePriceCents = Math.round(outcome.avgEntryPrice * 100);
33678
- const totalTradedValue = outcome.avgEntryPrice * outcome.totalSize;
33853
+ const { averagePriceCents, averagePrice, totalTradedValue, costUnknown } = costBasisDisplay(outcome);
33679
33854
  const finalPayoutValue = isResolved ? outcome.winner === true ? outcome.totalValue : 0 : outcome.totalValue;
33680
33855
  const finalPrice = isResolved ? outcome.winner === true ? 1 : 0 : outcome.currentPrice;
33681
- const finalPnlValue = finalPayoutValue - totalTradedValue;
33682
- const finalPnlPercent = totalTradedValue === 0 ? 0 : finalPnlValue / Math.abs(totalTradedValue) * 100;
33856
+ const finalPnlValue = totalTradedValue == null ? null : finalPayoutValue - totalTradedValue;
33857
+ const finalPnlPercent = totalTradedValue == null || totalTradedValue === 0 || finalPnlValue == null ? null : finalPnlValue / Math.abs(totalTradedValue) * 100;
33683
33858
  const displayCurrentPrice = isResolved ? finalPrice : isUnpriced ? null : outcome.currentPrice;
33684
33859
  const displayCurrentValue = isResolved ? finalPayoutValue : isUnpriced ? null : outcome.totalValue;
33685
- const displayPnlValue = isResolved ? finalPnlValue : isUnpriced ? null : outcome.unrealizedPnl;
33686
- const displayPnlPercent = isResolved ? finalPnlPercent : isUnpriced ? null : outcome.unrealizedPnlPercent;
33860
+ const displayPnlValue = costUnknown ? null : isResolved ? finalPnlValue : isUnpriced ? null : outcome.unrealizedPnl;
33861
+ const displayPnlPercent = costUnknown ? null : isResolved ? finalPnlPercent : isUnpriced ? null : outcome.unrealizedPnlPercent;
33687
33862
  const currentPriceCents = typeof displayCurrentPrice === "number" ? Math.round(displayCurrentPrice * 100) : null;
33688
33863
  const pnlPrefix = (displayPnlValue != null ? displayPnlValue : 0) >= 0 ? "+" : "";
33689
33864
  const pnlPercent = displayPnlPercent == null ? null : displayPnlPercent.toFixed(2);
@@ -33699,8 +33874,8 @@ var UserProfilePage = ({
33699
33874
  resolutionLabel: winningOutcomeLabel,
33700
33875
  venueShareBreakdown: buildVenueShareBreakdown(outcome),
33701
33876
  totalShares: outcome.totalSize,
33702
- averageLabel: `${averagePriceCents}\xA2`,
33703
- averagePrice: outcome.avgEntryPrice,
33877
+ averageLabel: averagePriceCents == null ? "\u2014" : `${averagePriceCents}\xA2`,
33878
+ averagePrice,
33704
33879
  currentLabel: currentPriceCents == null ? "\u2014" : `${currentPriceCents}\xA2`,
33705
33880
  currentPrice: displayCurrentPrice,
33706
33881
  valueLabel: displayCurrentValue == null ? "\u2014" : formatUsd2(displayCurrentValue),
@@ -33713,14 +33888,14 @@ var UserProfilePage = ({
33713
33888
  marketStatus: group.venueMarket.status,
33714
33889
  winner: (_f = outcome.winner) != null ? _f : null,
33715
33890
  resolutionDate: group.resolutionDate,
33716
- closedTotalTradedLabel: formatUsd2(totalTradedValue),
33891
+ closedTotalTradedLabel: totalTradedValue == null ? "\u2014" : formatUsd2(totalTradedValue),
33717
33892
  totalTradedValue,
33718
33893
  closedAmountWonLabel: formatUsd2(finalPayoutValue),
33719
33894
  finalPayoutValue,
33720
33895
  finalPnlValue,
33721
33896
  finalPnlPercent,
33722
33897
  finalPrice,
33723
- closedReturnLabel: formatSignedPercentLabel(finalPnlPercent / 100),
33898
+ closedReturnLabel: finalPnlPercent == null ? "\u2014" : formatSignedPercentLabel(finalPnlPercent / 100),
33724
33899
  closedClaimStatus: group.redeemStatus,
33725
33900
  winningOutcomeIds: winningOutcomeIds.length > 0 ? winningOutcomeIds : closedTotals.winningOutcomeIds
33726
33901
  };
@@ -33729,11 +33904,11 @@ var UserProfilePage = ({
33729
33904
  },
33730
33905
  []
33731
33906
  );
33732
- const resolvedActivePositions = (0, import_react51.useMemo)(() => {
33907
+ const resolvedActivePositions = (0, import_react52.useMemo)(() => {
33733
33908
  const source = activePositions != null ? activePositions : adaptPositionGroups(activePositionsQuery.positions);
33734
33909
  return source.filter(shouldIncludeByShares);
33735
33910
  }, [activePositions, activePositionsQuery.positions, adaptPositionGroups]);
33736
- const resolvedClosedPositions = (0, import_react51.useMemo)(() => {
33911
+ const resolvedClosedPositions = (0, import_react52.useMemo)(() => {
33737
33912
  const source = closedPositions != null ? closedPositions : adaptPositionGroups(closedPositionsQuery.positions);
33738
33913
  return source.filter(shouldIncludeByShares);
33739
33914
  }, [closedPositions, closedPositionsQuery.positions, adaptPositionGroups]);
@@ -33798,32 +33973,13 @@ var UserProfilePage = ({
33798
33973
  classNames == null ? void 0 : classNames.rightColumn
33799
33974
  ),
33800
33975
  children: [
33801
- /* @__PURE__ */ (0, import_jsx_runtime188.jsxs)(
33802
- "div",
33976
+ /* @__PURE__ */ (0, import_jsx_runtime188.jsx)(
33977
+ PositionsValueCard,
33803
33978
  {
33804
- className: cn(
33805
- "grid gap-4",
33806
- isKalshiAvailable && !isPaperMode ? "grid-cols-1 sm:grid-cols-2" : "grid-cols-1"
33807
- ),
33808
- children: [
33809
- /* @__PURE__ */ (0, import_jsx_runtime188.jsx)(
33810
- PositionsValueCard,
33811
- {
33812
- label: labels.userProfile.balance.positionsValue,
33813
- valueLabel: positionsValueLabel,
33814
- isLoading: isPositionsValueLoading,
33815
- compact: isPaperMode
33816
- }
33817
- ),
33818
- isKalshiAvailable && !isPaperMode ? /* @__PURE__ */ (0, import_jsx_runtime188.jsx)(
33819
- PositionsValueCard,
33820
- {
33821
- label: labels.userProfile.balance.kalshiBalance,
33822
- valueLabel: formatUsd2((_b = balanceState.kalshiBalance) != null ? _b : 0),
33823
- icon: /* @__PURE__ */ (0, import_jsx_runtime188.jsx)(VenueLogo, { venue: import_sdk29.Venue.kalshi, size: "small", className: "size-4" })
33824
- }
33825
- ) : null
33826
- ]
33979
+ label: labels.userProfile.balance.positionsValue,
33980
+ valueLabel: positionsValueLabel,
33981
+ isLoading: isPositionsValueLoading,
33982
+ compact: isPaperMode
33827
33983
  }
33828
33984
  ),
33829
33985
  isPaperMode ? (
@@ -33872,13 +34028,14 @@ var UserProfilePage = ({
33872
34028
  {
33873
34029
  valueLabel: availableBalanceLabel,
33874
34030
  isLoading: isAvailableBalanceLoading,
33875
- chains: ((_c = balanceChainsOverride != null ? balanceChainsOverride : balanceState.availableBalanceBreakdown) != null ? _c : balanceState.balanceBreakdown).map((b) => ({
34031
+ chains: ((_b = balanceChainsOverride != null ? balanceChainsOverride : balanceState.availableBalanceBreakdown) != null ? _b : balanceState.balanceBreakdown).map((b) => ({
33876
34032
  key: b.key,
33877
34033
  label: b.label,
33878
34034
  balance: b.balance,
33879
34035
  accountCount: b.accountCount,
33880
34036
  venues: b.venues
33881
34037
  })),
34038
+ kalshiValueLabel: isKalshiAvailable ? formatUsd2((_c = balanceState.kalshiBalance) != null ? _c : 0) : void 0,
33882
34039
  manageButtonRef: manageBalancesButtonRef,
33883
34040
  onManage: () => handleManageBalancesOpenChange(true)
33884
34041
  }