@liberfi.io/ui-portfolio 2.0.13 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +7 -15
- package/dist/index.d.ts +7 -15
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +14 -14
package/dist/index.d.mts
CHANGED
|
@@ -7,16 +7,8 @@ import { A as AssetTab, C as CurveType, a as CurvePeriod, P as PortfolioQuery, b
|
|
|
7
7
|
export { q as CURVE_PERIOD_VALUE, x as ChartDataPointDTO, F as CurvePoint, H as DistributionItem, G as GetPortfolioChartReply, y as GetSpotHoldingsReply, B as GetTradeHistoryReply, r as PerpsPositionSide, J as PerpsTradeRecord, w as PortfolioOverviewDTO, t as PredictionBetStatus, u as PredictionResult, K as PredictionSettledRecord, v as PredictionSource, E as SpotHistoryRecord, s as SpotHistoryType, T as TokenHoldingDTO, z as TradeRecordDTO } from './index-Bq_qim6b.mjs';
|
|
8
8
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
9
9
|
import { UseQueryOptions } from '@tanstack/react-query';
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
declare global {
|
|
13
|
-
interface Window {
|
|
14
|
-
__LIBERFI_VERSION__?: {
|
|
15
|
-
[key: string]: string;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
declare const _default: "2.0.13";
|
|
10
|
+
import { ActivitiesSortBy, Activity, Chain, WalletPortfolios, Portfolio, WalletPnlResolution, WalletPnlSortBy, WalletPortfolioPnls, PositionState, PortfolioPnl } from '@liberfi.io/types';
|
|
11
|
+
export { PositionState } from '@liberfi.io/types';
|
|
20
12
|
|
|
21
13
|
/** Action button rendered in the popover action bar. */
|
|
22
14
|
interface AccountAction {
|
|
@@ -319,7 +311,7 @@ interface TagBadgeListProps {
|
|
|
319
311
|
}
|
|
320
312
|
declare function TagBadgeList({ tags, className, max }: TagBadgeListProps): react_jsx_runtime.JSX.Element | null;
|
|
321
313
|
|
|
322
|
-
type PortfolioActivitiesSortBy =
|
|
314
|
+
type PortfolioActivitiesSortBy = ActivitiesSortBy;
|
|
323
315
|
type PortfolioActivitiesTypeFilter = "all" | "buy" | "sell";
|
|
324
316
|
interface PortfolioActivitiesProps {
|
|
325
317
|
activities: Array<Activity>;
|
|
@@ -445,9 +437,9 @@ interface PortfolioNetWorthTokensWidgetProps {
|
|
|
445
437
|
*/
|
|
446
438
|
declare function PortfolioNetWorthTokensWidget({ chain, address, limit, className, onRowClick, }: PortfolioNetWorthTokensWidgetProps): react_jsx_runtime.JSX.Element;
|
|
447
439
|
|
|
448
|
-
type PnlResolution =
|
|
449
|
-
type
|
|
450
|
-
|
|
440
|
+
type PnlResolution = WalletPnlResolution;
|
|
441
|
+
type PnlSortBy = WalletPnlSortBy;
|
|
442
|
+
|
|
451
443
|
interface PortfolioPnlDetailsProps {
|
|
452
444
|
data?: WalletPortfolioPnls;
|
|
453
445
|
isLoading?: boolean;
|
|
@@ -677,4 +669,4 @@ declare function computeDistribution(holdings: SpotHolding[]): DistributionData;
|
|
|
677
669
|
*/
|
|
678
670
|
declare function formatTime(epochMs: number): string;
|
|
679
671
|
|
|
680
|
-
export { type AccountAction, AccountInfoUI, type AccountInfoUIProps, AccountInfoWidget, type AccountInfoWidgetProps, AddressRowUI, type AddressRowUIProps, AssetTab, AssetTabsUI, type AssetTabsUIProps, 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, type PnlResolution, type PnlSortBy, PortfolioActivities, type PortfolioActivitiesProps, type PortfolioActivitiesSortBy, type PortfolioActivitiesTypeFilter, PortfolioActivitiesWidget, type PortfolioActivitiesWidgetProps, PortfolioClientContext, PortfolioClientProvider, type PortfolioClientProviderProps, PortfolioContext, type PortfolioContextValue, PortfolioNetWorthTokens, type PortfolioNetWorthTokensProps, PortfolioNetWorthTokensWidget, type PortfolioNetWorthTokensWidgetProps, PortfolioOverview, PortfolioPageSkeleton, PortfolioPageWidget, type PortfolioPageWidgetProps, PortfolioPnlDetails, type PortfolioPnlDetailsProps, PortfolioPnlDetailsWidget, type PortfolioPnlDetailsWidgetProps, PortfolioProvider, type PortfolioProviderProps, PortfolioQuery,
|
|
672
|
+
export { type AccountAction, AccountInfoUI, type AccountInfoUIProps, AccountInfoWidget, type AccountInfoWidgetProps, AddressRowUI, type AddressRowUIProps, AssetTab, AssetTabsUI, type AssetTabsUIProps, 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, type PnlResolution, type PnlSortBy, PortfolioActivities, type PortfolioActivitiesProps, type PortfolioActivitiesSortBy, type PortfolioActivitiesTypeFilter, PortfolioActivitiesWidget, type PortfolioActivitiesWidgetProps, PortfolioClientContext, PortfolioClientProvider, type PortfolioClientProviderProps, PortfolioContext, type PortfolioContextValue, PortfolioNetWorthTokens, type PortfolioNetWorthTokensProps, PortfolioNetWorthTokensWidget, type PortfolioNetWorthTokensWidgetProps, PortfolioOverview, PortfolioPageSkeleton, PortfolioPageWidget, type PortfolioPageWidgetProps, PortfolioPnlDetails, type PortfolioPnlDetailsProps, PortfolioPnlDetailsWidget, type PortfolioPnlDetailsWidgetProps, PortfolioProvider, type PortfolioProviderProps, PortfolioQuery, PredictionBet, PredictionBetsData, PredictionPanelUI, type PredictionPanelUIProps, PredictionSettledData, PredictionSettledQuery, type PredictionSubTab, type RefetchWalletSummaryFn, SpotHistoryData, SpotHistoryQuery, SpotHolding, SpotHoldingsData, SpotPanelUI, type SpotPanelUIProps, type SpotSubTab, TagBadge, TagBadgeList, type TagBadgeListProps, type TagBadgeProps, type TokenPortfolio, type UseAccountInfoResult, type UseHoldingsSectionOptions, type UseHoldingsSectionResult, type UsePortfolioActivitiesScriptParams, type UsePortfolioActivitiesScriptResult, type UsePortfolioNetWorthTokensScriptParams, type UsePortfolioNetWorthTokensScriptResult, type UsePortfolioPageOptions, type UsePortfolioPageResult, type UsePortfolioPnlDetailsScriptParams, type UsePortfolioPnlDetailsScriptResult, type UseWalletPortfoliosParams, ViewingBannerUI, type ViewingBannerUIProps, type WalletOption, WalletSummary, computeDistribution, curveDataQueryKey, distributionQueryKey, formatAgeShort, formatPercent, formatSignedUsd, formatTime, formatTokenBalance, formatUsd, getExplorerUrl, overviewQueryKey, parseDecimal, perpsHistoryQueryKey, perpsPositionsQueryKey, predictionBetsQueryKey, predictionSettledQueryKey, splitUsd, spotHistoryQueryKey, spotHoldingsQueryKey, truncateAddress, truncateMiddle, useAccountInfo, useCurveDataQuery, useDistributionQuery, useHoldingsSection, useOverviewQuery, usePerpsHistoryQuery, usePerpsPositionsQuery, usePortfolioActivitiesScript, usePortfolioClient, usePortfolioContext, usePortfolioNetWorthTokensScript, usePortfolioPage, usePortfolioPnlDetailsScript, usePredictionBetsQuery, usePredictionSettledQuery, useRefetchWalletSummary, useSpotHistoryQuery, useSpotHoldingsQuery, useWalletPortfolios, useWalletSummary };
|
package/dist/index.d.ts
CHANGED
|
@@ -7,16 +7,8 @@ import { A as AssetTab, C as CurveType, a as CurvePeriod, P as PortfolioQuery, b
|
|
|
7
7
|
export { q as CURVE_PERIOD_VALUE, x as ChartDataPointDTO, F as CurvePoint, H as DistributionItem, G as GetPortfolioChartReply, y as GetSpotHoldingsReply, B as GetTradeHistoryReply, r as PerpsPositionSide, J as PerpsTradeRecord, w as PortfolioOverviewDTO, t as PredictionBetStatus, u as PredictionResult, K as PredictionSettledRecord, v as PredictionSource, E as SpotHistoryRecord, s as SpotHistoryType, T as TokenHoldingDTO, z as TradeRecordDTO } from './index-Bq_qim6b.js';
|
|
8
8
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
9
9
|
import { UseQueryOptions } from '@tanstack/react-query';
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
declare global {
|
|
13
|
-
interface Window {
|
|
14
|
-
__LIBERFI_VERSION__?: {
|
|
15
|
-
[key: string]: string;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
declare const _default: "2.0.13";
|
|
10
|
+
import { ActivitiesSortBy, Activity, Chain, WalletPortfolios, Portfolio, WalletPnlResolution, WalletPnlSortBy, WalletPortfolioPnls, PositionState, PortfolioPnl } from '@liberfi.io/types';
|
|
11
|
+
export { PositionState } from '@liberfi.io/types';
|
|
20
12
|
|
|
21
13
|
/** Action button rendered in the popover action bar. */
|
|
22
14
|
interface AccountAction {
|
|
@@ -319,7 +311,7 @@ interface TagBadgeListProps {
|
|
|
319
311
|
}
|
|
320
312
|
declare function TagBadgeList({ tags, className, max }: TagBadgeListProps): react_jsx_runtime.JSX.Element | null;
|
|
321
313
|
|
|
322
|
-
type PortfolioActivitiesSortBy =
|
|
314
|
+
type PortfolioActivitiesSortBy = ActivitiesSortBy;
|
|
323
315
|
type PortfolioActivitiesTypeFilter = "all" | "buy" | "sell";
|
|
324
316
|
interface PortfolioActivitiesProps {
|
|
325
317
|
activities: Array<Activity>;
|
|
@@ -445,9 +437,9 @@ interface PortfolioNetWorthTokensWidgetProps {
|
|
|
445
437
|
*/
|
|
446
438
|
declare function PortfolioNetWorthTokensWidget({ chain, address, limit, className, onRowClick, }: PortfolioNetWorthTokensWidgetProps): react_jsx_runtime.JSX.Element;
|
|
447
439
|
|
|
448
|
-
type PnlResolution =
|
|
449
|
-
type
|
|
450
|
-
|
|
440
|
+
type PnlResolution = WalletPnlResolution;
|
|
441
|
+
type PnlSortBy = WalletPnlSortBy;
|
|
442
|
+
|
|
451
443
|
interface PortfolioPnlDetailsProps {
|
|
452
444
|
data?: WalletPortfolioPnls;
|
|
453
445
|
isLoading?: boolean;
|
|
@@ -677,4 +669,4 @@ declare function computeDistribution(holdings: SpotHolding[]): DistributionData;
|
|
|
677
669
|
*/
|
|
678
670
|
declare function formatTime(epochMs: number): string;
|
|
679
671
|
|
|
680
|
-
export { type AccountAction, AccountInfoUI, type AccountInfoUIProps, AccountInfoWidget, type AccountInfoWidgetProps, AddressRowUI, type AddressRowUIProps, AssetTab, AssetTabsUI, type AssetTabsUIProps, 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, type PnlResolution, type PnlSortBy, PortfolioActivities, type PortfolioActivitiesProps, type PortfolioActivitiesSortBy, type PortfolioActivitiesTypeFilter, PortfolioActivitiesWidget, type PortfolioActivitiesWidgetProps, PortfolioClientContext, PortfolioClientProvider, type PortfolioClientProviderProps, PortfolioContext, type PortfolioContextValue, PortfolioNetWorthTokens, type PortfolioNetWorthTokensProps, PortfolioNetWorthTokensWidget, type PortfolioNetWorthTokensWidgetProps, PortfolioOverview, PortfolioPageSkeleton, PortfolioPageWidget, type PortfolioPageWidgetProps, PortfolioPnlDetails, type PortfolioPnlDetailsProps, PortfolioPnlDetailsWidget, type PortfolioPnlDetailsWidgetProps, PortfolioProvider, type PortfolioProviderProps, PortfolioQuery,
|
|
672
|
+
export { type AccountAction, AccountInfoUI, type AccountInfoUIProps, AccountInfoWidget, type AccountInfoWidgetProps, AddressRowUI, type AddressRowUIProps, AssetTab, AssetTabsUI, type AssetTabsUIProps, 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, type PnlResolution, type PnlSortBy, PortfolioActivities, type PortfolioActivitiesProps, type PortfolioActivitiesSortBy, type PortfolioActivitiesTypeFilter, PortfolioActivitiesWidget, type PortfolioActivitiesWidgetProps, PortfolioClientContext, PortfolioClientProvider, type PortfolioClientProviderProps, PortfolioContext, type PortfolioContextValue, PortfolioNetWorthTokens, type PortfolioNetWorthTokensProps, PortfolioNetWorthTokensWidget, type PortfolioNetWorthTokensWidgetProps, PortfolioOverview, PortfolioPageSkeleton, PortfolioPageWidget, type PortfolioPageWidgetProps, PortfolioPnlDetails, type PortfolioPnlDetailsProps, PortfolioPnlDetailsWidget, type PortfolioPnlDetailsWidgetProps, PortfolioProvider, type PortfolioProviderProps, PortfolioQuery, PredictionBet, PredictionBetsData, PredictionPanelUI, type PredictionPanelUIProps, PredictionSettledData, PredictionSettledQuery, type PredictionSubTab, type RefetchWalletSummaryFn, SpotHistoryData, SpotHistoryQuery, SpotHolding, SpotHoldingsData, SpotPanelUI, type SpotPanelUIProps, type SpotSubTab, TagBadge, TagBadgeList, type TagBadgeListProps, type TagBadgeProps, type TokenPortfolio, type UseAccountInfoResult, type UseHoldingsSectionOptions, type UseHoldingsSectionResult, type UsePortfolioActivitiesScriptParams, type UsePortfolioActivitiesScriptResult, type UsePortfolioNetWorthTokensScriptParams, type UsePortfolioNetWorthTokensScriptResult, type UsePortfolioPageOptions, type UsePortfolioPageResult, type UsePortfolioPnlDetailsScriptParams, type UsePortfolioPnlDetailsScriptResult, type UseWalletPortfoliosParams, ViewingBannerUI, type ViewingBannerUIProps, type WalletOption, WalletSummary, computeDistribution, curveDataQueryKey, distributionQueryKey, formatAgeShort, formatPercent, formatSignedUsd, formatTime, formatTokenBalance, formatUsd, getExplorerUrl, overviewQueryKey, parseDecimal, perpsHistoryQueryKey, perpsPositionsQueryKey, predictionBetsQueryKey, predictionSettledQueryKey, splitUsd, spotHistoryQueryKey, spotHoldingsQueryKey, truncateAddress, truncateMiddle, useAccountInfo, useCurveDataQuery, useDistributionQuery, useHoldingsSection, useOverviewQuery, usePerpsHistoryQuery, usePerpsPositionsQuery, usePortfolioActivitiesScript, usePortfolioClient, usePortfolioContext, usePortfolioNetWorthTokensScript, usePortfolioPage, usePortfolioPnlDetailsScript, usePredictionBetsQuery, usePredictionSettledQuery, useRefetchWalletSummary, useSpotHistoryQuery, useSpotHoldingsQuery, useWalletPortfolios, useWalletSummary };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
'use strict';var react=require('react'),uiChainSelect=require('@liberfi.io/ui-chain-select'),utils=require('@liberfi.io/utils'),walletConnector=require('@liberfi.io/wallet-connector'),i18n=require('@liberfi.io/i18n'),ui=require('@liberfi.io/ui'),jsxRuntime=require('react/jsx-runtime'),recharts=require('recharts'),reactQuery=require('@tanstack/react-query'),react$1=require('@liberfi.io/react');typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/ui-portfolio"]="2.0.13");var Ho="2.0.13";var xe=react.createContext(null);var ge=react.createContext({}),De=react.createContext({});function ye(){let e=react.useContext(ge);if(!e)throw new Error("usePortfolioContext must be used within a PortfolioProvider");return e}function $e(){let{summary:e,summaryStatus:t}=ye();return {data:e,...t}}function ze(){let{status:e,signIn:t,signOut:o}=walletConnector.useAuth(),{data:r}=$e(),{chain:n,chainNamespace:a}=uiChainSelect.useCurrentChain(),i=walletConnector.useConnectedWallet(n),s=react.useMemo(()=>utils.getNativeToken(n),[n]),l=react.useMemo(()=>r?.balanceInUsd?utils.formatAmountUSD(r.balanceInUsd):"--",[r?.balanceInUsd]),p=react.useMemo(()=>r?.balanceInNative?utils.formatAmount(r.balanceInNative):"--",[r?.balanceInNative]);return {status:e,signIn:t,signOut:o,balanceUsdFormatted:l,balanceNativeFormatted:p,nativeToken:s,chainNamespace:a,walletAddress:i?.address??""}}function Ye({status:e,signIn:t,signOut:o,balanceUsdFormatted:r,balanceNativeFormatted:n,nativeToken:a,chainNamespace:i,walletAddress:s,actions:l}){let{t:p}=i18n.useTranslation(),{isMobile:c}=ui.useScreen(),{isOpen:d,onClose:m,onOpenChange:f}=ui.useDisclosure(),v=ui.useCopyToClipboard(),u=react.useCallback(()=>{v(s,()=>ui.toast.success(p("common.primaryAddressCopied",{network:i.toUpperCase()})));},[v,i,s]);return e==="unauthenticated"?jsxRuntime.jsx(ui.Button,{isIconOnly:c,size:"sm",color:"primary",radius:"full",disableRipple:true,onPress:t,startContent:c?void 0:jsxRuntime.jsx(ui.SignInIcon,{width:16,height:16}),"aria-label":p("common.signIn"),children:c?jsxRuntime.jsx(ui.SignInIcon,{width:16,height:16}):p("common.signIn")}):e==="authenticating"?jsxRuntime.jsx(ui.Button,{isIconOnly:c,size:"sm",color:"primary",radius:"full",disableRipple:true,isLoading:true,isDisabled:true,"aria-label":p("common.signingIn"),children:p("common.signingIn")}):e==="deauthenticating"?jsxRuntime.jsx(ui.Button,{isIconOnly:c,size:"sm",color:"primary",radius:"full",disableRipple:true,isLoading:true,isDisabled:true,"aria-label":p("common.signingOut"),children:p("common.signingOut")}):jsxRuntime.jsxs(ui.StyledPopover,{placement:c?"bottom":"bottom-end",isOpen:d,onOpenChange:f,triggerScaleOnOpen:false,children:[jsxRuntime.jsx(ui.PopoverTrigger,{children:jsxRuntime.jsx(ui.Button,{size:"sm",className:"bg-content2",radius:"full",disableRipple:true,startContent:jsxRuntime.jsx(ui.WalletIcon,{width:16,height:16,className:"text-neutral"}),endContent:jsxRuntime.jsx(ui.ChevronDownIcon,{width:16,height:16,className:ui.cn("text-neutral transition-transform",d&&"rotate-180")}),children:a&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx(ui.TokenIcon,{symbol:a.symbol,size:16}),jsxRuntime.jsx("span",{className:"text-xs text-foreground",children:c?n:`${n} ${a.symbol}`})]})})}),jsxRuntime.jsx(ui.PopoverContent,{children:jsxRuntime.jsxs("div",{className:"w-70 flex flex-col gap-3 py-4",children:[jsxRuntime.jsxs("div",{className:"px-4 flex items-start justify-between",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-0.5",children:[jsxRuntime.jsx("span",{className:"text-xs text-neutral",children:p("common.totalValue")}),jsxRuntime.jsx("span",{className:"text-base font-semibold text-foreground",children:r})]}),jsxRuntime.jsx("div",{className:"flex items-start justify-end gap-0.5",children:jsxRuntime.jsx(ui.StyledTooltip,{content:p("common.copyPrimaryAddress",{network:i.toUpperCase()}),children:jsxRuntime.jsx(ui.Button,{className:"text-xs bg-transparent text-neutral hover:text-foreground h-4 min-h-4 gap-1",startContent:jsxRuntime.jsx(ui.CopyIcon,{width:14,height:14}),disableRipple:true,disableAnimation:true,onPress:u,children:i.toUpperCase()})})})]}),jsxRuntime.jsx(ui.Divider,{}),jsxRuntime.jsxs("div",{className:"grid grid-cols-4 gap-2 px-4",children:[l?.map(x=>jsxRuntime.jsxs("button",{type:"button",className:"flex cursor-pointer flex-col items-center justify-center gap-1 rounded-md py-2 text-foreground transition-colors hover:text-primary",onClick:()=>{x.onPress(),m();},children:[x.icon,jsxRuntime.jsx("span",{className:"w-full truncate text-center text-xs",children:x.label})]},x.key)),jsxRuntime.jsxs("button",{type:"button",className:"flex cursor-pointer flex-col items-center justify-center gap-1 rounded-md py-2 text-danger transition-colors hover:text-danger/80",onClick:()=>{o(),m();},children:[jsxRuntime.jsx(ui.SignOutIcon,{width:16,height:16}),jsxRuntime.jsx("span",{className:"w-full truncate text-center text-xs",children:p("common.signOut")})]})]})]})})]})}function ar({actions:e}){let t=ze();return jsxRuntime.jsx(Ye,{status:t.status,signIn:t.signIn,signOut:t.signOut,balanceUsdFormatted:t.balanceUsdFormatted,balanceNativeFormatted:t.balanceNativeFormatted,nativeToken:t.nativeToken,chainNamespace:t.chainNamespace,walletAddress:t.walletAddress,actions:e})}function qs(e){if(!e)return 0;let t=Number(e);return Number.isFinite(t)?t:0}function I(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 Pe(e){let t=I(Math.abs(e));return e>0?`+${t}`:e<0?`-${t.replace("-","")}`:t}function Dt(e){return `${e>0?"+":""}${e.toFixed(2)}%`}function Ut(e){let o=Math.abs(e).toFixed(2).split("."),r=Number(o[0]).toLocaleString("en-US"),n=`.${o[1]}`;return {sign:e<0?"-$":"$",integer:r,decimal:n}}function ue(e,t=4,o=4){return e.length<=t+o+3?e:`${e.slice(0,t)}\u2026${e.slice(-o)}`}function Ge(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 Bt(e,t){return `https://solscan.io/tx/${e}`}var Rt=["#C8FF00","#00E676","#0066FF","#FF6B9D","#8B7BFF","#FF5252","#FFB74D","#4DD0E1"],pr="#3A3A4E";function Ht(e){let t=e.reduce((i,s)=>i+s.value,0);if(t<=0)return {items:[]};let o=[...e].sort((i,s)=>s.value-i.value),r=[],n=0,a=0;for(let i of o){let s=i.value/t*100;s<2?n+=i.value:(r.push({name:i.name,symbol:i.symbol,percent:s,value:i.value,color:Rt[a%Rt.length]}),a++);}return n>0&&r.push({name:"Other",symbol:"OTHER",percent:n/t*100,value:n,color:pr}),{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 je({walletId:e,wallets:t,isViewing:o,viewingAddress:r,onSelectWallet:n,onCopyAddress:a,onSearch:i}){let[s,l]=react.useState(false),[p,c]=react.useState(""),d=react.useRef(null),m=!e&&!o,f=t.find(S=>S.id===e),v=o?"External":m?"All Wallets":f?.name??"",u=o?ue(r??""):m?"Aggregated":ue(f?.address??""),x=o?"bg-[#5C5C72]":m?"bg-[#C8FF00]":"bg-[#00E676]",g=react.useCallback(()=>{let S=p.trim();S.length>=32&&(i(S),c(""));},[p,i]),w=react.useCallback(S=>{S.key==="Enter"&&g();},[g]);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:d,children:[jsxRuntime.jsxs("button",{type:"button",className:ui.cn("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&&l(S=>!S),children:[jsxRuntime.jsx("span",{className:ui.cn("h-[7px] w-[7px] flex-shrink-0 rounded-full",x)}),jsxRuntime.jsx("span",{className:"text-[11px] font-medium text-[#A0A0B8]",children:v}),jsxRuntime.jsx("span",{className:"font-mono text-xs text-foreground",children:u}),!o&&jsxRuntime.jsx("svg",{className:ui.cn("text-[#5C5C72] transition-transform",s&&"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"})})]}),s&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>l(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.cn("flex w-full items-center gap-2 rounded-[5px] px-2.5 py-2 transition-colors hover:bg-[#1C1C26]",m&&"bg-[rgba(200,255,0,0.07)]"),onClick:()=>{n(void 0),l(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(S=>jsxRuntime.jsxs("button",{type:"button",className:ui.cn("flex w-full items-center gap-2 rounded-[5px] px-2.5 py-2 transition-colors hover:bg-[#1C1C26]",e===S.id&&"bg-[rgba(200,255,0,0.07)]"),onClick:()=>{n(S.id),l(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:S.name}),jsxRuntime.jsx("span",{className:"font-mono text-[11px] text-[#5C5C72]",children:ue(S.address)}),jsxRuntime.jsx("span",{className:"ml-auto font-mono text-[11px] font-medium text-foreground",children:S.balance})]},S.id))]})]})]}),jsxRuntime.jsx("button",{type:"button",className:ui.cn("rounded p-1 text-[#5C5C72] transition-colors hover:bg-[#1C1C26] hover:text-[#C8FF00]",m&&!o&&"pointer-events-none opacity-40"),onClick:a,disabled:m&&!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.cn("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:p,onChange:S=>c(S.target.value),onKeyDown:w})]}),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:g,children:"View"})]})]})}var he=(r=>(r.SPOT="spot",r.PERPS="perps",r.PREDICTION="prediction",r))(he||{}),Xe=(o=>(o.NET_WORTH="networth",o.PNL="pnl",o))(Xe||{}),Ze=(n=>(n.ONE_DAY="1D",n.SEVEN_DAY="7D",n.THIRTY_DAY="30D",n.MAX="Max",n))(Ze||{}),Wt={"1D":1,"7D":7,"30D":30,Max:365},Lt=(o=>(o.LONG="long",o.SHORT="short",o))(Lt||{}),Mt=(r=>(r.SWAP="swap",r.SEND="send",r.RECEIVE="receive",r))(Mt||{}),_t=(o=>(o.ACTIVE="active",o.PENDING="pending",o))(_t||{}),Vt=(o=>(o.WON="won",o.LOST="lost",o))(Vt||{}),Kt=(r=>(r.POLYMARKET="polymarket",r.DRIFT="drift",r.METADAO="metadao",r))(Kt||{});var fr=[{key:"spot",label:"Spot"},{key:"perps",label:"Perps"},{key:"prediction",label:"Prediction"}];function mr(e,t,o,r){switch(e){case "spot":return t;case "perps":return o;case "prediction":return r}}function Je({activeTab:e,onTabChange:t,spotValue:o=0,perpsValue:r=0,predictionValue:n=0}){return jsxRuntime.jsx("div",{className:"flex gap-1 border-b border-[#252530] pb-0 pt-5",children:fr.map(({key:a,label:i})=>{let s=e===a,l=mr(a,o,r,n);return jsxRuntime.jsxs("button",{type:"button",className:ui.cn("relative flex items-center gap-2 border-b-2 px-4 pb-3 pt-2.5 text-[13px] font-medium transition-colors",s?"border-[#C8FF00] text-foreground":"border-transparent text-[#5C5C72] hover:text-[#A0A0B8]"),onClick:()=>t(a),children:[i,!s&&jsxRuntime.jsx("span",{className:"rounded-[10px] bg-[#16161E] px-2 py-0.5 font-mono text-[11px] text-[#5C5C72]",children:I(l)})]},a)})})}function tt({overview:e}){let t=e?.totalValue??0,o=e?.uPnl??0,r=e?.realizedPnl??0,n=e?.totalProfit??0,{sign:a,integer:i,decimal:s}=Ut(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:a}),i,jsxRuntime.jsx("span",{className:"text-base font-normal text-[#5C5C72]",children:s})]})}),jsxRuntime.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[jsxRuntime.jsx(et,{label:"uPNL",value:o}),jsxRuntime.jsx(qt,{}),jsxRuntime.jsx(et,{label:"Realized",value:r}),jsxRuntime.jsx(qt,{}),jsxRuntime.jsx(et,{label:"Total Profit",value:n})]})]})}function et({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.cn("font-mono text-xs font-medium",t>0?"text-[#00E676]":t<0?"text-[#FF5252]":"text-[#5C5C72]"),children:Pe(t)})]})}function qt(){return jsxRuntime.jsx("div",{className:"h-3.5 w-px bg-[#252530]"})}var Sr=["1D","7D","30D","Max"];function zt(e,t){let o=new Date(e);return t==="1D"?o.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):o.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Nr(e){return e==="pnl"?"change":"netWorth"}function rt({curveType:e,curvePeriod:t,data:o,isLoading:r,onTypeChange:n,onPeriodChange:a}){let i=o?.points??[],s=Nr(e),l=e==="pnl",p=react.useMemo(()=>i.map(u=>l?u.change:u.netWorth),[i,l]),c=p.some(u=>u<0),{minVal:d,maxVal:m}=react.useMemo(()=>{if(p.length===0)return {minVal:0,maxVal:100};let u=Math.min(...p),x=Math.max(...p),g=x-u||1;return {minVal:u-g*.1,maxVal:x+g*.1}},[p]),f=react.useMemo(()=>{if(i.length===0)return [];let u=Math.min(7,i.length),x=Math.max(1,Math.floor((i.length-1)/(u-1))),g=[];for(let S=0;S<i.length;S+=x)g.push({ts:i[S].timestamp,label:zt(i[S].timestamp,t)});let w=i[i.length-1];return g[g.length-1]?.ts!==w.timestamp&&g.push({ts:w.timestamp,label:zt(w.timestamp,t)}),g},[i,t]),v=p[p.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(Yt,{label:"Net Worth",active:e==="networth",onClick:()=>n("networth")}),jsxRuntime.jsx(Yt,{label:"PNL",active:e==="pnl",onClick:()=>n("pnl")})]}),jsxRuntime.jsx("div",{className:"flex gap-0.5",children:Sr.map(u=>jsxRuntime.jsx("button",{type:"button",className:ui.cn("rounded-[3px] px-2 py-1 text-[10px] font-medium transition-colors",t===u?"bg-[rgba(200,255,0,0.07)] text-[#C8FF00]":"text-[#5C5C72] hover:bg-[#16161E] hover:text-[#A0A0B8]"),onClick:()=>a(u),children:u},u))})]}),jsxRuntime.jsx("div",{className:"h-[180px] px-4 pt-2",children:r||i.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:i,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:[d,m]}),l&&c&&jsxRuntime.jsx(recharts.ReferenceLine,{y:0,stroke:"rgba(255,255,255,0.06)",strokeDasharray:"4 4"}),jsxRuntime.jsx(recharts.Area,{type:"monotone",dataKey:s,stroke:l?v>=0?"#00E676":"#FF5252":"#C8FF00",strokeWidth:1.5,fill:l?v>=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:f.map(({ts:u,label:x})=>jsxRuntime.jsx("span",{className:"font-mono text-[9px] text-[#3A3A4E]",children:x},u))})]})}function Yt({label:e,active:t,onClick:o}){return jsxRuntime.jsx("button",{type:"button",className:ui.cn("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 st({data:e,isLoading:t}){let o=e?.items??[],r=react.useMemo(()=>o.map(n=>({name:n.name,value:n.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((n,a)=>jsxRuntime.jsx(recharts.Cell,{fill:n.color},a))})})})}),jsxRuntime.jsx("div",{className:"px-4 pb-3 pt-2",children:o.map((n,a)=>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:n.color}}),jsxRuntime.jsx("span",{className:"min-w-0 flex-1 truncate text-[#A0A0B8]",children:n.name}),jsxRuntime.jsxs("span",{className:"font-mono text-[10px] text-[#5C5C72]",children:[n.percent.toFixed(1),"%"]}),jsxRuntime.jsx("span",{className:"min-w-[55px] text-right font-mono text-[10px] text-foreground",children:I(n.value)})]},a))})]})}function H(){let e=react.useContext(xe);if(!e)throw new Error("usePortfolioClient must be used within a PortfolioClientProvider");return e}function jt(e){return ["portfolio","overview",e??{}]}async function Dr(e,t){return await e.getOverview(t)}function it(e,t={}){let o=H();return reactQuery.useQuery({queryKey:jt(e),queryFn:async()=>Dr(o,e),...t})}function Xt(e){return ["portfolio","spot","holdings",e??{}]}async function Br(e,t){return await e.getSpotHoldings(t)}function ve(e,t={}){let o=H();return reactQuery.useQuery({queryKey:Xt(e),queryFn:async()=>Br(o,e),...t})}function Zt(e){return ["portfolio","spot","history",e??{}]}async function Or(e,t){return await e.getSpotHistory(t)}function at(e,t={}){let o=H();return reactQuery.useQuery({queryKey:Zt(e),queryFn:async()=>Or(o,e),...t})}function Jt(e){return ["portfolio","perps","positions",e??{}]}async function Qr(e,t){return await e.getPerpsPositions(t)}function lt(e,t={}){let o=H();return reactQuery.useQuery({queryKey:Jt(e),queryFn:async()=>Qr(o,e),...t})}function eo(e){return ["portfolio","perps","history",e??{}]}async function Lr(e,t){return await e.getPerpsHistory(t)}function pt(e,t={}){let o=H();return reactQuery.useQuery({queryKey:eo(e),queryFn:async()=>Lr(o,e),...t})}function to(e){return ["portfolio","prediction","active",e??{}]}async function _r(e,t){return await e.getPredictionBets(t)}function dt(e,t={}){let o=H();return reactQuery.useQuery({queryKey:to(e),queryFn:async()=>_r(o,e),...t})}function oo(e){return ["portfolio","prediction","settled",e??{}]}async function Kr(e,t){return await e.getPredictionSettled(t)}function ct(e,t={}){let o=H();return reactQuery.useQuery({queryKey:oo(e),queryFn:async()=>Kr(o,e),...t})}function ro(e){return ["portfolio","chart",e]}async function qr(e,t){return await e.getChartData(t)}function ut(e,t={}){let o=H();return reactQuery.useQuery({queryKey:ro(e),queryFn:async()=>qr(o,e),...t})}function Yr(){return ["portfolio","distribution"]}function ft(e){return {data:react.useMemo(()=>Ht(e),[e])}}function Gr(){let{refetchSummary:e}=ye();return e}var rn=15e3;function so(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}function nn({chain:e,address:t,tokenAddresses:o,pollMs:r=rn}){let n=!!t&&o.length>0,[a,i]=react.useState({}),s=react$1.useWalletPortfoliosByTokensQuery({chain:e,address:t,tokenAddresses:o},{enabled:n,refetchInterval:r}),l=react$1.useWalletPortfolioPnlsByTokensQuery({chain:e,address:t,tokenAddresses:o},{enabled:n,refetchInterval:r});react.useEffect(()=>{let v=s.data??[],u=new Map;if(l.data)for(let g of l.data)u.set(g.address,g);let x={};for(let g of v)x[g.address]={...g,pnl:u.get(g.address)??null};i(x);},[s.data,l.data]);let p=react.useRef(""),c=react.useRef(new Set),d=o.slice().sort().join(",");d!==p.current&&(p.current=d,c.current=new Set(o));let m=c.current;react$1.useWalletPortfoliosSubscription({chain:e,address:t},v=>{i(u=>{let x=u;for(let g of v){if(!m.has(g.tokenAddress))continue;let w=x[g.tokenAddress];if(!w)continue;let{chain:S,walletAddress:B,tokenAddress:O,...E}=g,V=so(E);Object.keys(V).length!==0&&(x=x===u?{...u}:x,x[g.tokenAddress]={...w,...V});}return x});},{enabled:n}),react$1.useWalletPortfolioPnlsSubscription({chain:e,address:t},v=>{i(u=>{let x=u;for(let g of v){if(!m.has(g.tokenAddress))continue;let w=x[g.tokenAddress];if(!w||!w.pnl)continue;let{walletAddress:S,tokenAddress:B,...O}=g,E=so(O);Object.keys(E).length!==0&&(x=x===u?{...u}:x,x[g.tokenAddress]={...w,pnl:{...w.pnl,...E}});}return x});},{enabled:n});let f=react.useCallback(async()=>{await Promise.all([s.refetch(),l.refetch()]);},[s.refetch,l.refetch]);return {tokens:a,isPending:s.isPending,isFetching:s.isFetching||l.isFetching,isError:s.isError,isSuccess:s.isSuccess,error:s.error,refetch:f}}function xt(e){let{defaultTab:t="spot",walletAddresses:o,chain:r}=e??{},[n,a]=react.useState(t),[i,s]=react.useState(void 0),[l,p]=react.useState(void 0),[c,d]=react.useState("networth"),[m,f]=react.useState("7D"),v=l!==void 0,u=react.useMemo(()=>{if(l)return {walletAddresses:[l],chain:r};if(o?.length)return {walletAddresses:o,chain:r}},[o,l,r]),x=it(u),g=ve(u),w=ut({period:Wt[m],...u}),S=ft(g.data?.holdings??[]),B=react.useMemo(()=>g.data?.holdings.reduce((W,U)=>W+U.value,0)??0,[g.data]),O=react.useCallback(W=>{p(W);},[]),E=react.useCallback(()=>{p(void 0);},[]),V=react.useCallback(W=>{s(W);},[]);return {activeTab:n,setActiveTab:a,walletId:i,selectWallet:V,viewingAddress:l,isViewing:v,curveType:c,setCurveType:d,curvePeriod:m,setCurvePeriod:f,portfolioQuery:u,overviewQuery:x,curveQuery:w,distributionQuery:S,spotHoldingsQuery:g,spotValue:B,perpsValue:0,predictionValue:0,enterViewing:O,exitViewing:E}}function gt(){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 yt({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:ue(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 sn({wallets:e=[],onCopyAddress:t,renderHoldings:o,isLoading:r,...n}){let a=xt(n),{activeTab:i,setActiveTab:s,walletId:l,selectWallet:p,viewingAddress:c,isViewing:d,curveType:m,setCurveType:f,curvePeriod:v,setCurvePeriod:u,portfolioQuery:x,overviewQuery:g,curveQuery:w,distributionQuery:S,spotValue:B,perpsValue:O,predictionValue:E,enterViewing:V,exitViewing:W}=a;return r||g.isLoading&&!g.data?jsxRuntime.jsx(gt,{}):jsxRuntime.jsxs("div",{children:[d&&c&&jsxRuntime.jsx(yt,{viewingAddress:c,onBack:W}),jsxRuntime.jsxs("div",{className:"mx-auto max-w-[1280px] px-6",children:[jsxRuntime.jsx(Je,{activeTab:i,onTabChange:s,spotValue:B,perpsValue:O,predictionValue:E}),jsxRuntime.jsx(je,{walletId:l,wallets:e,isViewing:d,viewingAddress:c,onSelectWallet:p,onCopyAddress:()=>{if(d&&c)t?.(c);else {let J=e.find(C=>C.id===l);J&&t?.(J.address);}},onSearch:V}),jsxRuntime.jsx(tt,{overview:g.data}),jsxRuntime.jsxs("div",{className:"grid grid-cols-[1fr_340px] gap-3 pb-4",children:[jsxRuntime.jsx(rt,{curveType:m,curvePeriod:v,data:w.data,isLoading:w.isLoading,onTypeChange:f,onPeriodChange:u}),jsxRuntime.jsx(st,{data:S.data,isLoading:false})]}),o?.({activeTab:i,portfolioQuery:x,isViewing:d})]})]})}function He({open:e,title:t,message:o,confirmLabel:r,cancelLabel:n,onConfirm:a,onCancel:i}){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:i,onKeyDown:s=>{s.key==="Escape"&&i();},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:i,children:n}),jsxRuntime.jsx("button",{type:"button",className:ui.cn("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:a,children:r})]})]})]}):null}function vt({activeTab:e,portfolioQuery:t,isViewing:o}){let[r,n]=react.useState("holdings"),[a,i]=react.useState("positions"),[s,l]=react.useState("active"),[p,c]=react.useState(""),[d,m]=react.useState(""),[f,v]=react.useState(""),[u,x]=react.useState(false),[g,w]=react.useState(false),S=react.useCallback(()=>{w(Q=>!Q);},[]),B=ve(t,{enabled:e==="spot"}),O=at(t,{enabled:e==="spot"&&r==="history"}),E=lt(t,{enabled:e==="perps"}),V=pt(t,{enabled:e==="perps"&&a==="history"}),W=dt(t,{enabled:e==="prediction"}),U=ct(t,{enabled:e==="prediction"&&s==="settled"}),ce=react.useMemo(()=>(B.data?.holdings??[]).filter(Y=>{if(u&&Y.value<1&&!Y.verified)return false;if(p){let L=p.toLowerCase();return Y.name.toLowerCase().includes(L)||Y.symbol.toLowerCase().includes(L)}return true}),[B.data?.holdings,u,p]),J=react.useMemo(()=>{let Q=E.data?.positions??[];if(!d)return Q;let Y=d.toLowerCase();return Q.filter(L=>L.pair.toLowerCase().includes(Y))},[E.data?.positions,d]),C=react.useMemo(()=>{let Q=W.data?.bets??[];if(!f)return Q;let Y=f.toLowerCase();return Q.filter(L=>L.market.toLowerCase().includes(Y))},[W.data?.bets,f]);return {spotSubTab:r,setSpotSubTab:n,perpsSubTab:a,setPerpsSubTab:i,predictionSubTab:s,setPredictionSubTab:l,spotSearch:p,setSpotSearch:c,perpsSearch:d,setPerpsSearch:m,predictionSearch:f,setPredictionSearch:v,hideSmall:u,setHideSmall:x,groupCollapsed:g,toggleGroupCollapsed:S,spotHoldingsQuery:B,spotHistoryQuery:O,perpsPositionsQuery:E,perpsHistoryQuery:V,predictionBetsQuery:W,predictionSettledQuery:U,filteredSpotHoldings:ce,filteredPerpsPositions:J,filteredPredictionBets:C,isViewing:o}}function le({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.cn("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 pe({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 j({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 Ne({label:e,disabled:t,onClick:o}){return jsxRuntime.jsxs("button",{type:"button",className:ui.cn("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 Ct({state:e,onClosePosition:t,onCloseAll:o}){let{t:r}=i18n.useTranslation(),{perpsSubTab:n,setPerpsSubTab:a,perpsSearch:i,setPerpsSearch:s,filteredPerpsPositions:l,perpsHistoryQuery:p,isViewing:c}=e,d=l.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(le,{tabs:[{key:"positions",label:r("portfolio.perps.openPositions")},{key:"history",label:r("portfolio.perps.tradeHistory")}],activeKey:n,onTabChange:m=>a(m)}),n==="positions"&&!c&&jsxRuntime.jsx(Ne,{label:r("portfolio.perps.closeAll"),disabled:!d,onClick:()=>o?.()})]}),jsxRuntime.jsx(pe,{value:i,onChange:s,placeholder:r("portfolio.perps.search.placeholder")})]}),n==="positions"?jsxRuntime.jsx(pn,{positions:l,isViewing:c,onClose:t}):jsxRuntime.jsx(cn,{records:p.data?.records??[],isLoading:p.isLoading})]})}function pn({positions:e,isViewing:t,onClose:o}){let{t:r}=i18n.useTranslation();return e.length===0?jsxRuntime.jsx(j,{title:r("portfolio.perps.empty"),hint:r("portfolio.perps.empty.hint")}):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:r("portfolio.perps.header.pair")}),jsxRuntime.jsx("span",{className:"text-right",children:r("portfolio.perps.header.size")}),jsxRuntime.jsx("span",{className:"text-right",children:r("portfolio.perps.header.entry")}),jsxRuntime.jsx("span",{className:"text-right",children:r("portfolio.perps.header.mark")}),jsxRuntime.jsx("span",{className:"text-right",children:r("portfolio.perps.header.uPnl")}),!t&&jsxRuntime.jsx("span",{className:"text-right"})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:e.map(n=>jsxRuntime.jsx(dn,{position:n,isViewing:t,onClose:o},n.id))})]})}function dn({position:e,isViewing:t,onClose:o}){let{t:r}=i18n.useTranslation(),n=e.side==="long",a=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.cn("rounded px-1.5 py-0.5 text-[10px] font-medium",n?"bg-[rgba(0,230,118,0.12)] text-[#00E676]":"bg-[rgba(255,82,82,0.12)] text-[#FF5252]"),children:r(n?"perpetuals.positions.long":"perpetuals.positions.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:I(e.size)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#A0A0B8]",children:I(e.entryPrice)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#A0A0B8]",children:I(e.markPrice)}),jsxRuntime.jsx("span",{className:ui.cn("text-right font-mono text-xs",a?"text-[#00E676]":"text-[#FF5252]"),children:Pe(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:r("portfolio.perps.close")})})]})}function cn({records:e,isLoading:t}){let{t:o}=i18n.useTranslation();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(j,{title:o("portfolio.perps.history.empty"),hint:o("portfolio.perps.history.empty.hint")}):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:o("portfolio.perps.history.header.pair")}),jsxRuntime.jsx("span",{children:o("portfolio.perps.history.header.side")}),jsxRuntime.jsx("span",{className:"text-right",children:o("portfolio.perps.history.header.size")}),jsxRuntime.jsx("span",{className:"text-right",children:o("portfolio.perps.history.header.pnl")}),jsxRuntime.jsx("span",{className:"text-right",children:o("portfolio.perps.history.header.closePrice")}),jsxRuntime.jsx("span",{className:"text-right",children:o("portfolio.perps.history.header.time")})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:e.map(r=>jsxRuntime.jsx(un,{record:r},r.id))})]})}function un({record:e}){let{t}=i18n.useTranslation(),o=e.side==="long",r=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.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",o?"bg-[rgba(0,230,118,0.12)] text-[#00E676]":"bg-[rgba(255,82,82,0.12)] text-[#FF5252]"),children:t(o?"perpetuals.positions.long":"perpetuals.positions.short")})}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-foreground",children:I(e.size)}),jsxRuntime.jsx("span",{className:ui.cn("text-right font-mono text-xs",r?"text-[#00E676]":"text-[#FF5252]"),children:Pe(e.pnl)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#A0A0B8]",children:I(e.closePrice)}),jsxRuntime.jsx("span",{className:"text-right text-[11px] text-[#5C5C72]",children:e.time})]})}function St({state:e,onSellBet:t,onSellAll:o}){let{predictionSubTab:r,setPredictionSubTab:n,predictionSearch:a,setPredictionSearch:i,filteredPredictionBets:s,predictionSettledQuery:l,isViewing:p}=e,c=s.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(le,{tabs:[{key:"active",label:"Active Bets"},{key:"settled",label:"Settled"}],activeKey:r,onTabChange:d=>n(d)}),r==="active"&&!p&&jsxRuntime.jsx(Ne,{label:"Sell All",disabled:!c,onClick:()=>o?.()})]}),jsxRuntime.jsx(pe,{value:a,onChange:i,placeholder:"Search market\u2026"})]}),r==="active"?jsxRuntime.jsx(xn,{bets:s,isViewing:p,onSell:t}):jsxRuntime.jsx(yn,{records:l.data?.records??[],isLoading:l.isLoading})]})}var fn={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]"},mn={polymarket:"Polymarket",drift:"Drift",metadao:"MetaDAO"};function lo({source:e}){return jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",fn[e]),children:mn[e]})}function xn({bets:e,isViewing:t,onSell:o}){return e.length===0?jsxRuntime.jsx(j,{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(gn,{bet:r,isViewing:t,onSell:o},r.id))})]})}function gn({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(lo,{source:e.source})]})]}),jsxRuntime.jsx("span",{className:ui.cn("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:I(e.stake)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#00E676]",children:I(e.potential)}),jsxRuntime.jsx("span",{className:"text-right",children:jsxRuntime.jsx("span",{className:ui.cn("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 yn({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(j,{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(bn,{record:o},o.id))})]})}function bn({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(lo,{source:e.source}),jsxRuntime.jsx("span",{className:ui.cn("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:I(e.stake)}),jsxRuntime.jsx("span",{className:"text-right",children:jsxRuntime.jsx("span",{className:ui.cn("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.cn("text-right font-mono text-xs",t?"text-[#00E676]":"text-[#5C5C72]"),children:t?`+${I(e.payout)}`:I(e.payout)})]})}function At({state:e}){let{spotSubTab:t,setSpotSubTab:o,spotSearch:r,setSpotSearch:n,hideSmall:a,setHideSmall:i,groupCollapsed:s,toggleGroupCollapsed:l,filteredSpotHoldings:p,spotHistoryQuery:c}=e;return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between pb-3",children:[jsxRuntime.jsx(le,{tabs:[{key:"holdings",label:"Holdings"},{key:"history",label:"History"}],activeKey:t,onTabChange:d=>o(d)}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(pe,{value:r,onChange:n,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:a,onChange:d=>i(d.target.checked)}),"Hide small"]})]})]}),t==="holdings"?jsxRuntime.jsx(Pn,{holdings:p,groupCollapsed:s,onToggleGroup:l}):jsxRuntime.jsx(vn,{records:c.data?.trades??[],isLoading:c.isLoading})]})}function Pn({holdings:e,groupCollapsed:t,onToggleGroup:o}){return e.length===0?jsxRuntime.jsx(j,{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.cn("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(hn,{holding:r},r.tokenAddress))})]})}function hn({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:Ge(e.balance)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#A0A0B8]",children:I(e.price)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-foreground",children:I(e.value)}),jsxRuntime.jsx("span",{className:ui.cn("text-right font-mono text-xs",t?"text-[#00E676]":"text-[#FF5252]"),children:Dt(e.change24h)})]})}function vn({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(j,{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(An,{record:o},`${o.txHash}-${o.tokenAddress}`))})]})}var Cn={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]"},Sn={swap:"Swap",send:"Send",receive:"Receive"};function Nn(e){return e.type==="swap"&&e.sideTokenSymbol?`${e.tokenSymbol} \u2192 ${e.sideTokenSymbol}`:e.tokenName||e.tokenSymbol}function An({record:e}){let t=Bt(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.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",Cn[e.type]),children:Sn[e.type]})}),jsxRuntime.jsx("span",{className:"truncate text-xs text-foreground",children:Nn(e)}),jsxRuntime.jsxs("span",{className:"text-right font-mono text-xs text-foreground",children:[Ge(e.tokenAmount)," ",e.tokenSymbol]}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#A0A0B8]",children:I(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 Tn({onClosePosition:e,onCloseAllPositions:t,onSellBet:o,onSellAllBets:r,...n}){let a=vt(n),[i,s]=react.useState(null),l=react.useCallback(()=>{s("closeAll");},[]),p=react.useCallback(()=>{s("sellAll");},[]),c=react.useCallback(()=>{i==="closeAll"?t?.():i==="sellAll"&&r?.(),s(null);},[i,t,r]),d=react.useCallback(()=>{s(null);},[]);return jsxRuntime.jsxs("div",{className:"rounded-xl border border-[#1C1C26] bg-[#0E0E16] p-4",children:[(()=>{switch(n.activeTab){case "spot":return jsxRuntime.jsx(At,{state:a});case "perps":return jsxRuntime.jsx(Ct,{state:a,onClosePosition:e,onCloseAll:l});case "prediction":return jsxRuntime.jsx(St,{state:a,onSellBet:o,onSellAll:p});default:return null}})(),jsxRuntime.jsx(He,{open:i==="closeAll",title:"Close All Positions",message:"Close all positions? This will route to each protocol to execute.",confirmLabel:"Confirm Close All",cancelLabel:"Cancel",onConfirm:c,onCancel:d}),jsxRuntime.jsx(He,{open:i==="sellAll",title:"Sell All Positions",message:"Sell all positions? This will route to each platform to execute.",confirmLabel:"Confirm Sell All",cancelLabel:"Cancel",onConfirm:c,onCancel:d})]})}function de(e,t=Date.now()){if(e==null)return "--";let o=typeof e=="string"||typeof e=="number"?new Date(e):e,r=typeof t=="number"?new Date(t):t,n=Math.max(0,Math.floor((r.getTime()-o.getTime())/1e3));if(n<60)return `${n}s`;let a=Math.floor(n/60);if(a<60)return `${a}m`;let i=Math.floor(a/60);if(i<24)return `${i}h`;let s=Math.floor(i/24);if(s<30)return `${s}d`;let l=Math.floor(s/30);return l<12?`${l}mo`:`${Math.floor(s/365)}y`}function me(e,t=4,o=4){return e?e.length<=t+o+1?e:`${e.slice(0,t)}\u2026${e.slice(-o)}`:"--"}var Fn={kol:{label:"KOL",bgClass:"bg-yellow-500/15",textClass:"text-yellow-400"},smart:{label:"Smart",bgClass:"bg-sky-500/15",textClass:"text-sky-400"},sniper:{label:"Sniper",bgClass:"bg-red-500/15",textClass:"text-red-400"},dev:{label:"Dev",bgClass:"bg-orange-500/15",textClass:"text-orange-400"},bundle:{label:"Bundle",bgClass:"bg-purple-500/15",textClass:"text-purple-400"},bluechip:{label:"Bluechip",bgClass:"bg-emerald-500/15",textClass:"text-emerald-400"},insider:{label:"Insider",bgClass:"bg-fuchsia-500/15",textClass:"text-fuchsia-400"},fresh:{label:"Fresh",bgClass:"bg-teal-500/15",textClass:"text-teal-400"}};function In({tag:e,className:t}){let o=Fn[e]??{label:e,bgClass:"bg-default/20",textClass:"text-default-500"};return jsxRuntime.jsx("span",{className:ui.cn("inline-flex items-center rounded px-1.5 py-0.5 text-[10px] font-medium uppercase leading-none tracking-wide",o.bgClass,o.textClass,t),children:o.label})}function We({tags:e,className:t,max:o}){if(!e||e.length===0)return null;let r=o!=null&&o>0?e.slice(0,o):e,n=e.length-r.length;return jsxRuntime.jsxs("div",{className:ui.cn("flex flex-wrap items-center gap-1",t),children:[r.map(a=>jsxRuntime.jsx(In,{tag:a},a)),n>0&&jsxRuntime.jsxs("span",{className:"inline-flex items-center rounded bg-default/20 px-1.5 py-0.5 text-[10px] font-medium text-default-500",children:["+",n]})]})}var Dn=[{value:"timestamp",label:"Latest"},{value:"totalUsd",label:"Top USD"}],Un=[{value:"all",label:"All"},{value:"buy",label:"Buys"},{value:"sell",label:"Sells"}];function mo({activities:e,isLoading:t,sortBy:o,onSortByChange:r,typeFilter:n="all",onTypeFilterChange:a,onLoadMore:i,hasMore:s,now:l=Date.now(),nativeDecimals:p=9,nativeSymbol:c="SOL",className:d,onRowClick:m}){return jsxRuntime.jsxs("div",{className:ui.cn("flex flex-col",d),children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-1",children:Un.map(f=>jsxRuntime.jsx("button",{type:"button",onClick:()=>a?.(f.value),className:ui.cn("rounded px-2 py-1 text-[11px] transition-colors",n===f.value?"bg-default-100 text-foreground":"text-default-400 hover:text-foreground"),children:f.label},f.value))}),jsxRuntime.jsx("div",{className:"flex items-center gap-1",children:Dn.map(f=>jsxRuntime.jsx("button",{type:"button",onClick:()=>r(f.value),className:ui.cn("rounded px-2 py-1 text-[11px] transition-colors",o===f.value?"bg-default-100 text-foreground":"text-default-400 hover:text-foreground"),children:f.label},f.value))})]}),jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full min-w-[780px] table-fixed text-[12px]",children:[jsxRuntime.jsx("thead",{className:"text-default-400",children:jsxRuntime.jsxs("tr",{className:"border-b border-default-100",children:[jsxRuntime.jsx("th",{className:"w-[10%] px-3 py-2 text-left font-normal",children:"Side"}),jsxRuntime.jsx("th",{className:"w-[25%] px-3 py-2 text-left font-normal",children:"Token"}),jsxRuntime.jsx("th",{className:"w-[15%] px-3 py-2 text-right font-normal",children:"Amount"}),jsxRuntime.jsx("th",{className:"w-[15%] px-3 py-2 text-right font-normal",children:"USD"}),jsxRuntime.jsx("th",{className:"w-[15%] px-3 py-2 text-left font-normal",children:"Tags"}),jsxRuntime.jsx("th",{className:"w-[10%] px-3 py-2 text-right font-normal",children:"Gas"}),jsxRuntime.jsx("th",{className:"w-[10%] px-3 py-2 text-right font-normal",children:"Age"})]})}),jsxRuntime.jsxs("tbody",{children:[e.length===0&&!t&&jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:7,className:"py-8 text-center text-default-400",children:"No activities"})}),e.map(f=>jsxRuntime.jsx(On,{activity:f,now:l,nativeDecimals:p,nativeSymbol:c,onRowClick:m},`${f.txHash}-${f.walletAddress}`)),t&&jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:7,className:"py-4 text-center text-default-400",children:"Loading\u2026"})})]})]})}),s&&jsxRuntime.jsx("div",{className:"flex justify-center px-3 py-2",children:jsxRuntime.jsx("button",{type:"button",onClick:i,disabled:t,className:"rounded bg-default-100 px-3 py-1 text-[11px] text-default-600 transition-colors hover:bg-default-200 disabled:opacity-50",children:"Load more"})})]})}function Bn(e){return e.type==="buy"?e.to:e.type==="sell"?e.from:e.to}function Hn(e,t,o){if(!e)return "--";let r=Number(e)/Math.pow(10,t);return Number.isFinite(r)?`${utils.formatAmount(r)} ${o}`:"--"}function On({activity:e,now:t,nativeDecimals:o,nativeSymbol:r,onRowClick:n}){let a=Bn(e),i=e.type==="buy"?"Buy":e.type==="sell"?"Sell":e.type.replace(/_/g," "),s=e.type==="buy"?"text-bullish":e.type==="sell"?"text-bearish":"text-default-500";return jsxRuntime.jsxs("tr",{className:ui.cn("border-b border-default-50 hover:bg-default-50/60",n&&"cursor-pointer"),onClick:n?()=>n(e):void 0,children:[jsxRuntime.jsx("td",{className:ui.cn("px-3 py-2 align-middle font-medium capitalize",s),children:i}),jsxRuntime.jsx("td",{className:"px-3 py-2 align-middle",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-0.5",children:[jsxRuntime.jsx("span",{className:"text-foreground",children:a.symbol}),jsxRuntime.jsx("span",{className:"font-mono text-[10px] text-default-400",children:me(a.address,6,6)})]})}),jsxRuntime.jsxs("td",{className:"px-3 py-2 text-right align-middle text-default-500",children:[utils.formatAmount(a.amount)," ",a.symbol]}),jsxRuntime.jsx("td",{className:"px-3 py-2 text-right align-middle text-foreground",children:a.amountInUsd?utils.formatAmountUSDCompact(a.amountInUsd):"--"}),jsxRuntime.jsx("td",{className:"px-3 py-2 align-middle",children:jsxRuntime.jsx(We,{tags:e.traderTags,max:2})}),jsxRuntime.jsx("td",{className:"px-3 py-2 text-right align-middle text-default-400",children:Hn(e.gasFee,o,r)}),jsxRuntime.jsx("td",{className:"px-3 py-2 text-right align-middle text-default-400",children:de(e.time,t)})]})}function yo({chain:e,address:t,limit:o=50,initialSortBy:r="timestamp",initialTypeFilter:n="all"}){let[a,i]=react.useState(r),[s,l]=react.useState(n),[p,c]=react.useState(void 0),[d,m]=react.useState([]),[f,v]=react.useState([]),u=react.useCallback(()=>{c(void 0),m([]),v([]);},[]),x=react.useCallback(C=>{C!==a&&(i(C),u());},[a,u]),g=react.useCallback(C=>{C!==s&&(l(C),u());},[s,u]);react.useEffect(()=>{u();},[e,t,u]);let w=s==="all"?void 0:s,S=react.useMemo(()=>({chain:e,address:t,cursor:p,limit:o,sortBy:a,type:w}),[e,t,p,o,a,w]),{data:B,isPending:O,isFetching:E}=react$1.useWalletActivitiesQuery(S);react.useEffect(()=>{B&&m(C=>p==null?[B]:C[C.length-1]?.endCursor===B.endCursor?C:[...C,B]);},[B,p]);let V=a==="timestamp"&&s==="all"&&p==null;react$1.useWalletActivitiesSubscription({chain:e,address:t},C=>{!V||!C?.length||v(Q=>{let Y=new Set(Q.map(Ke=>Ke.txHash)),L=C.filter(Ke=>!Y.has(Ke.txHash));return L.length===0?Q:[...L,...Q].slice(0,100)});});let W=react.useMemo(()=>{let C=d.flatMap(L=>L.data);if(!V||f.length===0)return C;let Q=new Set(C.map(L=>L.txHash));return [...f.filter(L=>!Q.has(L.txHash)),...C]},[d,f,V]),U=d[d.length-1],ce=!!(U?.hasNext&&U.endCursor),J=react.useCallback(()=>{!U?.endCursor||!U.hasNext||c(U.endCursor);},[U]);return {activities:W,isLoading:O||E,sortBy:a,setSortBy:x,typeFilter:s,setTypeFilter:g,hasMore:ce,loadMore:J}}function tp({chain:e,address:t,limit:o,initialSortBy:r,initialTypeFilter:n,nativeDecimals:a,nativeSymbol:i,className:s,onRowClick:l}){let{activities:p,isLoading:c,sortBy:d,setSortBy:m,typeFilter:f,setTypeFilter:v,hasMore:u,loadMore:x}=yo({chain:e,address:t,limit:o,initialSortBy:r,initialTypeFilter:n});return jsxRuntime.jsx(mo,{activities:p,isLoading:c,sortBy:d,onSortByChange:m,typeFilter:f,onTypeFilterChange:v,hasMore:u,onLoadMore:x,className:s,nativeDecimals:a,nativeSymbol:i,onRowClick:l})}function ho({data:e,isLoading:t,className:o,now:r=Date.now(),onRowClick:n,onLoadMore:a,hasMore:i}){return jsxRuntime.jsxs("div",{className:ui.cn("flex flex-col",o),children:[jsxRuntime.jsx("div",{className:"flex items-baseline justify-between px-3 py-2",children:jsxRuntime.jsxs("span",{className:"text-xs font-medium text-default-500",children:["Holdings",e&&jsxRuntime.jsxs("span",{className:"ml-2 text-[10px] text-default-400",children:["Net worth ",utils.formatAmountUSDCompact(e.balanceInUsd)]})]})}),jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full min-w-[720px] table-fixed text-[12px]",children:[jsxRuntime.jsx("thead",{className:"text-default-400",children:jsxRuntime.jsxs("tr",{className:"border-b border-default-100",children:[jsxRuntime.jsx("th",{className:"w-[28%] px-3 py-2 text-left font-normal",children:"Token"}),jsxRuntime.jsx("th",{className:"w-[15%] px-3 py-2 text-right font-normal",children:"Amount"}),jsxRuntime.jsx("th",{className:"w-[15%] px-3 py-2 text-right font-normal",children:"Value"}),jsxRuntime.jsx("th",{className:"w-[14%] px-3 py-2 text-right font-normal",children:"Avg cost"}),jsxRuntime.jsx("th",{className:"w-[16%] px-3 py-2 text-left font-normal",children:"Tags"}),jsxRuntime.jsx("th",{className:"w-[12%] px-3 py-2 text-right font-normal",children:"Last active"})]})}),jsxRuntime.jsxs("tbody",{children:[(!e||e.portfolios.length===0)&&!t&&jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:6,className:"py-8 text-center text-default-400",children:"No holdings"})}),e?.portfolios.map(s=>jsxRuntime.jsx(_n,{portfolio:s,now:r,onRowClick:n},`${s.chain}-${s.address}`)),t&&jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:6,className:"py-4 text-center text-default-400",children:"Loading\u2026"})})]})]})}),i&&jsxRuntime.jsx("div",{className:"flex justify-center px-3 py-2",children:jsxRuntime.jsx("button",{type:"button",onClick:a,disabled:t,className:"rounded bg-default-100 px-3 py-1 text-[11px] text-default-600 transition-colors hover:bg-default-200 disabled:opacity-50",children:"Load more"})})]})}function _n({portfolio:e,now:t,onRowClick:o}){return jsxRuntime.jsxs("tr",{className:ui.cn("border-b border-default-50 hover:bg-default-50/60",o&&"cursor-pointer"),onClick:o?()=>o(e):void 0,children:[jsxRuntime.jsx("td",{className:"px-3 py-2 align-middle",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-0.5",children:[jsxRuntime.jsx("span",{className:"text-foreground",children:e.symbol}),jsxRuntime.jsx("span",{className:"font-mono text-[10px] text-default-400",children:me(e.address,6,6)})]})}),jsxRuntime.jsx("td",{className:"px-3 py-2 text-right align-middle text-default-500",children:utils.formatAmount(e.amount)}),jsxRuntime.jsx("td",{className:"px-3 py-2 text-right align-middle text-foreground",children:utils.formatAmountUSDCompact(e.amountInUsd)}),jsxRuntime.jsx("td",{className:"px-3 py-2 text-right align-middle text-default-400",children:e.avgCostUsd?utils.formatPriceUSD(e.avgCostUsd):"--"}),jsxRuntime.jsx("td",{className:"px-3 py-2 align-middle",children:jsxRuntime.jsx(We,{tags:e.walletTokenTags,max:2})}),jsxRuntime.jsx("td",{className:"px-3 py-2 text-right align-middle text-default-400",children:e.lastActiveAt?de(e.lastActiveAt,t):"--"})]})}function So({chain:e,address:t,limit:o=50}){let[r,n]=react.useState(void 0),[a,i]=react.useState([]);react.useEffect(()=>{i([]),n(void 0);},[e,t]);let{data:s,isPending:l,isFetching:p}=react$1.useWalletPortfoliosQuery({chain:e,address:t,cursor:r,limit:o});react.useEffect(()=>{s&&i(v=>r==null?[s]:v[v.length-1]?.endCursor===s.endCursor?v:[...v,s]);},[s,r]);let c=react.useMemo(()=>a.length===0?void 0:{...a[0],portfolios:a.flatMap(u=>u.portfolios)},[a]),d=a[a.length-1],m=!!(d?.hasNext&&d.endCursor),f=react.useCallback(()=>{!d?.endCursor||!d.hasNext||n(d.endCursor);},[d]);return {data:c,isLoading:l||p,hasMore:m,loadMore:f}}function bp({chain:e,address:t,limit:o,className:r,onRowClick:n}){let{data:a,isLoading:i,hasMore:s,loadMore:l}=So({chain:e,address:t,limit:o});return jsxRuntime.jsx(ho,{data:a,isLoading:i,className:r,hasMore:s,onLoadMore:l,onRowClick:n})}var zn=[{value:"7d",label:"7D"},{value:"30d",label:"30D"},{value:"90d",label:"90D"}],Yn=[{value:"open",label:"Open"},{value:"closed",label:"Closed"},{value:"all",label:"All"}],Gn=[{value:"totalPnl",label:"Total"},{value:"realizedPnl",label:"Realized"},{value:"unrealizedPnl",label:"Unrealized"}];function To({data:e,isLoading:t,resolution:o,onResolutionChange:r,positionState:n,onPositionStateChange:a,sortBy:i,onSortByChange:s,hasMore:l,onLoadMore:p,now:c=Date.now(),className:d,onRowClick:m}){return jsxRuntime.jsxs("div",{className:ui.cn("flex flex-col gap-2",d),children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2",children:[jsxRuntime.jsx(wt,{label:"Window",options:zn,value:o,onChange:r}),jsxRuntime.jsx(wt,{label:"Status",options:Yn,value:n,onChange:a}),jsxRuntime.jsx(wt,{label:"Sort",options:Gn,value:i,onChange:s})]}),e&&jsxRuntime.jsx(jn,{data:e}),jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full min-w-[780px] table-fixed text-[12px]",children:[jsxRuntime.jsx("thead",{className:"text-default-400",children:jsxRuntime.jsxs("tr",{className:"border-b border-default-100",children:[jsxRuntime.jsx("th",{className:"w-[22%] px-3 py-2 text-left font-normal",children:"Token"}),jsxRuntime.jsx("th",{className:"w-[13%] px-3 py-2 text-right font-normal",children:"Holding"}),jsxRuntime.jsx("th",{className:"w-[13%] px-3 py-2 text-right font-normal",children:"Total PnL"}),jsxRuntime.jsx("th",{className:"w-[13%] px-3 py-2 text-right font-normal",children:"Realized"}),jsxRuntime.jsx("th",{className:"w-[13%] px-3 py-2 text-right font-normal",children:"Unrealized"}),jsxRuntime.jsx("th",{className:"w-[8%] px-3 py-2 text-right font-normal",children:"State"}),jsxRuntime.jsx("th",{className:"w-[9%] px-3 py-2 text-right font-normal",children:"First buy"}),jsxRuntime.jsx("th",{className:"w-[9%] px-3 py-2 text-right font-normal",children:"Last sell"})]})}),jsxRuntime.jsxs("tbody",{children:[(!e||e.portfolios.length===0)&&!t&&jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:8,className:"py-8 text-center text-default-400",children:"No positions"})}),e?.portfolios.map(f=>jsxRuntime.jsx(Xn,{pnl:f,now:c,onRowClick:m},`${f.chain}-${f.address}`)),t&&jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:8,className:"py-4 text-center text-default-400",children:"Loading\u2026"})})]})]})}),l&&jsxRuntime.jsx("div",{className:"flex justify-center px-3 py-2",children:jsxRuntime.jsx("button",{type:"button",onClick:p,disabled:t,className:"rounded bg-default-100 px-3 py-1 text-[11px] text-default-600 transition-colors hover:bg-default-200 disabled:opacity-50",children:"Load more"})})]})}function wt({label:e,options:t,value:o,onChange:r}){return jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] uppercase tracking-wide text-default-400",children:e}),jsxRuntime.jsx("div",{className:"flex items-center gap-1",children:t.map(n=>jsxRuntime.jsx("button",{type:"button",onClick:()=>r(n.value),className:ui.cn("rounded px-2 py-1 text-[11px] transition-colors",o===n.value?"bg-default-100 text-foreground":"text-default-400 hover:text-foreground"),children:n.label},n.value))})]})}function jn({data:e}){let t=e.totalProfitInUsd,o=e.totalProfitRatio,r=e.winRate;return jsxRuntime.jsxs("div",{className:"mx-3 flex flex-wrap items-center gap-x-6 gap-y-2 rounded border border-default-100 bg-default-50 px-4 py-2 text-xs",children:[jsxRuntime.jsx(Me,{label:"Total PnL",value:t?utils.formatAmountUSDCompact(t,{showPlusGtThanZero:true}):"--",tone:t?Ao(t):void 0}),jsxRuntime.jsx(Me,{label:"Return",value:o?utils.formatPercent(o,{showPlusGtThanZero:true}):"--",tone:o?Ao(o):void 0}),jsxRuntime.jsx(Me,{label:"Win rate",value:r?utils.formatPercent(r):"--"}),jsxRuntime.jsx(Me,{label:"Trades",value:e.totalTrades!=null?e.totalTrades.toString():"--"})]})}function Ao(e){let t=new utils.SafeBigNumber(e);if(t.gt(0))return "bullish";if(t.lt(0))return "bearish"}function Me({label:e,value:t,tone:o}){return jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-[10px] uppercase tracking-wide text-default-400",children:e}),jsxRuntime.jsx("span",{className:ui.cn("text-sm font-medium",o==="bullish"?"text-bullish":o==="bearish"?"text-bearish":"text-foreground"),children:t})]})}function Tt({value:e}){if(!e)return jsxRuntime.jsx("span",{className:"text-default-400",children:"--"});let t=new utils.SafeBigNumber(e),o=t.gt(0)?"text-bullish":t.lt(0)?"text-bearish":"text-default-500";return jsxRuntime.jsx("span",{className:o,children:utils.formatAmountUSDCompact(e,{showPlusGtThanZero:true})})}function Xn({pnl:e,now:t,onRowClick:o}){return jsxRuntime.jsxs("tr",{className:ui.cn("border-b border-default-50 hover:bg-default-50/60",o&&"cursor-pointer"),onClick:o?()=>o(e):void 0,children:[jsxRuntime.jsx("td",{className:"px-3 py-2 align-middle",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-0.5",children:[jsxRuntime.jsx("span",{className:"text-foreground",children:e.symbol}),jsxRuntime.jsx("span",{className:"font-mono text-[10px] text-default-400",children:me(e.address,6,6)})]})}),jsxRuntime.jsx("td",{className:"px-3 py-2 text-right align-middle text-foreground",children:utils.formatAmountUSDCompact(e.amountInUsd)}),jsxRuntime.jsx("td",{className:"px-3 py-2 text-right align-middle",children:jsxRuntime.jsx(Tt,{value:e.totalProfitInUsd})}),jsxRuntime.jsx("td",{className:"px-3 py-2 text-right align-middle",children:jsxRuntime.jsx(Tt,{value:e.realizedProfitInUsd})}),jsxRuntime.jsx("td",{className:"px-3 py-2 text-right align-middle",children:jsxRuntime.jsx(Tt,{value:e.unrealizedProfitInUsd})}),jsxRuntime.jsx("td",{className:"px-3 py-2 text-right align-middle text-[10px]",children:jsxRuntime.jsx("span",{className:ui.cn("rounded px-1.5 py-0.5",e.isClosed?"bg-default/20 text-default-500":"bg-bullish/15 text-bullish"),children:e.isClosed?"Closed":"Open"})}),jsxRuntime.jsx("td",{className:"px-3 py-2 text-right align-middle text-default-400",children:e.firstBuyAt?de(e.firstBuyAt,t):"--"}),jsxRuntime.jsx("td",{className:"px-3 py-2 text-right align-middle text-default-400",children:e.lastSellAt?de(e.lastSellAt,t):"--"})]})}function Io({chain:e,address:t,limit:o=50,initialResolution:r="30d",initialPositionState:n="open",initialSortBy:a="totalPnl"}){let[i,s]=react.useState(r),[l,p]=react.useState(n),[c,d]=react.useState(a),[m,f]=react.useState(void 0),[v,u]=react.useState([]),x=react.useCallback(()=>{f(void 0),u([]);},[]),g=react.useCallback(C=>{C!==i&&(s(C),x());},[i,x]),w=react.useCallback(C=>{C!==l&&(p(C),x());},[l,x]),S=react.useCallback(C=>{C!==c&&(d(C),x());},[c,x]);react.useEffect(()=>{x();},[e,t,x]);let B=react.useMemo(()=>({chain:e,address:t,cursor:m,limit:o,resolution:i,positionState:l,sortBy:c}),[e,t,m,o,i,l,c]),{data:O,isPending:E,isFetching:V}=react$1.useWalletPortfolioPnlsQuery(B);react.useEffect(()=>{O&&u(C=>m==null?[O]:C[C.length-1]?.endCursor===O.endCursor?C:[...C,O]);},[O,m]);let W=react.useMemo(()=>v.length===0?void 0:{...v[0],portfolios:v.flatMap(Q=>Q.portfolios)},[v]),U=v[v.length-1],ce=!!(U?.hasNext&&U.endCursor),J=react.useCallback(()=>{!U?.endCursor||!U.hasNext||f(U.endCursor);},[U]);return {data:W,isLoading:E||V,resolution:i,setResolution:g,positionState:l,setPositionState:w,sortBy:c,setSortBy:S,hasMore:ce,loadMore:J}}function Hp({chain:e,address:t,limit:o,initialResolution:r,initialPositionState:n,initialSortBy:a,className:i,onRowClick:s}){let{data:l,isLoading:p,resolution:c,setResolution:d,positionState:m,setPositionState:f,sortBy:v,setSortBy:u,hasMore:x,loadMore:g}=Io({chain:e,address:t,limit:o,initialResolution:r,initialPositionState:n,initialSortBy:a});return jsxRuntime.jsx(To,{data:l,isLoading:p,resolution:c,onResolutionChange:d,positionState:m,onPositionStateChange:f,sortBy:v,onSortByChange:u,hasMore:x,onLoadMore:g,className:i,onRowClick:s})}function es({client:e,children:t}){return jsxRuntime.jsx(xe.Provider,{value:e,children:t})}var as=15e3;function ls(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}function Ro({chain:e,address:t,enabled:o=true,summaryPollMs:r=as}){let{setSummary:n,setSummaryStatus:a,setRefetchSummary:i}=react.useContext(De),s=react$1.useWalletPortfoliosQuery({chain:e,address:t},{enabled:o,refetchInterval:r}),l=react$1.useWalletPnlQuery({chain:e,address:t},{enabled:o,refetchInterval:r});react.useEffect(()=>{n(null);},[e,t,n]),react.useEffect(()=>{let c=s.isPending||l.isPending,d=s.isFetching||l.isFetching,m=s.isError||l.isError,f=s.isSuccess&&l.isSuccess;a({status:m?"error":f?"success":"pending",fetchStatus:d?"fetching":"idle",isLoading:c&&d,isPending:c,isFetching:d,isRefetching:f&&d,isError:m,isSuccess:f,error:s.error??l.error,dataUpdatedAt:Math.max(s.dataUpdatedAt,l.dataUpdatedAt)});},[s.isPending,s.isFetching,s.isError,s.isSuccess,s.error,s.dataUpdatedAt,l.isPending,l.isFetching,l.isError,l.isSuccess,l.error,l.dataUpdatedAt,a]),react.useEffect(()=>{let c=s.data,d=l.data;!c||!d||n({...d,balanceInUsd:c.balanceInUsd,balanceInNative:c.balanceInNative});},[s.data,l.data,n]),react$1.useWalletPnlSubscription({chain:e,address:t},c=>{n(d=>{if(!d)return d;let m=d;for(let f of c)m={...m,...ls(f)};return m});},{enabled:o});let p=react.useCallback(async()=>{await Promise.all([s.refetch(),l.refetch()]);},[s,l]);react.useEffect(()=>{i(p);},[p,i]);}function ds({chain:e,address:t,children:o}){let[r,n]=react.useState(null),[a,i]=react.useState(us),s=react.useRef(()=>Promise.resolve()),l=react.useCallback(()=>s.current(),[]),p=react.useCallback(m=>{s.current=m;},[]),c=react.useMemo(()=>({summary:r,summaryStatus:a,refetchSummary:l}),[r,a,l]),d=react.useMemo(()=>({setSummary:n,setSummaryStatus:i,setRefetchSummary:p}),[n,i,p]);return jsxRuntime.jsx(De.Provider,{value:d,children:jsxRuntime.jsx(ge.Provider,{value:c,children:jsxRuntime.jsx(cs,{chain:e,address:t,children:o})})})}function cs({chain:e,address:t,children:o}){return Ro({chain:e,address:t,enabled:!!t}),jsxRuntime.jsx(jsxRuntime.Fragment,{children:o})}var us={status:"pending",fetchStatus:"idle",isLoading:false,isPending:true,isFetching:false,isRefetching:false,isError:false,isSuccess:false,error:null,dataUpdatedAt:0};
|
|
2
|
-
exports.AccountInfoUI=Ye;exports.AccountInfoWidget=
|
|
1
|
+
'use strict';var react=require('react'),uiChainSelect=require('@liberfi.io/ui-chain-select'),utils=require('@liberfi.io/utils'),walletConnector=require('@liberfi.io/wallet-connector'),i18n=require('@liberfi.io/i18n'),ui=require('@liberfi.io/ui'),jsxRuntime=require('react/jsx-runtime'),recharts=require('recharts'),reactQuery=require('@tanstack/react-query'),react$1=require('@liberfi.io/react');var xe=react.createContext(null);var ge=react.createContext({}),Re=react.createContext({});function ye(){let e=react.useContext(ge);if(!e)throw new Error("usePortfolioContext must be used within a PortfolioProvider");return e}function $e(){let{summary:e,summaryStatus:t}=ye();return {data:e,...t}}function ze(){let{status:e,signIn:t,signOut:o}=walletConnector.useAuth(),{data:r}=$e(),{chain:n,chainNamespace:a}=uiChainSelect.useCurrentChain(),i=walletConnector.useConnectedWallet(n),s=react.useMemo(()=>utils.getNativeToken(n),[n]),l=react.useMemo(()=>r?.balanceInUsd?utils.formatAmountUSD(r.balanceInUsd):"--",[r?.balanceInUsd]),p=react.useMemo(()=>r?.balanceInNative?utils.formatAmount(r.balanceInNative):"--",[r?.balanceInNative]);return {status:e,signIn:t,signOut:o,balanceUsdFormatted:l,balanceNativeFormatted:p,nativeToken:s,chainNamespace:a,walletAddress:i?.address??""}}function Ye({status:e,signIn:t,signOut:o,balanceUsdFormatted:r,balanceNativeFormatted:n,nativeToken:a,chainNamespace:i,walletAddress:s,actions:l}){let{t:p}=i18n.useTranslation(),{isMobile:c}=ui.useScreen(),{isOpen:d,onClose:m,onOpenChange:f}=ui.useDisclosure(),v=ui.useCopyToClipboard(),u=react.useCallback(()=>{v(s,()=>ui.toast.success(p("common.primaryAddressCopied",{network:i.toUpperCase()})));},[v,i,s]);return e==="unauthenticated"?jsxRuntime.jsx(ui.Button,{isIconOnly:c,size:"sm",color:"primary",radius:"full",disableRipple:true,onPress:t,startContent:c?void 0:jsxRuntime.jsx(ui.SignInIcon,{width:16,height:16}),"aria-label":p("common.signIn"),children:c?jsxRuntime.jsx(ui.SignInIcon,{width:16,height:16}):p("common.signIn")}):e==="authenticating"?jsxRuntime.jsx(ui.Button,{isIconOnly:c,size:"sm",color:"primary",radius:"full",disableRipple:true,isLoading:true,isDisabled:true,"aria-label":p("common.signingIn"),children:p("common.signingIn")}):e==="deauthenticating"?jsxRuntime.jsx(ui.Button,{isIconOnly:c,size:"sm",color:"primary",radius:"full",disableRipple:true,isLoading:true,isDisabled:true,"aria-label":p("common.signingOut"),children:p("common.signingOut")}):jsxRuntime.jsxs(ui.StyledPopover,{placement:c?"bottom":"bottom-end",isOpen:d,onOpenChange:f,triggerScaleOnOpen:false,children:[jsxRuntime.jsx(ui.PopoverTrigger,{children:jsxRuntime.jsx(ui.Button,{size:"sm",className:"bg-content2",radius:"full",disableRipple:true,startContent:jsxRuntime.jsx(ui.WalletIcon,{width:16,height:16,className:"text-neutral"}),endContent:jsxRuntime.jsx(ui.ChevronDownIcon,{width:16,height:16,className:ui.cn("text-neutral transition-transform",d&&"rotate-180")}),children:a&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx(ui.TokenIcon,{symbol:a.symbol,size:16}),jsxRuntime.jsx("span",{className:"text-xs text-foreground",children:c?n:`${n} ${a.symbol}`})]})})}),jsxRuntime.jsx(ui.PopoverContent,{children:jsxRuntime.jsxs("div",{className:"w-70 flex flex-col gap-3 py-4",children:[jsxRuntime.jsxs("div",{className:"px-4 flex items-start justify-between",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-0.5",children:[jsxRuntime.jsx("span",{className:"text-xs text-neutral",children:p("common.totalValue")}),jsxRuntime.jsx("span",{className:"text-base font-semibold text-foreground",children:r})]}),jsxRuntime.jsx("div",{className:"flex items-start justify-end gap-0.5",children:jsxRuntime.jsx(ui.StyledTooltip,{content:p("common.copyPrimaryAddress",{network:i.toUpperCase()}),children:jsxRuntime.jsx(ui.Button,{className:"text-xs bg-transparent text-neutral hover:text-foreground h-4 min-h-4 gap-1",startContent:jsxRuntime.jsx(ui.CopyIcon,{width:14,height:14}),disableRipple:true,disableAnimation:true,onPress:u,children:i.toUpperCase()})})})]}),jsxRuntime.jsx(ui.Divider,{}),jsxRuntime.jsxs("div",{className:"grid grid-cols-4 gap-2 px-4",children:[l?.map(x=>jsxRuntime.jsxs("button",{type:"button",className:"flex cursor-pointer flex-col items-center justify-center gap-1 rounded-md py-2 text-foreground transition-colors hover:text-primary",onClick:()=>{x.onPress(),m();},children:[x.icon,jsxRuntime.jsx("span",{className:"w-full truncate text-center text-xs",children:x.label})]},x.key)),jsxRuntime.jsxs("button",{type:"button",className:"flex cursor-pointer flex-col items-center justify-center gap-1 rounded-md py-2 text-danger transition-colors hover:text-danger/80",onClick:()=>{o(),m();},children:[jsxRuntime.jsx(ui.SignOutIcon,{width:16,height:16}),jsxRuntime.jsx("span",{className:"w-full truncate text-center text-xs",children:p("common.signOut")})]})]})]})})]})}function ir({actions:e}){let t=ze();return jsxRuntime.jsx(Ye,{status:t.status,signIn:t.signIn,signOut:t.signOut,balanceUsdFormatted:t.balanceUsdFormatted,balanceNativeFormatted:t.balanceNativeFormatted,nativeToken:t.nativeToken,chainNamespace:t.chainNamespace,walletAddress:t.walletAddress,actions:e})}function Ks(e){if(!e)return 0;let t=Number(e);return Number.isFinite(t)?t:0}function D(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 Pe(e){let t=D(Math.abs(e));return e>0?`+${t}`:e<0?`-${t.replace("-","")}`:t}function Rt(e){return `${e>0?"+":""}${e.toFixed(2)}%`}function It(e){let o=Math.abs(e).toFixed(2).split("."),r=Number(o[0]).toLocaleString("en-US"),n=`.${o[1]}`;return {sign:e<0?"-$":"$",integer:r,decimal:n}}function ue(e,t=4,o=4){return e.length<=t+o+3?e:`${e.slice(0,t)}\u2026${e.slice(-o)}`}function Ge(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 Bt(e,t){return `https://solscan.io/tx/${e}`}var Ut=["#C8FF00","#00E676","#0066FF","#FF6B9D","#8B7BFF","#FF5252","#FFB74D","#4DD0E1"],lr="#3A3A4E";function Ht(e){let t=e.reduce((i,s)=>i+s.value,0);if(t<=0)return {items:[]};let o=[...e].sort((i,s)=>s.value-i.value),r=[],n=0,a=0;for(let i of o){let s=i.value/t*100;s<2?n+=i.value:(r.push({name:i.name,symbol:i.symbol,percent:s,value:i.value,color:Ut[a%Ut.length]}),a++);}return n>0&&r.push({name:"Other",symbol:"OTHER",percent:n/t*100,value:n,color:lr}),{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 je({walletId:e,wallets:t,isViewing:o,viewingAddress:r,onSelectWallet:n,onCopyAddress:a,onSearch:i}){let[s,l]=react.useState(false),[p,c]=react.useState(""),d=react.useRef(null),m=!e&&!o,f=t.find(S=>S.id===e),v=o?"External":m?"All Wallets":f?.name??"",u=o?ue(r??""):m?"Aggregated":ue(f?.address??""),x=o?"bg-[#5C5C72]":m?"bg-[#C8FF00]":"bg-[#00E676]",g=react.useCallback(()=>{let S=p.trim();S.length>=32&&(i(S),c(""));},[p,i]),w=react.useCallback(S=>{S.key==="Enter"&&g();},[g]);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:d,children:[jsxRuntime.jsxs("button",{type:"button",className:ui.cn("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&&l(S=>!S),children:[jsxRuntime.jsx("span",{className:ui.cn("h-[7px] w-[7px] flex-shrink-0 rounded-full",x)}),jsxRuntime.jsx("span",{className:"text-[11px] font-medium text-[#A0A0B8]",children:v}),jsxRuntime.jsx("span",{className:"font-mono text-xs text-foreground",children:u}),!o&&jsxRuntime.jsx("svg",{className:ui.cn("text-[#5C5C72] transition-transform",s&&"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"})})]}),s&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>l(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.cn("flex w-full items-center gap-2 rounded-[5px] px-2.5 py-2 transition-colors hover:bg-[#1C1C26]",m&&"bg-[rgba(200,255,0,0.07)]"),onClick:()=>{n(void 0),l(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(S=>jsxRuntime.jsxs("button",{type:"button",className:ui.cn("flex w-full items-center gap-2 rounded-[5px] px-2.5 py-2 transition-colors hover:bg-[#1C1C26]",e===S.id&&"bg-[rgba(200,255,0,0.07)]"),onClick:()=>{n(S.id),l(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:S.name}),jsxRuntime.jsx("span",{className:"font-mono text-[11px] text-[#5C5C72]",children:ue(S.address)}),jsxRuntime.jsx("span",{className:"ml-auto font-mono text-[11px] font-medium text-foreground",children:S.balance})]},S.id))]})]})]}),jsxRuntime.jsx("button",{type:"button",className:ui.cn("rounded p-1 text-[#5C5C72] transition-colors hover:bg-[#1C1C26] hover:text-[#C8FF00]",m&&!o&&"pointer-events-none opacity-40"),onClick:a,disabled:m&&!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.cn("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:p,onChange:S=>c(S.target.value),onKeyDown:w})]}),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:g,children:"View"})]})]})}var he=(r=>(r.SPOT="spot",r.PERPS="perps",r.PREDICTION="prediction",r))(he||{}),Xe=(o=>(o.NET_WORTH="networth",o.PNL="pnl",o))(Xe||{}),Ze=(n=>(n.ONE_DAY="1D",n.SEVEN_DAY="7D",n.THIRTY_DAY="30D",n.MAX="Max",n))(Ze||{}),Wt={"1D":1,"7D":7,"30D":30,Max:365},Lt=(o=>(o.LONG="long",o.SHORT="short",o))(Lt||{}),Mt=(r=>(r.SWAP="swap",r.SEND="send",r.RECEIVE="receive",r))(Mt||{}),Vt=(o=>(o.ACTIVE="active",o.PENDING="pending",o))(Vt||{}),_t=(o=>(o.WON="won",o.LOST="lost",o))(_t||{}),Kt=(r=>(r.POLYMARKET="polymarket",r.DRIFT="drift",r.METADAO="metadao",r))(Kt||{});var ur=[{key:"spot",label:"Spot"},{key:"perps",label:"Perps"},{key:"prediction",label:"Prediction"}];function fr(e,t,o,r){switch(e){case "spot":return t;case "perps":return o;case "prediction":return r}}function Je({activeTab:e,onTabChange:t,spotValue:o=0,perpsValue:r=0,predictionValue:n=0}){return jsxRuntime.jsx("div",{className:"flex gap-1 border-b border-[#252530] pb-0 pt-5",children:ur.map(({key:a,label:i})=>{let s=e===a,l=fr(a,o,r,n);return jsxRuntime.jsxs("button",{type:"button",className:ui.cn("relative flex items-center gap-2 border-b-2 px-4 pb-3 pt-2.5 text-[13px] font-medium transition-colors",s?"border-[#C8FF00] text-foreground":"border-transparent text-[#5C5C72] hover:text-[#A0A0B8]"),onClick:()=>t(a),children:[i,!s&&jsxRuntime.jsx("span",{className:"rounded-[10px] bg-[#16161E] px-2 py-0.5 font-mono text-[11px] text-[#5C5C72]",children:D(l)})]},a)})})}function tt({overview:e}){let t=e?.totalValue??0,o=e?.uPnl??0,r=e?.realizedPnl??0,n=e?.totalProfit??0,{sign:a,integer:i,decimal:s}=It(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:a}),i,jsxRuntime.jsx("span",{className:"text-base font-normal text-[#5C5C72]",children:s})]})}),jsxRuntime.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[jsxRuntime.jsx(et,{label:"uPNL",value:o}),jsxRuntime.jsx(qt,{}),jsxRuntime.jsx(et,{label:"Realized",value:r}),jsxRuntime.jsx(qt,{}),jsxRuntime.jsx(et,{label:"Total Profit",value:n})]})]})}function et({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.cn("font-mono text-xs font-medium",t>0?"text-[#00E676]":t<0?"text-[#FF5252]":"text-[#5C5C72]"),children:Pe(t)})]})}function qt(){return jsxRuntime.jsx("div",{className:"h-3.5 w-px bg-[#252530]"})}var Cr=["1D","7D","30D","Max"];function zt(e,t){let o=new Date(e);return t==="1D"?o.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):o.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Sr(e){return e==="pnl"?"change":"netWorth"}function rt({curveType:e,curvePeriod:t,data:o,isLoading:r,onTypeChange:n,onPeriodChange:a}){let i=o?.points??[],s=Sr(e),l=e==="pnl",p=react.useMemo(()=>i.map(u=>l?u.change:u.netWorth),[i,l]),c=p.some(u=>u<0),{minVal:d,maxVal:m}=react.useMemo(()=>{if(p.length===0)return {minVal:0,maxVal:100};let u=Math.min(...p),x=Math.max(...p),g=x-u||1;return {minVal:u-g*.1,maxVal:x+g*.1}},[p]),f=react.useMemo(()=>{if(i.length===0)return [];let u=Math.min(7,i.length),x=Math.max(1,Math.floor((i.length-1)/(u-1))),g=[];for(let S=0;S<i.length;S+=x)g.push({ts:i[S].timestamp,label:zt(i[S].timestamp,t)});let w=i[i.length-1];return g[g.length-1]?.ts!==w.timestamp&&g.push({ts:w.timestamp,label:zt(w.timestamp,t)}),g},[i,t]),v=p[p.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(Yt,{label:"Net Worth",active:e==="networth",onClick:()=>n("networth")}),jsxRuntime.jsx(Yt,{label:"PNL",active:e==="pnl",onClick:()=>n("pnl")})]}),jsxRuntime.jsx("div",{className:"flex gap-0.5",children:Cr.map(u=>jsxRuntime.jsx("button",{type:"button",className:ui.cn("rounded-[3px] px-2 py-1 text-[10px] font-medium transition-colors",t===u?"bg-[rgba(200,255,0,0.07)] text-[#C8FF00]":"text-[#5C5C72] hover:bg-[#16161E] hover:text-[#A0A0B8]"),onClick:()=>a(u),children:u},u))})]}),jsxRuntime.jsx("div",{className:"h-[180px] px-4 pt-2",children:r||i.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:i,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:[d,m]}),l&&c&&jsxRuntime.jsx(recharts.ReferenceLine,{y:0,stroke:"rgba(255,255,255,0.06)",strokeDasharray:"4 4"}),jsxRuntime.jsx(recharts.Area,{type:"monotone",dataKey:s,stroke:l?v>=0?"#00E676":"#FF5252":"#C8FF00",strokeWidth:1.5,fill:l?v>=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:f.map(({ts:u,label:x})=>jsxRuntime.jsx("span",{className:"font-mono text-[9px] text-[#3A3A4E]",children:x},u))})]})}function Yt({label:e,active:t,onClick:o}){return jsxRuntime.jsx("button",{type:"button",className:ui.cn("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 st({data:e,isLoading:t}){let o=e?.items??[],r=react.useMemo(()=>o.map(n=>({name:n.name,value:n.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((n,a)=>jsxRuntime.jsx(recharts.Cell,{fill:n.color},a))})})})}),jsxRuntime.jsx("div",{className:"px-4 pb-3 pt-2",children:o.map((n,a)=>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:n.color}}),jsxRuntime.jsx("span",{className:"min-w-0 flex-1 truncate text-[#A0A0B8]",children:n.name}),jsxRuntime.jsxs("span",{className:"font-mono text-[10px] text-[#5C5C72]",children:[n.percent.toFixed(1),"%"]}),jsxRuntime.jsx("span",{className:"min-w-[55px] text-right font-mono text-[10px] text-foreground",children:D(n.value)})]},a))})]})}function H(){let e=react.useContext(xe);if(!e)throw new Error("usePortfolioClient must be used within a PortfolioClientProvider");return e}function jt(e){return ["portfolio","overview",e??{}]}async function Ur(e,t){return await e.getOverview(t)}function it(e,t={}){let o=H();return reactQuery.useQuery({queryKey:jt(e),queryFn:async()=>Ur(o,e),...t})}function Xt(e){return ["portfolio","spot","holdings",e??{}]}async function Ir(e,t){return await e.getSpotHoldings(t)}function ve(e,t={}){let o=H();return reactQuery.useQuery({queryKey:Xt(e),queryFn:async()=>Ir(o,e),...t})}function Zt(e){return ["portfolio","spot","history",e??{}]}async function Hr(e,t){return await e.getSpotHistory(t)}function at(e,t={}){let o=H();return reactQuery.useQuery({queryKey:Zt(e),queryFn:async()=>Hr(o,e),...t})}function Jt(e){return ["portfolio","perps","positions",e??{}]}async function Er(e,t){return await e.getPerpsPositions(t)}function lt(e,t={}){let o=H();return reactQuery.useQuery({queryKey:Jt(e),queryFn:async()=>Er(o,e),...t})}function eo(e){return ["portfolio","perps","history",e??{}]}async function Wr(e,t){return await e.getPerpsHistory(t)}function pt(e,t={}){let o=H();return reactQuery.useQuery({queryKey:eo(e),queryFn:async()=>Wr(o,e),...t})}function to(e){return ["portfolio","prediction","active",e??{}]}async function Mr(e,t){return await e.getPredictionBets(t)}function dt(e,t={}){let o=H();return reactQuery.useQuery({queryKey:to(e),queryFn:async()=>Mr(o,e),...t})}function oo(e){return ["portfolio","prediction","settled",e??{}]}async function _r(e,t){return await e.getPredictionSettled(t)}function ct(e,t={}){let o=H();return reactQuery.useQuery({queryKey:oo(e),queryFn:async()=>_r(o,e),...t})}function ro(e){return ["portfolio","chart",e]}async function $r(e,t){return await e.getChartData(t)}function ut(e,t={}){let o=H();return reactQuery.useQuery({queryKey:ro(e),queryFn:async()=>$r(o,e),...t})}function zr(){return ["portfolio","distribution"]}function ft(e){return {data:react.useMemo(()=>Ht(e),[e])}}function Yr(){let{refetchSummary:e}=ye();return e}var on=15e3;function so(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}function rn({chain:e,address:t,tokenAddresses:o,pollMs:r=on}){let n=!!t&&o.length>0,[a,i]=react.useState({}),s=react$1.useWalletPortfoliosByTokensQuery({chain:e,address:t,tokenAddresses:o},{enabled:n,refetchInterval:r}),l=react$1.useWalletPortfolioPnlsByTokensQuery({chain:e,address:t,tokenAddresses:o},{enabled:n,refetchInterval:r});react.useEffect(()=>{let v=s.data??[],u=new Map;if(l.data)for(let g of l.data)u.set(g.address,g);let x={};for(let g of v)x[g.address]={...g,pnl:u.get(g.address)??null};i(x);},[s.data,l.data]);let p=react.useRef(""),c=react.useRef(new Set),d=o.slice().sort().join(",");d!==p.current&&(p.current=d,c.current=new Set(o));let m=c.current;react$1.useWalletPortfoliosSubscription({chain:e,address:t},v=>{i(u=>{let x=u;for(let g of v){if(!m.has(g.tokenAddress))continue;let w=x[g.tokenAddress];if(!w)continue;let{chain:S,walletAddress:B,tokenAddress:O,...E}=g,_=so(E);Object.keys(_).length!==0&&(x=x===u?{...u}:x,x[g.tokenAddress]={...w,..._});}return x});},{enabled:n}),react$1.useWalletPortfolioPnlsSubscription({chain:e,address:t},v=>{i(u=>{let x=u;for(let g of v){if(!m.has(g.tokenAddress))continue;let w=x[g.tokenAddress];if(!w||!w.pnl)continue;let{walletAddress:S,tokenAddress:B,...O}=g,E=so(O);Object.keys(E).length!==0&&(x=x===u?{...u}:x,x[g.tokenAddress]={...w,pnl:{...w.pnl,...E}});}return x});},{enabled:n});let f=react.useCallback(async()=>{await Promise.all([s.refetch(),l.refetch()]);},[s.refetch,l.refetch]);return {tokens:a,isPending:s.isPending,isFetching:s.isFetching||l.isFetching,isError:s.isError,isSuccess:s.isSuccess,error:s.error,refetch:f}}function xt(e){let{defaultTab:t="spot",walletAddresses:o,chain:r}=e??{},[n,a]=react.useState(t),[i,s]=react.useState(void 0),[l,p]=react.useState(void 0),[c,d]=react.useState("networth"),[m,f]=react.useState("7D"),v=l!==void 0,u=react.useMemo(()=>{if(l)return {walletAddresses:[l],chain:r};if(o?.length)return {walletAddresses:o,chain:r}},[o,l,r]),x=it(u),g=ve(u),w=ut({period:Wt[m],...u}),S=ft(g.data?.holdings??[]),B=react.useMemo(()=>g.data?.holdings.reduce((W,I)=>W+I.value,0)??0,[g.data]),O=react.useCallback(W=>{p(W);},[]),E=react.useCallback(()=>{p(void 0);},[]),_=react.useCallback(W=>{s(W);},[]);return {activeTab:n,setActiveTab:a,walletId:i,selectWallet:_,viewingAddress:l,isViewing:v,curveType:c,setCurveType:d,curvePeriod:m,setCurvePeriod:f,portfolioQuery:u,overviewQuery:x,curveQuery:w,distributionQuery:S,spotHoldingsQuery:g,spotValue:B,perpsValue:0,predictionValue:0,enterViewing:O,exitViewing:E}}function gt(){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 yt({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:ue(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 nn({wallets:e=[],onCopyAddress:t,renderHoldings:o,isLoading:r,...n}){let a=xt(n),{activeTab:i,setActiveTab:s,walletId:l,selectWallet:p,viewingAddress:c,isViewing:d,curveType:m,setCurveType:f,curvePeriod:v,setCurvePeriod:u,portfolioQuery:x,overviewQuery:g,curveQuery:w,distributionQuery:S,spotValue:B,perpsValue:O,predictionValue:E,enterViewing:_,exitViewing:W}=a;return r||g.isLoading&&!g.data?jsxRuntime.jsx(gt,{}):jsxRuntime.jsxs("div",{children:[d&&c&&jsxRuntime.jsx(yt,{viewingAddress:c,onBack:W}),jsxRuntime.jsxs("div",{className:"mx-auto max-w-[1280px] px-6",children:[jsxRuntime.jsx(Je,{activeTab:i,onTabChange:s,spotValue:B,perpsValue:O,predictionValue:E}),jsxRuntime.jsx(je,{walletId:l,wallets:e,isViewing:d,viewingAddress:c,onSelectWallet:p,onCopyAddress:()=>{if(d&&c)t?.(c);else {let J=e.find(C=>C.id===l);J&&t?.(J.address);}},onSearch:_}),jsxRuntime.jsx(tt,{overview:g.data}),jsxRuntime.jsxs("div",{className:"grid grid-cols-[1fr_340px] gap-3 pb-4",children:[jsxRuntime.jsx(rt,{curveType:m,curvePeriod:v,data:w.data,isLoading:w.isLoading,onTypeChange:f,onPeriodChange:u}),jsxRuntime.jsx(st,{data:S.data,isLoading:false})]}),o?.({activeTab:i,portfolioQuery:x,isViewing:d})]})]})}function He({open:e,title:t,message:o,confirmLabel:r,cancelLabel:n,onConfirm:a,onCancel:i}){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:i,onKeyDown:s=>{s.key==="Escape"&&i();},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:i,children:n}),jsxRuntime.jsx("button",{type:"button",className:ui.cn("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:a,children:r})]})]})]}):null}function vt({activeTab:e,portfolioQuery:t,isViewing:o}){let[r,n]=react.useState("holdings"),[a,i]=react.useState("positions"),[s,l]=react.useState("active"),[p,c]=react.useState(""),[d,m]=react.useState(""),[f,v]=react.useState(""),[u,x]=react.useState(false),[g,w]=react.useState(false),S=react.useCallback(()=>{w(Q=>!Q);},[]),B=ve(t,{enabled:e==="spot"}),O=at(t,{enabled:e==="spot"&&r==="history"}),E=lt(t,{enabled:e==="perps"}),_=pt(t,{enabled:e==="perps"&&a==="history"}),W=dt(t,{enabled:e==="prediction"}),I=ct(t,{enabled:e==="prediction"&&s==="settled"}),ce=react.useMemo(()=>(B.data?.holdings??[]).filter(Y=>{if(u&&Y.value<1&&!Y.verified)return false;if(p){let L=p.toLowerCase();return Y.name.toLowerCase().includes(L)||Y.symbol.toLowerCase().includes(L)}return true}),[B.data?.holdings,u,p]),J=react.useMemo(()=>{let Q=E.data?.positions??[];if(!d)return Q;let Y=d.toLowerCase();return Q.filter(L=>L.pair.toLowerCase().includes(Y))},[E.data?.positions,d]),C=react.useMemo(()=>{let Q=W.data?.bets??[];if(!f)return Q;let Y=f.toLowerCase();return Q.filter(L=>L.market.toLowerCase().includes(Y))},[W.data?.bets,f]);return {spotSubTab:r,setSpotSubTab:n,perpsSubTab:a,setPerpsSubTab:i,predictionSubTab:s,setPredictionSubTab:l,spotSearch:p,setSpotSearch:c,perpsSearch:d,setPerpsSearch:m,predictionSearch:f,setPredictionSearch:v,hideSmall:u,setHideSmall:x,groupCollapsed:g,toggleGroupCollapsed:S,spotHoldingsQuery:B,spotHistoryQuery:O,perpsPositionsQuery:E,perpsHistoryQuery:_,predictionBetsQuery:W,predictionSettledQuery:I,filteredSpotHoldings:ce,filteredPerpsPositions:J,filteredPredictionBets:C,isViewing:o}}function le({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.cn("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 pe({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 j({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 Ne({label:e,disabled:t,onClick:o}){return jsxRuntime.jsxs("button",{type:"button",className:ui.cn("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 Ct({state:e,onClosePosition:t,onCloseAll:o}){let{t:r}=i18n.useTranslation(),{perpsSubTab:n,setPerpsSubTab:a,perpsSearch:i,setPerpsSearch:s,filteredPerpsPositions:l,perpsHistoryQuery:p,isViewing:c}=e,d=l.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(le,{tabs:[{key:"positions",label:r("portfolio.perps.openPositions")},{key:"history",label:r("portfolio.perps.tradeHistory")}],activeKey:n,onTabChange:m=>a(m)}),n==="positions"&&!c&&jsxRuntime.jsx(Ne,{label:r("portfolio.perps.closeAll"),disabled:!d,onClick:()=>o?.()})]}),jsxRuntime.jsx(pe,{value:i,onChange:s,placeholder:r("portfolio.perps.search.placeholder")})]}),n==="positions"?jsxRuntime.jsx(ln,{positions:l,isViewing:c,onClose:t}):jsxRuntime.jsx(dn,{records:p.data?.records??[],isLoading:p.isLoading})]})}function ln({positions:e,isViewing:t,onClose:o}){let{t:r}=i18n.useTranslation();return e.length===0?jsxRuntime.jsx(j,{title:r("portfolio.perps.empty"),hint:r("portfolio.perps.empty.hint")}):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:r("portfolio.perps.header.pair")}),jsxRuntime.jsx("span",{className:"text-right",children:r("portfolio.perps.header.size")}),jsxRuntime.jsx("span",{className:"text-right",children:r("portfolio.perps.header.entry")}),jsxRuntime.jsx("span",{className:"text-right",children:r("portfolio.perps.header.mark")}),jsxRuntime.jsx("span",{className:"text-right",children:r("portfolio.perps.header.uPnl")}),!t&&jsxRuntime.jsx("span",{className:"text-right"})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:e.map(n=>jsxRuntime.jsx(pn,{position:n,isViewing:t,onClose:o},n.id))})]})}function pn({position:e,isViewing:t,onClose:o}){let{t:r}=i18n.useTranslation(),n=e.side==="long",a=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.cn("rounded px-1.5 py-0.5 text-[10px] font-medium",n?"bg-[rgba(0,230,118,0.12)] text-[#00E676]":"bg-[rgba(255,82,82,0.12)] text-[#FF5252]"),children:r(n?"perpetuals.positions.long":"perpetuals.positions.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:D(e.size)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#A0A0B8]",children:D(e.entryPrice)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#A0A0B8]",children:D(e.markPrice)}),jsxRuntime.jsx("span",{className:ui.cn("text-right font-mono text-xs",a?"text-[#00E676]":"text-[#FF5252]"),children:Pe(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:r("portfolio.perps.close")})})]})}function dn({records:e,isLoading:t}){let{t:o}=i18n.useTranslation();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(j,{title:o("portfolio.perps.history.empty"),hint:o("portfolio.perps.history.empty.hint")}):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:o("portfolio.perps.history.header.pair")}),jsxRuntime.jsx("span",{children:o("portfolio.perps.history.header.side")}),jsxRuntime.jsx("span",{className:"text-right",children:o("portfolio.perps.history.header.size")}),jsxRuntime.jsx("span",{className:"text-right",children:o("portfolio.perps.history.header.pnl")}),jsxRuntime.jsx("span",{className:"text-right",children:o("portfolio.perps.history.header.closePrice")}),jsxRuntime.jsx("span",{className:"text-right",children:o("portfolio.perps.history.header.time")})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:e.map(r=>jsxRuntime.jsx(cn,{record:r},r.id))})]})}function cn({record:e}){let{t}=i18n.useTranslation(),o=e.side==="long",r=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.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",o?"bg-[rgba(0,230,118,0.12)] text-[#00E676]":"bg-[rgba(255,82,82,0.12)] text-[#FF5252]"),children:t(o?"perpetuals.positions.long":"perpetuals.positions.short")})}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-foreground",children:D(e.size)}),jsxRuntime.jsx("span",{className:ui.cn("text-right font-mono text-xs",r?"text-[#00E676]":"text-[#FF5252]"),children:Pe(e.pnl)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#A0A0B8]",children:D(e.closePrice)}),jsxRuntime.jsx("span",{className:"text-right text-[11px] text-[#5C5C72]",children:e.time})]})}function St({state:e,onSellBet:t,onSellAll:o}){let{predictionSubTab:r,setPredictionSubTab:n,predictionSearch:a,setPredictionSearch:i,filteredPredictionBets:s,predictionSettledQuery:l,isViewing:p}=e,c=s.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(le,{tabs:[{key:"active",label:"Active Bets"},{key:"settled",label:"Settled"}],activeKey:r,onTabChange:d=>n(d)}),r==="active"&&!p&&jsxRuntime.jsx(Ne,{label:"Sell All",disabled:!c,onClick:()=>o?.()})]}),jsxRuntime.jsx(pe,{value:a,onChange:i,placeholder:"Search market\u2026"})]}),r==="active"?jsxRuntime.jsx(mn,{bets:s,isViewing:p,onSell:t}):jsxRuntime.jsx(gn,{records:l.data?.records??[],isLoading:l.isLoading})]})}var un={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]"},fn={polymarket:"Polymarket",drift:"Drift",metadao:"MetaDAO"};function lo({source:e}){return jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",un[e]),children:fn[e]})}function mn({bets:e,isViewing:t,onSell:o}){return e.length===0?jsxRuntime.jsx(j,{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(xn,{bet:r,isViewing:t,onSell:o},r.id))})]})}function xn({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(lo,{source:e.source})]})]}),jsxRuntime.jsx("span",{className:ui.cn("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:D(e.stake)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#00E676]",children:D(e.potential)}),jsxRuntime.jsx("span",{className:"text-right",children:jsxRuntime.jsx("span",{className:ui.cn("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 gn({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(j,{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(yn,{record:o},o.id))})]})}function yn({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(lo,{source:e.source}),jsxRuntime.jsx("span",{className:ui.cn("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:D(e.stake)}),jsxRuntime.jsx("span",{className:"text-right",children:jsxRuntime.jsx("span",{className:ui.cn("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.cn("text-right font-mono text-xs",t?"text-[#00E676]":"text-[#5C5C72]"),children:t?`+${D(e.payout)}`:D(e.payout)})]})}function At({state:e}){let{spotSubTab:t,setSpotSubTab:o,spotSearch:r,setSpotSearch:n,hideSmall:a,setHideSmall:i,groupCollapsed:s,toggleGroupCollapsed:l,filteredSpotHoldings:p,spotHistoryQuery:c}=e;return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between pb-3",children:[jsxRuntime.jsx(le,{tabs:[{key:"holdings",label:"Holdings"},{key:"history",label:"History"}],activeKey:t,onTabChange:d=>o(d)}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(pe,{value:r,onChange:n,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:a,onChange:d=>i(d.target.checked)}),"Hide small"]})]})]}),t==="holdings"?jsxRuntime.jsx(bn,{holdings:p,groupCollapsed:s,onToggleGroup:l}):jsxRuntime.jsx(hn,{records:c.data?.trades??[],isLoading:c.isLoading})]})}function bn({holdings:e,groupCollapsed:t,onToggleGroup:o}){return e.length===0?jsxRuntime.jsx(j,{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.cn("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(Pn,{holding:r},r.tokenAddress))})]})}function Pn({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:Ge(e.balance)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#A0A0B8]",children:D(e.price)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-foreground",children:D(e.value)}),jsxRuntime.jsx("span",{className:ui.cn("text-right font-mono text-xs",t?"text-[#00E676]":"text-[#FF5252]"),children:Rt(e.change24h)})]})}function hn({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(j,{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(Nn,{record:o},`${o.txHash}-${o.tokenAddress}`))})]})}var vn={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]"},Cn={swap:"Swap",send:"Send",receive:"Receive"};function Sn(e){return e.type==="swap"&&e.sideTokenSymbol?`${e.tokenSymbol} \u2192 ${e.sideTokenSymbol}`:e.tokenName||e.tokenSymbol}function Nn({record:e}){let t=Bt(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.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",vn[e.type]),children:Cn[e.type]})}),jsxRuntime.jsx("span",{className:"truncate text-xs text-foreground",children:Sn(e)}),jsxRuntime.jsxs("span",{className:"text-right font-mono text-xs text-foreground",children:[Ge(e.tokenAmount)," ",e.tokenSymbol]}),jsxRuntime.jsx("span",{className:"text-right font-mono text-xs text-[#A0A0B8]",children:D(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 wn({onClosePosition:e,onCloseAllPositions:t,onSellBet:o,onSellAllBets:r,...n}){let a=vt(n),[i,s]=react.useState(null),l=react.useCallback(()=>{s("closeAll");},[]),p=react.useCallback(()=>{s("sellAll");},[]),c=react.useCallback(()=>{i==="closeAll"?t?.():i==="sellAll"&&r?.(),s(null);},[i,t,r]),d=react.useCallback(()=>{s(null);},[]);return jsxRuntime.jsxs("div",{className:"rounded-xl border border-[#1C1C26] bg-[#0E0E16] p-4",children:[(()=>{switch(n.activeTab){case "spot":return jsxRuntime.jsx(At,{state:a});case "perps":return jsxRuntime.jsx(Ct,{state:a,onClosePosition:e,onCloseAll:l});case "prediction":return jsxRuntime.jsx(St,{state:a,onSellBet:o,onSellAll:p});default:return null}})(),jsxRuntime.jsx(He,{open:i==="closeAll",title:"Close All Positions",message:"Close all positions? This will route to each protocol to execute.",confirmLabel:"Confirm Close All",cancelLabel:"Cancel",onConfirm:c,onCancel:d}),jsxRuntime.jsx(He,{open:i==="sellAll",title:"Sell All Positions",message:"Sell all positions? This will route to each platform to execute.",confirmLabel:"Confirm Sell All",cancelLabel:"Cancel",onConfirm:c,onCancel:d})]})}function de(e,t=Date.now()){if(e==null)return "--";let o=typeof e=="string"||typeof e=="number"?new Date(e):e,r=typeof t=="number"?new Date(t):t,n=Math.max(0,Math.floor((r.getTime()-o.getTime())/1e3));if(n<60)return `${n}s`;let a=Math.floor(n/60);if(a<60)return `${a}m`;let i=Math.floor(a/60);if(i<24)return `${i}h`;let s=Math.floor(i/24);if(s<30)return `${s}d`;let l=Math.floor(s/30);return l<12?`${l}mo`:`${Math.floor(s/365)}y`}function me(e,t=4,o=4){return e?e.length<=t+o+1?e:`${e.slice(0,t)}\u2026${e.slice(-o)}`:"--"}var kn={kol:{label:"KOL",bgClass:"bg-yellow-500/15",textClass:"text-yellow-400"},smart:{label:"Smart",bgClass:"bg-sky-500/15",textClass:"text-sky-400"},sniper:{label:"Sniper",bgClass:"bg-red-500/15",textClass:"text-red-400"},dev:{label:"Dev",bgClass:"bg-orange-500/15",textClass:"text-orange-400"},bundle:{label:"Bundle",bgClass:"bg-purple-500/15",textClass:"text-purple-400"},bluechip:{label:"Bluechip",bgClass:"bg-emerald-500/15",textClass:"text-emerald-400"},insider:{label:"Insider",bgClass:"bg-fuchsia-500/15",textClass:"text-fuchsia-400"},fresh:{label:"Fresh",bgClass:"bg-teal-500/15",textClass:"text-teal-400"}};function Fn({tag:e,className:t}){let o=kn[e]??{label:e,bgClass:"bg-default/20",textClass:"text-default-500"};return jsxRuntime.jsx("span",{className:ui.cn("inline-flex items-center rounded px-1.5 py-0.5 text-[10px] font-medium uppercase leading-none tracking-wide",o.bgClass,o.textClass,t),children:o.label})}function We({tags:e,className:t,max:o}){if(!e||e.length===0)return null;let r=o!=null&&o>0?e.slice(0,o):e,n=e.length-r.length;return jsxRuntime.jsxs("div",{className:ui.cn("flex flex-wrap items-center gap-1",t),children:[r.map(a=>jsxRuntime.jsx(Fn,{tag:a},a)),n>0&&jsxRuntime.jsxs("span",{className:"inline-flex items-center rounded bg-default/20 px-1.5 py-0.5 text-[10px] font-medium text-default-500",children:["+",n]})]})}var Un=[{value:"timestamp",label:"Latest"},{value:"totalUsd",label:"Top USD"}],Rn=[{value:"all",label:"All"},{value:"buy",label:"Buys"},{value:"sell",label:"Sells"}];function mo({activities:e,isLoading:t,sortBy:o,onSortByChange:r,typeFilter:n="all",onTypeFilterChange:a,onLoadMore:i,hasMore:s,now:l=Date.now(),nativeDecimals:p=9,nativeSymbol:c="SOL",className:d,onRowClick:m}){return jsxRuntime.jsxs("div",{className:ui.cn("flex flex-col",d),children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-1",children:Rn.map(f=>jsxRuntime.jsx("button",{type:"button",onClick:()=>a?.(f.value),className:ui.cn("rounded px-2 py-1 text-[11px] transition-colors",n===f.value?"bg-default-100 text-foreground":"text-default-400 hover:text-foreground"),children:f.label},f.value))}),jsxRuntime.jsx("div",{className:"flex items-center gap-1",children:Un.map(f=>jsxRuntime.jsx("button",{type:"button",onClick:()=>r(f.value),className:ui.cn("rounded px-2 py-1 text-[11px] transition-colors",o===f.value?"bg-default-100 text-foreground":"text-default-400 hover:text-foreground"),children:f.label},f.value))})]}),jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full min-w-[780px] table-fixed text-[12px]",children:[jsxRuntime.jsx("thead",{className:"text-default-400",children:jsxRuntime.jsxs("tr",{className:"border-b border-default-100",children:[jsxRuntime.jsx("th",{className:"w-[10%] px-3 py-2 text-left font-normal",children:"Side"}),jsxRuntime.jsx("th",{className:"w-[25%] px-3 py-2 text-left font-normal",children:"Token"}),jsxRuntime.jsx("th",{className:"w-[15%] px-3 py-2 text-right font-normal",children:"Amount"}),jsxRuntime.jsx("th",{className:"w-[15%] px-3 py-2 text-right font-normal",children:"USD"}),jsxRuntime.jsx("th",{className:"w-[15%] px-3 py-2 text-left font-normal",children:"Tags"}),jsxRuntime.jsx("th",{className:"w-[10%] px-3 py-2 text-right font-normal",children:"Gas"}),jsxRuntime.jsx("th",{className:"w-[10%] px-3 py-2 text-right font-normal",children:"Age"})]})}),jsxRuntime.jsxs("tbody",{children:[e.length===0&&!t&&jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:7,className:"py-8 text-center text-default-400",children:"No activities"})}),e.map(f=>jsxRuntime.jsx(Hn,{activity:f,now:l,nativeDecimals:p,nativeSymbol:c,onRowClick:m},`${f.txHash}-${f.walletAddress}`)),t&&jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:7,className:"py-4 text-center text-default-400",children:"Loading\u2026"})})]})]})}),s&&jsxRuntime.jsx("div",{className:"flex justify-center px-3 py-2",children:jsxRuntime.jsx("button",{type:"button",onClick:i,disabled:t,className:"rounded bg-default-100 px-3 py-1 text-[11px] text-default-600 transition-colors hover:bg-default-200 disabled:opacity-50",children:"Load more"})})]})}function In(e){return e.type==="buy"?e.to:e.type==="sell"?e.from:e.to}function Bn(e,t,o){if(!e)return "--";let r=Number(e)/Math.pow(10,t);return Number.isFinite(r)?`${utils.formatAmount(r)} ${o}`:"--"}function Hn({activity:e,now:t,nativeDecimals:o,nativeSymbol:r,onRowClick:n}){let a=In(e),i=e.type==="buy"?"Buy":e.type==="sell"?"Sell":e.type.replace(/_/g," "),s=e.type==="buy"?"text-bullish":e.type==="sell"?"text-bearish":"text-default-500";return jsxRuntime.jsxs("tr",{className:ui.cn("border-b border-default-50 hover:bg-default-50/60",n&&"cursor-pointer"),onClick:n?()=>n(e):void 0,children:[jsxRuntime.jsx("td",{className:ui.cn("px-3 py-2 align-middle font-medium capitalize",s),children:i}),jsxRuntime.jsx("td",{className:"px-3 py-2 align-middle",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-0.5",children:[jsxRuntime.jsx("span",{className:"text-foreground",children:a.symbol}),jsxRuntime.jsx("span",{className:"font-mono text-[10px] text-default-400",children:me(a.address,6,6)})]})}),jsxRuntime.jsxs("td",{className:"px-3 py-2 text-right align-middle text-default-500",children:[utils.formatAmount(a.amount)," ",a.symbol]}),jsxRuntime.jsx("td",{className:"px-3 py-2 text-right align-middle text-foreground",children:a.amountInUsd?utils.formatAmountUSDCompact(a.amountInUsd):"--"}),jsxRuntime.jsx("td",{className:"px-3 py-2 align-middle",children:jsxRuntime.jsx(We,{tags:e.traderTags,max:2})}),jsxRuntime.jsx("td",{className:"px-3 py-2 text-right align-middle text-default-400",children:Bn(e.gasFee,o,r)}),jsxRuntime.jsx("td",{className:"px-3 py-2 text-right align-middle text-default-400",children:de(e.time,t)})]})}function yo({chain:e,address:t,limit:o=50,initialSortBy:r="timestamp",initialTypeFilter:n="all"}){let[a,i]=react.useState(r),[s,l]=react.useState(n),[p,c]=react.useState(void 0),[d,m]=react.useState([]),[f,v]=react.useState([]),u=react.useCallback(()=>{c(void 0),m([]),v([]);},[]),x=react.useCallback(C=>{C!==a&&(i(C),u());},[a,u]),g=react.useCallback(C=>{C!==s&&(l(C),u());},[s,u]);react.useEffect(()=>{u();},[e,t,u]);let w=s==="all"?void 0:s,S=react.useMemo(()=>({chain:e,address:t,cursor:p,limit:o,sortBy:a,type:w}),[e,t,p,o,a,w]),{data:B,isPending:O,isFetching:E}=react$1.useWalletActivitiesQuery(S);react.useEffect(()=>{B&&m(C=>p==null?[B]:C[C.length-1]?.endCursor===B.endCursor?C:[...C,B]);},[B,p]);let _=a==="timestamp"&&s==="all"&&p==null;react$1.useWalletActivitiesSubscription({chain:e,address:t},C=>{!_||!C?.length||v(Q=>{let Y=new Set(Q.map(Ke=>Ke.txHash)),L=C.filter(Ke=>!Y.has(Ke.txHash));return L.length===0?Q:[...L,...Q].slice(0,100)});});let W=react.useMemo(()=>{let C=d.flatMap(L=>L.data);if(!_||f.length===0)return C;let Q=new Set(C.map(L=>L.txHash));return [...f.filter(L=>!Q.has(L.txHash)),...C]},[d,f,_]),I=d[d.length-1],ce=!!(I?.hasNext&&I.endCursor),J=react.useCallback(()=>{!I?.endCursor||!I.hasNext||c(I.endCursor);},[I]);return {activities:W,isLoading:O||E,sortBy:a,setSortBy:x,typeFilter:s,setTypeFilter:g,hasMore:ce,loadMore:J}}function Jl({chain:e,address:t,limit:o,initialSortBy:r,initialTypeFilter:n,nativeDecimals:a,nativeSymbol:i,className:s,onRowClick:l}){let{activities:p,isLoading:c,sortBy:d,setSortBy:m,typeFilter:f,setTypeFilter:v,hasMore:u,loadMore:x}=yo({chain:e,address:t,limit:o,initialSortBy:r,initialTypeFilter:n});return jsxRuntime.jsx(mo,{activities:p,isLoading:c,sortBy:d,onSortByChange:m,typeFilter:f,onTypeFilterChange:v,hasMore:u,onLoadMore:x,className:s,nativeDecimals:a,nativeSymbol:i,onRowClick:l})}function ho({data:e,isLoading:t,className:o,now:r=Date.now(),onRowClick:n,onLoadMore:a,hasMore:i}){return jsxRuntime.jsxs("div",{className:ui.cn("flex flex-col",o),children:[jsxRuntime.jsx("div",{className:"flex items-baseline justify-between px-3 py-2",children:jsxRuntime.jsxs("span",{className:"text-xs font-medium text-default-500",children:["Holdings",e&&jsxRuntime.jsxs("span",{className:"ml-2 text-[10px] text-default-400",children:["Net worth ",utils.formatAmountUSDCompact(e.balanceInUsd)]})]})}),jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full min-w-[720px] table-fixed text-[12px]",children:[jsxRuntime.jsx("thead",{className:"text-default-400",children:jsxRuntime.jsxs("tr",{className:"border-b border-default-100",children:[jsxRuntime.jsx("th",{className:"w-[28%] px-3 py-2 text-left font-normal",children:"Token"}),jsxRuntime.jsx("th",{className:"w-[15%] px-3 py-2 text-right font-normal",children:"Amount"}),jsxRuntime.jsx("th",{className:"w-[15%] px-3 py-2 text-right font-normal",children:"Value"}),jsxRuntime.jsx("th",{className:"w-[14%] px-3 py-2 text-right font-normal",children:"Avg cost"}),jsxRuntime.jsx("th",{className:"w-[16%] px-3 py-2 text-left font-normal",children:"Tags"}),jsxRuntime.jsx("th",{className:"w-[12%] px-3 py-2 text-right font-normal",children:"Last active"})]})}),jsxRuntime.jsxs("tbody",{children:[(!e||e.portfolios.length===0)&&!t&&jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:6,className:"py-8 text-center text-default-400",children:"No holdings"})}),e?.portfolios.map(s=>jsxRuntime.jsx(Mn,{portfolio:s,now:r,onRowClick:n},`${s.chain}-${s.address}`)),t&&jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:6,className:"py-4 text-center text-default-400",children:"Loading\u2026"})})]})]})}),i&&jsxRuntime.jsx("div",{className:"flex justify-center px-3 py-2",children:jsxRuntime.jsx("button",{type:"button",onClick:a,disabled:t,className:"rounded bg-default-100 px-3 py-1 text-[11px] text-default-600 transition-colors hover:bg-default-200 disabled:opacity-50",children:"Load more"})})]})}function Mn({portfolio:e,now:t,onRowClick:o}){return jsxRuntime.jsxs("tr",{className:ui.cn("border-b border-default-50 hover:bg-default-50/60",o&&"cursor-pointer"),onClick:o?()=>o(e):void 0,children:[jsxRuntime.jsx("td",{className:"px-3 py-2 align-middle",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-0.5",children:[jsxRuntime.jsx("span",{className:"text-foreground",children:e.symbol}),jsxRuntime.jsx("span",{className:"font-mono text-[10px] text-default-400",children:me(e.address,6,6)})]})}),jsxRuntime.jsx("td",{className:"px-3 py-2 text-right align-middle text-default-500",children:utils.formatAmount(e.amount)}),jsxRuntime.jsx("td",{className:"px-3 py-2 text-right align-middle text-foreground",children:utils.formatAmountUSDCompact(e.amountInUsd)}),jsxRuntime.jsx("td",{className:"px-3 py-2 text-right align-middle text-default-400",children:e.avgCostUsd?utils.formatPriceUSD(e.avgCostUsd):"--"}),jsxRuntime.jsx("td",{className:"px-3 py-2 align-middle",children:jsxRuntime.jsx(We,{tags:e.walletTokenTags,max:2})}),jsxRuntime.jsx("td",{className:"px-3 py-2 text-right align-middle text-default-400",children:e.lastActiveAt?de(e.lastActiveAt,t):"--"})]})}function So({chain:e,address:t,limit:o=50}){let[r,n]=react.useState(void 0),[a,i]=react.useState([]);react.useEffect(()=>{i([]),n(void 0);},[e,t]);let{data:s,isPending:l,isFetching:p}=react$1.useWalletPortfoliosQuery({chain:e,address:t,cursor:r,limit:o});react.useEffect(()=>{s&&i(v=>r==null?[s]:v[v.length-1]?.endCursor===s.endCursor?v:[...v,s]);},[s,r]);let c=react.useMemo(()=>a.length===0?void 0:{...a[0],portfolios:a.flatMap(u=>u.portfolios)},[a]),d=a[a.length-1],m=!!(d?.hasNext&&d.endCursor),f=react.useCallback(()=>{!d?.endCursor||!d.hasNext||n(d.endCursor);},[d]);return {data:c,isLoading:l||p,hasMore:m,loadMore:f}}function gp({chain:e,address:t,limit:o,className:r,onRowClick:n}){let{data:a,isLoading:i,hasMore:s,loadMore:l}=So({chain:e,address:t,limit:o});return jsxRuntime.jsx(ho,{data:a,isLoading:i,className:r,hasMore:s,onLoadMore:l,onRowClick:n})}var qn=[{value:"7d",label:"7D"},{value:"30d",label:"30D"},{value:"90d",label:"90D"}],zn=[{value:"open",label:"Open"},{value:"closed",label:"Closed"},{value:"all",label:"All"}],Yn=[{value:"totalPnl",label:"Total"},{value:"realizedPnl",label:"Realized"},{value:"unrealizedPnl",label:"Unrealized"}];function To({data:e,isLoading:t,resolution:o,onResolutionChange:r,positionState:n,onPositionStateChange:a,sortBy:i,onSortByChange:s,hasMore:l,onLoadMore:p,now:c=Date.now(),className:d,onRowClick:m}){return jsxRuntime.jsxs("div",{className:ui.cn("flex flex-col gap-2",d),children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2",children:[jsxRuntime.jsx(wt,{label:"Window",options:qn,value:o,onChange:r}),jsxRuntime.jsx(wt,{label:"Status",options:zn,value:n,onChange:a}),jsxRuntime.jsx(wt,{label:"Sort",options:Yn,value:i,onChange:s})]}),e&&jsxRuntime.jsx(Gn,{data:e}),jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full min-w-[780px] table-fixed text-[12px]",children:[jsxRuntime.jsx("thead",{className:"text-default-400",children:jsxRuntime.jsxs("tr",{className:"border-b border-default-100",children:[jsxRuntime.jsx("th",{className:"w-[22%] px-3 py-2 text-left font-normal",children:"Token"}),jsxRuntime.jsx("th",{className:"w-[13%] px-3 py-2 text-right font-normal",children:"Holding"}),jsxRuntime.jsx("th",{className:"w-[13%] px-3 py-2 text-right font-normal",children:"Total PnL"}),jsxRuntime.jsx("th",{className:"w-[13%] px-3 py-2 text-right font-normal",children:"Realized"}),jsxRuntime.jsx("th",{className:"w-[13%] px-3 py-2 text-right font-normal",children:"Unrealized"}),jsxRuntime.jsx("th",{className:"w-[8%] px-3 py-2 text-right font-normal",children:"State"}),jsxRuntime.jsx("th",{className:"w-[9%] px-3 py-2 text-right font-normal",children:"First buy"}),jsxRuntime.jsx("th",{className:"w-[9%] px-3 py-2 text-right font-normal",children:"Last sell"})]})}),jsxRuntime.jsxs("tbody",{children:[(!e||e.portfolios.length===0)&&!t&&jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:8,className:"py-8 text-center text-default-400",children:"No positions"})}),e?.portfolios.map(f=>jsxRuntime.jsx(jn,{pnl:f,now:c,onRowClick:m},`${f.chain}-${f.address}`)),t&&jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:8,className:"py-4 text-center text-default-400",children:"Loading\u2026"})})]})]})}),l&&jsxRuntime.jsx("div",{className:"flex justify-center px-3 py-2",children:jsxRuntime.jsx("button",{type:"button",onClick:p,disabled:t,className:"rounded bg-default-100 px-3 py-1 text-[11px] text-default-600 transition-colors hover:bg-default-200 disabled:opacity-50",children:"Load more"})})]})}function wt({label:e,options:t,value:o,onChange:r}){return jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] uppercase tracking-wide text-default-400",children:e}),jsxRuntime.jsx("div",{className:"flex items-center gap-1",children:t.map(n=>jsxRuntime.jsx("button",{type:"button",onClick:()=>r(n.value),className:ui.cn("rounded px-2 py-1 text-[11px] transition-colors",o===n.value?"bg-default-100 text-foreground":"text-default-400 hover:text-foreground"),children:n.label},n.value))})]})}function Gn({data:e}){let t=e.totalProfitInUsd,o=e.totalProfitRatio,r=e.winRate;return jsxRuntime.jsxs("div",{className:"mx-3 flex flex-wrap items-center gap-x-6 gap-y-2 rounded border border-default-100 bg-default-50 px-4 py-2 text-xs",children:[jsxRuntime.jsx(Me,{label:"Total PnL",value:t?utils.formatAmountUSDCompact(t,{showPlusGtThanZero:true}):"--",tone:t?Ao(t):void 0}),jsxRuntime.jsx(Me,{label:"Return",value:o?utils.formatPercent(o,{showPlusGtThanZero:true}):"--",tone:o?Ao(o):void 0}),jsxRuntime.jsx(Me,{label:"Win rate",value:r?utils.formatPercent(r):"--"}),jsxRuntime.jsx(Me,{label:"Trades",value:e.totalTrades!=null?e.totalTrades.toString():"--"})]})}function Ao(e){let t=new utils.SafeBigNumber(e);if(t.gt(0))return "bullish";if(t.lt(0))return "bearish"}function Me({label:e,value:t,tone:o}){return jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-[10px] uppercase tracking-wide text-default-400",children:e}),jsxRuntime.jsx("span",{className:ui.cn("text-sm font-medium",o==="bullish"?"text-bullish":o==="bearish"?"text-bearish":"text-foreground"),children:t})]})}function Tt({value:e}){if(!e)return jsxRuntime.jsx("span",{className:"text-default-400",children:"--"});let t=new utils.SafeBigNumber(e),o=t.gt(0)?"text-bullish":t.lt(0)?"text-bearish":"text-default-500";return jsxRuntime.jsx("span",{className:o,children:utils.formatAmountUSDCompact(e,{showPlusGtThanZero:true})})}function jn({pnl:e,now:t,onRowClick:o}){return jsxRuntime.jsxs("tr",{className:ui.cn("border-b border-default-50 hover:bg-default-50/60",o&&"cursor-pointer"),onClick:o?()=>o(e):void 0,children:[jsxRuntime.jsx("td",{className:"px-3 py-2 align-middle",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-0.5",children:[jsxRuntime.jsx("span",{className:"text-foreground",children:e.symbol}),jsxRuntime.jsx("span",{className:"font-mono text-[10px] text-default-400",children:me(e.address,6,6)})]})}),jsxRuntime.jsx("td",{className:"px-3 py-2 text-right align-middle text-foreground",children:utils.formatAmountUSDCompact(e.amountInUsd)}),jsxRuntime.jsx("td",{className:"px-3 py-2 text-right align-middle",children:jsxRuntime.jsx(Tt,{value:e.totalProfitInUsd})}),jsxRuntime.jsx("td",{className:"px-3 py-2 text-right align-middle",children:jsxRuntime.jsx(Tt,{value:e.realizedProfitInUsd})}),jsxRuntime.jsx("td",{className:"px-3 py-2 text-right align-middle",children:jsxRuntime.jsx(Tt,{value:e.unrealizedProfitInUsd})}),jsxRuntime.jsx("td",{className:"px-3 py-2 text-right align-middle text-[10px]",children:jsxRuntime.jsx("span",{className:ui.cn("rounded px-1.5 py-0.5",e.isClosed?"bg-default/20 text-default-500":"bg-bullish/15 text-bullish"),children:e.isClosed?"Closed":"Open"})}),jsxRuntime.jsx("td",{className:"px-3 py-2 text-right align-middle text-default-400",children:e.firstBuyAt?de(e.firstBuyAt,t):"--"}),jsxRuntime.jsx("td",{className:"px-3 py-2 text-right align-middle text-default-400",children:e.lastSellAt?de(e.lastSellAt,t):"--"})]})}function Do({chain:e,address:t,limit:o=50,initialResolution:r="30d",initialPositionState:n="open",initialSortBy:a="totalPnl"}){let[i,s]=react.useState(r),[l,p]=react.useState(n),[c,d]=react.useState(a),[m,f]=react.useState(void 0),[v,u]=react.useState([]),x=react.useCallback(()=>{f(void 0),u([]);},[]),g=react.useCallback(C=>{C!==i&&(s(C),x());},[i,x]),w=react.useCallback(C=>{C!==l&&(p(C),x());},[l,x]),S=react.useCallback(C=>{C!==c&&(d(C),x());},[c,x]);react.useEffect(()=>{x();},[e,t,x]);let B=react.useMemo(()=>({chain:e,address:t,cursor:m,limit:o,resolution:i,positionState:l,sortBy:c}),[e,t,m,o,i,l,c]),{data:O,isPending:E,isFetching:_}=react$1.useWalletPortfolioPnlsQuery(B);react.useEffect(()=>{O&&u(C=>m==null?[O]:C[C.length-1]?.endCursor===O.endCursor?C:[...C,O]);},[O,m]);let W=react.useMemo(()=>v.length===0?void 0:{...v[0],portfolios:v.flatMap(Q=>Q.portfolios)},[v]),I=v[v.length-1],ce=!!(I?.hasNext&&I.endCursor),J=react.useCallback(()=>{!I?.endCursor||!I.hasNext||f(I.endCursor);},[I]);return {data:W,isLoading:E||_,resolution:i,setResolution:g,positionState:l,setPositionState:w,sortBy:c,setSortBy:S,hasMore:ce,loadMore:J}}function Ip({chain:e,address:t,limit:o,initialResolution:r,initialPositionState:n,initialSortBy:a,className:i,onRowClick:s}){let{data:l,isLoading:p,resolution:c,setResolution:d,positionState:m,setPositionState:f,sortBy:v,setSortBy:u,hasMore:x,loadMore:g}=Do({chain:e,address:t,limit:o,initialResolution:r,initialPositionState:n,initialSortBy:a});return jsxRuntime.jsx(To,{data:l,isLoading:p,resolution:c,onResolutionChange:d,positionState:m,onPositionStateChange:f,sortBy:v,onSortByChange:u,hasMore:x,onLoadMore:g,className:i,onRowClick:s})}function Jn({client:e,children:t}){return jsxRuntime.jsx(xe.Provider,{value:e,children:t})}var is=15e3;function as(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}function Uo({chain:e,address:t,enabled:o=true,summaryPollMs:r=is}){let{setSummary:n,setSummaryStatus:a,setRefetchSummary:i}=react.useContext(Re),s=react$1.useWalletPortfoliosQuery({chain:e,address:t},{enabled:o,refetchInterval:r}),l=react$1.useWalletPnlQuery({chain:e,address:t},{enabled:o,refetchInterval:r});react.useEffect(()=>{n(null);},[e,t,n]),react.useEffect(()=>{let c=s.isPending||l.isPending,d=s.isFetching||l.isFetching,m=s.isError||l.isError,f=s.isSuccess&&l.isSuccess;a({status:m?"error":f?"success":"pending",fetchStatus:d?"fetching":"idle",isLoading:c&&d,isPending:c,isFetching:d,isRefetching:f&&d,isError:m,isSuccess:f,error:s.error??l.error,dataUpdatedAt:Math.max(s.dataUpdatedAt,l.dataUpdatedAt)});},[s.isPending,s.isFetching,s.isError,s.isSuccess,s.error,s.dataUpdatedAt,l.isPending,l.isFetching,l.isError,l.isSuccess,l.error,l.dataUpdatedAt,a]),react.useEffect(()=>{let c=s.data,d=l.data;!c||!d||n({...d,balanceInUsd:c.balanceInUsd,balanceInNative:c.balanceInNative});},[s.data,l.data,n]),react$1.useWalletPnlSubscription({chain:e,address:t},c=>{n(d=>{if(!d)return d;let m=d;for(let f of c)m={...m,...as(f)};return m});},{enabled:o});let p=react.useCallback(async()=>{await Promise.all([s.refetch(),l.refetch()]);},[s,l]);react.useEffect(()=>{i(p);},[p,i]);}function ps({chain:e,address:t,children:o}){let[r,n]=react.useState(null),[a,i]=react.useState(cs),s=react.useRef(()=>Promise.resolve()),l=react.useCallback(()=>s.current(),[]),p=react.useCallback(m=>{s.current=m;},[]),c=react.useMemo(()=>({summary:r,summaryStatus:a,refetchSummary:l}),[r,a,l]),d=react.useMemo(()=>({setSummary:n,setSummaryStatus:i,setRefetchSummary:p}),[n,i,p]);return jsxRuntime.jsx(Re.Provider,{value:d,children:jsxRuntime.jsx(ge.Provider,{value:c,children:jsxRuntime.jsx(ds,{chain:e,address:t,children:o})})})}function ds({chain:e,address:t,children:o}){return Uo({chain:e,address:t,enabled:!!t}),jsxRuntime.jsx(jsxRuntime.Fragment,{children:o})}var cs={status:"pending",fetchStatus:"idle",isLoading:false,isPending:true,isFetching:false,isRefetching:false,isError:false,isSuccess:false,error:null,dataUpdatedAt:0};
|
|
2
|
+
exports.AccountInfoUI=Ye;exports.AccountInfoWidget=ir;exports.AddressRowUI=je;exports.AssetTab=he;exports.AssetTabsUI=Je;exports.BalanceRowUI=tt;exports.BatchActionButton=Ne;exports.CURVE_PERIOD_VALUE=Wt;exports.ConfirmDialog=He;exports.CurveCardUI=rt;exports.CurvePeriod=Ze;exports.CurveType=Xe;exports.DistributionCardUI=st;exports.HoldingsEmpty=j;exports.HoldingsSearch=pe;exports.HoldingsSectionWidget=wn;exports.HoldingsSubTabs=le;exports.PerpsPanelUI=Ct;exports.PerpsPositionSide=Lt;exports.PortfolioActivities=mo;exports.PortfolioActivitiesWidget=Jl;exports.PortfolioClientContext=xe;exports.PortfolioClientProvider=Jn;exports.PortfolioContext=ge;exports.PortfolioNetWorthTokens=ho;exports.PortfolioNetWorthTokensWidget=gp;exports.PortfolioPageSkeleton=gt;exports.PortfolioPageWidget=nn;exports.PortfolioPnlDetails=To;exports.PortfolioPnlDetailsWidget=Ip;exports.PortfolioProvider=ps;exports.PredictionBetStatus=Vt;exports.PredictionPanelUI=St;exports.PredictionResult=_t;exports.PredictionSource=Kt;exports.SpotHistoryType=Mt;exports.SpotPanelUI=At;exports.TagBadge=Fn;exports.TagBadgeList=We;exports.ViewingBannerUI=yt;exports.computeDistribution=Ht;exports.curveDataQueryKey=ro;exports.distributionQueryKey=zr;exports.formatAgeShort=de;exports.formatPercent=Rt;exports.formatSignedUsd=Pe;exports.formatTime=Ot;exports.formatTokenBalance=Ge;exports.formatUsd=D;exports.getExplorerUrl=Bt;exports.overviewQueryKey=jt;exports.parseDecimal=Ks;exports.perpsHistoryQueryKey=eo;exports.perpsPositionsQueryKey=Jt;exports.predictionBetsQueryKey=to;exports.predictionSettledQueryKey=oo;exports.splitUsd=It;exports.spotHistoryQueryKey=Zt;exports.spotHoldingsQueryKey=Xt;exports.truncateAddress=ue;exports.truncateMiddle=me;exports.useAccountInfo=ze;exports.useCurveDataQuery=ut;exports.useDistributionQuery=ft;exports.useHoldingsSection=vt;exports.useOverviewQuery=it;exports.usePerpsHistoryQuery=pt;exports.usePerpsPositionsQuery=lt;exports.usePortfolioActivitiesScript=yo;exports.usePortfolioClient=H;exports.usePortfolioContext=ye;exports.usePortfolioNetWorthTokensScript=So;exports.usePortfolioPage=xt;exports.usePortfolioPnlDetailsScript=Do;exports.usePredictionBetsQuery=dt;exports.usePredictionSettledQuery=ct;exports.useRefetchWalletSummary=Yr;exports.useSpotHistoryQuery=at;exports.useSpotHoldingsQuery=ve;exports.useWalletPortfolios=rn;exports.useWalletSummary=$e;//# sourceMappingURL=index.js.map
|
|
3
3
|
//# sourceMappingURL=index.js.map
|