@liberfi.io/ui-portfolio 0.1.1 → 0.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.
package/dist/index.d.mts CHANGED
@@ -4,7 +4,9 @@ import { ReactNode, PropsWithChildren } from 'react';
4
4
  import { A as AssetTab, C as CurveType, a as CurvePeriod, P as PortfolioQuery, b as PortfolioOverview, c as CurveData, D as DistributionData, S as SpotHoldingsData, d as SpotHistoryData, e as PerpsPositionsData, f as PerpsHistoryData, g as PredictionBetsData, h as PredictionSettledData, i as SpotHolding, j as PerpsPosition, k as PredictionBet, I as IPortfolioClient, l as SpotHistoryQuery, m as PerpsHistoryQuery, n as PredictionSettledQuery, o as CurveQuery } from './index-Bm8Qidtb.mjs';
5
5
  export { p as CURVE_PERIOD_VALUE, w as ChartDataPointDTO, E as CurvePoint, F as DistributionItem, G as GetPortfolioChartReply, x as GetSpotHoldingsReply, z as GetTradeHistoryReply, q as PerpsPositionSide, H as PerpsTradeRecord, v as PortfolioOverviewDTO, s as PredictionBetStatus, t as PredictionResult, J as PredictionSettledRecord, u as PredictionSource, B as SpotHistoryRecord, r as SpotHistoryType, T as TokenHoldingDTO, y as TradeRecordDTO } from './index-Bm8Qidtb.mjs';
6
6
  import * as _tanstack_react_query from '@tanstack/react-query';
