@agg-build/ui 2.1.1 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/{chunk-TERG43WW.mjs → chunk-5RBHMMY3.mjs} +1 -1
  2. package/dist/{chunk-RPXRTXCY.mjs → chunk-75AMJAWR.mjs} +1 -1
  3. package/dist/{chunk-IQT4I5B4.mjs → chunk-7ZR5JYB3.mjs} +39 -241
  4. package/dist/{chunk-NK57KMYN.mjs → chunk-JJDYOBVG.mjs} +117 -48
  5. package/dist/{chunk-WU2C3C6K.mjs → chunk-NRNBJPYK.mjs} +1 -1
  6. package/dist/{chunk-YJO6LMRT.mjs → chunk-TBD3N4T4.mjs} +69 -7
  7. package/dist/{chunk-XHDGSRG7.mjs → chunk-ZOECARZW.mjs} +359 -14
  8. package/dist/events.js +175 -59
  9. package/dist/events.mjs +3 -3
  10. package/dist/index.js +1080 -820
  11. package/dist/index.mjs +12 -8
  12. package/dist/modals.js +1 -1
  13. package/dist/modals.mjs +3 -3
  14. package/dist/pages.js +845 -589
  15. package/dist/pages.mjs +6 -6
  16. package/dist/primitives.js +68 -7
  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 +679 -339
  21. package/dist/trading.mjs +10 -6
  22. package/dist/types/events/shared/format-event-title.d.mts +25 -0
  23. package/dist/types/events/shared/format-event-title.d.ts +25 -0
  24. package/dist/types/events/shared/select-best-outcome.d.mts +88 -0
  25. package/dist/types/events/shared/select-best-outcome.d.ts +88 -0
  26. package/dist/types/pages/event-market/event-market.types.d.mts +7 -0
  27. package/dist/types/pages/event-market/event-market.types.d.ts +7 -0
  28. package/dist/types/primitives/search/search.utils.d.mts +3 -1
  29. package/dist/types/primitives/search/search.utils.d.ts +3 -1
  30. package/dist/types/trading/index.d.mts +2 -0
  31. package/dist/types/trading/index.d.ts +2 -0
  32. package/dist/types/trading/place-order/index.d.mts +1 -1
  33. package/dist/types/trading/place-order/index.d.ts +1 -1
  34. package/dist/types/trading/place-order/index.place-order.types.d.mts +23 -1
  35. package/dist/types/trading/place-order/index.place-order.types.d.ts +23 -1
  36. package/dist/types/trading/use-claim-winnings.d.mts +84 -0
  37. package/dist/types/trading/use-claim-winnings.d.ts +84 -0
  38. package/dist/types/trading/use-resolved-market-claim.d.mts +26 -0
  39. package/dist/types/trading/use-resolved-market-claim.d.ts +26 -0
  40. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -260,9 +260,11 @@ __export(src_exports, {
260
260
  toDate: () => toDate,
261
261
  typographyVariants: () => typographyVariants,
262
262
  useCenterOrderbookSpread: () => useCenterOrderbookSpread,
263
+ useClaimWinnings: () => useClaimWinnings,
263
264
  useEventTradingContext: () => import_hooks41.useEventTradingContext,
264
265
  useHomePageModals: () => useHomePageModals,
265
266
  useOptionalToast: () => useOptionalToast,
267
+ useResolvedMarketClaim: () => useResolvedMarketClaim,
266
268
  useToast: () => useToast,
267
269
  venueLogoNames: () => venueLogoNames
268
270
  });
@@ -6805,7 +6807,57 @@ var SEARCH_DEBOUNCE_MS = 300;
6805
6807
 
6806
6808
  // src/primitives/search/search.utils.ts
6807
6809
  var import_sdk11 = require("@agg-build/sdk");
6810
+ var import_dayjs3 = __toESM(require("dayjs"));
6811
+
6812
+ // src/events/shared/format-event-title.ts
6808
6813
  var import_dayjs2 = __toESM(require("dayjs"));
6814
+ var SPORT_CATEGORY_TOKENS = /* @__PURE__ */ new Set(["sport", "sports"]);
6815
+ var normalizeCategoryToken = (value) => {
6816
+ if (typeof value !== "string") return null;
6817
+ const normalizedValue = value.trim().toLowerCase();
6818
+ if (!normalizedValue) return null;
6819
+ return normalizedValue;
6820
+ };
6821
+ var isSportCategoryToken = (value) => {
6822
+ const normalizedValue = normalizeCategoryToken(value);
6823
+ if (!normalizedValue) return false;
6824
+ return SPORT_CATEGORY_TOKENS.has(normalizedValue);
6825
+ };
6826
+ var isSportEvent = (categories, structureType) => {
6827
+ var _a;
6828
+ if (isSportCategoryToken(structureType)) return true;
6829
+ return (_a = categories == null ? void 0 : categories.some((categoryEntry) => {
6830
+ var _a2, _b, _c, _d;
6831
+ return isSportCategoryToken(categoryEntry.id) || isSportCategoryToken((_a2 = categoryEntry.category) == null ? void 0 : _a2.id) || isSportCategoryToken((_b = categoryEntry.category) == null ? void 0 : _b.name) || isSportCategoryToken((_c = categoryEntry.category) == null ? void 0 : _c.displayName) || isSportCategoryToken((_d = categoryEntry.category) == null ? void 0 : _d.parentId);
6832
+ })) != null ? _a : false;
6833
+ };
6834
+ var formatEventDateSuffix = (value, locale) => {
6835
+ if (!(0, import_dayjs2.default)(value).isValid()) return null;
6836
+ return new Intl.DateTimeFormat(locale, {
6837
+ month: "long",
6838
+ day: "numeric",
6839
+ timeZone: "UTC"
6840
+ }).format(new Date(value));
6841
+ };
6842
+ var formatEventTitleWithDateSuffix = ({
6843
+ title: title2,
6844
+ categories,
6845
+ structureType,
6846
+ gameStartTime,
6847
+ endDate,
6848
+ locale = "en-US"
6849
+ }) => {
6850
+ const resolvedTitle = title2.trim();
6851
+ if (!resolvedTitle) return resolvedTitle;
6852
+ if (!isSportEvent(categories, structureType)) return resolvedTitle;
6853
+ const dateSource = gameStartTime != null ? gameStartTime : endDate;
6854
+ if (!dateSource) return resolvedTitle;
6855
+ const formattedDate = formatEventDateSuffix(dateSource, locale);
6856
+ if (!formattedDate) return resolvedTitle;
6857
+ const suffix = ` - ${formattedDate}`;
6858
+ if (resolvedTitle.endsWith(suffix)) return resolvedTitle;
6859
+ return `${resolvedTitle}${suffix}`;
6860
+ };
6809
6861
 
6810
6862
  // src/events/item/event-list-item.utils.ts
6811
6863
  var import_hooks26 = require("@agg-build/hooks");