7
- import { UseQueryOptions } from '@tanstack/react-query';
7
+ import { UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
8
+ import { WalletPortfolios, WalletPnl, Chain } from '@liberfi.io/types';
9
+ import * as jotai from 'jotai';
8
10
 
9
11
  declare global {
10
12
  interface Window {
@@ -13,7 +15,7 @@ declare global {
13
15
  };
14
16
  }
15
17
  }
16
- declare const _default: "0.1.1";
18
+ declare const _default: "0.1.2";
17
19
 
18
20
  interface WalletOption {
19
21
  id: string;
@@ -284,6 +286,41 @@ declare function useDistributionQuery(holdings: SpotHolding[]): {
284
286
  data: DistributionData;
285
287
  };
286
288
 
289
+ /** Wallet summary: balance + PnL fields flattened */
290
+ type WalletSummary = Omit<WalletPortfolios, "portfolios"> & WalletPnl;
291
+ /** Async status derived from React Query */
292
+ type AsyncStatus = Pick<UseQueryResult, "status" | "fetchStatus" | "isLoading" | "isPending" | "isFetching" | "isRefetching" | "isError" | "isSuccess" | "error" | "dataUpdatedAt">;
293
+ /** Wallet balance + PnL summary */
294
+ declare const walletSummaryAtom: jotai.PrimitiveAtom<WalletSummary | null> & {
295
+ init: WalletSummary | null;
296
+ };
297
+ /** Async status for wallet summary */
298
+ declare const walletSummaryStatusAtom: jotai.PrimitiveAtom<AsyncStatus> & {
299
+ init: AsyncStatus;
300
+ };
301
+ /** Refetch function for wallet summary (wrapped in object to avoid Jotai treating function as read-only getter) */
302
+ type RefetchFn = () => Promise<void>;
303
+ declare const walletSummaryRefetchAtom: jotai.WritableAtom<RefetchFn, [fn: RefetchFn], void>;
304
+
305
+ interface UseWalletStateManagerParams {
306
+ chain: Chain;
307
+ address: string;
308
+ enabled?: boolean;
309
+ summaryPollMs?: number;
310
+ }
311
+ /**
312
+ * Mounts the wallet summary state engine: queries, polls, and subscribes to
313
+ * wallet balance + PnL summary, writing results to jotai atoms.
314
+ * Call this once near the top of the component tree.
315
+ */
316
+ declare function useWalletStateManager({ chain, address, enabled, summaryPollMs, }: UseWalletStateManagerParams): void;
317
+ /** Read wallet summary (balance + PnL flat) with async status. */
318
+ declare function useWalletSummary(): AsyncStatus & {
319
+ data: WalletSummary | null;
320
+ };
321
+ /** Returns a function that triggers a wallet summary refetch. */
322
+ declare function useRefetchWalletSummary(): () => Promise<void>;
323
+
287
324
  /**
288
325
  * Parse a decimal string to a number, returning 0 for empty / invalid values.
289
326
  */
@@ -339,4 +376,4 @@ declare function computeDistribution(holdings: SpotHolding[]): DistributionData;
339
376
  */
340
377
  declare function formatTime(epochMs: number): string;
341
378
 
342
- export { AddressRowUI, type AddressRowUIProps, AssetTab, AssetTabsUI, type AssetTabsUIProps, BalanceRowUI, type BalanceRowUIProps, BatchActionButton, type BatchActionButtonProps, ConfirmDialog, type ConfirmDialogProps, CurveCardUI, type CurveCardUIProps, CurveData, CurvePeriod, CurveQuery, CurveType, DistributionCardUI, type DistributionCardUIProps, DistributionData, HoldingsEmpty, type HoldingsEmptyProps, type HoldingsRenderProps, HoldingsSearch, type HoldingsSearchProps, HoldingsSectionWidget, type HoldingsSectionWidgetProps, HoldingsSubTabs, type HoldingsSubTabsProps, IPortfolioClient, PerpsHistoryData, PerpsHistoryQuery, PerpsPanelUI, type PerpsPanelUIProps, PerpsPosition, PerpsPositionsData, type PerpsSubTab, PortfolioContext, type PortfolioContextValue, PortfolioOverview, PortfolioPageSkeleton, PortfolioPageWidget, type PortfolioPageWidgetProps, PortfolioProvider, type PortfolioProviderProps, PortfolioQuery, PredictionBet, PredictionBetsData, PredictionPanelUI, type PredictionPanelUIProps, PredictionSettledData, PredictionSettledQuery, type PredictionSubTab, SpotHistoryData, SpotHistoryQuery, SpotHolding, SpotHoldingsData, SpotPanelUI, type SpotPanelUIProps, type SpotSubTab, type UseHoldingsSectionOptions, type UseHoldingsSectionResult, type UsePortfolioPageOptions, type UsePortfolioPageResult, ViewingBannerUI, type ViewingBannerUIProps, type WalletOption, computeDistribution, curveDataQueryKey, distributionQueryKey, formatPercent, formatSignedUsd, formatTime, formatTokenBalance, formatUsd, getExplorerUrl, overviewQueryKey, parseDecimal, perpsHistoryQueryKey, perpsPositionsQueryKey, predictionBetsQueryKey, predictionSettledQueryKey, splitUsd, spotHistoryQueryKey, spotHoldingsQueryKey, truncateAddress, useCurveDataQuery, useDistributionQuery, useHoldingsSection, useOverviewQuery, usePerpsHistoryQuery, usePerpsPositionsQuery, usePortfolioClient, usePortfolioContext, usePortfolioPage, usePredictionBetsQuery, usePredictionSettledQuery, useSpotHistoryQuery, useSpotHoldingsQuery, _default as version };
379
+ export { AddressRowUI, type AddressRowUIProps, AssetTab, AssetTabsUI, type AssetTabsUIProps, type AsyncStatus, BalanceRowUI, type BalanceRowUIProps, BatchActionButton, type BatchActionButtonProps, ConfirmDialog, type ConfirmDialogProps, CurveCardUI, type CurveCardUIProps, CurveData, CurvePeriod, CurveQuery, CurveType, DistributionCardUI, type DistributionCardUIProps, DistributionData, HoldingsEmpty, type HoldingsEmptyProps, type HoldingsRenderProps, HoldingsSearch, type HoldingsSearchProps, HoldingsSectionWidget, type HoldingsSectionWidgetProps, HoldingsSubTabs, type HoldingsSubTabsProps, IPortfolioClient, PerpsHistoryData, PerpsHistoryQuery, PerpsPanelUI, type PerpsPanelUIProps, PerpsPosition, PerpsPositionsData, type PerpsSubTab, PortfolioContext, type PortfolioContextValue, PortfolioOverview, PortfolioPageSkeleton, PortfolioPageWidget, type PortfolioPageWidgetProps, PortfolioProvider, type PortfolioProviderProps, PortfolioQuery, PredictionBet, PredictionBetsData, PredictionPanelUI, type PredictionPanelUIProps, PredictionSettledData, PredictionSettledQuery, type PredictionSubTab, SpotHistoryData, SpotHistoryQuery, SpotHolding, SpotHoldingsData, SpotPanelUI, type SpotPanelUIProps, type SpotSubTab, type UseHoldingsSectionOptions, type UseHoldingsSectionResult, type UsePortfolioPageOptions, type UsePortfolioPageResult, type UseWalletStateManagerParams, ViewingBannerUI, type ViewingBannerUIProps, type WalletOption, type WalletSummary, computeDistribution, curveDataQueryKey, distributionQueryKey, formatPercent, formatSignedUsd, formatTime, formatTokenBalance, formatUsd, getExplorerUrl, overviewQueryKey, parseDecimal, perpsHistoryQueryKey, perpsPositionsQueryKey, predictionBetsQueryKey, predictionSettledQueryKey, splitUsd, spotHistoryQueryKey, spotHoldingsQueryKey, truncateAddress, useCurveDataQuery, useDistributionQuery, useHoldingsSection, useOverviewQuery, usePerpsHistoryQuery, usePerpsPositionsQuery, usePortfolioClient, usePortfolioContext, usePortfolioPage, usePredictionBetsQuery, usePredictionSettledQuery, useRefetchWalletSummary, useSpotHistoryQuery, useSpotHoldingsQuery, useWalletStateManager, useWalletSummary, _default as version, walletSummaryAtom, walletSummaryRefetchAtom, walletSummaryStatusAtom };
package/dist/index.d.ts CHANGED
@@ -4,7 +4,9 @@ import { ReactNode, PropsWithChildren } from 'react';
4
4
  import { A as AssetTab, C as CurveType, a as CurvePeriod, P as PortfolioQuery, b as PortfolioOverview, c as CurveData, D as DistributionData, S as SpotHoldingsData, d as SpotHistoryData, e as PerpsPositionsData, f as PerpsHistoryData, g as PredictionBetsData, h as PredictionSettledData, i as SpotHolding, j as PerpsPosition, k as PredictionBet, I as IPortfolioClient, l as SpotHistoryQuery, m as PerpsHistoryQuery, n as PredictionSettledQuery, o as CurveQuery } from './index-Bm8Qidtb.js';
5
5
  export { p as CURVE_PERIOD_VALUE, w as ChartDataPointDTO, E as CurvePoint, F as DistributionItem, G as GetPortfolioChartReply, x as GetSpotHoldingsReply, z as GetTradeHistoryReply, q as PerpsPositionSide, H as PerpsTradeRecord, v as PortfolioOverviewDTO, s as PredictionBetStatus, t as PredictionResult, J as PredictionSettledRecord, u as PredictionSource, B as SpotHistoryRecord, r as SpotHistoryType, T as TokenHoldingDTO, y as TradeRecordDTO } from './index-Bm8Qidtb.js';
6
6
  import * as _tanstack_react_query from '@tanstack/react-query';
7
- import { UseQueryOptions } from '@tanstack/react-query';
7
+ import { UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
8
+ import { WalletPortfolios, WalletPnl, Chain } from '@liberfi.io/types';
9
+ import * as jotai from 'jotai';
8
10
 
9
11
  declare global {
10
12
  interface Window {
@@ -13,7 +15,7 @@ declare global {
13
15
  };
14
16
  }
15
17
  }
16
- declare const _default: "0.1.1";
18
+ declare const _default: "0.1.2";
17
19
 
18
20
  interface WalletOption {
19
21
  id: string;
@@ -284,6 +286,41 @@ declare function useDistributionQuery(holdings: SpotHolding[]): {
284
286
  data: DistributionData;
285
287
  };
286
288
 
289
+ /** Wallet summary: balance + PnL fields flattened */
290
+ type WalletSummary = Omit<WalletPortfolios, "portfolios"> & WalletPnl;
291
+ /** Async status derived from React Query */
292
+ type AsyncStatus = Pick<UseQueryResult, "status" | "fetchStatus" | "isLoading" | "isPending" | "isFetching" | "isRefetching" | "isError" | "isSuccess" | "error" | "dataUpdatedAt">;
293
+ /** Wallet balance + PnL summary */
294
+ declare const walletSummaryAtom: jotai.PrimitiveAtom<WalletSummary | null> & {
295
+ init: WalletSummary | null;
296
+ };
297
+ /** Async status for wallet summary */
298
+ declare const walletSummaryStatusAtom: jotai.PrimitiveAtom<AsyncStatus> & {
299
+ init: AsyncStatus;
300
+ };
301
+ /** Refetch function for wallet summary (wrapped in object to avoid Jotai treating function as read-only getter) */
302
+ type RefetchFn = () => Promise<void>;
303
+ declare const walletSummaryRefetchAtom: jotai.WritableAtom<RefetchFn, [fn: RefetchFn], void>;
304
+
305
+ interface UseWalletStateManagerParams {
306
+ chain: Chain;
307
+ address: string;
308
+ enabled?: boolean;
309
+ summaryPollMs?: number;
310
+ }
311
+ /**
312
+ * Mounts the wallet summary state engine: queries, polls, and subscribes to
313
+ * wallet balance + PnL summary, writing results to jotai atoms.
314
+ * Call this once near the top of the component tree.
315
+ */
316
+ declare function useWalletStateManager({ chain, address, enabled, summaryPollMs, }: UseWalletStateManagerParams): void;
317
+ /** Read wallet summary (balance + PnL flat) with async status. */
318
+ declare function useWalletSummary(): AsyncStatus & {
319
+ data: WalletSummary | null;
320
+ };
321
+ /** Returns a function that triggers a wallet summary refetch. */
322
+ declare function useRefetchWalletSummary(): () => Promise<void>;
323
+
287
324
  /**
288
325
  * Parse a decimal string to a number, returning 0 for empty / invalid values.
289
326
  */
@@ -339,4 +376,4 @@ declare function computeDistribution(holdings: SpotHolding[]): DistributionData;
339
376
  */
340
377
  declare function formatTime(epochMs: number): string;
341
378
 
342
- export { AddressRowUI, type AddressRowUIProps, AssetTab, AssetTabsUI, type AssetTabsUIProps, BalanceRowUI, type BalanceRowUIProps, BatchActionButton, type BatchActionButtonProps, ConfirmDialog, type ConfirmDialogProps, CurveCardUI, type CurveCardUIProps, CurveData, CurvePeriod, CurveQuery, CurveType, DistributionCardUI, type DistributionCardUIProps, DistributionData, HoldingsEmpty, type HoldingsEmptyProps, type HoldingsRenderProps, HoldingsSearch, type HoldingsSearchProps, HoldingsSectionWidget, type HoldingsSectionWidgetProps, HoldingsSubTabs, type HoldingsSubTabsProps, IPortfolioClient, PerpsHistoryData, PerpsHistoryQuery, PerpsPanelUI, type PerpsPanelUIProps, PerpsPosition, PerpsPositionsData, type PerpsSubTab, PortfolioContext, type PortfolioContextValue, PortfolioOverview, PortfolioPageSkeleton, PortfolioPageWidget, type PortfolioPageWidgetProps, PortfolioProvider, type PortfolioProviderProps, PortfolioQuery, PredictionBet, PredictionBetsData, PredictionPanelUI, type PredictionPanelUIProps, PredictionSettledData, PredictionSettledQuery, type PredictionSubTab, SpotHistoryData, SpotHistoryQuery, SpotHolding, SpotHoldingsData, SpotPanelUI, type SpotPanelUIProps, type SpotSubTab, type UseHoldingsSectionOptions, type UseHoldingsSectionResult, type UsePortfolioPageOptions, type UsePortfolioPageResult, ViewingBannerUI, type ViewingBannerUIProps, type WalletOption, computeDistribution, curveDataQueryKey, distributionQueryKey, formatPercent, formatSignedUsd, formatTime, formatTokenBalance, formatUsd, getExplorerUrl, overviewQueryKey, parseDecimal, perpsHistoryQueryKey, perpsPositionsQueryKey, predictionBetsQueryKey, predictionSettledQueryKey, splitUsd, spotHistoryQueryKey, spotHoldingsQueryKey, truncateAddress, useCurveDataQuery, useDistributionQuery, useHoldingsSection, useOverviewQuery, usePerpsHistoryQuery, usePerpsPositionsQuery, usePortfolioClient, usePortfolioContext, usePortfolioPage, usePredictionBetsQuery, usePredictionSettledQuery, useSpotHistoryQuery, useSpotHoldingsQuery, _default as version };
379
+ export { AddressRowUI, type AddressRowUIProps, AssetTab, AssetTabsUI, type AssetTabsUIProps, type AsyncStatus, BalanceRowUI, type BalanceRowUIProps, BatchActionButton, type BatchActionButtonProps, ConfirmDialog, type ConfirmDialogProps, CurveCardUI, type CurveCardUIProps, CurveData, CurvePeriod, CurveQuery, CurveType, DistributionCardUI, type DistributionCardUIProps, DistributionData, HoldingsEmpty, type HoldingsEmptyProps, type HoldingsRenderProps, HoldingsSearch, type HoldingsSearchProps, HoldingsSectionWidget, type HoldingsSectionWidgetProps, HoldingsSubTabs, type HoldingsSubTabsProps, IPortfolioClient, PerpsHistoryData, PerpsHistoryQuery, PerpsPanelUI, type PerpsPanelUIProps, PerpsPosition, PerpsPositionsData, type PerpsSubTab, PortfolioContext, type PortfolioContextValue, PortfolioOverview, PortfolioPageSkeleton, PortfolioPageWidget, type PortfolioPageWidgetProps, PortfolioProvider, type PortfolioProviderProps, PortfolioQuery, PredictionBet, PredictionBetsData, PredictionPanelUI, type PredictionPanelUIProps, PredictionSettledData, PredictionSettledQuery, type PredictionSubTab, SpotHistoryData, SpotHistoryQuery, SpotHolding, SpotHoldingsData, SpotPanelUI, type SpotPanelUIProps, type SpotSubTab, type UseHoldingsSectionOptions, type UseHoldingsSectionResult, type UsePortfolioPageOptions, type UsePortfolioPageResult, type UseWalletStateManagerParams, ViewingBannerUI, type ViewingBannerUIProps, type WalletOption, type WalletSummary, computeDistribution, curveDataQueryKey, distributionQueryKey, formatPercent, formatSignedUsd, formatTime, formatTokenBalance, formatUsd, getExplorerUrl, overviewQueryKey, parseDecimal, perpsHistoryQueryKey, perpsPositionsQueryKey, predictionBetsQueryKey, predictionSettledQueryKey, splitUsd, spotHistoryQueryKey, spotHoldingsQueryKey, truncateAddress, useCurveDataQuery, useDistributionQuery, useHoldingsSection, useOverviewQuery, usePerpsHistoryQuery, usePerpsPositionsQuery, usePortfolioClient, usePortfolioContext, usePortfolioPage, usePredictionBetsQuery, usePredictionSettledQuery, useRefetchWalletSummary, useSpotHistoryQuery, useSpotHoldingsQuery, useWalletStateManager, useWalletSummary, _default as version, walletSummaryAtom, walletSummaryRefetchAtom, walletSummaryStatusAtom };
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- 'use strict';var react=require('react'),ui=require('@liberfi.io/ui'),jsxRuntime=require('react/jsx-runtime'),recharts=require('recharts'),reactQuery=require('@tanstack/react-query');typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/ui-portfolio"]="0.1.1");var At="0.1.1";function Wo(e){if(!e)return 0;let t=Number(e);return Number.isFinite(t)?t:0}function v(e){let t=Math.abs(e),o=e<0?"-":"";return t>=1e6?`${o}$${(t/1e6).toFixed(1)}M`:t>=1e4?`${o}$${(t/1e3).toFixed(1)}K`:t>=1?`${o}$${t.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`:t>=.01?`${o}$${t.toFixed(2)}`:t>0?`${o}<$0.01`:"$0.00"}function te(e){let t=v(Math.abs(e));return e>0?`+${t}`:e<0?`-${t.replace("-","")}`:t}function Je(e){return `${e>0?"+":""}${e.toFixed(2)}%`}function Ze(e){let o=Math.abs(e).toFixed(2).split("."),r=Number(o[0]).toLocaleString("en-US"),s=`.${o[1]}`;return {sign:e<0?"-$":"$",integer:r,decimal:s}}function X(e,t=4,o=4){return e.length<=t+o+3?e:`${e.slice(0,t)}\u2026${e.slice(-o)}`}function be(e){return e===0?"0":e>=1e6?`${(e/1e6).toFixed(2)}M`:e>=1e3?e.toLocaleString("en-US",{maximumFractionDigits:2}):e>=1?e.toFixed(2):e>=1e-4?e.toFixed(4):"<0.0001"}function et(e,t){return `https://solscan.io/tx/${e}`}var Xe=["#C8FF00","#00E676","#0066FF","#FF6B9D","#8B7BFF","#FF5252","#FFB74D","#4DD0E1"],Tt="#3A3A4E";function tt(e){let t=e.reduce((n,p)=>n+p.value,0);if(t<=0)return {items:[]};let o=[...e].sort((n,p)=>p.value-n.value),r=[],s=0,d=0;for(let n of o){let p=n.value/t*100;p<2?s+=n.value:(r.push({name:n.name,symbol:n.symbol,percent:p,value:n.value,color:Xe[d%Xe.length]}),d++);}return s>0&&r.push({name:"Other",symbol:"OTHER",percent:s/t*100,value:s,color:Tt}),{items:r}}function ot(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:false})}function Pe({walletId:e,wallets:t,isViewing:o,viewingAddress:r,onSelectWallet:s,onCopyAddress:d,onSearch:n}){let[p,c]=react.useState(false),[u,b]=react.useState(""),g=react.useRef(null),S=!e&&!o,T=t.find(x=>x.id===e),R=o?"External":S?"All Wallets":T?.name??"",f=o?X(r??""):S?"Aggregated":X(T?.address??""),A=o?"bg-[#5C5C72]":S?"bg-[#C8FF00]":"bg-[#00E676]",P=react.useCallback(()=>{let x=u.trim();x.length>=32&&(n(x),b(""));},[u,n]),D=react.useCallback(x=>{x.key==="Enter"&&P();},[P]);return jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-4 pb-4",children:[jsxRuntime.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[jsxRuntime.jsxs("div",{className:"relative",ref:g,children:[jsxRuntime.jsxs("button",{type:"button",className:ui.clsx("flex items-center gap-2 rounded-lg border px-2.5 py-1.5 transition-colors",o?"border-[rgba(200,255,0,0.2)] bg-[rgba(200,255,0,0.04)]":"border-[#252530] bg-[#16161E] hover:border-[#35354A] hover:bg-[#1C1C26]",o&&"pointer-events-none"),onClick:()=>!o&&c(x=>!x),children:[jsxRuntime.jsx("span",{className:ui.clsx("h-[7px] w-[7px] flex-shrink-0 rounded-full",A)}),jsxRuntime.jsx("span",{className:"text-[11px] font-medium text-[#A0A0B8]",children:R}),jsxRuntime.jsx("span",{className:"font-mono text-xs text-foreground",children:f}),!o&&jsxRuntime.jsx("svg",{className:ui.clsx("text-[#5C5C72] transition-transform",p&&"rotate-180"),width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",children:jsxRuntime.jsx("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round"})})]}),p&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>c(false)}),jsxRuntime.jsxs("div",{className:"absolute left-0 top-[calc(100%+4px)] z-50 min-w-[260px] rounded-lg border border-[#252530] bg-[#16161E] p-1 shadow-[0_8px_32px_rgba(0,0,0,0.4)]",children:[jsxRuntime.jsxs("button",{type:"button",className:ui.clsx("flex w-full items-center gap-2 rounded-[5px] px-2.5 py-2 transition-colors hover:bg-[#1C1C26]",S&&"bg-[rgba(200,255,0,0.07)]"),onClick:()=>{s(void 0),c(false);},children:[jsxRuntime.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[#C8FF00]"}),jsxRuntime.jsx("span",{className:"min-w-[60px] text-[11px] font-medium text-[#A0A0B8]",children:"All Wallets"}),jsxRuntime.jsx("span",{className:"text-[11px] text-[#3A3A4E]",children:"Aggregated"})]}),t.map(x=>jsxRuntime.jsxs("button",{type:"button",className:ui.clsx("flex w-full items-center gap-2 rounded-[5px] px-2.5 py-2 transition-colors hover:bg-[#1C1C26]",e===x.id&&"bg-[rgba(200,255,0,0.07)]"),onClick:()=>{s(x.id),c(false);},children:[jsxRuntime.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[#00E676]"}),jsxRuntime.jsx("span",{className:"min-w-[60px] text-[11px] font-medium text-[#A0A0B8]",children:x.name}),jsxRuntime.jsx("span",{className:"font-mono text-[11px] text-[#5C5C72]",children:X(x.address)}),jsxRuntime.jsx("span",{className:"ml-auto font-mono text-[11px] font-medium text-foreground",children:x.balance})]},x.id))]})]})]}),jsxRuntime.jsx("button",{type:"button",className:ui.clsx("rounded p-1 text-[#5C5C72] transition-colors hover:bg-[#1C1C26] hover:text-[#C8FF00]",S&&!o&&"pointer-events-none opacity-40"),onClick:d,disabled:S&&!o,children:jsxRuntime.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:[jsxRuntime.jsx("rect",{x:"4.5",y:"4.5",width:"7",height:"7",rx:"1.5",stroke:"currentColor",strokeWidth:"1.2"}),jsxRuntime.jsx("path",{d:"M9.5 4.5V3a1.5 1.5 0 0 0-1.5-1.5H3A1.5 1.5 0 0 0 1.5 3v5A1.5 1.5 0 0 0 3 9.5h1.5",stroke:"currentColor",strokeWidth:"1.2"})]})}),jsxRuntime.jsx("span",{className:ui.clsx("flex-shrink-0 rounded-[3px] px-1.5 py-[3px] text-[9px] font-semibold uppercase tracking-wider",o?"bg-[rgba(200,255,0,0.07)] text-[#C8FF00] animate-[pulse-glow_2s_ease-in-out_infinite]":"bg-[rgba(0,230,118,0.1)] text-[#00E676]"),children:o?"Viewing":"Owner"})]}),jsxRuntime.jsxs("div",{className:"flex flex-shrink-0 items-center gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex h-[34px] w-[240px] items-center gap-1.5 rounded-lg border border-[#252530] bg-[#16161E] px-2.5 transition-all focus-within:w-[300px] focus-within:border-[#C8FF00]",children:[jsxRuntime.jsxs("svg",{className:"flex-shrink-0 text-[#5C5C72]",width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"7",cy:"7",r:"5.5",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M11 11L14.5 14.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),jsxRuntime.jsx("input",{className:"flex-1 border-none bg-transparent font-mono text-xs text-foreground caret-[#C8FF00] outline-none placeholder:font-sans placeholder:text-[11px] placeholder:text-[#5C5C72]",placeholder:"Search wallet address\u2026",spellCheck:false,value:u,onChange:x=>b(x.target.value),onKeyDown:D})]}),jsxRuntime.jsx("button",{type:"button",className:"whitespace-nowrap rounded-[5px] border border-[#252530] bg-[#1C1C26] px-3 py-1.5 text-[11px] font-medium text-[#A0A0B8] transition-colors hover:border-[#C8FF00] hover:bg-[#C8FF00] hover:text-black",onClick:P,children:"View"})]})]})}var oe=(r=>(r.SPOT="spot",r.PERPS="perps",r.PREDICTION="prediction",r))(oe||{}),ve=(o=>(o.NET_WORTH="networth",o.PNL="pnl",o))(ve||{}),he=(s=>(s.ONE_DAY="1D",s.SEVEN_DAY="7D",s.THIRTY_DAY="30D",s.MAX="Max",s))(he||{}),st={"1D":1,"7D":7,"30D":30,Max:365},it=(o=>(o.LONG="long",o.SHORT="short",o))(it||{}),at=(r=>(r.SWAP="swap",r.SEND="send",r.RECEIVE="receive",r))(at||{}),lt=(o=>(o.ACTIVE="active",o.PENDING="pending",o))(lt||{}),pt=(o=>(o.WON="won",o.LOST="lost",o))(pt||{}),dt=(r=>(r.POLYMARKET="polymarket",r.DRIFT="drift",r.METADAO="metadao",r))(dt||{});var Et=[{key:"spot",label:"Spot"},{key:"perps",label:"Perps"},{key:"prediction",label:"Prediction"}];function Qt(e,t,o,r){switch(e){case "spot":return t;case "perps":return o;case "prediction":return r}}function Ce({activeTab:e,onTabChange:t,spotValue:o=0,perpsValue:r=0,predictionValue:s=0}){return jsxRuntime.jsx("div",{className:"flex gap-1 border-b border-[#252530] pb-0 pt-5",children:Et.map(({key:d,label:n})=>{let p=e===d,c=Qt(d,o,r,s);return jsxRuntime.jsxs("button",{type:"button",className:ui.clsx("relative flex items-center gap-2 border-b-2 px-4 pb-3 pt-2.5 text-[13px] font-medium transition-colors",p?"border-[#C8FF00] text-foreground":"border-transparent text-[#5C5C72] hover:text-[#A0A0B8]"),onClick:()=>t(d),children:[n,!p&&jsxRuntime.jsx("span",{className:"rounded-[10px] bg-[#16161E] px-2 py-0.5 font-mono text-[11px] text-[#5C5C72]",children:v(c)})]},d)})})}function Se({overview:e}){let t=e?.totalValue??0,o=e?.uPnl??0,r=e?.realizedPnl??0,s=e?.totalProfit??0,{sign:d,integer:n,decimal:p}=Ze(t);return jsxRuntime.jsxs("div",{className:"flex items-center gap-4 pb-4",children:[jsxRuntime.jsx("div",{className:"flex items-baseline gap-3",children:jsxRuntime.jsxs("div",{className:"font-mono text-[26px] font-bold leading-none tracking-tight",children:[jsxRuntime.jsx("span",{className:"mr-px text-lg font-medium text-[#C8FF00]",children:d}),n,jsxRuntime.jsx("span",{className:"text-base font-normal text-[#5C5C72]",children:p})]})}),jsxRuntime.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[jsxRuntime.jsx(Ne,{label:"uPNL",value:o}),jsxRuntime.jsx(ut,{}),jsxRuntime.jsx(Ne,{label:"Realized",value:r}),jsxRuntime.jsx(ut,{}),jsxRuntime.jsx(Ne,{label:"Total Profit",value:s})]})]})}function Ne({label:e,value:t}){return jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx("span",{className:"text-[11px] text-[#5C5C72]",children:e}),jsxRuntime.jsx("span",{className:ui.clsx("font-mono text-xs font-medium",t>0?"text-[#00E676]":t<0?"text-[#FF5252]":"text-[#5C5C72]"),children:te(t)})]})}function ut(){return jsxRuntime.jsx("div",{className:"h-3.5 w-px bg-[#252530]"})}var Wt=["1D","7D","30D","Max"];function mt(e,t){let o=new Date(e);switch(t){case "1D":return o.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false});default:return o.toLocaleDateString("en-US",{month:"short",day:"numeric"})}}function Kt(e){return e==="pnl"?"change":"netWorth"}function ke({curveType:e,curvePeriod:t,data:o,isLoading:r,onTypeChange:s,onPeriodChange:d}){let n=o?.points??[],p=Kt(e),c=e==="pnl",u=react.useMemo(()=>n.map(f=>c?f.change:f.netWorth),[n,c]),b=u.some(f=>f<0),{minVal:g,maxVal:S}=react.useMemo(()=>{if(u.length===0)return {minVal:0,maxVal:100};let f=Math.min(...u),A=Math.max(...u),P=A-f||1;return {minVal:f-P*.1,maxVal:A+P*.1}},[u]),T=react.useMemo(()=>{if(n.length===0)return [];let f=Math.min(7,n.length),A=Math.max(1,Math.floor((n.length-1)/(f-1))),P=[];for(let x=0;x<n.length;x+=A)P.push({ts:n[x].timestamp,label:mt(n[x].timestamp,t)});let D=n[n.length-1];return P[P.length-1]?.ts!==D.timestamp&&P.push({ts:D.timestamp,label:mt(D.timestamp,t)}),P},[n,t]),R=u[u.length-1]??0;return jsxRuntime.jsxs("div",{className:"overflow-hidden rounded-lg border border-[#252530] bg-[#0F0F16]",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 pt-3",children:[jsxRuntime.jsxs("div",{className:"flex gap-0.5 rounded-[5px] bg-[#16161E] p-0.5",children:[jsxRuntime.jsx(ft,{label:"Net Worth",active:e==="networth",onClick:()=>s("networth")}),jsxRuntime.jsx(ft,{label:"PNL",active:e==="pnl",onClick:()=>s("pnl")})]}),jsxRuntime.jsx("div",{className:"flex gap-0.5",children:Wt.map(f=>jsxRuntime.jsx("button",{type:"button",className:ui.clsx("rounded-[3px] px-2 py-1 text-[10px] font-medium transition-colors",t===f?"bg-[rgba(200,255,0,0.07)] text-[#C8FF00]":"text-[#5C5C72] hover:bg-[#16161E] hover:text-[#A0A0B8]"),onClick:()=>d(f),children:f},f))})]}),jsxRuntime.jsx("div",{className:"h-[180px] px-4 pt-2",children:r||n.length<2?jsxRuntime.jsx("div",{className:"flex h-full items-center justify-center",children:jsxRuntime.jsx("span",{className:"text-xs text-[#5C5C72]",children:r?"":"Not enough data"})}):jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",children:jsxRuntime.jsxs(recharts.AreaChart,{data:n,margin:{top:8,right:0,left:0,bottom:0},children:[jsxRuntime.jsxs("defs",{children:[jsxRuntime.jsxs("linearGradient",{id:"gradAccent",x1:"0",y1:"0",x2:"0",y2:"1",children:[jsxRuntime.jsx("stop",{offset:"0%",stopColor:"#C8FF00",stopOpacity:.12}),jsxRuntime.jsx("stop",{offset:"100%",stopColor:"#C8FF00",stopOpacity:0})]}),jsxRuntime.jsxs("linearGradient",{id:"gradGreen",x1:"0",y1:"0",x2:"0",y2:"1",children:[jsxRuntime.jsx("stop",{offset:"0%",stopColor:"#00E676",stopOpacity:.12}),jsxRuntime.jsx("stop",{offset:"100%",stopColor:"#00E676",stopOpacity:0})]}),jsxRuntime.jsxs("linearGradient",{id:"gradRed",x1:"0",y1:"0",x2:"0",y2:"1",children:[jsxRuntime.jsx("stop",{offset:"0%",stopColor:"#FF5252",stopOpacity:0}),jsxRuntime.jsx("stop",{offset:"100%",stopColor:"#FF5252",stopOpacity:.1})]})]}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"timestamp",hide:true}),jsxRuntime.jsx(recharts.YAxis,{hide:true,domain:[g,S]}),c&&b&&jsxRuntime.jsx(recharts.ReferenceLine,{y:0,stroke:"rgba(255,255,255,0.06)",strokeDasharray:"4 4"}),jsxRuntime.jsx(recharts.Area,{type:"monotone",dataKey:p,stroke:c?R>=0?"#00E676":"#FF5252":"#C8FF00",strokeWidth:1.5,fill:c?R>=0?"url(#gradGreen)":"url(#gradRed)":"url(#gradAccent)",dot:false,isAnimationActive:false})]})})}),jsxRuntime.jsx("div",{className:"flex justify-between px-4 pb-2.5 pt-1",children:T.map(({ts:f,label:A})=>jsxRuntime.jsx("span",{className:"font-mono text-[9px] text-[#3A3A4E]",children:A},f))})]})}function ft({label:e,active:t,onClick:o}){return jsxRuntime.jsx("button",{type:"button",className:ui.clsx("rounded px-2.5 py-1 text-[11px] font-medium transition-colors",t?"bg-[#1C1C26] text-foreground":"text-[#5C5C72] hover:text-[#A0A0B8]"),onClick:o,children:e})}function Te({data:e,isLoading:t}){let o=e?.items??[],r=react.useMemo(()=>o.map(s=>({name:s.name,value:s.percent})),[o]);return jsxRuntime.jsxs("div",{className:"flex flex-col overflow-hidden rounded-lg border border-[#252530] bg-[#0F0F16]",children:[jsxRuntime.jsx("div",{className:"px-4 pb-2 pt-3",children:jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[#A0A0B8]",children:"Distribution"})}),jsxRuntime.jsx("div",{className:"flex flex-1 items-center justify-center px-4",children:t||o.length===0?jsxRuntime.jsx("div",{className:"flex h-[140px] w-[140px] items-center justify-center",children:jsxRuntime.jsx("span",{className:"text-xs text-[#5C5C72]",children:t?"":"No data"})}):jsxRuntime.jsx(recharts.ResponsiveContainer,{width:140,height:140,children:jsxRuntime.jsx(recharts.PieChart,{children:jsxRuntime.jsx(recharts.Pie,{data:r,cx:"50%",cy:"50%",innerRadius:32,outerRadius:55,dataKey:"value",stroke:"none",isAnimationActive:false,children:o.map((s,d)=>jsxRuntime.jsx(recharts.Cell,{fill:s.color},d))})})})}),jsxRuntime.jsx("div",{className:"px-4 pb-3 pt-2",children:o.map((s,d)=>jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 py-[3px] text-[11px]",children:[jsxRuntime.jsx("span",{className:"h-[7px] w-[7px] flex-shrink-0 rounded-[2px]",style:{background:s.color}}),jsxRuntime.jsx("span",{className:"min-w-0 flex-1 truncate text-[#A0A0B8]",children:s.name}),jsxRuntime.jsxs("span",{className:"font-mono text-[10px] text-[#5C5C72]",children:[s.percent.toFixed(1),"%"]}),jsxRuntime.jsx("span",{className:"min-w-[55px] text-right font-mono text-[10px] text-foreground",children:v(s.value)})]},d))})]})}var re=react.createContext({});function He(){let e=react.useContext(re);if(!e)throw new Error("usePortfolioContext must be used within a PortfolioProvider");return e}function N(){let{client:e}=He();return e}function gt(e){return ["portfolio","overview",e??{}]}async function Jt(e,t){return await e.getOverview(t)}function Fe(e,t={}){let o=N();return reactQuery.useQuery({queryKey:gt(e),queryFn:async()=>Jt(o,e),...t})}function yt(e){return ["portfolio","spot","holdings",e??{}]}async function eo(e,t){return await e.getSpotHoldings(t)}function ne(e,t={}){let o=N();return reactQuery.useQuery({queryKey:yt(e),queryFn:async()=>eo(o,e),...t})}function bt(e){return ["portfolio","spot","history",e??{}]}async function oo(e,t){return await e.getSpotHistory(t)}function De(e,t={}){let o=N();return reactQuery.useQuery({queryKey:bt(e),queryFn:async()=>oo(o,e),...t})}function Pt(e){return ["portfolio","perps","positions",e??{}]}async function no(e,t){return await e.getPerpsPositions(t)}function Ee(e,t={}){let o=N();return reactQuery.useQuery({queryKey:Pt(e),queryFn:async()=>no(o,e),...t})}function vt(e){return ["portfolio","perps","history",e??{}]}async function io(e,t){return await e.getPerpsHistory(t)}function Qe(e,t={}){let o=N();return reactQuery.useQuery({queryKey:vt(e),queryFn:async()=>io(o,e),...t})}function ht(e){return ["portfolio","prediction","active",e??{}]}async function lo(e,t){return await e.getPredictionBets(t)}function Ue(e,t={}){let o=N();return reactQuery.useQuery({queryKey:ht(e),queryFn:async()=>lo(o,e),...t})}function Ct(e){return ["portfolio","prediction","settled",e??{}]}async function co(e,t){return await e.getPredictionSettled(t)}function Ie(e,t={}){let o=N();return reactQuery.useQuery({queryKey:Ct(e),queryFn:async()=>co(o,e),...t})}function Nt(e){return ["portfolio","chart",e]}async function mo(e,t){return await e.getChartData(t)}function Re(e,t={}){let o=N();return reactQuery.useQuery({queryKey:Nt(e),queryFn:async()=>mo(o,e),...t})}function xo(){return ["portfolio","distribution"]}function Oe(e){return {data:react.useMemo(()=>tt(e),[e])}}function Le(e){let{defaultTab:t="spot",walletAddresses:o,chain:r}=e??{},[s,d]=react.useState(t),[n,p]=react.useState(void 0),[c,u]=react.useState(void 0),[b,g]=react.useState("networth"),[S,T]=react.useState("7D"),R=c!==void 0,f=react.useMemo(()=>{if(c)return {walletAddresses:[c],chain:r};if(o?.length)return {walletAddresses:o,chain:r}},[o,c,r]),A=Fe(f),P=ne(f),D=Re({period:st[S],...f}),x=Oe(P.data?.holdings??[]),K=react.useMemo(()=>P.data?.holdings.reduce((U,pe)=>U+pe.value,0)??0,[P.data]),Z=react.useCallback(U=>{u(U);},[]),M=react.useCallback(()=>{u(void 0);},[]),ee=react.useCallback(U=>{p(U);},[]);return {activeTab:s,setActiveTab:d,walletId:n,selectWallet:ee,viewingAddress:c,isViewing:R,curveType:b,setCurveType:g,curvePeriod:S,setCurvePeriod:T,portfolioQuery:f,overviewQuery:A,curveQuery:D,distributionQuery:x,spotHoldingsQuery:P,spotValue:K,perpsValue:0,predictionValue:0,enterViewing:Z,exitViewing:M}}function Ve(){return jsxRuntime.jsxs("div",{className:"mx-auto max-w-[1280px] px-6",children:[jsxRuntime.jsxs("div",{className:"flex gap-4 border-b border-[#252530] pb-0 pt-5",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-9 w-16 rounded-md"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-9 w-28 rounded-md"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-9 w-32 rounded-md"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-4 py-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2.5",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-48 rounded-lg"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-6 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-5 w-14 rounded-[3px]"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-[34px] w-[240px] rounded-lg"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-[34px] w-12 rounded-[5px]"})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 pb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-baseline gap-3",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-48 rounded-md"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-16 rounded"})]}),jsxRuntime.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-28 rounded"}),jsxRuntime.jsx("div",{className:"h-3.5 w-px bg-[#252530]"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-28 rounded"}),jsxRuntime.jsx("div",{className:"h-3.5 w-px bg-[#252530]"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-20 rounded"})]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-[1fr_340px] gap-3 pb-4",children:[jsxRuntime.jsxs("div",{className:"rounded-lg border border-[#252530] bg-[#0F0F16] p-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between pb-4",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-40 rounded-[5px]"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-32 rounded"})]}),jsxRuntime.jsx(ui.Skeleton,{className:"h-[180px] w-full rounded-md"}),jsxRuntime.jsx("div",{className:"mt-2 flex justify-between",children:Array.from({length:7}).map((e,t)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-3 w-8 rounded"},t))})]}),jsxRuntime.jsxs("div",{className:"rounded-lg border border-[#252530] bg-[#0F0F16] p-4",children:[jsxRuntime.jsx(ui.Skeleton,{className:"mb-3 h-4 w-24 rounded"}),jsxRuntime.jsx("div",{className:"flex items-center justify-center py-4",children:jsxRuntime.jsx(ui.Skeleton,{className:"h-[140px] w-[140px] rounded-full"})}),jsxRuntime.jsx("div",{className:"space-y-1.5 pt-2",children:Array.from({length:5}).map((e,t)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-full rounded"},t))})]})]}),jsxRuntime.jsxs("div",{className:"pb-6",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between pb-3",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-40 rounded-[5px]"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-40 rounded-[5px]"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-24 rounded-[5px]"})]})]}),jsxRuntime.jsx(ui.Skeleton,{className:"mb-3 h-5 w-full rounded"}),Array.from({length:5}).map((e,t)=>jsxRuntime.jsx(ui.Skeleton,{className:"mb-2 h-12 w-full rounded-[5px]"},t))]})]})}function _e({viewingAddress:e,onBack:t}){return jsxRuntime.jsxs("div",{className:"flex items-center justify-between border-b border-[rgba(200,255,0,0.12)] bg-[rgba(200,255,0,0.06)] px-6 py-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"flex h-[18px] w-[18px] items-center justify-center rounded-full border border-[rgba(200,255,0,0.25)] bg-[rgba(200,255,0,0.07)]",children:jsxRuntime.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",children:[jsxRuntime.jsx("path",{d:"M8 3C4.36 3 1.26 5.28 0 8.5c1.26 3.22 4.36 5.5 8 5.5s6.74-2.28 8-5.5C14.74 5.28 11.64 3 8 3z",stroke:"#C8FF00",strokeWidth:"1.3",fill:"none"}),jsxRuntime.jsx("circle",{cx:"8",cy:"8.5",r:"2.5",stroke:"#C8FF00",strokeWidth:"1.3",fill:"none"})]})}),jsxRuntime.jsx("span",{className:"text-xs font-medium text-[#C8FF00]",children:"Viewing external portfolio"}),jsxRuntime.jsx("span",{className:"ml-1 font-mono text-[11px] text-[#A0A0B8]",children:X(e)})]}),jsxRuntime.jsxs("button",{type:"button",className:"flex items-center gap-1.5 rounded-[5px] border border-[#252530] bg-[#1C1C26] px-3 py-1.5 text-[11px] font-medium text-[#A0A0B8] transition-colors hover:border-[#C8FF00] hover:bg-[#C8FF00] hover:text-black",onClick:t,children:[jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M10 2L4 8l6 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),"Back to My Portfolio"]})]})}function go({wallets:e=[],onCopyAddress:t,renderHoldings:o,isLoading:r,...s}){let d=Le(s),{activeTab:n,setActiveTab:p,walletId:c,selectWallet:u,viewingAddress:b,isViewing:g,curveType:S,setCurveType:T,curvePeriod:R,setCurvePeriod:f,portfolioQuery:A,overviewQuery:P,curveQuery:D,distributionQuery:x,spotValue:K,perpsValue:Z,predictionValue:M,enterViewing:ee,exitViewing:U}=d;return r||P.isLoading&&!P.data?jsxRuntime.jsx(Ve,{}):jsxRuntime.jsxs("div",{children:[g&&b&&jsxRuntime.jsx(_e,{viewingAddress:b,onBack:U}),jsxRuntime.jsxs("div",{className:"mx-auto max-w-[1280px] px-6",children:[jsxRuntime.jsx(Ce,{activeTab:n,onTabChange:p,spotValue:K,perpsValue:Z,predictionValue:M}),jsxRuntime.jsx(Pe,{walletId:c,wallets:e,isViewing:g,viewingAddress:b,onSelectWallet:u,onCopyAddress:()=>{if(g&&b)t?.(b);else {let de=e.find(ye=>ye.id===c);de&&t?.(de.address);}},onSearch:ee}),jsxRuntime.jsx(Se,{overview:P.data}),jsxRuntime.jsxs("div",{className:"grid grid-cols-[1fr_340px] gap-3 pb-4",children:[jsxRuntime.jsx(ke,{curveType:S,curvePeriod:R,data:D.data,isLoading:D.isLoading,onTypeChange:T,onPeriodChange:f}),jsxRuntime.jsx(Te,{data:x.data,isLoading:false})]}),o?.({activeTab:n,portfolioQuery:A,isViewing:g})]})]})}function me({open:e,title:t,message:o,confirmLabel:r,cancelLabel:s,onConfirm:d,onCancel:n}){return e?jsxRuntime.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[jsxRuntime.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:n,onKeyDown:p=>{p.key==="Escape"&&n();},role:"button",tabIndex:-1,"aria-label":"Close dialog"}),jsxRuntime.jsxs("div",{className:"relative z-10 w-full max-w-sm rounded-xl border border-[#252530] bg-[#12121A] p-6 shadow-2xl",children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold text-foreground",children:t}),jsxRuntime.jsx("p",{className:"mt-2 text-xs leading-relaxed text-[#A0A0B8]",children:o}),jsxRuntime.jsxs("div",{className:"mt-5 flex items-center justify-end gap-2",children:[jsxRuntime.jsx("button",{type:"button",className:"rounded-lg px-4 py-2 text-xs font-medium text-[#5C5C72] transition-colors hover:bg-[#1C1C26] hover:text-foreground",onClick:n,children:s}),jsxRuntime.jsx("button",{type:"button",className:ui.clsx("rounded-lg border px-4 py-2 text-xs font-medium transition-colors","border-[rgba(255,82,82,0.25)] text-[#FF5252]","hover:border-[#FF5252] hover:bg-[rgba(255,82,82,0.1)]"),onClick:d,children:r})]})]})]}):null}function qe({activeTab:e,portfolioQuery:t,isViewing:o}){let[r,s]=react.useState("holdings"),[d,n]=react.useState("positions"),[p,c]=react.useState("active"),[u,b]=react.useState(""),[g,S]=react.useState(""),[T,R]=react.useState(""),[f,A]=react.useState(false),[P,D]=react.useState(false),x=react.useCallback(()=>{D(L=>!L);},[]),K=ne(t,{enabled:e==="spot"}),Z=De(t,{enabled:e==="spot"&&r==="history"}),M=Ee(t,{enabled:e==="perps"}),ee=Qe(t,{enabled:e==="perps"&&d==="history"}),U=Ue(t,{enabled:e==="prediction"}),pe=Ie(t,{enabled:e==="prediction"&&p==="settled"}),je=react.useMemo(()=>(K.data?.holdings??[]).filter(V=>{if(f&&V.value<1&&!V.verified)return false;if(u){let j=u.toLowerCase();return V.name.toLowerCase().includes(j)||V.symbol.toLowerCase().includes(j)}return true}),[K.data?.holdings,f,u]),de=react.useMemo(()=>{let L=M.data?.positions??[];if(!g)return L;let V=g.toLowerCase();return L.filter(j=>j.pair.toLowerCase().includes(V))},[M.data?.positions,g]),ye=react.useMemo(()=>{let L=U.data?.bets??[];if(!T)return L;let V=T.toLowerCase();return L.filter(j=>j.market.toLowerCase().includes(V))},[U.data?.bets,T]);return {spotSubTab:r,setSpotSubTab:s,perpsSubTab:d,setPerpsSubTab:n,predictionSubTab:p,setPredictionSubTab:c,spotSearch:u,setSpotSearch:b,perpsSearch:g,setPerpsSearch:S,predictionSearch:T,setPredictionSearch:R,hideSmall:f,setHideSmall:A,groupCollapsed:P,toggleGroupCollapsed:x,spotHoldingsQuery:K,spotHistoryQuery:Z,perpsPositionsQuery:M,perpsHistoryQuery:ee,predictionBetsQuery:U,predictionSettledQuery:pe,filteredSpotHoldings:je,filteredPerpsPositions:de,filteredPredictionBets:ye,isViewing:o}}function z({tabs:e,activeKey:t,onTabChange:o}){return jsxRuntime.jsx("div",{className:"flex gap-0.5",children:e.map(r=>jsxRuntime.jsx("button",{type:"button",className:ui.clsx("rounded-[5px] px-3 py-1.5 text-xs font-medium transition-colors",t===r.key?"bg-[#1C1C26] text-foreground":"text-[#5C5C72] hover:bg-[#16161E] hover:text-[#A0A0B8]"),onClick:()=>o(r.key),children:r.label},r.key))})}function G({value:e,onChange:t,placeholder:o}){return jsxRuntime.jsxs("div",{className:"flex h-7 w-40 items-center gap-1 rounded-[5px] border border-[#252530] bg-[#16161E] px-2 transition-all focus-within:w-[200px] focus-within:border-[#C8FF00]",children:[jsxRuntime.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",className:"flex-shrink-0 text-[#5C5C72]",children:[jsxRuntime.jsx("circle",{cx:"7",cy:"7",r:"5.5",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M11 11L14.5 14.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),jsxRuntime.jsx("input",{type:"text",className:"flex-1 border-none bg-transparent font-mono text-[11px] text-foreground caret-[#C8FF00] outline-none placeholder:font-sans placeholder:text-[10px] placeholder:text-[#5C5C72]",placeholder:o,spellCheck:false,value:e,onChange:r=>t(r.target.value)})]})}function O({title:e,hint:t}){return jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[jsxRuntime.jsx("span",{className:"text-sm text-[#5C5C72]",children:e}),t&&jsxRuntime.jsx("span",{className:"mt-1 text-xs text-[#3A3A4E]",children:t})]})}function ae({label:e,disabled:t,onClick:o}){return jsxRuntime.jsxs("button",{type:"button",className:ui.clsx("flex items-center gap-1 whitespace-nowrap rounded-[5px] border px-3 py-1.5 text-[11px] font-medium transition-colors",t?"pointer-events-none border-[#252530] text-[#3A3A4E]":"border-[rgba(255,82,82,0.25)] text-[#FF5252] hover:border-[#FF5252] hover:bg-[rgba(255,82,82,0.1)]"),onClick:o,disabled:t,children:[jsxRuntime.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),e]})}function $e({state:e,onClosePosition:t,onCloseAll:o}){let{perpsSubTab:r,setPerpsSubTab:s,perpsSearch:d,setPerpsSearch:n,filteredPerpsPositions:p,perpsHistoryQuery:c,isViewing:u}=e,b=p.length>0;return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between pb-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(z,{tabs:[{key:"positions",label:"Open Positions"},{key:"history",label:"Trade History"}],activeKey:r,onTabChange:g=>s(g)}),r==="positions"&&!u&&jsxRuntime.jsx(ae,{label:"Close All",disabled:!b,onClick:()=>o?.()})]}),jsxRuntime.jsx(G,{value:d,onChange:n,placeholder:"Search pair\u2026"})]}),r==="positions"?jsxRuntime.jsx(Po,{positions:p,isViewing:u,onClose:t}):jsxRuntime.jsx(ho,{records:c.data?.records??[],isLoading:c.isLoading})]})}function Po({positions:e,isViewing:t,onClose:o}){return e.length===0?jsxRuntime.jsx(O,{title:"No open positions",hint:"Start trading \u2192"}):jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"grid gap-2 px-3 pb-2 text-[10px] font-medium uppercase tracking-wider text-[#5C5C72]",style:{gridTemplateColumns:t?"2fr 1fr .8fr .8fr 1fr":"2fr 1fr .8fr .8fr 1fr 80px"},children:[jsxRuntime.jsx("span",{children:"Pair / Side"}),jsxRuntime.jsx("span",{className:"text-right",children:"Size"}),jsxRuntime.jsx("span",{className:"text-right",children:"Entry"}),jsxRuntime.jsx("span",{className:"text-right",children:"Mark"}),jsxRuntime.jsx("span",{className:"text-right",children:"uPNL"}),!t&&jsxRuntime.jsx("span",{className:"text-right"})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:e.map(r=>jsxRuntime.jsx(vo,{position:r,isViewing:t,onClose:o},r.id))})]})}function vo({position:e,isViewing:t,onClose:o}){let r=e.side==="long",s=e.uPnl>=0;return jsxRuntime.jsxs("div",{className:"grid items-center gap-2 rounded-[5px] px-3 py-2.5 transition-colors hover:bg-[#16161E]",style:{gridTemplateColumns:t?"2fr 1fr .8fr .8fr 1fr":"2fr 1fr .8fr .8fr 1fr 80px"},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[e.icon?jsxRuntime.jsx("img",{src:e.icon,alt:e.pair,className:"h-6 w-6 flex-shrink-0 rounded-full"}):jsxRuntime.jsx("div",{className:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-full bg-[#1C1C26] text-[9px] font-bold text-[#5C5C72]",children:e.pair.slice(0,2)}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx("span",{className:"text-xs font-medium text-foreground",children:e.pair}),jsxRuntime.jsx("span",{className:ui.clsx("rounded px-1.5 py-0.5 text-[10px] font-medium",r?"bg-[rgba(0,230,118,0.12)] text-[#00E676]":"bg-[rgba(255,82,82,0.12)] text-[#FF5252]"),children:r?"Long":"Short"}),jsxRuntime.jsxs("span",{className:"rounded bg-[rgba(200,255,0,0.1)] px-1.5 py-0.5 text-[10px] font-medium text-[#C8FF00]",children:[e.leverage,"\xD7"]})]})]}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-foreground",children:v(e.size)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#A0A0B8]",children:v(e.entryPrice)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#A0A0B8]",children:v(e.markPrice)}),jsxRuntime.jsx("span",{className:ui.clsx("text-right font-mono text-xs",s?"text-[#00E676]":"text-[#FF5252]"),children:te(e.uPnl)}),!t&&jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx("button",{type:"button",className:"rounded-[5px] border border-[#252530] px-2.5 py-1 text-[10px] font-medium text-[#5C5C72] transition-colors hover:border-[#FF5252] hover:text-[#FF5252]",onClick:()=>o?.(e),children:"Close"})})]})}function ho({records:e,isLoading:t}){return t?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-16",children:jsxRuntime.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-[#C8FF00] border-t-transparent"})}):e.length===0?jsxRuntime.jsx(O,{title:"No trade history",hint:"Closed positions will appear here"}):jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"grid gap-2 px-3 pb-2 text-[10px] font-medium uppercase tracking-wider text-[#5C5C72]",style:{gridTemplateColumns:"1.5fr 80px 1fr 1fr 1fr 100px"},children:[jsxRuntime.jsx("span",{children:"Pair"}),jsxRuntime.jsx("span",{children:"Side"}),jsxRuntime.jsx("span",{className:"text-right",children:"Size"}),jsxRuntime.jsx("span",{className:"text-right",children:"PNL"}),jsxRuntime.jsx("span",{className:"text-right",children:"Close Price"}),jsxRuntime.jsx("span",{className:"text-right",children:"Time"})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:e.map(o=>jsxRuntime.jsx(Co,{record:o},o.id))})]})}function Co({record:e}){let t=e.side==="long",o=e.pnl>=0;return jsxRuntime.jsxs("div",{className:"grid items-center gap-2 rounded-[5px] px-3 py-2.5 transition-colors hover:bg-[#16161E]",style:{gridTemplateColumns:"1.5fr 80px 1fr 1fr 1fr 100px"},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[e.icon?jsxRuntime.jsx("img",{src:e.icon,alt:e.pair,className:"h-5 w-5 flex-shrink-0 rounded-full"}):jsxRuntime.jsx("div",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-full bg-[#1C1C26] text-[8px] font-bold text-[#5C5C72]",children:e.pair.slice(0,2)}),jsxRuntime.jsx("span",{className:"text-xs font-medium text-foreground",children:e.pair})]}),jsxRuntime.jsx("span",{children:jsxRuntime.jsx("span",{className:ui.clsx("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",t?"bg-[rgba(0,230,118,0.12)] text-[#00E676]":"bg-[rgba(255,82,82,0.12)] text-[#FF5252]"),children:t?"Long":"Short"})}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-foreground",children:v(e.size)}),jsxRuntime.jsx("span",{className:ui.clsx("text-right font-mono text-xs",o?"text-[#00E676]":"text-[#FF5252]"),children:te(e.pnl)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#A0A0B8]",children:v(e.closePrice)}),jsxRuntime.jsx("span",{className:"text-right text-[11px] text-[#5C5C72]",children:e.time})]})}function Ye({state:e,onSellBet:t,onSellAll:o}){let{predictionSubTab:r,setPredictionSubTab:s,predictionSearch:d,setPredictionSearch:n,filteredPredictionBets:p,predictionSettledQuery:c,isViewing:u}=e,b=p.length>0;return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between pb-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(z,{tabs:[{key:"active",label:"Active Bets"},{key:"settled",label:"Settled"}],activeKey:r,onTabChange:g=>s(g)}),r==="active"&&!u&&jsxRuntime.jsx(ae,{label:"Sell All",disabled:!b,onClick:()=>o?.()})]}),jsxRuntime.jsx(G,{value:d,onChange:n,placeholder:"Search market\u2026"})]}),r==="active"?jsxRuntime.jsx(wo,{bets:p,isViewing:u,onSell:t}):jsxRuntime.jsx(Ao,{records:c.data?.records??[],isLoading:c.isLoading})]})}var No={polymarket:"bg-[rgba(0,102,255,0.12)] text-[#0066FF]",drift:"bg-[rgba(200,255,0,0.1)] text-[#C8FF00]",metadao:"bg-[rgba(255,107,157,0.1)] text-[#FF6B9D]"},So={polymarket:"Polymarket",drift:"Drift",metadao:"MetaDAO"};function kt({source:e}){return jsxRuntime.jsx("span",{className:ui.clsx("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",No[e]),children:So[e]})}function wo({bets:e,isViewing:t,onSell:o}){return e.length===0?jsxRuntime.jsx(O,{title:"No active bets",hint:"Explore prediction markets \u2192"}):jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"grid gap-2 px-3 pb-2 text-[10px] font-medium uppercase tracking-wider text-[#5C5C72]",style:{gridTemplateColumns:t?"2.2fr .6fr .7fr .7fr .7fr":"2.2fr .6fr .7fr .7fr .7fr 80px"},children:[jsxRuntime.jsx("span",{children:"Market / Source"}),jsxRuntime.jsx("span",{className:"text-right",children:"Position"}),jsxRuntime.jsx("span",{className:"text-right",children:"Stake"}),jsxRuntime.jsx("span",{className:"text-right",children:"Potential"}),jsxRuntime.jsx("span",{className:"text-right",children:"Status"}),!t&&jsxRuntime.jsx("span",{className:"text-right"})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:e.map(r=>jsxRuntime.jsx(ko,{bet:r,isViewing:t,onSell:o},r.id))})]})}function ko({bet:e,isViewing:t,onSell:o}){return jsxRuntime.jsxs("div",{className:"grid items-center gap-2 rounded-[5px] px-3 py-2.5 transition-colors hover:bg-[#16161E]",style:{gridTemplateColumns:t?"2.2fr .6fr .7fr .7fr .7fr":"2.2fr .6fr .7fr .7fr .7fr 80px"},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[e.icon?jsxRuntime.jsx("img",{src:e.icon,alt:e.market,className:"h-6 w-6 flex-shrink-0 rounded-full"}):jsxRuntime.jsx("div",{className:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-full bg-[#1C1C26] text-[9px] font-bold text-[#5C5C72]",children:"?"}),jsxRuntime.jsxs("div",{className:"flex flex-col overflow-hidden",children:[jsxRuntime.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:e.market}),jsxRuntime.jsx(kt,{source:e.source})]})]}),jsxRuntime.jsx("span",{className:ui.clsx("text-right text-xs font-medium",e.position==="Yes"?"text-[#00E676]":"text-[#FF5252]"),children:e.position}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-foreground",children:v(e.stake)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#00E676]",children:v(e.potential)}),jsxRuntime.jsx("span",{className:"text-right",children:jsxRuntime.jsx("span",{className:ui.clsx("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",e.status==="active"?"bg-[rgba(0,230,118,0.12)] text-[#00E676]":"bg-[rgba(200,255,0,0.1)] text-[#C8FF00]"),children:e.status==="active"?"Active":"Pending"})}),!t&&jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx("button",{type:"button",className:"rounded-[5px] border border-[#252530] px-2.5 py-1 text-[10px] font-medium text-[#5C5C72] transition-colors hover:border-[#FF5252] hover:text-[#FF5252]",onClick:()=>o?.(e),children:"Sell"})})]})}function Ao({records:e,isLoading:t}){return t?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-16",children:jsxRuntime.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-[#C8FF00] border-t-transparent"})}):e.length===0?jsxRuntime.jsx(O,{title:"No settled bets",hint:"Settled predictions will appear here"}):jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"grid gap-2 px-3 pb-2 text-[10px] font-medium uppercase tracking-wider text-[#5C5C72]",style:{gridTemplateColumns:"1.5fr .8fr .6fr .7fr .6fr .7fr"},children:[jsxRuntime.jsx("span",{children:"Market"}),jsxRuntime.jsx("span",{children:"Source"}),jsxRuntime.jsx("span",{className:"text-right",children:"Position"}),jsxRuntime.jsx("span",{className:"text-right",children:"Stake"}),jsxRuntime.jsx("span",{className:"text-right",children:"Result"}),jsxRuntime.jsx("span",{className:"text-right",children:"Payout"})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:e.map(o=>jsxRuntime.jsx(To,{record:o},o.id))})]})}function To({record:e}){let t=e.result==="won";return jsxRuntime.jsxs("div",{className:"grid items-center gap-2 rounded-[5px] px-3 py-2.5 transition-colors hover:bg-[#16161E]",style:{gridTemplateColumns:"1.5fr .8fr .6fr .7fr .6fr .7fr"},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[e.icon?jsxRuntime.jsx("img",{src:e.icon,alt:e.market,className:"h-5 w-5 flex-shrink-0 rounded-full"}):jsxRuntime.jsx("div",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-full bg-[#1C1C26] text-[8px] font-bold text-[#5C5C72]",children:"?"}),jsxRuntime.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:e.market})]}),jsxRuntime.jsx(kt,{source:e.source}),jsxRuntime.jsx("span",{className:ui.clsx("text-right text-xs font-medium",e.position==="Yes"?"text-[#00E676]":"text-[#FF5252]"),children:e.position}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-foreground",children:v(e.stake)}),jsxRuntime.jsx("span",{className:"text-right",children:jsxRuntime.jsx("span",{className:ui.clsx("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",t?"bg-[rgba(0,230,118,0.12)] text-[#00E676]":"bg-[rgba(255,82,82,0.12)] text-[#FF5252]"),children:t?"Won":"Lost"})}),jsxRuntime.jsx("span",{className:ui.clsx("text-right font-mono text-xs",t?"text-[#00E676]":"text-[#5C5C72]"),children:t?`+${v(e.payout)}`:v(e.payout)})]})}function Ge({state:e}){let{spotSubTab:t,setSpotSubTab:o,spotSearch:r,setSpotSearch:s,hideSmall:d,setHideSmall:n,groupCollapsed:p,toggleGroupCollapsed:c,filteredSpotHoldings:u,spotHistoryQuery:b}=e;return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between pb-3",children:[jsxRuntime.jsx(z,{tabs:[{key:"holdings",label:"Holdings"},{key:"history",label:"History"}],activeKey:t,onTabChange:g=>o(g)}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(G,{value:r,onChange:s,placeholder:"Search token\u2026"}),t==="holdings"&&jsxRuntime.jsxs("label",{className:"flex cursor-pointer items-center gap-1.5 text-[11px] text-[#5C5C72] select-none",children:[jsxRuntime.jsx("input",{type:"checkbox",className:"accent-[#C8FF00]",checked:d,onChange:g=>n(g.target.checked)}),"Hide small"]})]})]}),t==="holdings"?jsxRuntime.jsx(Ho,{holdings:u,groupCollapsed:p,onToggleGroup:c}):jsxRuntime.jsx(Do,{records:b.data?.trades??[],isLoading:b.isLoading})]})}function Ho({holdings:e,groupCollapsed:t,onToggleGroup:o}){return e.length===0?jsxRuntime.jsx(O,{title:"No tokens found",hint:"Your spot tokens will appear here"}):jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"grid gap-2 px-3 pb-2 text-[10px] font-medium uppercase tracking-wider text-[#5C5C72]",style:{gridTemplateColumns:"2fr 1fr 1fr 1fr 1fr"},children:[jsxRuntime.jsx("span",{children:"Asset"}),jsxRuntime.jsx("span",{className:"text-right",children:"Balance"}),jsxRuntime.jsx("span",{className:"text-right",children:"Price"}),jsxRuntime.jsx("span",{className:"text-right",children:"Value"}),jsxRuntime.jsx("span",{className:"text-right",children:"24h"})]}),jsxRuntime.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 px-3 py-2 text-[10px] font-medium uppercase tracking-wider text-[#5C5C72] transition-colors hover:text-[#A0A0B8]",onClick:o,children:[jsxRuntime.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",className:ui.clsx("transition-transform",t&&"-rotate-90"),children:jsxRuntime.jsx("path",{d:"M4 6l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),jsxRuntime.jsx("span",{children:"Tokens"}),jsxRuntime.jsx("span",{className:"text-[#3A3A4E]",children:e.length})]}),!t&&jsxRuntime.jsx("div",{className:"flex flex-col",children:e.map(r=>jsxRuntime.jsx(Fo,{holding:r},r.tokenAddress))})]})}function Fo({holding:e}){let t=e.change24h>=0;return jsxRuntime.jsxs("div",{className:"grid items-center gap-2 rounded-[5px] px-3 py-2.5 transition-colors hover:bg-[#16161E]",style:{gridTemplateColumns:"2fr 1fr 1fr 1fr 1fr"},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2.5 overflow-hidden",children:[e.image?jsxRuntime.jsx("img",{src:e.image,alt:e.symbol,className:"h-7 w-7 flex-shrink-0 rounded-full"}):jsxRuntime.jsx("div",{className:"flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-full bg-[#1C1C26] text-[10px] font-bold text-[#5C5C72]",children:e.symbol.slice(0,2)}),jsxRuntime.jsxs("div",{className:"flex flex-col overflow-hidden",children:[jsxRuntime.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:e.name}),jsxRuntime.jsx("span",{className:"text-[10px] text-[#5C5C72]",children:e.symbol})]})]}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-foreground",children:be(e.balance)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#A0A0B8]",children:v(e.price)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-foreground",children:v(e.value)}),jsxRuntime.jsx("span",{className:ui.clsx("text-right font-mono text-xs",t?"text-[#00E676]":"text-[#FF5252]"),children:Je(e.change24h)})]})}function Do({records:e,isLoading:t}){return t?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-16",children:jsxRuntime.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-[#C8FF00] border-t-transparent"})}):e.length===0?jsxRuntime.jsx(O,{title:"No history found",hint:"Transaction history will appear here"}):jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"grid gap-2 px-3 pb-2 text-[10px] font-medium uppercase tracking-wider text-[#5C5C72]",style:{gridTemplateColumns:"80px 1.5fr 1fr 1fr 100px 80px"},children:[jsxRuntime.jsx("span",{children:"Type"}),jsxRuntime.jsx("span",{children:"Detail"}),jsxRuntime.jsx("span",{className:"text-right",children:"Amount"}),jsxRuntime.jsx("span",{className:"text-right",children:"Value"}),jsxRuntime.jsx("span",{className:"text-right",children:"Time"}),jsxRuntime.jsx("span",{className:"text-right",children:"TxHash"})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:e.map(o=>jsxRuntime.jsx(Io,{record:o},`${o.txHash}-${o.tokenAddress}`))})]})}var Eo={swap:"bg-[rgba(139,123,255,0.12)] text-[#8B7BFF]",send:"bg-[rgba(255,82,82,0.12)] text-[#FF5252]",receive:"bg-[rgba(0,230,118,0.12)] text-[#00E676]"},Qo={swap:"Swap",send:"Send",receive:"Receive"};function Uo(e){return e.type==="swap"&&e.sideTokenSymbol?`${e.tokenSymbol} \u2192 ${e.sideTokenSymbol}`:e.tokenName||e.tokenSymbol}function Io({record:e}){let t=et(e.txHash,e.chain);return jsxRuntime.jsxs("div",{className:"grid items-center gap-2 rounded-[5px] px-3 py-2.5 transition-colors hover:bg-[#16161E]",style:{gridTemplateColumns:"80px 1.5fr 1fr 1fr 100px 80px"},children:[jsxRuntime.jsx("span",{children:jsxRuntime.jsx("span",{className:ui.clsx("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",Eo[e.type]),children:Qo[e.type]})}),jsxRuntime.jsx("span",{className:"truncate text-xs text-foreground",children:Uo(e)}),jsxRuntime.jsxs("span",{className:"text-right font-mono text-xs text-foreground",children:[be(e.tokenAmount)," ",e.tokenSymbol]}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#A0A0B8]",children:v(e.valueUsd)}),jsxRuntime.jsx("span",{className:"text-right text-[11px] text-[#5C5C72]",children:e.timestamp?ot(e.timestamp):"\u2014"}),jsxRuntime.jsx("span",{className:"text-right",children:e.txHash?jsxRuntime.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"font-mono text-[11px] text-[#5C5C72] transition-colors hover:text-[#C8FF00]",children:[e.txHash.slice(0,4),"\u2026",e.txHash.slice(-3)]}):jsxRuntime.jsx("span",{className:"font-mono text-[11px] text-[#3A3A4E]",children:"\u2014"})})]})}function Oo({onClosePosition:e,onCloseAllPositions:t,onSellBet:o,onSellAllBets:r,...s}){let d=qe(s),[n,p]=react.useState(null),c=react.useCallback(()=>{p("closeAll");},[]),u=react.useCallback(()=>{p("sellAll");},[]),b=react.useCallback(()=>{n==="closeAll"?t?.():n==="sellAll"&&r?.(),p(null);},[n,t,r]),g=react.useCallback(()=>{p(null);},[]);return jsxRuntime.jsxs("div",{className:"rounded-xl border border-[#1C1C26] bg-[#0E0E16] p-4",children:[(()=>{switch(s.activeTab){case "spot":return jsxRuntime.jsx(Ge,{state:d});case "perps":return jsxRuntime.jsx($e,{state:d,onClosePosition:e,onCloseAll:c});case "prediction":return jsxRuntime.jsx(Ye,{state:d,onSellBet:o,onSellAll:u});default:return null}})(),jsxRuntime.jsx(me,{open:n==="closeAll",title:"Close All Positions",message:"Close all positions? This will route to each protocol to execute.",confirmLabel:"Confirm Close All",cancelLabel:"Cancel",onConfirm:b,onCancel:g}),jsxRuntime.jsx(me,{open:n==="sellAll",title:"Sell All Positions",message:"Sell all positions? This will route to each platform to execute.",confirmLabel:"Confirm Sell All",cancelLabel:"Cancel",onConfirm:b,onCancel:g})]})}function Lo({client:e,children:t}){return jsxRuntime.jsx(re.Provider,{value:{client:e},children:t})}
2
- exports.AddressRowUI=Pe;exports.AssetTab=oe;exports.AssetTabsUI=Ce;exports.BalanceRowUI=Se;exports.BatchActionButton=ae;exports.CURVE_PERIOD_VALUE=st;exports.ConfirmDialog=me;exports.CurveCardUI=ke;exports.CurvePeriod=he;exports.CurveType=ve;exports.DistributionCardUI=Te;exports.HoldingsEmpty=O;exports.HoldingsSearch=G;exports.HoldingsSectionWidget=Oo;exports.HoldingsSubTabs=z;exports.PerpsPanelUI=$e;exports.PerpsPositionSide=it;exports.PortfolioContext=re;exports.PortfolioPageSkeleton=Ve;exports.PortfolioPageWidget=go;exports.PortfolioProvider=Lo;exports.PredictionBetStatus=lt;exports.PredictionPanelUI=Ye;exports.PredictionResult=pt;exports.PredictionSource=dt;exports.SpotHistoryType=at;exports.SpotPanelUI=Ge;exports.ViewingBannerUI=_e;exports.computeDistribution=tt;exports.curveDataQueryKey=Nt;exports.distributionQueryKey=xo;exports.formatPercent=Je;exports.formatSignedUsd=te;exports.formatTime=ot;exports.formatTokenBalance=be;exports.formatUsd=v;exports.getExplorerUrl=et;exports.overviewQueryKey=gt;exports.parseDecimal=Wo;exports.perpsHistoryQueryKey=vt;exports.perpsPositionsQueryKey=Pt;exports.predictionBetsQueryKey=ht;exports.predictionSettledQueryKey=Ct;exports.splitUsd=Ze;exports.spotHistoryQueryKey=bt;exports.spotHoldingsQueryKey=yt;exports.truncateAddress=X;exports.useCurveDataQuery=Re;exports.useDistributionQuery=Oe;exports.useHoldingsSection=qe;exports.useOverviewQuery=Fe;exports.usePerpsHistoryQuery=Qe;exports.usePerpsPositionsQuery=Ee;exports.usePortfolioClient=N;exports.usePortfolioContext=He;exports.usePortfolioPage=Le;exports.usePredictionBetsQuery=Ue;exports.usePredictionSettledQuery=Ie;exports.useSpotHistoryQuery=De;exports.useSpotHoldingsQuery=ne;exports.version=At;//# sourceMappingURL=index.js.map
1
+ 'use strict';var react=require('react'),ui=require('@liberfi.io/ui'),jsxRuntime=require('react/jsx-runtime'),recharts=require('recharts'),reactQuery=require('@tanstack/react-query'),jotai=require('jotai'),client=require('@liberfi.io/client'),uiChainSelect=require('@liberfi.io/ui-chain-select'),walletConnector=require('@liberfi.io/wallet-connector');typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/ui-portfolio"]="0.1.2");var It="0.1.2";function ar(e){if(!e)return 0;let t=Number(e);return Number.isFinite(t)?t:0}function v(e){let t=Math.abs(e),o=e<0?"-":"";return t>=1e6?`${o}$${(t/1e6).toFixed(1)}M`:t>=1e4?`${o}$${(t/1e3).toFixed(1)}K`:t>=1?`${o}$${t.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`:t>=.01?`${o}$${t.toFixed(2)}`:t>0?`${o}<$0.01`:"$0.00"}function te(e){let t=v(Math.abs(e));return e>0?`+${t}`:e<0?`-${t.replace("-","")}`:t}function it(e){return `${e>0?"+":""}${e.toFixed(2)}%`}function at(e){let o=Math.abs(e).toFixed(2).split("."),r=Number(o[0]).toLocaleString("en-US"),s=`.${o[1]}`;return {sign:e<0?"-$":"$",integer:r,decimal:s}}function X(e,t=4,o=4){return e.length<=t+o+3?e:`${e.slice(0,t)}\u2026${e.slice(-o)}`}function Pe(e){return e===0?"0":e>=1e6?`${(e/1e6).toFixed(2)}M`:e>=1e3?e.toLocaleString("en-US",{maximumFractionDigits:2}):e>=1?e.toFixed(2):e>=1e-4?e.toFixed(4):"<0.0001"}function lt(e,t){return `https://solscan.io/tx/${e}`}var nt=["#C8FF00","#00E676","#0066FF","#FF6B9D","#8B7BFF","#FF5252","#FFB74D","#4DD0E1"],Ot="#3A3A4E";function pt(e){let t=e.reduce((n,i)=>n+i.value,0);if(t<=0)return {items:[]};let o=[...e].sort((n,i)=>i.value-n.value),r=[],s=0,c=0;for(let n of o){let i=n.value/t*100;i<2?s+=n.value:(r.push({name:n.name,symbol:n.symbol,percent:i,value:n.value,color:nt[c%nt.length]}),c++);}return s>0&&r.push({name:"Other",symbol:"OTHER",percent:s/t*100,value:s,color:Ot}),{items:r}}function dt(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:false})}function he({walletId:e,wallets:t,isViewing:o,viewingAddress:r,onSelectWallet:s,onCopyAddress:c,onSearch:n}){let[i,a]=react.useState(false),[m,f]=react.useState(""),u=react.useRef(null),P=!e&&!o,N=t.find(y=>y.id===e),I=o?"External":P?"All Wallets":N?.name??"",g=o?X(r??""):P?"Aggregated":X(N?.address??""),T=o?"bg-[#5C5C72]":P?"bg-[#C8FF00]":"bg-[#00E676]",h=react.useCallback(()=>{let y=m.trim();y.length>=32&&(n(y),f(""));},[m,n]),D=react.useCallback(y=>{y.key==="Enter"&&h();},[h]);return jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-4 pb-4",children:[jsxRuntime.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[jsxRuntime.jsxs("div",{className:"relative",ref:u,children:[jsxRuntime.jsxs("button",{type:"button",className:ui.clsx("flex items-center gap-2 rounded-lg border px-2.5 py-1.5 transition-colors",o?"border-[rgba(200,255,0,0.2)] bg-[rgba(200,255,0,0.04)]":"border-[#252530] bg-[#16161E] hover:border-[#35354A] hover:bg-[#1C1C26]",o&&"pointer-events-none"),onClick:()=>!o&&a(y=>!y),children:[jsxRuntime.jsx("span",{className:ui.clsx("h-[7px] w-[7px] flex-shrink-0 rounded-full",T)}),jsxRuntime.jsx("span",{className:"text-[11px] font-medium text-[#A0A0B8]",children:I}),jsxRuntime.jsx("span",{className:"font-mono text-xs text-foreground",children:g}),!o&&jsxRuntime.jsx("svg",{className:ui.clsx("text-[#5C5C72] transition-transform",i&&"rotate-180"),width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",children:jsxRuntime.jsx("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round"})})]}),i&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>a(false)}),jsxRuntime.jsxs("div",{className:"absolute left-0 top-[calc(100%+4px)] z-50 min-w-[260px] rounded-lg border border-[#252530] bg-[#16161E] p-1 shadow-[0_8px_32px_rgba(0,0,0,0.4)]",children:[jsxRuntime.jsxs("button",{type:"button",className:ui.clsx("flex w-full items-center gap-2 rounded-[5px] px-2.5 py-2 transition-colors hover:bg-[#1C1C26]",P&&"bg-[rgba(200,255,0,0.07)]"),onClick:()=>{s(void 0),a(false);},children:[jsxRuntime.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[#C8FF00]"}),jsxRuntime.jsx("span",{className:"min-w-[60px] text-[11px] font-medium text-[#A0A0B8]",children:"All Wallets"}),jsxRuntime.jsx("span",{className:"text-[11px] text-[#3A3A4E]",children:"Aggregated"})]}),t.map(y=>jsxRuntime.jsxs("button",{type:"button",className:ui.clsx("flex w-full items-center gap-2 rounded-[5px] px-2.5 py-2 transition-colors hover:bg-[#1C1C26]",e===y.id&&"bg-[rgba(200,255,0,0.07)]"),onClick:()=>{s(y.id),a(false);},children:[jsxRuntime.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[#00E676]"}),jsxRuntime.jsx("span",{className:"min-w-[60px] text-[11px] font-medium text-[#A0A0B8]",children:y.name}),jsxRuntime.jsx("span",{className:"font-mono text-[11px] text-[#5C5C72]",children:X(y.address)}),jsxRuntime.jsx("span",{className:"ml-auto font-mono text-[11px] font-medium text-foreground",children:y.balance})]},y.id))]})]})]}),jsxRuntime.jsx("button",{type:"button",className:ui.clsx("rounded p-1 text-[#5C5C72] transition-colors hover:bg-[#1C1C26] hover:text-[#C8FF00]",P&&!o&&"pointer-events-none opacity-40"),onClick:c,disabled:P&&!o,children:jsxRuntime.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:[jsxRuntime.jsx("rect",{x:"4.5",y:"4.5",width:"7",height:"7",rx:"1.5",stroke:"currentColor",strokeWidth:"1.2"}),jsxRuntime.jsx("path",{d:"M9.5 4.5V3a1.5 1.5 0 0 0-1.5-1.5H3A1.5 1.5 0 0 0 1.5 3v5A1.5 1.5 0 0 0 3 9.5h1.5",stroke:"currentColor",strokeWidth:"1.2"})]})}),jsxRuntime.jsx("span",{className:ui.clsx("flex-shrink-0 rounded-[3px] px-1.5 py-[3px] text-[9px] font-semibold uppercase tracking-wider",o?"bg-[rgba(200,255,0,0.07)] text-[#C8FF00] animate-[pulse-glow_2s_ease-in-out_infinite]":"bg-[rgba(0,230,118,0.1)] text-[#00E676]"),children:o?"Viewing":"Owner"})]}),jsxRuntime.jsxs("div",{className:"flex flex-shrink-0 items-center gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex h-[34px] w-[240px] items-center gap-1.5 rounded-lg border border-[#252530] bg-[#16161E] px-2.5 transition-all focus-within:w-[300px] focus-within:border-[#C8FF00]",children:[jsxRuntime.jsxs("svg",{className:"flex-shrink-0 text-[#5C5C72]",width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"7",cy:"7",r:"5.5",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M11 11L14.5 14.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),jsxRuntime.jsx("input",{className:"flex-1 border-none bg-transparent font-mono text-xs text-foreground caret-[#C8FF00] outline-none placeholder:font-sans placeholder:text-[11px] placeholder:text-[#5C5C72]",placeholder:"Search wallet address\u2026",spellCheck:false,value:m,onChange:y=>f(y.target.value),onKeyDown:D})]}),jsxRuntime.jsx("button",{type:"button",className:"whitespace-nowrap rounded-[5px] border border-[#252530] bg-[#1C1C26] px-3 py-1.5 text-[11px] font-medium text-[#A0A0B8] transition-colors hover:border-[#C8FF00] hover:bg-[#C8FF00] hover:text-black",onClick:h,children:"View"})]})]})}var oe=(r=>(r.SPOT="spot",r.PERPS="perps",r.PREDICTION="prediction",r))(oe||{}),ve=(o=>(o.NET_WORTH="networth",o.PNL="pnl",o))(ve||{}),Ce=(s=>(s.ONE_DAY="1D",s.SEVEN_DAY="7D",s.THIRTY_DAY="30D",s.MAX="Max",s))(Ce||{}),mt={"1D":1,"7D":7,"30D":30,Max:365},ft=(o=>(o.LONG="long",o.SHORT="short",o))(ft||{}),xt=(r=>(r.SWAP="swap",r.SEND="send",r.RECEIVE="receive",r))(xt||{}),gt=(o=>(o.ACTIVE="active",o.PENDING="pending",o))(gt||{}),yt=(o=>(o.WON="won",o.LOST="lost",o))(yt||{}),bt=(r=>(r.POLYMARKET="polymarket",r.DRIFT="drift",r.METADAO="metadao",r))(bt||{});var _t=[{key:"spot",label:"Spot"},{key:"perps",label:"Perps"},{key:"prediction",label:"Prediction"}];function Vt(e,t,o,r){switch(e){case "spot":return t;case "perps":return o;case "prediction":return r}}function Se({activeTab:e,onTabChange:t,spotValue:o=0,perpsValue:r=0,predictionValue:s=0}){return jsxRuntime.jsx("div",{className:"flex gap-1 border-b border-[#252530] pb-0 pt-5",children:_t.map(({key:c,label:n})=>{let i=e===c,a=Vt(c,o,r,s);return jsxRuntime.jsxs("button",{type:"button",className:ui.clsx("relative flex items-center gap-2 border-b-2 px-4 pb-3 pt-2.5 text-[13px] font-medium transition-colors",i?"border-[#C8FF00] text-foreground":"border-transparent text-[#5C5C72] hover:text-[#A0A0B8]"),onClick:()=>t(c),children:[n,!i&&jsxRuntime.jsx("span",{className:"rounded-[10px] bg-[#16161E] px-2 py-0.5 font-mono text-[11px] text-[#5C5C72]",children:v(a)})]},c)})})}function we({overview:e}){let t=e?.totalValue??0,o=e?.uPnl??0,r=e?.realizedPnl??0,s=e?.totalProfit??0,{sign:c,integer:n,decimal:i}=at(t);return jsxRuntime.jsxs("div",{className:"flex items-center gap-4 pb-4",children:[jsxRuntime.jsx("div",{className:"flex items-baseline gap-3",children:jsxRuntime.jsxs("div",{className:"font-mono text-[26px] font-bold leading-none tracking-tight",children:[jsxRuntime.jsx("span",{className:"mr-px text-lg font-medium text-[#C8FF00]",children:c}),n,jsxRuntime.jsx("span",{className:"text-base font-normal text-[#5C5C72]",children:i})]})}),jsxRuntime.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[jsxRuntime.jsx(Ne,{label:"uPNL",value:o}),jsxRuntime.jsx(ht,{}),jsxRuntime.jsx(Ne,{label:"Realized",value:r}),jsxRuntime.jsx(ht,{}),jsxRuntime.jsx(Ne,{label:"Total Profit",value:s})]})]})}function Ne({label:e,value:t}){return jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx("span",{className:"text-[11px] text-[#5C5C72]",children:e}),jsxRuntime.jsx("span",{className:ui.clsx("font-mono text-xs font-medium",t>0?"text-[#00E676]":t<0?"text-[#FF5252]":"text-[#5C5C72]"),children:te(t)})]})}function ht(){return jsxRuntime.jsx("div",{className:"h-3.5 w-px bg-[#252530]"})}var Xt=["1D","7D","30D","Max"];function vt(e,t){let o=new Date(e);switch(t){case "1D":return o.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false});default:return o.toLocaleDateString("en-US",{month:"short",day:"numeric"})}}function Jt(e){return e==="pnl"?"change":"netWorth"}function ke({curveType:e,curvePeriod:t,data:o,isLoading:r,onTypeChange:s,onPeriodChange:c}){let n=o?.points??[],i=Jt(e),a=e==="pnl",m=react.useMemo(()=>n.map(g=>a?g.change:g.netWorth),[n,a]),f=m.some(g=>g<0),{minVal:u,maxVal:P}=react.useMemo(()=>{if(m.length===0)return {minVal:0,maxVal:100};let g=Math.min(...m),T=Math.max(...m),h=T-g||1;return {minVal:g-h*.1,maxVal:T+h*.1}},[m]),N=react.useMemo(()=>{if(n.length===0)return [];let g=Math.min(7,n.length),T=Math.max(1,Math.floor((n.length-1)/(g-1))),h=[];for(let y=0;y<n.length;y+=T)h.push({ts:n[y].timestamp,label:vt(n[y].timestamp,t)});let D=n[n.length-1];return h[h.length-1]?.ts!==D.timestamp&&h.push({ts:D.timestamp,label:vt(D.timestamp,t)}),h},[n,t]),I=m[m.length-1]??0;return jsxRuntime.jsxs("div",{className:"overflow-hidden rounded-lg border border-[#252530] bg-[#0F0F16]",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 pt-3",children:[jsxRuntime.jsxs("div",{className:"flex gap-0.5 rounded-[5px] bg-[#16161E] p-0.5",children:[jsxRuntime.jsx(Ct,{label:"Net Worth",active:e==="networth",onClick:()=>s("networth")}),jsxRuntime.jsx(Ct,{label:"PNL",active:e==="pnl",onClick:()=>s("pnl")})]}),jsxRuntime.jsx("div",{className:"flex gap-0.5",children:Xt.map(g=>jsxRuntime.jsx("button",{type:"button",className:ui.clsx("rounded-[3px] px-2 py-1 text-[10px] font-medium transition-colors",t===g?"bg-[rgba(200,255,0,0.07)] text-[#C8FF00]":"text-[#5C5C72] hover:bg-[#16161E] hover:text-[#A0A0B8]"),onClick:()=>c(g),children:g},g))})]}),jsxRuntime.jsx("div",{className:"h-[180px] px-4 pt-2",children:r||n.length<2?jsxRuntime.jsx("div",{className:"flex h-full items-center justify-center",children:jsxRuntime.jsx("span",{className:"text-xs text-[#5C5C72]",children:r?"":"Not enough data"})}):jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",children:jsxRuntime.jsxs(recharts.AreaChart,{data:n,margin:{top:8,right:0,left:0,bottom:0},children:[jsxRuntime.jsxs("defs",{children:[jsxRuntime.jsxs("linearGradient",{id:"gradAccent",x1:"0",y1:"0",x2:"0",y2:"1",children:[jsxRuntime.jsx("stop",{offset:"0%",stopColor:"#C8FF00",stopOpacity:.12}),jsxRuntime.jsx("stop",{offset:"100%",stopColor:"#C8FF00",stopOpacity:0})]}),jsxRuntime.jsxs("linearGradient",{id:"gradGreen",x1:"0",y1:"0",x2:"0",y2:"1",children:[jsxRuntime.jsx("stop",{offset:"0%",stopColor:"#00E676",stopOpacity:.12}),jsxRuntime.jsx("stop",{offset:"100%",stopColor:"#00E676",stopOpacity:0})]}),jsxRuntime.jsxs("linearGradient",{id:"gradRed",x1:"0",y1:"0",x2:"0",y2:"1",children:[jsxRuntime.jsx("stop",{offset:"0%",stopColor:"#FF5252",stopOpacity:0}),jsxRuntime.jsx("stop",{offset:"100%",stopColor:"#FF5252",stopOpacity:.1})]})]}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"timestamp",hide:true}),jsxRuntime.jsx(recharts.YAxis,{hide:true,domain:[u,P]}),a&&f&&jsxRuntime.jsx(recharts.ReferenceLine,{y:0,stroke:"rgba(255,255,255,0.06)",strokeDasharray:"4 4"}),jsxRuntime.jsx(recharts.Area,{type:"monotone",dataKey:i,stroke:a?I>=0?"#00E676":"#FF5252":"#C8FF00",strokeWidth:1.5,fill:a?I>=0?"url(#gradGreen)":"url(#gradRed)":"url(#gradAccent)",dot:false,isAnimationActive:false})]})})}),jsxRuntime.jsx("div",{className:"flex justify-between px-4 pb-2.5 pt-1",children:N.map(({ts:g,label:T})=>jsxRuntime.jsx("span",{className:"font-mono text-[9px] text-[#3A3A4E]",children:T},g))})]})}function Ct({label:e,active:t,onClick:o}){return jsxRuntime.jsx("button",{type:"button",className:ui.clsx("rounded px-2.5 py-1 text-[11px] font-medium transition-colors",t?"bg-[#1C1C26] text-foreground":"text-[#5C5C72] hover:text-[#A0A0B8]"),onClick:o,children:e})}function Fe({data:e,isLoading:t}){let o=e?.items??[],r=react.useMemo(()=>o.map(s=>({name:s.name,value:s.percent})),[o]);return jsxRuntime.jsxs("div",{className:"flex flex-col overflow-hidden rounded-lg border border-[#252530] bg-[#0F0F16]",children:[jsxRuntime.jsx("div",{className:"px-4 pb-2 pt-3",children:jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[#A0A0B8]",children:"Distribution"})}),jsxRuntime.jsx("div",{className:"flex flex-1 items-center justify-center px-4",children:t||o.length===0?jsxRuntime.jsx("div",{className:"flex h-[140px] w-[140px] items-center justify-center",children:jsxRuntime.jsx("span",{className:"text-xs text-[#5C5C72]",children:t?"":"No data"})}):jsxRuntime.jsx(recharts.ResponsiveContainer,{width:140,height:140,children:jsxRuntime.jsx(recharts.PieChart,{children:jsxRuntime.jsx(recharts.Pie,{data:r,cx:"50%",cy:"50%",innerRadius:32,outerRadius:55,dataKey:"value",stroke:"none",isAnimationActive:false,children:o.map((s,c)=>jsxRuntime.jsx(recharts.Cell,{fill:s.color},c))})})})}),jsxRuntime.jsx("div",{className:"px-4 pb-3 pt-2",children:o.map((s,c)=>jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 py-[3px] text-[11px]",children:[jsxRuntime.jsx("span",{className:"h-[7px] w-[7px] flex-shrink-0 rounded-[2px]",style:{background:s.color}}),jsxRuntime.jsx("span",{className:"min-w-0 flex-1 truncate text-[#A0A0B8]",children:s.name}),jsxRuntime.jsxs("span",{className:"font-mono text-[10px] text-[#5C5C72]",children:[s.percent.toFixed(1),"%"]}),jsxRuntime.jsx("span",{className:"min-w-[55px] text-right font-mono text-[10px] text-foreground",children:v(s.value)})]},c))})]})}var re=react.createContext({});function He(){let e=react.useContext(re);if(!e)throw new Error("usePortfolioContext must be used within a PortfolioProvider");return e}function w(){let{client:e}=He();return e}function Nt(e){return ["portfolio","overview",e??{}]}async function ao(e,t){return await e.getOverview(t)}function De(e,t={}){let o=w();return reactQuery.useQuery({queryKey:Nt(e),queryFn:async()=>ao(o,e),...t})}function wt(e){return ["portfolio","spot","holdings",e??{}]}async function po(e,t){return await e.getSpotHoldings(t)}function se(e,t={}){let o=w();return reactQuery.useQuery({queryKey:wt(e),queryFn:async()=>po(o,e),...t})}function At(e){return ["portfolio","spot","history",e??{}]}async function uo(e,t){return await e.getSpotHistory(t)}function Ee(e,t={}){let o=w();return reactQuery.useQuery({queryKey:At(e),queryFn:async()=>uo(o,e),...t})}function kt(e){return ["portfolio","perps","positions",e??{}]}async function fo(e,t){return await e.getPerpsPositions(t)}function Qe(e,t={}){let o=w();return reactQuery.useQuery({queryKey:kt(e),queryFn:async()=>fo(o,e),...t})}function Tt(e){return ["portfolio","perps","history",e??{}]}async function go(e,t){return await e.getPerpsHistory(t)}function Ue(e,t={}){let o=w();return reactQuery.useQuery({queryKey:Tt(e),queryFn:async()=>go(o,e),...t})}function Ft(e){return ["portfolio","prediction","active",e??{}]}async function bo(e,t){return await e.getPredictionBets(t)}function Re(e,t={}){let o=w();return reactQuery.useQuery({queryKey:Ft(e),queryFn:async()=>bo(o,e),...t})}function Ht(e){return ["portfolio","prediction","settled",e??{}]}async function ho(e,t){return await e.getPredictionSettled(t)}function Ie(e,t={}){let o=w();return reactQuery.useQuery({queryKey:Ht(e),queryFn:async()=>ho(o,e),...t})}function Dt(e){return ["portfolio","chart",e]}async function Co(e,t){return await e.getChartData(t)}function Oe(e,t={}){let o=w();return reactQuery.useQuery({queryKey:Dt(e),queryFn:async()=>Co(o,e),...t})}function No(){return ["portfolio","distribution"]}function Be(e){return {data:react.useMemo(()=>pt(e),[e])}}var Le=jotai.atom(null),We=jotai.atom({status:"pending",fetchStatus:"idle",isLoading:false,isPending:true,isFetching:false,isRefetching:false,isError:false,isSuccess:false,error:null,dataUpdatedAt:0}),Et=jotai.atom({current:()=>Promise.resolve()}),_e=jotai.atom(e=>e(Et).current,(e,t,o)=>t(Et,{current:o}));var Fo=15e3;function Ho(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}function qe({chain:e,address:t,enabled:o=true,summaryPollMs:r=Fo}){let s=jotai.useSetAtom(Le),c=jotai.useSetAtom(We),n=jotai.useSetAtom(_e),i=client.useWalletPortfoliosQuery({chain:e,address:t},{enabled:o,refetchInterval:r}),a=client.useWalletPnlQuery({chain:e,address:t},{enabled:o,refetchInterval:r});react.useEffect(()=>{let f=i.isPending||a.isPending,u=i.isFetching||a.isFetching,P=i.isError||a.isError,N=i.isSuccess&&a.isSuccess;c({status:P?"error":N?"success":"pending",fetchStatus:u?"fetching":"idle",isLoading:f&&u,isPending:f,isFetching:u,isRefetching:N&&u,isError:P,isSuccess:N,error:i.error??a.error,dataUpdatedAt:Math.max(i.dataUpdatedAt,a.dataUpdatedAt)});},[i.isPending,i.isFetching,i.isError,i.isSuccess,i.error,i.dataUpdatedAt,a.isPending,a.isFetching,a.isError,a.isSuccess,a.error,a.dataUpdatedAt,c]),react.useEffect(()=>{let f=i.data,u=a.data;!f||!u||s({...u,balanceInUsd:f.balanceInUsd,balanceInNative:f.balanceInNative});},[i.data,a.data,s]),client.useWalletPnlSubscription({chain:e,address:t},f=>{s(u=>{if(!u)return u;let P=u;for(let N of f)P={...P,...Ho(N)};return P});},{enabled:o});let m=react.useCallback(async()=>{await Promise.all([i.refetch(),a.refetch()]);},[i,a]);react.useEffect(()=>{n(m);},[m,n]);}function Do(){let e=jotai.useAtomValue(Le),t=jotai.useAtomValue(We);return {data:e,...t}}function Eo(){return jotai.useAtomValue(_e)}function Ye(e){let{defaultTab:t="spot",walletAddresses:o,chain:r}=e??{},[s,c]=react.useState(t),[n,i]=react.useState(void 0),[a,m]=react.useState(void 0),[f,u]=react.useState("networth"),[P,N]=react.useState("7D"),I=a!==void 0,g=react.useMemo(()=>{if(a)return {walletAddresses:[a],chain:r};if(o?.length)return {walletAddresses:o,chain:r}},[o,a,r]),T=De(g),h=se(g),D=Oe({period:mt[P],...g}),y=Be(h.data?.holdings??[]),M=react.useMemo(()=>h.data?.holdings.reduce((U,pe)=>U+pe.value,0)??0,[h.data]),Z=react.useCallback(U=>{m(U);},[]),K=react.useCallback(()=>{m(void 0);},[]),ee=react.useCallback(U=>{i(U);},[]);return {activeTab:s,setActiveTab:c,walletId:n,selectWallet:ee,viewingAddress:a,isViewing:I,curveType:f,setCurveType:u,curvePeriod:P,setCurvePeriod:N,portfolioQuery:g,overviewQuery:T,curveQuery:D,distributionQuery:y,spotHoldingsQuery:h,spotValue:M,perpsValue:0,predictionValue:0,enterViewing:Z,exitViewing:K}}function ze(){return jsxRuntime.jsxs("div",{className:"mx-auto max-w-[1280px] px-6",children:[jsxRuntime.jsxs("div",{className:"flex gap-4 border-b border-[#252530] pb-0 pt-5",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-9 w-16 rounded-md"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-9 w-28 rounded-md"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-9 w-32 rounded-md"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-4 py-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2.5",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-48 rounded-lg"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-6 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-5 w-14 rounded-[3px]"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-[34px] w-[240px] rounded-lg"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-[34px] w-12 rounded-[5px]"})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 pb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-baseline gap-3",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-48 rounded-md"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-16 rounded"})]}),jsxRuntime.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-28 rounded"}),jsxRuntime.jsx("div",{className:"h-3.5 w-px bg-[#252530]"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-28 rounded"}),jsxRuntime.jsx("div",{className:"h-3.5 w-px bg-[#252530]"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-20 rounded"})]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-[1fr_340px] gap-3 pb-4",children:[jsxRuntime.jsxs("div",{className:"rounded-lg border border-[#252530] bg-[#0F0F16] p-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between pb-4",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-40 rounded-[5px]"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-32 rounded"})]}),jsxRuntime.jsx(ui.Skeleton,{className:"h-[180px] w-full rounded-md"}),jsxRuntime.jsx("div",{className:"mt-2 flex justify-between",children:Array.from({length:7}).map((e,t)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-3 w-8 rounded"},t))})]}),jsxRuntime.jsxs("div",{className:"rounded-lg border border-[#252530] bg-[#0F0F16] p-4",children:[jsxRuntime.jsx(ui.Skeleton,{className:"mb-3 h-4 w-24 rounded"}),jsxRuntime.jsx("div",{className:"flex items-center justify-center py-4",children:jsxRuntime.jsx(ui.Skeleton,{className:"h-[140px] w-[140px] rounded-full"})}),jsxRuntime.jsx("div",{className:"space-y-1.5 pt-2",children:Array.from({length:5}).map((e,t)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-full rounded"},t))})]})]}),jsxRuntime.jsxs("div",{className:"pb-6",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between pb-3",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-40 rounded-[5px]"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-40 rounded-[5px]"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-24 rounded-[5px]"})]})]}),jsxRuntime.jsx(ui.Skeleton,{className:"mb-3 h-5 w-full rounded"}),Array.from({length:5}).map((e,t)=>jsxRuntime.jsx(ui.Skeleton,{className:"mb-2 h-12 w-full rounded-[5px]"},t))]})]})}function Ge({viewingAddress:e,onBack:t}){return jsxRuntime.jsxs("div",{className:"flex items-center justify-between border-b border-[rgba(200,255,0,0.12)] bg-[rgba(200,255,0,0.06)] px-6 py-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"flex h-[18px] w-[18px] items-center justify-center rounded-full border border-[rgba(200,255,0,0.25)] bg-[rgba(200,255,0,0.07)]",children:jsxRuntime.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",children:[jsxRuntime.jsx("path",{d:"M8 3C4.36 3 1.26 5.28 0 8.5c1.26 3.22 4.36 5.5 8 5.5s6.74-2.28 8-5.5C14.74 5.28 11.64 3 8 3z",stroke:"#C8FF00",strokeWidth:"1.3",fill:"none"}),jsxRuntime.jsx("circle",{cx:"8",cy:"8.5",r:"2.5",stroke:"#C8FF00",strokeWidth:"1.3",fill:"none"})]})}),jsxRuntime.jsx("span",{className:"text-xs font-medium text-[#C8FF00]",children:"Viewing external portfolio"}),jsxRuntime.jsx("span",{className:"ml-1 font-mono text-[11px] text-[#A0A0B8]",children:X(e)})]}),jsxRuntime.jsxs("button",{type:"button",className:"flex items-center gap-1.5 rounded-[5px] border border-[#252530] bg-[#1C1C26] px-3 py-1.5 text-[11px] font-medium text-[#A0A0B8] transition-colors hover:border-[#C8FF00] hover:bg-[#C8FF00] hover:text-black",onClick:t,children:[jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M10 2L4 8l6 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),"Back to My Portfolio"]})]})}function Qo({wallets:e=[],onCopyAddress:t,renderHoldings:o,isLoading:r,...s}){let c=Ye(s),{activeTab:n,setActiveTab:i,walletId:a,selectWallet:m,viewingAddress:f,isViewing:u,curveType:P,setCurveType:N,curvePeriod:I,setCurvePeriod:g,portfolioQuery:T,overviewQuery:h,curveQuery:D,distributionQuery:y,spotValue:M,perpsValue:Z,predictionValue:K,enterViewing:ee,exitViewing:U}=c;return r||h.isLoading&&!h.data?jsxRuntime.jsx(ze,{}):jsxRuntime.jsxs("div",{children:[u&&f&&jsxRuntime.jsx(Ge,{viewingAddress:f,onBack:U}),jsxRuntime.jsxs("div",{className:"mx-auto max-w-[1280px] px-6",children:[jsxRuntime.jsx(Se,{activeTab:n,onTabChange:i,spotValue:M,perpsValue:Z,predictionValue:K}),jsxRuntime.jsx(he,{walletId:a,wallets:e,isViewing:u,viewingAddress:f,onSelectWallet:m,onCopyAddress:()=>{if(u&&f)t?.(f);else {let de=e.find(be=>be.id===a);de&&t?.(de.address);}},onSearch:ee}),jsxRuntime.jsx(we,{overview:h.data}),jsxRuntime.jsxs("div",{className:"grid grid-cols-[1fr_340px] gap-3 pb-4",children:[jsxRuntime.jsx(ke,{curveType:P,curvePeriod:I,data:D.data,isLoading:D.isLoading,onTypeChange:N,onPeriodChange:g}),jsxRuntime.jsx(Fe,{data:y.data,isLoading:false})]}),o?.({activeTab:n,portfolioQuery:T,isViewing:u})]})]})}function fe({open:e,title:t,message:o,confirmLabel:r,cancelLabel:s,onConfirm:c,onCancel:n}){return e?jsxRuntime.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[jsxRuntime.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:n,onKeyDown:i=>{i.key==="Escape"&&n();},role:"button",tabIndex:-1,"aria-label":"Close dialog"}),jsxRuntime.jsxs("div",{className:"relative z-10 w-full max-w-sm rounded-xl border border-[#252530] bg-[#12121A] p-6 shadow-2xl",children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold text-foreground",children:t}),jsxRuntime.jsx("p",{className:"mt-2 text-xs leading-relaxed text-[#A0A0B8]",children:o}),jsxRuntime.jsxs("div",{className:"mt-5 flex items-center justify-end gap-2",children:[jsxRuntime.jsx("button",{type:"button",className:"rounded-lg px-4 py-2 text-xs font-medium text-[#5C5C72] transition-colors hover:bg-[#1C1C26] hover:text-foreground",onClick:n,children:s}),jsxRuntime.jsx("button",{type:"button",className:ui.clsx("rounded-lg border px-4 py-2 text-xs font-medium transition-colors","border-[rgba(255,82,82,0.25)] text-[#FF5252]","hover:border-[#FF5252] hover:bg-[rgba(255,82,82,0.1)]"),onClick:c,children:r})]})]})]}):null}function Ze({activeTab:e,portfolioQuery:t,isViewing:o}){let[r,s]=react.useState("holdings"),[c,n]=react.useState("positions"),[i,a]=react.useState("active"),[m,f]=react.useState(""),[u,P]=react.useState(""),[N,I]=react.useState(""),[g,T]=react.useState(false),[h,D]=react.useState(false),y=react.useCallback(()=>{D(L=>!L);},[]),M=se(t,{enabled:e==="spot"}),Z=Ee(t,{enabled:e==="spot"&&r==="history"}),K=Qe(t,{enabled:e==="perps"}),ee=Ue(t,{enabled:e==="perps"&&c==="history"}),U=Re(t,{enabled:e==="prediction"}),pe=Ie(t,{enabled:e==="prediction"&&i==="settled"}),st=react.useMemo(()=>(M.data?.holdings??[]).filter(W=>{if(g&&W.value<1&&!W.verified)return false;if(m){let j=m.toLowerCase();return W.name.toLowerCase().includes(j)||W.symbol.toLowerCase().includes(j)}return true}),[M.data?.holdings,g,m]),de=react.useMemo(()=>{let L=K.data?.positions??[];if(!u)return L;let W=u.toLowerCase();return L.filter(j=>j.pair.toLowerCase().includes(W))},[K.data?.positions,u]),be=react.useMemo(()=>{let L=U.data?.bets??[];if(!N)return L;let W=N.toLowerCase();return L.filter(j=>j.market.toLowerCase().includes(W))},[U.data?.bets,N]);return {spotSubTab:r,setSpotSubTab:s,perpsSubTab:c,setPerpsSubTab:n,predictionSubTab:i,setPredictionSubTab:a,spotSearch:m,setSpotSearch:f,perpsSearch:u,setPerpsSearch:P,predictionSearch:N,setPredictionSearch:I,hideSmall:g,setHideSmall:T,groupCollapsed:h,toggleGroupCollapsed:y,spotHoldingsQuery:M,spotHistoryQuery:Z,perpsPositionsQuery:K,perpsHistoryQuery:ee,predictionBetsQuery:U,predictionSettledQuery:pe,filteredSpotHoldings:st,filteredPerpsPositions:de,filteredPredictionBets:be,isViewing:o}}function z({tabs:e,activeKey:t,onTabChange:o}){return jsxRuntime.jsx("div",{className:"flex gap-0.5",children:e.map(r=>jsxRuntime.jsx("button",{type:"button",className:ui.clsx("rounded-[5px] px-3 py-1.5 text-xs font-medium transition-colors",t===r.key?"bg-[#1C1C26] text-foreground":"text-[#5C5C72] hover:bg-[#16161E] hover:text-[#A0A0B8]"),onClick:()=>o(r.key),children:r.label},r.key))})}function G({value:e,onChange:t,placeholder:o}){return jsxRuntime.jsxs("div",{className:"flex h-7 w-40 items-center gap-1 rounded-[5px] border border-[#252530] bg-[#16161E] px-2 transition-all focus-within:w-[200px] focus-within:border-[#C8FF00]",children:[jsxRuntime.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",className:"flex-shrink-0 text-[#5C5C72]",children:[jsxRuntime.jsx("circle",{cx:"7",cy:"7",r:"5.5",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M11 11L14.5 14.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),jsxRuntime.jsx("input",{type:"text",className:"flex-1 border-none bg-transparent font-mono text-[11px] text-foreground caret-[#C8FF00] outline-none placeholder:font-sans placeholder:text-[10px] placeholder:text-[#5C5C72]",placeholder:o,spellCheck:false,value:e,onChange:r=>t(r.target.value)})]})}function O({title:e,hint:t}){return jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[jsxRuntime.jsx("span",{className:"text-sm text-[#5C5C72]",children:e}),t&&jsxRuntime.jsx("span",{className:"mt-1 text-xs text-[#3A3A4E]",children:t})]})}function ae({label:e,disabled:t,onClick:o}){return jsxRuntime.jsxs("button",{type:"button",className:ui.clsx("flex items-center gap-1 whitespace-nowrap rounded-[5px] border px-3 py-1.5 text-[11px] font-medium transition-colors",t?"pointer-events-none border-[#252530] text-[#3A3A4E]":"border-[rgba(255,82,82,0.25)] text-[#FF5252] hover:border-[#FF5252] hover:bg-[rgba(255,82,82,0.1)]"),onClick:o,disabled:t,children:[jsxRuntime.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),e]})}function et({state:e,onClosePosition:t,onCloseAll:o}){let{perpsSubTab:r,setPerpsSubTab:s,perpsSearch:c,setPerpsSearch:n,filteredPerpsPositions:i,perpsHistoryQuery:a,isViewing:m}=e,f=i.length>0;return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between pb-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(z,{tabs:[{key:"positions",label:"Open Positions"},{key:"history",label:"Trade History"}],activeKey:r,onTabChange:u=>s(u)}),r==="positions"&&!m&&jsxRuntime.jsx(ae,{label:"Close All",disabled:!f,onClick:()=>o?.()})]}),jsxRuntime.jsx(G,{value:c,onChange:n,placeholder:"Search pair\u2026"})]}),r==="positions"?jsxRuntime.jsx(Io,{positions:i,isViewing:m,onClose:t}):jsxRuntime.jsx(Bo,{records:a.data?.records??[],isLoading:a.isLoading})]})}function Io({positions:e,isViewing:t,onClose:o}){return e.length===0?jsxRuntime.jsx(O,{title:"No open positions",hint:"Start trading \u2192"}):jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"grid gap-2 px-3 pb-2 text-[10px] font-medium uppercase tracking-wider text-[#5C5C72]",style:{gridTemplateColumns:t?"2fr 1fr .8fr .8fr 1fr":"2fr 1fr .8fr .8fr 1fr 80px"},children:[jsxRuntime.jsx("span",{children:"Pair / Side"}),jsxRuntime.jsx("span",{className:"text-right",children:"Size"}),jsxRuntime.jsx("span",{className:"text-right",children:"Entry"}),jsxRuntime.jsx("span",{className:"text-right",children:"Mark"}),jsxRuntime.jsx("span",{className:"text-right",children:"uPNL"}),!t&&jsxRuntime.jsx("span",{className:"text-right"})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:e.map(r=>jsxRuntime.jsx(Oo,{position:r,isViewing:t,onClose:o},r.id))})]})}function Oo({position:e,isViewing:t,onClose:o}){let r=e.side==="long",s=e.uPnl>=0;return jsxRuntime.jsxs("div",{className:"grid items-center gap-2 rounded-[5px] px-3 py-2.5 transition-colors hover:bg-[#16161E]",style:{gridTemplateColumns:t?"2fr 1fr .8fr .8fr 1fr":"2fr 1fr .8fr .8fr 1fr 80px"},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[e.icon?jsxRuntime.jsx("img",{src:e.icon,alt:e.pair,className:"h-6 w-6 flex-shrink-0 rounded-full"}):jsxRuntime.jsx("div",{className:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-full bg-[#1C1C26] text-[9px] font-bold text-[#5C5C72]",children:e.pair.slice(0,2)}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx("span",{className:"text-xs font-medium text-foreground",children:e.pair}),jsxRuntime.jsx("span",{className:ui.clsx("rounded px-1.5 py-0.5 text-[10px] font-medium",r?"bg-[rgba(0,230,118,0.12)] text-[#00E676]":"bg-[rgba(255,82,82,0.12)] text-[#FF5252]"),children:r?"Long":"Short"}),jsxRuntime.jsxs("span",{className:"rounded bg-[rgba(200,255,0,0.1)] px-1.5 py-0.5 text-[10px] font-medium text-[#C8FF00]",children:[e.leverage,"\xD7"]})]})]}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-foreground",children:v(e.size)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#A0A0B8]",children:v(e.entryPrice)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#A0A0B8]",children:v(e.markPrice)}),jsxRuntime.jsx("span",{className:ui.clsx("text-right font-mono text-xs",s?"text-[#00E676]":"text-[#FF5252]"),children:te(e.uPnl)}),!t&&jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx("button",{type:"button",className:"rounded-[5px] border border-[#252530] px-2.5 py-1 text-[10px] font-medium text-[#5C5C72] transition-colors hover:border-[#FF5252] hover:text-[#FF5252]",onClick:()=>o?.(e),children:"Close"})})]})}function Bo({records:e,isLoading:t}){return t?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-16",children:jsxRuntime.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-[#C8FF00] border-t-transparent"})}):e.length===0?jsxRuntime.jsx(O,{title:"No trade history",hint:"Closed positions will appear here"}):jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"grid gap-2 px-3 pb-2 text-[10px] font-medium uppercase tracking-wider text-[#5C5C72]",style:{gridTemplateColumns:"1.5fr 80px 1fr 1fr 1fr 100px"},children:[jsxRuntime.jsx("span",{children:"Pair"}),jsxRuntime.jsx("span",{children:"Side"}),jsxRuntime.jsx("span",{className:"text-right",children:"Size"}),jsxRuntime.jsx("span",{className:"text-right",children:"PNL"}),jsxRuntime.jsx("span",{className:"text-right",children:"Close Price"}),jsxRuntime.jsx("span",{className:"text-right",children:"Time"})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:e.map(o=>jsxRuntime.jsx(Lo,{record:o},o.id))})]})}function Lo({record:e}){let t=e.side==="long",o=e.pnl>=0;return jsxRuntime.jsxs("div",{className:"grid items-center gap-2 rounded-[5px] px-3 py-2.5 transition-colors hover:bg-[#16161E]",style:{gridTemplateColumns:"1.5fr 80px 1fr 1fr 1fr 100px"},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[e.icon?jsxRuntime.jsx("img",{src:e.icon,alt:e.pair,className:"h-5 w-5 flex-shrink-0 rounded-full"}):jsxRuntime.jsx("div",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-full bg-[#1C1C26] text-[8px] font-bold text-[#5C5C72]",children:e.pair.slice(0,2)}),jsxRuntime.jsx("span",{className:"text-xs font-medium text-foreground",children:e.pair})]}),jsxRuntime.jsx("span",{children:jsxRuntime.jsx("span",{className:ui.clsx("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",t?"bg-[rgba(0,230,118,0.12)] text-[#00E676]":"bg-[rgba(255,82,82,0.12)] text-[#FF5252]"),children:t?"Long":"Short"})}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-foreground",children:v(e.size)}),jsxRuntime.jsx("span",{className:ui.clsx("text-right font-mono text-xs",o?"text-[#00E676]":"text-[#FF5252]"),children:te(e.pnl)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#A0A0B8]",children:v(e.closePrice)}),jsxRuntime.jsx("span",{className:"text-right text-[11px] text-[#5C5C72]",children:e.time})]})}function tt({state:e,onSellBet:t,onSellAll:o}){let{predictionSubTab:r,setPredictionSubTab:s,predictionSearch:c,setPredictionSearch:n,filteredPredictionBets:i,predictionSettledQuery:a,isViewing:m}=e,f=i.length>0;return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between pb-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(z,{tabs:[{key:"active",label:"Active Bets"},{key:"settled",label:"Settled"}],activeKey:r,onTabChange:u=>s(u)}),r==="active"&&!m&&jsxRuntime.jsx(ae,{label:"Sell All",disabled:!f,onClick:()=>o?.()})]}),jsxRuntime.jsx(G,{value:c,onChange:n,placeholder:"Search market\u2026"})]}),r==="active"?jsxRuntime.jsx(Vo,{bets:i,isViewing:m,onSell:t}):jsxRuntime.jsx(Ko,{records:a.data?.records??[],isLoading:a.isLoading})]})}var Wo={polymarket:"bg-[rgba(0,102,255,0.12)] text-[#0066FF]",drift:"bg-[rgba(200,255,0,0.1)] text-[#C8FF00]",metadao:"bg-[rgba(255,107,157,0.1)] text-[#FF6B9D]"},_o={polymarket:"Polymarket",drift:"Drift",metadao:"MetaDAO"};function Rt({source:e}){return jsxRuntime.jsx("span",{className:ui.clsx("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",Wo[e]),children:_o[e]})}function Vo({bets:e,isViewing:t,onSell:o}){return e.length===0?jsxRuntime.jsx(O,{title:"No active bets",hint:"Explore prediction markets \u2192"}):jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"grid gap-2 px-3 pb-2 text-[10px] font-medium uppercase tracking-wider text-[#5C5C72]",style:{gridTemplateColumns:t?"2.2fr .6fr .7fr .7fr .7fr":"2.2fr .6fr .7fr .7fr .7fr 80px"},children:[jsxRuntime.jsx("span",{children:"Market / Source"}),jsxRuntime.jsx("span",{className:"text-right",children:"Position"}),jsxRuntime.jsx("span",{className:"text-right",children:"Stake"}),jsxRuntime.jsx("span",{className:"text-right",children:"Potential"}),jsxRuntime.jsx("span",{className:"text-right",children:"Status"}),!t&&jsxRuntime.jsx("span",{className:"text-right"})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:e.map(r=>jsxRuntime.jsx(Mo,{bet:r,isViewing:t,onSell:o},r.id))})]})}function Mo({bet:e,isViewing:t,onSell:o}){return jsxRuntime.jsxs("div",{className:"grid items-center gap-2 rounded-[5px] px-3 py-2.5 transition-colors hover:bg-[#16161E]",style:{gridTemplateColumns:t?"2.2fr .6fr .7fr .7fr .7fr":"2.2fr .6fr .7fr .7fr .7fr 80px"},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[e.icon?jsxRuntime.jsx("img",{src:e.icon,alt:e.market,className:"h-6 w-6 flex-shrink-0 rounded-full"}):jsxRuntime.jsx("div",{className:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-full bg-[#1C1C26] text-[9px] font-bold text-[#5C5C72]",children:"?"}),jsxRuntime.jsxs("div",{className:"flex flex-col overflow-hidden",children:[jsxRuntime.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:e.market}),jsxRuntime.jsx(Rt,{source:e.source})]})]}),jsxRuntime.jsx("span",{className:ui.clsx("text-right text-xs font-medium",e.position==="Yes"?"text-[#00E676]":"text-[#FF5252]"),children:e.position}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-foreground",children:v(e.stake)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#00E676]",children:v(e.potential)}),jsxRuntime.jsx("span",{className:"text-right",children:jsxRuntime.jsx("span",{className:ui.clsx("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",e.status==="active"?"bg-[rgba(0,230,118,0.12)] text-[#00E676]":"bg-[rgba(200,255,0,0.1)] text-[#C8FF00]"),children:e.status==="active"?"Active":"Pending"})}),!t&&jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx("button",{type:"button",className:"rounded-[5px] border border-[#252530] px-2.5 py-1 text-[10px] font-medium text-[#5C5C72] transition-colors hover:border-[#FF5252] hover:text-[#FF5252]",onClick:()=>o?.(e),children:"Sell"})})]})}function Ko({records:e,isLoading:t}){return t?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-16",children:jsxRuntime.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-[#C8FF00] border-t-transparent"})}):e.length===0?jsxRuntime.jsx(O,{title:"No settled bets",hint:"Settled predictions will appear here"}):jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"grid gap-2 px-3 pb-2 text-[10px] font-medium uppercase tracking-wider text-[#5C5C72]",style:{gridTemplateColumns:"1.5fr .8fr .6fr .7fr .6fr .7fr"},children:[jsxRuntime.jsx("span",{children:"Market"}),jsxRuntime.jsx("span",{children:"Source"}),jsxRuntime.jsx("span",{className:"text-right",children:"Position"}),jsxRuntime.jsx("span",{className:"text-right",children:"Stake"}),jsxRuntime.jsx("span",{className:"text-right",children:"Result"}),jsxRuntime.jsx("span",{className:"text-right",children:"Payout"})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:e.map(o=>jsxRuntime.jsx(qo,{record:o},o.id))})]})}function qo({record:e}){let t=e.result==="won";return jsxRuntime.jsxs("div",{className:"grid items-center gap-2 rounded-[5px] px-3 py-2.5 transition-colors hover:bg-[#16161E]",style:{gridTemplateColumns:"1.5fr .8fr .6fr .7fr .6fr .7fr"},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[e.icon?jsxRuntime.jsx("img",{src:e.icon,alt:e.market,className:"h-5 w-5 flex-shrink-0 rounded-full"}):jsxRuntime.jsx("div",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-full bg-[#1C1C26] text-[8px] font-bold text-[#5C5C72]",children:"?"}),jsxRuntime.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:e.market})]}),jsxRuntime.jsx(Rt,{source:e.source}),jsxRuntime.jsx("span",{className:ui.clsx("text-right text-xs font-medium",e.position==="Yes"?"text-[#00E676]":"text-[#FF5252]"),children:e.position}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-foreground",children:v(e.stake)}),jsxRuntime.jsx("span",{className:"text-right",children:jsxRuntime.jsx("span",{className:ui.clsx("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",t?"bg-[rgba(0,230,118,0.12)] text-[#00E676]":"bg-[rgba(255,82,82,0.12)] text-[#FF5252]"),children:t?"Won":"Lost"})}),jsxRuntime.jsx("span",{className:ui.clsx("text-right font-mono text-xs",t?"text-[#00E676]":"text-[#5C5C72]"),children:t?`+${v(e.payout)}`:v(e.payout)})]})}function rt({state:e}){let{spotSubTab:t,setSpotSubTab:o,spotSearch:r,setSpotSearch:s,hideSmall:c,setHideSmall:n,groupCollapsed:i,toggleGroupCollapsed:a,filteredSpotHoldings:m,spotHistoryQuery:f}=e;return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between pb-3",children:[jsxRuntime.jsx(z,{tabs:[{key:"holdings",label:"Holdings"},{key:"history",label:"History"}],activeKey:t,onTabChange:u=>o(u)}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(G,{value:r,onChange:s,placeholder:"Search token\u2026"}),t==="holdings"&&jsxRuntime.jsxs("label",{className:"flex cursor-pointer items-center gap-1.5 text-[11px] text-[#5C5C72] select-none",children:[jsxRuntime.jsx("input",{type:"checkbox",className:"accent-[#C8FF00]",checked:c,onChange:u=>n(u.target.checked)}),"Hide small"]})]})]}),t==="holdings"?jsxRuntime.jsx($o,{holdings:m,groupCollapsed:i,onToggleGroup:a}):jsxRuntime.jsx(zo,{records:f.data?.trades??[],isLoading:f.isLoading})]})}function $o({holdings:e,groupCollapsed:t,onToggleGroup:o}){return e.length===0?jsxRuntime.jsx(O,{title:"No tokens found",hint:"Your spot tokens will appear here"}):jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"grid gap-2 px-3 pb-2 text-[10px] font-medium uppercase tracking-wider text-[#5C5C72]",style:{gridTemplateColumns:"2fr 1fr 1fr 1fr 1fr"},children:[jsxRuntime.jsx("span",{children:"Asset"}),jsxRuntime.jsx("span",{className:"text-right",children:"Balance"}),jsxRuntime.jsx("span",{className:"text-right",children:"Price"}),jsxRuntime.jsx("span",{className:"text-right",children:"Value"}),jsxRuntime.jsx("span",{className:"text-right",children:"24h"})]}),jsxRuntime.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 px-3 py-2 text-[10px] font-medium uppercase tracking-wider text-[#5C5C72] transition-colors hover:text-[#A0A0B8]",onClick:o,children:[jsxRuntime.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",className:ui.clsx("transition-transform",t&&"-rotate-90"),children:jsxRuntime.jsx("path",{d:"M4 6l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),jsxRuntime.jsx("span",{children:"Tokens"}),jsxRuntime.jsx("span",{className:"text-[#3A3A4E]",children:e.length})]}),!t&&jsxRuntime.jsx("div",{className:"flex flex-col",children:e.map(r=>jsxRuntime.jsx(Yo,{holding:r},r.tokenAddress))})]})}function Yo({holding:e}){let t=e.change24h>=0;return jsxRuntime.jsxs("div",{className:"grid items-center gap-2 rounded-[5px] px-3 py-2.5 transition-colors hover:bg-[#16161E]",style:{gridTemplateColumns:"2fr 1fr 1fr 1fr 1fr"},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2.5 overflow-hidden",children:[e.image?jsxRuntime.jsx("img",{src:e.image,alt:e.symbol,className:"h-7 w-7 flex-shrink-0 rounded-full"}):jsxRuntime.jsx("div",{className:"flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-full bg-[#1C1C26] text-[10px] font-bold text-[#5C5C72]",children:e.symbol.slice(0,2)}),jsxRuntime.jsxs("div",{className:"flex flex-col overflow-hidden",children:[jsxRuntime.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:e.name}),jsxRuntime.jsx("span",{className:"text-[10px] text-[#5C5C72]",children:e.symbol})]})]}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-foreground",children:Pe(e.balance)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#A0A0B8]",children:v(e.price)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-foreground",children:v(e.value)}),jsxRuntime.jsx("span",{className:ui.clsx("text-right font-mono text-xs",t?"text-[#00E676]":"text-[#FF5252]"),children:it(e.change24h)})]})}function zo({records:e,isLoading:t}){return t?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-16",children:jsxRuntime.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-[#C8FF00] border-t-transparent"})}):e.length===0?jsxRuntime.jsx(O,{title:"No history found",hint:"Transaction history will appear here"}):jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"grid gap-2 px-3 pb-2 text-[10px] font-medium uppercase tracking-wider text-[#5C5C72]",style:{gridTemplateColumns:"80px 1.5fr 1fr 1fr 100px 80px"},children:[jsxRuntime.jsx("span",{children:"Type"}),jsxRuntime.jsx("span",{children:"Detail"}),jsxRuntime.jsx("span",{className:"text-right",children:"Amount"}),jsxRuntime.jsx("span",{className:"text-right",children:"Value"}),jsxRuntime.jsx("span",{className:"text-right",children:"Time"}),jsxRuntime.jsx("span",{className:"text-right",children:"TxHash"})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:e.map(o=>jsxRuntime.jsx(Jo,{record:o},`${o.txHash}-${o.tokenAddress}`))})]})}var Go={swap:"bg-[rgba(139,123,255,0.12)] text-[#8B7BFF]",send:"bg-[rgba(255,82,82,0.12)] text-[#FF5252]",receive:"bg-[rgba(0,230,118,0.12)] text-[#00E676]"},jo={swap:"Swap",send:"Send",receive:"Receive"};function Xo(e){return e.type==="swap"&&e.sideTokenSymbol?`${e.tokenSymbol} \u2192 ${e.sideTokenSymbol}`:e.tokenName||e.tokenSymbol}function Jo({record:e}){let t=lt(e.txHash,e.chain);return jsxRuntime.jsxs("div",{className:"grid items-center gap-2 rounded-[5px] px-3 py-2.5 transition-colors hover:bg-[#16161E]",style:{gridTemplateColumns:"80px 1.5fr 1fr 1fr 100px 80px"},children:[jsxRuntime.jsx("span",{children:jsxRuntime.jsx("span",{className:ui.clsx("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",Go[e.type]),children:jo[e.type]})}),jsxRuntime.jsx("span",{className:"truncate text-xs text-foreground",children:Xo(e)}),jsxRuntime.jsxs("span",{className:"text-right font-mono text-xs text-foreground",children:[Pe(e.tokenAmount)," ",e.tokenSymbol]}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#A0A0B8]",children:v(e.valueUsd)}),jsxRuntime.jsx("span",{className:"text-right text-[11px] text-[#5C5C72]",children:e.timestamp?dt(e.timestamp):"\u2014"}),jsxRuntime.jsx("span",{className:"text-right",children:e.txHash?jsxRuntime.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"font-mono text-[11px] text-[#5C5C72] transition-colors hover:text-[#C8FF00]",children:[e.txHash.slice(0,4),"\u2026",e.txHash.slice(-3)]}):jsxRuntime.jsx("span",{className:"font-mono text-[11px] text-[#3A3A4E]",children:"\u2014"})})]})}function er({onClosePosition:e,onCloseAllPositions:t,onSellBet:o,onSellAllBets:r,...s}){let c=Ze(s),[n,i]=react.useState(null),a=react.useCallback(()=>{i("closeAll");},[]),m=react.useCallback(()=>{i("sellAll");},[]),f=react.useCallback(()=>{n==="closeAll"?t?.():n==="sellAll"&&r?.(),i(null);},[n,t,r]),u=react.useCallback(()=>{i(null);},[]);return jsxRuntime.jsxs("div",{className:"rounded-xl border border-[#1C1C26] bg-[#0E0E16] p-4",children:[(()=>{switch(s.activeTab){case "spot":return jsxRuntime.jsx(rt,{state:c});case "perps":return jsxRuntime.jsx(et,{state:c,onClosePosition:e,onCloseAll:a});case "prediction":return jsxRuntime.jsx(tt,{state:c,onSellBet:o,onSellAll:m});default:return null}})(),jsxRuntime.jsx(fe,{open:n==="closeAll",title:"Close All Positions",message:"Close all positions? This will route to each protocol to execute.",confirmLabel:"Confirm Close All",cancelLabel:"Cancel",onConfirm:f,onCancel:u}),jsxRuntime.jsx(fe,{open:n==="sellAll",title:"Sell All Positions",message:"Sell all positions? This will route to each platform to execute.",confirmLabel:"Confirm Sell All",cancelLabel:"Cancel",onConfirm:f,onCancel:u})]})}function sr({client:e,children:t}){let{chain:o}=uiChainSelect.useCurrentChain(),r=walletConnector.useWallet(o),s=!!r?.isConnected;return qe({chain:o,address:r?.address??"",enabled:s}),jsxRuntime.jsx(re.Provider,{value:{client:e},children:t})}
2
+ exports.AddressRowUI=he;exports.AssetTab=oe;exports.AssetTabsUI=Se;exports.BalanceRowUI=we;exports.BatchActionButton=ae;exports.CURVE_PERIOD_VALUE=mt;exports.ConfirmDialog=fe;exports.CurveCardUI=ke;exports.CurvePeriod=Ce;exports.CurveType=ve;exports.DistributionCardUI=Fe;exports.HoldingsEmpty=O;exports.HoldingsSearch=G;exports.HoldingsSectionWidget=er;exports.HoldingsSubTabs=z;exports.PerpsPanelUI=et;exports.PerpsPositionSide=ft;exports.PortfolioContext=re;exports.PortfolioPageSkeleton=ze;exports.PortfolioPageWidget=Qo;exports.PortfolioProvider=sr;exports.PredictionBetStatus=gt;exports.PredictionPanelUI=tt;exports.PredictionResult=yt;exports.PredictionSource=bt;exports.SpotHistoryType=xt;exports.SpotPanelUI=rt;exports.ViewingBannerUI=Ge;exports.computeDistribution=pt;exports.curveDataQueryKey=Dt;exports.distributionQueryKey=No;exports.formatPercent=it;exports.formatSignedUsd=te;exports.formatTime=dt;exports.formatTokenBalance=Pe;exports.formatUsd=v;exports.getExplorerUrl=lt;exports.overviewQueryKey=Nt;exports.parseDecimal=ar;exports.perpsHistoryQueryKey=Tt;exports.perpsPositionsQueryKey=kt;exports.predictionBetsQueryKey=Ft;exports.predictionSettledQueryKey=Ht;exports.splitUsd=at;exports.spotHistoryQueryKey=At;exports.spotHoldingsQueryKey=wt;exports.truncateAddress=X;exports.useCurveDataQuery=Oe;exports.useDistributionQuery=Be;exports.useHoldingsSection=Ze;exports.useOverviewQuery=De;exports.usePerpsHistoryQuery=Ue;exports.usePerpsPositionsQuery=Qe;exports.usePortfolioClient=w;exports.usePortfolioContext=He;exports.usePortfolioPage=Ye;exports.usePredictionBetsQuery=Re;exports.usePredictionSettledQuery=Ie;exports.useRefetchWalletSummary=Eo;exports.useSpotHistoryQuery=Ee;exports.useSpotHoldingsQuery=se;exports.useWalletStateManager=qe;exports.useWalletSummary=Do;exports.version=It;exports.walletSummaryAtom=Le;exports.walletSummaryRefetchAtom=_e;exports.walletSummaryStatusAtom=We;//# sourceMappingURL=index.js.map
3
3
  //# sourceMappingURL=index.js.map