@@ -7118,8 +7170,8 @@ var resolveDisplayVolume = (eventVolume, venueMarkets) => {
7118
7170
 
7119
7171
  // src/primitives/search/search.utils.ts
7120
7172
  var formatSearchContextLabel = (value) => {
7121
- if (!(0, import_dayjs2.default)(value).isValid()) return value;
7122
- return (0, import_dayjs2.default)(value).format("MMMM D, YYYY");
7173
+ if (!(0, import_dayjs3.default)(value).isValid()) return value;
7174
+ return (0, import_dayjs3.default)(value).format("MMMM D, YYYY");
7123
7175
  };
7124
7176
  var venueLogoNameSet = new Set(import_sdk11.VENUES);
7125
7177
  var toVenueLogoName = (value) => {
@@ -7127,7 +7179,7 @@ var toVenueLogoName = (value) => {
7127
7179
  if (!venueLogoNameSet.has(value)) return null;
7128
7180
  return value;
7129
7181
  };
7130
- var mapVenueEventToSearchResult = (event, labels, formatPercent, formatCompactCurrency) => {
7182
+ var mapVenueEventToSearchResult = (event, labels, formatPercent, formatCompactCurrency, options) => {
7131
7183
  var _a, _b;
7132
7184
  const primaryVenueMarket = selectPrimaryVenueMarket(event.venueMarkets);
7133
7185
  if (!primaryVenueMarket) return null;
@@ -7137,7 +7189,14 @@ var mapVenueEventToSearchResult = (event, labels, formatPercent, formatCompactCu
7137
7189
  if (!visibleOutcome) return null;
7138
7190
  const probability = normalizeProbability(visibleOutcome.outcome.price);
7139
7191
  if (probability == null) return null;
7140
- const resolvedTitle = (_a = event == null ? void 0 : event.title) == null ? void 0 : _a.trim();
7192
+ const resolvedTitle = formatEventTitleWithDateSuffix({
7193
+ title: (_a = event == null ? void 0 : event.title) != null ? _a : "",
7194
+ categories: event.categories,
7195
+ structureType: event.structureType,
7196
+ gameStartTime: event.gameStartTime,
7197
+ endDate: event.endDate,
7198
+ locale: options == null ? void 0 : options.locale
7199
+ });
7141
7200
  if (!resolvedTitle) return null;
7142
7201
  const { marketCount, venueCount } = getVenueSummary(event.venueMarkets);
7143
7202
  const marketSummaryLabel = [
@@ -7350,6 +7409,7 @@ var Search = ({
7350
7409
  const {
7351
7410
  search: searchConfig,
7352
7411
  features: { enableAnimations },
7412
+ general: { locale },
7353
7413
  formatting: { formatCompactCurrency, formatPercent }
7354
7414
  } = (0, import_hooks27.useSdkUiConfig)();
7355
7415
  const resolvedValue = searchConfig.value;
@@ -7390,7 +7450,10 @@ var Search = ({
7390
7450
  event,
7391
7451
  labels,
7392
7452
  formatPercent,
7393
- formatCompactCurrency
7453
+ formatCompactCurrency,
7454
+ {
7455
+ locale
7456
+ }
7394
7457
  );
7395
7458
  if (!item) return null;
7396
7459
  nextEventsByResultId.set(item.id, event);
@@ -7400,7 +7463,7 @@ var Search = ({
7400
7463
  validatedResults: nextResults,
7401
7464
  eventsByResultId: nextEventsByResultId
7402
7465
  };
7403
- }, [openEvents, formatCompactCurrency, formatPercent, labels]);
7466
+ }, [formatCompactCurrency, formatPercent, labels, locale, openEvents]);
7404
7467
  const hasSearchValue = trimmedValue.length > 0;
7405
7468
  const shouldRenderDropdown = isFocused && shouldSearchValue && !searchConfig.result && !searchConfig.isShowingAllResults;
7406
7469
  const resolvedIsActive = isFocused;
@@ -8496,7 +8559,7 @@ var Select = ({
8496
8559
  disabled: item.disabled,
8497
8560
  className: cn(
8498
8561
  "agg-select-item",
8499
- "relative flex w-full items-center gap-3 rounded-[6px] px-5 py-3 text-left text-agg-sm leading-agg-5 outline-none",
8562
+ "relative flex w-full items-center gap-3 rounded-[6px] pl-3 pr-5 py-3 text-left text-agg-sm leading-agg-5 outline-none",
8500
8563
  "hover:bg-agg-secondary-hover focus-visible:bg-agg-secondary-hover",
8501
8564
  isSelected ? "bg-agg-primary/10 font-agg-normal text-agg-primary" : "font-agg-normal text-agg-foreground",
8502
8565
  item.disabled && "cursor-not-allowed opacity-60",
@@ -11111,7 +11174,14 @@ var EventListItemContent = ({
11111
11174
  const config = (0, import_hooks39.useSdkUiConfig)();
11112
11175
  const labels = (0, import_hooks39.useLabels)();
11113
11176
  const allVenueMarkets = (0, import_react18.useMemo)(() => event.venueMarkets, [event.venueMarkets]);
11114
- const resolvedTitle = event.title;
11177
+ const resolvedTitle = formatEventTitleWithDateSuffix({
11178
+ title: event.title,
11179
+ categories: event.categories,
11180
+ structureType: event.structureType,
11181
+ gameStartTime: event.gameStartTime,
11182
+ endDate: event.endDate,
11183
+ locale: config.general.locale
11184
+ });
11115
11185
  const resolvedImage = event.image;
11116
11186
  const visibleVenueLogos = (0, import_react18.useMemo)(() => {
11117
11187
  var _a2;
@@ -11724,10 +11794,10 @@ var import_hooks41 = require("@agg-build/hooks");
11724
11794
 
11725
11795
  // src/events/market-details/market-details.utils.ts
11726
11796
  var import_sdk13 = require("@agg-build/sdk");
11727
- var import_dayjs4 = __toESM(require("dayjs"));
11797
+ var import_dayjs5 = __toESM(require("dayjs"));
11728
11798
 
11729
11799
  // src/events/item-details/event-list-item-details.utils.ts
11730
- var import_dayjs3 = __toESM(require("dayjs"));
11800
+ var import_dayjs4 = __toESM(require("dayjs"));
11731
11801
  var compareOutcomeSelectorLabels = (leftLabel, rightLabel) => {
11732
11802
  const leftSemanticLabel = toSemanticLabel(leftLabel);
11733
11803
  const rightSemanticLabel = toSemanticLabel(rightLabel);
@@ -11740,8 +11810,8 @@ var compareOutcomeSelectorLabels = (leftLabel, rightLabel) => {
11740
11810
  if (leftBinaryOrder != null && rightBinaryOrder != null) {
11741
11811
  return leftBinaryOrder - rightBinaryOrder;
11742
11812
  }
11743
- const leftDate = isDateLikeLabel(leftLabel) ? (0, import_dayjs3.default)(leftLabel).valueOf() : null;
11744
- const rightDate = isDateLikeLabel(rightLabel) ? (0, import_dayjs3.default)(rightLabel).valueOf() : null;
11813
+ const leftDate = isDateLikeLabel(leftLabel) ? (0, import_dayjs4.default)(leftLabel).valueOf() : null;
11814
+ const rightDate = isDateLikeLabel(rightLabel) ? (0, import_dayjs4.default)(rightLabel).valueOf() : null;
11745
11815
  if (leftDate != null && rightDate != null && leftDate !== rightDate) {
11746
11816
  return leftDate - rightDate;
11747
11817
  }
@@ -11782,7 +11852,7 @@ var toSemanticLabel = (value) => {
11782
11852
  };
11783
11853
  var isDateLikeLabel = (value) => {
11784
11854
  if (!value.trim()) return false;
11785
- return (0, import_dayjs3.default)(value).isValid();
11855
+ return (0, import_dayjs4.default)(value).isValid();
11786
11856
  };
11787
11857
  var matchOutcomeByLabel = (outcome, selectedOutcomeLabel) => {
11788
11858
  const normalizedSelectedLabel = normalizeLabel(selectedOutcomeLabel);
@@ -12296,19 +12366,19 @@ var resolveOtherTabRows = (market, labels) => {
12296
12366
  if (market.creationDate) {
12297
12367
  rows.push({
12298
12368
  label: labels.marketDetails.meta.created,
12299
- value: (0, import_dayjs4.default)(market.creationDate).format("MMM D, YYYY")
12369
+ value: (0, import_dayjs5.default)(market.creationDate).format("MMM D, YYYY")
12300
12370
  });
12301
12371
  }
12302
12372
  if (market.startDate) {
12303
12373
  rows.push({
12304
12374
  label: labels.marketDetails.meta.opens,
12305
- value: (0, import_dayjs4.default)(market.startDate).format("MMM D, YYYY")
12375
+ value: (0, import_dayjs5.default)(market.startDate).format("MMM D, YYYY")
12306
12376
  });
12307
12377
  }
12308
12378
  if (market.endDate) {
12309
12379
  rows.push({
12310
12380
  label: labels.marketDetails.meta.closes,
12311
- value: (0, import_dayjs4.default)(market.endDate).format("MMM D, YYYY")
12381
+ value: (0, import_dayjs5.default)(market.endDate).format("MMM D, YYYY")
12312
12382
  });
12313
12383
  }
12314
12384
  if (rows.length === 1) {
@@ -13393,12 +13463,12 @@ var import_react22 = require("react");
13393
13463
 
13394
13464
  // src/trading/utils.ts
13395
13465
  var import_hooks45 = require("@agg-build/hooks");
13396
- var import_dayjs5 = __toESM(require("dayjs"));
13466
+ var import_dayjs6 = __toESM(require("dayjs"));
13397
13467
  var defaultLabels = (0, import_hooks45.resolveAggUiLabels)("en-US");
13398
13468
  var defaultSettlementSectionLabel = defaultLabels.trading.settlementSection;
13399
13469
  var defaultTradingDisclaimer = defaultLabels.trading.disclaimer;
13400
13470
  var getTradingDateLabel = (value) => {
13401
- const parsedValue = (0, import_dayjs5.default)(value);
13471
+ const parsedValue = (0, import_dayjs6.default)(value);
13402
13472
  if (!parsedValue.isValid()) {
13403
13473
  return typeof value === "string" ? value : "";
13404
13474
  }
@@ -14284,11 +14354,28 @@ var EventListItemDetailsContent = ({
14284
14354
  if (typeof resolvedVolume !== "number") return "";
14285
14355
  return `${config.formatting.formatCompactCurrency(resolvedVolume)} ${labels.eventItemDetails.volumeSuffix}`;
14286
14356
  }, [config, event.volume, labels.eventItemDetails.volumeSuffix, venueMarkets]);
14357
+ const resolvedTitle = (0, import_react24.useMemo)(() => {
14358
+ return formatEventTitleWithDateSuffix({
14359
+ title: event.title,
14360
+ categories: event.categories,
14361
+ structureType: event.structureType,
14362
+ gameStartTime: event.gameStartTime,
14363
+ endDate: event.endDate,
14364
+ locale: config.general.locale
14365
+ });
14366
+ }, [
14367
+ config.general.locale,
14368
+ event.categories,
14369
+ event.gameStartTime,
14370
+ event.endDate,
14371
+ event.structureType,
14372
+ event.title
14373
+ ]);
14287
14374
  return /* @__PURE__ */ (0, import_jsx_runtime142.jsxs)(
14288
14375
  Card,
14289
14376
  {
14290
14377
  className: cn("group/agg-event-details", detailsBaseCardClassName, classNames == null ? void 0 : classNames.root),
14291
- "aria-label": ariaLabel != null ? ariaLabel : event.title,
14378
+ "aria-label": ariaLabel != null ? ariaLabel : resolvedTitle,
14292
14379
  onClick: () => {
14293
14380
  onClick == null ? void 0 : onClick(event);
14294
14381
  },
@@ -14323,7 +14410,7 @@ var EventListItemDetailsContent = ({
14323
14410
  "truncate text-wrap wrap-break-word line-clamp-2",
14324
14411
  classNames == null ? void 0 : classNames.title
14325
14412
  ),
14326
- children: event.title
14413
+ children: resolvedTitle
14327
14414
  }
14328
14415
  ),
14329
14416
  venueMarkets.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
@@ -15021,37 +15108,71 @@ var Orderbook = ({
15021
15108
  };
15022
15109
  Orderbook.displayName = "Orderbook";
15023
15110
 
15024
- // src/events/shared/display-outcome-venue.ts
15111
+ // src/events/shared/select-best-outcome.ts
15025
15112
  var normalizeOutcomeLabel3 = (label2) => {
15026
15113
  return typeof label2 === "string" ? label2.trim().toLowerCase() : "";
15027
15114
  };
15028
- var getDisplayOutcomeVenue = ({
15029
- outcomeId,
15030
- outcomeLabel,
15031
- selection,
15032
- bestMidpointVenue,
15033
- bestVenueByOutcomeId,
15034
- bestPriceVenuesByOutcomeId,
15035
- fallbackVenue
15036
- }) => {
15037
- var _a;
15038
- if (selection && outcomeId) {
15039
- const sideVenues = bestPriceVenuesByOutcomeId == null ? void 0 : bestPriceVenuesByOutcomeId.get(outcomeId);
15040
- if (selection === "buy" && (sideVenues == null ? void 0 : sideVenues.bestAskVenue)) return sideVenues.bestAskVenue;
15041
- if (selection === "sell" && (sideVenues == null ? void 0 : sideVenues.bestBidVenue)) return sideVenues.bestBidVenue;
15115
+ var selectBestOutcomeCandidate = (args) => {
15116
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
15117
+ const { outcomeId, selection } = args;
15118
+ if (!outcomeId) return void 0;
15119
+ const resolveVenueMarketId = (venue) => {
15120
+ var _a2, _b2;
15121
+ return venue ? (_b2 = (_a2 = args.venueMarketIdByVenue) == null ? void 0 : _a2.get(venue)) != null ? _b2 : void 0 : void 0;
15122
+ };
15123
+ const make = (price, venue, source, updatedAt) => ({
15124
+ price,
15125
+ venue: venue != null ? venue : void 0,
15126
+ venueMarketId: resolveVenueMarketId(venue != null ? venue : void 0),
15127
+ outcomeId,
15128
+ source,
15129
+ updatedAt: updatedAt != null ? updatedAt : void 0
15130
+ });
15131
+ if (selection === "buy" || selection === "sell") {
15132
+ const wsSidePrice = selection === "buy" ? (_a = args.live) == null ? void 0 : _a.bestAsk : (_b = args.live) == null ? void 0 : _b.bestBid;
15133
+ const wsSideVenue = selection === "buy" ? (_c = args.live) == null ? void 0 : _c.bestAskVenue : (_d = args.live) == null ? void 0 : _d.bestBidVenue;
15134
+ if (wsSidePrice != null) {
15135
+ return make(wsSidePrice, wsSideVenue, "ws", (_e = args.live) == null ? void 0 : _e.updatedAt);
15136
+ }
15137
+ const restSidePrice = selection === "buy" ? (_f = args.restBest) == null ? void 0 : _f.bestAsk : (_g = args.restBest) == null ? void 0 : _g.bestBid;
15138
+ const restSideVenue = selection === "buy" ? (_h = args.restBestVenues) == null ? void 0 : _h.bestAskVenue : (_i = args.restBestVenues) == null ? void 0 : _i.bestBidVenue;
15139
+ if (restSidePrice != null) {
15140
+ return make(restSidePrice, restSideVenue, "rest-best", void 0);
15141
+ }
15042
15142
  }
15043
- if (normalizeOutcomeLabel3(outcomeLabel) === "yes" && bestMidpointVenue) {
15044
- return bestMidpointVenue;
15143
+ if (((_j = args.live) == null ? void 0 : _j.midpoint) != null) {
15144
+ return make(args.live.midpoint, args.live.midpointVenue, "ws", args.live.updatedAt);
15145
+ }
15146
+ if (normalizeOutcomeLabel3(args.outcomeLabel) === "yes" && args.bestMidpoint != null && args.bestMidpointVenue) {
15147
+ return make(args.bestMidpoint, args.bestMidpointVenue, "rest-midpoint", void 0);
15148
+ }
15149
+ if (args.restMidpoint != null) {
15150
+ return make(args.restMidpoint, args.restMidpointVenue, "rest-midpoint", void 0);
15151
+ }
15152
+ if (args.staticPrice != null) {
15153
+ return make(args.staticPrice, args.staticVenue, "static", void 0);
15154
+ }
15155
+ return void 0;
15156
+ };
15157
+ var buildVenueMarketIdByVenue = (venueMarkets) => {
15158
+ var _a;
15159
+ const map = /* @__PURE__ */ new Map();
15160
+ if (!(venueMarkets == null ? void 0 : venueMarkets.length)) return map;
15161
+ const visit = (vm) => {
15162
+ if (vm.venue && vm.id && !map.has(vm.venue)) map.set(vm.venue, vm.id);
15163
+ };
15164
+ for (const vm of venueMarkets) {
15165
+ visit(vm);
15166
+ for (const sibling of (_a = vm.matchedVenueMarkets) != null ? _a : []) visit(sibling);
15045
15167
  }
15046
- const bestVenue = outcomeId ? bestVenueByOutcomeId == null ? void 0 : bestVenueByOutcomeId.get(outcomeId) : void 0;
15047
- return (_a = bestVenue != null ? bestVenue : fallbackVenue) != null ? _a : void 0;
15168
+ return map;
15048
15169
  };
15049
15170
 
15050
15171
  // src/events/shared/event-trading-state.utils.ts
15051
- var import_dayjs6 = __toESM(require("dayjs"));
15172
+ var import_dayjs7 = __toESM(require("dayjs"));
15052
15173
  var formatTradingStateDate = (value) => {
15053
- if (!(0, import_dayjs6.default)(value).isValid()) return value;
15054
- return (0, import_dayjs6.default)(value).format("MMM D, YYYY");
15174
+ if (!(0, import_dayjs7.default)(value).isValid()) return value;
15175
+ return (0, import_dayjs7.default)(value).format("MMM D, YYYY");
15055
15176
  };
15056
15177
  var resolveTradingStateTimestampLabel = (labels, state) => {
15057
15178
  if (state.kind === "resolved" && state.resolvesAt) {
@@ -15306,7 +15427,7 @@ var MarketDetailsContent = ({
15306
15427
  suppressOutcomeFallbackSelection,
15307
15428
  midpointsResult
15308
15429
  }) => {
15309
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
15430
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
15310
15431
  const config = (0, import_hooks50.useSdkUiConfig)();
15311
15432
  const {
15312
15433
  features: { enableAnimations },
@@ -15320,6 +15441,7 @@ var MarketDetailsContent = ({
15320
15441
  const tradeSide = (_a = tradingContext == null ? void 0 : tradingContext.tradeSide) != null ? _a : "buy";
15321
15442
  const wsLivePrices = (0, import_hooks50.useLiveOutcomePrices)(venueMarkets);
15322
15443
  const wsBestPrices = (0, import_hooks50.useLiveBestPrices)(venueMarkets);
15444
+ const wsBestCandidates = (0, import_hooks50.useLiveBestPriceCandidates)(venueMarkets);
15323
15445
  const resolvedMarket = (0, import_react27.useMemo)(() => {
15324
15446
  return resolveMarketFromVenueMarkets(venueMarkets, marketId);
15325
15447
  }, [venueMarkets, marketId]);
@@ -15329,6 +15451,10 @@ var MarketDetailsContent = ({
15329
15451
  return (_b2 = (_a2 = resolvedMarket.venueMarkets.find((venueMarket) => venueMarket.id === resolvedMarket.id)) != null ? _a2 : resolvedMarket.venueMarkets[0]) != null ? _b2 : null;
15330
15452
  }, [resolvedMarket]);
15331
15453
  const isResolvedMarket = (0, import_hooks50.resolveMarketTradingState)(scopedResolvedMarket).kind === "resolved";
15454
+ (0, import_hooks50.useEventOrderbookData)(
15455
+ isResolvedMarket ? [] : resolvedMarket == null ? void 0 : resolvedMarket.venueMarkets,
15456
+ (_b = scopedResolvedMarket == null ? void 0 : scopedResolvedMarket.id) != null ? _b : null
15457
+ );
15332
15458
  const clusterMidpointResult = midpointsResult != null ? midpointsResult : {
15333
15459
  prices: /* @__PURE__ */ new Map(),
15334
15460
  bestMidpointsByOutcomeId: /* @__PURE__ */ new Map(),
@@ -15339,7 +15465,7 @@ var MarketDetailsContent = ({
15339
15465
  bestMidpoint: void 0,
15340
15466
  bestMidpointVenue: void 0
15341
15467
  };
15342
- const clusterMidpoints = (_b = clusterMidpointResult.bestMidpointsByOutcomeId) != null ? _b : clusterMidpointResult.prices;
15468
+ const clusterMidpoints = (_c = clusterMidpointResult.bestMidpointsByOutcomeId) != null ? _c : clusterMidpointResult.prices;
15343
15469
  const clusterBestMidpointsByOutcomeId = clusterMidpoints;
15344
15470
  const clusterVenueByOutcomeId = clusterMidpointResult.venueByOutcomeId;
15345
15471
  const clusterBestMidpoint = clusterMidpointResult.bestMidpoint;
@@ -15454,7 +15580,7 @@ var MarketDetailsContent = ({
15454
15580
  tradingContext == null ? void 0 : tradingContext.selectedOutcomeId
15455
15581
  ]);
15456
15582
  const selectedOutcomeId = scopedSelectedOutcomeState.outcomeId;
15457
- const selectedOutcomeLabel = (_c = scopedSelectedOutcomeState.outcomeLabel) != null ? _c : null;
15583
+ const selectedOutcomeLabel = (_d = scopedSelectedOutcomeState.outcomeLabel) != null ? _d : null;
15458
15584
  const selectOutcome = tradingContext == null ? void 0 : tradingContext.selectOutcome;
15459
15585
  const [selectedGraphVenue, setSelectedGraphVenue] = (0, import_react27.useState)(null);
15460
15586
  const [chartOutcomeLabel, setChartOutcomeLabel] = (0, import_react27.useState)(selectedOutcomeLabel);
@@ -15488,31 +15614,33 @@ var MarketDetailsContent = ({
15488
15614
  tradingContext == null ? void 0 : tradingContext.selectedMarketId,
15489
15615
  selectOutcome
15490
15616
  ]);
15617
+ const venueMarketIdByVenue = (0, import_react27.useMemo)(
15618
+ () => buildVenueMarketIdByVenue(model == null ? void 0 : model.market.venueMarkets),
15619
+ [model]
15620
+ );
15491
15621
  const headerOutcomeItems = (0, import_react27.useMemo)(() => {
15492
15622
  if (!model) return [];
15493
15623
  const items = resolveHeaderOutcomeItems(model.market.venueMarkets, scopedMarketForCard);
15494
15624
  return items.map((item) => {
15495
15625
  var _a2;
15496
15626
  const fallbackPrice = midpointsFallback == null ? void 0 : midpointsFallback.get(item.id);
15497
- const bestVenue = getDisplayOutcomeVenue({
15498
- outcomeId: item.id,
15499
- outcomeLabel: item.label,
15500
- selection: tradeSide,
15501
- bestMidpointVenue: clusterBestMidpointVenue,
15502
- bestVenueByOutcomeId: clusterVenueByOutcomeId,
15503
- bestPriceVenuesByOutcomeId: clusterBestPriceVenuesByOutcomeId,
15504
- fallbackVenue: midpointsFallbackVenues == null ? void 0 : midpointsFallbackVenues.get(item.id)
15505
- });
15506
- const outcomeBestPrice = getDisplayOutcomePrice({
15627
+ const candidate = selectBestOutcomeCandidate({
15507
15628
  outcomeId: item.id,
15508
15629
  outcomeLabel: item.label,
15509
15630
  selection: tradeSide,
15510
- bestPrices: clusterBestPrices,
15631
+ live: wsBestCandidates.get(item.id),
15632
+ restBest: clusterBestPricesRest.get(item.id),
15633
+ restBestVenues: clusterBestPriceVenuesByOutcomeId.get(item.id),
15634
+ restMidpoint: clusterBestMidpointsByOutcomeId.get(item.id),
15635
+ restMidpointVenue: clusterVenueByOutcomeId.get(item.id),
15511
15636
  bestMidpoint: clusterBestMidpoint,
15512
- bestMidpointsByOutcomeId: clusterBestMidpointsByOutcomeId,
15513
- livePrices: wsLivePrices,
15514
- fallbackPrice
15637
+ bestMidpointVenue: clusterBestMidpointVenue,
15638
+ staticPrice: fallbackPrice,
15639
+ staticVenue: midpointsFallbackVenues == null ? void 0 : midpointsFallbackVenues.get(item.id),
15640
+ venueMarketIdByVenue
15515
15641
  });
15642
+ const bestVenue = candidate == null ? void 0 : candidate.venue;
15643
+ const outcomeBestPrice = candidate == null ? void 0 : candidate.price;
15516
15644
  if (isResolvedMarket) {
15517
15645
  const isWinningOutcome = item.id === ((_a2 = marketTradingState.winningOutcome) == null ? void 0 : _a2.id);
15518
15646
  return __spreadValues(__spreadProps(__spreadValues({}, item), {
@@ -15530,17 +15658,18 @@ var MarketDetailsContent = ({
15530
15658
  clusterBestMidpoint,
15531
15659
  clusterBestMidpointVenue,
15532
15660
  clusterBestMidpointsByOutcomeId,
15533
- clusterBestPrices,
15661
+ clusterBestPricesRest,
15534
15662
  clusterBestPriceVenuesByOutcomeId,
15535
15663
  model,
15536
15664
  scopedMarketForCard,
15537
15665
  clusterVenueByOutcomeId,
15538
15666
  isResolvedMarket,
15539
- (_d = marketTradingState.winningOutcome) == null ? void 0 : _d.id,
15667
+ (_e = marketTradingState.winningOutcome) == null ? void 0 : _e.id,
15540
15668
  midpointsFallback,
15541
15669
  midpointsFallbackVenues,
15542
15670
  tradeSide,
15543
- wsLivePrices
15671
+ venueMarketIdByVenue,
15672
+ wsBestCandidates
15544
15673
  ]);
15545
15674
  const headlineProbability = (0, import_react27.useMemo)(() => {
15546
15675
  var _a2, _b2, _c2, _d2;
@@ -15606,9 +15735,9 @@ var MarketDetailsContent = ({
15606
15735
  const chartEnabled = isOpened && effectiveSelectedTab === "graph";
15607
15736
  const orderBookEnabled = isOpened && effectiveSelectedTab === "order-book" && !marketTradingState.isTradingDisabled;
15608
15737
  const rollingWindow = (0, import_hooks50.useRollingChartWindow)({ range: effectiveChartTimeRange });
15609
- const primaryVenueMarketId = (_f = (_e = selectedOutcomesByVenue[0]) == null ? void 0 : _e.market.id) != null ? _f : null;
15610
- const primaryOutcomeId = (_h = (_g = selectedOutcomesByVenue[0]) == null ? void 0 : _g.outcome.id) != null ? _h : null;
15611
- const chartPrimaryOutcomeId = (_j = (_i = chartOutcomesByVenue[0]) == null ? void 0 : _i.outcome.id) != null ? _j : null;
15738
+ const primaryVenueMarketId = (_g = (_f = selectedOutcomesByVenue[0]) == null ? void 0 : _f.market.id) != null ? _g : null;
15739
+ const primaryOutcomeId = (_i = (_h = selectedOutcomesByVenue[0]) == null ? void 0 : _h.outcome.id) != null ? _i : null;
15740
+ const chartPrimaryOutcomeId = (_k = (_j = chartOutcomesByVenue[0]) == null ? void 0 : _j.outcome.id) != null ? _k : null;
15612
15741
  const chartVenueOutcomeIds = (0, import_react27.useMemo)(() => {
15613
15742
  return chartOutcomesByVenue.map((item) => item.outcome.id);
15614
15743
  }, [chartOutcomesByVenue]);
@@ -16111,7 +16240,7 @@ var MarketDetailsContent = ({
16111
16240
  height: 260,
16112
16241
  isLoading: isMarketChartLoading,
16113
16242
  chartType: selectedChartType,
16114
- liveCandle: selectedChartType === "candlestick" ? (_k = graphLiveState.liveCandle) != null ? _k : void 0 : void 0,
16243
+ liveCandle: selectedChartType === "candlestick" ? (_l = graphLiveState.liveCandle) != null ? _l : void 0 : void 0,
16115
16244
  lineValue: graphLiveState.lineValue,
16116
16245
  classNames: { root: "agg-chart-region w-full" },
16117
16246
  showSeriesControls: chartAvailableOutcomesByVenue.length > 0 || headerOutcomeItems.length > 0,
@@ -17393,14 +17522,14 @@ var EventList = ({
17393
17522
  EventList.displayName = "EventList";
17394
17523
 
17395
17524
  // src/pages/home/index.tsx
17396
- var import_hooks58 = require("@agg-build/hooks");
17525
+ var import_hooks60 = require("@agg-build/hooks");
17397
17526
  var import_sdk18 = require("@agg-build/sdk");
17398
- var import_react38 = require("react");
17527
+ var import_react40 = require("react");
17399
17528
 
17400
17529
  // src/pages/event-market/index.tsx
17401
- var import_hooks57 = require("@agg-build/hooks");
17530
+ var import_hooks59 = require("@agg-build/hooks");
17402
17531
  var Dialog4 = __toESM(require("@radix-ui/react-dialog"));
17403
- var import_react35 = require("react");
17532
+ var import_react37 = require("react");
17404
17533
 
17405
17534
  // src/trading/types.ts
17406
17535
  var import_sdk16 = require("@agg-build/sdk");
@@ -19771,10 +19900,8 @@ var PlaceOrderResolvedView = ({
19771
19900
  resolvedClaim,
19772
19901
  className
19773
19902
  }) => {
19774
- var _a, _b, _c, _d, _e;
19775
19903
  const labels = (0, import_hooks56.useLabels)();
19776
19904
  const tradingLabels = labels.trading;
19777
- const extendedTradingLabels = tradingLabels;
19778
19905
  return /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
19779
19906
  Card,
19780
19907
  {
@@ -19813,18 +19940,18 @@ var PlaceOrderResolvedView = ({
19813
19940
  resolvedClaim ? /* @__PURE__ */ (0, import_jsx_runtime154.jsxs)(import_jsx_runtime154.Fragment, { children: [
19814
19941
  /* @__PURE__ */ (0, import_jsx_runtime154.jsx)("div", { className: "h-px w-full bg-agg-separator" }),
19815
19942
  /* @__PURE__ */ (0, import_jsx_runtime154.jsxs)("div", { className: "flex w-full flex-col gap-5 p-6", children: [
19816
- /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(Typography, { variant: "body-strong", className: "text-center", children: (_a = extendedTradingLabels.resolvedEarningsTitle) != null ? _a : "Your Earnings" }),
19943
+ /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(Typography, { variant: "body-strong", className: "text-center", children: tradingLabels.resolvedEarningsTitle }),
19817
19944
  /* @__PURE__ */ (0, import_jsx_runtime154.jsxs)("div", { className: "flex flex-col gap-3 text-agg-sm leading-agg-5 text-agg-foreground", children: [
19818
19945
  resolvedClaim.resolutionDateLabel ? /* @__PURE__ */ (0, import_jsx_runtime154.jsxs)("div", { className: "flex items-center justify-between gap-4", children: [
19819
- /* @__PURE__ */ (0, import_jsx_runtime154.jsx)("span", { children: (_b = extendedTradingLabels.resolvedResolutionDateLabel) != null ? _b : "Resolution date" }),
19946
+ /* @__PURE__ */ (0, import_jsx_runtime154.jsx)("span", { children: tradingLabels.resolvedResolutionDateLabel }),
19820
19947
  /* @__PURE__ */ (0, import_jsx_runtime154.jsx)("span", { className: "font-agg-bold", children: resolvedClaim.resolutionDateLabel })
19821
19948
  ] }) : null,
19822
19949
  /* @__PURE__ */ (0, import_jsx_runtime154.jsxs)("div", { className: "flex items-center justify-between gap-4", children: [
19823
- /* @__PURE__ */ (0, import_jsx_runtime154.jsx)("span", { children: (_c = extendedTradingLabels.resolvedSharesLabel) != null ? _c : "Shares" }),
19950
+ /* @__PURE__ */ (0, import_jsx_runtime154.jsx)("span", { children: tradingLabels.resolvedSharesLabel }),
19824
19951
  /* @__PURE__ */ (0, import_jsx_runtime154.jsx)("span", { className: "font-agg-bold", children: resolvedClaim.sharesLabel })
19825
19952
  ] }),
19826
19953
  /* @__PURE__ */ (0, import_jsx_runtime154.jsxs)("div", { className: "flex items-center justify-between gap-4", children: [
19827
- /* @__PURE__ */ (0, import_jsx_runtime154.jsx)("span", { children: (_d = extendedTradingLabels.resolvedTotalPayoutLabel) != null ? _d : "Total payout" }),
19954
+ /* @__PURE__ */ (0, import_jsx_runtime154.jsx)("span", { children: tradingLabels.resolvedTotalPayoutLabel }),
19828
19955
  /* @__PURE__ */ (0, import_jsx_runtime154.jsx)("span", { className: "font-agg-bold", children: resolvedClaim.totalPayoutLabel })
19829
19956
  ] })
19830
19957
  ] }),
@@ -19836,7 +19963,7 @@ var PlaceOrderResolvedView = ({
19836
19963
  onClick: resolvedClaim.onClaim,
19837
19964
  isLoading: resolvedClaim.isClaiming,
19838
19965
  disabled: resolvedClaim.isClaiming,
19839
- children: (_e = extendedTradingLabels.claimWinnings) != null ? _e : "Claim Winnings"
19966
+ children: tradingLabels.claimWinnings
19840
19967
  }
19841
19968
  ) : null
19842
19969
  ] })
@@ -20172,6 +20299,7 @@ var PlaceOrder = ({
20172
20299
  onClose,
20173
20300
  onOutcomeChange,
20174
20301
  onPrimaryAction,
20302
+ onBeforePrimaryAction,
20175
20303
  onTabChange,
20176
20304
  onSuccess,
20177
20305
  onError,
@@ -20310,6 +20438,7 @@ var PlaceOrder = ({
20310
20438
  const [isSplitDetailOpen, setIsSplitDetailOpen] = (0, import_react34.useState)(false);
20311
20439
  const [submissionFeedback, setSubmissionFeedback] = (0, import_react34.useState)(null);
20312
20440
  const [submissionProgressState, setSubmissionProgressState] = (0, import_react34.useState)(null);
20441
+ const [isBeforeActionPending, setIsBeforeActionPending] = (0, import_react34.useState)(false);
20313
20442
  const executionDebugStoreRef = (0, import_react34.useRef)(null);
20314
20443
  const executionDebugAttemptIdRef = (0, import_react34.useRef)(null);
20315
20444
  const submittedSelectionRef = (0, import_react34.useRef)(null);
@@ -20895,7 +21024,7 @@ var PlaceOrder = ({
20895
21024
  }
20896
21025
  ];
20897
21026
  }, [activeFeeBreakdown, tradingLabels]);
20898
- const isActionLoading = isPrimaryActionLoading || executeManaged.isPending;
21027
+ const isActionLoading = isPrimaryActionLoading || executeManaged.isPending || isBeforeActionPending;
20899
21028
  const selectedRouteGeoBlocked = (_D = selectedRouteCard == null ? void 0 : selectedRouteCard.isUnavailable) != null ? _D : false;
20900
21029
  const geoBlockedVenuesFromWarnings = (0, import_react34.useMemo)(
20901
21030
  () => {
@@ -21261,7 +21390,7 @@ var PlaceOrder = ({
21261
21390
  });
21262
21391
  };
21263
21392
  const handlePrimaryAction = () => __async(null, null, function* () {
21264
- var _a2;
21393
+ var _a2, _b2, _c2;
21265
21394
  if (!orderEligibility.canPlaceOrder) {
21266
21395
  setSubmissionFeedback({
21267
21396
  message: (_a2 = resolveOrderEligibilityMessage(labels, orderEligibility.reason)) != null ? _a2 : tradingLabels.orderFailed,
@@ -21271,6 +21400,26 @@ var PlaceOrder = ({
21271
21400
  }
21272
21401
  if (!selectedRouteCard) return;
21273
21402
  setSubmissionFeedback(null);
21403
+ if (onBeforePrimaryAction) {
21404
+ const beforeContext = isPaperMode ? { quoteId: (_b2 = selectedRouteCard.quoteData) == null ? void 0 : _b2.quoteId, mode: "paper" } : { quoteId: (_c2 = selectedRouteCard.quoteData) == null ? void 0 : _c2.quoteId };
21405
+ setIsBeforeActionPending(true);
21406
+ try {
21407
+ const proceed = yield onBeforePrimaryAction(beforeContext);
21408
+ if (proceed === false) return;
21409
+ } catch (error) {
21410
+ setSubmissionFeedback({
21411
+ message: normalizePlaceOrderErrorMessage({
21412
+ errorMessage: error instanceof Error ? error.message : String(error),
21413
+ fallbackMessage: tradingLabels.orderFailed,
21414
+ labels: tradingLabels
21415
+ }),
21416
+ tone: "error"
21417
+ });
21418
+ return;
21419
+ } finally {
21420
+ setIsBeforeActionPending(false);
21421
+ }
21422
+ }
21274
21423
  if (scopedSelectedMarket && scopedSelectedOutcomeId) {
21275
21424
  submittedSelectionRef.current = {
21276
21425
  marketId: scopedSelectedMarket.id,
@@ -21741,177 +21890,485 @@ var PlaceOrder = ({
21741
21890
  };
21742
21891
  PlaceOrder.displayName = "PlaceOrder";
21743
21892
 
21744
- // src/pages/event-market/event-market.utils.ts
21745
- var EVENT_MARKET_PAGE_STICKY_HEADER_OFFSET_PX = 48;
21746
- var EVENT_MARKET_PAGE_STICKY_SPACING_PX = 32;
21747
- var EVENT_MARKET_PAGE_STICKY_TOP_PX = EVENT_MARKET_PAGE_STICKY_HEADER_OFFSET_PX + EVENT_MARKET_PAGE_STICKY_SPACING_PX;
21748
- var EVENT_MARKET_PAGE_STICKY_TOP_CSS_VAR = "--agg-event-market-sidebar-top";
21749
- var EVENT_MARKET_PAGE_STICKY_SPACING_CSS_VAR = "--agg-event-market-sidebar-spacing";
21750
- var toCssLength = (value, fallback) => {
21751
- if (typeof value === "number") {
21752
- return `${value}px`;
21753
- }
21754
- return value != null ? value : `${fallback}px`;
21755
- };
21756
- var deriveSpacingFromTop = (top) => {
21757
- if (typeof top !== "number") {
21758
- return void 0;
21759
- }
21760
- return Math.max(top - EVENT_MARKET_PAGE_STICKY_HEADER_OFFSET_PX, 0);
21761
- };
21762
- var resolveEventMarketPageStickyState = ({
21763
- stickyOrderPanel
21764
- }) => {
21765
- var _a, _b;
21766
- const isEnabled = (_a = stickyOrderPanel == null ? void 0 : stickyOrderPanel.enabled) != null ? _a : Boolean(stickyOrderPanel);
21767
- if (!isEnabled) {
21768
- return {
21769
- contentClassName: cn(),
21770
- sidebarClassName: cn("pt-4 sm:pt-6 md:pt-8 pb-10"),
21771
- placeOrder: cn("mb-10"),
21772
- mainClassName: cn("pt-4 sm:pt-6 md:pt-8"),
21773
- style: {}
21774
- };
21775
- }
21776
- return {
21777
- contentClassName: cn("lg:items-stretch!"),
21778
- sidebarClassName: cn(
21779
- "pt-4 sm:pt-6 md:pt-8 pb-10",
21780
- "lg:self-start lg:sticky lg:top-[var(--agg-event-market-sidebar-top)] lg:max-h-[calc(100vh-var(--agg-event-market-sidebar-top))] lg:overflow-y-auto lg:overscroll-contain",
21781
- stickyOrderPanel == null ? void 0 : stickyOrderPanel.className
21782
- ),
21783
- placeOrder: cn("mb-10"),
21784
- mainClassName: cn("pt-4 sm:pt-6 md:pt-8"),
21785
- style: {
21786
- [EVENT_MARKET_PAGE_STICKY_TOP_CSS_VAR]: toCssLength(
21787
- stickyOrderPanel == null ? void 0 : stickyOrderPanel.top,
21788
- EVENT_MARKET_PAGE_STICKY_TOP_PX
21789
- ),
21790
- [EVENT_MARKET_PAGE_STICKY_SPACING_CSS_VAR]: toCssLength(
21791
- (_b = stickyOrderPanel == null ? void 0 : stickyOrderPanel.spacing) != null ? _b : deriveSpacingFromTop(stickyOrderPanel == null ? void 0 : stickyOrderPanel.top),
21792
- EVENT_MARKET_PAGE_STICKY_SPACING_PX
21793
- )
21794
- }
21795
- };
21796
- };
21797
-
21798
- // src/pages/event-market/index.tsx
21799
- var import_jsx_runtime155 = require("react/jsx-runtime");
21800
- var MOBILE_EVENT_MARKET_MEDIA_QUERY = "(max-width: 1023px)";
21801
- var getIsMobileEventMarketViewport = () => {
21802
- if (typeof window === "undefined") return false;
21803
- if (typeof window.matchMedia !== "function") return false;
21804
- return window.matchMedia(MOBILE_EVENT_MARKET_MEDIA_QUERY).matches;
21805
- };
21806
- var useIsMobileEventMarketViewport = () => {
21807
- const [isMobileViewport, setIsMobileViewport] = (0, import_react35.useState)(getIsMobileEventMarketViewport);
21808
- (0, import_react35.useEffect)(() => {
21809
- if (typeof window === "undefined") return;
21810
- if (typeof window.matchMedia !== "function") return;
21811
- const mediaQueryList = window.matchMedia(MOBILE_EVENT_MARKET_MEDIA_QUERY);
21812
- const handleChange = () => {
21813
- setIsMobileViewport(mediaQueryList.matches);
21814
- };
21815
- handleChange();
21816
- mediaQueryList.addEventListener("change", handleChange);
21817
- return () => {
21818
- mediaQueryList.removeEventListener("change", handleChange);
21819
- };
21820
- }, []);
21821
- return isMobileViewport;
21822
- };
21823
- var resolveDesktopTradePlaceOrderClassNames = (classNames) => {
21824
- const resolvedClassNames = {
21825
- body: classNames == null ? void 0 : classNames.tradeBody,
21826
- content: classNames == null ? void 0 : classNames.tradeContent,
21827
- footer: classNames == null ? void 0 : classNames.tradeFooter,
21828
- header: classNames == null ? void 0 : classNames.tradeHeader
21829
- };
21830
- if (!Object.values(resolvedClassNames).some(Boolean)) {
21831
- return void 0;
21832
- }
21833
- return resolvedClassNames;
21834
- };
21835
- var resolveMobileTradePlaceOrderClassNames = (classNames) => {
21836
- return {
21837
- root: "rounded-t-agg-2xl rounded-b-none md:rounded-agg-2xl md:rounded-b-agg-2xl",
21838
- body: cn("flex h-full min-h-0 flex-col", classNames == null ? void 0 : classNames.tradeBody, classNames == null ? void 0 : classNames.mobileTradeBody),
21839
- content: cn(
21840
- "min-h-0 flex-1 overflow-y-auto overflow-x-hidden overscroll-contain [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
21841
- classNames == null ? void 0 : classNames.tradeContent,
21842
- classNames == null ? void 0 : classNames.mobileTradeContent
21843
- ),
21844
- footer: cn(classNames == null ? void 0 : classNames.tradeFooter, classNames == null ? void 0 : classNames.mobileTradeFooter),
21845
- header: cn(
21846
- "sticky top-0 z-10 bg-agg-secondary",
21847
- classNames == null ? void 0 : classNames.tradeHeader,
21848
- classNames == null ? void 0 : classNames.mobileTradeHeader
21849
- )
21850
- };
21893
+ // src/trading/use-claim-winnings.ts
21894
+ var import_hooks57 = require("@agg-build/hooks");
21895
+ var import_react35 = require("react");
21896
+ var toClaimError = (err) => {
21897
+ if (err instanceof Error) return err;
21898
+ return new Error(String(err));
21851
21899
  };
21852
- var EventMarketPageMobileTrade = ({
21853
- classNames,
21854
- eventTradingState,
21855
- executionMode,
21856
- showPlaceOrder = true,
21857
- isOpen,
21858
- onOpenChange,
21859
- midpointsResult
21860
- }) => {
21900
+ function useClaimWinnings(options = {}) {
21901
+ const { onClaim, onClaimResult, onClaimSubmitError, externalClaimingKeys } = options;
21861
21902
  const labels = (0, import_hooks57.useLabels)();
21862
- if (!showPlaceOrder) return null;
21863
- const handleOpenChange = (nextOpen) => {
21864
- onOpenChange(nextOpen);
21865
- };
21866
- const handleClose = () => {
21867
- onOpenChange(false);
21868
- };
21869
- return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(import_jsx_runtime155.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(Modal, { open: isOpen, onOpenChange: handleOpenChange, children: /* @__PURE__ */ (0, import_jsx_runtime155.jsxs)(
21870
- Modal.Container,
21871
- {
21872
- classNames: {
21873
- content: "items-end p-0 sm:items-center sm:p-4",
21874
- container: cn(
21875
- "agg-mobile-trade-modal",
21876
- "w-full border-0 bg-transparent shadow-none",
21877
- classNames == null ? void 0 : classNames.mobileTradeModal
21878
- )
21879
- },
21880
- children: [
21881
- /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(Dialog4.Title, { className: "sr-only", children: labels.trading.confirmOrder }),
21882
- /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(Dialog4.Description, { className: "sr-only", children: labels.trading.disclaimer }),
21883
- /* @__PURE__ */ (0, import_jsx_runtime155.jsx)("div", { className: "agg-mobile-trade-handle relative flex w-full flex-col items-center sm:hidden", children: /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
21884
- "button",
21885
- {
21886
- type: "button",
21887
- className: "absolute right-3 top-4 z-100 flex cursor-pointer items-center justify-center rounded-full p-1 text-agg-muted-foreground hover:text-agg-foreground",
21888
- "aria-label": labels.common.close,
21889
- onClick: handleClose,
21890
- children: /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(CloseIcon, { className: "h-5 w-5" })
21891
- }
21892
- ) }),
21893
- /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
21894
- PlaceOrder,
21895
- {
21896
- eventTradingState,
21897
- executionMode,
21898
- midpointsResult,
21899
- className: cn(
21900
- "agg-mobile-trade-panel w-full overflow-hidden rounded-t-agg-2xl sm:rounded-agg-xl",
21901
- classNames == null ? void 0 : classNames.mobileTrade
21902
- ),
21903
- classNames: resolveMobileTradePlaceOrderClassNames(classNames),
21904
- onClose: handleClose
21905
- }
21906
- )
21907
- ]
21903
+ const claimNotificationLabels = labels.notifications.claim;
21904
+ const toastCtx = useOptionalToast();
21905
+ const queryClient = (0, import_hooks57.useQueryClient)();
21906
+ const redeemMutation = (0, import_hooks57.useRedeem)();
21907
+ const [activeRedeems, setActiveRedeems] = (0, import_react35.useState)({});
21908
+ const activeClaimKeysRef = (0, import_react35.useRef)(/* @__PURE__ */ new Set());
21909
+ const pendingClaimToastIdsRef = (0, import_react35.useRef)({});
21910
+ const submittedClaimToastKeysRef = (0, import_react35.useRef)(/* @__PURE__ */ new Set());
21911
+ const [submittingClaimKeys, setSubmittingClaimKeys] = (0, import_react35.useState)({});
21912
+ const lifecycleInputs = (0, import_react35.useMemo)(
21913
+ () => Object.values(activeRedeems),
21914
+ [activeRedeems]
21915
+ );
21916
+ const lifecycleStates = (0, import_hooks57.useRedeemLifecycles)(lifecycleInputs);
21917
+ const internalClaimingIds = (0, import_react35.useMemo)(() => {
21918
+ const out = __spreadValues({}, submittingClaimKeys);
21919
+ for (const [claimKey, active] of Object.entries(activeRedeems)) {
21920
+ const state = lifecycleStates[active.redeemId];
21921
+ if (!state || !state.terminal) out[claimKey] = true;
21908
21922
  }
21909
- ) }) });
21923
+ return out;
21924
+ }, [activeRedeems, lifecycleStates, submittingClaimKeys]);
21925
+ const claimingKeys = externalClaimingKeys != null ? externalClaimingKeys : internalClaimingIds;
21926
+ const isClaiming = (0, import_react35.useCallback)(
21927
+ (claimKey) => Boolean(externalClaimingKeys == null ? void 0 : externalClaimingKeys[claimKey]) || Boolean(internalClaimingIds[claimKey]),
21928
+ [externalClaimingKeys, internalClaimingIds]
21929
+ );
21930
+ const invalidateClaimUiState = (0, import_react35.useCallback)(() => {
21931
+ (0, import_hooks57.invalidateBalanceQueries)(queryClient);
21932
+ (0, import_hooks57.invalidatePositionQueries)(queryClient);
21933
+ queryClient.invalidateQueries({
21934
+ queryKey: import_hooks57.executionKeys.claimablePositionsCount(),
21935
+ refetchType: "active"
21936
+ });
21937
+ (0, import_hooks57.invalidateUserActivityQueries)(queryClient);
21938
+ }, [queryClient]);
21939
+ const claim = (0, import_react35.useCallback)(
21940
+ (_0) => __async(null, [_0], function* ({ claimKey, winningOutcomeIds, payload }) {
21941
+ if (activeClaimKeysRef.current.has(claimKey) || Boolean(externalClaimingKeys == null ? void 0 : externalClaimingKeys[claimKey]) || internalClaimingIds[claimKey]) {
21942
+ return;
21943
+ }
21944
+ activeClaimKeysRef.current.add(claimKey);
21945
+ setSubmittingClaimKeys((prev) => __spreadProps(__spreadValues({}, prev), { [claimKey]: true }));
21946
+ const pendingToastId = toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.pendingMessage, {
21947
+ title: claimNotificationLabels.pendingTitle,
21948
+ tone: "info"
21949
+ });
21950
+ if (pendingToastId != null) {
21951
+ pendingClaimToastIdsRef.current[claimKey] = pendingToastId;
21952
+ }
21953
+ if (onClaim) {
21954
+ try {
21955
+ yield onClaim(payload);
21956
+ const pendingId = pendingClaimToastIdsRef.current[claimKey];
21957
+ if (pendingId != null) toastCtx == null ? void 0 : toastCtx.dismiss(pendingId);
21958
+ delete pendingClaimToastIdsRef.current[claimKey];
21959
+ toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.successMessage, {
21960
+ title: claimNotificationLabels.successTitle,
21961
+ tone: "success"
21962
+ });
21963
+ } catch (err) {
21964
+ const error = toClaimError(err);
21965
+ console.error("[useClaimWinnings] redeem failed", error);
21966
+ const pendingId = pendingClaimToastIdsRef.current[claimKey];
21967
+ if (pendingId != null) toastCtx == null ? void 0 : toastCtx.dismiss(pendingId);
21968
+ delete pendingClaimToastIdsRef.current[claimKey];
21969
+ toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.failedMessage(error.message), {
21970
+ title: claimNotificationLabels.failedTitle,
21971
+ tone: "error"
21972
+ });
21973
+ onClaimSubmitError == null ? void 0 : onClaimSubmitError(claimKey, error);
21974
+ throw error;
21975
+ } finally {
21976
+ invalidateClaimUiState();
21977
+ activeClaimKeysRef.current.delete(claimKey);
21978
+ setSubmittingClaimKeys((prev) => {
21979
+ const _a = prev, { [claimKey]: _removed } = _a, rest = __objRest(_a, [__restKey(claimKey)]);
21980
+ return rest;
21981
+ });
21982
+ }
21983
+ return;
21984
+ }
21985
+ if (winningOutcomeIds.length === 0) {
21986
+ const error = new Error(claimNotificationLabels.missingOutcomeMessage);
21987
+ console.error("[useClaimWinnings] redeem failed", error);
21988
+ const pendingId = pendingClaimToastIdsRef.current[claimKey];
21989
+ if (pendingId != null) toastCtx == null ? void 0 : toastCtx.dismiss(pendingId);
21990
+ delete pendingClaimToastIdsRef.current[claimKey];
21991
+ toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.failedMessage(error.message), {
21992
+ title: claimNotificationLabels.failedTitle,
21993
+ tone: "error"
21994
+ });
21995
+ onClaimSubmitError == null ? void 0 : onClaimSubmitError(claimKey, error);
21996
+ invalidateClaimUiState();
21997
+ activeClaimKeysRef.current.delete(claimKey);
21998
+ setSubmittingClaimKeys((prev) => {
21999
+ const _a = prev, { [claimKey]: _removed } = _a, rest = __objRest(_a, [__restKey(claimKey)]);
22000
+ return rest;
22001
+ });
22002
+ throw error;
22003
+ }
22004
+ try {
22005
+ const response = yield redeemMutation.mutateAsync({
22006
+ venueMarketOutcomeIds: winningOutcomeIds
22007
+ });
22008
+ const expectedOutcomeIds = [];
22009
+ const preFailedOutcomeIds = [];
22010
+ const preFailedReasons = {};
22011
+ const preConfirmedOutcomeIds = [];
22012
+ const preConfirmedTxHashes = {};
22013
+ for (const result of response.results) {
22014
+ if (result.status === "submitted") {
22015
+ expectedOutcomeIds.push(result.venueMarketOutcomeId);
22016
+ } else if (result.status === "confirmed") {
22017
+ preConfirmedOutcomeIds.push(result.venueMarketOutcomeId);
22018
+ preConfirmedTxHashes[result.venueMarketOutcomeId] = result.txHash;
22019
+ } else if (result.status === "ineligible" || result.status === "rejected") {
22020
+ preFailedOutcomeIds.push(result.venueMarketOutcomeId);
22021
+ preFailedReasons[result.venueMarketOutcomeId] = result.reason;
22022
+ }
22023
+ }
22024
+ if (expectedOutcomeIds.length > 0) {
22025
+ const pendingId = pendingClaimToastIdsRef.current[claimKey];
22026
+ if (pendingId != null) toastCtx == null ? void 0 : toastCtx.dismiss(pendingId);
22027
+ delete pendingClaimToastIdsRef.current[claimKey];
22028
+ submittedClaimToastKeysRef.current.add(claimKey);
22029
+ toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.submittedMessage, {
22030
+ title: claimNotificationLabels.submittedTitle,
22031
+ tone: "success"
22032
+ });
22033
+ }
22034
+ setActiveRedeems((prev) => __spreadProps(__spreadValues({}, prev), {
22035
+ [claimKey]: {
22036
+ redeemId: response.redeemId,
22037
+ expectedOutcomeIds,
22038
+ preFailedOutcomeIds,
22039
+ preFailedReasons,
22040
+ preConfirmedOutcomeIds,
22041
+ preConfirmedTxHashes
22042
+ }
22043
+ }));
22044
+ yield queryClient.invalidateQueries({ queryKey: ["current-user"] });
22045
+ } catch (err) {
22046
+ const error = toClaimError(err);
22047
+ console.error("[useClaimWinnings] redeem failed", error);
22048
+ const pendingId = pendingClaimToastIdsRef.current[claimKey];
22049
+ if (pendingId != null) toastCtx == null ? void 0 : toastCtx.dismiss(pendingId);
22050
+ delete pendingClaimToastIdsRef.current[claimKey];
22051
+ toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.failedMessage(error.message), {
22052
+ title: claimNotificationLabels.failedTitle,
22053
+ tone: "error"
22054
+ });
22055
+ onClaimSubmitError == null ? void 0 : onClaimSubmitError(claimKey, error);
22056
+ throw error;
22057
+ } finally {
22058
+ activeClaimKeysRef.current.delete(claimKey);
22059
+ setSubmittingClaimKeys((prev) => {
22060
+ const _a = prev, { [claimKey]: _removed } = _a, rest = __objRest(_a, [__restKey(claimKey)]);
22061
+ return rest;
22062
+ });
22063
+ }
22064
+ }),
22065
+ [
22066
+ claimNotificationLabels,
22067
+ externalClaimingKeys,
22068
+ internalClaimingIds,
22069
+ invalidateClaimUiState,
22070
+ onClaim,
22071
+ onClaimSubmitError,
22072
+ queryClient,
22073
+ redeemMutation,
22074
+ toastCtx
22075
+ ]
22076
+ );
22077
+ const firedTerminalRef = (0, import_react35.useRef)({});
22078
+ (0, import_react35.useEffect)(() => {
22079
+ var _a, _b;
22080
+ for (const [claimKey, active] of Object.entries(activeRedeems)) {
22081
+ const state = lifecycleStates[active.redeemId];
22082
+ if (!state || !state.terminal) continue;
22083
+ if (firedTerminalRef.current[active.redeemId]) continue;
22084
+ firedTerminalRef.current[active.redeemId] = true;
22085
+ onClaimResult == null ? void 0 : onClaimResult(claimKey, {
22086
+ allConfirmed: state.allConfirmed,
22087
+ anyFailed: state.anyFailed,
22088
+ errorMessage: state.errorMessage
22089
+ });
22090
+ const pendingId = pendingClaimToastIdsRef.current[claimKey];
22091
+ if (pendingId != null) toastCtx == null ? void 0 : toastCtx.dismiss(pendingId);
22092
+ delete pendingClaimToastIdsRef.current[claimKey];
22093
+ if (state.allConfirmed) {
22094
+ if (!submittedClaimToastKeysRef.current.has(claimKey)) {
22095
+ toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.successMessage, {
22096
+ title: claimNotificationLabels.successTitle,
22097
+ tone: "success"
22098
+ });
22099
+ }
22100
+ } else if (state.anyFailed) {
22101
+ const hasConfirmedLeg = Object.values(state.legs).some((leg) => leg.status === "confirmed");
22102
+ if (hasConfirmedLeg) {
22103
+ toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.partialMessage((_a = state.errorMessage) != null ? _a : void 0), {
22104
+ title: claimNotificationLabels.partialTitle,
22105
+ tone: "warning"
22106
+ });
22107
+ } else {
22108
+ toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.failedMessage((_b = state.errorMessage) != null ? _b : void 0), {
22109
+ title: claimNotificationLabels.failedTitle,
22110
+ tone: "error"
22111
+ });
22112
+ }
22113
+ }
22114
+ submittedClaimToastKeysRef.current.delete(claimKey);
22115
+ invalidateClaimUiState();
22116
+ delete firedTerminalRef.current[active.redeemId];
22117
+ setActiveRedeems((prev) => {
22118
+ const _a2 = prev, { [claimKey]: _removed } = _a2, rest = __objRest(_a2, [__restKey(claimKey)]);
22119
+ return rest;
22120
+ });
22121
+ }
22122
+ }, [
22123
+ activeRedeems,
22124
+ claimNotificationLabels,
22125
+ invalidateClaimUiState,
22126
+ lifecycleStates,
22127
+ onClaimResult,
22128
+ toastCtx
22129
+ ]);
22130
+ return { claim, claimingKeys, isClaiming };
22131
+ }
22132
+
22133
+ // src/trading/use-resolved-market-claim.ts
22134
+ var import_hooks58 = require("@agg-build/hooks");
22135
+ var import_react36 = require("react");
22136
+ var sharesFormatter = new Intl.NumberFormat("en-US", { maximumFractionDigits: 2 });
22137
+ var dateFormatter = new Intl.DateTimeFormat("en-US", {
22138
+ month: "short",
22139
+ day: "numeric",
22140
+ year: "numeric"
22141
+ });
22142
+ var formatResolutionDate = (value) => {
22143
+ if (!value) return "";
22144
+ const date = new Date(value);
22145
+ if (Number.isNaN(date.getTime())) return "";
22146
+ return dateFormatter.format(date);
22147
+ };
22148
+ function useResolvedMarketClaim(options = {}) {
22149
+ var _a;
22150
+ const { market, enabled = true, executionMode } = options;
22151
+ const { isAuthenticated } = (0, import_hooks58.useAggAuthState)();
22152
+ const tradingState = (0, import_react36.useMemo)(() => (0, import_hooks58.resolveMarketTradingState)(market), [market]);
22153
+ const isResolved = tradingState.kind === "resolved";
22154
+ const marketId = (_a = market == null ? void 0 : market.id) != null ? _a : null;
22155
+ const shouldFetch = Boolean(enabled && isAuthenticated && isResolved && marketId);
22156
+ const { positions } = (0, import_hooks58.useExecutionPositions)(__spreadValues({
22157
+ enabled: shouldFetch,
22158
+ status: "active",
22159
+ limit: 50
22160
+ }, executionMode === "paper" ? { mode: "paper" } : {}));
22161
+ const claimWinnings = useClaimWinnings();
22162
+ return (0, import_react36.useMemo)(() => {
22163
+ var _a2, _b, _c;
22164
+ if (!shouldFetch || !marketId) return void 0;
22165
+ const group = positions.find(
22166
+ (candidate) => candidate.targetMarketId === marketId
22167
+ );
22168
+ if (!group || group.venueMarket.status !== "resolved") return void 0;
22169
+ const winningOutcomes = group.venueMarket.venueMarketOutcomes.filter(
22170
+ (outcome) => outcome.winner === true && outcome.totalSize > 0
22171
+ );
22172
+ if (winningOutcomes.length === 0) return void 0;
22173
+ const totals = (0, import_hooks58.computeClosedPositionTotals)(group);
22174
+ const winningShares = winningOutcomes.reduce((sum, outcome) => sum + outcome.totalSize, 0);
22175
+ const winningOutcomeLabel = ((_b = (_a2 = winningOutcomes[0]) == null ? void 0 : _a2.title) == null ? void 0 : _b.trim()) || ((_c = winningOutcomes[0]) == null ? void 0 : _c.label) || "";
22176
+ const claimKey = group.targetMarketId;
22177
+ const canClaim = group.redeemStatus === "eligible" && totals.winningOutcomeIds.length > 0;
22178
+ return {
22179
+ resolutionDateLabel: formatResolutionDate(group.resolutionDate),
22180
+ winningOutcomeLabel,
22181
+ sharesLabel: `${sharesFormatter.format(winningShares)} ${winningOutcomeLabel}`.trim(),
22182
+ // Payout is always shown with 2 decimals (e.g. "$8.50"), matching the
22183
+ // resolved-earnings design and the profile positions list.
22184
+ totalPayoutLabel: formatUsd(totals.amountWon, {
22185
+ minimumFractionDigits: 2,
22186
+ maximumFractionDigits: 2
22187
+ }),
22188
+ isClaiming: claimWinnings.isClaiming(claimKey),
22189
+ onClaim: canClaim ? () => {
22190
+ void claimWinnings.claim({
22191
+ claimKey,
22192
+ winningOutcomeIds: totals.winningOutcomeIds
22193
+ });
22194
+ } : void 0
22195
+ };
22196
+ }, [claimWinnings, marketId, positions, shouldFetch]);
22197
+ }
22198
+
22199
+ // src/pages/event-market/event-market.utils.ts
22200
+ var EVENT_MARKET_PAGE_STICKY_HEADER_OFFSET_PX = 48;
22201
+ var EVENT_MARKET_PAGE_STICKY_SPACING_PX = 32;
22202
+ var EVENT_MARKET_PAGE_STICKY_TOP_PX = EVENT_MARKET_PAGE_STICKY_HEADER_OFFSET_PX + EVENT_MARKET_PAGE_STICKY_SPACING_PX;
22203
+ var EVENT_MARKET_PAGE_STICKY_TOP_CSS_VAR = "--agg-event-market-sidebar-top";
22204
+ var EVENT_MARKET_PAGE_STICKY_SPACING_CSS_VAR = "--agg-event-market-sidebar-spacing";
22205
+ var toCssLength = (value, fallback) => {
22206
+ if (typeof value === "number") {
22207
+ return `${value}px`;
22208
+ }
22209
+ return value != null ? value : `${fallback}px`;
22210
+ };
22211
+ var deriveSpacingFromTop = (top) => {
22212
+ if (typeof top !== "number") {
22213
+ return void 0;
22214
+ }
22215
+ return Math.max(top - EVENT_MARKET_PAGE_STICKY_HEADER_OFFSET_PX, 0);
22216
+ };
22217
+ var resolveEventMarketPageStickyState = ({
22218
+ stickyOrderPanel
22219
+ }) => {
22220
+ var _a, _b;
22221
+ const isEnabled = (_a = stickyOrderPanel == null ? void 0 : stickyOrderPanel.enabled) != null ? _a : Boolean(stickyOrderPanel);
22222
+ if (!isEnabled) {
22223
+ return {
22224
+ contentClassName: cn(),
22225
+ sidebarClassName: cn("pt-4 sm:pt-6 md:pt-8 pb-10"),
22226
+ placeOrder: cn("mb-10"),
22227
+ mainClassName: cn("pt-4 sm:pt-6 md:pt-8"),
22228
+ style: {}
22229
+ };
22230
+ }
22231
+ return {
22232
+ contentClassName: cn("lg:items-stretch!"),
22233
+ sidebarClassName: cn(
22234
+ "pt-4 sm:pt-6 md:pt-8 pb-10",
22235
+ "lg:self-start lg:sticky lg:top-[var(--agg-event-market-sidebar-top)] lg:max-h-[calc(100vh-var(--agg-event-market-sidebar-top))] lg:overflow-y-auto lg:overscroll-contain",
22236
+ stickyOrderPanel == null ? void 0 : stickyOrderPanel.className
22237
+ ),
22238
+ placeOrder: cn("mb-10"),
22239
+ mainClassName: cn("pt-4 sm:pt-6 md:pt-8"),
22240
+ style: {
22241
+ [EVENT_MARKET_PAGE_STICKY_TOP_CSS_VAR]: toCssLength(
22242
+ stickyOrderPanel == null ? void 0 : stickyOrderPanel.top,
22243
+ EVENT_MARKET_PAGE_STICKY_TOP_PX
22244
+ ),
22245
+ [EVENT_MARKET_PAGE_STICKY_SPACING_CSS_VAR]: toCssLength(
22246
+ (_b = stickyOrderPanel == null ? void 0 : stickyOrderPanel.spacing) != null ? _b : deriveSpacingFromTop(stickyOrderPanel == null ? void 0 : stickyOrderPanel.top),
22247
+ EVENT_MARKET_PAGE_STICKY_SPACING_PX
22248
+ )
22249
+ }
22250
+ };
22251
+ };
22252
+
22253
+ // src/pages/event-market/index.tsx
22254
+ var import_jsx_runtime155 = require("react/jsx-runtime");
22255
+ var MOBILE_EVENT_MARKET_MEDIA_QUERY = "(max-width: 1023px)";
22256
+ var getIsMobileEventMarketViewport = () => {
22257
+ if (typeof window === "undefined") return false;
22258
+ if (typeof window.matchMedia !== "function") return false;
22259
+ return window.matchMedia(MOBILE_EVENT_MARKET_MEDIA_QUERY).matches;
22260
+ };
22261
+ var useIsMobileEventMarketViewport = () => {
22262
+ const [isMobileViewport, setIsMobileViewport] = (0, import_react37.useState)(getIsMobileEventMarketViewport);
22263
+ (0, import_react37.useEffect)(() => {
22264
+ if (typeof window === "undefined") return;
22265
+ if (typeof window.matchMedia !== "function") return;
22266
+ const mediaQueryList = window.matchMedia(MOBILE_EVENT_MARKET_MEDIA_QUERY);
22267
+ const handleChange = () => {
22268
+ setIsMobileViewport(mediaQueryList.matches);
22269
+ };
22270
+ handleChange();
22271
+ mediaQueryList.addEventListener("change", handleChange);
22272
+ return () => {
22273
+ mediaQueryList.removeEventListener("change", handleChange);
22274
+ };
22275
+ }, []);
22276
+ return isMobileViewport;
22277
+ };
22278
+ var resolveDesktopTradePlaceOrderClassNames = (classNames) => {
22279
+ const resolvedClassNames = {
22280
+ body: classNames == null ? void 0 : classNames.tradeBody,
22281
+ content: classNames == null ? void 0 : classNames.tradeContent,
22282
+ footer: classNames == null ? void 0 : classNames.tradeFooter,
22283
+ header: classNames == null ? void 0 : classNames.tradeHeader
22284
+ };
22285
+ if (!Object.values(resolvedClassNames).some(Boolean)) {
22286
+ return void 0;
22287
+ }
22288
+ return resolvedClassNames;
22289
+ };
22290
+ var resolveMobileTradePlaceOrderClassNames = (classNames) => {
22291
+ return {
22292
+ root: "rounded-t-agg-2xl rounded-b-none md:rounded-agg-2xl md:rounded-b-agg-2xl",
22293
+ body: cn("flex h-full min-h-0 flex-col", classNames == null ? void 0 : classNames.tradeBody, classNames == null ? void 0 : classNames.mobileTradeBody),
22294
+ content: cn(
22295
+ "min-h-0 flex-1 overflow-y-auto overflow-x-hidden overscroll-contain [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
22296
+ classNames == null ? void 0 : classNames.tradeContent,
22297
+ classNames == null ? void 0 : classNames.mobileTradeContent
22298
+ ),
22299
+ footer: cn(classNames == null ? void 0 : classNames.tradeFooter, classNames == null ? void 0 : classNames.mobileTradeFooter),
22300
+ header: cn(
22301
+ "sticky top-0 z-10 bg-agg-secondary",
22302
+ classNames == null ? void 0 : classNames.tradeHeader,
22303
+ classNames == null ? void 0 : classNames.mobileTradeHeader
22304
+ )
22305
+ };
22306
+ };
22307
+ var EventMarketPageMobileTrade = ({
22308
+ classNames,
22309
+ eventTradingState,
22310
+ executionMode,
22311
+ showPlaceOrder = true,
22312
+ isOpen,
22313
+ onOpenChange,
22314
+ midpointsResult,
22315
+ onBeforePrimaryAction
22316
+ }) => {
22317
+ const labels = (0, import_hooks59.useLabels)();
22318
+ if (!showPlaceOrder) return null;
22319
+ const handleOpenChange = (nextOpen) => {
22320
+ onOpenChange(nextOpen);
22321
+ };
22322
+ const handleClose = () => {
22323
+ onOpenChange(false);
22324
+ };
22325
+ return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(import_jsx_runtime155.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(Modal, { open: isOpen, onOpenChange: handleOpenChange, children: /* @__PURE__ */ (0, import_jsx_runtime155.jsxs)(
22326
+ Modal.Container,
22327
+ {
22328
+ classNames: {
22329
+ content: "items-end p-0 sm:items-center sm:p-4",
22330
+ container: cn(
22331
+ "agg-mobile-trade-modal",
22332
+ "w-full border-0 bg-transparent shadow-none",
22333
+ classNames == null ? void 0 : classNames.mobileTradeModal
22334
+ )
22335
+ },
22336
+ children: [
22337
+ /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(Dialog4.Title, { className: "sr-only", children: labels.trading.confirmOrder }),
22338
+ /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(Dialog4.Description, { className: "sr-only", children: labels.trading.disclaimer }),
22339
+ /* @__PURE__ */ (0, import_jsx_runtime155.jsx)("div", { className: "agg-mobile-trade-handle relative flex w-full flex-col items-center sm:hidden", children: /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
22340
+ "button",
22341
+ {
22342
+ type: "button",
22343
+ className: "absolute right-3 top-4 z-100 flex cursor-pointer items-center justify-center rounded-full p-1 text-agg-muted-foreground hover:text-agg-foreground",
22344
+ "aria-label": labels.common.close,
22345
+ onClick: handleClose,
22346
+ children: /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(CloseIcon, { className: "h-5 w-5" })
22347
+ }
22348
+ ) }),
22349
+ /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
22350
+ PlaceOrder,
22351
+ {
22352
+ eventTradingState,
22353
+ executionMode,
22354
+ midpointsResult,
22355
+ onBeforePrimaryAction,
22356
+ className: cn(
22357
+ "agg-mobile-trade-panel w-full overflow-hidden rounded-t-agg-2xl sm:rounded-agg-xl",
22358
+ classNames == null ? void 0 : classNames.mobileTrade
22359
+ ),
22360
+ classNames: resolveMobileTradePlaceOrderClassNames(classNames),
22361
+ onClose: handleClose
22362
+ }
22363
+ )
22364
+ ]
22365
+ }
22366
+ ) }) });
21910
22367
  };
21911
22368
  var EventMarketPageUnavailableState = ({
21912
22369
  ariaLabel: _ariaLabel
21913
22370
  }) => {
21914
- const labels = (0, import_hooks57.useLabels)();
22371
+ const labels = (0, import_hooks59.useLabels)();
21915
22372
  return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
21916
22373
  StateMessage,
21917
22374
  {
@@ -21927,7 +22384,7 @@ var EventMarketPageUnavailableState = ({
21927
22384
  var EventMarketPageNotFoundState = ({
21928
22385
  ariaLabel: _ariaLabel
21929
22386
  }) => {
21930
- const labels = (0, import_hooks57.useLabels)();
22387
+ const labels = (0, import_hooks59.useLabels)();
21931
22388
  return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
21932
22389
  StateMessage,
21933
22390
  {
@@ -22024,26 +22481,33 @@ var EventMarketPageContent = ({
22024
22481
  showPlaceOrder,
22025
22482
  executionMode,
22026
22483
  stickyOrderPanel,
22027
- resolvedClaim
22484
+ resolvedClaim,
22485
+ onBeforePrimaryAction
22028
22486
  }) => {
22029
- const eventTradingState = (0, import_react35.useMemo)(() => (0, import_hooks57.resolveEventTradingState)(event), [event]);
22487
+ const eventTradingState = (0, import_react37.useMemo)(() => (0, import_hooks59.resolveEventTradingState)(event), [event]);
22030
22488
  const stickyOrderPanelState = resolveEventMarketPageStickyState({
22031
22489
  stickyOrderPanel
22032
22490
  });
22033
22491
  const {
22034
22492
  trading: { executionMode: configuredExecutionMode }
22035
- } = (0, import_hooks57.useSdkUiConfig)();
22493
+ } = (0, import_hooks59.useSdkUiConfig)();
22036
22494
  const resolvedExecutionMode = executionMode != null ? executionMode : configuredExecutionMode;
22037
- const [isMobileTradeOpen, setIsMobileTradeOpen] = (0, import_react35.useState)(false);
22495
+ const [isMobileTradeOpen, setIsMobileTradeOpen] = (0, import_react37.useState)(false);
22038
22496
  const isMobileViewport = useIsMobileEventMarketViewport();
22039
- const tradingContext = (0, import_hooks57.useEventTradingContext)();
22040
- const midpointsResult = (0, import_hooks57.useMidpoints)(event.venueMarkets);
22041
- const setTradeSideRef = (0, import_react35.useRef)(tradingContext == null ? void 0 : tradingContext.setTradeSide);
22497
+ const tradingContext = (0, import_hooks59.useEventTradingContext)();
22498
+ const midpointsResult = (0, import_hooks59.useMidpoints)(event.venueMarkets);
22499
+ const internalResolvedClaim = useResolvedMarketClaim({
22500
+ market: eventTradingState.primaryMarket,
22501
+ enabled: eventTradingState.kind === "resolved",
22502
+ executionMode: resolvedExecutionMode
22503
+ });
22504
+ const effectiveResolvedClaim = resolvedClaim != null ? resolvedClaim : internalResolvedClaim;
22505
+ const setTradeSideRef = (0, import_react37.useRef)(tradingContext == null ? void 0 : tradingContext.setTradeSide);
22042
22506
  setTradeSideRef.current = tradingContext == null ? void 0 : tradingContext.setTradeSide;
22043
- (0, import_react35.useEffect)(() => {
22507
+ (0, import_react37.useEffect)(() => {
22044
22508
  return () => {
22045
22509
  var _a;
22046
- (_a = setTradeSideRef.current) == null ? void 0 : _a.call(setTradeSideRef, import_hooks57.TradeSide.Buy);
22510
+ (_a = setTradeSideRef.current) == null ? void 0 : _a.call(setTradeSideRef, import_hooks59.TradeSide.Buy);
22047
22511
  };
22048
22512
  }, []);
22049
22513
  if (!event.venueMarkets.length) {
@@ -22115,8 +22579,9 @@ var EventMarketPageContent = ({
22115
22579
  {
22116
22580
  eventTradingState,
22117
22581
  executionMode: resolvedExecutionMode,
22118
- resolvedClaim,
22582
+ resolvedClaim: effectiveResolvedClaim,
22119
22583
  midpointsResult,
22584
+ onBeforePrimaryAction,
22120
22585
  className: cn(
22121
22586
  "agg-mobile-trade-panel w-full overflow-hidden",
22122
22587
  classNames == null ? void 0 : classNames.mobileTrade
@@ -22141,8 +22606,9 @@ var EventMarketPageContent = ({
22141
22606
  {
22142
22607
  eventTradingState,
22143
22608
  executionMode: resolvedExecutionMode,
22144
- resolvedClaim,
22609
+ resolvedClaim: effectiveResolvedClaim,
22145
22610
  midpointsResult,
22611
+ onBeforePrimaryAction,
22146
22612
  className: cn(stickyOrderPanelState == null ? void 0 : stickyOrderPanelState.placeOrder, classNames == null ? void 0 : classNames.trade),
22147
22613
  classNames: resolveDesktopTradePlaceOrderClassNames(classNames)
22148
22614
  }
@@ -22161,7 +22627,8 @@ var EventMarketPageContent = ({
22161
22627
  showPlaceOrder,
22162
22628
  isOpen: isMobileTradeOpen,
22163
22629
  onOpenChange: setIsMobileTradeOpen,
22164
- midpointsResult
22630
+ midpointsResult,
22631
+ onBeforePrimaryAction
22165
22632
  }
22166
22633
  ) : null
22167
22634
  ]
@@ -22175,7 +22642,7 @@ var EventMarketPage = (props) => {
22175
22642
  event: fetchedEvent,
22176
22643
  error: eventError,
22177
22644
  isLoading: isFetchingEvent
22178
- } = (0, import_hooks57.useEnrichedVenueEvent)({
22645
+ } = (0, import_hooks59.useEnrichedVenueEvent)({
22179
22646
  eventId: hasEventProp ? "" : (_a = props.eventId) != null ? _a : "",
22180
22647
  enabled: !props.isLoading && !hasEventProp && !!props.eventId
22181
22648
  });
@@ -22274,15 +22741,15 @@ var resolveInitialTabValue = (tabs, defaultActiveTab) => {
22274
22741
  };
22275
22742
 
22276
22743
  // src/pages/home/use-scroll-restoration.ts
22277
- var import_react36 = require("react");
22744
+ var import_react38 = require("react");
22278
22745
  function useScrollRestoration({
22279
22746
  enabled,
22280
22747
  scrollY,
22281
22748
  isReady
22282
22749
  }) {
22283
- const restoredRef = (0, import_react36.useRef)(false);
22284
- const [isRestoring, setIsRestoring] = (0, import_react36.useState)(enabled && scrollY > 0);
22285
- (0, import_react36.useLayoutEffect)(() => {
22750
+ const restoredRef = (0, import_react38.useRef)(false);
22751
+ const [isRestoring, setIsRestoring] = (0, import_react38.useState)(enabled && scrollY > 0);
22752
+ (0, import_react38.useLayoutEffect)(() => {
22286
22753
  if (!enabled || restoredRef.current) return;
22287
22754
  if (!isReady) return;
22288
22755
  restoredRef.current = true;
@@ -22295,15 +22762,15 @@ function useScrollRestoration({
22295
22762
  }
22296
22763
 
22297
22764
  // src/pages/home/use-home-page-modals.ts
22298
- var import_react37 = require("react");
22765
+ var import_react39 = require("react");
22299
22766
  var useHomePageModals = () => {
22300
- const [profileOpen, setProfileOpen] = (0, import_react37.useState)(false);
22301
- const [depositOpen, setDepositOpen] = (0, import_react37.useState)(false);
22302
- const [withdrawOpen, setWithdrawOpen] = (0, import_react37.useState)(false);
22303
- const onProfileClick = (0, import_react37.useCallback)(() => setProfileOpen(true), []);
22304
- const onDepositClick = (0, import_react37.useCallback)(() => setDepositOpen(true), []);
22305
- const onWithdrawClick = (0, import_react37.useCallback)(() => setWithdrawOpen(true), []);
22306
- (0, import_react37.useEffect)(() => {
22767
+ const [profileOpen, setProfileOpen] = (0, import_react39.useState)(false);
22768
+ const [depositOpen, setDepositOpen] = (0, import_react39.useState)(false);
22769
+ const [withdrawOpen, setWithdrawOpen] = (0, import_react39.useState)(false);
22770
+ const onProfileClick = (0, import_react39.useCallback)(() => setProfileOpen(true), []);
22771
+ const onDepositClick = (0, import_react39.useCallback)(() => setDepositOpen(true), []);
22772
+ const onWithdrawClick = (0, import_react39.useCallback)(() => setWithdrawOpen(true), []);
22773
+ (0, import_react39.useEffect)(() => {
22307
22774
  if (typeof window === "undefined") return;
22308
22775
  window.addEventListener(DEPOSIT_MODAL_OPEN_EVENT, onDepositClick);
22309
22776
  window.addEventListener(WITHDRAW_MODAL_OPEN_EVENT, onWithdrawClick);
@@ -22340,20 +22807,20 @@ var HomeSearchResults = ({
22340
22807
  onEventClick,
22341
22808
  onMarketClick
22342
22809
  }) => {
22343
- const labels = (0, import_hooks58.useLabels)();
22344
- const { search: searchConfig } = (0, import_hooks58.useSdkUiConfig)();
22345
- const { disabledVenues } = (0, import_hooks58.useAppConfig)();
22346
- const [activeVenueTabValue, setActiveVenueTabValue] = (0, import_react38.useState)("matched");
22810
+ const labels = (0, import_hooks60.useLabels)();
22811
+ const { search: searchConfig } = (0, import_hooks60.useSdkUiConfig)();
22812
+ const { disabledVenues } = (0, import_hooks60.useAppConfig)();
22813
+ const [activeVenueTabValue, setActiveVenueTabValue] = (0, import_react40.useState)("matched");
22347
22814
  const eventListTabs = useEventListTabs();
22348
22815
  const { headerRef, titleRef, shouldUseSelectOverflow } = useEventListTabsHeaderOverflow(eventListTabs);
22349
- const visibleVenues = (0, import_react38.useMemo)(
22350
- () => disabledVenues.length === 0 ? void 0 : (0, import_hooks58.getVisibleVenueIdsByConfig)(import_sdk18.VENUES, disabledVenues),
22816
+ const visibleVenues = (0, import_react40.useMemo)(
22817
+ () => disabledVenues.length === 0 ? void 0 : (0, import_hooks60.getVisibleVenueIdsByConfig)(import_sdk18.VENUES, disabledVenues),
22351
22818
  [disabledVenues]
22352
22819
  );
22353
- const activeVenueTab = (0, import_react38.useMemo)(() => {
22820
+ const activeVenueTab = (0, import_react40.useMemo)(() => {
22354
22821
  return eventListTabs.find((tab) => tab.value === activeVenueTabValue);
22355
22822
  }, [activeVenueTabValue, eventListTabs]);
22356
- const activeCategoryTab = (0, import_react38.useMemo)(() => {
22823
+ const activeCategoryTab = (0, import_react40.useMemo)(() => {
22357
22824
  return resolvedTabs.find((tab) => tab.value === activeTabValue);
22358
22825
  }, [activeTabValue, resolvedTabs]);
22359
22826
  const activeVenues = resolveTabVenus(activeVenueTab, visibleVenues);
@@ -22365,7 +22832,7 @@ var HomeSearchResults = ({
22365
22832
  hasNextPage,
22366
22833
  isFetchingNextPage,
22367
22834
  isPlaceholderData
22368
- } = (0, import_hooks58.useSearch)({
22835
+ } = (0, import_hooks60.useSearch)({
22369
22836
  q: query,
22370
22837
  type: "events",
22371
22838
  categoryIds: activeTabValue === ALL_CATEGORIES_TAB_VALUE ? void 0 : activeCategoryTab == null ? void 0 : activeCategoryTab.categoryIds,
@@ -22377,15 +22844,15 @@ var HomeSearchResults = ({
22377
22844
  // so debounced keystrokes don't pay reranker latency.
22378
22845
  deep: true
22379
22846
  });
22380
- const openEvents = (0, import_react38.useMemo)(() => {
22847
+ const openEvents = (0, import_react40.useMemo)(() => {
22381
22848
  let filtered = filterOpenEvents(searchResults);
22382
22849
  if (activeVenues == null ? void 0 : activeVenues.length) {
22383
22850
  filtered = filtered.filter((e) => activeVenues.includes(e.venue));
22384
22851
  }
22385
22852
  return filtered;
22386
22853
  }, [searchResults, activeVenues]);
22387
- const loadMoreRef = (0, import_react38.useRef)(null);
22388
- (0, import_react38.useEffect)(() => {
22854
+ const loadMoreRef = (0, import_react40.useRef)(null);
22855
+ (0, import_react40.useEffect)(() => {
22389
22856
  if (!hasNextPage) return;
22390
22857
  const target = loadMoreRef.current;
22391
22858
  if (!target) return;
@@ -22527,7 +22994,7 @@ var HomePage = ({
22527
22994
  stickyOrderPanel
22528
22995
  }) => {
22529
22996
  var _a, _b, _c, _d;
22530
- const labels = (0, import_hooks58.useLabels)();
22997
+ const labels = (0, import_hooks60.useLabels)();
22531
22998
  const {
22532
22999
  search: {
22533
23000
  value: searchValue,
@@ -22537,11 +23004,11 @@ var HomePage = ({
22537
23004
  onSelect: onSelectEventInternal
22538
23005
  },
22539
23006
  trading: { executionMode }
22540
- } = (0, import_hooks58.useSdkUiConfig)();
22541
- const { capture, consume } = (0, import_hooks58.useEventListState)();
22542
- const [snapshot] = (0, import_react38.useState)(() => consume());
22543
- const eventListStateRef = (0, import_react38.useRef)(null);
22544
- const handleSelectEvent = (0, import_react38.useCallback)(
23007
+ } = (0, import_hooks60.useSdkUiConfig)();
23008
+ const { capture, consume } = (0, import_hooks60.useEventListState)();
23009
+ const [snapshot] = (0, import_react40.useState)(() => consume());
23010
+ const eventListStateRef = (0, import_react40.useRef)(null);
23011
+ const handleSelectEvent = (0, import_react40.useCallback)(
22545
23012
  (event) => {
22546
23013
  var _a2, _b2, _c2, _d2;
22547
23014
  capture({
@@ -22560,14 +23027,14 @@ var HomePage = ({
22560
23027
  );
22561
23028
  const hasCustomTabs = !!tabs && tabs.length > 0;
22562
23029
  const normalizedSearchValue = searchValue.trim();
22563
- const [stickySelectedEvent, setStickySelectedEvent] = (0, import_react38.useState)(
23030
+ const [stickySelectedEvent, setStickySelectedEvent] = (0, import_react40.useState)(
22564
23031
  selectedEvent
22565
23032
  );
22566
- const [debouncedSearchValue, setDebouncedSearchValue] = (0, import_react38.useState)(() => {
23033
+ const [debouncedSearchValue, setDebouncedSearchValue] = (0, import_react40.useState)(() => {
22567
23034
  return normalizedSearchValue.length >= MIN_SEARCH_LENGTH2 ? normalizedSearchValue : "";
22568
23035
  });
22569
- const [isMobileSearchViewport, setIsMobileSearchViewport] = (0, import_react38.useState)(false);
22570
- (0, import_react38.useEffect)(() => {
23036
+ const [isMobileSearchViewport, setIsMobileSearchViewport] = (0, import_react40.useState)(false);
23037
+ (0, import_react40.useEffect)(() => {
22571
23038
  if (typeof window === "undefined") return;
22572
23039
  const mediaQueryList = window.matchMedia(MOBILE_HOME_SEARCH_MEDIA_QUERY);
22573
23040
  const handleMediaQueryChange = (event) => {
@@ -22585,7 +23052,7 @@ var HomePage = ({
22585
23052
  mediaQueryList.removeListener(handleMediaQueryChange);
22586
23053
  };
22587
23054
  }, []);
22588
- (0, import_react38.useEffect)(() => {
23055
+ (0, import_react40.useEffect)(() => {
22589
23056
  if (normalizedSearchValue.length < MIN_SEARCH_LENGTH2) {
22590
23057
  setDebouncedSearchValue("");
22591
23058
  return;
@@ -22597,7 +23064,7 @@ var HomePage = ({
22597
23064
  window.clearTimeout(timeoutId);
22598
23065
  };
22599
23066
  }, [normalizedSearchValue]);
22600
- (0, import_react38.useEffect)(() => {
23067
+ (0, import_react40.useEffect)(() => {
22601
23068
  if (selectedEvent) {
22602
23069
  setStickySelectedEvent(selectedEvent);
22603
23070
  return;
@@ -22608,34 +23075,34 @@ var HomePage = ({
22608
23075
  }, [isShowingAllResults, normalizedSearchValue, selectedEvent]);
22609
23076
  const resolvedSelectedEvent = selectedEvent != null ? selectedEvent : stickySelectedEvent;
22610
23077
  const resolvedAllCategoryTabLabel = allCategoryTabLabel === DEFAULT_ALL_CATEGORY_TAB_LABEL ? labels.home.trending : allCategoryTabLabel;
22611
- const { categories } = (0, import_hooks58.useCategories)({
23078
+ const { categories } = (0, import_hooks60.useCategories)({
22612
23079
  limit: categoriesLimit,
22613
23080
  enabled: !hasCustomTabs
22614
23081
  });
22615
- const categoryTabs = (0, import_react38.useMemo)(() => {
23082
+ const categoryTabs = (0, import_react40.useMemo)(() => {
22616
23083
  return resolveCategoryTabs(categories, resolvedAllCategoryTabLabel);
22617
23084
  }, [categories, resolvedAllCategoryTabLabel]);
22618
- const resolvedTabs = (0, import_react38.useMemo)(() => {
23085
+ const resolvedTabs = (0, import_react40.useMemo)(() => {
22619
23086
  if (hasCustomTabs && tabs) return tabs;
22620
23087
  return categoryTabs;
22621
23088
  }, [categoryTabs, hasCustomTabs, tabs]);
22622
23089
  const resolvedEventSectionItems = eventSectionItems && eventSectionItems.length > 0 ? eventSectionItems : getDefaultEventSectionItems(labels);
22623
- const [activeTabValue, setActiveTabValue] = (0, import_react38.useState)(() => {
23090
+ const [activeTabValue, setActiveTabValue] = (0, import_react40.useState)(() => {
22624
23091
  if (snapshot == null ? void 0 : snapshot.categoryTab) {
22625
23092
  return snapshot.categoryTab;
22626
23093
  }
22627
23094
  return resolveInitialTabValue(resolvedTabs, defaultActiveTab);
22628
23095
  });
22629
- const activeTabValueRef = (0, import_react38.useRef)(activeTabValue);
23096
+ const activeTabValueRef = (0, import_react40.useRef)(activeTabValue);
22630
23097
  activeTabValueRef.current = activeTabValue;
22631
- (0, import_react38.useEffect)(() => {
23098
+ (0, import_react40.useEffect)(() => {
22632
23099
  setActiveTabValue((currentValue) => {
22633
23100
  const hasCurrentValue = resolvedTabs.some((tab) => tab.value === currentValue);
22634
23101
  if (hasCurrentValue) return currentValue;
22635
23102
  return resolveInitialTabValue(resolvedTabs, defaultActiveTab);
22636
23103
  });
22637
23104
  }, [defaultActiveTab, resolvedTabs]);
22638
- const tabsItems = (0, import_react38.useMemo)(() => {
23105
+ const tabsItems = (0, import_react40.useMemo)(() => {
22639
23106
  return resolvedTabs.map((tab) => {
22640
23107
  const isActive = tab.value === activeTabValue;
22641
23108
  return {
@@ -22655,10 +23122,10 @@ var HomePage = ({
22655
23122
  };
22656
23123
  });
22657
23124
  }, [activeTabValue, resolvedTabs]);
22658
- const activeTab = (0, import_react38.useMemo)(() => {
23125
+ const activeTab = (0, import_react40.useMemo)(() => {
22659
23126
  return resolvedTabs.find((tab) => tab.value === activeTabValue);
22660
23127
  }, [activeTabValue, resolvedTabs]);
22661
- const resolvedSectionItems = (0, import_react38.useMemo)(() => {
23128
+ const resolvedSectionItems = (0, import_react40.useMemo)(() => {
22662
23129
  var _a2, _b2, _c2;
22663
23130
  if (activeTabValue === ALL_CATEGORIES_TAB_VALUE) {
22664
23131
  return resolvedEventSectionItems;
@@ -22818,9 +23285,9 @@ var HomePage = ({
22818
23285
  HomePage.displayName = "HomePage";
22819
23286
 
22820
23287
  // src/pages/user-profile/index.tsx
22821
- var import_hooks63 = require("@agg-build/hooks");
23288
+ var import_hooks65 = require("@agg-build/hooks");
22822
23289
  var import_sdk19 = require("@agg-build/sdk");
22823
- var import_react40 = require("react");
23290
+ var import_react42 = require("react");
22824
23291
 
22825
23292
  // src/pages/user-profile/chain-display.ts
22826
23293
  var CHAIN_ID_TO_LABEL = {
@@ -22843,7 +23310,7 @@ var formatChainIdLabel = (chainId) => {
22843
23310
  };
22844
23311
 
22845
23312
  // src/pages/user-profile/components/available-balance-card.tsx
22846
- var import_hooks59 = require("@agg-build/hooks");
23313
+ var import_hooks61 = require("@agg-build/hooks");
22847
23314
  var import_jsx_runtime157 = require("react/jsx-runtime");
22848
23315
  var BASE_URL = "https://assets.snagsolutions.io";
22849
23316
  var CHAIN_ID_TO_ICON_URL = {
@@ -22898,7 +23365,7 @@ var AvailableBalanceCard = ({
22898
23365
  isLoading = false,
22899
23366
  className
22900
23367
  }) => {
22901
- const labels = (0, import_hooks59.useLabels)();
23368
+ const labels = (0, import_hooks61.useLabels)();
22902
23369
  const balanceLabels = labels.userProfile.balance;
22903
23370
  const resolvedLabel = label2 != null ? label2 : balanceLabels.availableBalance;
22904
23371
  const hasPaperBalance = chains.some(isPaperChain);
@@ -23057,8 +23524,8 @@ var AvailableBalanceCard = ({
23057
23524
  AvailableBalanceCard.displayName = "AvailableBalanceCard";
23058
23525
 
23059
23526
  // src/pages/user-profile/components/positions-activity.tsx
23060
- var import_hooks61 = require("@agg-build/hooks");
23061
- var import_react39 = require("react");
23527
+ var import_hooks63 = require("@agg-build/hooks");
23528
+ var import_react41 = require("react");
23062
23529
 
23063
23530
  // src/pages/user-profile/user-profile.constants.ts
23064
23531
  var USER_PROFILE_TAB_POSITIONS = "positions";
@@ -23899,7 +24366,7 @@ var EmptyState = ({ title: title2, description, className }) => {
23899
24366
  EmptyState.displayName = "EmptyState";
23900
24367
 
23901
24368
  // src/pages/user-profile/components/position-row.tsx
23902
- var import_hooks60 = require("@agg-build/hooks");
24369
+ var import_hooks62 = require("@agg-build/hooks");
23903
24370
  var import_jsx_runtime160 = require("react/jsx-runtime");
23904
24371
  var shouldUseNativeLinkNavigation2 = (event) => {
23905
24372
  return event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || event.button === 1;
@@ -24037,7 +24504,7 @@ var PositionRow = ({
24037
24504
  onClaim,
24038
24505
  isClaiming = false
24039
24506
  }) => {
24040
- const labels = (0, import_hooks60.useLabels)().userProfile.positions;
24507
+ const labels = (0, import_hooks62.useLabels)().userProfile.positions;
24041
24508
  const model = toPositionRowViewModel(position, {
24042
24509
  avgPrefix: labels.avgPrefix,
24043
24510
  nowPrefix: labels.nowPrefix,
@@ -24091,7 +24558,7 @@ var PositionRow = ({
24091
24558
  /* @__PURE__ */ (0, import_jsx_runtime160.jsx)("div", { className: "agg-position-image flex h-10 w-10 shrink-0 items-center justify-center md:h-15 md:w-15", children: /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(
24092
24559
  RemoteImage,
24093
24560
  {
24094
- src: (0, import_hooks60.optimizedImageUrl)(model.thumbnailSrc, 60),
24561
+ src: (0, import_hooks62.optimizedImageUrl)(model.thumbnailSrc, 60),
24095
24562
  alt: "",
24096
24563
  className: "h-full w-full rounded-agg-sm object-cover"
24097
24564
  }
@@ -24217,7 +24684,7 @@ var tabItems = [
24217
24684
  // Restore by re-adding USER_PROFILE_TAB_OPEN_ORDERS here and the renderer below.
24218
24685
  { value: USER_PROFILE_TAB_ACTIVITY, label: "Activity" }
24219
24686
  ];
24220
- var TabRowsSkeleton = ({ ariaLabel }) => /* @__PURE__ */ (0, import_jsx_runtime161.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_runtime161.jsxs)(import_react39.Fragment, { children: [
24687
+ var TabRowsSkeleton = ({ ariaLabel }) => /* @__PURE__ */ (0, import_jsx_runtime161.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_runtime161.jsxs)(import_react41.Fragment, { children: [
24221
24688
  /* @__PURE__ */ (0, import_jsx_runtime161.jsx)("div", { className: "h-14 rounded-agg-sm bg-agg-secondary-hover/80 sm:h-16" }, index),
24222
24689
  index < acc.length - 1 ? /* @__PURE__ */ (0, import_jsx_runtime161.jsx)("div", { className: "agg-position-divider h-px w-full shrink-0 bg-agg-separator", "aria-hidden": true }) : null
24223
24690
  ] }, index)) });
@@ -24250,9 +24717,9 @@ var PositionsActivity = ({
24250
24717
  initialPositionFilter = "active",
24251
24718
  className
24252
24719
  }) => {
24253
- const positionsLabels = (0, import_hooks61.useLabels)().userProfile.positions;
24720
+ const positionsLabels = (0, import_hooks63.useLabels)().userProfile.positions;
24254
24721
  const isTabControlled = tab !== void 0;
24255
- const [internalActiveTab, setInternalActiveTab] = (0, import_react39.useState)(
24722
+ const [internalActiveTab, setInternalActiveTab] = (0, import_react41.useState)(
24256
24723
  tab != null ? tab : USER_PROFILE_TAB_POSITIONS
24257
24724
  );
24258
24725
  const activeTab = isTabControlled ? tab : internalActiveTab;
@@ -24260,19 +24727,19 @@ var PositionsActivity = ({
24260
24727
  if (!isTabControlled) setInternalActiveTab(next);
24261
24728
  onTabChange == null ? void 0 : onTabChange(next);
24262
24729
  };
24263
- const [positionFilter, setPositionFilter] = (0, import_react39.useState)(initialPositionFilter);
24264
- const [searchValue, setSearchValue] = (0, import_react39.useState)("");
24265
- const [isSearchFocused, setIsSearchFocused] = (0, import_react39.useState)(false);
24266
- const [locallyClaimedPositionIds, setLocallyClaimedPositionIds] = (0, import_react39.useState)(
24730
+ const [positionFilter, setPositionFilter] = (0, import_react41.useState)(initialPositionFilter);
24731
+ const [searchValue, setSearchValue] = (0, import_react41.useState)("");
24732
+ const [isSearchFocused, setIsSearchFocused] = (0, import_react41.useState)(false);
24733
+ const [locallyClaimedPositionIds, setLocallyClaimedPositionIds] = (0, import_react41.useState)(
24267
24734
  () => /* @__PURE__ */ new Set()
24268
24735
  );
24269
- const positionsLoadMoreRef = (0, import_react39.useRef)(null);
24270
- const activitiesLoadMoreRef = (0, import_react39.useRef)(null);
24271
- const rowsScrollRef = (0, import_react39.useRef)(null);
24736
+ const positionsLoadMoreRef = (0, import_react41.useRef)(null);
24737
+ const activitiesLoadMoreRef = (0, import_react41.useRef)(null);
24738
+ const rowsScrollRef = (0, import_react41.useRef)(null);
24272
24739
  const isPositionsTab = activeTab === USER_PROFILE_TAB_POSITIONS;
24273
24740
  const isActivityTab = activeTab === USER_PROFILE_TAB_ACTIVITY;
24274
24741
  const isClosedPositionsFilter = isPositionsTab && positionFilter === "closed";
24275
- const positionsForCurrentFilter = (0, import_react39.useMemo)(() => {
24742
+ const positionsForCurrentFilter = (0, import_react41.useMemo)(() => {
24276
24743
  if (positionFilter === "active") {
24277
24744
  return activePositions.filter((position) => !locallyClaimedPositionIds.has(position.id));
24278
24745
  }
@@ -24289,7 +24756,7 @@ var PositionsActivity = ({
24289
24756
  }
24290
24757
  return Array.from(byId.values());
24291
24758
  }, [activePositions, closedPositions, locallyClaimedPositionIds, positionFilter]);
24292
- const filteredPositions = (0, import_react39.useMemo)(() => {
24759
+ const filteredPositions = (0, import_react41.useMemo)(() => {
24293
24760
  if (!searchValue.trim()) return positionsForCurrentFilter;
24294
24761
  const q = searchValue.toLowerCase();
24295
24762
  return positionsForCurrentFilter.filter((p) => p.title.toLowerCase().includes(q));
@@ -24314,7 +24781,7 @@ var PositionsActivity = ({
24314
24781
  const isLoadingMorePositions = positionFilter === "active" ? isLoadingMoreActivePositions : isLoadingMoreClosedPositions;
24315
24782
  const loadMorePositions = positionFilter === "active" ? onLoadMoreActivePositions : onLoadMoreClosedPositions;
24316
24783
  const filteredActivities = activities;
24317
- const searchResults = (0, import_react39.useMemo)(() => {
24784
+ const searchResults = (0, import_react41.useMemo)(() => {
24318
24785
  if (!isPositionsTab || !searchValue.trim()) return [];
24319
24786
  return filteredPositions.slice(0, 5).map((position) => ({
24320
24787
  id: position.id,
@@ -24332,11 +24799,11 @@ var PositionsActivity = ({
24332
24799
  const handleSearchChange = (event) => {
24333
24800
  setSearchValue(event.target.value);
24334
24801
  };
24335
- (0, import_react39.useEffect)(() => {
24802
+ (0, import_react41.useEffect)(() => {
24336
24803
  if (isPositionsTab) return;
24337
24804
  setIsSearchFocused(false);
24338
24805
  }, [isPositionsTab]);
24339
- (0, import_react39.useEffect)(() => {
24806
+ (0, import_react41.useEffect)(() => {
24340
24807
  if (!isPositionsTab || !hasMorePositions) return;
24341
24808
  const target = positionsLoadMoreRef.current;
24342
24809
  if (!target || !loadMorePositions) return;
@@ -24358,7 +24825,7 @@ var PositionsActivity = ({
24358
24825
  isPositionsTab,
24359
24826
  loadMorePositions
24360
24827
  ]);
24361
- (0, import_react39.useEffect)(() => {
24828
+ (0, import_react41.useEffect)(() => {
24362
24829
  if (!isActivityTab || !hasMoreActivities) return;
24363
24830
  const target = activitiesLoadMoreRef.current;
24364
24831
  if (!target || !onLoadMoreActivities) return;
@@ -24477,7 +24944,7 @@ var PositionsActivity = ({
24477
24944
  /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(
24478
24945
  "img",
24479
24946
  {
24480
- src: (0, import_hooks61.optimizedImageUrl)(item.thumbnailSrc, 48),
24947
+ src: (0, import_hooks63.optimizedImageUrl)(item.thumbnailSrc, 48),
24481
24948
  alt: "",
24482
24949
  className: "size-12 shrink-0 rounded-agg-lg object-cover"
24483
24950
  }
@@ -24585,7 +25052,7 @@ var PositionsActivity = ({
24585
25052
  }
24586
25053
  ) : filteredPositions.length > 0 ? filteredPositions.map((position, index) => {
24587
25054
  var _a;
24588
- return /* @__PURE__ */ (0, import_jsx_runtime161.jsxs)(import_react39.Fragment, { children: [
25055
+ return /* @__PURE__ */ (0, import_jsx_runtime161.jsxs)(import_react41.Fragment, { children: [
24589
25056
  index > 0 ? /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(
24590
25057
  "div",
24591
25058
  {
@@ -24630,7 +25097,7 @@ var PositionsActivity = ({
24630
25097
  title: "Unable to load activity",
24631
25098
  description: "Please try again in a moment."
24632
25099
  }
24633
- ) : filteredActivities.length > 0 ? filteredActivities.map((activity, index) => /* @__PURE__ */ (0, import_jsx_runtime161.jsxs)(import_react39.Fragment, { children: [
25100
+ ) : filteredActivities.length > 0 ? filteredActivities.map((activity, index) => /* @__PURE__ */ (0, import_jsx_runtime161.jsxs)(import_react41.Fragment, { children: [
24634
25101
  index > 0 ? /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(
24635
25102
  "div",
24636
25103
  {
@@ -24720,7 +25187,7 @@ var PositionsValueCard = ({
24720
25187
  PositionsValueCard.displayName = "PositionsValueCard";
24721
25188
 
24722
25189
  // src/pages/user-profile/components/user-info-card.tsx
24723
- var import_hooks62 = require("@agg-build/hooks");
25190
+ var import_hooks64 = require("@agg-build/hooks");
24724
25191
  var import_jsx_runtime163 = require("react/jsx-runtime");
24725
25192
  var UserInfoCard = ({
24726
25193
  user,
@@ -24731,7 +25198,7 @@ var UserInfoCard = ({
24731
25198
  className
24732
25199
  }) => {
24733
25200
  var _a;
24734
- const labels = (0, import_hooks62.useLabels)();
25201
+ const labels = (0, import_hooks64.useLabels)();
24735
25202
  const wallets = (_a = user.connectedWallets) != null ? _a : [];
24736
25203
  const hasWallets = wallets.length > 0;
24737
25204
  return /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)(
@@ -24747,7 +25214,7 @@ var UserInfoCard = ({
24747
25214
  /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("div", { className: "agg-profile-avatar shrink-0", children: user.avatarUrl ? /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
24748
25215
  RemoteImage,
24749
25216
  {
24750
- src: (0, import_hooks62.optimizedImageUrl)(user.avatarUrl, 120),
25217
+ src: (0, import_hooks64.optimizedImageUrl)(user.avatarUrl, 120),
24751
25218
  alt: user.username,
24752
25219
  className: "h-20 w-20 rounded-full object-cover sm:h-[120px] sm:w-[120px]"
24753
25220
  }
@@ -25243,10 +25710,6 @@ function buildVenueShareBreakdown(outcome) {
25243
25710
  sharesLabel: `${twoDecimalNumberFormatter.format(row.size)} shares`
25244
25711
  }));
25245
25712
  }
25246
- var toClaimError = (err) => {
25247
- if (err instanceof Error) return err;
25248
- return new Error(String(err));
25249
- };
25250
25713
  var UserProfilePage = ({
25251
25714
  user,
25252
25715
  balanceChainsOverride,
@@ -25296,305 +25759,100 @@ var UserProfilePage = ({
25296
25759
  classNames,
25297
25760
  onError
25298
25761
  }) => {
25299
- const [isHydrated, setIsHydrated] = (0, import_react40.useState)(false);
25300
- (0, import_react40.useEffect)(() => {
25762
+ const [isHydrated, setIsHydrated] = (0, import_react42.useState)(false);
25763
+ (0, import_react42.useEffect)(() => {
25301
25764
  setIsHydrated(true);
25302
25765
  }, []);
25303
- const { user: currentUser, isAuthenticated } = (0, import_hooks63.useAggAuthState)();
25304
- const { isDepositBlocked } = (0, import_hooks63.useGeoBlock)();
25305
- const balanceState = (0, import_hooks63.useAggBalance)();
25306
- const client = (0, import_hooks63.useAggClient)();
25307
- const labels = (0, import_hooks63.useLabels)();
25766
+ const { user: currentUser, isAuthenticated } = (0, import_hooks65.useAggAuthState)();
25767
+ const { isDepositBlocked } = (0, import_hooks65.useGeoBlock)();
25768
+ const balanceState = (0, import_hooks65.useAggBalance)();
25769
+ const client = (0, import_hooks65.useAggClient)();
25770
+ const labels = (0, import_hooks65.useLabels)();
25308
25771
  const {
25309
25772
  trading: { executionMode: configuredExecutionMode }
25310
- } = (0, import_hooks63.useSdkUiConfig)();
25311
- const claimNotificationLabels = labels.notifications.claim;
25312
- const toastCtx = useOptionalToast();
25313
- const queryClient = (0, import_hooks63.useQueryClient)();
25314
- const redeemMutation = (0, import_hooks63.useRedeem)();
25315
- const [internalCancellingIds, setInternalCancellingIds] = (0, import_react40.useState)({});
25316
- const [activeRedeems, setActiveRedeems] = (0, import_react40.useState)({});
25317
- const activeClaimKeysRef = (0, import_react40.useRef)(/* @__PURE__ */ new Set());
25318
- const pendingClaimToastIdsRef = (0, import_react40.useRef)({});
25319
- const submittedClaimToastKeysRef = (0, import_react40.useRef)(/* @__PURE__ */ new Set());
25320
- const [submittingClaimKeys, setSubmittingClaimKeys] = (0, import_react40.useState)({});
25321
- const lifecycleInputs = (0, import_react40.useMemo)(
25322
- () => Object.values(activeRedeems),
25323
- [activeRedeems]
25324
- );
25325
- const lifecycleStates = (0, import_hooks63.useRedeemLifecycles)(lifecycleInputs);
25326
- const internalClaimingIds = (0, import_react40.useMemo)(() => {
25327
- const out = __spreadValues({}, submittingClaimKeys);
25328
- for (const [claimKey, active] of Object.entries(activeRedeems)) {
25329
- const state = lifecycleStates[active.redeemId];
25330
- if (!state || !state.terminal) out[claimKey] = true;
25331
- }
25332
- return out;
25333
- }, [activeRedeems, lifecycleStates, submittingClaimKeys]);
25334
- const [profileUser, setProfileUser] = (0, import_react40.useState)(void 0);
25773
+ } = (0, import_hooks65.useSdkUiConfig)();
25774
+ const queryClient = (0, import_hooks65.useQueryClient)();
25775
+ const [internalCancellingIds, setInternalCancellingIds] = (0, import_react42.useState)({});
25776
+ const { claim: startClaim, claimingKeys } = useClaimWinnings({
25777
+ onClaim,
25778
+ onClaimResult,
25779
+ onClaimSubmitError,
25780
+ externalClaimingKeys: claimingPositionKeys
25781
+ });
25782
+ const [profileUser, setProfileUser] = (0, import_react42.useState)(void 0);
25335
25783
  const shouldUseHookData = !user;
25336
- const connectedVenues = (0, import_react40.useMemo)(() => {
25784
+ const connectedVenues = (0, import_react42.useMemo)(() => {
25337
25785
  var _a;
25338
25786
  if (!shouldUseHookData) return [];
25339
- const fromBalance = (_a = balanceState.connectedVenues) != null ? _a : [];
25340
- return [...new Set(fromBalance)].sort((a, b) => a.localeCompare(b));
25341
- }, [balanceState, shouldUseHookData]);
25342
- const [positionFilter, setPositionFilter] = (0, import_react40.useState)(initialPositionFilter);
25343
- const resolvedExecutionMode = executionMode != null ? executionMode : configuredExecutionMode;
25344
- const queryExecutionMode = resolvedExecutionMode === "paper" ? "paper" : void 0;
25345
- const activePositionsQuery = (0, import_hooks63.useExecutionPositions)({
25346
- enabled: shouldUseHookData && isAuthenticated,
25347
- status: "active",
25348
- limit: 25,
25349
- mode: queryExecutionMode
25350
- });
25351
- const closedPositionsQuery = (0, import_hooks63.useExecutionPositions)({
25352
- enabled: shouldUseHookData && isAuthenticated,
25353
- status: "closed",
25354
- limit: 25,
25355
- mode: queryExecutionMode
25356
- });
25357
- const handlePositionFilterChange = (0, import_react40.useCallback)(
25358
- (filter) => {
25359
- setPositionFilter(filter);
25360
- onPositionFilterChangeProp == null ? void 0 : onPositionFilterChangeProp(filter);
25361
- },
25362
- [onPositionFilterChangeProp]
25363
- );
25364
- (0, import_react40.useEffect)(() => {
25365
- setPositionFilter(initialPositionFilter);
25366
- }, [initialPositionFilter]);
25367
- const ordersQuery = (0, import_hooks63.useExecutionOrders)({
25368
- enabled: shouldUseHookData && isAuthenticated,
25369
- limit: 25,
25370
- mode: queryExecutionMode
25371
- });
25372
- const activityQuery = (0, import_hooks63.useUserActivity)({
25373
- enabled: shouldUseHookData && isAuthenticated,
25374
- limit: 25
25375
- });
25376
- const handleCancelOrder = (0, import_react40.useCallback)(
25377
- (order) => __async(null, null, function* () {
25378
- if (onCancelOrder) {
25379
- onCancelOrder(order);
25380
- return;
25381
- }
25382
- setInternalCancellingIds((prev) => __spreadProps(__spreadValues({}, prev), { [order.id]: true }));
25383
- try {
25384
- yield client.cancelManagedOrder(order.id);
25385
- yield queryClient.invalidateQueries({ queryKey: ["execution-orders"] });
25386
- } finally {
25387
- setInternalCancellingIds((prev) => {
25388
- var _a;
25389
- const _b = prev, { [_a = order.id]: _removed } = _b, rest = __objRest(_b, [__restKey(_a)]);
25390
- return rest;
25391
- });
25392
- }
25393
- }),
25394
- [client, onCancelOrder, queryClient]
25395
- );
25396
- const invalidateClaimUiState = (0, import_react40.useCallback)(() => {
25397
- (0, import_hooks63.invalidateBalanceQueries)(queryClient);
25398
- (0, import_hooks63.invalidatePositionQueries)(queryClient);
25399
- queryClient.invalidateQueries({
25400
- queryKey: import_hooks63.executionKeys.claimablePositionsCount(),
25401
- refetchType: "active"
25402
- });
25403
- (0, import_hooks63.invalidateUserActivityQueries)(queryClient);
25404
- }, [queryClient]);
25405
- const handleClaimPosition = (0, import_react40.useCallback)(
25406
- (position) => __async(null, null, function* () {
25407
- var _a, _b;
25408
- const claimKey = (_a = position.marketId) != null ? _a : position.id;
25409
- if (activeClaimKeysRef.current.has(claimKey) || (claimingPositionKeys == null ? void 0 : claimingPositionKeys[claimKey]) || internalClaimingIds[claimKey]) {
25410
- return;
25411
- }
25412
- activeClaimKeysRef.current.add(claimKey);
25413
- setSubmittingClaimKeys((prev) => __spreadProps(__spreadValues({}, prev), { [claimKey]: true }));
25414
- const pendingToastId = toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.pendingMessage, {
25415
- title: claimNotificationLabels.pendingTitle,
25416
- tone: "info"
25417
- });
25418
- if (pendingToastId != null) {
25419
- pendingClaimToastIdsRef.current[claimKey] = pendingToastId;
25420
- }
25421
- if (onClaim) {
25422
- try {
25423
- yield onClaim(position);
25424
- const pendingId = pendingClaimToastIdsRef.current[claimKey];
25425
- if (pendingId != null) toastCtx == null ? void 0 : toastCtx.dismiss(pendingId);
25426
- delete pendingClaimToastIdsRef.current[claimKey];
25427
- toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.successMessage, {
25428
- title: claimNotificationLabels.successTitle,
25429
- tone: "success"
25430
- });
25431
- } catch (err) {
25432
- const error = toClaimError(err);
25433
- console.error("[UserProfilePage] redeem failed", error);
25434
- const pendingId = pendingClaimToastIdsRef.current[claimKey];
25435
- if (pendingId != null) toastCtx == null ? void 0 : toastCtx.dismiss(pendingId);
25436
- delete pendingClaimToastIdsRef.current[claimKey];
25437
- toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.failedMessage(error.message), {
25438
- title: claimNotificationLabels.failedTitle,
25439
- tone: "error"
25440
- });
25441
- onClaimSubmitError == null ? void 0 : onClaimSubmitError(claimKey, error);
25442
- throw error;
25443
- } finally {
25444
- invalidateClaimUiState();
25445
- activeClaimKeysRef.current.delete(claimKey);
25446
- setSubmittingClaimKeys((prev) => {
25447
- const _a2 = prev, { [claimKey]: _removed } = _a2, rest = __objRest(_a2, [__restKey(claimKey)]);
25448
- return rest;
25449
- });
25450
- }
25451
- return;
25452
- }
25453
- const venueMarketOutcomeIds = (_b = position.winningOutcomeIds) != null ? _b : [];
25454
- if (venueMarketOutcomeIds.length === 0) {
25455
- const error = new Error(claimNotificationLabels.missingOutcomeMessage);
25456
- console.error("[UserProfilePage] redeem failed", error);
25457
- const pendingId = pendingClaimToastIdsRef.current[claimKey];
25458
- if (pendingId != null) toastCtx == null ? void 0 : toastCtx.dismiss(pendingId);
25459
- delete pendingClaimToastIdsRef.current[claimKey];
25460
- toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.failedMessage(error.message), {
25461
- title: claimNotificationLabels.failedTitle,
25462
- tone: "error"
25463
- });
25464
- onClaimSubmitError == null ? void 0 : onClaimSubmitError(claimKey, error);
25465
- invalidateClaimUiState();
25466
- activeClaimKeysRef.current.delete(claimKey);
25467
- setSubmittingClaimKeys((prev) => {
25468
- const _a2 = prev, { [claimKey]: _removed } = _a2, rest = __objRest(_a2, [__restKey(claimKey)]);
25469
- return rest;
25470
- });
25471
- throw error;
25472
- }
25473
- try {
25474
- const response = yield redeemMutation.mutateAsync({ venueMarketOutcomeIds });
25475
- const expectedOutcomeIds = [];
25476
- const preFailedOutcomeIds = [];
25477
- const preFailedReasons = {};
25478
- const preConfirmedOutcomeIds = [];
25479
- const preConfirmedTxHashes = {};
25480
- for (const result of response.results) {
25481
- if (result.status === "submitted") {
25482
- expectedOutcomeIds.push(result.venueMarketOutcomeId);
25483
- } else if (result.status === "confirmed") {
25484
- preConfirmedOutcomeIds.push(result.venueMarketOutcomeId);
25485
- preConfirmedTxHashes[result.venueMarketOutcomeId] = result.txHash;
25486
- } else if (result.status === "ineligible" || result.status === "rejected") {
25487
- preFailedOutcomeIds.push(result.venueMarketOutcomeId);
25488
- preFailedReasons[result.venueMarketOutcomeId] = result.reason;
25489
- }
25490
- }
25491
- if (expectedOutcomeIds.length > 0) {
25492
- const pendingId = pendingClaimToastIdsRef.current[claimKey];
25493
- if (pendingId != null) toastCtx == null ? void 0 : toastCtx.dismiss(pendingId);
25494
- delete pendingClaimToastIdsRef.current[claimKey];
25495
- submittedClaimToastKeysRef.current.add(claimKey);
25496
- toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.submittedMessage, {
25497
- title: claimNotificationLabels.submittedTitle,
25498
- tone: "success"
25499
- });
25500
- }
25501
- setActiveRedeems((prev) => __spreadProps(__spreadValues({}, prev), {
25502
- [claimKey]: {
25503
- redeemId: response.redeemId,
25504
- expectedOutcomeIds,
25505
- preFailedOutcomeIds,
25506
- preFailedReasons,
25507
- preConfirmedOutcomeIds,
25508
- preConfirmedTxHashes
25509
- }
25510
- }));
25511
- yield queryClient.invalidateQueries({ queryKey: ["current-user"] });
25512
- } catch (err) {
25513
- const error = toClaimError(err);
25514
- console.error("[UserProfilePage] redeem failed", error);
25515
- const pendingId = pendingClaimToastIdsRef.current[claimKey];
25516
- if (pendingId != null) toastCtx == null ? void 0 : toastCtx.dismiss(pendingId);
25517
- delete pendingClaimToastIdsRef.current[claimKey];
25518
- toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.failedMessage(error.message), {
25519
- title: claimNotificationLabels.failedTitle,
25520
- tone: "error"
25521
- });
25522
- onClaimSubmitError == null ? void 0 : onClaimSubmitError(claimKey, error);
25523
- throw error;
25787
+ const fromBalance = (_a = balanceState.connectedVenues) != null ? _a : [];
25788
+ return [...new Set(fromBalance)].sort((a, b) => a.localeCompare(b));
25789
+ }, [balanceState, shouldUseHookData]);
25790
+ const [positionFilter, setPositionFilter] = (0, import_react42.useState)(initialPositionFilter);
25791
+ const resolvedExecutionMode = executionMode != null ? executionMode : configuredExecutionMode;
25792
+ const queryExecutionMode = resolvedExecutionMode === "paper" ? "paper" : void 0;
25793
+ const activePositionsQuery = (0, import_hooks65.useExecutionPositions)({
25794
+ enabled: shouldUseHookData && isAuthenticated,
25795
+ status: "active",
25796
+ limit: 25,
25797
+ mode: queryExecutionMode
25798
+ });
25799
+ const closedPositionsQuery = (0, import_hooks65.useExecutionPositions)({
25800
+ enabled: shouldUseHookData && isAuthenticated,
25801
+ status: "closed",
25802
+ limit: 25,
25803
+ mode: queryExecutionMode
25804
+ });
25805
+ const handlePositionFilterChange = (0, import_react42.useCallback)(
25806
+ (filter) => {
25807
+ setPositionFilter(filter);
25808
+ onPositionFilterChangeProp == null ? void 0 : onPositionFilterChangeProp(filter);
25809
+ },
25810
+ [onPositionFilterChangeProp]
25811
+ );
25812
+ (0, import_react42.useEffect)(() => {
25813
+ setPositionFilter(initialPositionFilter);
25814
+ }, [initialPositionFilter]);
25815
+ const ordersQuery = (0, import_hooks65.useExecutionOrders)({
25816
+ enabled: shouldUseHookData && isAuthenticated,
25817
+ limit: 25,
25818
+ mode: queryExecutionMode
25819
+ });
25820
+ const activityQuery = (0, import_hooks65.useUserActivity)({
25821
+ enabled: shouldUseHookData && isAuthenticated,
25822
+ limit: 25
25823
+ });
25824
+ const handleCancelOrder = (0, import_react42.useCallback)(
25825
+ (order) => __async(null, null, function* () {
25826
+ if (onCancelOrder) {
25827
+ onCancelOrder(order);
25828
+ return;
25829
+ }
25830
+ setInternalCancellingIds((prev) => __spreadProps(__spreadValues({}, prev), { [order.id]: true }));
25831
+ try {
25832
+ yield client.cancelManagedOrder(order.id);
25833
+ yield queryClient.invalidateQueries({ queryKey: ["execution-orders"] });
25524
25834
  } finally {
25525
- activeClaimKeysRef.current.delete(claimKey);
25526
- setSubmittingClaimKeys((prev) => {
25527
- const _a2 = prev, { [claimKey]: _removed } = _a2, rest = __objRest(_a2, [__restKey(claimKey)]);
25835
+ setInternalCancellingIds((prev) => {
25836
+ var _a;
25837
+ const _b = prev, { [_a = order.id]: _removed } = _b, rest = __objRest(_b, [__restKey(_a)]);
25528
25838
  return rest;
25529
25839
  });
25530
25840
  }
25531
25841
  }),
25532
- [
25533
- claimingPositionKeys,
25534
- claimNotificationLabels,
25535
- invalidateClaimUiState,
25536
- internalClaimingIds,
25537
- onClaim,
25538
- onClaimSubmitError,
25539
- queryClient,
25540
- redeemMutation,
25541
- toastCtx
25542
- ]
25842
+ [client, onCancelOrder, queryClient]
25543
25843
  );
25544
- const firedTerminalRef = (0, import_react40.useRef)({});
25545
- (0, import_react40.useEffect)(() => {
25546
- var _a, _b;
25547
- for (const [claimKey, active] of Object.entries(activeRedeems)) {
25548
- const state = lifecycleStates[active.redeemId];
25549
- if (!state || !state.terminal) continue;
25550
- if (firedTerminalRef.current[active.redeemId]) continue;
25551
- firedTerminalRef.current[active.redeemId] = true;
25552
- onClaimResult == null ? void 0 : onClaimResult(claimKey, {
25553
- allConfirmed: state.allConfirmed,
25554
- anyFailed: state.anyFailed,
25555
- errorMessage: state.errorMessage
25556
- });
25557
- const pendingId = pendingClaimToastIdsRef.current[claimKey];
25558
- if (pendingId != null) toastCtx == null ? void 0 : toastCtx.dismiss(pendingId);
25559
- delete pendingClaimToastIdsRef.current[claimKey];
25560
- if (state.allConfirmed) {
25561
- if (!submittedClaimToastKeysRef.current.has(claimKey)) {
25562
- toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.successMessage, {
25563
- title: claimNotificationLabels.successTitle,
25564
- tone: "success"
25565
- });
25566
- }
25567
- } else if (state.anyFailed) {
25568
- const hasConfirmedLeg = Object.values(state.legs).some((leg) => leg.status === "confirmed");
25569
- if (hasConfirmedLeg) {
25570
- toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.partialMessage((_a = state.errorMessage) != null ? _a : void 0), {
25571
- title: claimNotificationLabels.partialTitle,
25572
- tone: "warning"
25573
- });
25574
- } else {
25575
- toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.failedMessage((_b = state.errorMessage) != null ? _b : void 0), {
25576
- title: claimNotificationLabels.failedTitle,
25577
- tone: "error"
25578
- });
25579
- }
25580
- }
25581
- submittedClaimToastKeysRef.current.delete(claimKey);
25582
- invalidateClaimUiState();
25583
- delete firedTerminalRef.current[active.redeemId];
25584
- setActiveRedeems((prev) => {
25585
- const _a2 = prev, { [claimKey]: _removed } = _a2, rest = __objRest(_a2, [__restKey(claimKey)]);
25586
- return rest;
25844
+ const handleClaimPosition = (0, import_react42.useCallback)(
25845
+ (position) => {
25846
+ var _a, _b;
25847
+ return startClaim({
25848
+ claimKey: (_a = position.marketId) != null ? _a : position.id,
25849
+ winningOutcomeIds: (_b = position.winningOutcomeIds) != null ? _b : [],
25850
+ payload: position
25587
25851
  });
25588
- }
25589
- }, [
25590
- activeRedeems,
25591
- claimNotificationLabels,
25592
- invalidateClaimUiState,
25593
- lifecycleStates,
25594
- onClaimResult,
25595
- toastCtx
25596
- ]);
25597
- (0, import_react40.useEffect)(() => {
25852
+ },
25853
+ [startClaim]
25854
+ );
25855
+ (0, import_react42.useEffect)(() => {
25598
25856
  if (!shouldUseHookData || !isAuthenticated) {
25599
25857
  setProfileUser(void 0);
25600
25858
  return;
@@ -25613,11 +25871,11 @@ var UserProfilePage = ({
25613
25871
  isActive = false;
25614
25872
  };
25615
25873
  }, [client, currentUser, isAuthenticated, shouldUseHookData]);
25616
- const resolvedUser = (0, import_react40.useMemo)(() => {
25874
+ const resolvedUser = (0, import_react42.useMemo)(() => {
25617
25875
  var _a, _b, _c, _d, _e, _f;
25618
25876
  if (user) return user;
25619
25877
  const fullUser = profileUser != null ? profileUser : currentUser;
25620
- const walletAddress = (0, import_hooks63.getWalletAddressFromUserProfile)(fullUser);
25878
+ const walletAddress = (0, import_hooks65.getWalletAddressFromUserProfile)(fullUser);
25621
25879
  const fallbackUsername = walletAddress && shortenAddress(walletAddress) || "username";
25622
25880
  const twitterAccount = (_a = fullUser == null ? void 0 : fullUser.accounts) == null ? void 0 : _a.find(
25623
25881
  (account) => String(account.provider).toLowerCase() === "twitter"
@@ -25647,7 +25905,7 @@ var UserProfilePage = ({
25647
25905
  socialHandle: normalizedTwitterHandle != null ? normalizedTwitterHandle : void 0
25648
25906
  };
25649
25907
  }, [connectedVenues, currentUser, profileUser, user]);
25650
- const _resolvedVenueBalances = (0, import_react40.useMemo)(() => {
25908
+ const _resolvedVenueBalances = (0, import_react42.useMemo)(() => {
25651
25909
  if (_venueBalances) return _venueBalances;
25652
25910
  return balanceState.balanceBreakdown.map((item) => ({
25653
25911
  chain: item.label,
@@ -25655,7 +25913,7 @@ var UserProfilePage = ({
25655
25913
  balanceLabel: formatUsd2(item.balance)
25656
25914
  }));
25657
25915
  }, [_venueBalances, balanceState.balanceBreakdown]);
25658
- const positionsValueLabel = (0, import_react40.useMemo)(() => {
25916
+ const positionsValueLabel = (0, import_react42.useMemo)(() => {
25659
25917
  var _a;
25660
25918
  if (balance == null ? void 0 : balance.totalLabel) return balance.totalLabel;
25661
25919
  const managed = balanceState.managedBalances;
@@ -25663,13 +25921,13 @@ var UserProfilePage = ({
25663
25921
  const positionsValueTotal = positions.reduce((sum, p) => sum + (Number(p.balance) || 0), 0);
25664
25922
  return formatUsd2(positionsValueTotal);
25665
25923
  }, [balance, balanceState]);
25666
- const availableBalanceLabel = (0, import_react40.useMemo)(() => {
25924
+ const availableBalanceLabel = (0, import_react42.useMemo)(() => {
25667
25925
  var _a;
25668
25926
  return formatUsd2((_a = balanceState.totalBalance) != null ? _a : 0);
25669
25927
  }, [balanceState.totalBalance]);
25670
25928
  const isPositionsValueLoading = !(balance == null ? void 0 : balance.totalLabel) && balanceState.isLoading;
25671
25929
  const isAvailableBalanceLoading = balanceState.isLoading;
25672
- const resolvedActivities = (0, import_react40.useMemo)(() => {
25930
+ const resolvedActivities = (0, import_react42.useMemo)(() => {
25673
25931
  if (activities) return activities.filter(isVisibleUserProfileActivity);
25674
25932
  const formatTime = isHydrated ? toRelativeTimeLabel : toAbsoluteTimeLabel;
25675
25933
  return activityQuery.activities.filter(isVisibleActivityItem).map((item, index) => {
@@ -25818,7 +26076,7 @@ var UserProfilePage = ({
25818
26076
  };
25819
26077
  });
25820
26078
  }, [activities, activityQuery.activities, isHydrated, labels, ordersQuery.orders]);
25821
- const resolvedOpenOrders = (0, import_react40.useMemo)(() => {
26079
+ const resolvedOpenOrders = (0, import_react42.useMemo)(() => {
25822
26080
  if (openOrders) return openOrders;
25823
26081
  return ordersQuery.orders.filter((order) => isOpenOrderStatus(order.status)).map((order) => {
25824
26082
  var _a, _b, _c, _d, _e, _f, _g;
@@ -25835,11 +26093,11 @@ var UserProfilePage = ({
25835
26093
  };
25836
26094
  });
25837
26095
  }, [openOrders, ordersQuery.orders]);
25838
- const adaptPositionGroups = (0, import_react40.useCallback)(
26096
+ const adaptPositionGroups = (0, import_react42.useCallback)(
25839
26097
  (groups) => {
25840
26098
  return groups.flatMap((group) => {
25841
26099
  var _a, _b, _c, _d;
25842
- const closedTotals = (0, import_hooks63.computeClosedPositionTotals)(group);
26100
+ const closedTotals = (0, import_hooks65.computeClosedPositionTotals)(group);
25843
26101
  const winningOutcome = group.venueMarket.venueMarketOutcomes.find(
25844
26102
  (outcome) => outcome.winner === true
25845
26103
  );
@@ -25905,11 +26163,11 @@ var UserProfilePage = ({
25905
26163
  },
25906
26164
  []
25907
26165
  );
25908
- const resolvedActivePositions = (0, import_react40.useMemo)(() => {
26166
+ const resolvedActivePositions = (0, import_react42.useMemo)(() => {
25909
26167
  const source = activePositions != null ? activePositions : adaptPositionGroups(activePositionsQuery.positions);
25910
26168
  return source.filter(shouldIncludeByShares);
25911
26169
  }, [activePositions, activePositionsQuery.positions, adaptPositionGroups]);
25912
- const resolvedClosedPositions = (0, import_react40.useMemo)(() => {
26170
+ const resolvedClosedPositions = (0, import_react42.useMemo)(() => {
25913
26171
  const source = closedPositions != null ? closedPositions : adaptPositionGroups(closedPositionsQuery.positions);
25914
26172
  return source.filter(shouldIncludeByShares);
25915
26173
  }, [closedPositions, closedPositionsQuery.positions, adaptPositionGroups]);
@@ -25998,7 +26256,7 @@ var UserProfilePage = ({
25998
26256
  onPositionClick,
25999
26257
  getPositionHref,
26000
26258
  onClaim: handleClaimPosition,
26001
- claimingPositionKeys: claimingPositionKeys != null ? claimingPositionKeys : internalClaimingIds,
26259
+ claimingPositionKeys: claimingKeys,
26002
26260
  onActivityClick,
26003
26261
  getActivityHref,
26004
26262
  onOpenOrderClick,
@@ -26044,9 +26302,9 @@ var UserProfilePage = ({
26044
26302
  UserProfilePage.displayName = "UserProfilePage";
26045
26303
 
26046
26304
  // src/deposit/index.tsx
26047
- var import_hooks74 = require("@agg-build/hooks");
26305
+ var import_hooks76 = require("@agg-build/hooks");
26048
26306
  var import_deposit = require("@agg-build/hooks/deposit");
26049
- var import_react43 = require("react");
26307
+ var import_react45 = require("react");
26050
26308
 
26051
26309
  // src/shared/constants.ts
26052
26310
  var USDC = {
@@ -26277,8 +26535,8 @@ var NETWORK_TO_CURRENCY_CODE = {
26277
26535
  };
26278
26536
 
26279
26537
  // src/deposit/steps/card-deposit.tsx
26280
- var import_hooks64 = require("@agg-build/hooks");
26281
- var import_react41 = require("react");
26538
+ var import_hooks66 = require("@agg-build/hooks");
26539
+ var import_react43 = require("react");
26282
26540
  var import_jsx_runtime165 = require("react/jsx-runtime");
26283
26541
  var CardDepositStep = ({
26284
26542
  amount,
@@ -26295,9 +26553,9 @@ var CardDepositStep = ({
26295
26553
  onNetworkChange,
26296
26554
  onContinue
26297
26555
  }) => {
26298
- const labels = (0, import_hooks64.useLabels)();
26299
- const [localAmount, setLocalAmount] = (0, import_react41.useState)(amount);
26300
- (0, import_react41.useEffect)(() => {
26556
+ const labels = (0, import_hooks66.useLabels)();
26557
+ const [localAmount, setLocalAmount] = (0, import_react43.useState)(amount);
26558
+ (0, import_react43.useEffect)(() => {
26301
26559
  setLocalAmount(amount);
26302
26560
  }, [amount]);
26303
26561
  const numericAmount = Number(localAmount) || 0;
@@ -26412,7 +26670,7 @@ var CardDepositStep = ({
26412
26670
  };
26413
26671
 
26414
26672
  // src/deposit/steps/card-payment-pending.tsx
26415
- var import_hooks65 = require("@agg-build/hooks");
26673
+ var import_hooks67 = require("@agg-build/hooks");
26416
26674
  var import_jsx_runtime166 = require("react/jsx-runtime");
26417
26675
  var CardPaymentPendingStep = ({
26418
26676
  providerName,
@@ -26421,7 +26679,7 @@ var CardPaymentPendingStep = ({
26421
26679
  onViewActivity,
26422
26680
  onChooseAnotherProvider
26423
26681
  }) => {
26424
- const labels = (0, import_hooks65.useLabels)();
26682
+ const labels = (0, import_hooks67.useLabels)();
26425
26683
  return /* @__PURE__ */ (0, import_jsx_runtime166.jsx)("div", { className: "relative", children: /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)(Modal.Body, { classNames: { root: "px-5 py-8 sm:px-8 sm:py-10" }, children: [
26426
26684
  /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
26427
26685
  "button",
@@ -26471,10 +26729,10 @@ var CardPaymentPendingStep = ({
26471
26729
  };
26472
26730
 
26473
26731
  // src/deposit/steps/card-provider.tsx
26474
- var import_hooks66 = require("@agg-build/hooks");
26732
+ var import_hooks68 = require("@agg-build/hooks");
26475
26733
  var import_jsx_runtime167 = require("react/jsx-runtime");
26476
26734
  var CardProviderItem = ({ provider, onSelect }) => {
26477
- const labels = (0, import_hooks66.useLabels)();
26735
+ const labels = (0, import_hooks68.useLabels)();
26478
26736
  const badgeText = provider.badge === "best" ? labels.deposit.cardFlow.providerBadges.best : provider.badge === "low-kyc" ? labels.deposit.cardFlow.providerBadges.lowKyc : void 0;
26479
26737
  return /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(
26480
26738
  "button",
@@ -26520,7 +26778,7 @@ var CardProviderStep = ({
26520
26778
  onSelectProvider,
26521
26779
  onRetry
26522
26780
  }) => {
26523
- const labels = (0, import_hooks66.useLabels)();
26781
+ const labels = (0, import_hooks68.useLabels)();
26524
26782
  return /* @__PURE__ */ (0, import_jsx_runtime167.jsxs)(import_jsx_runtime167.Fragment, { children: [
26525
26783
  /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(
26526
26784
  Modal.Header,
@@ -26584,7 +26842,7 @@ var CardProviderStep = ({
26584
26842
  };
26585
26843
 
26586
26844
  // src/deposit/steps/card-purchase-success.tsx
26587
- var import_hooks67 = require("@agg-build/hooks");
26845
+ var import_hooks69 = require("@agg-build/hooks");
26588
26846
  var import_jsx_runtime168 = require("react/jsx-runtime");
26589
26847
  var SummaryRow = ({ label: label2, value }) => /* @__PURE__ */ (0, import_jsx_runtime168.jsxs)("div", { className: "flex items-center justify-between border-b border-agg-separator py-2 last:border-b-0", children: [
26590
26848
  /* @__PURE__ */ (0, import_jsx_runtime168.jsx)("p", { className: "text-[12px] leading-4 font-agg-bold uppercase text-agg-muted-foreground", children: label2 }),
@@ -26595,7 +26853,7 @@ var CardPurchaseSuccessStep = ({
26595
26853
  onDone,
26596
26854
  onClose
26597
26855
  }) => {
26598
- const labels = (0, import_hooks67.useLabels)();
26856
+ const labels = (0, import_hooks69.useLabels)();
26599
26857
  return /* @__PURE__ */ (0, import_jsx_runtime168.jsx)("div", { className: "relative", children: /* @__PURE__ */ (0, import_jsx_runtime168.jsxs)(Modal.Body, { classNames: { root: "px-5 py-8 sm:px-8 sm:py-10" }, children: [
26600
26858
  /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(
26601
26859
  "button",
@@ -26630,10 +26888,10 @@ var CardPurchaseSuccessStep = ({
26630
26888
  };
26631
26889
 
26632
26890
  // src/deposit/steps/crypto-transfer.tsx
26633
- var import_hooks69 = require("@agg-build/hooks");
26891
+ var import_hooks71 = require("@agg-build/hooks");
26634
26892
 
26635
26893
  // src/shared/transfer-fee-summary.tsx
26636
- var import_hooks68 = require("@agg-build/hooks");
26894
+ var import_hooks70 = require("@agg-build/hooks");
26637
26895
  var import_jsx_runtime169 = require("react/jsx-runtime");
26638
26896
  var separator = /* @__PURE__ */ (0, import_jsx_runtime169.jsx)("span", { className: "text-agg-muted-foreground", "aria-hidden": "true", children: "\xB7" });
26639
26897
  var normalizeFeeLabel = (label2) => label2.replace(/\s*~\s*$/, "");
@@ -26643,7 +26901,7 @@ var TransferFeeSummary = ({
26643
26901
  minDeposit,
26644
26902
  eta
26645
26903
  }) => {
26646
- const labels = (0, import_hooks68.useLabels)();
26904
+ const labels = (0, import_hooks70.useLabels)();
26647
26905
  if (!estimate) return null;
26648
26906
  if (view === "deposit") {
26649
26907
  return /* @__PURE__ */ (0, import_jsx_runtime169.jsxs)("p", { className: "agg-type-label flex flex-wrap items-center gap-x-2 gap-y-1 text-agg-foreground", children: [
@@ -26749,7 +27007,7 @@ DepositQRCode.displayName = "DepositQRCode";
26749
27007
  // src/deposit/steps/crypto-transfer.tsx
26750
27008
  var import_jsx_runtime171 = require("react/jsx-runtime");
26751
27009
  var CryptoAddressLoadingState = () => {
26752
- const labels = (0, import_hooks69.useLabels)();
27010
+ const labels = (0, import_hooks71.useLabels)();
26753
27011
  const sendCryptoLabels = labels.deposit.sendCrypto;
26754
27012
  return /* @__PURE__ */ (0, import_jsx_runtime171.jsxs)(
26755
27013
  "div",
@@ -26794,11 +27052,11 @@ var CryptoTransferStep = ({
26794
27052
  onDone
26795
27053
  }) => {
26796
27054
  var _a;
26797
- const labels = (0, import_hooks69.useLabels)();
27055
+ const labels = (0, import_hooks71.useLabels)();
26798
27056
  const selectedNetworkOption = networkOptions.find((n) => n.value === selectedNetwork);
26799
27057
  const networkLogoUrl = (_a = selectedNetworkOption == null ? void 0 : selectedNetworkOption.iconUrl) != null ? _a : "";
26800
27058
  const networkLogo = selectedNetworkOption == null ? void 0 : selectedNetworkOption.icon;
26801
- const transferFeeEstimate = (0, import_hooks69.useWithdrawEstimate)({
27059
+ const transferFeeEstimate = (0, import_hooks71.useWithdrawEstimate)({
26802
27060
  amount: getEstimateAmountFromMinDeposit(minDeposit),
26803
27061
  selectedToken,
26804
27062
  selectedNetwork
@@ -26901,7 +27159,7 @@ var CryptoTransferStep = ({
26901
27159
  };
26902
27160
 
26903
27161
  // src/deposit/steps/deposit-method.tsx
26904
- var import_hooks70 = require("@agg-build/hooks");
27162
+ var import_hooks72 = require("@agg-build/hooks");
26905
27163
  var import_jsx_runtime172 = require("react/jsx-runtime");
26906
27164
  var DepositMethodCard = ({
26907
27165
  icon,
@@ -26954,7 +27212,7 @@ var DepositMethodStep = ({
26954
27212
  depositAddressesReady = true,
26955
27213
  onSelectMethod
26956
27214
  }) => {
26957
- const labels = (0, import_hooks70.useLabels)();
27215
+ const labels = (0, import_hooks72.useLabels)();
26958
27216
  return /* @__PURE__ */ (0, import_jsx_runtime172.jsxs)(import_jsx_runtime172.Fragment, { children: [
26959
27217
  /* @__PURE__ */ (0, import_jsx_runtime172.jsx)(Modal.Header, { title: labels.deposit.title, hideBorder: true }),
26960
27218
  /* @__PURE__ */ (0, import_jsx_runtime172.jsx)(Modal.Body, { classNames: { root: "px-5 pt-0 pb-6 sm:px-8 sm:pt-0 sm:pb-8" }, children: /* @__PURE__ */ (0, import_jsx_runtime172.jsxs)("div", { className: "flex flex-col gap-5", children: [
@@ -27003,7 +27261,7 @@ var DepositMethodStep = ({
27003
27261
  };
27004
27262
 
27005
27263
  // src/deposit/steps/wallet-form.tsx
27006
- var import_hooks71 = require("@agg-build/hooks");
27264
+ var import_hooks73 = require("@agg-build/hooks");
27007
27265
  var import_jsx_runtime173 = require("react/jsx-runtime");
27008
27266
  var WalletFormStep = ({
27009
27267
  walletLabel,
@@ -27027,7 +27285,7 @@ var WalletFormStep = ({
27027
27285
  onMax,
27028
27286
  onConfirm
27029
27287
  }) => {
27030
- const labels = (0, import_hooks71.useLabels)();
27288
+ const labels = (0, import_hooks73.useLabels)();
27031
27289
  const isConfirmEnabled = !isSubmitting && !isBalanceLoading && Number(amount) > 0 && Number(amount) <= walletBalance;
27032
27290
  return /* @__PURE__ */ (0, import_jsx_runtime173.jsxs)(import_jsx_runtime173.Fragment, { children: [
27033
27291
  /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(
@@ -27153,16 +27411,16 @@ var WalletFormStep = ({
27153
27411
  };
27154
27412
 
27155
27413
  // src/deposit/steps/wallet-processing.tsx
27156
- var import_hooks72 = require("@agg-build/hooks");
27157
- var import_react42 = require("react");
27414
+ var import_hooks74 = require("@agg-build/hooks");
27415
+ var import_react44 = require("react");
27158
27416
  var import_jsx_runtime174 = require("react/jsx-runtime");
27159
27417
  var WalletProcessingStep = ({
27160
27418
  steps,
27161
27419
  errorMessage,
27162
27420
  onComplete
27163
27421
  }) => {
27164
- const labels = (0, import_hooks72.useLabels)();
27165
- (0, import_react42.useEffect)(() => {
27422
+ const labels = (0, import_hooks74.useLabels)();
27423
+ (0, import_react44.useEffect)(() => {
27166
27424
  const allDone = steps.length > 0 && steps.every((s) => s.status === "complete");
27167
27425
  if (allDone) {
27168
27426
  onComplete();
@@ -27200,7 +27458,7 @@ var WalletProcessingStep = ({
27200
27458
  };
27201
27459
 
27202
27460
  // src/deposit/steps/wallet-success.tsx
27203
- var import_hooks73 = require("@agg-build/hooks");
27461
+ var import_hooks75 = require("@agg-build/hooks");
27204
27462
  var import_jsx_runtime175 = require("react/jsx-runtime");
27205
27463
  var SummaryRow2 = ({ label: label2, value }) => /* @__PURE__ */ (0, import_jsx_runtime175.jsxs)("div", { className: "flex items-center justify-between border-b border-agg-separator py-2 last:border-b-0", children: [
27206
27464
  /* @__PURE__ */ (0, import_jsx_runtime175.jsx)("p", { className: "text-[12px] leading-4 font-agg-bold uppercase text-agg-muted-foreground", children: label2 }),
@@ -27211,7 +27469,7 @@ var WalletSuccessStep = ({
27211
27469
  onDone,
27212
27470
  onClose
27213
27471
  }) => {
27214
- const labels = (0, import_hooks73.useLabels)();
27472
+ const labels = (0, import_hooks75.useLabels)();
27215
27473
  return /* @__PURE__ */ (0, import_jsx_runtime175.jsx)("div", { className: "relative", children: /* @__PURE__ */ (0, import_jsx_runtime175.jsxs)(Modal.Body, { classNames: { root: "px-5 py-8 sm:px-8 sm:py-10" }, children: [
27216
27474
  /* @__PURE__ */ (0, import_jsx_runtime175.jsx)(
27217
27475
  "button",
@@ -27331,49 +27589,49 @@ function DepositModalControlled({
27331
27589
  pendingCardPurchaseSummary
27332
27590
  }) {
27333
27591
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
27334
- const { isWeb3User } = (0, import_hooks74.useAggAuthState)();
27335
- const { walletActions } = (0, import_hooks74.useAggUiConfig)();
27336
- const labels = (0, import_hooks74.useLabels)();
27592
+ const { isWeb3User } = (0, import_hooks76.useAggAuthState)();
27593
+ const { walletActions } = (0, import_hooks76.useAggUiConfig)();
27594
+ const labels = (0, import_hooks76.useLabels)();
27337
27595
  const defaultMethod = isWeb3User ? "wallet" : "crypto";
27338
- const [step, setStep] = (0, import_react43.useState)(
27596
+ const [step, setStep] = (0, import_react45.useState)(
27339
27597
  () => pendingCardPurchaseSummary ? "card-success" : "method"
27340
27598
  );
27341
- const [highlightedMethod, setHighlightedMethod] = (0, import_react43.useState)(defaultMethod);
27342
- const walletSubmitInFlightRef = (0, import_react43.useRef)(false);
27343
- const walletDepositAttemptIdRef = (0, import_react43.useRef)(0);
27344
- const notifiedWalletDepositStatusesRef = (0, import_react43.useRef)(/* @__PURE__ */ new Set());
27345
- const [isWalletSubmitting, setIsWalletSubmitting] = (0, import_react43.useState)(false);
27346
- const [cardProviders, setCardProviders] = (0, import_react43.useState)([]);
27347
- const [quotesLoading, setQuotesLoading] = (0, import_react43.useState)(false);
27348
- const [quotesError, setQuotesError] = (0, import_react43.useState)(null);
27349
- const [sessionError, setSessionError] = (0, import_react43.useState)(null);
27350
- const [pendingProviderName, setPendingProviderName] = (0, import_react43.useState)("");
27351
- const [pendingProviderWalletAddress, setPendingProviderWalletAddress] = (0, import_react43.useState)("");
27352
- (0, import_react43.useEffect)(() => {
27599
+ const [highlightedMethod, setHighlightedMethod] = (0, import_react45.useState)(defaultMethod);
27600
+ const walletSubmitInFlightRef = (0, import_react45.useRef)(false);
27601
+ const walletDepositAttemptIdRef = (0, import_react45.useRef)(0);
27602
+ const notifiedWalletDepositStatusesRef = (0, import_react45.useRef)(/* @__PURE__ */ new Set());
27603
+ const [isWalletSubmitting, setIsWalletSubmitting] = (0, import_react45.useState)(false);
27604
+ const [cardProviders, setCardProviders] = (0, import_react45.useState)([]);
27605
+ const [quotesLoading, setQuotesLoading] = (0, import_react45.useState)(false);
27606
+ const [quotesError, setQuotesError] = (0, import_react45.useState)(null);
27607
+ const [sessionError, setSessionError] = (0, import_react45.useState)(null);
27608
+ const [pendingProviderName, setPendingProviderName] = (0, import_react45.useState)("");
27609
+ const [pendingProviderWalletAddress, setPendingProviderWalletAddress] = (0, import_react45.useState)("");
27610
+ (0, import_react45.useEffect)(() => {
27353
27611
  if (pendingCardPurchaseSummary) {
27354
27612
  clearPendingCardSession();
27355
27613
  setStep("card-success");
27356
27614
  }
27357
27615
  }, [pendingCardPurchaseSummary]);
27358
- const [walletChainId, setWalletChainId] = (0, import_react43.useState)("");
27359
- const [walletToken, setWalletToken] = (0, import_react43.useState)("");
27360
- const [sendChainId, setSendChainId] = (0, import_react43.useState)("");
27361
- const [sendToken, setSendToken] = (0, import_react43.useState)("");
27616
+ const [walletChainId, setWalletChainId] = (0, import_react45.useState)("");
27617
+ const [walletToken, setWalletToken] = (0, import_react45.useState)("");
27618
+ const [sendChainId, setSendChainId] = (0, import_react45.useState)("");
27619
+ const [sendToken, setSendToken] = (0, import_react45.useState)("");
27362
27620
  const {
27363
27621
  isReady,
27364
27622
  isTimedOut,
27365
27623
  error: addrError,
27366
27624
  supportedChains,
27367
27625
  getAddress
27368
- } = (0, import_hooks74.useDepositAddresses)({ enabled: open });
27369
- const fallbackNetworkOptions = (0, import_react43.useMemo)(() => mapNetworksToOptions(), []);
27370
- const networkOptions = (0, import_react43.useMemo)(() => {
27626
+ } = (0, import_hooks76.useDepositAddresses)({ enabled: open });
27627
+ const fallbackNetworkOptions = (0, import_react45.useMemo)(() => mapNetworksToOptions(), []);
27628
+ const networkOptions = (0, import_react45.useMemo)(() => {
27371
27629
  if (!(supportedChains == null ? void 0 : supportedChains.length)) return fallbackNetworkOptions;
27372
27630
  return withNetworkIcons(
27373
27631
  supportedChains.map((c) => ({ value: String(c.chainId), label: c.name }))
27374
27632
  );
27375
27633
  }, [supportedChains, fallbackNetworkOptions]);
27376
- const walletNetworkOptions = (0, import_react43.useMemo)(() => {
27634
+ const walletNetworkOptions = (0, import_react45.useMemo)(() => {
27377
27635
  if (!(supportedChains == null ? void 0 : supportedChains.length) || !connectedWalletKind) return networkOptions;
27378
27636
  const filtered = supportedChains.filter(
27379
27637
  (c) => connectedWalletKind === "solana" ? import_deposit.SVM_CHAIN_IDS.has(c.chainId) : !import_deposit.SVM_CHAIN_IDS.has(c.chainId)
@@ -27381,17 +27639,17 @@ function DepositModalControlled({
27381
27639
  if (filtered.length === 0) return networkOptions;
27382
27640
  return withNetworkIcons(filtered.map((c) => ({ value: String(c.chainId), label: c.name })));
27383
27641
  }, [supportedChains, networkOptions, connectedWalletKind]);
27384
- const walletTokenOptions = (0, import_react43.useMemo)(() => {
27642
+ const walletTokenOptions = (0, import_react45.useMemo)(() => {
27385
27643
  const chain = supportedChains == null ? void 0 : supportedChains.find((c) => String(c.chainId) === walletChainId);
27386
27644
  if (!chain) return withTokenIcons(DEFAULT_CURRENCY_OPTIONS);
27387
27645
  return withTokenIcons(chain.tokens.map((t) => ({ value: t.symbol, label: t.symbol })));
27388
27646
  }, [supportedChains, walletChainId]);
27389
- const sendTokenOptions = (0, import_react43.useMemo)(() => {
27647
+ const sendTokenOptions = (0, import_react45.useMemo)(() => {
27390
27648
  const chain = supportedChains == null ? void 0 : supportedChains.find((c) => String(c.chainId) === sendChainId);
27391
27649
  if (!chain) return withTokenIcons(DEFAULT_CURRENCY_OPTIONS);
27392
27650
  return withTokenIcons(chain.tokens.map((t) => ({ value: t.symbol, label: t.symbol })));
27393
27651
  }, [supportedChains, sendChainId]);
27394
- (0, import_react43.useEffect)(() => {
27652
+ (0, import_react45.useEffect)(() => {
27395
27653
  if (walletNetworkOptions.length > 0) {
27396
27654
  if (!walletChainId || !walletNetworkOptions.some((o) => o.value === walletChainId)) {
27397
27655
  const ethereumMainnetOption = walletNetworkOptions.find(
@@ -27402,30 +27660,30 @@ function DepositModalControlled({
27402
27660
  }
27403
27661
  }
27404
27662
  }, [walletNetworkOptions, walletChainId, initialWalletChainId]);
27405
- (0, import_react43.useEffect)(() => {
27663
+ (0, import_react45.useEffect)(() => {
27406
27664
  if (networkOptions.length > 0) {
27407
27665
  if (!sendChainId || !networkOptions.some((o) => o.value === sendChainId)) {
27408
27666
  setSendChainId(networkOptions[0].value);
27409
27667
  }
27410
27668
  }
27411
27669
  }, [networkOptions, sendChainId]);
27412
- (0, import_react43.useEffect)(() => {
27670
+ (0, import_react45.useEffect)(() => {
27413
27671
  var _a2, _b2;
27414
27672
  if (walletTokenOptions.length > 0) {
27415
27673
  const preferredToken = (_b2 = (_a2 = walletTokenOptions.find((option) => option.value === DEFAULT_WALLET_TOKEN)) == null ? void 0 : _a2.value) != null ? _b2 : walletTokenOptions[0].value;
27416
27674
  setWalletToken(preferredToken);
27417
27675
  }
27418
27676
  }, [walletTokenOptions]);
27419
- (0, import_react43.useEffect)(() => {
27677
+ (0, import_react45.useEffect)(() => {
27420
27678
  var _a2, _b2;
27421
27679
  setSendToken((_b2 = (_a2 = sendTokenOptions == null ? void 0 : sendTokenOptions[0]) == null ? void 0 : _a2.value) != null ? _b2 : "");
27422
27680
  }, [sendTokenOptions]);
27423
- (0, import_react43.useEffect)(() => {
27681
+ (0, import_react45.useEffect)(() => {
27424
27682
  if (walletChainId) {
27425
27683
  onWalletNetworkChange == null ? void 0 : onWalletNetworkChange(walletChainId);
27426
27684
  }
27427
27685
  }, [walletChainId, onWalletNetworkChange]);
27428
- (0, import_react43.useEffect)(() => {
27686
+ (0, import_react45.useEffect)(() => {
27429
27687
  if (walletToken) {
27430
27688
  onWalletTokenChange == null ? void 0 : onWalletTokenChange(walletToken);
27431
27689
  }
@@ -27444,7 +27702,7 @@ function DepositModalControlled({
27444
27702
  fromWallet: walletFlow.walletLabel,
27445
27703
  gasFee: ""
27446
27704
  }, walletFlow.successSummary);
27447
- const handleWalletDepositNotification = (0, import_react43.useCallback)(
27705
+ const handleWalletDepositNotification = (0, import_react45.useCallback)(
27448
27706
  (status, errorMessage) => {
27449
27707
  if (notifiedWalletDepositStatusesRef.current.has(status)) return;
27450
27708
  notifiedWalletDepositStatusesRef.current.add(status);
@@ -27458,13 +27716,13 @@ function DepositModalControlled({
27458
27716
  },
27459
27717
  [walletFlow.amount, walletToken]
27460
27718
  );
27461
- (0, import_react43.useEffect)(() => {
27719
+ (0, import_react45.useEffect)(() => {
27462
27720
  if (step === "wallet-processing" && !isWalletSubmitting && walletFlow.transactionStatus === "settled") {
27463
27721
  handleWalletDepositNotification("completed");
27464
27722
  setStep("wallet-success");
27465
27723
  }
27466
27724
  }, [handleWalletDepositNotification, isWalletSubmitting, step, walletFlow.transactionStatus]);
27467
- (0, import_react43.useEffect)(() => {
27725
+ (0, import_react45.useEffect)(() => {
27468
27726
  if (!onCancelWalletDeposit) return;
27469
27727
  if (step === "wallet-processing" && !isWalletSubmitting && walletFlow.transactionStatus === "error") {
27470
27728
  walletSubmitInFlightRef.current = false;
@@ -27807,17 +28065,17 @@ var DepositModal = (props) => {
27807
28065
  DepositModal.displayName = "DepositModal";
27808
28066
 
27809
28067
  // src/withdraw/index.tsx
27810
- var import_react44 = require("react");
28068
+ var import_react46 = require("react");
27811
28069
  var import_withdraw = require("@agg-build/hooks/withdraw");
27812
28070
 
27813
28071
  // src/withdraw/steps/withdraw-method.tsx
27814
- var import_hooks75 = require("@agg-build/hooks");
28072
+ var import_hooks77 = require("@agg-build/hooks");
27815
28073
  var import_jsx_runtime177 = require("react/jsx-runtime");
27816
28074
  var WithdrawMethodStep = ({
27817
28075
  balance,
27818
28076
  onSelectMethod
27819
28077
  }) => {
27820
- const labels = (0, import_hooks75.useLabels)();
28078
+ const labels = (0, import_hooks77.useLabels)();
27821
28079
  return /* @__PURE__ */ (0, import_jsx_runtime177.jsxs)(import_jsx_runtime177.Fragment, { children: [
27822
28080
  /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(Modal.Header, { title: labels.withdraw.title, hideBorder: true }),
27823
28081
  /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(Modal.Body, { classNames: { root: "px-5 pt-0 pb-6 sm:px-8 sm:pt-0 sm:pb-8" }, children: /* @__PURE__ */ (0, import_jsx_runtime177.jsxs)("div", { className: "flex flex-col gap-5", children: [
@@ -27857,7 +28115,7 @@ var WithdrawMethodStep = ({
27857
28115
  };
27858
28116
 
27859
28117
  // src/withdraw/steps/withdraw-amount.tsx
27860
- var import_hooks76 = require("@agg-build/hooks");
28118
+ var import_hooks78 = require("@agg-build/hooks");
27861
28119
  var import_jsx_runtime178 = require("react/jsx-runtime");
27862
28120
  var formatRawTokenAmount = (rawAmount, decimals) => {
27863
28121
  if (!rawAmount) return "0";
@@ -27902,7 +28160,7 @@ var WithdrawAmountStep = ({
27902
28160
  onContinue
27903
28161
  }) => {
27904
28162
  var _a, _b, _c, _d;
27905
- const labels = (0, import_hooks76.useLabels)();
28163
+ const labels = (0, import_hooks78.useLabels)();
27906
28164
  const SOLANA_CHAIN_ID = "792703809";
27907
28165
  const isSolanaDest = selectedNetwork === SOLANA_CHAIN_ID;
27908
28166
  const trimmedDestination = destinationWallet.trim();
@@ -27910,7 +28168,7 @@ var WithdrawAmountStep = ({
27910
28168
  const isValid = Number(amount) > 0 && isValidAddress;
27911
28169
  const amountRaw = amount && Number(amount) > 0 ? parseTokenAmountToRaw(amount, destDecimals) : null;
27912
28170
  const destinationChainId = Number(selectedNetwork) || null;
27913
- const preview = (0, import_hooks76.useWithdrawPreview)({
28171
+ const preview = (0, import_hooks78.useWithdrawPreview)({
27914
28172
  amountRaw,
27915
28173
  tokenSymbol: selectedToken || null,
27916
28174
  destinationChainId,
@@ -28049,7 +28307,7 @@ var WithdrawAmountStep = ({
28049
28307
  };
28050
28308
 
28051
28309
  // src/withdraw/steps/withdraw-success.tsx
28052
- var import_hooks77 = require("@agg-build/hooks");
28310
+ var import_hooks79 = require("@agg-build/hooks");
28053
28311
  var import_jsx_runtime179 = require("react/jsx-runtime");
28054
28312
  var SummaryRow3 = ({ label: label2, value }) => /* @__PURE__ */ (0, import_jsx_runtime179.jsxs)("div", { className: "flex items-center justify-between gap-4 border-b border-agg-separator py-2 last:border-b-0", children: [
28055
28313
  /* @__PURE__ */ (0, import_jsx_runtime179.jsx)("p", { className: "min-w-0 text-[12px] leading-4 font-agg-bold uppercase text-agg-muted-foreground", children: label2 }),
@@ -28094,10 +28352,10 @@ var WithdrawLoadingStep = ({
28094
28352
  lifecycleState,
28095
28353
  onClose
28096
28354
  }) => {
28097
- const labels = (0, import_hooks77.useLabels)();
28355
+ const labels = (0, import_hooks79.useLabels)();
28098
28356
  const {
28099
28357
  features: { enableAnimations }
28100
- } = (0, import_hooks77.useSdkUiConfig)();
28358
+ } = (0, import_hooks79.useSdkUiConfig)();
28101
28359
  const walletFlowLabels = labels.withdraw.walletFlow;
28102
28360
  const activeIndex = loadingActiveIndexFor(lifecycleState);
28103
28361
  const loadingSteps = getLoadingSteps(walletFlowLabels);
@@ -28181,7 +28439,7 @@ var WithdrawSuccessStep = ({
28181
28439
  onRetry,
28182
28440
  onClose
28183
28441
  }) => {
28184
- const labels = (0, import_hooks77.useLabels)();
28442
+ const labels = (0, import_hooks79.useLabels)();
28185
28443
  const walletFlowLabels = labels.withdraw.walletFlow;
28186
28444
  const { title: title2, description } = resultCopyFor({
28187
28445
  status: resultStatus,
@@ -28339,14 +28597,14 @@ function WithdrawModalControlled({
28339
28597
  onSelectWithdrawProvider,
28340
28598
  onDoneWithdraw
28341
28599
  }) {
28342
- const [flowState, setFlowState] = (0, import_react44.useState)({
28600
+ const [flowState, setFlowState] = (0, import_react46.useState)({
28343
28601
  status: "form",
28344
28602
  formStep: "method"
28345
28603
  });
28346
- const [isConfirming, setIsConfirming] = (0, import_react44.useState)(false);
28347
- const [confirmError, setConfirmError] = (0, import_react44.useState)(null);
28604
+ const [isConfirming, setIsConfirming] = (0, import_react46.useState)(false);
28605
+ const [confirmError, setConfirmError] = (0, import_react46.useState)(null);
28348
28606
  const { state: withdrawalLifecycleState, reset: resetWithdrawalLifecycle } = (0, import_withdraw.useWithdrawalLifecycle)(withdrawFlow.withdrawalId);
28349
- (0, import_react44.useEffect)(() => {
28607
+ (0, import_react46.useEffect)(() => {
28350
28608
  if (!open) {
28351
28609
  setFlowState({ status: "form", formStep: "method" });
28352
28610
  setIsConfirming(false);
@@ -28354,7 +28612,7 @@ function WithdrawModalControlled({
28354
28612
  resetWithdrawalLifecycle();
28355
28613
  }
28356
28614
  }, [open, resetWithdrawalLifecycle]);
28357
- (0, import_react44.useEffect)(() => {
28615
+ (0, import_react46.useEffect)(() => {
28358
28616
  if (flowState.status !== "loading") return;
28359
28617
  if (!withdrawalLifecycleState.terminal) return;
28360
28618
  if (withdrawalLifecycleState.status === "completed") {
@@ -28488,8 +28746,8 @@ var WithdrawModal = (props) => {
28488
28746
  WithdrawModal.displayName = "WithdrawModal";
28489
28747
 
28490
28748
  // src/onboarding/index.tsx
28491
- var import_react49 = require("react");
28492
- var import_hooks83 = require("@agg-build/hooks");
28749
+ var import_react51 = require("react");
28750
+ var import_hooks85 = require("@agg-build/hooks");
28493
28751
  var Dialog7 = __toESM(require("@radix-ui/react-dialog"));
28494
28752
 
28495
28753
  // src/onboarding/onboarding-modal.constants.ts
@@ -28508,8 +28766,8 @@ var ONBOARDING_STEPS = {
28508
28766
  var ONCHAIN_VENUES = [import_sdk20.Venue.polymarket, import_sdk20.Venue.opinion, import_sdk20.Venue.predict];
28509
28767
 
28510
28768
  // src/onboarding/steps/how-it-works.tsx
28511
- var import_react45 = require("react");
28512
- var import_hooks78 = require("@agg-build/hooks");
28769
+ var import_react47 = require("react");
28770
+ var import_hooks80 = require("@agg-build/hooks");
28513
28771
  var import_jsx_runtime181 = require("react/jsx-runtime");
28514
28772
  var defaultIcons = {
28515
28773
  createAccount: /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(CreateAccountIcon, { className: "h-[28px] w-[28px] text-agg-muted-foreground" }),
@@ -28518,11 +28776,11 @@ var defaultIcons = {
28518
28776
  stayInControl: /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(StayInControlIcon, { className: "h-[28px] w-[28px] text-agg-muted-foreground" })
28519
28777
  };
28520
28778
  var HowItWorksStep = ({ onContinue, icons }) => {
28521
- const labels = (0, import_hooks78.useLabels)();
28522
- const scrollRef = (0, import_react45.useRef)(null);
28523
- const [showTopGradient, setShowTopGradient] = (0, import_react45.useState)(false);
28524
- const [showBottomGradient, setShowBottomGradient] = (0, import_react45.useState)(true);
28525
- const handleScroll = (0, import_react45.useCallback)(() => {
28779
+ const labels = (0, import_hooks80.useLabels)();
28780
+ const scrollRef = (0, import_react47.useRef)(null);
28781
+ const [showTopGradient, setShowTopGradient] = (0, import_react47.useState)(false);
28782
+ const [showBottomGradient, setShowBottomGradient] = (0, import_react47.useState)(true);
28783
+ const handleScroll = (0, import_react47.useCallback)(() => {
28526
28784
  const el = scrollRef.current;
28527
28785
  if (!el) return;
28528
28786
  setShowTopGradient(el.scrollTop > 0);
@@ -28591,20 +28849,20 @@ var HowItWorksStep = ({ onContinue, icons }) => {
28591
28849
  HowItWorksStep.displayName = "HowItWorksStep";
28592
28850
 
28593
28851
  // src/onboarding/steps/profile-setup.tsx
28594
- var import_react46 = require("react");
28595
- var import_hooks79 = require("@agg-build/hooks");
28852
+ var import_react48 = require("react");
28853
+ var import_hooks81 = require("@agg-build/hooks");
28596
28854
  var import_jsx_runtime182 = require("react/jsx-runtime");
28597
28855
  var ProfileSetupStep = ({ onContinue }) => {
28598
- const labels = (0, import_hooks79.useLabels)();
28599
- const [username, setUsername] = (0, import_react46.useState)("");
28600
- const [avatarFile, setAvatarFile] = (0, import_react46.useState)();
28601
- const [avatarPreview, setAvatarPreview] = (0, import_react46.useState)();
28602
- const fileInputRef = (0, import_react46.useRef)(null);
28603
- const handleAvatarClick = (0, import_react46.useCallback)(() => {
28856
+ const labels = (0, import_hooks81.useLabels)();
28857
+ const [username, setUsername] = (0, import_react48.useState)("");
28858
+ const [avatarFile, setAvatarFile] = (0, import_react48.useState)();
28859
+ const [avatarPreview, setAvatarPreview] = (0, import_react48.useState)();
28860
+ const fileInputRef = (0, import_react48.useRef)(null);
28861
+ const handleAvatarClick = (0, import_react48.useCallback)(() => {
28604
28862
  var _a;
28605
28863
  (_a = fileInputRef.current) == null ? void 0 : _a.click();
28606
28864
  }, []);
28607
- const handleFileChange = (0, import_react46.useCallback)((e) => {
28865
+ const handleFileChange = (0, import_react48.useCallback)((e) => {
28608
28866
  var _a;
28609
28867
  const file = (_a = e.target.files) == null ? void 0 : _a[0];
28610
28868
  if (!file) return;
@@ -28616,7 +28874,7 @@ var ProfileSetupStep = ({ onContinue }) => {
28616
28874
  };
28617
28875
  reader.readAsDataURL(file);
28618
28876
  }, []);
28619
- const handleContinue = (0, import_react46.useCallback)(() => {
28877
+ const handleContinue = (0, import_react48.useCallback)(() => {
28620
28878
  onContinue({
28621
28879
  username,
28622
28880
  avatarFile,
@@ -28726,7 +28984,7 @@ ProfileSetupStep.displayName = "ProfileSetupStep";
28726
28984
 
28727
28985
  // src/onboarding/steps/connect-accounts.tsx
28728
28986
  var import_sdk21 = require("@agg-build/sdk");
28729
- var import_hooks80 = require("@agg-build/hooks");
28987
+ var import_hooks82 = require("@agg-build/hooks");
28730
28988
  var import_jsx_runtime183 = require("react/jsx-runtime");
28731
28989
  var OnchainVenueLogos = () => {
28732
28990
  return /* @__PURE__ */ (0, import_jsx_runtime183.jsx)("div", { className: "flex gap-1 sm:gap-0 sm:-space-x-5", children: ONCHAIN_VENUES.map((venue, index) => /* @__PURE__ */ (0, import_jsx_runtime183.jsx)("div", { style: { zIndex: ONCHAIN_VENUES.length - index }, children: /* @__PURE__ */ (0, import_jsx_runtime183.jsx)(VenueLogo, { venue, variant: "logo", size: "medium", className: "sm:h-8 sm:w-8" }) }, venue)) });
@@ -28740,7 +28998,7 @@ var VenueCard = ({
28740
28998
  onConnect,
28741
28999
  connected = false
28742
29000
  }) => {
28743
- const labels = (0, import_hooks80.useLabels)();
29001
+ const labels = (0, import_hooks82.useLabels)();
28744
29002
  const action = connected ? /* @__PURE__ */ (0, import_jsx_runtime183.jsx)(CheckCircleIcon, { className: "h-6 w-6 text-agg-success" }) : /* @__PURE__ */ (0, import_jsx_runtime183.jsx)(
28745
29003
  Button,
28746
29004
  {
@@ -28801,7 +29059,7 @@ var ConnectAccountsStep = ({
28801
29059
  connectedOnchain = false,
28802
29060
  connectedKalshi = false
28803
29061
  }) => {
28804
- const labels = (0, import_hooks80.useLabels)();
29062
+ const labels = (0, import_hooks82.useLabels)();
28805
29063
  const canContinue = connectedOnchain || connectedKalshi;
28806
29064
  return /* @__PURE__ */ (0, import_jsx_runtime183.jsxs)("div", { className: "flex flex-col gap-6", children: [
28807
29065
  /* @__PURE__ */ (0, import_jsx_runtime183.jsx)("h2", { className: "text-center text-agg-2xl font-agg-bold text-agg-foreground", children: labels.onboarding.connectAccounts.title }),
@@ -28858,8 +29116,8 @@ ConnectAccountsStep.displayName = "ConnectAccountsStep";
28858
29116
 
28859
29117
  // src/onboarding/steps/connect-kalshi-modal.tsx
28860
29118
  var import_sdk22 = require("@agg-build/sdk");
28861
- var import_react47 = require("react");
28862
- var import_hooks81 = require("@agg-build/hooks");
29119
+ var import_react49 = require("react");
29120
+ var import_hooks83 = require("@agg-build/hooks");
28863
29121
  var Dialog5 = __toESM(require("@radix-ui/react-dialog"));
28864
29122
  var import_jsx_runtime184 = require("react/jsx-runtime");
28865
29123
  var ConnectKalshiModal = ({
@@ -28867,16 +29125,16 @@ var ConnectKalshiModal = ({
28867
29125
  onOpenChange,
28868
29126
  onVerify
28869
29127
  }) => {
28870
- const labels = (0, import_hooks81.useLabels)();
28871
- const [apiKeyId, setApiKeyId] = (0, import_react47.useState)("");
28872
- const [privateKey, setPrivateKey] = (0, import_react47.useState)("");
28873
- const [verifying, setVerifying] = (0, import_react47.useState)(false);
28874
- const [error, setError] = (0, import_react47.useState)();
29128
+ const labels = (0, import_hooks83.useLabels)();
29129
+ const [apiKeyId, setApiKeyId] = (0, import_react49.useState)("");
29130
+ const [privateKey, setPrivateKey] = (0, import_react49.useState)("");
29131
+ const [verifying, setVerifying] = (0, import_react49.useState)(false);
29132
+ const [error, setError] = (0, import_react49.useState)();
28875
29133
  const canVerify = apiKeyId.trim().length > 0 && privateKey.trim().length > 0;
28876
- const handleCancel = (0, import_react47.useCallback)(() => {
29134
+ const handleCancel = (0, import_react49.useCallback)(() => {
28877
29135
  onOpenChange(false);
28878
29136
  }, [onOpenChange]);
28879
- const handleVerify = (0, import_react47.useCallback)(() => __async(null, null, function* () {
29137
+ const handleVerify = (0, import_react49.useCallback)(() => __async(null, null, function* () {
28880
29138
  if (!canVerify || verifying) return;
28881
29139
  setVerifying(true);
28882
29140
  setError(void 0);
@@ -28905,7 +29163,7 @@ var ConnectKalshiModal = ({
28905
29163
  privateKey,
28906
29164
  verifying
28907
29165
  ]);
28908
- const handleOpenChange = (0, import_react47.useCallback)(
29166
+ const handleOpenChange = (0, import_react49.useCallback)(
28909
29167
  (value) => {
28910
29168
  if (value) {
28911
29169
  setApiKeyId("");
@@ -29108,8 +29366,8 @@ var ConnectKalshiModal = ({
29108
29366
  ConnectKalshiModal.displayName = "ConnectKalshiModal";
29109
29367
 
29110
29368
  // src/onboarding/steps/connect-onchain-modal.tsx
29111
- var import_react48 = require("react");
29112
- var import_hooks82 = require("@agg-build/hooks");
29369
+ var import_react50 = require("react");
29370
+ var import_hooks84 = require("@agg-build/hooks");
29113
29371
  var Dialog6 = __toESM(require("@radix-ui/react-dialog"));
29114
29372
  var import_jsx_runtime185 = require("react/jsx-runtime");
29115
29373
  var ConnectOnchainModal = ({
@@ -29117,13 +29375,13 @@ var ConnectOnchainModal = ({
29117
29375
  onOpenChange,
29118
29376
  onConnect
29119
29377
  }) => {
29120
- const labels = (0, import_hooks82.useLabels)();
29121
- const [connecting, setConnecting] = (0, import_react48.useState)(false);
29122
- const [error, setError] = (0, import_react48.useState)();
29123
- const handleCancel = (0, import_react48.useCallback)(() => {
29378
+ const labels = (0, import_hooks84.useLabels)();
29379
+ const [connecting, setConnecting] = (0, import_react50.useState)(false);
29380
+ const [error, setError] = (0, import_react50.useState)();
29381
+ const handleCancel = (0, import_react50.useCallback)(() => {
29124
29382
  onOpenChange(false);
29125
29383
  }, [onOpenChange]);
29126
- const handleConnect = (0, import_react48.useCallback)(() => __async(null, null, function* () {
29384
+ const handleConnect = (0, import_react50.useCallback)(() => __async(null, null, function* () {
29127
29385
  if (connecting) return;
29128
29386
  setConnecting(true);
29129
29387
  setError(void 0);
@@ -29138,7 +29396,7 @@ var ConnectOnchainModal = ({
29138
29396
  setConnecting(false);
29139
29397
  }
29140
29398
  }), [connecting, labels.onboarding.connectOnchainModal.fallbackError, onConnect, onOpenChange]);
29141
- const handleOpenChange = (0, import_react48.useCallback)(
29399
+ const handleOpenChange = (0, import_react50.useCallback)(
29142
29400
  (value) => {
29143
29401
  if (value) {
29144
29402
  setError(void 0);
@@ -29229,49 +29487,49 @@ var OnboardingModal = ({
29229
29487
  connectedKalshi = false
29230
29488
  }) => {
29231
29489
  var _a;
29232
- const labels = (0, import_hooks83.useLabels)();
29233
- const [step, setStep] = (0, import_react49.useState)(ONBOARDING_STEPS.HOW_IT_WORKS);
29490
+ const labels = (0, import_hooks85.useLabels)();
29491
+ const [step, setStep] = (0, import_react51.useState)(ONBOARDING_STEPS.HOW_IT_WORKS);
29234
29492
  const stepLabels = {
29235
29493
  [ONBOARDING_STEPS.HOW_IT_WORKS]: labels.onboarding.modal.stepHowItWorks,
29236
29494
  [ONBOARDING_STEPS.PROFILE_SETUP]: labels.onboarding.modal.stepProfileSetup,
29237
29495
  [ONBOARDING_STEPS.CONNECT_ACCOUNTS]: labels.onboarding.modal.stepConnectAccounts
29238
29496
  };
29239
29497
  const resolvedTitle = (_a = stepLabels[step]) != null ? _a : labels.onboarding.modal.title;
29240
- const [kalshiModalOpen, setKalshiModalOpen] = (0, import_react49.useState)(false);
29241
- const [kalshiConnected, setKalshiConnected] = (0, import_react49.useState)(false);
29242
- const [onchainModalOpen, setOnchainModalOpen] = (0, import_react49.useState)(false);
29243
- const [onchainConnected, setOnchainConnected] = (0, import_react49.useState)(false);
29244
- (0, import_react49.useEffect)(() => {
29498
+ const [kalshiModalOpen, setKalshiModalOpen] = (0, import_react51.useState)(false);
29499
+ const [kalshiConnected, setKalshiConnected] = (0, import_react51.useState)(false);
29500
+ const [onchainModalOpen, setOnchainModalOpen] = (0, import_react51.useState)(false);
29501
+ const [onchainConnected, setOnchainConnected] = (0, import_react51.useState)(false);
29502
+ (0, import_react51.useEffect)(() => {
29245
29503
  if (open) {
29246
29504
  setStep(ONBOARDING_STEPS.HOW_IT_WORKS);
29247
29505
  setKalshiConnected(false);
29248
29506
  setOnchainConnected(false);
29249
29507
  }
29250
29508
  }, [open]);
29251
- const handleHowItWorksContinue = (0, import_react49.useCallback)(() => {
29509
+ const handleHowItWorksContinue = (0, import_react51.useCallback)(() => {
29252
29510
  setStep(ONBOARDING_STEPS.PROFILE_SETUP);
29253
29511
  }, []);
29254
- const handleProfileContinue = (0, import_react49.useCallback)(
29512
+ const handleProfileContinue = (0, import_react51.useCallback)(
29255
29513
  (data) => {
29256
29514
  onProfileSubmit == null ? void 0 : onProfileSubmit(data);
29257
29515
  setStep(ONBOARDING_STEPS.CONNECT_ACCOUNTS);
29258
29516
  },
29259
29517
  [onProfileSubmit]
29260
29518
  );
29261
- const handleConnectContinue = (0, import_react49.useCallback)(() => {
29519
+ const handleConnectContinue = (0, import_react51.useCallback)(() => {
29262
29520
  onComplete == null ? void 0 : onComplete();
29263
29521
  }, [onComplete]);
29264
- const handleOpenOnchainModal = (0, import_react49.useCallback)(() => {
29522
+ const handleOpenOnchainModal = (0, import_react51.useCallback)(() => {
29265
29523
  setOnchainModalOpen(true);
29266
29524
  }, []);
29267
- const handleOnchainConnect = (0, import_react49.useCallback)(() => __async(null, null, function* () {
29525
+ const handleOnchainConnect = (0, import_react51.useCallback)(() => __async(null, null, function* () {
29268
29526
  yield onConnectOnchain == null ? void 0 : onConnectOnchain();
29269
29527
  setOnchainConnected(true);
29270
29528
  }), [onConnectOnchain]);
29271
- const handleOpenKalshiModal = (0, import_react49.useCallback)(() => {
29529
+ const handleOpenKalshiModal = (0, import_react51.useCallback)(() => {
29272
29530
  setKalshiModalOpen(true);
29273
29531
  }, []);
29274
- const handleKalshiVerify = (0, import_react49.useCallback)(
29532
+ const handleKalshiVerify = (0, import_react51.useCallback)(
29275
29533
  (credentials) => __async(null, null, function* () {
29276
29534
  yield onConnectKalshi == null ? void 0 : onConnectKalshi(credentials);
29277
29535
  setKalshiConnected(true);
@@ -29325,8 +29583,8 @@ var OnboardingModal = ({
29325
29583
  OnboardingModal.displayName = "OnboardingModal";
29326
29584
 
29327
29585
  // src/profile/index.tsx
29328
- var import_react52 = require("react");
29329
- var import_hooks86 = require("@agg-build/hooks");
29586
+ var import_react54 = require("react");
29587
+ var import_hooks88 = require("@agg-build/hooks");
29330
29588
 
29331
29589
  // src/profile/profile-modal.constants.ts
29332
29590
  var PROFILE_TAB_KEYS = {
@@ -29343,8 +29601,8 @@ var PROFILE_TAB_ITEMS = [
29343
29601
  ];
29344
29602
 
29345
29603
  // src/profile/tabs/about-tab.tsx
29346
- var import_react50 = require("react");
29347
- var import_hooks84 = require("@agg-build/hooks");
29604
+ var import_react52 = require("react");
29605
+ var import_hooks86 = require("@agg-build/hooks");
29348
29606
  var import_jsx_runtime187 = require("react/jsx-runtime");
29349
29607
  var AboutTab = ({
29350
29608
  avatarPreview,
@@ -29355,13 +29613,13 @@ var AboutTab = ({
29355
29613
  draftAvatarPreview,
29356
29614
  avatarError: _avatarError
29357
29615
  }) => {
29358
- const labels = (0, import_hooks84.useLabels)();
29359
- const fileInputRef = (0, import_react50.useRef)(null);
29360
- const handleAvatarClick = (0, import_react50.useCallback)(() => {
29616
+ const labels = (0, import_hooks86.useLabels)();
29617
+ const fileInputRef = (0, import_react52.useRef)(null);
29618
+ const handleAvatarClick = (0, import_react52.useCallback)(() => {
29361
29619
  var _a;
29362
29620
  (_a = fileInputRef.current) == null ? void 0 : _a.click();
29363
29621
  }, []);
29364
- const handleFileChange = (0, import_react50.useCallback)(
29622
+ const handleFileChange = (0, import_react52.useCallback)(
29365
29623
  (e) => {
29366
29624
  var _a;
29367
29625
  const file = (_a = e.target.files) == null ? void 0 : _a[0];
@@ -29630,8 +29888,8 @@ var AccountsWalletsTab = ({
29630
29888
  AccountsWalletsTab.displayName = "AccountsWalletsTab";
29631
29889
 
29632
29890
  // src/profile/tabs/trading-access-tab.tsx
29633
- var import_hooks85 = require("@agg-build/hooks");
29634
- var import_react51 = require("react");
29891
+ var import_hooks87 = require("@agg-build/hooks");
29892
+ var import_react53 = require("react");
29635
29893
  var import_jsx_runtime189 = require("react/jsx-runtime");
29636
29894
  var TRADING_ACCESS_VENUES = [
29637
29895
  "kalshi",
@@ -29657,15 +29915,15 @@ var AccessRow = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime189.jsx)
29657
29915
  }
29658
29916
  );
29659
29917
  var VerifyIdentityButton = ({ onError }) => {
29660
- const labels = (0, import_hooks85.useLabels)();
29661
- const client = (0, import_hooks85.useAggClient)();
29662
- const [isInitiating, setIsInitiating] = (0, import_react51.useState)(false);
29663
- const [needsDepositAddress, setNeedsDepositAddress] = (0, import_react51.useState)(false);
29664
- const { isReady, isTimedOut } = (0, import_hooks85.useDepositAddresses)({
29918
+ const labels = (0, import_hooks87.useLabels)();
29919
+ const client = (0, import_hooks87.useAggClient)();
29920
+ const [isInitiating, setIsInitiating] = (0, import_react53.useState)(false);
29921
+ const [needsDepositAddress, setNeedsDepositAddress] = (0, import_react53.useState)(false);
29922
+ const { isReady, isTimedOut } = (0, import_hooks87.useDepositAddresses)({
29665
29923
  enabled: needsDepositAddress,
29666
29924
  poll: true
29667
29925
  });
29668
- (0, import_react51.useEffect)(() => {
29926
+ (0, import_react53.useEffect)(() => {
29669
29927
  if (!isInitiating || !isReady) return;
29670
29928
  const redirectUri = window.location.href;
29671
29929
  client.initiateKyc("kalshi", redirectUri).then((res) => {
@@ -29679,13 +29937,13 @@ var VerifyIdentityButton = ({ onError }) => {
29679
29937
  setNeedsDepositAddress(false);
29680
29938
  });
29681
29939
  }, [isReady, isInitiating, client, onError]);
29682
- (0, import_react51.useEffect)(() => {
29940
+ (0, import_react53.useEffect)(() => {
29683
29941
  if (!isTimedOut || !isInitiating) return;
29684
29942
  setIsInitiating(false);
29685
29943
  setNeedsDepositAddress(false);
29686
29944
  onError == null ? void 0 : onError(new Error("Deposit address provisioning timed out"));
29687
29945
  }, [isTimedOut, isInitiating, onError]);
29688
- const handleClick = (0, import_react51.useCallback)(() => {
29946
+ const handleClick = (0, import_react53.useCallback)(() => {
29689
29947
  setIsInitiating(true);
29690
29948
  setNeedsDepositAddress(true);
29691
29949
  }, []);
@@ -29705,7 +29963,7 @@ var AvailableStatus = () => /* @__PURE__ */ (0, import_jsx_runtime189.jsxs)("div
29705
29963
  /* @__PURE__ */ (0, import_jsx_runtime189.jsx)("span", { className: "text-agg-sm font-agg-normal leading-agg-5 text-agg-foreground whitespace-nowrap", children: "Available" })
29706
29964
  ] });
29707
29965
  var GeoblockedStatus = () => {
29708
- const labels = (0, import_hooks85.useLabels)();
29966
+ const labels = (0, import_hooks87.useLabels)();
29709
29967
  return /* @__PURE__ */ (0, import_jsx_runtime189.jsxs)("div", { className: "flex items-center gap-2 text-agg-muted-foreground", children: [
29710
29968
  /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(Icon, { name: "warning-filled", size: "small", color: "currentColor" }),
29711
29969
  /* @__PURE__ */ (0, import_jsx_runtime189.jsx)("span", { className: "text-agg-sm font-agg-normal leading-agg-5 whitespace-nowrap", children: labels.trading.venueUnavailableInRegion })
@@ -29715,11 +29973,11 @@ var TradingAccessTab = ({
29715
29973
  venueAccounts,
29716
29974
  onKycError
29717
29975
  }) => {
29718
- const labels = (0, import_hooks85.useLabels)();
29719
- const { disabledVenues } = (0, import_hooks85.useAppConfig)();
29720
- const { isLocationBlocked } = (0, import_hooks85.useGeoBlock)();
29721
- const visibleVenues = (0, import_react51.useMemo)(
29722
- () => (0, import_hooks85.getVisibleVenuesByConfig)(TRADING_ACCESS_VENUE_ITEMS, disabledVenues),
29976
+ const labels = (0, import_hooks87.useLabels)();
29977
+ const { disabledVenues } = (0, import_hooks87.useAppConfig)();
29978
+ const { isLocationBlocked } = (0, import_hooks87.useGeoBlock)();
29979
+ const visibleVenues = (0, import_react53.useMemo)(
29980
+ () => (0, import_hooks87.getVisibleVenuesByConfig)(TRADING_ACCESS_VENUE_ITEMS, disabledVenues),
29723
29981
  [disabledVenues]
29724
29982
  );
29725
29983
  return /* @__PURE__ */ (0, import_jsx_runtime189.jsxs)("div", { className: "agg-trading-access-section flex flex-col gap-4", children: [
@@ -29729,7 +29987,7 @@ var TradingAccessTab = ({
29729
29987
  const venueAccount = venueAccounts == null ? void 0 : venueAccounts.find((account) => account.venue === venue);
29730
29988
  const isKalshi = venue === "kalshi";
29731
29989
  const isVerified = (venueAccount == null ? void 0 : venueAccount.kycStatus) === "verified";
29732
- const availabilityState = (0, import_hooks85.getVenueAvailabilityState)({
29990
+ const availabilityState = (0, import_hooks87.getVenueAvailabilityState)({
29733
29991
  venueId: venue,
29734
29992
  disabledVenues,
29735
29993
  isLocationBlocked
@@ -29776,21 +30034,21 @@ var ProfileModal = ({
29776
30034
  onKycError
29777
30035
  }) => {
29778
30036
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
29779
- const client = (0, import_hooks86.useAggClient)();
29780
- const { user, startAuth } = (0, import_hooks86.useAggAuthState)();
30037
+ const client = (0, import_hooks88.useAggClient)();
30038
+ const { user, startAuth } = (0, import_hooks88.useAggAuthState)();
29781
30039
  const toastCtx = useOptionalToast();
29782
- const [activeTab, setActiveTab] = (0, import_react52.useState)(PROFILE_TAB_KEYS.PROFILE_ACCOUNTS);
30040
+ const [activeTab, setActiveTab] = (0, import_react54.useState)(PROFILE_TAB_KEYS.PROFILE_ACCOUNTS);
29783
30041
  const resolvedInitialUsername = (_a = username != null ? username : user == null ? void 0 : user.username) != null ? _a : "";
29784
- const [draftUsername, setDraftUsername] = (0, import_react52.useState)(resolvedInitialUsername);
29785
- const [draftAvatarFile, setDraftAvatarFile] = (0, import_react52.useState)();
29786
- const [draftAvatarPreview, setDraftAvatarPreview] = (0, import_react52.useState)();
29787
- const [isSaving, setIsSaving] = (0, import_react52.useState)(false);
29788
- const [avatarTypeError, setAvatarTypeError] = (0, import_react52.useState)(null);
29789
- (0, import_react52.useEffect)(() => {
30042
+ const [draftUsername, setDraftUsername] = (0, import_react54.useState)(resolvedInitialUsername);
30043
+ const [draftAvatarFile, setDraftAvatarFile] = (0, import_react54.useState)();
30044
+ const [draftAvatarPreview, setDraftAvatarPreview] = (0, import_react54.useState)();
30045
+ const [isSaving, setIsSaving] = (0, import_react54.useState)(false);
30046
+ const [avatarTypeError, setAvatarTypeError] = (0, import_react54.useState)(null);
30047
+ (0, import_react54.useEffect)(() => {
29790
30048
  var _a2;
29791
30049
  setDraftUsername((_a2 = username != null ? username : user == null ? void 0 : user.username) != null ? _a2 : "");
29792
30050
  }, [username, user == null ? void 0 : user.username]);
29793
- const handleOpenChange = (0, import_react52.useCallback)(
30051
+ const handleOpenChange = (0, import_react54.useCallback)(
29794
30052
  (isOpen) => {
29795
30053
  var _a2;
29796
30054
  if (!isOpen) {
@@ -29814,7 +30072,7 @@ var ProfileModal = ({
29814
30072
  setDraftAvatarPreview
29815
30073
  ]
29816
30074
  );
29817
- const handleDraftAvatarChange = (0, import_react52.useCallback)(
30075
+ const handleDraftAvatarChange = (0, import_react54.useCallback)(
29818
30076
  (file, preview) => {
29819
30077
  const ACCEPTED_AVATAR_TYPES = ["image/jpeg", "image/png", "image/gif", "image/webp"];
29820
30078
  if (file && !ACCEPTED_AVATAR_TYPES.includes(file.type)) {
@@ -29829,7 +30087,7 @@ var ProfileModal = ({
29829
30087
  );
29830
30088
  const originalUsername = (_b = username != null ? username : user == null ? void 0 : user.username) != null ? _b : "";
29831
30089
  const hasChanges = draftUsername !== originalUsername || draftAvatarFile !== void 0;
29832
- const handleSave = (0, import_react52.useCallback)(() => __async(null, null, function* () {
30090
+ const handleSave = (0, import_react54.useCallback)(() => __async(null, null, function* () {
29833
30091
  var _a2, _b2, _c2;
29834
30092
  setIsSaving(true);
29835
30093
  try {
@@ -29884,7 +30142,7 @@ var ProfileModal = ({
29884
30142
  originalUsername,
29885
30143
  toastCtx
29886
30144
  ]);
29887
- const handleCancel = (0, import_react52.useCallback)(() => {
30145
+ const handleCancel = (0, import_react54.useCallback)(() => {
29888
30146
  handleOpenChange(false);
29889
30147
  }, [handleOpenChange]);
29890
30148
  const isAccountConnected = (providers) => {
@@ -29928,7 +30186,7 @@ var ProfileModal = ({
29928
30186
  if (typeof window === "undefined") return;
29929
30187
  ((_a2 = window.top) != null ? _a2 : window).location.assign(url);
29930
30188
  };
29931
- const handleConnectTwitter = (0, import_react52.useCallback)(() => __async(null, null, function* () {
30189
+ const handleConnectTwitter = (0, import_react54.useCallback)(() => __async(null, null, function* () {
29932
30190
  const result = yield startAuth({
29933
30191
  provider: "twitter",
29934
30192
  redirectUrl: resolveRedirectUrl()
@@ -29938,7 +30196,7 @@ var ProfileModal = ({
29938
30196
  navigateTopWindow(result.url);
29939
30197
  }
29940
30198
  }), [onConnectTwitter, startAuth]);
29941
- const handleConnectGoogle = (0, import_react52.useCallback)(() => __async(null, null, function* () {
30199
+ const handleConnectGoogle = (0, import_react54.useCallback)(() => __async(null, null, function* () {
29942
30200
  const result = yield startAuth({
29943
30201
  provider: "google",
29944
30202
  redirectUrl: resolveRedirectUrl()
@@ -29948,7 +30206,7 @@ var ProfileModal = ({
29948
30206
  navigateTopWindow(result.url);
29949
30207
  }
29950
30208
  }), [onConnectGoogle, startAuth]);
29951
- const handleConnectApple = (0, import_react52.useCallback)(() => __async(null, null, function* () {
30209
+ const handleConnectApple = (0, import_react54.useCallback)(() => __async(null, null, function* () {
29952
30210
  const result = yield startAuth({
29953
30211
  provider: "apple",
29954
30212
  redirectUrl: resolveRedirectUrl()
@@ -29958,22 +30216,22 @@ var ProfileModal = ({
29958
30216
  navigateTopWindow(result.url);
29959
30217
  }
29960
30218
  }), [onConnectApple, startAuth]);
29961
- const handleDisconnectTwitter = (0, import_react52.useCallback)(() => __async(null, null, function* () {
30219
+ const handleDisconnectTwitter = (0, import_react54.useCallback)(() => __async(null, null, function* () {
29962
30220
  yield client.disconnectAccount("twitter");
29963
30221
  yield client.getCurrentUser();
29964
30222
  onDisconnectTwitter == null ? void 0 : onDisconnectTwitter();
29965
30223
  }), [client, onDisconnectTwitter]);
29966
- const handleDisconnectGoogle = (0, import_react52.useCallback)(() => __async(null, null, function* () {
30224
+ const handleDisconnectGoogle = (0, import_react54.useCallback)(() => __async(null, null, function* () {
29967
30225
  yield client.disconnectAccount("google");
29968
30226
  yield client.getCurrentUser();
29969
30227
  onDisconnectGoogle == null ? void 0 : onDisconnectGoogle();
29970
30228
  }), [client, onDisconnectGoogle]);
29971
- const handleDisconnectApple = (0, import_react52.useCallback)(() => __async(null, null, function* () {
30229
+ const handleDisconnectApple = (0, import_react54.useCallback)(() => __async(null, null, function* () {
29972
30230
  yield client.disconnectAccount("apple");
29973
30231
  yield client.getCurrentUser();
29974
30232
  onDisconnectApple == null ? void 0 : onDisconnectApple();
29975
30233
  }), [client, onDisconnectApple]);
29976
- const handleConnectEmail = (0, import_react52.useCallback)(() => __async(null, null, function* () {
30234
+ const handleConnectEmail = (0, import_react54.useCallback)(() => __async(null, null, function* () {
29977
30235
  var _a2;
29978
30236
  const typedEmail = typeof window !== "undefined" ? (_a2 = window.prompt("Enter your email to receive a magic link")) == null ? void 0 : _a2.trim() : void 0;
29979
30237
  if (!typedEmail) return;
@@ -29984,7 +30242,7 @@ var ProfileModal = ({
29984
30242
  });
29985
30243
  onConnectEmail == null ? void 0 : onConnectEmail();
29986
30244
  }), [onConnectEmail, startAuth]);
29987
- const handleDisconnectWallet = (0, import_react52.useCallback)(
30245
+ const handleDisconnectWallet = (0, import_react54.useCallback)(
29988
30246
  (wallet) => __async(null, null, function* () {
29989
30247
  const normalizedChain = wallet.chain.toLowerCase();
29990
30248
  const provider = normalizedChain === "solana" || normalizedChain === "svm" ? "solana_wallet" : "wallet";
@@ -29994,7 +30252,7 @@ var ProfileModal = ({
29994
30252
  }),
29995
30253
  [client, onDisconnectWallet]
29996
30254
  );
29997
- const providerActionMap = (0, import_react52.useMemo)(
30255
+ const providerActionMap = (0, import_react54.useMemo)(
29998
30256
  () => ({
29999
30257
  twitter: {
30000
30258
  connect: () => {
@@ -30036,7 +30294,7 @@ var ProfileModal = ({
30036
30294
  handleDisconnectTwitter
30037
30295
  ]
30038
30296
  );
30039
- const resolvedWallets = (0, import_react52.useMemo)(() => {
30297
+ const resolvedWallets = (0, import_react54.useMemo)(() => {
30040
30298
  var _a2, _b2;
30041
30299
  if (wallets) return wallets;
30042
30300
  const walletAccounts = (_b2 = (_a2 = user == null ? void 0 : user.accounts) == null ? void 0 : _a2.filter((account) => {
@@ -30182,8 +30440,8 @@ var ProfileModal = ({
30182
30440
  ProfileModal.displayName = "ProfileModal";
30183
30441
 
30184
30442
  // src/geo-block-modal/index.tsx
30185
- var import_hooks87 = require("@agg-build/hooks");
30186
- var import_react53 = require("react");
30443
+ var import_hooks89 = require("@agg-build/hooks");
30444
+ var import_react55 = require("react");
30187
30445
  var import_jsx_runtime191 = require("react/jsx-runtime");
30188
30446
  var GeoBlockModal = ({
30189
30447
  open,
@@ -30191,8 +30449,8 @@ var GeoBlockModal = ({
30191
30449
  onConfirm,
30192
30450
  classNames
30193
30451
  }) => {
30194
- const labels = (0, import_hooks87.useLabels)();
30195
- const handleConfirm = (0, import_react53.useCallback)(() => {
30452
+ const labels = (0, import_hooks89.useLabels)();
30453
+ const handleConfirm = (0, import_react55.useCallback)(() => {
30196
30454
  onConfirm == null ? void 0 : onConfirm();
30197
30455
  onOpenChange(false);
30198
30456
  }, [onConfirm, onOpenChange]);
@@ -30430,9 +30688,11 @@ GeoBlockModal.displayName = "GeoBlockModal";
30430
30688
  toDate,
30431
30689
  typographyVariants,
30432
30690
  useCenterOrderbookSpread,
30691
+ useClaimWinnings,
30433
30692
  useEventTradingContext,
30434
30693
  useHomePageModals,
30435
30694
  useOptionalToast,
30695
+ useResolvedMarketClaim,
30436
30696
  useToast,
30437
30697
  venueLogoNames
30438
30698
  });