@liberfi.io/ui-predict 4.0.49 → 4.0.51
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 +13 -6
- package/dist/index.d.ts +13 -6
- package/dist/index.js +13 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {createContext,memo,useRef,forwardRef,useState,useImperativeHandle,useMemo,useEffect,useCallback,useContext,Fragment as Fragment$1,startTransition,Component}from'react';import {PolymarketIcon,KalshiIcon,cn as cn$1,Skeleton,toast,StyledModal,ModalContent,useDisclosure,Tabs,Tab,StyledInput,StyledSwitch,Select,SelectItem,StyledNumberInput,ChevronDownIcon,Button,Spinner,useScreen,TimerIcon,DropletIcon,ChartLineIcon,CalendarIcon,Linkable,Avatar,ChevronUpIcon,OrderbookTableIcon,OrderbookDepthIcon,RefreshIcon,Dropdown,DropdownTrigger,DropdownMenu,DropdownItem,ChevronRightIcon,ChevronLeftIcon,EmptyIcon,TrashIcon,Chip,XCloseIcon,Kbd,SearchIcon,ModalHeader,ModalBody}from'@liberfi.io/ui';import {AsyncModal,useAsyncModal}from'@liberfi.io/ui-scaffold';import {useTranslation}from'@liberfi.io/i18n';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useWallets,useAuth,useAuthCallback}from'@liberfi.io/wallet-connector';import {keepPreviousData,useQueryClient,useQueries}from'@tanstack/react-query';import {useInfiniteMatchMarkets,useBalance,useDFlowKYC,usePolymarketSetup,usePredictClient,PolymarketContext,useTickSize,useFeeRate,useRebateConfig,useRealtimeOrderbook,pickBestAsk,walkOrderbook,usePositions,useDFlowQuote,useDFlowSubmit,useOrder,buildSignedV2OrderPayload,buildCtfExchangeDomain,buildOrderMessage,CTF_ORDER_TYPES,buildSignedOrder,buildClobPayload,resolveEventsParams,useInfiniteEvents,useRedeemPosition,pickBestBid,buildPolymarketL2Headers,useAvailableShares,getPolymarketSharesPrecision,useInfiniteOrders,useCancelOrder,useInfiniteTrades,useMarketHistory,useOrderbook,useEvent,useSimilarEvents,candlesticksQueryKey,useInfiniteComments,useSearchEvents}from'@liberfi.io/react-predict';export{PredictClient,PredictContext,PredictProvider,PredictWsClient,createPredictClient,createPredictWsClient,eventStatsQueryKey,fetchMatchMarketsPage,fetchMatchesPage,matchMarketsQueryKey,matchQueryKey,matchesQueryKey,useBalance,useCancelOrder,useCandlesticks,useDFlowKYC,useDFlowQuote,useDFlowSubmit,useEvent,useEventStats,useEvents,useInfiniteEvents,useInfiniteMatchMarkets,useInfiniteMatches,useInfiniteOrders,useInfiniteTrades,useMarket,useMarketHistory,useMarketTrades,useMatch,useOrder,useOrderbook,useOrders,usePositions,usePredictClient,usePriceHistory,useRedeemPosition,useSearchEvents,useSimilarEvents,useTrades}from'@liberfi.io/react-predict';import {ChainNamespace,Chain}from'@liberfi.io/types';import {formatAmountInUsd,SOLANA_TOKENS,formatAmount,debounce}from'@liberfi.io/utils';import Po from'canvas-confetti';import {List,useDynamicRowHeight}from'react-window';import {useInfiniteLoader}from'react-window-infinite-loader';import {useScrollCollapse,useResizeObserver,useCallbackRef}from'@liberfi.io/hooks';import {ResponsiveContainer,LineChart,CartesianGrid,XAxis,YAxis,Tooltip,Line,ReferenceDot}from'recharts';import {useAtom}from'jotai';import {atomWithStorage}from'jotai/utils';var Zl={Weather:["Daily temperature","Snow and rain","Climate change","Natural disasters","Hurricanes"],Companies:["IPOs","Product launches","KPIs","Elon Musk","CEOs","Layoffs"],Crypto:["BTC","15 min","Hourly","ETH","SOL","DOGE","Pre-Market","XRP","BNB","HYPE"],Economics:["Growth","Fed","Inflation","Oil and energy","Employment","Housing","Jobs & Economy","Bankruptcy & Defaults","GDP","Global Central Banks"],Elections:["Primaries","International elections"],Entertainment:["Music","Movies","Music charts","Television","Awards","Video games","Oscars","Rotten Tomatoes"],Financials:["S&P","Nasdaq","Daily","Metals","Treasuries","Oil","EUR/USD","USD/JPY","WTI"],Mentions:["Politicians","Earnings","Entertainment"],Politics:["Trump","Congress","International","SCOTUS & courts","Local","Recurring","Iran","House"],Science:["AI","Energy","Space"],Social:null,Sports:["Soccer","Basketball","Baseball","Football","Hockey","Golf","Tennis","Motorsport","Esports","Boxing","MMA","Rugby","Lacrosse","Mentions","Chess","Cricket","Aussie Rules","Darts"],World:null},bi=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],ko=(()=>{let e=t=>{let r=bi.indexOf(t);return r===-1?bi.length:r};return Object.entries(Zl).map(([t,r])=>({slug:t,label:t,tags:(r??[]).map(o=>({slug:o,label:o}))})).sort((t,r)=>e(t.slug)-e(r.slug))})();function Si({categories:e,selectedCategory:t,selectedTag:r,activeTags:o,onCategorySelect:n,onTagSelect:i,trailing:s,pulsingTab:a="Trending",className:l}){let{t:u}=useTranslation(),d=useCallback(()=>{n(null);},[n]),p=u("predict.categories.trending");return jsxs("div",{className:cn$1("sticky top-0 z-30 flex w-full flex-col justify-between gap-2 px-4 py-2.5 lg:px-4 lg:py-2",l),children:[jsx("style",{children:".cat-primary-row{display:flex;width:100%;flex-direction:column;gap:8px}@media(min-width:1024px){.cat-primary-row{flex-direction:row;align-items:center}}.cat-primary-row>.cat-tabs{min-width:0;overflow-x:auto;overflow-y:hidden;-ms-overflow-style:none;scrollbar-width:none}.cat-primary-row>.cat-tabs::-webkit-scrollbar{display:none}@media(min-width:1024px){.cat-primary-row>.cat-tabs{flex:1 1 0%}}"}),jsxs("div",{className:"cat-primary-row",children:[jsx("div",{className:"cat-tabs hideScrollbar",children:jsxs("div",{className:"flex min-h-9 items-stretch gap-x-3 lg:min-h-10",children:[jsx(yi,{label:p,isSelected:t===null,onPress:d,showPulse:p===a}),jsx(nc,{}),e.map(m=>jsx(yi,{label:m.category,isSelected:t===m.category,onPress:()=>n(m.category),badge:m.badge,showPulse:m.category===a},m.category))]})}),s&&jsx("div",{className:"flex-shrink-0",children:s})]}),t&&o.length>0&&jsx("div",{className:"hideScrollbar overflow-x-auto overflow-y-hidden flex items-center",children:jsxs("div",{className:"flex gap-x-1.5 pl-1 lg:w-full lg:gap-x-2",children:[jsx(ki,{label:u("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>i(null)}),o.map(m=>jsx(ki,{label:m.label,icon:m.icon,isSelected:r===m.label,onPress:()=>i(m.label)},m.label))]})})]})}function yi({label:e,isSelected:t,onPress:r,badge:o,showPulse:n}){return jsxs("button",{type:"button",onClick:r,className:cn$1("relative shrink-0 cursor-pointer whitespace-nowrap border-b px-2.5 py-1.5 text-sm font-medium capitalize transition-colors",t?"border-primary/50 text-primary":"border-transparent text-neutral-500 hover:text-neutral-300"),children:[n?jsxs("span",{className:"flex items-center gap-x-1.5",children:[jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-[rgb(240,68,56)]"}),jsx("span",{children:e})]}):e,o&&jsx("span",{className:"absolute -right-1 top-0 rounded bg-primary px-0.5 py-px text-[0.625rem] font-semibold leading-none text-neutral-950",children:o})]})}function nc(){return jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function ki({label:e,icon:t,isSelected:r,onPress:o}){return jsxs("button",{type:"button",onClick:o,className:cn$1("flex shrink-0 items-center justify-center gap-x-1 min-w-14 rounded-2xl border px-3 py-1.5 text-sm font-medium uppercase transition-colors cursor-pointer",r?"border-primary/40 bg-primary/15 text-primary":"border-border/80 text-neutral-500 hover:bg-primary/10 hover:text-primary"),children:[t&&jsx("span",{className:cn$1("iconify size-4",t)}),e]})}function Gh({count:e=6}){return jsx("div",{className:"flex w-full flex-col gap-2 px-4 py-2.5 lg:px-4 lg:py-2",children:jsx("div",{className:"flex min-h-9 items-center gap-x-3 lg:min-h-10",children:Array.from({length:e}).map((t,r)=>jsx(Skeleton,{className:"h-6 w-16 shrink-0 rounded"},r))})})}function oc(e){return e.map(t=>({category:t.label,tags:t.tags.map(r=>r.label)}))}function ic(e){return e?e.tags.map(t=>({label:t.label,icon:t.icon})):[]}function Ni({onSelect:e,trailing:t,className:r}){let[o,n]=useState(null),[i,s]=useState(null),a=useCallback(m=>{n(m),s(null),e?.({categorySlug:m,tagSlug:null});},[e]),l=useCallback(m=>{s(m),e?.({categorySlug:o,tagSlug:m});},[o,e]),u=oc(ko),d=ko.find(m=>m.slug===o),p=ic(d);return jsx(Si,{categories:u,selectedCategory:o,selectedTag:i,activeTags:p,onCategorySelect:a,onTagSelect:l,trailing:t,className:r})}function Sn(e){return {title:e.title,imageUrl:e.image_url}}function wn(e,t){let r=e.outcomes[0],o=e.outcomes[1];return {question:e.question,yesAsk:t?.yesAsk??r?.best_ask??r?.price,noAsk:t?.noAsk??o?.best_ask??o?.price,yesBid:t?.yesBid??r?.best_bid,noBid:t?.noBid??o?.best_bid,yesSubTitle:r?.label??"Yes",noSubTitle:o?.label??"No"}}var $r=24,So=4,Pn={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},le={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},Nn=le.ALL,nv={[le.ONE_DAY]:Pn.ONE_MINUTE,[le.ONE_WEEK]:Pn.ONE_HOUR,[le.ONE_MONTH]:Pn.ONE_HOUR,[le.ALL]:Pn.ONE_DAY},ov={[le.ONE_DAY]:300,[le.ONE_WEEK]:3600,[le.ONE_MONTH]:10800,[le.ALL]:1440*60},iv={[le.ONE_DAY]:1440*60,[le.ONE_WEEK]:10080*60,[le.ONE_MONTH]:720*60*60,[le.ALL]:null},Cn=1,Mn=1,sv=1,av=1,lv=99,Rr={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},cv=Rr.ONE_WEEK,dv={[Rr.ONE_HOUR]:60,[Rr.SIX_HOURS]:60,[Rr.ONE_DAY]:300,[Rr.ONE_WEEK]:1800,[Rr.MAX]:1800};var Ei=createContext(null);function hr(){let e=useContext(Ei);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var pc=1e4;function mc({pollingInterval:e=pc,enabled:t=true,enableKalshi:r=true,children:o}){let n=useWallets(),i=useMemo(()=>n.find(D=>D.chainNamespace===ChainNamespace.SOLANA&&D.isConnected)?.address,[n]),s=useMemo(()=>n.find(D=>D.chainNamespace===ChainNamespace.EVM&&D.isConnected)?.address,[n]),{data:a,isLoading:l,isFetching:u,error:d}=useBalance({source:"kalshi",user:i??""},{enabled:t&&r&&!!i,refetchInterval:e}),{data:p,isLoading:m}=useDFlowKYC(i,{enabled:t&&r&&!!i,refetchInterval:3e4}),{data:c,isLoading:f}=usePolymarketSetup(s,{enabled:t&&!!s,refetchInterval:3e4}),g=c?.safe_address,v=c?.verified??false,x=c?.wallet_kind??"deposit",b=c?.deposit_wallet_address,w=x==="safe"?c?.safe_address:b,S=x==="safe"?c?.safe_deployed??false:c?.deposit_wallet_deployed??false,{data:h,isLoading:y,isFetching:k,error:P}=useBalance({source:"polymarket",user:s??""},{enabled:t&&v&&!!s,refetchInterval:e}),I=useMemo(()=>({solanaAddress:i,evmAddress:s,polymarketWalletKind:x,polymarketWalletAddress:w,polymarketDepositWalletAddress:b,polymarketWalletDeployed:S,polymarketSafeAddress:g,kalshiUsdcBalance:a?Number(a.balance):null,polymarketUsdcBalance:v&&h?Number(h.balance):null,kalshiKycVerified:p?.verified??false,kalshiKycUrl:p?.kyc_url??null,kalshiKycLoading:m,polymarketSetupVerified:v,polymarketSafeDeployed:c?.safe_deployed??false,polymarketTokenApproved:c?.token_approved??false,polymarketSetupLoading:f,isLoading:l||y,isFetching:u||k,error:d??P??null}),[i,s,x,w,b,S,g,a,h,v,p,m,c,f,l,y,u,k,d,P]);return jsx(Ei.Provider,{value:I,children:o})}var gc={minutes:60,hours:3600,days:86400};function En(e,t,r){let o=Math.floor(Date.now()/1e3);switch(e){case "5m":return o+300;case "1h":return o+3600;case "12h":return o+720*60;case "24h":return o+1440*60;case "eod":{let n=new Date;return n.setUTCHours(23,59,59,0),Math.floor(n.getTime()/1e3)}case "custom":return o+t*gc[r]}}function Tn(e,t){let r=parseFloat(t);return !r||r<=0?e:Math.round(e/r)*r}function he(e,t){let r=Math.pow(10,t);return Math.floor(e*r)/r}function Ti(e){let t=e;return !Number.isFinite(t)||t<=0||t>=1?1:Math.min(1,(1-t)/t)}function Li({source:e,usdcBalance:t,safetyBufferUsd:r=.01,feeRateBps:o=0,pricePerShare:n}){if(t==null||!Number.isFinite(t))return 0;let i=he(Math.max(0,t),2);if(e!=="polymarket")return i;let s=Math.max(0,o)/1e4*Ti(n??NaN),a=i/(1+s)-r;return he(Math.max(0,a),2)}function Ri({usdcAmount:e,pricePerShare:t,feeRateBps:r}){let o=Math.max(0,r)/1e4;return o<=0||!Number.isFinite(e)||e<=0?0:e*o*Ti(t)}function Ln(e,t,r){let o=e.match(/Size\s*\(([\d.]+)\)\s*lower than the minimum:\s*([\d.]+)/i);if(o)return t("predict.trade.polymarket.minOrderSize",{current:o[1],min:o[2]});let n=e.match(/balance:\s*(\d+),\s*sum of active orders:\s*(\d+)/i);if(n){let s=parseInt(n[1],10)/1e6,a=parseInt(n[2],10)/1e6,l=Math.max(0,s-a);return t("predict.trade.polymarket.insufficientBalance",{total:he(s,2).toFixed(2),active:he(a,2).toFixed(2),available:he(l,2).toFixed(2)})}return /not enough balance/i.test(e)?t(r==="sell"?"predict.trade.insufficientShares":"predict.trade.insufficientBalance"):/max accuracy of/i.test(e)?t("predict.trade.polymarket.decimalAccuracy"):/tick size/i.test(e)?t("predict.trade.polymarket.tickSizeError"):/couldn.*fully filled|FOK.*filled or killed/i.test(e)?t("predict.trade.polymarket.fokNotFilled"):e.replace(/order\s+0x[a-f0-9]+\s+is invalid\.\s*/i,"")||e}function Kr(e,t=2){return parseFloat(he(e,t).toFixed(t)).toString()}function vr(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};Po({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{Po({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{Po({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function Oi({market:e,initialOutcome:t="yes",slippageBps:r=100,onInsufficientBalance:o}){let{t:n}=useTranslation(),{status:i}=useAuth(),s=useWallets(),a=usePredictClient(),l=useContext(PolymarketContext),u=useQueryClient(),d=e.source,p=d==="polymarket",m=s.find(L=>L.chainNamespace===ChainNamespace.SOLANA&&L.isConnected),c=s.find(L=>L.chainNamespace===ChainNamespace.EVM&&L.isConnected&&"switchChain"in L),f=i==="authenticated",g=m?.address,v=c?.address,[x,b]=useState(t),[w,S]=useState("market"),[h,y]=useState(NaN),[k,P]=useState(NaN),[I,D]=useState(false),[W,O]=useState(null),[G,j]=useState(false),[Q,re]=useState(false),[te,N]=useState("1h"),[M,U]=useState(30),[X,se]=useState("minutes"),R=useMemo(()=>{if(d!=="polymarket")return;let L=e.provider_meta?.["polymarket.clobTokenIds"];return L?(typeof L=="string"?JSON.parse(L):L)[x==="yes"?0:1]:void 0},[d,e.provider_meta,x]),{data:ke,isLoading:H}=useTickSize(R),Se=ke?.minimum_tick_size?String(ke.minimum_tick_size):"0.01",{data:bt,isLoading:Te}=useFeeRate(R),Fe=bt?.base_fee??0,nt=String(Fe),{data:ve}=useRebateConfig(),Ye=ve?.builder_enabled&&ve.builder_code?ve.builder_code:void 0,Le=null,Qe=false,Pt=null,Nt=false,Ke,ot,Be;try{let L=hr();Le={kalshiUsdcBalance:L.kalshiUsdcBalance,polymarketUsdcBalance:L.polymarketUsdcBalance,isLoading:L.isLoading},Qe=L.kalshiKycVerified,Pt=L.kalshiKycUrl,Nt=L.polymarketSetupVerified,Ke=L.polymarketSafeAddress,ot=L.polymarketWalletKind,Be=L.polymarketWalletAddress;}catch{}let Ve=d==="kalshi"&&!Qe,je=d==="polymarket"&&!Nt,{data:He}=useRealtimeOrderbook({slug:e.slug,source:d,outcome:x},{enabled:e.status==="open"}),Re=useMemo(()=>{let L=pickBestAsk(He,x);if(L!=null&&L>0)return L;let _e=x==="yes"?0:1,Je=e.outcomes[_e];return Je?.best_ask??Je?.price??.5},[He,e.outcomes,x]),A=useCallback(L=>{S(L);},[]),de=useCallback(L=>{b(L),P(NaN);},[]);useEffect(()=>{de(t);},[t,de]),useEffect(()=>{w==="limit"&&isNaN(k)&&P(Math.round(Re*1e4)/1e4);},[w,k,Re]);let ze=useMemo(()=>isNaN(h)||h<=0?0:Re>0?h/Re:0,[h,Re]),we=useMemo(()=>walkOrderbook({orderbook:He,outcome:x,side:"buy",sharesNeeded:ze,slippageBps:r}),[He,x,ze,r]),Ht=useMemo(()=>we.status==="ok"&&we.worstPrice!=null&&we.worstPrice>0?we.worstPrice:Re,[we,Re]),rt=useMemo(()=>isNaN(h)||h<=0?"0":String(Math.round(h*1e6)),[h]),Ur=e.provider_meta?.["dflow.yesMint"]??"",F=e.provider_meta?.["dflow.noMint"]??"",Pe=SOLANA_TOKENS.stablecoins.USDC.address,zt=x==="yes"?Ur:F,Wt=Pe,Ut=zt,$t=d==="kalshi"?g??"":v??"",{data:Xe,isLoading:co}=usePositions({source:d,user:$t},{enabled:!!$t}),uo=d==="kalshi"&&!!Wt&&!!Ut&&!!g&&rt!=="0",{refetch:pn}=useDFlowQuote({inputMint:Wt,outputMint:Ut,amount:rt,userPublicKey:g??"",slippageBps:100},{enabled:uo}),Ct=useMemo(()=>Le?d==="kalshi"?Le.kalshiUsdcBalance:Le.polymarketUsdcBalance:Xe&&Xe.positions.reduce((_e,Je)=>Je.side==="USDC"||Je.side==="collateral"?_e+(Je.current_value??0):_e,0)||null,[Le,Xe,d]),po=Le?Le.isLoading:co,Kt=useMemo(()=>w==="limit"&&p&&!isNaN(k)?k:Re,[w,p,k,Re]),mo=useMemo(()=>Li({source:d,usdcBalance:Ct,feeRateBps:Fe,pricePerShare:Kt}),[d,Ct,Fe,Kt]),Rt=Ct==null?null:mo,mn=useMemo(()=>isNaN(h)||h<=0?0:h,[h]),tr=useMemo(()=>isNaN(h)||h<=0?0:Kt>0?h/Kt*1:0,[h,Kt]),cr=tr-mn,dr=useMemo(()=>d!=="polymarket"||isNaN(h)||h<=0?0:Ri({usdcAmount:h,pricePerShare:Kt,feeRateBps:Fe}),[d,h,Kt,Fe]),Er=useCallback(L=>{if(isNaN(L)){y(NaN);return}y(Math.round(Math.max(0,L)*100)/100);},[]),fo=useCallback(L=>{if(isNaN(L)){P(NaN);return}P(Math.round(L*1e4)/1e4);},[]),ur=useCallback(()=>{y(NaN),P(NaN),S("market"),re(false),N("1h"),U(30),se("minutes");},[]),pr=useMemo(()=>{let L=[];return isNaN(h)||h<=0?L.push(n("predict.trade.minAmountUsd",{amount:Mn})):h<Mn&&L.push(n("predict.trade.minAmountUsd",{amount:Mn})),e.status!=="open"&&L.push(n("predict.trade.marketNotActive")),Rt!=null&&!isNaN(h)&&h>0&&h>Rt&&L.push(n("predict.trade.insufficientBalance")),w==="limit"&&p&&(isNaN(k)||k<.01||k>.99)&&L.push(n("predict.trade.limitPriceRange")),w==="limit"&&p&&Q&&te==="custom"&&(isNaN(M)||M<=0)&&L.push(n("predict.trade.expiration.invalidDate")),d==="polymarket"&&w==="market"&&!isNaN(h)&&h>0&&ze>0&&(we.status==="insufficient_liquidity"?L.push(n("predict.trade.insufficientLiquidity",{available:he(we.totalAvailable,2)})):we.status==="exceeds_slippage"&&L.push(n("predict.trade.priceImpactTooHigh",{impact:(we.priceImpactBps/100).toFixed(2),slippage:(r/100).toFixed(2)}))),{isValid:L.length===0,errors:L}},[h,e.status,Rt,w,p,k,Q,te,M,d,ze,we,r,n]),yt=useMemo(()=>Rt==null||isNaN(h)||h<=0?false:h>Rt,[Rt,h]),fn=useCallback(()=>{o?.(d);},[o,d]),{mutateAsync:gn}=useDFlowSubmit(),{data:mr}=useOrder({id:W??"",source:d},{enabled:!!W});useEffect(()=>{if(!mr||!W)return;let{status:L}=mr;L==="closed"?(O(null),D(false),toast.success(n("predict.trade.submitSuccess")),vr(),ur(),u.invalidateQueries({queryKey:["predict","positions"]})):(L==="failed"||L==="expired")&&(D(false),O(null),toast.error(n("predict.trade.submitError")));},[mr,W,u,ur,n]);let hn=useCallback(async()=>{if(!g||!m)return;if(!Wt||!Ut){toast.error("Missing token mint addresses"),D(false);return}if(!Qe){j(true),D(false);return}let kt=(await pn()).data?.transaction;if(!kt){toast.error(n("predict.trade.submitError")),D(false);return}let fr=Uint8Array.from(atob(kt),St=>St.charCodeAt(0)),rr=await m.signTransaction(fr),dt=await gn({signedTransaction:btoa(String.fromCharCode(...rr)),orderContext:{user_public_key:g,input_mint:Wt,output_mint:Ut,amount:rt,price:String(Re),side:"BUY",outcome:x==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});O(dt.signature);},[g,m,pn,gn,Wt,Ut,rt,Re,x,e.slug,n,Qe]),vn=useCallback(async()=>{if(!c||!l)return;let L=c.chain,_e=L!==Chain.POLYGON;_e&&await c.switchChain(Chain.POLYGON);try{let Je=await c.getEip1193Provider();if(!Je){toast.error(n("predict.trade.submitError")),D(!1);return}let kt=ot==="deposit"&&!!Be,fr=!kt&&!!Ke,rr=kt?Be:Ke,dt={address:c.address,signatureType:kt?3:fr?2:0,signTypedData:async(We,Vt,nr,Tr)=>{let or=[];"name"in We&&or.push({name:"name",type:"string"}),"version"in We&&or.push({name:"version",type:"string"}),"chainId"in We&&or.push({name:"chainId",type:"uint256"}),"verifyingContract"in We&&or.push({name:"verifyingContract",type:"address"}),"salt"in We&&or.push({name:"salt",type:"bytes32"});let ho={EIP712Domain:or,...Vt};return await Je.request({method:"eth_signTypedData_v4",params:[c.address,JSON.stringify({domain:We,types:ho,primaryType:nr,message:Tr})]})}},St=l.credentials??await l.authenticate(dt),xn=x==="yes"?0:1,bn="",C=e.provider_meta?.["polymarket.clobTokenIds"];C&&(bn=(typeof C=="string"?JSON.parse(C):C)[xn]??"");let Ie=e.provider_meta?.["polymarket.negRisk"]??!1,Ze=w==="limit"&&!isNaN(k)?k:Ht,et=Tn(Ze,Se),it=w==="limit"?Q?"GTD":"GTC":"FOK",Mt=w==="market"?h:et>0?h/et:0,st={tokenId:bn,price:et,size:Mt,side:"BUY",orderType:it,tickSize:Se,negRisk:Ie,...rr&&{funderAddress:rr},...Ye&&{builderCode:Ye},...w==="limit"&&Q&&{expiration:En(te,M,X)}},Me;if(kt)Me=await buildSignedV2OrderPayload({signer:dt,depositWalletAddress:rr,input:st,owner:St.apiKey});else {let We=buildCtfExchangeDomain(Ie),Vt=buildOrderMessage({...st,signerAddress:dt.address,signatureType:dt.signatureType,feeRateBps:nt}),nr=await dt.signTypedData(We,CTF_ORDER_TYPES,"Order",Vt),Tr=buildSignedOrder(Vt,nr,st.orderType);Me=buildClobPayload(Tr,St.apiKey);}await a.executePolymarketOrder({payload:Me,l2_api_key:St.apiKey,l2_secret:St.secret,l2_passphrase:St.passphrase,signer_address:St.address,owner:St.apiKey}),u.invalidateQueries({queryKey:["predict","orders"]}),u.invalidateQueries({queryKey:["predict","positions"]}),toast.success(n("predict.trade.submitSuccess")),vr(),ur(),D(!1);}finally{_e&&L&&c.switchChain(L).catch(()=>{});}},[c,l,x,e.provider_meta,w,k,Ht,h,a,u,Q,te,M,X,ur,n,Se,nt,Ke,ot,Be,Ye]),go=useCallback(async()=>{if(!(!pr.isValid||!f)){D(true),O(null),j(false);try{d==="kalshi"?await hn():await vn();}catch(L){let _e=L instanceof Error?L.message:"",Je=d==="polymarket"&&_e?Ln(_e,n,"buy"):_e||void 0;toast.error(Je||n("predict.trade.submitError")),D(false);}}},[pr.isValid,f,d,hn,vn,n]);return {outcome:x,orderType:w,quantity:h,limitPrice:k,shares:ze,estimatedCost:mn,estimatedFee:dr,potentialPayout:tr,potentialProfit:cr,pricePerShare:Re,usdcBalance:Ct,maxBuyAmount:mo,spendableUsdcBalance:Rt,isBalanceLoading:po,isMarketDataLoading:d==="polymarket"&&(Te||H),isSubmitting:I,authStatus:i,validation:pr,isInsufficientBalance:yt,source:d,supportsLimitOrder:p,kycRequired:G,needsKyc:Ve,needsSetup:je,kycUrl:Pt,expirationEnabled:Q,expirationPreset:te,customDuration:M,customDurationUnit:X,setOutcome:de,setOrderType:A,setQuantity:Er,setLimitPrice:fo,setExpirationEnabled:re,setExpirationPreset:N,setCustomDuration:U,setCustomDurationUnit:se,submit:go,notifyInsufficientBalance:fn}}function Rn({isOpen:e,onClose:t,kycUrl:r}){let{t:o}=useTranslation();return jsx(StyledModal,{isOpen:e,onOpenChange:n=>{n||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:o("predict.trade.kycModalTitle")}),jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxs("div",{className:"px-5 pb-5",children:[jsx("p",{className:"text-[13px] text-zinc-400 mb-4 text-left",children:o("predict.trade.kycModalDescription")}),jsx("div",{className:"flex flex-col gap-2 mb-4",children:["predict.trade.kycModalBullet1","predict.trade.kycModalBullet2","predict.trade.kycModalBullet3"].map(n=>jsxs("div",{className:"flex items-center gap-2.5 text-[13px] text-zinc-300",children:[jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#c7ff2e] shrink-0",children:jsx("polyline",{points:"20 6 9 17 4 12"})}),jsx("span",{children:o(n)})]},n))}),r&&jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[13px] text-[#c7ff2e]/70 hover:text-[#c7ff2e] transition-colors mb-3",children:[o("predict.trade.goToKYC")," \u2192"]}),jsx("p",{className:"text-[11px] text-zinc-500 mb-5",children:o("predict.trade.kycModalNote")}),jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:o("common.ok")})]})]})})})}var Jc=["5m","1h","12h","24h","eod","custom"],Zc={"5m":"predict.trade.expiration.5m","1h":"predict.trade.expiration.1h","12h":"predict.trade.expiration.12h","24h":"predict.trade.expiration.24h",eod:"predict.trade.expiration.eod",custom:"predict.trade.expiration.custom"},ed=["minutes","hours","days"],td={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},rd={maximumFractionDigits:0},Ir="-";function $i({event:e,market:t,variant:r="bordered",outcome:o,orderType:n,quantity:i,limitPrice:s,shares:a,potentialProfit:l,potentialPayout:u,estimatedCost:d,estimatedFee:p=0,usdcBalance:m,isBalanceLoading:c,isMarketDataLoading:f,isSubmitting:g,authStatus:v,isValid:x,validationErrors:b,isInsufficientBalance:w,onInsufficientBalance:S,supportsLimitOrder:h,maxBuyAmount:y,kycRequired:k,needsKyc:P,needsSetup:I,kycUrl:D,expirationEnabled:W,expirationPreset:O,customDuration:G,customDurationUnit:j,oddsFormatter:Q,onOutcomeChange:re,onOrderTypeChange:te,onQuantityChange:N,onLimitPriceChange:M,onExpirationEnabledChange:U,onExpirationPresetChange:X,onCustomDurationChange:se,onCustomDurationUnitChange:R,onSubmit:ke}){let{t:H}=useTranslation(),[Se,bt]=useState(true),Te=useDisclosure(),[Fe,nt]=useState(""),ve=useRef(false);useEffect(()=>{ve.current||nt(isNaN(i)?"":String(i));},[i]);let[Ye,Le]=useState(""),Qe=useRef(false);useEffect(()=>{Qe.current||(isNaN(s)?Le(""):Le(String(parseFloat((s*100).toFixed(2)))));},[s]);let Pt=useCallback(F=>{if(F!==""&&!/^\d*\.?\d{0,2}$/.test(F))return;if(Le(F),F===""||F==="."){M(NaN);return}let zt=parseFloat(F);isNaN(zt)||M(zt/100);},[M]),Nt=useCallback(F=>{if(F!==""&&!/^\d*\.?\d{0,2}$/.test(F))return;if(nt(F),rt(false),F===""||F==="."){N(NaN);return}let zt=parseFloat(F);isNaN(zt)||N(zt);},[N]);useEffect(()=>{k&&!Te.isOpen&&Te.onOpen();},[k]);let Ke=useMemo(()=>{let F=o==="yes"?t.yesAsk:t.noAsk;return F!=null?parseFloat((Number(F)*100).toFixed(2)):null},[o,t]),ot=o==="yes"?t.yesAsk:t.noAsk,Be=ot!=null&&Q?Q(Number(ot)):Ke!=null?`${Ke} \xA2`:Ir,Ve=!isNaN(i)&&i>0,je=v==="authenticated",He=v==="authenticating"||v==="deauthenticating",Re=je&&(P||I),A=useMemo(()=>{if(He)return H("predict.trade.checkingLogin");if(!je)return H("predict.trade.loginToTrade");if(P)return H("predict.trade.kycRequired");if(I)return H("predict.trade.setupRequired");if(c)return H("predict.trade.loadingBalance");if(f)return H("predict.trade.loadingMarketData");if(g)return H("predict.trade.submitting");if(k)return H("predict.trade.kycRequired");if(!Ve)return H("predict.trade.enterAmount");let F=H(o==="yes"?"predict.trade.yes":"predict.trade.no"),Pe=l>0?` \u2192 Win $${l.toFixed(2)}`:"";return `${H("predict.trade.buy")} ${F}${Pe}`},[He,je,P,I,c,f,g,k,Ve,o,l,H]),de="primary",ze=()=>{let F=y??he(m??0,2);N(he(F/2,2));},we=()=>{N(y??he(m??0,2));},[Ht,rt]=useState(false),Ur=()=>{if(!je){rt(false),ke();return}if(P){Te.onOpen();return}if(I&&S){rt(false),S();return}if(k){Te.onOpen();return}if(w&&S){rt(false),S();return}if(!x){rt(true);return}rt(false),ke();};return jsxs(Fragment,{children:[jsxs("div",{className:"flex w-full flex-col gap-y-4 p-4",style:r==="bordered"?{borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",transition:"border-color 0.2s"}:void 0,onMouseEnter:F=>{r==="bordered"&&(F.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:F=>{r==="bordered"&&(F.currentTarget.style.borderColor="rgba(39,39,42,0.6)");},children:[e&&jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxs("span",{className:"text-bullish",children:[H("predict.trade.buy")," ",H(o==="yes"?"predict.trade.yes":"predict.trade.no")]}),jsxs("span",{className:"text-foreground",children:[" \xB7 ",t.yesSubTitle]})]})]})]}),jsxs("div",{className:"flex items-center justify-between",children:[h?jsxs(Tabs,{variant:"underlined",selectedKey:n,onSelectionChange:F=>te(F),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsx(Tab,{title:H("predict.trade.market")},"market"),jsx(Tab,{title:H("predict.trade.limit")},"limit")]}):jsx("span",{className:"text-sm font-medium text-foreground",children:H("predict.trade.market")}),n==="limit"&&h?jsx(StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:Ye,onChange:F=>Pt(F.target.value),onFocus:()=>{Qe.current=true;},onBlur:()=>{Qe.current=false,isNaN(s)?Le(""):Le(String(parseFloat((s*100).toFixed(2))));},endContent:jsx("span",{className:"text-xl font-bold tabular-nums text-foreground",children:"\xA2"}),classNames:{base:"w-28",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 rounded-lg px-2 h-9 min-h-9",input:"text-xl font-bold tabular-nums text-right"}}):Be!=null&&jsx("span",{className:"text-xl font-bold tabular-nums",children:Be})]}),jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(F=>{let Pe=F==="yes"?t.yesAsk:t.noAsk;return jsx("div",{className:"flex flex-1 flex-col gap-y-1",children:jsxs("button",{type:"button",onClick:()=>re(F),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${o===F?"border-bullish bg-bullish/10 text-bullish":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsx("span",{children:H(F==="yes"?"predict.trade.yes":"predict.trade.no")}),Pe!=null&&jsx("span",{className:"ml-1 opacity-70",children:Q?Q(Number(Pe)):`${parseFloat((Number(Pe)*100).toFixed(2))}\xA2`})]})},F)})}),jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsx("span",{className:"text-sm font-medium text-foreground",children:H("predict.trade.youArePaying")}),jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("button",{type:"button",onClick:ze,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:H("predict.trade.half")}),jsx("button",{type:"button",onClick:we,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:H("predict.trade.max")})]})]}),jsx(StyledInput,{"aria-label":"Trade amount",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:Fe,onChange:F=>Nt(F.target.value),onFocus:()=>{ve.current=true;},onBlur:()=>{ve.current=false,nt(isNaN(i)?"":String(i));},startContent:jsx("span",{className:"text-default-600 text-xl",children:"$"}),classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}}),Ht&&b.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:b.map(F=>jsx("span",{className:"text-xs text-danger",children:F},F))})]}),jsxs("div",{className:"flex items-center justify-end gap-x-1.5 text-sm",children:[jsx("span",{className:"text-neutral-500",children:H("predict.trade.balance")}),jsx("span",{className:"font-medium text-foreground tabular-nums",children:m!=null?`$${he(m,2).toFixed(2)}`:"$0"})]}),n==="limit"&&h&&jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-medium text-primary",children:H("predict.trade.setExpiration")}),jsx(StyledSwitch,{size:"sm",color:"primary",isSelected:W,onValueChange:U,"aria-label":H("predict.trade.setExpiration")})]}),W&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":H("predict.trade.setExpiration"),selectedKeys:[O],onSelectionChange:F=>{let Pe=Array.from(F)[0];Pe&&X(Pe);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Jc.map(F=>jsx(SelectItem,{children:H(Zc[F])},F))}),O==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(G)?void 0:G,onValueChange:se,minValue:1,step:1,formatOptions:rd,classNames:{base:"flex-1",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 min-h-10",input:"text-sm"}}),jsx(Select,{"aria-label":"Duration unit",selectedKeys:[j],onSelectionChange:F=>{let Pe=Array.from(F)[0];Pe&&R(Pe);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:ed.map(F=>jsx(SelectItem,{children:H(td[F])},F))})]})]})]}),jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxs("div",{className:"flex items-center justify-between text-sm",children:[jsxs("button",{type:"button",onClick:()=>bt(F=>!F),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{children:H("predict.trade.odds")}),jsx(ChevronDownIcon,{className:cn$1("h-3.5 w-3.5 transition-transform",Se&&"rotate-180")})]}),jsx("span",{className:"text-foreground font-medium tabular-nums",children:Q&&ot!=null?Be:Ke!=null?H("predict.trade.chance",{percent:Ke}):Ir})]}),Se&&jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-neutral-500",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:H("predict.trade.totalSize")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${d.toFixed(2)}`:Ir})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:H("predict.trade.numContracts")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(a)&&a>0?Kr(a):Ir})]}),p>0&&jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:H("predict.trade.estFee")}),jsx("span",{className:"tabular-nums text-foreground",children:`$${p.toFixed(2)}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:H("predict.trade.payout")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${u.toFixed(2)}`:Ir})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:H("predict.trade.estProfit")}),jsx("span",{className:"tabular-nums text-bullish",children:!isNaN(i)&&i>0&&l>0?`+$${l.toFixed(2)}`:Ir})]})]})]}),jsx(Button,{color:de,fullWidth:true,radius:"lg",size:"lg",isDisabled:He||je&&!Re&&(c||f||!Ve||g),isLoading:He||je&&!Re&&(g||c||f),spinner:jsx(Spinner,{size:"sm",color:"current"}),onPress:Ur,children:A})]}),jsx(Rn,{isOpen:Te.isOpen,onClose:Te.onClose,kycUrl:D})]})}function In({event:e,market:t,variant:r,initialOutcome:o,chain:n,slippageBps:i,onInsufficientBalance:s,onOutcomeChange:a,oddsFormatter:l}){let{outcome:u,orderType:d,quantity:p,limitPrice:m,shares:c,estimatedCost:f,estimatedFee:g,potentialPayout:v,potentialProfit:x,pricePerShare:b,usdcBalance:w,maxBuyAmount:S,isBalanceLoading:h,isMarketDataLoading:y,isSubmitting:k,authStatus:P,validation:I,isInsufficientBalance:D,supportsLimitOrder:W,kycRequired:O,needsKyc:G,needsSetup:j,kycUrl:Q,expirationEnabled:re,expirationPreset:te,customDuration:N,customDurationUnit:M,setOutcome:U,setOrderType:X,setQuantity:se,setLimitPrice:R,setExpirationEnabled:ke,setExpirationPreset:H,setCustomDuration:Se,setCustomDurationUnit:bt,submit:Te,notifyInsufficientBalance:Fe}=Oi({market:t,initialOutcome:o,slippageBps:i,onInsufficientBalance:s}),nt=useAuthCallback(Te),ve=useCallback(Qe=>{U(Qe),a?.(Qe);},[U,a]),Ye=useMemo(()=>e?Sn(e):void 0,[e]),Le=useMemo(()=>wn(t,{yesAsk:u==="yes"?b:void 0,noAsk:u==="no"?b:void 0}),[t,u,b]);return jsx($i,{event:Ye,market:Le,variant:r,outcome:u,orderType:d,quantity:p,limitPrice:m,shares:c,estimatedCost:f,estimatedFee:g,potentialPayout:v,potentialProfit:x,usdcBalance:w,maxBuyAmount:S,isBalanceLoading:h,isMarketDataLoading:y,isSubmitting:k,authStatus:P,isValid:I.isValid,validationErrors:I.errors,isInsufficientBalance:D,onInsufficientBalance:s?Fe:void 0,supportsLimitOrder:W,kycRequired:O,needsKyc:G,needsSetup:j,kycUrl:Q,expirationEnabled:re,expirationPreset:te,customDuration:N,customDurationUnit:M,oddsFormatter:l,onOutcomeChange:ve,onOrderTypeChange:X,onQuantityChange:se,onLimitPriceChange:R,onExpirationEnabledChange:ke,onExpirationPresetChange:H,onCustomDurationChange:Se,onCustomDurationUnitChange:bt,onSubmit:nt})}var Vr="predict-trade";function On({id:e=Vr}){return jsx(AsyncModal,{id:e,children:t=>jsx(ud,{...t})})}function ud({params:e,isOpen:t,onOpenChange:r}){let{t:o}=useTranslation(),{isMobile:n}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:n?"lg":"md",backdrop:"opaque",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{className:n?"":"p-2",children:[jsx(In,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,chain:e.chain,slippageBps:e.slippageBps,variant:"flat",onInsufficientBalance:e.onInsufficientBalance}),jsx("div",{className:"px-4 pb-4",children:jsx("button",{type:"button",onClick:()=>r(false),className:"w-full h-12 rounded-xl text-sm font-medium text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:o("common.cancel")})})]})})}):null}var jr={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function Mo(e,t=true){let r=0;return t&&e.source&&r++,e.timeRemaining&&r++,e.minVolume&&r++,e.minLiquidity&&r++,r}function Vi({isOpen:e,onClose:t,value:r,onChange:o,enableKalshi:n=true}){let{t:i}=useTranslation(),[s,a]=useState(r),l=useMemo(()=>n?jr:{...jr,source:"polymarket"},[n]),u=useCallback(b=>{b?a(r):t();},[r,t]),d=useCallback(()=>{a(l);},[l]),p=useCallback(()=>{o(s),t();},[s,o,t]),m=useCallback((b,w)=>{a(S=>({...S,[b]:w}));},[]),c=useMemo(()=>Mo(s,n),[s,n]),f=useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"polymarket",label:i("predict.platform.polymarket")},{value:"kalshi",label:i("predict.platform.kalshi")}],[i]),g=useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1d",label:i("predict.filter.lessThanDay")},{value:"7d",label:i("predict.filter.lessThanWeek")},{value:"30d",label:i("predict.filter.lessThanMonth")}],[i]),v=useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[i]),x=useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[i]);return jsx(StyledModal,{isOpen:e,onOpenChange:u,size:"md",backdrop:"opaque",scrollBehavior:"inside",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:i("predict.filter.title")}),jsx(vd,{onClick:()=>u(false)})]}),jsxs("div",{style:{padding:"0 20px 16px",display:"flex",flexDirection:"column",gap:20},children:[n&&jsx(Dn,{label:i("predict.filter.platform"),children:jsx(Fn,{options:f,selected:s.source,onSelect:b=>m("source",b)})}),jsx(Dn,{label:i("predict.filter.timeRemaining"),children:jsx(Fn,{options:g,selected:s.timeRemaining,onSelect:b=>m("timeRemaining",b)})}),jsx(Dn,{label:i("predict.filter.minVolume"),children:jsx(Fn,{options:v,selected:s.minVolume,onSelect:b=>m("minVolume",b)})}),jsx(Dn,{label:i("predict.filter.minLiquidity"),children:jsx(Fn,{options:x,selected:s.minLiquidity,onSelect:b=>m("minLiquidity",b)})})]}),jsxs("div",{className:"flex items-center gap-3 px-5 py-4",style:{borderTop:"1px solid rgba(39,39,42,0.5)"},children:[jsx("button",{type:"button",className:"inline-flex items-center justify-center py-2.5 px-5 rounded-[10px] text-zinc-400 text-sm font-medium hover:text-white transition-colors cursor-pointer",onClick:d,children:i("predict.filter.reset")}),jsxs("button",{type:"button",className:"flex-1 inline-flex items-center justify-center gap-2 py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer",onClick:p,children:[i("predict.filter.showResults"),c>0&&jsxs("span",{style:{opacity:.7},children:["(",c,")"]})]})]})]})})})}function Dn({label:e,children:t}){return jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[jsx("span",{style:{fontSize:11,fontWeight:500,color:"#71717a",textTransform:"uppercase",letterSpacing:"0.05em"},children:e}),t]})}function vd({onClick:e}){return jsx("button",{type:"button",onClick:e,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}function Fn({options:e,selected:t,onSelect:r,allowDeselect:o=true}){return jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:e.map(n=>{let i=t===n.value;return jsx("button",{type:"button",onClick:()=>{r(i&&o?void 0:n.value);},style:{flexShrink:0,borderRadius:10,padding:"6px 14px",fontSize:13,fontWeight:500,cursor:"pointer",transition:"all 0.15s",border:i?"1px solid rgba(199,255,46,0.3)":"1px solid rgba(63,63,70,0.5)",background:i?"rgba(199,255,46,0.08)":"rgba(39,39,42,0.4)",color:i?"#c7ff2e":"#a1a1aa"},onMouseEnter:s=>{i||(s.currentTarget.style.background="rgba(39,39,42,0.8)",s.currentTarget.style.color="#fff");},onMouseLeave:s=>{i||(s.currentTarget.style.background="rgba(39,39,42,0.4)",s.currentTarget.style.color="#a1a1aa");},children:n.label},n.value??"__all")})})}var Qi={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},qi={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},Cd=["start_time","volume","liquidity","ending_soon"],Gi={display:"inline-flex",alignItems:"center",gap:8,borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"8px 12px",fontSize:14,color:"#d4d4d8",cursor:"pointer",transition:"all 0.15s"},Md={position:"absolute",left:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function Xi({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:o,onFilterPress:n,filterCount:i=0,className:s}){let{t:a}=useTranslation(),[l,u]=useState(false),d=useRef(null),p=useCallback(c=>{d.current&&!d.current.contains(c.target)&&u(false);},[]);useEffect(()=>(document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)),[p]),useEffect(()=>{if(!l)return;let c=f=>{f.key==="Escape"&&u(false);};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[l]);let m=Yi[e];return jsxs("div",{className:s,style:{display:"flex",alignItems:"center",gap:8},children:[jsxs("div",{ref:d,style:{position:"relative"},children:[jsxs("button",{type:"button",style:Gi,onMouseEnter:c=>{c.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:c=>{c.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>u(c=>!c),children:[jsx(Ed,{}),jsx(m,{className:"size-4 shrink-0",style:{color:"#a1a1aa"}}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:a(qi[e])}),jsx(Ld,{open:l})]}),l&&jsx("div",{style:{...Md,width:224,padding:4},children:Cd.map(c=>{let f=Yi[c],g=e===c;return jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",gap:12,padding:"10px 12px",textAlign:"left",fontSize:14,border:"none",cursor:"pointer",transition:"all 0.15s",background:g?"rgba(199,255,46,0.08)":"transparent",color:g?"#c7ff2e":"#a1a1aa",borderRadius:10},onMouseEnter:v=>{g||(v.currentTarget.style.background="rgba(39,39,42,0.5)",v.currentTarget.style.color="#fff");},onMouseLeave:v=>{g||(v.currentTarget.style.background="transparent",v.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===c?o(!r):t(c),u(false);},children:[jsx(f,{className:"size-4 shrink-0",style:{color:g?"#c7ff2e":"#71717a"}}),jsx("span",{style:{flex:1,fontWeight:500},children:a(qi[c])}),g&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 6 9 17l-5-5"})})]},c)})})]}),jsx("button",{type:"button",style:{borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",width:36,height:36,color:"#a1a1aa",cursor:"pointer",transition:"all 0.15s",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:14},onMouseEnter:c=>{c.currentTarget.style.background="rgba(39,39,42,1)",c.currentTarget.style.color="#fff";},onMouseLeave:c=>{c.currentTarget.style.background="rgba(39,39,42,0.6)",c.currentTarget.style.color="#a1a1aa";},onClick:()=>o(!r),children:r?"\u2191":"\u2193"}),jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxs("button",{type:"button",style:Gi,onMouseEnter:c=>{c.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:c=>{c.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:n,children:[jsx(Td,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:a("predict.filter.title")})]}),i>0&&jsx("span",{style:{position:"absolute",top:-4,right:-4,minWidth:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,background:"#c7ff2e",color:"#000",fontSize:10,fontWeight:600,padding:"0 4px"},children:i})]})]})}var Yi={start_time:CalendarIcon,volume:ChartLineIcon,liquidity:DropletIcon,ending_soon:TimerIcon};function Ed(){return jsxs("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#a1a1aa"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"m21 16-4 4-4-4"}),jsx("path",{d:"M17 20V4"}),jsx("path",{d:"m3 8 4-4 4 4"}),jsx("path",{d:"M7 4v16"})]})}function Td(){return jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#a1a1aa"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"})})}function Ld({open:e}){return jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#71717a",transition:"transform 0.15s",transform:e?"rotate(180deg)":void 0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"m6 9 6 6 6-6"})})}function es(e={}){let t=useMemo(()=>resolveEventsParams(e),[e.tagSlugSelection,e.limit,e.status,e.sort_by,e.sort_asc,e.source,e.with_markets,e.minVolume,e.minLiquidity,e.timeRemaining,e.markets_limit]),{data:r,isLoading:o,isFetching:n,isFetchingNextPage:i,isError:s,error:a,hasNextPage:l,fetchNextPage:u,refetch:d}=useInfiniteEvents(t),p=useMemo(()=>r?.pages.flatMap(f=>f.items).filter(f=>f!=null)??[],[r]),m=useCallback(()=>{u();},[u]),c=useCallback(()=>{d();},[d]);return {data:p,isLoading:o,isFetching:n&&!i,isFetchingMore:i,isError:s,error:a??null,hasMore:l??false,fetchMore:m,refetch:c}}var ts=`
|
|
1
|
+
import {createContext,memo,useRef,forwardRef,useState,useImperativeHandle,useMemo,useEffect,useCallback,useContext,Fragment as Fragment$1,startTransition,Component}from'react';import {PolymarketIcon,KalshiIcon,cn,Skeleton,toast,StyledModal,ModalContent,useDisclosure,Tabs,Tab,StyledInput,StyledSwitch,Select,SelectItem,StyledNumberInput,ChevronDownIcon,Button,Spinner,useScreen,TimerIcon,DropletIcon,ChartLineIcon,CalendarIcon,Linkable,Avatar,ChevronUpIcon,OrderbookTableIcon,OrderbookDepthIcon,RefreshIcon,Dropdown,DropdownTrigger,DropdownMenu,DropdownItem,ChevronRightIcon,ChevronLeftIcon,EmptyIcon,TrashIcon,Chip,XCloseIcon,Kbd,SearchIcon,ModalHeader,ModalBody}from'@liberfi.io/ui';import {AsyncModal,useAsyncModal}from'@liberfi.io/ui-scaffold';import {useTranslation}from'@liberfi.io/i18n';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useWallets,useAuth,useAuthCallback}from'@liberfi.io/wallet-connector';import {keepPreviousData,useQueryClient,useQueries}from'@tanstack/react-query';import {useInfiniteMatchMarkets,useBalance,useDFlowKYC,usePolymarketSetup,usePredictClient,PolymarketContext,useTickSize,useFeeRate,useRebateConfig,useRealtimeOrderbook,pickBestAsk,walkOrderbook,usePositions,useDFlowQuote,useDFlowSubmit,useOrder,buildSignedV2OrderPayload,buildCtfExchangeDomain,buildOrderMessage,CTF_ORDER_TYPES,buildSignedOrder,buildClobPayload,resolveEventsParams,useInfiniteEvents,useRedeemPosition,pickBestBid,buildPolymarketL2Headers,useAvailableShares,getPolymarketSharesPrecision,useInfiniteOrders,useCancelOrder,useInfiniteTrades,useMarketHistory,useOrderbook,useEvent,useSimilarEvents,candlesticksQueryKey,useInfiniteComments,useSearchEvents}from'@liberfi.io/react-predict';export{PredictClient,PredictContext,PredictProvider,PredictWsClient,createPredictClient,createPredictWsClient,eventStatsQueryKey,fetchMatchMarketsPage,fetchMatchesPage,matchMarketsQueryKey,matchQueryKey,matchesQueryKey,useBalance,useCancelOrder,useCandlesticks,useDFlowKYC,useDFlowQuote,useDFlowSubmit,useEvent,useEventStats,useEvents,useInfiniteEvents,useInfiniteMatchMarkets,useInfiniteMatches,useInfiniteOrders,useInfiniteTrades,useMarket,useMarketHistory,useMarketTrades,useMatch,useOrder,useOrderbook,useOrders,usePositions,usePredictClient,usePriceHistory,useRedeemPosition,useSearchEvents,useSimilarEvents,useTrades}from'@liberfi.io/react-predict';import {ChainNamespace,Chain}from'@liberfi.io/types';import {formatAmountInUsd,SOLANA_TOKENS,formatAmount,debounce}from'@liberfi.io/utils';import Po from'canvas-confetti';import {List,useDynamicRowHeight}from'react-window';import {useInfiniteLoader}from'react-window-infinite-loader';import {useScrollCollapse,useResizeObserver,useCallbackRef}from'@liberfi.io/hooks';import {ResponsiveContainer,LineChart,CartesianGrid,XAxis,YAxis,Tooltip,Line,ReferenceDot}from'recharts';import {useAtom}from'jotai';import {atomWithStorage}from'jotai/utils';var tc={Weather:["Daily temperature","Snow and rain","Climate change","Natural disasters","Hurricanes"],Companies:["IPOs","Product launches","KPIs","Elon Musk","CEOs","Layoffs"],Crypto:["BTC","15 min","Hourly","ETH","SOL","DOGE","Pre-Market","XRP","BNB","HYPE"],Economics:["Growth","Fed","Inflation","Oil and energy","Employment","Housing","Jobs & Economy","Bankruptcy & Defaults","GDP","Global Central Banks"],Elections:["Primaries","International elections"],Entertainment:["Music","Movies","Music charts","Television","Awards","Video games","Oscars","Rotten Tomatoes"],Financials:["S&P","Nasdaq","Daily","Metals","Treasuries","Oil","EUR/USD","USD/JPY","WTI"],Mentions:["Politicians","Earnings","Entertainment"],Politics:["Trump","Congress","International","SCOTUS & courts","Local","Recurring","Iran","House"],Science:["AI","Energy","Space"],Social:null,Sports:["Soccer","Basketball","Baseball","Football","Hockey","Golf","Tennis","Motorsport","Esports","Boxing","MMA","Rugby","Lacrosse","Mentions","Chess","Cricket","Aussie Rules","Darts"],World:null},yi=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],ko=(()=>{let e=t=>{let r=yi.indexOf(t);return r===-1?yi.length:r};return Object.entries(tc).map(([t,r])=>({slug:t,label:t,tags:(r??[]).map(o=>({slug:o,label:o}))})).sort((t,r)=>e(t.slug)-e(r.slug))})();function wi({categories:e,selectedCategory:t,selectedTag:r,activeTags:o,onCategorySelect:n,onTagSelect:i,trailing:s,pulsingTab:a="Trending",className:l}){let{t:u}=useTranslation(),d=useCallback(()=>{n(null);},[n]),p=u("predict.categories.trending");return jsxs("div",{className:cn("sticky top-0 z-30 flex w-full flex-col justify-between gap-2 px-4 py-2.5 lg:px-4 lg:py-2",l),children:[jsx("style",{children:".cat-primary-row{display:flex;width:100%;flex-direction:column;gap:8px}@media(min-width:1024px){.cat-primary-row{flex-direction:row;align-items:center}}.cat-primary-row>.cat-tabs{min-width:0;overflow-x:auto;overflow-y:hidden;-ms-overflow-style:none;scrollbar-width:none}.cat-primary-row>.cat-tabs::-webkit-scrollbar{display:none}@media(min-width:1024px){.cat-primary-row>.cat-tabs{flex:1 1 0%}}"}),jsxs("div",{className:"cat-primary-row",children:[jsx("div",{className:"cat-tabs hideScrollbar",children:jsxs("div",{className:"flex min-h-9 items-stretch gap-x-3 lg:min-h-10",children:[jsx(ki,{label:p,isSelected:t===null,onPress:d,showPulse:p===a}),jsx(ic,{}),e.map(m=>jsx(ki,{label:m.category,isSelected:t===m.category,onPress:()=>n(m.category),badge:m.badge,showPulse:m.category===a},m.category))]})}),s&&jsx("div",{className:"flex-shrink-0",children:s})]}),t&&o.length>0&&jsx("div",{className:"hideScrollbar overflow-x-auto overflow-y-hidden flex items-center",children:jsxs("div",{className:"flex gap-x-1.5 pl-1 lg:w-full lg:gap-x-2",children:[jsx(Si,{label:u("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>i(null)}),o.map(m=>jsx(Si,{label:m.label,icon:m.icon,isSelected:r===m.label,onPress:()=>i(m.label)},m.label))]})})]})}function ki({label:e,isSelected:t,onPress:r,badge:o,showPulse:n}){return jsxs("button",{type:"button",onClick:r,className:cn("relative shrink-0 cursor-pointer whitespace-nowrap border-b px-2.5 py-1.5 text-sm font-medium capitalize transition-colors",t?"border-primary/50 text-primary":"border-transparent text-neutral-500 hover:text-neutral-300"),children:[n?jsxs("span",{className:"flex items-center gap-x-1.5",children:[jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-[rgb(240,68,56)]"}),jsx("span",{children:e})]}):e,o&&jsx("span",{className:"absolute -right-1 top-0 rounded bg-primary px-0.5 py-px text-[0.625rem] font-semibold leading-none text-neutral-950",children:o})]})}function ic(){return jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function Si({label:e,icon:t,isSelected:r,onPress:o}){return jsxs("button",{type:"button",onClick:o,className:cn("flex shrink-0 items-center justify-center gap-x-1 min-w-14 rounded-2xl border px-3 py-1.5 text-sm font-medium uppercase transition-colors cursor-pointer",r?"border-primary/40 bg-primary/15 text-primary":"border-border/80 text-neutral-500 hover:bg-primary/10 hover:text-primary"),children:[t&&jsx("span",{className:cn("iconify size-4",t)}),e]})}function Jh({count:e=6}){return jsx("div",{className:"flex w-full flex-col gap-2 px-4 py-2.5 lg:px-4 lg:py-2",children:jsx("div",{className:"flex min-h-9 items-center gap-x-3 lg:min-h-10",children:Array.from({length:e}).map((t,r)=>jsx(Skeleton,{className:"h-6 w-16 shrink-0 rounded"},r))})})}function sc(e){return e.map(t=>({category:t.label,tags:t.tags.map(r=>r.label)}))}function ac(e){return e?e.tags.map(t=>({label:t.label,icon:t.icon})):[]}function Ci({onSelect:e,trailing:t,className:r}){let[o,n]=useState(null),[i,s]=useState(null),a=useCallback(m=>{n(m),s(null),e?.({categorySlug:m,tagSlug:null});},[e]),l=useCallback(m=>{s(m),e?.({categorySlug:o,tagSlug:m});},[o,e]),u=sc(ko),d=ko.find(m=>m.slug===o),p=ac(d);return jsx(wi,{categories:u,selectedCategory:o,selectedTag:i,activeTags:p,onCategorySelect:a,onTagSelect:l,trailing:t,className:r})}function Sn(e){return {title:e.title,imageUrl:e.image_url}}function wn(e,t){let r=e.outcomes[0],o=e.outcomes[1];return {question:e.question,yesAsk:t?.yesAsk??r?.best_ask??r?.price,noAsk:t?.noAsk??o?.best_ask??o?.price,yesBid:t?.yesBid??r?.best_bid,noBid:t?.noBid??o?.best_bid,yesSubTitle:r?.label??"Yes",noSubTitle:o?.label??"No"}}var qr=24,So=4,Pn={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},le={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},Nn=le.ALL,av={[le.ONE_DAY]:Pn.ONE_MINUTE,[le.ONE_WEEK]:Pn.ONE_HOUR,[le.ONE_MONTH]:Pn.ONE_HOUR,[le.ALL]:Pn.ONE_DAY},lv={[le.ONE_DAY]:300,[le.ONE_WEEK]:3600,[le.ONE_MONTH]:10800,[le.ALL]:1440*60},cv={[le.ONE_DAY]:1440*60,[le.ONE_WEEK]:10080*60,[le.ONE_MONTH]:720*60*60,[le.ALL]:null},Cn=1,Mn=1,dv=1,uv=1,pv=99,Rr={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},mv=Rr.ONE_WEEK,fv={[Rr.ONE_HOUR]:60,[Rr.SIX_HOURS]:60,[Rr.ONE_DAY]:300,[Rr.ONE_WEEK]:1800,[Rr.MAX]:1800};var Ti=createContext(null);function pr(){let e=useContext(Ti);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var fc=1e4;function gc({pollingInterval:e=fc,enabled:t=true,enableKalshi:r=true,children:o}){let n=useWallets(),i=useMemo(()=>n.find(F=>F.chainNamespace===ChainNamespace.SOLANA&&F.isConnected)?.address,[n]),s=useMemo(()=>n.find(F=>F.chainNamespace===ChainNamespace.EVM&&F.isConnected)?.address,[n]),{data:a,isLoading:l,isFetching:u,error:d}=useBalance({source:"kalshi",user:i??""},{enabled:t&&r&&!!i,refetchInterval:e}),{data:p,isLoading:m}=useDFlowKYC(i,{enabled:t&&r&&!!i,refetchInterval:3e4}),{data:c,isLoading:f}=usePolymarketSetup(s,{enabled:t&&!!s,refetchInterval:3e4}),g=c?.safe_address,v=c?.verified??false,x=c?.wallet_kind??"deposit",b=c?.deposit_wallet_address,w=x==="safe"?c?.safe_address:b,S=x==="safe"?c?.safe_deployed??false:c?.deposit_wallet_deployed??false,{data:h,isLoading:y,isFetching:k,error:P}=useBalance({source:"polymarket",user:s??""},{enabled:t&&v&&!!s,refetchInterval:e}),O=useMemo(()=>({solanaAddress:i,evmAddress:s,polymarketWalletKind:x,polymarketWalletAddress:w,polymarketDepositWalletAddress:b,polymarketWalletDeployed:S,polymarketSafeAddress:g,kalshiUsdcBalance:a?Number(a.balance):null,polymarketUsdcBalance:v&&h?Number(h.balance):null,kalshiKycVerified:p?.verified??false,kalshiKycUrl:p?.kyc_url??null,kalshiKycLoading:m,polymarketSetupVerified:v,polymarketSafeDeployed:c?.safe_deployed??false,polymarketTokenApproved:c?.token_approved??false,polymarketSetupLoading:f,isLoading:l||y,isFetching:u||k,error:d??P??null}),[i,s,x,w,b,S,g,a,h,v,p,m,c,f,l,y,u,k,d,P]);return jsx(Ti.Provider,{value:O,children:o})}var vc={minutes:60,hours:3600,days:86400};function En(e,t,r){let o=Math.floor(Date.now()/1e3);switch(e){case "5m":return o+300;case "1h":return o+3600;case "12h":return o+720*60;case "24h":return o+1440*60;case "eod":{let n=new Date;return n.setUTCHours(23,59,59,0),Math.floor(n.getTime()/1e3)}case "custom":return o+t*vc[r]}}function Tn(e,t){let r=parseFloat(t);return !r||r<=0?e:Math.round(e/r)*r}function ve(e,t){let r=Math.pow(10,t);return Math.floor(e*r)/r}function Li(e){let t=e;return !Number.isFinite(t)||t<=0||t>=1?1:1-t}var xc=300;function bc(e,t){let r=e?.[t],o=typeof r=="number"?r:Number(r);return Number.isFinite(o)?o:void 0}function yc(e,t){let r=e?.[t];return typeof r=="string"?r:void 0}function Ri(e){let t=bc(e,"polymarket.effectiveTakerFeeBps");if(t!==void 0&&t>=0)return t;let r=e?.["polymarket.feeDescriptor"],o=typeof r?.r=="number"?r.r:Number(r?.r);return Number.isFinite(o)&&o>=0?o*1e4:yc(e,"polymarket.sportsMarketType")?xc:0}function _i({source:e,usdcBalance:t,safetyBufferUsd:r=.01,feeRateBps:o=0,pricePerShare:n}){if(t==null||!Number.isFinite(t))return 0;let i=ve(Math.max(0,t),2);if(e!=="polymarket")return i;let s=Math.max(0,o)/1e4*Li(n??NaN),a=i/(1+s)-r;return ve(Math.max(0,a),2)}function Ii({usdcAmount:e,pricePerShare:t,feeRateBps:r}){let o=Math.max(0,r)/1e4;return o<=0||!Number.isFinite(e)||e<=0?0:e*o*Li(t)}function Ln(e,t,r){let o=e.match(/Size\s*\(([\d.]+)\)\s*lower than the minimum:\s*([\d.]+)/i);if(o)return t("predict.trade.polymarket.minOrderSize",{current:o[1],min:o[2]});let n=e.match(/balance:\s*(\d+),\s*sum of active orders:\s*(\d+)/i);if(n){let s=parseInt(n[1],10)/1e6,a=parseInt(n[2],10)/1e6,l=Math.max(0,s-a);return t("predict.trade.polymarket.insufficientBalance",{total:ve(s,2).toFixed(2),active:ve(a,2).toFixed(2),available:ve(l,2).toFixed(2)})}return /not enough balance/i.test(e)?t(r==="sell"?"predict.trade.insufficientShares":"predict.trade.insufficientBalance"):/max accuracy of/i.test(e)?t("predict.trade.polymarket.decimalAccuracy"):/tick size/i.test(e)?t("predict.trade.polymarket.tickSizeError"):/couldn.*fully filled|FOK.*filled or killed/i.test(e)?t("predict.trade.polymarket.fokNotFilled"):e.replace(/order\s+0x[a-f0-9]+\s+is invalid\.\s*/i,"")||e}function Gr(e,t=2){return parseFloat(ve(e,t).toFixed(t)).toString()}function mr(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};Po({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{Po({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{Po({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function Di({market:e,initialOutcome:t="yes",slippageBps:r=100,onInsufficientBalance:o}){let{t:n}=useTranslation(),{status:i}=useAuth(),s=useWallets(),a=usePredictClient(),l=useContext(PolymarketContext),u=useQueryClient(),d=e.source,p=d==="polymarket",m=s.find(L=>L.chainNamespace===ChainNamespace.SOLANA&&L.isConnected),c=s.find(L=>L.chainNamespace===ChainNamespace.EVM&&L.isConnected&&"switchChain"in L),f=i==="authenticated",g=m?.address,v=c?.address,[x,b]=useState(t),[w,S]=useState("market"),[h,y]=useState(NaN),[k,P]=useState(NaN),[O,F]=useState(false),[W,A]=useState(null),[G,q]=useState(false),[Y,re]=useState(false),[te,N]=useState("1h"),[C,U]=useState(30),[X,se]=useState("minutes"),_=useMemo(()=>{if(d!=="polymarket")return;let L=e.provider_meta?.["polymarket.clobTokenIds"];return L?(typeof L=="string"?JSON.parse(L):L)[x==="yes"?0:1]:void 0},[d,e.provider_meta,x]),{data:Se,isLoading:B}=useTickSize(_),Pe=Se?.minimum_tick_size?String(Se.minimum_tick_size):"0.01",{data:yt,isLoading:Le}=useFeeRate(_),rt=yt?.base_fee??0,nt=String(rt),he=useMemo(()=>Ri(e.provider_meta),[e.provider_meta]),{data:je}=useRebateConfig(),Qe=je?.builder_enabled&&je.builder_code?je.builder_code:void 0,Re=null,dt=false,Nt=null,Xe=false,Je,Be,we;try{let L=pr();Re={kalshiUsdcBalance:L.kalshiUsdcBalance,polymarketUsdcBalance:L.polymarketUsdcBalance,isLoading:L.isLoading},dt=L.kalshiKycVerified,Nt=L.kalshiKycUrl,Xe=L.polymarketSetupVerified,Je=L.polymarketSafeAddress,Be=L.polymarketWalletKind,we=L.polymarketWalletAddress;}catch{}let ut=d==="kalshi"&&!dt,Ze=d==="polymarket"&&!Xe,{data:_t}=useRealtimeOrderbook({slug:e.slug,source:d,outcome:x},{enabled:e.status==="open"}),E=useMemo(()=>{let L=pickBestAsk(_t,x);if(L!=null&&L>0)return L;let We=x==="yes"?0:1,Ue=e.outcomes[We];return Ue?.best_ask??Ue?.price??.5},[_t,e.outcomes,x]),de=useCallback(L=>{S(L);},[]),He=useCallback(L=>{b(L),P(NaN);},[]);useEffect(()=>{He(t);},[t,He]),useEffect(()=>{w==="limit"&&isNaN(k)&&P(Math.round(E*1e4)/1e4);},[w,k,E]);let qe=useMemo(()=>isNaN(h)||h<=0?0:E>0?h/E:0,[h,E]),ze=useMemo(()=>walkOrderbook({orderbook:_t,outcome:x,side:"buy",sharesNeeded:qe,slippageBps:r}),[_t,x,qe,r]),Zt=useMemo(()=>ze.status==="ok"&&ze.worstPrice!=null&&ze.worstPrice>0?ze.worstPrice:E,[ze,E]),er=useMemo(()=>isNaN(h)||h<=0?"0":String(Math.round(h*1e6)),[h]),Wr=e.provider_meta?.["dflow.yesMint"]??"",ot=e.provider_meta?.["dflow.noMint"]??"",Ur=SOLANA_TOKENS.stablecoins.USDC.address,D=x==="yes"?Wr:ot,xe=Ur,Ae=D,et=d==="kalshi"?g??"":v??"",{data:$r,isLoading:co}=usePositions({source:d,user:et},{enabled:!!et}),uo=d==="kalshi"&&!!xe&&!!Ae&&!!g&&er!=="0",{refetch:Wt}=useDFlowQuote({inputMint:xe,outputMint:Ae,amount:er,userPublicKey:g??"",slippageBps:100},{enabled:uo}),Nr=useMemo(()=>Re?d==="kalshi"?Re.kalshiUsdcBalance:Re.polymarketUsdcBalance:$r&&$r.positions.reduce((We,Ue)=>Ue.side==="USDC"||Ue.side==="collateral"?We+(Ue.current_value??0):We,0)||null,[Re,$r,d]),po=Re?Re.isLoading:co,tr=useMemo(()=>w==="limit"&&p&&!isNaN(k)?k:E,[w,p,k,E]),Kr=useMemo(()=>_i({source:d,usdcBalance:Nr,feeRateBps:he,pricePerShare:tr}),[d,Nr,he,tr]),Ut=Nr==null?null:Kr,rr=useMemo(()=>isNaN(h)||h<=0?0:h,[h]),nr=useMemo(()=>isNaN(h)||h<=0?0:tr>0?h/tr*1:0,[h,tr]),or=useMemo(()=>d!=="polymarket"||isNaN(h)||h<=0?0:Ii({usdcAmount:h,pricePerShare:tr,feeRateBps:he}),[d,h,tr,he]),Cr=nr-rr-or,mo=useCallback(L=>{if(isNaN(L)){y(NaN);return}y(Math.round(Math.max(0,L)*100)/100);},[]),hn=useCallback(L=>{if(isNaN(L)){P(NaN);return}P(Math.round(L*1e4)/1e4);},[]),ir=useCallback(()=>{y(NaN),P(NaN),S("market"),re(false),N("1h"),U(30),se("minutes");},[]),it=useMemo(()=>{let L=[];return isNaN(h)||h<=0?L.push(n("predict.trade.minAmountUsd",{amount:Mn})):h<Mn&&L.push(n("predict.trade.minAmountUsd",{amount:Mn})),e.status!=="open"&&L.push(n("predict.trade.marketNotActive")),Ut!=null&&!isNaN(h)&&h>0&&h>Ut&&L.push(n("predict.trade.insufficientBalance")),w==="limit"&&p&&(isNaN(k)||k<.01||k>.99)&&L.push(n("predict.trade.limitPriceRange")),w==="limit"&&p&&Y&&te==="custom"&&(isNaN(C)||C<=0)&&L.push(n("predict.trade.expiration.invalidDate")),d==="polymarket"&&w==="market"&&!isNaN(h)&&h>0&&qe>0&&(ze.status==="insufficient_liquidity"?L.push(n("predict.trade.insufficientLiquidity",{available:ve(ze.totalAvailable,2)})):ze.status==="exceeds_slippage"&&L.push(n("predict.trade.priceImpactTooHigh",{impact:(ze.priceImpactBps/100).toFixed(2),slippage:(r/100).toFixed(2)}))),{isValid:L.length===0,errors:L}},[h,e.status,Ut,w,p,k,Y,te,C,d,qe,ze,r,n]),vn=useMemo(()=>Ut==null||isNaN(h)||h<=0?false:h>Ut,[Ut,h]),fo=useCallback(()=>{o?.(d);},[o,d]),{mutateAsync:Mr}=useDFlowSubmit(),{data:Vr}=useOrder({id:W??"",source:d},{enabled:!!W});useEffect(()=>{if(!Vr||!W)return;let{status:L}=Vr;L==="closed"?(A(null),F(false),toast.success(n("predict.trade.submitSuccess")),mr(),ir(),u.invalidateQueries({queryKey:["predict","positions"]})):(L==="failed"||L==="expired")&&(F(false),A(null),toast.error(n("predict.trade.submitError")));},[Vr,W,u,ir,n]);let xn=useCallback(async()=>{if(!g||!m)return;if(!xe||!Ae){toast.error("Missing token mint addresses"),F(false);return}if(!dt){q(true),F(false);return}let Ct=(await Wt()).data?.transaction;if(!Ct){toast.error(n("predict.trade.submitError")),F(false);return}let Er=Uint8Array.from(atob(Ct),kt=>kt.charCodeAt(0)),Mt=await m.signTransaction(Er),It=await Mr({signedTransaction:btoa(String.fromCharCode(...Mt)),orderContext:{user_public_key:g,input_mint:xe,output_mint:Ae,amount:er,price:String(E),side:"BUY",outcome:x==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});A(It.signature);},[g,m,Wt,Mr,xe,Ae,er,E,x,e.slug,n,dt]),bn=useCallback(async()=>{if(!c||!l)return;let L=c.chain,We=L!==Chain.POLYGON;We&&await c.switchChain(Chain.POLYGON);try{let Ue=await c.getEip1193Provider();if(!Ue){toast.error(n("predict.trade.submitError")),F(!1);return}let Ct=Be==="deposit"&&!!we,Er=!Ct&&!!Je,Mt=Ct?we:Je,It={address:c.address,signatureType:Ct?3:Er?2:0,signTypedData:async(at,$t,Tr,jr)=>{let sr=[];"name"in at&&sr.push({name:"name",type:"string"}),"version"in at&&sr.push({name:"version",type:"string"}),"chainId"in at&&sr.push({name:"chainId",type:"uint256"}),"verifyingContract"in at&&sr.push({name:"verifyingContract",type:"address"}),"salt"in at&&sr.push({name:"salt",type:"bytes32"});let bi={EIP712Domain:sr,...$t};return await Ue.request({method:"eth_signTypedData_v4",params:[c.address,JSON.stringify({domain:at,types:bi,primaryType:Tr,message:jr})]})}},kt=l.credentials??await l.authenticate(It),ho=x==="yes"?0:1,M="",Ne=e.provider_meta?.["polymarket.clobTokenIds"];Ne&&(M=(typeof Ne=="string"?JSON.parse(Ne):Ne)[ho]??"");let $e=e.provider_meta?.["polymarket.negRisk"]??!1,st=w==="limit"&&!isNaN(k)?k:Zt,Ge=Tn(st,Pe),Et=w==="limit"?Y?"GTD":"GTC":"FOK",St=w==="market"?h:Ge>0?h/Ge:0,Ee={tokenId:M,price:Ge,size:St,side:"BUY",orderType:Et,tickSize:Pe,negRisk:$e,...Mt&&{funderAddress:Mt},...Qe&&{builderCode:Qe},...w==="limit"&&Y&&{expiration:En(te,C,X)}},wt;if(Ct)wt=await buildSignedV2OrderPayload({signer:It,depositWalletAddress:Mt,input:Ee,owner:kt.apiKey});else {let at=buildCtfExchangeDomain($e),$t=buildOrderMessage({...Ee,signerAddress:It.address,signatureType:It.signatureType,feeRateBps:nt}),Tr=await It.signTypedData(at,CTF_ORDER_TYPES,"Order",$t),jr=buildSignedOrder($t,Tr,Ee.orderType);wt=buildClobPayload(jr,kt.apiKey);}await a.executePolymarketOrder({payload:wt,l2_api_key:kt.apiKey,l2_secret:kt.secret,l2_passphrase:kt.passphrase,signer_address:kt.address,owner:kt.apiKey}),u.invalidateQueries({queryKey:["predict","orders"]}),u.invalidateQueries({queryKey:["predict","positions"]}),toast.success(n("predict.trade.submitSuccess")),mr(),ir(),F(!1);}finally{We&&L&&c.switchChain(L).catch(()=>{});}},[c,l,x,e.provider_meta,w,k,Zt,h,a,u,Y,te,C,X,ir,n,Pe,nt,Je,Be,we,Qe]),go=useCallback(async()=>{if(!(!it.isValid||!f)){F(true),A(null),q(false);try{d==="kalshi"?await xn():await bn();}catch(L){let We=L instanceof Error?L.message:"",Ue=d==="polymarket"&&We?Ln(We,n,"buy"):We||void 0;toast.error(Ue||n("predict.trade.submitError")),F(false);}}},[it.isValid,f,d,xn,bn,n]);return {outcome:x,orderType:w,quantity:h,limitPrice:k,shares:qe,estimatedCost:rr,estimatedFee:or,potentialPayout:nr,potentialProfit:Cr,pricePerShare:E,usdcBalance:Nr,maxBuyAmount:Kr,spendableUsdcBalance:Ut,isBalanceLoading:po,isMarketDataLoading:d==="polymarket"&&(Le||B),isSubmitting:O,authStatus:i,validation:it,isInsufficientBalance:vn,source:d,supportsLimitOrder:p,kycRequired:G,needsKyc:ut,needsSetup:Ze,kycUrl:Nt,expirationEnabled:Y,expirationPreset:te,customDuration:C,customDurationUnit:X,setOutcome:He,setOrderType:de,setQuantity:mo,setLimitPrice:hn,setExpirationEnabled:re,setExpirationPreset:N,setCustomDuration:U,setCustomDurationUnit:se,submit:go,notifyInsufficientBalance:fo}}function Rn({isOpen:e,onClose:t,kycUrl:r}){let{t:o}=useTranslation();return jsx(StyledModal,{isOpen:e,onOpenChange:n=>{n||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:o("predict.trade.kycModalTitle")}),jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxs("div",{className:"px-5 pb-5",children:[jsx("p",{className:"text-[13px] text-zinc-400 mb-4 text-left",children:o("predict.trade.kycModalDescription")}),jsx("div",{className:"flex flex-col gap-2 mb-4",children:["predict.trade.kycModalBullet1","predict.trade.kycModalBullet2","predict.trade.kycModalBullet3"].map(n=>jsxs("div",{className:"flex items-center gap-2.5 text-[13px] text-zinc-300",children:[jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#c7ff2e] shrink-0",children:jsx("polyline",{points:"20 6 9 17 4 12"})}),jsx("span",{children:o(n)})]},n))}),r&&jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[13px] text-[#c7ff2e]/70 hover:text-[#c7ff2e] transition-colors mb-3",children:[o("predict.trade.goToKYC")," \u2192"]}),jsx("p",{className:"text-[11px] text-zinc-500 mb-5",children:o("predict.trade.kycModalNote")}),jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:o("common.ok")})]})]})})})}var nd=["5m","1h","12h","24h","eod","custom"],od={"5m":"predict.trade.expiration.5m","1h":"predict.trade.expiration.1h","12h":"predict.trade.expiration.12h","24h":"predict.trade.expiration.24h",eod:"predict.trade.expiration.eod",custom:"predict.trade.expiration.custom"},id=["minutes","hours","days"],sd={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},ad={maximumFractionDigits:0},gr="-";function Vi({event:e,market:t,variant:r="bordered",outcome:o,orderType:n,quantity:i,limitPrice:s,shares:a,potentialProfit:l,potentialPayout:u,estimatedCost:d,estimatedFee:p=0,usdcBalance:m,isBalanceLoading:c,isMarketDataLoading:f,isSubmitting:g,authStatus:v,isValid:x,validationErrors:b,isInsufficientBalance:w,onInsufficientBalance:S,supportsLimitOrder:h,maxBuyAmount:y,kycRequired:k,needsKyc:P,needsSetup:O,kycUrl:F,expirationEnabled:W,expirationPreset:A,customDuration:G,customDurationUnit:q,oddsFormatter:Y,onOutcomeChange:re,onOrderTypeChange:te,onQuantityChange:N,onLimitPriceChange:C,onExpirationEnabledChange:U,onExpirationPresetChange:X,onCustomDurationChange:se,onCustomDurationUnitChange:_,onSubmit:Se}){let{t:B}=useTranslation(),[Pe,yt]=useState(true),Le=useDisclosure(),[rt,nt]=useState(""),he=useRef(false);useEffect(()=>{he.current||nt(isNaN(i)?"":String(i));},[i]);let[je,Qe]=useState(""),Re=useRef(false);useEffect(()=>{Re.current||(isNaN(s)?Qe(""):Qe(String(parseFloat((s*100).toFixed(2)))));},[s]);let dt=useCallback(D=>{if(D!==""&&!/^\d*\.?\d{0,2}$/.test(D))return;if(Qe(D),D===""||D==="."){C(NaN);return}let Ae=parseFloat(D);isNaN(Ae)||C(Ae/100);},[C]),Nt=useCallback(D=>{if(D!==""&&!/^\d*\.?\d{0,2}$/.test(D))return;if(nt(D),ot(false),D===""||D==="."){N(NaN);return}let Ae=parseFloat(D);isNaN(Ae)||N(Ae);},[N]);useEffect(()=>{k&&!Le.isOpen&&Le.onOpen();},[k]);let Xe=useMemo(()=>{let D=o==="yes"?t.yesAsk:t.noAsk;return D!=null?parseFloat((Number(D)*100).toFixed(2)):null},[o,t]),Je=o==="yes"?t.yesAsk:t.noAsk,Be=Je!=null&&Y?Y(Number(Je)):Xe!=null?`${Xe} \xA2`:gr,we=!isNaN(i)&&i>0,ut=we?d+p:0,Ze=we&&a>0?ut/a:0,_t=Ze>0&&Y?Y(Ze):Ze>0?`${parseFloat((Ze*100).toFixed(2))}\xA2`:gr,E=v==="authenticated",de=v==="authenticating"||v==="deauthenticating",He=E&&(P||O),qe=useMemo(()=>{if(de)return B("predict.trade.checkingLogin");if(!E)return B("predict.trade.loginToTrade");if(P)return B("predict.trade.kycRequired");if(O)return B("predict.trade.setupRequired");if(c)return B("predict.trade.loadingBalance");if(f)return B("predict.trade.loadingMarketData");if(g)return B("predict.trade.submitting");if(k)return B("predict.trade.kycRequired");if(!we)return B("predict.trade.enterAmount");let D=B(o==="yes"?"predict.trade.yes":"predict.trade.no"),xe=l>0?` \u2192 Win $${l.toFixed(2)}`:"";return `${B("predict.trade.buy")} ${D}${xe}`},[de,E,P,O,c,f,g,k,we,o,l,B]),ze="primary",Zt=()=>{let D=y??ve(m??0,2);N(ve(D/2,2));},er=()=>{N(y??ve(m??0,2));},[Wr,ot]=useState(false),Ur=()=>{if(!E){ot(false),Se();return}if(P){Le.onOpen();return}if(O&&S){ot(false),S();return}if(k){Le.onOpen();return}if(w&&S){ot(false),S();return}if(!x){ot(true);return}ot(false),Se();};return jsxs(Fragment,{children:[jsxs("div",{className:"flex w-full flex-col gap-y-4 p-4",style:r==="bordered"?{borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",transition:"border-color 0.2s"}:void 0,onMouseEnter:D=>{r==="bordered"&&(D.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:D=>{r==="bordered"&&(D.currentTarget.style.borderColor="rgba(39,39,42,0.6)");},children:[e&&jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxs("span",{className:"text-bullish",children:[B("predict.trade.buy")," ",B(o==="yes"?"predict.trade.yes":"predict.trade.no")]}),jsxs("span",{className:"text-foreground",children:[" \xB7 ",t.yesSubTitle]})]})]})]}),jsxs("div",{className:"flex items-center justify-between",children:[h?jsxs(Tabs,{variant:"underlined",selectedKey:n,onSelectionChange:D=>te(D),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsx(Tab,{title:B("predict.trade.market")},"market"),jsx(Tab,{title:B("predict.trade.limit")},"limit")]}):jsx("span",{className:"text-sm font-medium text-foreground",children:B("predict.trade.market")}),n==="limit"&&h?jsx(StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:je,onChange:D=>dt(D.target.value),onFocus:()=>{Re.current=true;},onBlur:()=>{Re.current=false,isNaN(s)?Qe(""):Qe(String(parseFloat((s*100).toFixed(2))));},endContent:jsx("span",{className:"text-xl font-bold tabular-nums text-foreground",children:"\xA2"}),classNames:{base:"w-28",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 rounded-lg px-2 h-9 min-h-9",input:"text-xl font-bold tabular-nums text-right"}}):Be!=null&&jsx("span",{className:"text-xl font-bold tabular-nums",children:Be})]}),jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(D=>{let xe=D==="yes"?t.yesAsk:t.noAsk;return jsx("div",{className:"flex flex-1 flex-col gap-y-1",children:jsxs("button",{type:"button",onClick:()=>re(D),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${o===D?"border-bullish bg-bullish/10 text-bullish":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsx("span",{children:B(D==="yes"?"predict.trade.yes":"predict.trade.no")}),xe!=null&&jsx("span",{className:"ml-1 opacity-70",children:Y?Y(Number(xe)):`${parseFloat((Number(xe)*100).toFixed(2))}\xA2`})]})},D)})}),jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsx("span",{className:"text-sm font-medium text-foreground",children:B("predict.trade.youArePaying")}),jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("button",{type:"button",onClick:Zt,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:B("predict.trade.half")}),jsx("button",{type:"button",onClick:er,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:B("predict.trade.max")})]})]}),jsx(StyledInput,{"aria-label":"Trade amount",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:rt,onChange:D=>Nt(D.target.value),onFocus:()=>{he.current=true;},onBlur:()=>{he.current=false,nt(isNaN(i)?"":String(i));},startContent:jsx("span",{className:"text-default-600 text-xl",children:"$"}),classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}}),Wr&&b.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:b.map(D=>jsx("span",{className:"text-xs text-danger",children:D},D))})]}),jsxs("div",{className:"flex items-center justify-end gap-x-1.5 text-sm",children:[jsx("span",{className:"text-neutral-500",children:B("predict.trade.balance")}),jsx("span",{className:"font-medium text-foreground tabular-nums",children:m!=null?`$${ve(m,2).toFixed(2)}`:"$0"})]}),n==="limit"&&h&&jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-medium text-primary",children:B("predict.trade.setExpiration")}),jsx(StyledSwitch,{size:"sm",color:"primary",isSelected:W,onValueChange:U,"aria-label":B("predict.trade.setExpiration")})]}),W&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":B("predict.trade.setExpiration"),selectedKeys:[A],onSelectionChange:D=>{let xe=Array.from(D)[0];xe&&X(xe);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:nd.map(D=>jsx(SelectItem,{children:B(od[D])},D))}),A==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(G)?void 0:G,onValueChange:se,minValue:1,step:1,formatOptions:ad,classNames:{base:"flex-1",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 min-h-10",input:"text-sm"}}),jsx(Select,{"aria-label":"Duration unit",selectedKeys:[q],onSelectionChange:D=>{let xe=Array.from(D)[0];xe&&_(xe);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:id.map(D=>jsx(SelectItem,{children:B(sd[D])},D))})]})]})]}),jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxs("div",{className:"flex items-center justify-between text-sm",children:[jsxs("button",{type:"button",onClick:()=>yt(D=>!D),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{children:B("predict.trade.odds")}),jsx(ChevronDownIcon,{className:cn("h-3.5 w-3.5 transition-transform",Pe&&"rotate-180")})]}),jsx("span",{className:"text-foreground font-medium tabular-nums",children:Y&&Je!=null?Be:Xe!=null?B("predict.trade.chance",{percent:Xe}):gr})]}),Pe&&jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-neutral-500",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:B("predict.trade.totalSize")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${d.toFixed(2)}`:gr})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:B("predict.trade.numContracts")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(a)&&a>0?Gr(a):gr})]}),p>0&&jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:B("predict.trade.estFee")}),jsx("span",{className:"tabular-nums text-foreground",children:`$${p.toFixed(2)}`})]}),p>0&&jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:B("predict.trade.totalPayment")}),jsx("span",{className:"tabular-nums text-foreground",children:`$${ut.toFixed(2)}`})]}),p>0&&jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:B("predict.trade.effectiveOdds")}),jsx("span",{className:"tabular-nums text-foreground",children:_t})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:B("predict.trade.payout")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${u.toFixed(2)}`:gr})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:B("predict.trade.estProfit")}),jsx("span",{className:"tabular-nums text-bullish",children:!isNaN(i)&&i>0&&l>0?`+$${l.toFixed(2)}`:gr})]})]})]}),jsx(Button,{color:ze,fullWidth:true,radius:"lg",size:"lg",isDisabled:de||E&&!He&&(c||f||!we||g),isLoading:de||E&&!He&&(g||c||f),spinner:jsx(Spinner,{size:"sm",color:"current"}),onPress:Ur,children:qe})]}),jsx(Rn,{isOpen:Le.isOpen,onClose:Le.onClose,kycUrl:F})]})}function In({event:e,market:t,variant:r,initialOutcome:o,chain:n,slippageBps:i,onInsufficientBalance:s,onOutcomeChange:a,oddsFormatter:l}){let{outcome:u,orderType:d,quantity:p,limitPrice:m,shares:c,estimatedCost:f,estimatedFee:g,potentialPayout:v,potentialProfit:x,pricePerShare:b,usdcBalance:w,maxBuyAmount:S,isBalanceLoading:h,isMarketDataLoading:y,isSubmitting:k,authStatus:P,validation:O,isInsufficientBalance:F,supportsLimitOrder:W,kycRequired:A,needsKyc:G,needsSetup:q,kycUrl:Y,expirationEnabled:re,expirationPreset:te,customDuration:N,customDurationUnit:C,setOutcome:U,setOrderType:X,setQuantity:se,setLimitPrice:_,setExpirationEnabled:Se,setExpirationPreset:B,setCustomDuration:Pe,setCustomDurationUnit:yt,submit:Le,notifyInsufficientBalance:rt}=Di({market:t,initialOutcome:o,slippageBps:i,onInsufficientBalance:s}),nt=useAuthCallback(Le),he=useCallback(Re=>{U(Re),a?.(Re);},[U,a]),je=useMemo(()=>e?Sn(e):void 0,[e]),Qe=useMemo(()=>wn(t,{yesAsk:u==="yes"?b:void 0,noAsk:u==="no"?b:void 0}),[t,u,b]);return jsx(Vi,{event:je,market:Qe,variant:r,outcome:u,orderType:d,quantity:p,limitPrice:m,shares:c,estimatedCost:f,estimatedFee:g,potentialPayout:v,potentialProfit:x,usdcBalance:w,maxBuyAmount:S,isBalanceLoading:h,isMarketDataLoading:y,isSubmitting:k,authStatus:P,isValid:O.isValid,validationErrors:O.errors,isInsufficientBalance:F,onInsufficientBalance:s?rt:void 0,supportsLimitOrder:W,kycRequired:A,needsKyc:G,needsSetup:q,kycUrl:Y,expirationEnabled:re,expirationPreset:te,customDuration:N,customDurationUnit:C,oddsFormatter:l,onOutcomeChange:he,onOrderTypeChange:X,onQuantityChange:se,onLimitPriceChange:_,onExpirationEnabledChange:Se,onExpirationPresetChange:B,onCustomDurationChange:Pe,onCustomDurationUnitChange:yt,onSubmit:nt})}var Yr="predict-trade";function On({id:e=Yr}){return jsx(AsyncModal,{id:e,children:t=>jsx(hd,{...t})})}function hd({params:e,isOpen:t,onOpenChange:r}){let{t:o}=useTranslation(),{isMobile:n}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:n?"lg":"md",backdrop:"opaque",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{className:n?"":"p-2",children:[jsx(In,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,chain:e.chain,slippageBps:e.slippageBps,variant:"flat",onInsufficientBalance:e.onInsufficientBalance}),jsx("div",{className:"px-4 pb-4",children:jsx("button",{type:"button",onClick:()=>r(false),className:"w-full h-12 rounded-xl text-sm font-medium text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:o("common.cancel")})})]})})}):null}var Qr={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function Mo(e,t=true){let r=0;return t&&e.source&&r++,e.timeRemaining&&r++,e.minVolume&&r++,e.minLiquidity&&r++,r}function qi({isOpen:e,onClose:t,value:r,onChange:o,enableKalshi:n=true}){let{t:i}=useTranslation(),[s,a]=useState(r),l=useMemo(()=>n?Qr:{...Qr,source:"polymarket"},[n]),u=useCallback(b=>{b?a(r):t();},[r,t]),d=useCallback(()=>{a(l);},[l]),p=useCallback(()=>{o(s),t();},[s,o,t]),m=useCallback((b,w)=>{a(S=>({...S,[b]:w}));},[]),c=useMemo(()=>Mo(s,n),[s,n]),f=useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"polymarket",label:i("predict.platform.polymarket")},{value:"kalshi",label:i("predict.platform.kalshi")}],[i]),g=useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1d",label:i("predict.filter.lessThanDay")},{value:"7d",label:i("predict.filter.lessThanWeek")},{value:"30d",label:i("predict.filter.lessThanMonth")}],[i]),v=useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[i]),x=useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[i]);return jsx(StyledModal,{isOpen:e,onOpenChange:u,size:"md",backdrop:"opaque",scrollBehavior:"inside",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:i("predict.filter.title")}),jsx(Sd,{onClick:()=>u(false)})]}),jsxs("div",{style:{padding:"0 20px 16px",display:"flex",flexDirection:"column",gap:20},children:[n&&jsx(Dn,{label:i("predict.filter.platform"),children:jsx(Fn,{options:f,selected:s.source,onSelect:b=>m("source",b)})}),jsx(Dn,{label:i("predict.filter.timeRemaining"),children:jsx(Fn,{options:g,selected:s.timeRemaining,onSelect:b=>m("timeRemaining",b)})}),jsx(Dn,{label:i("predict.filter.minVolume"),children:jsx(Fn,{options:v,selected:s.minVolume,onSelect:b=>m("minVolume",b)})}),jsx(Dn,{label:i("predict.filter.minLiquidity"),children:jsx(Fn,{options:x,selected:s.minLiquidity,onSelect:b=>m("minLiquidity",b)})})]}),jsxs("div",{className:"flex items-center gap-3 px-5 py-4",style:{borderTop:"1px solid rgba(39,39,42,0.5)"},children:[jsx("button",{type:"button",className:"inline-flex items-center justify-center py-2.5 px-5 rounded-[10px] text-zinc-400 text-sm font-medium hover:text-white transition-colors cursor-pointer",onClick:d,children:i("predict.filter.reset")}),jsxs("button",{type:"button",className:"flex-1 inline-flex items-center justify-center gap-2 py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer",onClick:p,children:[i("predict.filter.showResults"),c>0&&jsxs("span",{style:{opacity:.7},children:["(",c,")"]})]})]})]})})})}function Dn({label:e,children:t}){return jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[jsx("span",{style:{fontSize:11,fontWeight:500,color:"#71717a",textTransform:"uppercase",letterSpacing:"0.05em"},children:e}),t]})}function Sd({onClick:e}){return jsx("button",{type:"button",onClick:e,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}function Fn({options:e,selected:t,onSelect:r,allowDeselect:o=true}){return jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:e.map(n=>{let i=t===n.value;return jsx("button",{type:"button",onClick:()=>{r(i&&o?void 0:n.value);},style:{flexShrink:0,borderRadius:10,padding:"6px 14px",fontSize:13,fontWeight:500,cursor:"pointer",transition:"all 0.15s",border:i?"1px solid rgba(199,255,46,0.3)":"1px solid rgba(63,63,70,0.5)",background:i?"rgba(199,255,46,0.08)":"rgba(39,39,42,0.4)",color:i?"#c7ff2e":"#a1a1aa"},onMouseEnter:s=>{i||(s.currentTarget.style.background="rgba(39,39,42,0.8)",s.currentTarget.style.color="#fff");},onMouseLeave:s=>{i||(s.currentTarget.style.background="rgba(39,39,42,0.4)",s.currentTarget.style.color="#a1a1aa");},children:n.label},n.value??"__all")})})}var Ji={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},Yi={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},Rd=["start_time","volume","liquidity","ending_soon"],Qi={display:"inline-flex",alignItems:"center",gap:8,borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"8px 12px",fontSize:14,color:"#d4d4d8",cursor:"pointer",transition:"all 0.15s"},_d={position:"absolute",left:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function Zi({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:o,onFilterPress:n,filterCount:i=0,className:s}){let{t:a}=useTranslation(),[l,u]=useState(false),d=useRef(null),p=useCallback(c=>{d.current&&!d.current.contains(c.target)&&u(false);},[]);useEffect(()=>(document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)),[p]),useEffect(()=>{if(!l)return;let c=f=>{f.key==="Escape"&&u(false);};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[l]);let m=Xi[e];return jsxs("div",{className:s,style:{display:"flex",alignItems:"center",gap:8},children:[jsxs("div",{ref:d,style:{position:"relative"},children:[jsxs("button",{type:"button",style:Qi,onMouseEnter:c=>{c.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:c=>{c.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>u(c=>!c),children:[jsx(Id,{}),jsx(m,{className:"size-4 shrink-0",style:{color:"#a1a1aa"}}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:a(Yi[e])}),jsx(Ad,{open:l})]}),l&&jsx("div",{style:{..._d,width:224,padding:4},children:Rd.map(c=>{let f=Xi[c],g=e===c;return jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",gap:12,padding:"10px 12px",textAlign:"left",fontSize:14,border:"none",cursor:"pointer",transition:"all 0.15s",background:g?"rgba(199,255,46,0.08)":"transparent",color:g?"#c7ff2e":"#a1a1aa",borderRadius:10},onMouseEnter:v=>{g||(v.currentTarget.style.background="rgba(39,39,42,0.5)",v.currentTarget.style.color="#fff");},onMouseLeave:v=>{g||(v.currentTarget.style.background="transparent",v.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===c?o(!r):t(c),u(false);},children:[jsx(f,{className:"size-4 shrink-0",style:{color:g?"#c7ff2e":"#71717a"}}),jsx("span",{style:{flex:1,fontWeight:500},children:a(Yi[c])}),g&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 6 9 17l-5-5"})})]},c)})})]}),jsx("button",{type:"button",style:{borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",width:36,height:36,color:"#a1a1aa",cursor:"pointer",transition:"all 0.15s",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:14},onMouseEnter:c=>{c.currentTarget.style.background="rgba(39,39,42,1)",c.currentTarget.style.color="#fff";},onMouseLeave:c=>{c.currentTarget.style.background="rgba(39,39,42,0.6)",c.currentTarget.style.color="#a1a1aa";},onClick:()=>o(!r),children:r?"\u2191":"\u2193"}),jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxs("button",{type:"button",style:Qi,onMouseEnter:c=>{c.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:c=>{c.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:n,children:[jsx(Od,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:a("predict.filter.title")})]}),i>0&&jsx("span",{style:{position:"absolute",top:-4,right:-4,minWidth:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,background:"#c7ff2e",color:"#000",fontSize:10,fontWeight:600,padding:"0 4px"},children:i})]})]})}var Xi={start_time:CalendarIcon,volume:ChartLineIcon,liquidity:DropletIcon,ending_soon:TimerIcon};function Id(){return jsxs("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#a1a1aa"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"m21 16-4 4-4-4"}),jsx("path",{d:"M17 20V4"}),jsx("path",{d:"m3 8 4-4 4 4"}),jsx("path",{d:"M7 4v16"})]})}function Od(){return jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#a1a1aa"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"})})}function Ad({open:e}){return jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#71717a",transition:"transform 0.15s",transform:e?"rotate(180deg)":void 0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"m6 9 6 6 6-6"})})}function rs(e={}){let t=useMemo(()=>resolveEventsParams(e),[e.tagSlugSelection,e.limit,e.status,e.sort_by,e.sort_asc,e.source,e.with_markets,e.minVolume,e.minLiquidity,e.timeRemaining,e.markets_limit]),{data:r,isLoading:o,isFetching:n,isFetchingNextPage:i,isError:s,error:a,hasNextPage:l,fetchNextPage:u,refetch:d}=useInfiniteEvents(t),p=useMemo(()=>r?.pages.flatMap(f=>f.items).filter(f=>f!=null)??[],[r]),m=useCallback(()=>{u();},[u]),c=useCallback(()=>{d();},[d]);return {data:p,isLoading:o,isFetching:n&&!i,isFetchingMore:i,isError:s,error:a??null,hasMore:l??false,fetchMore:m,refetch:c}}var ns=`
|
|
2
2
|
@keyframes evtShimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}
|
|
3
3
|
@media(max-width:1279px){.evt-skel-grid{grid-template-columns:repeat(3,1fr)!important}}
|
|
4
4
|
@media(max-width:1023px){.evt-skel-grid{grid-template-columns:repeat(2,1fr)!important}.evt-skel-card{min-height:200px!important}}
|
|
5
5
|
@media(max-width:767px){.evt-skel-grid{grid-template-columns:1fr!important}}
|
|
6
|
-
`,
|
|
6
|
+
`,os={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:"evtShimmer 1.8s ease-in-out infinite",borderRadius:6};function Bn(e){return {...os,animationDelay:`${e}ms`}}function Eo({count:e=6}){return jsxs(Fragment,{children:[jsx("style",{children:ns}),jsx("div",{className:"evt-skel-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",width:"100%"},children:Array.from({length:e}).map((t,r)=>jsx(Bd,{index:r},r))})]})}function Bd({index:e}){let t=e*120,r={...os,animationDelay:`${t}ms`},o=e%3===0?"85%":e%3===1?"70%":"60%";return jsx("div",{style:{padding:8},children:jsxs("div",{className:"evt-skel-card",style:{display:"flex",flexDirection:"column",minHeight:248,borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 14px 8px"},children:[jsx("div",{style:{...r,width:36,height:36,borderRadius:10,flexShrink:0}}),jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6},children:[jsx("div",{style:{...r,height:12,width:o}}),jsx("div",{style:{...r,height:10,width:"40%"}})]})]}),jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,padding:"4px 14px 14px",flex:1},children:[0,1,2].map(n=>jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[jsx("div",{style:{...r,height:11,width:n===0?"55%":n===1?"45%":"35%"}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsx("div",{style:{...r,height:11,width:32}}),jsx("div",{style:{...r,height:28,width:80,borderRadius:8}})]})]},n))}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.15)",padding:"8px 14px"},children:[jsx("div",{style:{...r,height:10,width:56}}),jsx("div",{style:{...r,height:10,width:72}})]})]})})}function Hd(){return jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px"},children:[jsx("div",{style:{display:"flex",alignItems:"center",gap:10,minHeight:40,flex:1},children:[48,64,48,56,72,56].map((e,t)=>jsx("div",{style:{...Bn(t*50),height:28,width:e,borderRadius:6}},t))}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[jsx("div",{style:{...Bn(0),height:36,width:120,borderRadius:10}}),jsx("div",{style:{...Bn(50),height:36,width:36,borderRadius:10}}),jsx("div",{style:{...Bn(100),height:36,width:80,borderRadius:10}})]})]})}function Sx({count:e=24}){return jsxs("div",{style:{minHeight:"100vh",position:"relative",width:"100%",maxWidth:1680,margin:"0 auto"},children:[jsx("style",{children:ns}),jsx("div",{style:{position:"sticky",top:0,zIndex:40,background:"rgba(10,10,11,0.8)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:jsx(Hd,{})}),jsx("div",{style:{padding:"12px 8px 80px"},children:jsx(Eo,{count:e})})]})}var is=3,Yd={polymarket:{border:"rgba(80,162,255,0.4)",shadow:"0 2px 18px rgba(80,162,255,0.45)"},kalshi:{border:"rgba(0,212,146,0.4)",shadow:"0 2px 18px rgba(0,212,146,0.45)"}},Qd={border:"hsl(var(--heroui-primary) / 0.4)",shadow:"0 2px 18px hsl(var(--heroui-primary) / 0.45)"},Lo={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},ds={bg:"hsl(var(--heroui-secondary) / 0.14)",text:"hsl(var(--heroui-secondary))",shadow:"hsl(var(--heroui-secondary) / 0.18)"},Xd={bg:"rgba(239, 68, 68, 0.14)",text:"rgb(239, 68, 68)",shadow:"rgba(239, 68, 68, 0.18)"},Xr=[{bg:"rgba(139,92,246,0.14)",text:"rgb(139,92,246)",shadow:"rgba(139,92,246,0.18)"},{bg:"rgba(34,197,94,0.14)",text:"rgb(34,197,94)",shadow:"rgba(34,197,94,0.18)"},{bg:"rgba(0,166,212,0.14)",text:"rgb(0,166,212)",shadow:"rgba(0,166,212,0.18)"},{bg:"rgba(194,120,32,0.14)",text:"rgb(194,120,32)",shadow:"rgba(194,120,32,0.18)"},{bg:"rgba(202,138,4,0.14)",text:"rgb(202,138,4)",shadow:"rgba(202,138,4,0.18)"},{bg:"rgba(236,72,153,0.14)",text:"rgb(236,72,153)",shadow:"rgba(236,72,153,0.18)"},{bg:"rgba(99,102,241,0.14)",text:"rgb(99,102,241)",shadow:"rgba(99,102,241,0.18)"},{bg:"rgba(244,114,82,0.14)",text:"rgb(244,114,82)",shadow:"rgba(244,114,82,0.18)"}];function ss(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r)|0;return Math.abs(t)}function Jd(e){let t=e.outcomes?.map(s=>s.label?.toLowerCase().trim()??"")??[];if(t.some(s=>s==="up")&&t.some(s=>s==="down"))return [Lo,Xd];if(t.some(s=>s==="yes")&&t.some(s=>s==="no"))return [Lo,ds];let r=t[0]??"",o=t[1]??"",n=ss(r)%Xr.length,i=ss(o)%Xr.length;return i===n&&(i=(i+1)%Xr.length),[Xr[n],Xr[i]]}function Zd(e){let t=e.outcomes?.[0];return t?t.best_ask??t.price??null:null}function us(e){let t=Zd(e);return t!=null?parseFloat((t*100).toFixed(2)):0}function ps(e){return e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function as(e){let t=e.outcomes?.[0],r=t?.best_ask??t?.price??0;return parseFloat((r*100).toFixed(2)).toString()}function ls(e){let t=e.outcomes?.[1];if(t){let n=t.best_ask??t.price??0;return parseFloat((n*100).toFixed(2)).toString()}let r=e.outcomes?.[0],o=r?.best_ask??r?.price??0;return parseFloat(((1-o)*100).toFixed(2)).toString()}function eu(e){let t=new Date(e).getTime()-Date.now();if(t<=0)return null;let r=Math.floor(t/864e5),o=Math.floor(t%864e5/36e5),n=Math.floor(t%36e5/6e4),i=[];return r>0&&i.push(`${r}d`),o>0&&i.push(`${o}h`),i.push(`${n}m`),i.join(" ")}var tu=`
|
|
7
7
|
.badge-shine { position: relative; overflow: hidden; }
|
|
8
8
|
.badge-shine::after {
|
|
9
9
|
content: "";
|
|
@@ -27,13 +27,13 @@ import {createContext,memo,useRef,forwardRef,useState,useImperativeHandle,useMem
|
|
|
27
27
|
outline: 2px solid hsl(var(--heroui-primary) / 0.4);
|
|
28
28
|
outline-offset: 2px;
|
|
29
29
|
}
|
|
30
|
-
`;function us({event:e,href:t,LinkComponent:r,onSelect:o,onSelectOutcome:n,onHover:i}){let[s,a]=useState(null),l=e.markets??[],d=useMemo(()=>l.length>2?[...l].sort((h,y)=>(y.outcomes?.[0]?.price??0)-(h.outcomes?.[0]?.price??0)):l,[l]).filter(h=>h.status==="open"),p=d.length===1,m=d.slice(0,ns),c=d.length-ns,f=useMemo(()=>formatAmountInUsd(e.volume??0),[e.volume]),g=s?d.find(h=>h.slug===s)??null:null,v=!!g||p,x=()=>{v||o?.(e);},b=h=>{h.stopPropagation(),g&&(h.preventDefault(),a(null));},w=h=>{h.stopPropagation(),t||(h.preventDefault(),o?.(e));},S=p?jsx(lu,{event:e,formattedVolume:f,href:t,LinkComponent:r,onSelect:o}):g?jsx(du,{onCollapse:()=>a(null)}):jsx(ou,{moreCount:c,formattedVolume:f,source:e.source,href:t,LinkComponent:r,onShowMore:w});return jsxs("div",{className:"group evt-card",style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",cursor:v?void 0:"pointer"},onMouseEnter:h=>{let y=h.currentTarget,k=Kd[e.source]??Vd;y.style.borderColor=k.border,y.style.boxShadow=k.shadow,i?.(e);},onMouseLeave:h=>{let y=h.currentTarget;y.style.borderColor="rgba(39,39,42,0.6)",y.style.boxShadow="none";},onClick:x,children:[jsx("style",{children:Qd}),jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,padding:"14px 14px 12px",gap:8},children:[jsx(Xd,{event:e,href:t,LinkComponent:r,onClick:b,isExpanded:v}),jsx("div",{style:{display:"flex",flexDirection:"column",flex:1},children:p?jsx(au,{market:d[0],event:e,onSelectOutcome:n}):g?jsx(cu,{market:g,event:e,onCollapse:()=>a(null),onSelectOutcome:n}):jsx(nu,{displayedMarkets:m,onMarketClick:h=>a(h.slug)})})]}),jsx(iu,{children:S})]})}function Xd({event:e,href:t,LinkComponent:r,onClick:o,isExpanded:n}){let i=e.start_at?Yd(e.start_at):null;return jsxs(Linkable,{href:t,LinkComponent:r,as:"button",className:"group/header flex items-center gap-x-2 lg:gap-x-4 w-full text-left cursor-pointer",onClick:o,children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",className:"h-8 w-8 flex-shrink-0 transition-transform duration-300 group-hover/header:scale-110 lg:h-12 lg:w-12",classNames:{base:"bg-transparent"}}),jsxs("div",{className:"flex min-w-0 flex-1 flex-col justify-center gap-y-0.5",children:[jsx("p",{className:cn$1("min-w-0 text-sm font-semibold leading-snug text-slate-200 line-clamp-2 lg:text-base",n&&"group-hover/header:text-neutral-400"),children:e.title}),i&&jsxs("span",{className:"text-[10px] leading-4 text-neutral-500",children:["Live in ",i]})]}),jsx(Zd,{event:e})]})}function Jd(e){let t=[];if(e.status==="closed")return t.push({kind:"closed"}),t.slice(0,2);let r=e.tags?.some(n=>n.label?.toLowerCase()==="crypto"),o=e.tags?.some(n=>n.label?.toLowerCase()==="live");if(r&&e.end_at){let n=new Date(e.end_at).getTime()-Date.now(),i=300*1e3,s=900*1e3;if(n>0&&n<=s){let a=n<=i?"#ef4444":"#f59e0b";t.push({kind:"crypto-short",label:n<=i?"5m":"15m",color:a});}}return o&&t.push({kind:"live"}),t.slice(0,2)}function Zd({event:e}){let t=useMemo(()=>Jd(e),[e]);return t.length===0?null:jsx("div",{className:"flex flex-shrink-0 flex-col items-end gap-1",children:t.map((r,o)=>{switch(r.kind){case "live":return jsx(eu,{},o);case "crypto-short":return jsx(tu,{label:r.label,color:r.color},o);case "closed":return jsx(ru,{},o)}})})}function eu(){let{t:e}=useTranslation();return jsxs("span",{className:"badge-shine relative inline-flex items-center gap-1 overflow-hidden rounded-md bg-[rgb(240,68,56)]/10 px-1.5 py-0.5 text-xs font-semibold text-[rgb(240,68,56)]",children:[jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-current"}),e("predict.event.status.live")]})}function tu({label:e,color:t}){return jsxs("span",{className:"badge-shine relative inline-flex items-center gap-1 overflow-hidden rounded-md px-1.5 py-0.5 text-xs font-semibold",style:{backgroundColor:`${t}26`,color:t},children:[jsx(TimerIcon,{className:"size-3 shrink-0"}),e]})}function ru(){let{t:e}=useTranslation();return jsx("span",{className:"inline-flex items-center rounded-md bg-neutral-800/80 px-1.5 py-0.5 text-xs font-semibold text-neutral-400",children:e("predict.event.status.closed")})}function nu({displayedMarkets:e,onMarketClick:t}){return e.length>0?jsx("div",{className:"flex w-full flex-1 flex-col gap-y-0.5 lg:gap-y-2",children:e.map(r=>{let o=cs(r);return jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between gap-x-2 transition-opacity hover:cursor-pointer hover:opacity-80",onClick:n=>{n.stopPropagation(),t(r);},children:[jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 line-clamp-1 lg:text-sm",children:r.outcomes?.[0]?.label??r.question}),jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:ds(o)}),jsx(su,{})]})]},r.id??`${r.source}-${r.slug}`)})}):null}function ou({moreCount:e,formattedVolume:t,source:r,href:o,LinkComponent:n,onShowMore:i}){let{t:s}=useTranslation();return jsxs(Fragment,{children:[e>0?jsxs(Linkable,{href:o,LinkComponent:n,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-zinc-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:i,children:[s("predict.event.showMore"),jsx(ms,{className:"h-3 w-3"})]}):jsx("div",{}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[t," ",s("predict.event.volume"),jsx(fs,{source:r})]})]})}function iu({children:e}){return jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.15)",padding:"8px 14px",marginTop:"auto"},children:e})}function as({bgColor:e,textColor:t,shadowColor:r,onClick:o,children:n}){return jsx("button",{type:"button",className:"flex h-12 flex-1 w-full items-center justify-center gap-x-1 overflow-hidden rounded-lg p-3 text-base font-normal hover:cursor-pointer will-change-transform [-webkit-tap-highlight-color:transparent]",style:{backgroundColor:e,color:t,"--shadow-color":r,"--shadow-offset":"4px",boxShadow:"inset 0 -1px 0 rgba(255,255,255,0.08), 0 var(--shadow-offset, 4px) 0 var(--shadow-color, rgba(0,0,0,0.22))",transition:"transform .12s, box-shadow .12s, opacity .14s"},onMouseEnter:a=>{let l=a.currentTarget;l.style.setProperty("--shadow-offset","2px"),l.style.transform="translateY(2px)";},onMouseLeave:a=>{let l=a.currentTarget;l.style.setProperty("--shadow-offset","4px"),l.style.transform="translateY(0px)";},onClick:o,children:n})}function ps({market:e,event:t,onSelectOutcome:r,dynamicColors:o=false,labelFormat:n="action"}){let{t:i}=useTranslation(),[s,a]=o?qd(e):[Lo,ls],l=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",u=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",d=n==="label"&&l===u?"action":n,p=d==="label"?`${e.outcomes?.[0]?.label??"Yes"} ${is(e)}\xA2`:i("predict.market.action.yes",{price:is(e)}),m=d==="label"?`${e.outcomes?.[1]?.label??"No"} ${ss(e)}\xA2`:i("predict.market.action.no",{price:ss(e)});return jsxs("div",{className:"flex gap-2",children:[jsx(as,{bgColor:s.bg,textColor:s.text,shadowColor:s.shadow,onClick:c=>{c.stopPropagation(),r?.(t,e,"yes");},children:p}),jsx(as,{bgColor:a.bg,textColor:a.text,shadowColor:a.shadow,onClick:c=>{c.stopPropagation(),r?.(t,e,"no");},children:m})]})}function su(){let{t:e}=useTranslation();return jsxs("span",{className:"inline-flex h-7 w-[85px] items-center justify-center gap-x-3 rounded-lg p-1.5 text-xs font-semibold flex-shrink-0 bg-gradient-to-r from-primary/15 to-secondary/15 lg:h-9 lg:w-24 lg:gap-x-4 lg:p-2 lg:text-sm",children:[jsx("span",{className:"text-primary",children:e("predict.market.yes")}),jsx("span",{className:"text-neutral-400",children:"/"}),jsx("span",{className:"text-secondary",children:e("predict.market.no")})]})}function au({market:e,event:t,onSelectOutcome:r}){return jsx("div",{style:{flex:1},children:jsx(ps,{market:e,event:t,onSelectOutcome:r,dynamicColors:true,labelFormat:"label"})})}function lu({event:e,formattedVolume:t,href:r,LinkComponent:o,onSelect:n}){let{t:i}=useTranslation();return jsxs(Fragment,{children:[jsxs(Linkable,{href:r,LinkComponent:o,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-zinc-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:a=>{a.stopPropagation(),r||(a.preventDefault(),n?.(e));},children:[i("predict.event.viewEvent"),jsx(ms,{className:"h-3 w-3"})]}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[t," ",i("predict.event.volume"),jsx(fs,{source:e.source})]})]})}function cu({market:e,event:t,onCollapse:r,onSelectOutcome:o}){let n=cs(e);return jsxs("div",{style:{flex:1},children:[jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between cursor-pointer",onClick:i=>{i.stopPropagation(),r();},children:[jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 lg:text-sm",children:e.outcomes?.[0]?.label??e.question}),jsxs("div",{className:"flex items-center gap-x-1 flex-shrink-0",children:[jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:ds(n)}),jsx(ChevronUpIcon,{className:"h-4 w-4 text-neutral-400"})]})]}),jsx("div",{style:{marginTop:12},children:jsx(ps,{market:e,event:t,onSelectOutcome:o,labelFormat:"action"})})]})}function du({onCollapse:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsxs("button",{type:"button",className:"flex items-center gap-x-1 text-[10px] font-normal transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",style:{color:"#71717a"},onClick:r=>{r.stopPropagation(),e();},children:[jsx(uu,{className:"h-3 w-3"}),t("predict.event.back")]}),jsx("div",{})]})}function ms({className:e}){return jsx("svg",{viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:jsx("path",{d:"M4.5 2.5L8 6l-3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function uu({className:e}){return jsx("svg",{viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:jsx("path",{d:"M7.5 2.5L4 6l3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function fs({source:e}){return jsxs("span",{className:"inline-flex items-center gap-x-1 text-neutral-400",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsx("span",{className:"text-neutral-600",children:"\xB7"}),e==="polymarket"?jsx(PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsx(KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}var gu=8;function hs({events:e,hasMore:t=false,isFetchingMore:r=false,onFetchMore:o,onSelect:n,onSelectOutcome:i,getEventHref:s,LinkComponent:a,onHover:l}){let{t:u}=useTranslation(),d=useRef(null);useEffect(()=>{let c=d.current;if(!c)return;let f=new IntersectionObserver(g=>{g[0]?.isIntersecting&&t&&!r&&o?.();},{rootMargin:"300px"});return f.observe(c),()=>f.disconnect()},[t,r,o]);let p=useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]),m=!t&&e.length>0;return jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[jsx("style",{children:`
|
|
30
|
+
`;function ms({event:e,href:t,LinkComponent:r,onSelect:o,onSelectOutcome:n,onHover:i}){let[s,a]=useState(null),l=e.markets??[],d=useMemo(()=>l.length>2?[...l].sort((h,y)=>(y.outcomes?.[0]?.price??0)-(h.outcomes?.[0]?.price??0)):l,[l]).filter(h=>h.status==="open"),p=d.length===1,m=d.slice(0,is),c=d.length-is,f=useMemo(()=>formatAmountInUsd(e.volume??0),[e.volume]),g=s?d.find(h=>h.slug===s)??null:null,v=!!g||p,x=()=>{v||o?.(e);},b=h=>{h.stopPropagation(),g&&(h.preventDefault(),a(null));},w=h=>{h.stopPropagation(),t||(h.preventDefault(),o?.(e));},S=p?jsx(mu,{event:e,formattedVolume:f,href:t,LinkComponent:r,onSelect:o}):g?jsx(gu,{onCollapse:()=>a(null)}):jsx(cu,{moreCount:c,formattedVolume:f,source:e.source,href:t,LinkComponent:r,onShowMore:w});return jsxs("div",{className:"group evt-card",style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",cursor:v?void 0:"pointer"},onMouseEnter:h=>{let y=h.currentTarget,k=Yd[e.source]??Qd;y.style.borderColor=k.border,y.style.boxShadow=k.shadow,i?.(e);},onMouseLeave:h=>{let y=h.currentTarget;y.style.borderColor="rgba(39,39,42,0.6)",y.style.boxShadow="none";},onClick:x,children:[jsx("style",{children:tu}),jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,padding:"14px 14px 12px",gap:8},children:[jsx(ru,{event:e,href:t,LinkComponent:r,onClick:b,isExpanded:v}),jsx("div",{style:{display:"flex",flexDirection:"column",flex:1},children:p?jsx(pu,{market:d[0],event:e,onSelectOutcome:n}):g?jsx(fu,{market:g,event:e,onCollapse:()=>a(null),onSelectOutcome:n}):jsx(lu,{displayedMarkets:m,onMarketClick:h=>a(h.slug)})})]}),jsx(du,{children:S})]})}function ru({event:e,href:t,LinkComponent:r,onClick:o,isExpanded:n}){let i=e.start_at?eu(e.start_at):null;return jsxs(Linkable,{href:t,LinkComponent:r,as:"button",className:"group/header flex items-center gap-x-2 lg:gap-x-4 w-full text-left cursor-pointer",onClick:o,children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",className:"h-8 w-8 flex-shrink-0 transition-transform duration-300 group-hover/header:scale-110 lg:h-12 lg:w-12",classNames:{base:"bg-transparent"}}),jsxs("div",{className:"flex min-w-0 flex-1 flex-col justify-center gap-y-0.5",children:[jsx("p",{className:cn("min-w-0 text-sm font-semibold leading-snug text-slate-200 line-clamp-2 lg:text-base",n&&"group-hover/header:text-neutral-400"),children:e.title}),i&&jsxs("span",{className:"text-[10px] leading-4 text-neutral-500",children:["Live in ",i]})]}),jsx(ou,{event:e})]})}function nu(e){let t=[];if(e.status==="closed")return t.push({kind:"closed"}),t.slice(0,2);let r=e.tags?.some(n=>n.label?.toLowerCase()==="crypto"),o=e.tags?.some(n=>n.label?.toLowerCase()==="live");if(r&&e.end_at){let n=new Date(e.end_at).getTime()-Date.now(),i=300*1e3,s=900*1e3;if(n>0&&n<=s){let a=n<=i?"#ef4444":"#f59e0b";t.push({kind:"crypto-short",label:n<=i?"5m":"15m",color:a});}}return o&&t.push({kind:"live"}),t.slice(0,2)}function ou({event:e}){let t=useMemo(()=>nu(e),[e]);return t.length===0?null:jsx("div",{className:"flex flex-shrink-0 flex-col items-end gap-1",children:t.map((r,o)=>{switch(r.kind){case "live":return jsx(iu,{},o);case "crypto-short":return jsx(su,{label:r.label,color:r.color},o);case "closed":return jsx(au,{},o)}})})}function iu(){let{t:e}=useTranslation();return jsxs("span",{className:"badge-shine relative inline-flex items-center gap-1 overflow-hidden rounded-md bg-[rgb(240,68,56)]/10 px-1.5 py-0.5 text-xs font-semibold text-[rgb(240,68,56)]",children:[jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-current"}),e("predict.event.status.live")]})}function su({label:e,color:t}){return jsxs("span",{className:"badge-shine relative inline-flex items-center gap-1 overflow-hidden rounded-md px-1.5 py-0.5 text-xs font-semibold",style:{backgroundColor:`${t}26`,color:t},children:[jsx(TimerIcon,{className:"size-3 shrink-0"}),e]})}function au(){let{t:e}=useTranslation();return jsx("span",{className:"inline-flex items-center rounded-md bg-neutral-800/80 px-1.5 py-0.5 text-xs font-semibold text-neutral-400",children:e("predict.event.status.closed")})}function lu({displayedMarkets:e,onMarketClick:t}){return e.length>0?jsx("div",{className:"flex w-full flex-1 flex-col gap-y-0.5 lg:gap-y-2",children:e.map(r=>{let o=us(r);return jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between gap-x-2 transition-opacity hover:cursor-pointer hover:opacity-80",onClick:n=>{n.stopPropagation(),t(r);},children:[jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 line-clamp-1 lg:text-sm",children:r.outcomes?.[0]?.label??r.question}),jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:ps(o)}),jsx(uu,{})]})]},r.id??`${r.source}-${r.slug}`)})}):null}function cu({moreCount:e,formattedVolume:t,source:r,href:o,LinkComponent:n,onShowMore:i}){let{t:s}=useTranslation();return jsxs(Fragment,{children:[e>0?jsxs(Linkable,{href:o,LinkComponent:n,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-zinc-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:i,children:[s("predict.event.showMore"),jsx(gs,{className:"h-3 w-3"})]}):jsx("div",{}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[t," ",s("predict.event.volume"),jsx(hs,{source:r})]})]})}function du({children:e}){return jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.15)",padding:"8px 14px",marginTop:"auto"},children:e})}function cs({bgColor:e,textColor:t,shadowColor:r,onClick:o,children:n}){return jsx("button",{type:"button",className:"flex h-12 flex-1 w-full items-center justify-center gap-x-1 overflow-hidden rounded-lg p-3 text-base font-normal hover:cursor-pointer will-change-transform [-webkit-tap-highlight-color:transparent]",style:{backgroundColor:e,color:t,"--shadow-color":r,"--shadow-offset":"4px",boxShadow:"inset 0 -1px 0 rgba(255,255,255,0.08), 0 var(--shadow-offset, 4px) 0 var(--shadow-color, rgba(0,0,0,0.22))",transition:"transform .12s, box-shadow .12s, opacity .14s"},onMouseEnter:a=>{let l=a.currentTarget;l.style.setProperty("--shadow-offset","2px"),l.style.transform="translateY(2px)";},onMouseLeave:a=>{let l=a.currentTarget;l.style.setProperty("--shadow-offset","4px"),l.style.transform="translateY(0px)";},onClick:o,children:n})}function fs({market:e,event:t,onSelectOutcome:r,dynamicColors:o=false,labelFormat:n="action"}){let{t:i}=useTranslation(),[s,a]=o?Jd(e):[Lo,ds],l=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",u=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",d=n==="label"&&l===u?"action":n,p=d==="label"?`${e.outcomes?.[0]?.label??"Yes"} ${as(e)}\xA2`:i("predict.market.action.yes",{price:as(e)}),m=d==="label"?`${e.outcomes?.[1]?.label??"No"} ${ls(e)}\xA2`:i("predict.market.action.no",{price:ls(e)});return jsxs("div",{className:"flex gap-2",children:[jsx(cs,{bgColor:s.bg,textColor:s.text,shadowColor:s.shadow,onClick:c=>{c.stopPropagation(),r?.(t,e,"yes");},children:p}),jsx(cs,{bgColor:a.bg,textColor:a.text,shadowColor:a.shadow,onClick:c=>{c.stopPropagation(),r?.(t,e,"no");},children:m})]})}function uu(){let{t:e}=useTranslation();return jsxs("span",{className:"inline-flex h-7 w-[85px] items-center justify-center gap-x-3 rounded-lg p-1.5 text-xs font-semibold flex-shrink-0 bg-gradient-to-r from-primary/15 to-secondary/15 lg:h-9 lg:w-24 lg:gap-x-4 lg:p-2 lg:text-sm",children:[jsx("span",{className:"text-primary",children:e("predict.market.yes")}),jsx("span",{className:"text-neutral-400",children:"/"}),jsx("span",{className:"text-secondary",children:e("predict.market.no")})]})}function pu({market:e,event:t,onSelectOutcome:r}){return jsx("div",{style:{flex:1},children:jsx(fs,{market:e,event:t,onSelectOutcome:r,dynamicColors:true,labelFormat:"label"})})}function mu({event:e,formattedVolume:t,href:r,LinkComponent:o,onSelect:n}){let{t:i}=useTranslation();return jsxs(Fragment,{children:[jsxs(Linkable,{href:r,LinkComponent:o,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-zinc-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:a=>{a.stopPropagation(),r||(a.preventDefault(),n?.(e));},children:[i("predict.event.viewEvent"),jsx(gs,{className:"h-3 w-3"})]}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[t," ",i("predict.event.volume"),jsx(hs,{source:e.source})]})]})}function fu({market:e,event:t,onCollapse:r,onSelectOutcome:o}){let n=us(e);return jsxs("div",{style:{flex:1},children:[jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between cursor-pointer",onClick:i=>{i.stopPropagation(),r();},children:[jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 lg:text-sm",children:e.outcomes?.[0]?.label??e.question}),jsxs("div",{className:"flex items-center gap-x-1 flex-shrink-0",children:[jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:ps(n)}),jsx(ChevronUpIcon,{className:"h-4 w-4 text-neutral-400"})]})]}),jsx("div",{style:{marginTop:12},children:jsx(fs,{market:e,event:t,onSelectOutcome:o,labelFormat:"action"})})]})}function gu({onCollapse:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsxs("button",{type:"button",className:"flex items-center gap-x-1 text-[10px] font-normal transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",style:{color:"#71717a"},onClick:r=>{r.stopPropagation(),e();},children:[jsx(hu,{className:"h-3 w-3"}),t("predict.event.back")]}),jsx("div",{})]})}function gs({className:e}){return jsx("svg",{viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:jsx("path",{d:"M4.5 2.5L8 6l-3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function hu({className:e}){return jsx("svg",{viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:jsx("path",{d:"M7.5 2.5L4 6l3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function hs({source:e}){return jsxs("span",{className:"inline-flex items-center gap-x-1 text-neutral-400",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsx("span",{className:"text-neutral-600",children:"\xB7"}),e==="polymarket"?jsx(PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsx(KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}var yu=8;function xs({events:e,hasMore:t=false,isFetchingMore:r=false,onFetchMore:o,onSelect:n,onSelectOutcome:i,getEventHref:s,LinkComponent:a,onHover:l}){let{t:u}=useTranslation(),d=useRef(null);useEffect(()=>{let c=d.current;if(!c)return;let f=new IntersectionObserver(g=>{g[0]?.isIntersecting&&t&&!r&&o?.();},{rootMargin:"300px"});return f.observe(c),()=>f.disconnect()},[t,r,o]);let p=useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]),m=!t&&e.length>0;return jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[jsx("style",{children:`
|
|
31
31
|
@keyframes eventCardEnter{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}
|
|
32
32
|
@keyframes evt-load-spin{to{transform:rotate(360deg)}}
|
|
33
33
|
@media(max-width:767px){.evt-card-grid{grid-template-columns:1fr!important}}
|
|
34
34
|
@media(min-width:768px) and (max-width:1023px){.evt-card-grid{grid-template-columns:repeat(2,1fr)!important}}
|
|
35
35
|
@media(min-width:1024px) and (max-width:1279px){.evt-card-grid{grid-template-columns:repeat(3,1fr)!important}}
|
|
36
|
-
`}),jsx("div",{className:"evt-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)"},children:e.map((c,f)=>c==null?null:jsx("div",{style:{padding:
|
|
36
|
+
`}),jsx("div",{className:"evt-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)"},children:e.map((c,f)=>c==null?null:jsx("div",{style:{padding:yu,animation:`eventCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${f%4*35}ms both`},children:jsx(ms,{event:c,href:s?.(c),LinkComponent:a,onSelect:n,onSelectOutcome:i,onHover:l})},`${c.source}-${c.slug}`))}),jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",alignItems:"center",gap:8,padding:"16px 0",minHeight:1},children:r&&jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#71717a",fontSize:13},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:"evt-load-spin 1s linear infinite"},children:jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),u("predict.events.loadMore")]})}),m&&jsx(ku,{onScrollToTop:p})]})}function ku({onScrollToTop:e}){let{t}=useTranslation();return jsxs("div",{className:"flex w-full flex-col items-center justify-center gap-y-4 py-6",children:[jsxs("div",{className:"flex w-full items-center justify-center gap-x-4",children:[jsx("div",{className:"h-px w-16 bg-neutral-700"}),jsx("span",{className:"text-xs font-medium text-neutral-500",children:t("predict.event.endOfList")}),jsx("div",{className:"h-px w-16 bg-neutral-700"})]}),jsxs("button",{type:"button",className:"flex cursor-pointer items-center gap-x-1 text-xs font-medium text-neutral-400",onClick:e,children:[jsx("span",{className:"iconify size-4 ph--arrow-up-bold"}),jsx("span",{children:t("predict.event.backToTop")})]})]})}function ys({tagSlugSelection:e,limit:t=24,status:r,sort_by:o,sort_asc:n,source:i,with_markets:s,timeRemaining:a,minVolume:l,minLiquidity:u,markets_limit:d,onSelect:p,onSelectOutcome:m,getEventHref:c,LinkComponent:f,onHover:g}){let{data:v,hasMore:x,fetchMore:b,isFetching:w,isFetchingMore:S}=rs({tagSlugSelection:e,limit:t,status:r,sort_by:o,sort_asc:n,source:i,with_markets:s,timeRemaining:a,minVolume:l,minLiquidity:u,markets_limit:d});return w?jsx(Eo,{count:24}):jsx(xs,{events:v,hasMore:x,isFetchingMore:S,onFetchMore:b,onSelect:p,onSelectOutcome:m,getEventHref:c,LinkComponent:f,onHover:g})}function Qx({onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:o,onHover:n,bgImageSrc:i,onInsufficientBalance:s,enableKalshi:a=true}){let[l,u]=useState({categorySlug:null,tagSlug:null}),[d,p]=useState(()=>a?Qr:{...Qr,source:"polymarket"}),{isOpen:m,onOpen:c,onClose:f}=useDisclosure(),{onOpen:g}=useAsyncModal(Yr),v=useCallback((P,O,F)=>{t?.(P,O,F),g({params:{event:P,market:O,initialOutcome:F,onInsufficientBalance:s}});},[t,g,s]),x=useCallback(P=>{u(P);},[]),b=useCallback(P=>{p(O=>({...O,sortPreset:P}));},[]),w=useCallback(P=>{p(O=>({...O,sortAsc:P}));},[]),S=useCallback(P=>{p(P);},[]),h=useMemo(()=>Ji[d.sortPreset].sort_by,[d.sortPreset]),y=useMemo(()=>Mo(d,a),[d,a]),k=useMemo(()=>jsx(Zi,{sortPreset:d.sortPreset,onSortChange:b,sortAsc:d.sortAsc,onSortAscChange:w,onFilterPress:c,filterCount:y}),[d.sortPreset,d.sortAsc,y,b,w,c]);return jsxs("div",{style:{minHeight:"100vh",position:"relative",width:"100%",maxWidth:1680,margin:"0 auto"},children:[jsx("div",{style:{position:"sticky",top:0,zIndex:40,background:"rgba(10,10,11,0.8)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:jsx(Ci,{onSelect:x,trailing:k})}),jsxs("div",{style:{padding:"12px 8px 80px"},children:[jsx(qi,{isOpen:m,onClose:f,value:d,onChange:S,enableKalshi:a}),jsx(ys,{tagSlugSelection:l,sort_by:h,sort_asc:d.sortAsc,source:d.source,timeRemaining:d.timeRemaining,minVolume:d.minVolume,minLiquidity:d.minLiquidity,onSelect:e,onSelectOutcome:v,getEventHref:r,LinkComponent:o,onHover:n})]}),jsx(On,{})]})}function Ps(e){return formatAmountInUsd(e)}var Cu=[{key:"total_events",labelKey:"predict.events.stats.totalEvents",format:e=>formatAmount(e),valueColor:"#c7ff2e",gradientFrom:"rgba(199,255,46,0.18)",gradientTo:"rgba(199,255,46,0.04)"},{key:"total_volume_24h",labelKey:"predict.events.stats.volume24h",format:Ps,valueColor:"#f76816",gradientFrom:"rgba(247,104,22,0.18)",gradientTo:"rgba(247,104,22,0.04)"},{key:"avg_liquidity",labelKey:"predict.events.stats.avgLiquidity",format:Ps,valueColor:"#17c964",gradientFrom:"rgba(23,201,100,0.18)",gradientTo:"rgba(23,201,100,0.04)"},{key:"active_sources",labelKey:"predict.events.stats.activeSources",format:e=>formatAmount(e),valueColor:"#f5a524",gradientFrom:"rgba(245,165,36,0.18)",gradientTo:"rgba(245,165,36,0.04)"}];function tb({stats:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsx("style",{children:`
|
|
37
37
|
@keyframes evt-live-ping{75%,100%{transform:scale(2.2);opacity:0}}
|
|
38
38
|
@keyframes evt-live-breathe{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.55;transform:scale(.85)}}
|
|
39
39
|
@keyframes evtHeroTitleEnter{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}
|
|
@@ -71,15 +71,15 @@ import {createContext,memo,useRef,forwardRef,useState,useImperativeHandle,useMem
|
|
|
71
71
|
.evt-stat-label{font-size:11px;line-height:16px;min-height:16px;white-space:nowrap}
|
|
72
72
|
@media(min-width:640px){.evt-stat-label{font-size:12px;line-height:18px;min-height:18px}}
|
|
73
73
|
`}),jsxs("div",{className:"evt-hero-outer",children:[jsxs("div",{className:"evt-hero-left",style:{minWidth:0,flex:1,animation:"evtHeroTitleEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both"},children:[jsx("div",{className:"evt-hero-live",style:{marginBottom:16},children:jsxs("div",{className:"inline-flex items-center",style:{gap:8,borderRadius:9999,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"6px 12px",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)"},children:[jsxs("span",{style:{position:"relative",display:"flex",width:8,height:8},children:[jsx("span",{style:{position:"absolute",display:"inline-flex",width:"100%",height:"100%",borderRadius:9999,background:"#00d492",opacity:.75,animation:"evt-live-ping 1.2s cubic-bezier(0,0,0.2,1) infinite"}}),jsx("span",{style:{position:"relative",display:"inline-flex",width:8,height:8,borderRadius:9999,background:"#00bc7d",animation:"evt-live-breathe 2.4s ease-in-out infinite"}})]}),jsx("span",{style:{fontSize:12,fontWeight:500,color:"#d4d4d8",letterSpacing:"0.025em"},children:t("predict.events.liveBadge")})]})}),jsxs("h1",{className:"evt-hero-title",style:{fontFamily:"var(--font-dm-sans, 'DM Sans', sans-serif)",fontWeight:700,letterSpacing:"-1.2px",lineHeight:1.2,color:"#fff",margin:"0 0 14px"},children:[jsxs("span",{style:{color:"#fff"},children:[t("predict.events.titlePrefix")," "]}),jsx("span",{style:{backgroundImage:"linear-gradient(to right, #c7ff2e, #a0e515, #17c964)",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",backgroundClip:"text"},children:t("predict.events.titleHighlight")})]}),jsx("p",{className:"evt-hero-subtitle evt-hero-subtitle-text",style:{lineHeight:1.6,color:"#71717a",maxWidth:460},children:String(t("predict.events.heroSubtitle")).split(`
|
|
74
|
-
`).map((r,o)=>jsxs("span",{children:[o>0&&jsx("br",{className:"hidden sm:block"}),r,o===0?" ":""]},o))})]}),jsx("div",{className:"evt-stat-grid",style:e?{animation:"evtStatsEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:"0.1s"}:{},children:ku.map((r,o)=>jsxs("div",{style:{padding:"14px 16px",background:e?`linear-gradient(to bottom, ${r.gradientFrom}, ${r.gradientTo})`:"rgba(255,255,255,0.02)",borderRight:o%2===0?"1px solid rgba(39,39,42,0.4)":"none",borderBottom:o<2?"1px solid rgba(39,39,42,0.4)":"none",...e?{animation:"evtStatCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:`${150+o*60}ms`}:{}},children:[jsx("div",{className:"evt-stat-val",style:{fontWeight:700,fontVariantNumeric:"tabular-nums",color:e?r.valueColor:"transparent",display:"flex",alignItems:"center"},children:e?r.format(e[r.key]):jsx("div",{style:{height:16,width:56,borderRadius:4,background:"rgba(255,255,255,0.06)",animation:"evtStatCardEnter 0.6s ease-out both",animationDelay:`${o*80}ms`}})}),jsx("div",{className:"evt-stat-label",style:{fontWeight:500,color:e?"#71717a":"transparent",marginTop:2,display:"flex",alignItems:"center"},children:e?t(r.labelKey):jsx("div",{style:{height:10,width:64,borderRadius:4,background:"rgba(255,255,255,0.04)",animation:"evtStatCardEnter 0.6s ease-out both",animationDelay:`${50+o*80}ms`}})})]},r.key))})]})]})}function Ms({event:e,market:t,position:r,onSuccess:o,onCancel:n}){let{t:i}=useTranslation(),{mutateAsync:s}=useRedeemPosition(),{evmAddress:a}=hr(),l=useWallets(),[u,d]=useState("idle"),[p,m]=useState(null),c=t.provider_meta?.["polymarket.conditionId"],f=t.provider_meta?.["polymarket.negRisk"]??false,g=a??"",v=useMemo(()=>l.find(O=>O.chainNamespace===ChainNamespace.EVM&&O.isConnected),[l]),x=Cs(r.side,t.outcomes),w=t.outcomes?.[x]?.label??r.side,S=t.result!=null?Cs(t.result,t.outcomes):-1,y=(S>=0?t.outcomes?.[S]:void 0)?.label??t.result??"",k=t.result!=null?x===S:true,P=useMemo(()=>k?r.size:0,[k,r.size]),I=useCallback(async()=>{if(!(!c||!g||!v)){d("pending"),m(null);try{let O=await v.getEip1193Provider();if(!O)throw new Error("EIP-1193 provider unavailable");await s({wallet_address:g,condition_id:c,neg_risk:f,signMessage:async G=>await O.request({method:"personal_sign",params:[G,g]}),signTypedData:async G=>await O.request({method:"eth_signTypedData_v4",params:[g,JSON.stringify(G)]})}),d("success"),o?.();}catch(O){d("error"),m(O instanceof Error?O.message:i("predict.redeem.error"));}}},[c,g,f,v,s,o,i]),D=useAuthCallback(I),W=u==="idle"&&!!c&&!!g&&!!v&&r.redeemable;return jsxs("div",{className:"flex flex-col gap-4 p-4",children:[jsx("div",{className:"text-base font-medium text-white",children:e?.title??t.question}),jsxs("div",{className:"flex flex-col gap-2 rounded-xl bg-[rgba(39,39,42,0.4)] p-3",children:[jsx(Hn,{label:i("predict.positions.side"),value:w,valueClassName:k?"text-green-400":"text-red-400"}),t.result!=null&&jsx(Hn,{label:i("predict.redeem.result"),value:y,valueClassName:"text-green-400"}),jsx(Hn,{label:i("predict.positions.size"),value:r.size.toFixed(2)}),jsx(Hn,{label:i("predict.redeem.expectedPayout"),value:`$${P.toFixed(2)}`,valueClassName:P>0?"text-green-400":"text-zinc-400"})]}),!k&&P===0&&jsx("p",{className:"text-sm text-zinc-500",children:i("predict.redeem.noWinnings")}),u==="error"&&p&&jsx("p",{className:"text-sm text-red-400",children:p}),u==="success"&&jsx("p",{className:"text-sm text-green-400",children:i("predict.redeem.success")}),jsxs("div",{className:"flex flex-col gap-2",children:[u!=="success"&&jsx(Button,{color:"success",className:"w-full h-12 rounded-xl text-sm font-semibold",isDisabled:!W,isLoading:u==="pending",onPress:D,spinner:jsx(Spinner,{size:"sm",color:"current"}),children:i("predict.redeem.confirm")}),n&&u!=="success"&&jsx("button",{type:"button",onClick:n,className:"w-full h-12 rounded-xl text-sm font-medium text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:i("common.cancel")}),u==="success"&&n&&jsx(Button,{className:"w-full h-12 rounded-xl text-sm font-medium",onPress:n,children:i("common.ok")})]})]})}function Hn({label:e,value:t,valueClassName:r="text-white"}){return jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm text-zinc-400",children:e}),jsx("span",{className:`text-sm font-medium ${r}`,children:t})]})}function Cs(e,t){let r=e.toLowerCase();if(r==="yes")return 0;if(r==="no"||!t)return 1;let o=t.findIndex(n=>n.label.toLowerCase()===r);return o>=0?o:1}var Au="predict-redeem";function Ts({id:e=Au}){return jsx(AsyncModal,{id:e,children:t=>jsx(Du,{...t})})}function Du({params:e,isOpen:t,onOpenChange:r}){let{t:o}=useTranslation(),{isMobile:n}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:n?"lg":"md",backdrop:"opaque",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{className:n?"":"p-2",children:[jsxs("div",{className:"px-4 pt-4 pb-1",children:[jsx("h3",{className:"text-lg font-semibold text-white",children:o("predict.redeem.title")}),jsx("p",{className:"text-sm text-zinc-400 mt-1",children:o("predict.redeem.description")})]}),jsx(Ms,{event:e.event,market:e.market,position:e.position,onSuccess:()=>{setTimeout(()=>r(false),1500);},onCancel:()=>r(false)})]})})}):null}function _s({market:e,initialOutcome:t="yes",slippageBps:r=100,onSuccess:o}){let{t:n}=useTranslation(),i=useRef(o);i.current=o;let{status:s}=useAuth(),a=useWallets(),l=usePredictClient(),u=useContext(PolymarketContext),d=useQueryClient(),p=e.source,m=p==="polymarket",c=a.find(C=>C.chainNamespace===ChainNamespace.SOLANA&&C.isConnected),f=a.find(C=>C.chainNamespace===ChainNamespace.EVM&&C.isConnected&&"switchChain"in C),g=s==="authenticated",v=c?.address,x=f?.address,[b,w]=useState(t),[S,h]=useState("market"),[y,k]=useState(NaN),[P,I]=useState(NaN),[D,W]=useState(false),[O,G]=useState(false),[j,Q]=useState(null),[re,te]=useState(null),[N,M]=useState(false),[U,X]=useState(false),[se,R]=useState("1h"),[ke,H]=useState(30),[Se,bt]=useState("minutes"),Te=useMemo(()=>{if(p!=="polymarket")return;let C=e.provider_meta?.["polymarket.clobTokenIds"];return C?(typeof C=="string"?JSON.parse(C):C)[b==="yes"?0:1]:void 0},[p,e.provider_meta,b]),{data:Fe,isLoading:nt}=useTickSize(Te),ve=Fe?.minimum_tick_size?String(Fe.minimum_tick_size):"0.01",{data:Ye,isLoading:Le}=useFeeRate(Te),Qe=String(Ye?.base_fee??0),{data:Pt}=useRebateConfig(),Nt=Pt?.builder_enabled&&Pt.builder_code?Pt.builder_code:void 0,Ke=false,ot=null,Be=false,Ve,je,He;try{let C=hr();Ke=C.kalshiKycVerified,ot=C.kalshiKycUrl,Be=C.polymarketSetupVerified,Ve=C.polymarketSafeAddress,je=C.polymarketWalletKind,He=C.polymarketWalletAddress;}catch{}let Re=p==="kalshi"&&!Ke,A=p==="polymarket"&&!Be,de=useCallback(async()=>{if(!f||!u)return null;let C=await f.getEip1193Provider();if(!C)return null;let Ie=je==="deposit"&&!!He,Ze=!Ie&&!!Ve,et={address:f.address,signatureType:Ie?3:Ze?2:0,signTypedData:async(it,Mt,st,Me)=>{let We=[];"name"in it&&We.push({name:"name",type:"string"}),"version"in it&&We.push({name:"version",type:"string"}),"chainId"in it&&We.push({name:"chainId",type:"uint256"}),"verifyingContract"in it&&We.push({name:"verifyingContract",type:"address"}),"salt"in it&&We.push({name:"salt",type:"bytes32"});let Vt={EIP712Domain:We,...Mt};return await C.request({method:"eth_signTypedData_v4",params:[f.address,JSON.stringify({domain:it,types:Vt,primaryType:st,message:Me})]})}};return u.credentials??await u.authenticate(et)},[Ve,je,He,f,u]),{data:ze}=useRealtimeOrderbook({slug:e.slug,source:p,outcome:b},{enabled:e.status==="open"}),we=useMemo(()=>{let C=pickBestBid(ze,b);if(C!=null&&C>0)return C;let Ie=b==="yes"?0:1,Ze=e.outcomes[Ie];return Ze?.best_bid??Ze?.price??.5},[ze,e.outcomes,b]),Ht=p==="kalshi"?v??"":x??"",{data:rt,isLoading:Ur}=usePositions({source:p,user:Ht},{enabled:!!Ht,refetchInterval:3e4}),F=useCallback(async()=>{let C=await de();return C?await buildPolymarketL2Headers(C.address,{apiKey:C.apiKey,secret:C.secret,passphrase:C.passphrase,method:"GET",requestPath:"/data/orders",body:""}):{}},[de]),{data:Pe,isLoading:zt}=useAvailableShares({source:p,user:Ht,market:e.slug,side:b},p==="polymarket"?{getHeaders:F}:void 0,{enabled:!!Ht&&!!e.slug,refetchOnMount:"always"}),Wt=Pe?.total_shares??0,Ut=Pe?.active_order_shares??0,$t=Pe?.available_shares??0,Xe=useMemo(()=>p==="polymarket"?getPolymarketSharesPrecision(ve):Pe?.precision??0,[p,ve,Pe?.precision]),co=zt||Ur,uo=e.provider_meta?.["dflow.yesMint"]??"",pn=e.provider_meta?.["dflow.noMint"]??"",Ct=SOLANA_TOKENS.stablecoins.USDC.address,po=e.provider_meta?.["dflow.collateralMint"]||"",Kt=b==="yes"?uo:pn,Rt=useMemo(()=>rt?rt.positions.find(C=>C.side?.toLowerCase()===b&&C.market?.slug===e.slug)??null:null,[rt,e.slug,b])?.market?.provider_meta,mn=Rt?.["dflow.outcomeMint"]||Kt,tr=Rt?.["dflow.collateralMint"]||po,cr=mn,dr=tr||Ct,Er=useMemo(()=>isNaN(y)||y<=0?"0":String(Math.round(y*1e6)),[y]),fo=p==="kalshi"&&!!cr&&!!dr&&!!v&&Er!=="0",{refetch:ur}=useDFlowQuote({inputMint:cr,outputMint:dr,amount:Er,userPublicKey:v??"",slippageBps:100},{enabled:fo}),pr=useMemo(()=>isNaN(y)||y<=0?0:y,[y]),yt=useMemo(()=>walkOrderbook({orderbook:ze,outcome:b,side:"sell",sharesNeeded:pr,slippageBps:r}),[ze,b,pr,r]),fn=useMemo(()=>yt.status==="ok"&&yt.worstPrice!=null&&yt.worstPrice>0?yt.worstPrice:we,[yt,we]),gn=useMemo(()=>{if(isNaN(y)||y<=0)return 0;let C=S==="limit"&&m&&!isNaN(P)?P:we;return y*C},[y,S,m,P,we]),mr=useCallback(C=>{w(C),I(NaN),k(NaN),G(false);},[]);useEffect(()=>{mr(t);},[t,mr]);let hn=useCallback(C=>{h(C);},[]);useEffect(()=>{S==="limit"&&I(Math.round(we*1e4)/1e4);},[S,b]);let vn=useCallback(C=>{if(G(false),isNaN(C)){k(NaN);return}k(he(Math.max(0,C),Xe));},[Xe]),go=useCallback(()=>{G(true),k(he($t,Xe));},[$t,Xe]),L=useCallback(C=>{if(isNaN(C)){I(NaN);return}I(Math.round(C*1e4)/1e4);},[]),_e=useCallback(()=>{k(NaN),I(NaN),h("market"),G(false),X(false),R("1h"),H(30),bt("minutes");},[]),Je=useMemo(()=>{let C=[];return isNaN(y)||y<=0?C.push(n("predict.trade.minQuantity",{amount:Cn})):y<Cn&&C.push(n("predict.trade.minQuantity",{amount:Cn})),e.status!=="open"&&C.push(n("predict.trade.marketNotActive")),!isNaN(y)&&y>0&&!O&&y>$t&&C.push(n("predict.trade.insufficientSharesDetail",{total:he(Wt,Xe).toFixed(Xe),active:he(Ut,Xe).toFixed(Xe),available:he($t,Xe).toFixed(Xe)})),S==="limit"&&m&&(isNaN(P)||P<.01||P>.99)&&C.push(n("predict.trade.limitPriceRange")),S==="limit"&&m&&U&&se==="custom"&&(isNaN(ke)||ke<=0)&&C.push(n("predict.trade.expiration.invalidDate")),p==="polymarket"&&S==="market"&&!isNaN(y)&&y>0&&(yt.status==="insufficient_liquidity"?C.push(n("predict.trade.insufficientLiquidity",{available:he(yt.totalAvailable,2)})):yt.status==="exceeds_slippage"&&C.push(n("predict.trade.priceImpactTooHigh",{impact:(yt.priceImpactBps/100).toFixed(2),slippage:(r/100).toFixed(2)}))),{isValid:C.length===0,errors:C}},[y,e.status,$t,Wt,Ut,O,S,m,P,U,se,ke,Xe,p,yt,r,n]),{mutateAsync:kt}=useDFlowSubmit(),{data:fr}=useOrder({id:j??"",source:p},{enabled:!!j}),rr=useCallback(async()=>{if(!re||!v||!c)return;let{cashAmount:C,collateral:Ie}=re;te(null);try{let et=(await l.createDFlowQuote({inputMint:Ie,outputMint:Ct,amount:C,userPublicKey:v,slippageBps:100}))?.transaction;if(!et)return;let it=Uint8Array.from(atob(et),st=>st.charCodeAt(0)),Mt=await c.signTransaction(it);await kt({signedTransaction:btoa(String.fromCharCode(...Mt)),orderContext:{user_public_key:v,input_mint:Ie,output_mint:Ct,amount:C,price:"1",side:"SELL",outcome:"",market_slug:"",slippage_bps:100}});}catch{}},[re,v,c,l,kt,Ct]),dt=useCallback(()=>{d.invalidateQueries({queryKey:["predict","positions"]}),d.invalidateQueries({queryKey:["predict","orders"]}),d.invalidateQueries({queryKey:["predict","available-shares"]});},[d]);useEffect(()=>{if(!fr||!j)return;let{status:C}=fr;C==="closed"?(Q(null),re?rr().finally(()=>{W(false),toast.success(n("predict.trade.submitSuccess")),vr(),dt(),_e(),i.current?.();}):(W(false),toast.success(n("predict.trade.submitSuccess")),vr(),dt(),_e(),i.current?.())):(C==="failed"||C==="expired")&&(W(false),Q(null),te(null),toast.error(n("predict.trade.submitError")));},[fr,j,re,rr,dt,_e,n]);let St=useCallback(async()=>{if(!v||!c)return;if(!cr||!dr){toast.error("Missing token mint addresses"),W(false);return}if(!Ke){M(true),W(false);return}let Ze=(await ur()).data,et=Ze?.transaction;if(!et){toast.error(n("predict.trade.submitError")),W(false);return}if(tr&&tr!==Ct){let Me=String(Ze?.outAmount??"");Me&&Me!=="0"&&te({cashAmount:Me,collateral:tr});}let it=Uint8Array.from(atob(et),Me=>Me.charCodeAt(0)),Mt=await c.signTransaction(it),st=await kt({signedTransaction:btoa(String.fromCharCode(...Mt)),orderContext:{user_public_key:v,input_mint:cr,output_mint:dr,amount:Er,price:String(we),side:"SELL",outcome:b==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});Q(st.signature);},[v,c,ur,kt,cr,dr,Er,we,b,e.slug,tr,Ct,n,Ke]),xn=useCallback(async()=>{if(!f||!u)return;let C=f.chain,Ie=C!==Chain.POLYGON;Ie&&await f.switchChain(Chain.POLYGON);try{let Ze=await f.getEip1193Provider();if(!Ze){toast.error(n("predict.trade.submitError")),W(!1);return}let et=je==="deposit"&&!!He,it=!et&&!!Ve,Mt=et?He:Ve,st={address:f.address,signatureType:et?3:it?2:0,signTypedData:async(jt,yn,bo,yo)=>{let Lr=[];"name"in jt&&Lr.push({name:"name",type:"string"}),"version"in jt&&Lr.push({name:"version",type:"string"}),"chainId"in jt&&Lr.push({name:"chainId",type:"uint256"}),"verifyingContract"in jt&&Lr.push({name:"verifyingContract",type:"address"}),"salt"in jt&&Lr.push({name:"salt",type:"bytes32"});let Jl={EIP712Domain:Lr,...yn};return await Ze.request({method:"eth_signTypedData_v4",params:[f.address,JSON.stringify({domain:jt,types:Jl,primaryType:bo,message:yo})]})}},Me=await de();if(!Me){toast.error(n("predict.trade.submitError")),W(!1);return}let We=b==="yes"?0:1,Vt="",nr=e.provider_meta?.["polymarket.clobTokenIds"];nr&&(Vt=(typeof nr=="string"?JSON.parse(nr):nr)[We]??"");let Tr=e.provider_meta?.["polymarket.negRisk"]??!1,or=S==="limit"&&!isNaN(P)?P:fn,ho=Tn(or,ve),vo={tokenId:Vt,price:ho,size:y,side:"SELL",orderType:S==="limit"?U?"GTD":"GTC":"FOK",tickSize:ve,negRisk:Tr,...Mt&&{funderAddress:Mt},...Nt&&{builderCode:Nt},...S==="limit"&&U&&{expiration:En(se,ke,Se)}},xo;if(et)xo=await buildSignedV2OrderPayload({signer:st,depositWalletAddress:Mt,input:vo,owner:Me.apiKey});else {let jt=buildCtfExchangeDomain(Tr),yn=buildOrderMessage({...vo,signerAddress:st.address,signatureType:st.signatureType,feeRateBps:Qe}),bo=await st.signTypedData(jt,CTF_ORDER_TYPES,"Order",yn),yo=buildSignedOrder(yn,bo,vo.orderType);xo=buildClobPayload(yo,Me.apiKey);}await l.executePolymarketOrder({payload:xo,l2_api_key:Me.apiKey,l2_secret:Me.secret,l2_passphrase:Me.passphrase,signer_address:Me.address,owner:Me.apiKey}),dt(),toast.success(n("predict.trade.submitSuccess")),vr(),_e(),W(!1),i.current?.();}finally{Ie&&C&&f.switchChain(C).catch(()=>{});}},[f,u,de,b,e.provider_meta,S,P,fn,y,l,dt,U,se,ke,Se,_e,n,ve,Qe,e.slug,Ve,je,He,Nt]),bn=useCallback(async()=>{if(!(!Je.isValid||!g)){W(true),Q(null),M(false);try{p==="kalshi"?await St():await xn();}catch(C){let Ie=C instanceof Error?C.message:"",Ze=p==="polymarket"&&Ie?Ln(Ie,n,"sell"):Ie||void 0;toast.error(Ze||n("predict.trade.submitError")),W(false);}}},[Je.isValid,g,p,St,xn,n]);return {outcome:b,orderType:S,quantity:y,limitPrice:P,shares:pr,estimatedReturn:gn,pricePerShare:we,isMarketDataLoading:p==="polymarket"&&(Le||nt),isSubmitting:D,authStatus:s,validation:Je,supportsLimitOrder:m,kycRequired:N,needsKyc:Re,needsSetup:A,kycUrl:ot,totalShares:Wt,activeOrderShares:Ut,availableShares:$t,isAvailableLoading:co,isSellAll:O,precision:Xe,expirationEnabled:U,expirationPreset:se,customDuration:ke,customDurationUnit:Se,setOutcome:mr,setOrderType:hn,setQuantity:vn,setLimitPrice:L,setSellAll:go,setExpirationEnabled:X,setExpirationPreset:R,setCustomDuration:H,setCustomDurationUnit:bt,submit:bn}}var xp=["5m","1h","12h","24h","eod","custom"],bp={"5m":"predict.trade.expiration.5m","1h":"predict.trade.expiration.1h","12h":"predict.trade.expiration.12h","24h":"predict.trade.expiration.24h",eod:"predict.trade.expiration.eod",custom:"predict.trade.expiration.custom"},yp=["minutes","hours","days"],kp={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},Sp={maximumFractionDigits:0};function Ws({event:e,market:t,variant:r="bordered",outcome:o,orderType:n,quantity:i,limitPrice:s,estimatedReturn:a,isMarketDataLoading:l,isSubmitting:u,authStatus:d,isValid:p,validationErrors:m,supportsLimitOrder:c,kycRequired:f,needsKyc:g,needsSetup:v,onSetupRequired:x,kycUrl:b,totalShares:w,activeOrderShares:S,availableShares:h,isAvailableLoading:y,precision:k,expirationEnabled:P,expirationPreset:I,customDuration:D,customDurationUnit:W,oddsFormatter:O,onOutcomeChange:G,onOrderTypeChange:j,onQuantityChange:Q,onLimitPriceChange:re,onSellAll:te,onExpirationEnabledChange:N,onExpirationPresetChange:M,onCustomDurationChange:U,onCustomDurationUnitChange:X,onSubmit:se}){let{t:R}=useTranslation(),[ke,H]=useState(false),Se=useDisclosure(),[bt,Te]=useState(""),Fe=useRef(false);useEffect(()=>{Fe.current||Te(isNaN(i)?"":String(i));},[i]);let[nt,ve]=useState(""),Ye=useRef(false);useEffect(()=>{Ye.current||(isNaN(s)?ve(""):ve(String(parseFloat((s*100).toFixed(2)))));},[s]);let Le=useCallback(A=>{if(A!==""&&!/^\d*\.?\d{0,2}$/.test(A))return;if(ve(A),A===""||A==="."){re(NaN);return}let ze=parseFloat(A);isNaN(ze)||re(ze/100);},[re]),Qe=useCallback(A=>{let de=new RegExp(`^\\d*\\.?\\d{0,${k}}$`);if(A!==""&&!de.test(A))return;if(Te(A),H(false),A===""||A==="."){Q(NaN);return}let ze=parseFloat(A);isNaN(ze)||Q(ze);},[Q,k]);useEffect(()=>{f&&!Se.isOpen&&Se.onOpen();},[f]);let Pt=useMemo(()=>{let A=o==="yes"?t.yesBid:t.noBid;return A!=null?parseFloat((Number(A)*100).toFixed(2)):null},[o,t]),Nt=o==="yes"?t.yesBid:t.noBid,Ke=Nt!=null&&O?O(Number(Nt)):Pt!=null?`${Pt} \xA2`:null,ot=!isNaN(i)&&i>0,Be=d==="authenticated",Ve=d==="authenticating"||d==="deauthenticating",je=Be&&(g||v),He=useMemo(()=>{if(Ve)return R("predict.trade.checkingLogin");if(!Be)return R("predict.trade.loginToTrade");if(g)return R("predict.trade.kycRequired");if(v)return R("predict.trade.setupRequired");if(y)return R("predict.trade.loadingBalance");if(l)return R("predict.trade.loadingMarketData");if(u)return R("predict.trade.submitting");if(f)return R("predict.trade.kycRequired");if(!ot)return R("predict.trade.enterAmount");let A=R(o==="yes"?"predict.trade.yes":"predict.trade.no");return `${R("predict.trade.sell")} ${A}`},[Ve,Be,g,v,y,l,u,f,ot,o,R]),Re=()=>{if(!Be){H(false),se();return}if(g){Se.onOpen();return}if(v&&x){H(false),x();return}if(f){Se.onOpen();return}if(!p){H(true);return}H(false),se();};return jsxs(Fragment,{children:[jsxs("div",{className:"flex w-full flex-col gap-y-4 p-4",style:r==="bordered"?{borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",transition:"border-color 0.2s"}:void 0,onMouseEnter:A=>{r==="bordered"&&(A.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:A=>{r==="bordered"&&(A.currentTarget.style.borderColor="rgba(39,39,42,0.6)");},children:[e&&jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxs("span",{className:"text-bearish",children:[R("predict.trade.sell")," ",R(o==="yes"?"predict.trade.yes":"predict.trade.no")]}),jsxs("span",{className:"text-foreground",children:[" \xB7 ",t.yesSubTitle]})]})]})]}),jsxs("div",{className:"flex items-center justify-between",children:[c?jsxs(Tabs,{variant:"underlined",selectedKey:n,onSelectionChange:A=>j(A),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsx(Tab,{title:R("predict.trade.market")},"market"),jsx(Tab,{title:R("predict.trade.limit")},"limit")]}):jsx("span",{className:"text-sm font-medium text-foreground",children:R("predict.trade.market")}),n==="limit"&&c?jsx(StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:nt,onChange:A=>Le(A.target.value),onFocus:()=>{Ye.current=true;},onBlur:()=>{Ye.current=false,isNaN(s)?ve(""):ve(String(parseFloat((s*100).toFixed(2))));},endContent:jsx("span",{className:"text-xl font-bold tabular-nums text-foreground",children:"\xA2"}),classNames:{base:"w-28",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 rounded-lg px-2 h-9 min-h-9",input:"text-xl font-bold tabular-nums text-right"}}):Ke!=null&&jsx("span",{className:"text-xl font-bold tabular-nums",children:Ke})]}),jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(A=>{let de=A==="yes"?t.yesBid:t.noBid;return jsx("div",{className:"flex flex-1 flex-col gap-y-1",children:jsxs("button",{type:"button",onClick:()=>G(A),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${o===A?"border-bearish bg-bearish/10 text-bearish":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsx("span",{children:R(A==="yes"?"predict.trade.yes":"predict.trade.no")}),de!=null&&jsx("span",{className:"ml-1 opacity-70",children:O?O(Number(de)):`${parseFloat((Number(de)*100).toFixed(2))}\xA2`})]})},A)})}),jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsx("span",{className:"text-sm font-medium text-foreground",children:R("predict.trade.sellContracts")}),jsxs("div",{className:"flex items-center gap-x-2",children:[[25,50].map(A=>{let de=Math.pow(10,k);return jsxs("button",{type:"button",onClick:()=>{Q(Math.floor(h*A/100*de)/de);},className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:[A,"%"]},A)}),jsx("button",{type:"button",onClick:te,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:R("common.all")})]})]}),jsx(StyledInput,{"aria-label":"Sell quantity",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:bt,onChange:A=>Qe(A.target.value),onFocus:()=>{Fe.current=true;},onBlur:()=>{Fe.current=false,Te(isNaN(i)?"":String(i));},classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}}),ke&&m.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:m.map(A=>jsx("span",{className:"text-xs text-danger",children:A},A))})]}),jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-neutral-500",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:R("predict.trade.totalShares")}),jsx("span",{className:"tabular-nums text-foreground",children:y?"\u2013":`${he(w,k).toFixed(k)}${R("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:R("predict.trade.activeOrders")}),jsx("span",{className:"tabular-nums text-warning",children:y?"\u2013":S>0?`-${he(S,k).toFixed(k)}${R("predict.trade.sharesUnit")}`:`0${R("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:R("predict.trade.availableShares")}),jsx("span",{className:"tabular-nums text-success font-medium",children:y?"\u2013":`${he(h,k).toFixed(k)}${R("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:R("predict.trade.estReturn")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${a.toFixed(2)}`:"\u2013"})]})]}),n==="limit"&&c&&jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-medium text-primary",children:R("predict.trade.setExpiration")}),jsx(StyledSwitch,{size:"sm",color:"primary",isSelected:P,onValueChange:N,"aria-label":R("predict.trade.setExpiration")})]}),P&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":R("predict.trade.setExpiration"),selectedKeys:[I],onSelectionChange:A=>{let de=Array.from(A)[0];de&&M(de);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:xp.map(A=>jsx(SelectItem,{children:R(bp[A])},A))}),I==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(D)?void 0:D,onValueChange:U,minValue:1,step:1,formatOptions:Sp,classNames:{base:"flex-1",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 min-h-10",input:"text-sm"}}),jsx(Select,{"aria-label":"Duration unit",selectedKeys:[W],onSelectionChange:A=>{let de=Array.from(A)[0];de&&X(de);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:yp.map(A=>jsx(SelectItem,{children:R(kp[A])},A))})]})]})]}),jsx(Button,{color:"secondary",fullWidth:true,radius:"lg",size:"lg",isDisabled:Ve||Be&&!je&&(y||l||!ot||u),isLoading:Ve||Be&&!je&&(u||y||l),spinner:jsx(Spinner,{size:"sm",color:"current"}),onPress:Re,children:He})]}),jsx(Rn,{isOpen:Se.isOpen,onClose:Se.onClose,kycUrl:b})]})}function Wn({event:e,market:t,variant:r,initialOutcome:o,chain:n,slippageBps:i,onOutcomeChange:s,onSetupRequired:a,onSuccess:l,oddsFormatter:u}){let{outcome:d,orderType:p,quantity:m,limitPrice:c,estimatedReturn:f,pricePerShare:g,isMarketDataLoading:v,isSubmitting:x,authStatus:b,validation:w,supportsLimitOrder:S,kycRequired:h,needsKyc:y,needsSetup:k,kycUrl:P,totalShares:I,activeOrderShares:D,availableShares:W,isAvailableLoading:O,precision:G,expirationEnabled:j,expirationPreset:Q,customDuration:re,customDurationUnit:te,setOutcome:N,setOrderType:M,setQuantity:U,setLimitPrice:X,setSellAll:se,setExpirationEnabled:R,setExpirationPreset:ke,setCustomDuration:H,setCustomDurationUnit:Se,submit:bt}=_s({market:t,initialOutcome:o,slippageBps:i,onSuccess:l}),Te=useAuthCallback(bt),Fe=useCallback(Ye=>{N(Ye),s?.(Ye);},[N,s]),nt=useMemo(()=>e?Sn(e):void 0,[e]),ve=useMemo(()=>wn(t,{yesBid:d==="yes"?g:void 0,noBid:d==="no"?g:void 0}),[t,d,g]);return jsx(Ws,{event:nt,market:ve,variant:r,outcome:d,orderType:p,quantity:m,limitPrice:c,estimatedReturn:f,isMarketDataLoading:v,isSubmitting:x,authStatus:b,isValid:w.isValid,validationErrors:w.errors,supportsLimitOrder:S,kycRequired:h,needsKyc:y,needsSetup:k,onSetupRequired:a,kycUrl:P,totalShares:I,activeOrderShares:D,availableShares:W,isAvailableLoading:O,precision:G,expirationEnabled:j,expirationPreset:Q,customDuration:re,customDurationUnit:te,oddsFormatter:u,onOutcomeChange:Fe,onOrderTypeChange:M,onQuantityChange:U,onLimitPriceChange:X,onSellAll:se,onExpirationEnabledChange:R,onExpirationPresetChange:ke,onCustomDurationChange:H,onCustomDurationUnitChange:Se,onSubmit:Te})}var Fo="predict-sell";function $s({id:e=Fo}){return jsx(AsyncModal,{id:e,children:t=>jsx(Rp,{...t})})}function Rp({params:e,isOpen:t,onOpenChange:r}){let{t:o}=useTranslation(),{isMobile:n}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:n?"lg":"md",backdrop:"opaque",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{className:n?"":"p-2",children:[jsx(Wn,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,chain:e.chain,slippageBps:e.slippageBps,onSetupRequired:e.onSetupRequired,onSuccess:()=>r(false),variant:"flat"}),jsx("div",{className:"px-4 pb-4",children:jsx("button",{type:"button",onClick:()=>r(false),className:"w-full h-12 rounded-xl text-sm font-medium text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:o("common.cancel")})})]})})}):null}var zo=40,Kn=36,Jr=480,Wo=Jr-Kn;function js({event:e,walletAddress:t,onCancelOrder:r}){let{t:o}=useTranslation(),[n,i]=useState("positions"),s=useMemo(()=>e.markets?.map(p=>p.slug)??[],[e.markets]),{data:a}=usePositions({source:e.source,user:t??""}),l=useMemo(()=>!a?.positions||!t?0:s.length===0?a.positions.length:a.positions.filter(p=>p.market&&s.includes(p.market.slug)).length,[a?.positions,s,t]),d=[{key:"positions",label:l>0?`${o("predict.positions.title")} (${l})`:o("predict.positions.title")},{key:"orders",label:o("predict.openOrders.title")},{key:"trades",label:o("predict.tradeHistory.title")}];return jsxs("div",{className:"flex flex-col gap-y-2 mt-6 px-1 lg:px-4",children:[jsx("div",{className:"flex items-center gap-x-1 border-b border-border",children:d.map(p=>jsx("button",{type:"button",onClick:()=>i(p.key),className:cn$1("px-3 py-2 text-sm font-medium transition-colors cursor-pointer",n===p.key?"text-foreground border-b-2 border-primary":"text-neutral hover:text-foreground"),children:p.label},p.key))}),t?jsxs("div",{style:{height:Jr},children:[n==="positions"&&jsx(Bp,{source:e.source,walletAddress:t,marketSlugs:s}),n==="orders"&&jsx(zp,{source:e.source,walletAddress:t,marketSlugs:s,onCancelOrder:r}),n==="trades"&&jsx($p,{source:e.source,walletAddress:t})]}):jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:Jr},children:o("predict.trade.connectWallet")})]})}function Bp({source:e,walletAddress:t,marketSlugs:r}){let{t:o}=useTranslation(),{data:n,isLoading:i}=usePositions({source:e,user:t}),s=useMemo(()=>n?.positions?r.length===0?n.positions:n.positions.filter(a=>a.market&&r.includes(a.market.slug)):[],[n?.positions,r]);return i?jsx($o,{}):s.length===0?jsx(Uo,{message:o("predict.positions.empty")}):jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:Kn},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2 whitespace-nowrap",children:o("predict.positions.event")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.totalSize")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.value")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.avgPrice")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.markPrice")}),jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:o("predict.positions.pnl")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.payoutIfRight")}),jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:o("predict.positions.estSettlement")}),jsx("div",{className:"w-16 shrink-0"})]}),jsx(List,{style:{height:Wo},rowComponent:Hp,rowCount:s.length,rowHeight:zo,rowProps:{positions:s,closeLabel:o("predict.positions.close")}})]})}function Hp({index:e,style:t,positions:r,closeLabel:o}){let n=r[e];if(!n)return null;let i=n.pnl??0,s=n.pnl_percent??0,a=n.avg_price??0,l=n.current_price??0,u=i>0?"text-success":i<0?"text-danger":"text-foreground",d=i>0?"+":"",p=n.market?.outcomes?.[0]?.label??n.market?.question??"\u2014",m=n.side,c=n.size,f=n.size*l,g=n.market?.end_at?jp(n.market.end_at):"\u2014";return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-xs lg:text-sm",children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxs("div",{className:"flex flex-col gap-y-0.5",children:[jsx("span",{className:"text-foreground truncate font-medium",children:p}),jsx("span",{className:cn$1("text-[10px] font-medium",m.toLowerCase()==="yes"?"text-primary":"text-secondary"),children:m})]})}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:n.size}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",f.toFixed(2)]}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:Un(a)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:Un(l)}),jsxs("div",{className:cn$1("flex-[1.5] pr-2 text-right font-mono whitespace-nowrap",u),children:[d,"$",Math.abs(i).toFixed(2),jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",d,s.toFixed(1),"%)"]})]}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",c.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:g}),jsx("div",{className:"w-16 shrink-0 text-right",children:jsx("button",{type:"button",className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors rounded px-2 py-0.5 border border-border hover:border-foreground/40",children:o})})]})}function zp({source:e,walletAddress:t,marketSlugs:r,onCancelOrder:o}){let{t:n}=useTranslation(),{data:i,isLoading:s,fetchNextPage:a,hasNextPage:l}=useInfiniteOrders({source:e,wallet_address:t}),u=useCancelOrder(),d=useMemo(()=>{let x=i?.pages?.flatMap(S=>S.items)??[],b=new Set(["live","open","submitted","pending"]),w=x.filter(S=>b.has(S.status));return r.length>0&&(w=w.filter(S=>S.market_id&&r.includes(S.market_id))),w},[i?.pages,r]),p=useCallback(x=>{o?o(x.id):u.mutate({source:x.source,id:x.id});},[o,u]),m=d.length,c=m+(l?1:0),f=useCallback(x=>x<m,[m]),g=useCallback(async()=>{await a();},[a]),v=useInfiniteLoader({isRowLoaded:f,loadMoreRows:g,rowCount:c,threshold:5});return s?jsx($o,{}):d.length===0&&!l?jsx(Uo,{message:n("predict.openOrders.empty")}):jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:Kn},children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:n("predict.openOrders.side")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.openOrders.outcome")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.openOrders.type")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.openOrders.price")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.openOrders.filled")}),jsx("div",{className:"w-20 shrink-0 pr-2",children:n("predict.openOrders.status")}),jsx("div",{className:"w-16 shrink-0"})]}),jsx(List,{style:{height:Wo},onRowsRendered:v,rowComponent:Wp,rowCount:c,rowHeight:zo,rowProps:{orders:d,itemCount:m,onCancel:p,isCancelling:u.isPending,cancelLabel:n("predict.openOrders.cancel")}})]})}function Wp({index:e,style:t,orders:r,itemCount:o,onCancel:n,isCancelling:i,cancelLabel:s}){if(e>=o)return jsx("div",{style:t,className:"flex justify-center items-center",children:jsx(Spinner,{size:"sm"})});let a=r[e];if(!a)return null;let l=a.side==="BUY";return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:jsx("span",{className:cn$1("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",l?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:a.side})}),jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:a.outcome??"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-neutral capitalize",children:a.order_type??"limit"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:a.price?Un(parseFloat(a.price)):"\u2014"}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:[a.size_matched??"0","/",a.original_size??"\u2014"]}),jsx("div",{className:"w-20 shrink-0 pr-2",children:jsx(Up,{status:a.status})}),jsx("div",{className:"w-16 shrink-0 text-right",children:jsx("button",{type:"button",onClick:()=>n(a),disabled:i,className:"text-[10px] text-danger hover:text-danger/80 cursor-pointer disabled:opacity-50 transition-colors",children:i?jsx(Spinner,{size:"sm"}):s})})]})}function Up({status:e}){return jsx("span",{className:cn$1("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium capitalize",{live:"bg-success/10 text-success",open:"bg-success/10 text-success",submitted:"bg-warning/10 text-warning",pending:"bg-warning/10 text-warning",matched:"bg-primary/10 text-primary",cancelled:"bg-neutral/10 text-neutral",failed:"bg-danger/10 text-danger",expired:"bg-neutral/10 text-neutral"}[e]??"bg-neutral/10 text-neutral"),children:e})}function $p({source:e,walletAddress:t}){let{t:r}=useTranslation(),{data:o,isLoading:n,fetchNextPage:i,hasNextPage:s}=useInfiniteTrades({source:e,wallet:t,limit:50}),a=useMemo(()=>o?.pages?.flatMap(c=>c.items)??[],[o?.pages]),l=a.length,u=l+(s?1:0),d=useCallback(c=>c<l,[l]),p=useCallback(async()=>{await i();},[i]),m=useInfiniteLoader({isRowLoaded:d,loadMoreRows:p,rowCount:u,threshold:5});return n?jsx($o,{}):a.length===0&&!s?jsx(Uo,{message:r("predict.tradeHistory.empty")}):jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:Kn},children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:r("predict.tradeHistory.side")}),jsx("div",{className:"flex-1 pr-2",children:r("predict.tradeHistory.outcome")}),jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.price")}),jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.qty")}),jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.total")}),jsx("div",{className:"flex-[1.5] pr-2 text-right",children:r("predict.tradeHistory.time")})]}),jsx(List,{style:{height:Wo},onRowsRendered:m,rowComponent:Kp,rowCount:u,rowHeight:zo,rowProps:{trades:a,itemCount:l}})]})}function Kp({index:e,style:t,trades:r,itemCount:o}){if(e>=o)return jsx("div",{style:t,className:"flex justify-center items-center",children:jsx(Spinner,{size:"sm"})});let n=r[e];if(!n)return null;let i=n.side?.toUpperCase()==="BUY",s=Vp(n.timestamp),a=n.price??0,l=n.usd_size??0;return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:jsx("span",{className:cn$1("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",i?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:n.side})}),jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:n.outcome??"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Un(a)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:n.size}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",l.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:s})]})}function Uo({message:e}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:Jr},children:e})}function $o(){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:Jr},children:Array.from({length:6}).map((e,t)=>jsx(Skeleton,{className:"h-8 w-full rounded-md"},t))})}function Un(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(1)}\xA2`}function Vp(e){let t=new Date(e*1e3),r=(t.getMonth()+1).toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),n=t.getHours().toString().padStart(2,"0"),i=t.getMinutes().toString().padStart(2,"0");return `${r}/${o} ${n}:${i}`}function jp(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return "\u2014"}}var qs=`
|
|
74
|
+
`).map((r,o)=>jsxs("span",{children:[o>0&&jsx("br",{className:"hidden sm:block"}),r,o===0?" ":""]},o))})]}),jsx("div",{className:"evt-stat-grid",style:e?{animation:"evtStatsEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:"0.1s"}:{},children:Cu.map((r,o)=>jsxs("div",{style:{padding:"14px 16px",background:e?`linear-gradient(to bottom, ${r.gradientFrom}, ${r.gradientTo})`:"rgba(255,255,255,0.02)",borderRight:o%2===0?"1px solid rgba(39,39,42,0.4)":"none",borderBottom:o<2?"1px solid rgba(39,39,42,0.4)":"none",...e?{animation:"evtStatCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:`${150+o*60}ms`}:{}},children:[jsx("div",{className:"evt-stat-val",style:{fontWeight:700,fontVariantNumeric:"tabular-nums",color:e?r.valueColor:"transparent",display:"flex",alignItems:"center"},children:e?r.format(e[r.key]):jsx("div",{style:{height:16,width:56,borderRadius:4,background:"rgba(255,255,255,0.06)",animation:"evtStatCardEnter 0.6s ease-out both",animationDelay:`${o*80}ms`}})}),jsx("div",{className:"evt-stat-label",style:{fontWeight:500,color:e?"#71717a":"transparent",marginTop:2,display:"flex",alignItems:"center"},children:e?t(r.labelKey):jsx("div",{style:{height:10,width:64,borderRadius:4,background:"rgba(255,255,255,0.04)",animation:"evtStatCardEnter 0.6s ease-out both",animationDelay:`${50+o*80}ms`}})})]},r.key))})]})]})}function Ts({event:e,market:t,position:r,onSuccess:o,onCancel:n}){let{t:i}=useTranslation(),{mutateAsync:s}=useRedeemPosition(),{evmAddress:a}=pr(),l=useWallets(),[u,d]=useState("idle"),[p,m]=useState(null),c=t.provider_meta?.["polymarket.conditionId"],f=t.provider_meta?.["polymarket.negRisk"]??false,g=a??"",v=useMemo(()=>l.find(A=>A.chainNamespace===ChainNamespace.EVM&&A.isConnected),[l]),x=Es(r.side,t.outcomes),w=t.outcomes?.[x]?.label??r.side,S=t.result!=null?Es(t.result,t.outcomes):-1,y=(S>=0?t.outcomes?.[S]:void 0)?.label??t.result??"",k=t.result!=null?x===S:true,P=useMemo(()=>k?r.size:0,[k,r.size]),O=useCallback(async()=>{if(!(!c||!g||!v)){d("pending"),m(null);try{let A=await v.getEip1193Provider();if(!A)throw new Error("EIP-1193 provider unavailable");await s({wallet_address:g,condition_id:c,neg_risk:f,signMessage:async G=>await A.request({method:"personal_sign",params:[G,g]}),signTypedData:async G=>await A.request({method:"eth_signTypedData_v4",params:[g,JSON.stringify(G)]})}),d("success"),o?.();}catch(A){d("error"),m(A instanceof Error?A.message:i("predict.redeem.error"));}}},[c,g,f,v,s,o,i]),F=useAuthCallback(O),W=u==="idle"&&!!c&&!!g&&!!v&&r.redeemable;return jsxs("div",{className:"flex flex-col gap-4 p-4",children:[jsx("div",{className:"text-base font-medium text-white",children:e?.title??t.question}),jsxs("div",{className:"flex flex-col gap-2 rounded-xl bg-[rgba(39,39,42,0.4)] p-3",children:[jsx(Hn,{label:i("predict.positions.side"),value:w,valueClassName:k?"text-green-400":"text-red-400"}),t.result!=null&&jsx(Hn,{label:i("predict.redeem.result"),value:y,valueClassName:"text-green-400"}),jsx(Hn,{label:i("predict.positions.size"),value:r.size.toFixed(2)}),jsx(Hn,{label:i("predict.redeem.expectedPayout"),value:`$${P.toFixed(2)}`,valueClassName:P>0?"text-green-400":"text-zinc-400"})]}),!k&&P===0&&jsx("p",{className:"text-sm text-zinc-500",children:i("predict.redeem.noWinnings")}),u==="error"&&p&&jsx("p",{className:"text-sm text-red-400",children:p}),u==="success"&&jsx("p",{className:"text-sm text-green-400",children:i("predict.redeem.success")}),jsxs("div",{className:"flex flex-col gap-2",children:[u!=="success"&&jsx(Button,{color:"success",className:"w-full h-12 rounded-xl text-sm font-semibold",isDisabled:!W,isLoading:u==="pending",onPress:F,spinner:jsx(Spinner,{size:"sm",color:"current"}),children:i("predict.redeem.confirm")}),n&&u!=="success"&&jsx("button",{type:"button",onClick:n,className:"w-full h-12 rounded-xl text-sm font-medium text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:i("common.cancel")}),u==="success"&&n&&jsx(Button,{className:"w-full h-12 rounded-xl text-sm font-medium",onPress:n,children:i("common.ok")})]})]})}function Hn({label:e,value:t,valueClassName:r="text-white"}){return jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm text-zinc-400",children:e}),jsx("span",{className:`text-sm font-medium ${r}`,children:t})]})}function Es(e,t){let r=e.toLowerCase();if(r==="yes")return 0;if(r==="no"||!t)return 1;let o=t.findIndex(n=>n.label.toLowerCase()===r);return o>=0?o:1}var zu="predict-redeem";function Rs({id:e=zu}){return jsx(AsyncModal,{id:e,children:t=>jsx(Wu,{...t})})}function Wu({params:e,isOpen:t,onOpenChange:r}){let{t:o}=useTranslation(),{isMobile:n}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:n?"lg":"md",backdrop:"opaque",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{className:n?"":"p-2",children:[jsxs("div",{className:"px-4 pt-4 pb-1",children:[jsx("h3",{className:"text-lg font-semibold text-white",children:o("predict.redeem.title")}),jsx("p",{className:"text-sm text-zinc-400 mt-1",children:o("predict.redeem.description")})]}),jsx(Ts,{event:e.event,market:e.market,position:e.position,onSuccess:()=>{setTimeout(()=>r(false),1500);},onCancel:()=>r(false)})]})})}):null}function Os({market:e,initialOutcome:t="yes",slippageBps:r=100,onSuccess:o}){let{t:n}=useTranslation(),i=useRef(o);i.current=o;let{status:s}=useAuth(),a=useWallets(),l=usePredictClient(),u=useContext(PolymarketContext),d=useQueryClient(),p=e.source,m=p==="polymarket",c=a.find(M=>M.chainNamespace===ChainNamespace.SOLANA&&M.isConnected),f=a.find(M=>M.chainNamespace===ChainNamespace.EVM&&M.isConnected&&"switchChain"in M),g=s==="authenticated",v=c?.address,x=f?.address,[b,w]=useState(t),[S,h]=useState("market"),[y,k]=useState(NaN),[P,O]=useState(NaN),[F,W]=useState(false),[A,G]=useState(false),[q,Y]=useState(null),[re,te]=useState(null),[N,C]=useState(false),[U,X]=useState(false),[se,_]=useState("1h"),[Se,B]=useState(30),[Pe,yt]=useState("minutes"),Le=useMemo(()=>{if(p!=="polymarket")return;let M=e.provider_meta?.["polymarket.clobTokenIds"];return M?(typeof M=="string"?JSON.parse(M):M)[b==="yes"?0:1]:void 0},[p,e.provider_meta,b]),{data:rt,isLoading:nt}=useTickSize(Le),he=rt?.minimum_tick_size?String(rt.minimum_tick_size):"0.01",{data:je,isLoading:Qe}=useFeeRate(Le),Re=String(je?.base_fee??0),{data:dt}=useRebateConfig(),Nt=dt?.builder_enabled&&dt.builder_code?dt.builder_code:void 0,Xe=false,Je=null,Be=false,we,ut,Ze;try{let M=pr();Xe=M.kalshiKycVerified,Je=M.kalshiKycUrl,Be=M.polymarketSetupVerified,we=M.polymarketSafeAddress,ut=M.polymarketWalletKind,Ze=M.polymarketWalletAddress;}catch{}let _t=p==="kalshi"&&!Xe,E=p==="polymarket"&&!Be,de=useCallback(async()=>{if(!f||!u)return null;let M=await f.getEip1193Provider();if(!M)return null;let Ne=ut==="deposit"&&!!Ze,$e=!Ne&&!!we,st={address:f.address,signatureType:Ne?3:$e?2:0,signTypedData:async(Ge,Et,St,Ee)=>{let wt=[];"name"in Ge&&wt.push({name:"name",type:"string"}),"version"in Ge&&wt.push({name:"version",type:"string"}),"chainId"in Ge&&wt.push({name:"chainId",type:"uint256"}),"verifyingContract"in Ge&&wt.push({name:"verifyingContract",type:"address"}),"salt"in Ge&&wt.push({name:"salt",type:"bytes32"});let at={EIP712Domain:wt,...Et};return await M.request({method:"eth_signTypedData_v4",params:[f.address,JSON.stringify({domain:Ge,types:at,primaryType:St,message:Ee})]})}};return u.credentials??await u.authenticate(st)},[we,ut,Ze,f,u]),{data:He}=useRealtimeOrderbook({slug:e.slug,source:p,outcome:b},{enabled:e.status==="open"}),qe=useMemo(()=>{let M=pickBestBid(He,b);if(M!=null&&M>0)return M;let Ne=b==="yes"?0:1,$e=e.outcomes[Ne];return $e?.best_bid??$e?.price??.5},[He,e.outcomes,b]),ze=p==="kalshi"?v??"":x??"",{data:Zt,isLoading:er}=usePositions({source:p,user:ze},{enabled:!!ze,refetchInterval:3e4}),Wr=useCallback(async()=>{let M=await de();return M?await buildPolymarketL2Headers(M.address,{apiKey:M.apiKey,secret:M.secret,passphrase:M.passphrase,method:"GET",requestPath:"/data/orders",body:""}):{}},[de]),{data:ot,isLoading:Ur}=useAvailableShares({source:p,user:ze,market:e.slug,side:b},p==="polymarket"?{getHeaders:Wr}:void 0,{enabled:!!ze&&!!e.slug,refetchOnMount:"always"}),D=ot?.total_shares??0,xe=ot?.active_order_shares??0,Ae=ot?.available_shares??0,et=useMemo(()=>p==="polymarket"?getPolymarketSharesPrecision(he):ot?.precision??0,[p,he,ot?.precision]),$r=Ur||er,co=e.provider_meta?.["dflow.yesMint"]??"",uo=e.provider_meta?.["dflow.noMint"]??"",Wt=SOLANA_TOKENS.stablecoins.USDC.address,Nr=e.provider_meta?.["dflow.collateralMint"]||"",po=b==="yes"?co:uo,Kr=useMemo(()=>Zt?Zt.positions.find(M=>M.side?.toLowerCase()===b&&M.market?.slug===e.slug)??null:null,[Zt,e.slug,b])?.market?.provider_meta,Ut=Kr?.["dflow.outcomeMint"]||po,rr=Kr?.["dflow.collateralMint"]||Nr,nr=Ut,or=rr||Wt,Cr=useMemo(()=>isNaN(y)||y<=0?"0":String(Math.round(y*1e6)),[y]),mo=p==="kalshi"&&!!nr&&!!or&&!!v&&Cr!=="0",{refetch:hn}=useDFlowQuote({inputMint:nr,outputMint:or,amount:Cr,userPublicKey:v??"",slippageBps:100},{enabled:mo}),ir=useMemo(()=>isNaN(y)||y<=0?0:y,[y]),it=useMemo(()=>walkOrderbook({orderbook:He,outcome:b,side:"sell",sharesNeeded:ir,slippageBps:r}),[He,b,ir,r]),vn=useMemo(()=>it.status==="ok"&&it.worstPrice!=null&&it.worstPrice>0?it.worstPrice:qe,[it,qe]),fo=useMemo(()=>{if(isNaN(y)||y<=0)return 0;let M=S==="limit"&&m&&!isNaN(P)?P:qe;return y*M},[y,S,m,P,qe]),Mr=useCallback(M=>{w(M),O(NaN),k(NaN),G(false);},[]);useEffect(()=>{Mr(t);},[t,Mr]);let Vr=useCallback(M=>{h(M);},[]);useEffect(()=>{S==="limit"&&O(Math.round(qe*1e4)/1e4);},[S,b]);let xn=useCallback(M=>{if(G(false),isNaN(M)){k(NaN);return}k(ve(Math.max(0,M),et));},[et]),bn=useCallback(()=>{G(true),k(ve(Ae,et));},[Ae,et]),go=useCallback(M=>{if(isNaN(M)){O(NaN);return}O(Math.round(M*1e4)/1e4);},[]),L=useCallback(()=>{k(NaN),O(NaN),h("market"),G(false),X(false),_("1h"),B(30),yt("minutes");},[]),We=useMemo(()=>{let M=[];return isNaN(y)||y<=0?M.push(n("predict.trade.minQuantity",{amount:Cn})):y<Cn&&M.push(n("predict.trade.minQuantity",{amount:Cn})),e.status!=="open"&&M.push(n("predict.trade.marketNotActive")),!isNaN(y)&&y>0&&!A&&y>Ae&&M.push(n("predict.trade.insufficientSharesDetail",{total:ve(D,et).toFixed(et),active:ve(xe,et).toFixed(et),available:ve(Ae,et).toFixed(et)})),S==="limit"&&m&&(isNaN(P)||P<.01||P>.99)&&M.push(n("predict.trade.limitPriceRange")),S==="limit"&&m&&U&&se==="custom"&&(isNaN(Se)||Se<=0)&&M.push(n("predict.trade.expiration.invalidDate")),p==="polymarket"&&S==="market"&&!isNaN(y)&&y>0&&(it.status==="insufficient_liquidity"?M.push(n("predict.trade.insufficientLiquidity",{available:ve(it.totalAvailable,2)})):it.status==="exceeds_slippage"&&M.push(n("predict.trade.priceImpactTooHigh",{impact:(it.priceImpactBps/100).toFixed(2),slippage:(r/100).toFixed(2)}))),{isValid:M.length===0,errors:M}},[y,e.status,Ae,D,xe,A,S,m,P,U,se,Se,et,p,it,r,n]),{mutateAsync:Ue}=useDFlowSubmit(),{data:Ct}=useOrder({id:q??"",source:p},{enabled:!!q}),Er=useCallback(async()=>{if(!re||!v||!c)return;let{cashAmount:M,collateral:Ne}=re;te(null);try{let st=(await l.createDFlowQuote({inputMint:Ne,outputMint:Wt,amount:M,userPublicKey:v,slippageBps:100}))?.transaction;if(!st)return;let Ge=Uint8Array.from(atob(st),St=>St.charCodeAt(0)),Et=await c.signTransaction(Ge);await Ue({signedTransaction:btoa(String.fromCharCode(...Et)),orderContext:{user_public_key:v,input_mint:Ne,output_mint:Wt,amount:M,price:"1",side:"SELL",outcome:"",market_slug:"",slippage_bps:100}});}catch{}},[re,v,c,l,Ue,Wt]),Mt=useCallback(()=>{d.invalidateQueries({queryKey:["predict","positions"]}),d.invalidateQueries({queryKey:["predict","orders"]}),d.invalidateQueries({queryKey:["predict","available-shares"]});},[d]);useEffect(()=>{if(!Ct||!q)return;let{status:M}=Ct;M==="closed"?(Y(null),re?Er().finally(()=>{W(false),toast.success(n("predict.trade.submitSuccess")),mr(),Mt(),L(),i.current?.();}):(W(false),toast.success(n("predict.trade.submitSuccess")),mr(),Mt(),L(),i.current?.())):(M==="failed"||M==="expired")&&(W(false),Y(null),te(null),toast.error(n("predict.trade.submitError")));},[Ct,q,re,Er,Mt,L,n]);let It=useCallback(async()=>{if(!v||!c)return;if(!nr||!or){toast.error("Missing token mint addresses"),W(false);return}if(!Xe){C(true),W(false);return}let $e=(await hn()).data,st=$e?.transaction;if(!st){toast.error(n("predict.trade.submitError")),W(false);return}if(rr&&rr!==Wt){let Ee=String($e?.outAmount??"");Ee&&Ee!=="0"&&te({cashAmount:Ee,collateral:rr});}let Ge=Uint8Array.from(atob(st),Ee=>Ee.charCodeAt(0)),Et=await c.signTransaction(Ge),St=await Ue({signedTransaction:btoa(String.fromCharCode(...Et)),orderContext:{user_public_key:v,input_mint:nr,output_mint:or,amount:Cr,price:String(qe),side:"SELL",outcome:b==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});Y(St.signature);},[v,c,hn,Ue,nr,or,Cr,qe,b,e.slug,rr,Wt,n,Xe]),kt=useCallback(async()=>{if(!f||!u)return;let M=f.chain,Ne=M!==Chain.POLYGON;Ne&&await f.switchChain(Chain.POLYGON);try{let $e=await f.getEip1193Provider();if(!$e){toast.error(n("predict.trade.submitError")),W(!1);return}let st=ut==="deposit"&&!!Ze,Ge=!st&&!!we,Et=st?Ze:we,St={address:f.address,signatureType:st?3:Ge?2:0,signTypedData:async(Kt,yn,bo,yo)=>{let Lr=[];"name"in Kt&&Lr.push({name:"name",type:"string"}),"version"in Kt&&Lr.push({name:"version",type:"string"}),"chainId"in Kt&&Lr.push({name:"chainId",type:"uint256"}),"verifyingContract"in Kt&&Lr.push({name:"verifyingContract",type:"address"}),"salt"in Kt&&Lr.push({name:"salt",type:"bytes32"});let ec={EIP712Domain:Lr,...yn};return await $e.request({method:"eth_signTypedData_v4",params:[f.address,JSON.stringify({domain:Kt,types:ec,primaryType:bo,message:yo})]})}},Ee=await de();if(!Ee){toast.error(n("predict.trade.submitError")),W(!1);return}let wt=b==="yes"?0:1,at="",$t=e.provider_meta?.["polymarket.clobTokenIds"];$t&&(at=(typeof $t=="string"?JSON.parse($t):$t)[wt]??"");let Tr=e.provider_meta?.["polymarket.negRisk"]??!1,jr=S==="limit"&&!isNaN(P)?P:vn,sr=Tn(jr,he),vo={tokenId:at,price:sr,size:y,side:"SELL",orderType:S==="limit"?U?"GTD":"GTC":"FOK",tickSize:he,negRisk:Tr,...Et&&{funderAddress:Et},...Nt&&{builderCode:Nt},...S==="limit"&&U&&{expiration:En(se,Se,Pe)}},xo;if(st)xo=await buildSignedV2OrderPayload({signer:St,depositWalletAddress:Et,input:vo,owner:Ee.apiKey});else {let Kt=buildCtfExchangeDomain(Tr),yn=buildOrderMessage({...vo,signerAddress:St.address,signatureType:St.signatureType,feeRateBps:Re}),bo=await St.signTypedData(Kt,CTF_ORDER_TYPES,"Order",yn),yo=buildSignedOrder(yn,bo,vo.orderType);xo=buildClobPayload(yo,Ee.apiKey);}await l.executePolymarketOrder({payload:xo,l2_api_key:Ee.apiKey,l2_secret:Ee.secret,l2_passphrase:Ee.passphrase,signer_address:Ee.address,owner:Ee.apiKey}),Mt(),toast.success(n("predict.trade.submitSuccess")),mr(),L(),W(!1),i.current?.();}finally{Ne&&M&&f.switchChain(M).catch(()=>{});}},[f,u,de,b,e.provider_meta,S,P,vn,y,l,Mt,U,se,Se,Pe,L,n,he,Re,e.slug,we,ut,Ze,Nt]),ho=useCallback(async()=>{if(!(!We.isValid||!g)){W(true),Y(null),C(false);try{p==="kalshi"?await It():await kt();}catch(M){let Ne=M instanceof Error?M.message:"",$e=p==="polymarket"&&Ne?Ln(Ne,n,"sell"):Ne||void 0;toast.error($e||n("predict.trade.submitError")),W(false);}}},[We.isValid,g,p,It,kt,n]);return {outcome:b,orderType:S,quantity:y,limitPrice:P,shares:ir,estimatedReturn:fo,pricePerShare:qe,isMarketDataLoading:p==="polymarket"&&(Qe||nt),isSubmitting:F,authStatus:s,validation:We,supportsLimitOrder:m,kycRequired:N,needsKyc:_t,needsSetup:E,kycUrl:Je,totalShares:D,activeOrderShares:xe,availableShares:Ae,isAvailableLoading:$r,isSellAll:A,precision:et,expirationEnabled:U,expirationPreset:se,customDuration:Se,customDurationUnit:Pe,setOutcome:Mr,setOrderType:Vr,setQuantity:xn,setLimitPrice:go,setSellAll:bn,setExpirationEnabled:X,setExpirationPreset:_,setCustomDuration:B,setCustomDurationUnit:yt,submit:ho}}var wp=["5m","1h","12h","24h","eod","custom"],Pp={"5m":"predict.trade.expiration.5m","1h":"predict.trade.expiration.1h","12h":"predict.trade.expiration.12h","24h":"predict.trade.expiration.24h",eod:"predict.trade.expiration.eod",custom:"predict.trade.expiration.custom"},Np=["minutes","hours","days"],Cp={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},Mp={maximumFractionDigits:0};function $s({event:e,market:t,variant:r="bordered",outcome:o,orderType:n,quantity:i,limitPrice:s,estimatedReturn:a,isMarketDataLoading:l,isSubmitting:u,authStatus:d,isValid:p,validationErrors:m,supportsLimitOrder:c,kycRequired:f,needsKyc:g,needsSetup:v,onSetupRequired:x,kycUrl:b,totalShares:w,activeOrderShares:S,availableShares:h,isAvailableLoading:y,precision:k,expirationEnabled:P,expirationPreset:O,customDuration:F,customDurationUnit:W,oddsFormatter:A,onOutcomeChange:G,onOrderTypeChange:q,onQuantityChange:Y,onLimitPriceChange:re,onSellAll:te,onExpirationEnabledChange:N,onExpirationPresetChange:C,onCustomDurationChange:U,onCustomDurationUnitChange:X,onSubmit:se}){let{t:_}=useTranslation(),[Se,B]=useState(false),Pe=useDisclosure(),[yt,Le]=useState(""),rt=useRef(false);useEffect(()=>{rt.current||Le(isNaN(i)?"":String(i));},[i]);let[nt,he]=useState(""),je=useRef(false);useEffect(()=>{je.current||(isNaN(s)?he(""):he(String(parseFloat((s*100).toFixed(2)))));},[s]);let Qe=useCallback(E=>{if(E!==""&&!/^\d*\.?\d{0,2}$/.test(E))return;if(he(E),E===""||E==="."){re(NaN);return}let He=parseFloat(E);isNaN(He)||re(He/100);},[re]),Re=useCallback(E=>{let de=new RegExp(`^\\d*\\.?\\d{0,${k}}$`);if(E!==""&&!de.test(E))return;if(Le(E),B(false),E===""||E==="."){Y(NaN);return}let He=parseFloat(E);isNaN(He)||Y(He);},[Y,k]);useEffect(()=>{f&&!Pe.isOpen&&Pe.onOpen();},[f]);let dt=useMemo(()=>{let E=o==="yes"?t.yesBid:t.noBid;return E!=null?parseFloat((Number(E)*100).toFixed(2)):null},[o,t]),Nt=o==="yes"?t.yesBid:t.noBid,Xe=Nt!=null&&A?A(Number(Nt)):dt!=null?`${dt} \xA2`:null,Je=!isNaN(i)&&i>0,Be=d==="authenticated",we=d==="authenticating"||d==="deauthenticating",ut=Be&&(g||v),Ze=useMemo(()=>{if(we)return _("predict.trade.checkingLogin");if(!Be)return _("predict.trade.loginToTrade");if(g)return _("predict.trade.kycRequired");if(v)return _("predict.trade.setupRequired");if(y)return _("predict.trade.loadingBalance");if(l)return _("predict.trade.loadingMarketData");if(u)return _("predict.trade.submitting");if(f)return _("predict.trade.kycRequired");if(!Je)return _("predict.trade.enterAmount");let E=_(o==="yes"?"predict.trade.yes":"predict.trade.no");return `${_("predict.trade.sell")} ${E}`},[we,Be,g,v,y,l,u,f,Je,o,_]),_t=()=>{if(!Be){B(false),se();return}if(g){Pe.onOpen();return}if(v&&x){B(false),x();return}if(f){Pe.onOpen();return}if(!p){B(true);return}B(false),se();};return jsxs(Fragment,{children:[jsxs("div",{className:"flex w-full flex-col gap-y-4 p-4",style:r==="bordered"?{borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",transition:"border-color 0.2s"}:void 0,onMouseEnter:E=>{r==="bordered"&&(E.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:E=>{r==="bordered"&&(E.currentTarget.style.borderColor="rgba(39,39,42,0.6)");},children:[e&&jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxs("span",{className:"text-bearish",children:[_("predict.trade.sell")," ",_(o==="yes"?"predict.trade.yes":"predict.trade.no")]}),jsxs("span",{className:"text-foreground",children:[" \xB7 ",t.yesSubTitle]})]})]})]}),jsxs("div",{className:"flex items-center justify-between",children:[c?jsxs(Tabs,{variant:"underlined",selectedKey:n,onSelectionChange:E=>q(E),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsx(Tab,{title:_("predict.trade.market")},"market"),jsx(Tab,{title:_("predict.trade.limit")},"limit")]}):jsx("span",{className:"text-sm font-medium text-foreground",children:_("predict.trade.market")}),n==="limit"&&c?jsx(StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:nt,onChange:E=>Qe(E.target.value),onFocus:()=>{je.current=true;},onBlur:()=>{je.current=false,isNaN(s)?he(""):he(String(parseFloat((s*100).toFixed(2))));},endContent:jsx("span",{className:"text-xl font-bold tabular-nums text-foreground",children:"\xA2"}),classNames:{base:"w-28",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 rounded-lg px-2 h-9 min-h-9",input:"text-xl font-bold tabular-nums text-right"}}):Xe!=null&&jsx("span",{className:"text-xl font-bold tabular-nums",children:Xe})]}),jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(E=>{let de=E==="yes"?t.yesBid:t.noBid;return jsx("div",{className:"flex flex-1 flex-col gap-y-1",children:jsxs("button",{type:"button",onClick:()=>G(E),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${o===E?"border-bearish bg-bearish/10 text-bearish":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsx("span",{children:_(E==="yes"?"predict.trade.yes":"predict.trade.no")}),de!=null&&jsx("span",{className:"ml-1 opacity-70",children:A?A(Number(de)):`${parseFloat((Number(de)*100).toFixed(2))}\xA2`})]})},E)})}),jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsx("span",{className:"text-sm font-medium text-foreground",children:_("predict.trade.sellContracts")}),jsxs("div",{className:"flex items-center gap-x-2",children:[[25,50].map(E=>{let de=Math.pow(10,k);return jsxs("button",{type:"button",onClick:()=>{Y(Math.floor(h*E/100*de)/de);},className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:[E,"%"]},E)}),jsx("button",{type:"button",onClick:te,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:_("common.all")})]})]}),jsx(StyledInput,{"aria-label":"Sell quantity",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:yt,onChange:E=>Re(E.target.value),onFocus:()=>{rt.current=true;},onBlur:()=>{rt.current=false,Le(isNaN(i)?"":String(i));},classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}}),Se&&m.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:m.map(E=>jsx("span",{className:"text-xs text-danger",children:E},E))})]}),jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-neutral-500",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:_("predict.trade.totalShares")}),jsx("span",{className:"tabular-nums text-foreground",children:y?"\u2013":`${ve(w,k).toFixed(k)}${_("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:_("predict.trade.activeOrders")}),jsx("span",{className:"tabular-nums text-warning",children:y?"\u2013":S>0?`-${ve(S,k).toFixed(k)}${_("predict.trade.sharesUnit")}`:`0${_("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:_("predict.trade.availableShares")}),jsx("span",{className:"tabular-nums text-success font-medium",children:y?"\u2013":`${ve(h,k).toFixed(k)}${_("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:_("predict.trade.estReturn")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${a.toFixed(2)}`:"\u2013"})]})]}),n==="limit"&&c&&jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-medium text-primary",children:_("predict.trade.setExpiration")}),jsx(StyledSwitch,{size:"sm",color:"primary",isSelected:P,onValueChange:N,"aria-label":_("predict.trade.setExpiration")})]}),P&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":_("predict.trade.setExpiration"),selectedKeys:[O],onSelectionChange:E=>{let de=Array.from(E)[0];de&&C(de);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:wp.map(E=>jsx(SelectItem,{children:_(Pp[E])},E))}),O==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(F)?void 0:F,onValueChange:U,minValue:1,step:1,formatOptions:Mp,classNames:{base:"flex-1",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 min-h-10",input:"text-sm"}}),jsx(Select,{"aria-label":"Duration unit",selectedKeys:[W],onSelectionChange:E=>{let de=Array.from(E)[0];de&&X(de);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Np.map(E=>jsx(SelectItem,{children:_(Cp[E])},E))})]})]})]}),jsx(Button,{color:"secondary",fullWidth:true,radius:"lg",size:"lg",isDisabled:we||Be&&!ut&&(y||l||!Je||u),isLoading:we||Be&&!ut&&(u||y||l),spinner:jsx(Spinner,{size:"sm",color:"current"}),onPress:_t,children:Ze})]}),jsx(Rn,{isOpen:Pe.isOpen,onClose:Pe.onClose,kycUrl:b})]})}function Wn({event:e,market:t,variant:r,initialOutcome:o,chain:n,slippageBps:i,onOutcomeChange:s,onSetupRequired:a,onSuccess:l,oddsFormatter:u}){let{outcome:d,orderType:p,quantity:m,limitPrice:c,estimatedReturn:f,pricePerShare:g,isMarketDataLoading:v,isSubmitting:x,authStatus:b,validation:w,supportsLimitOrder:S,kycRequired:h,needsKyc:y,needsSetup:k,kycUrl:P,totalShares:O,activeOrderShares:F,availableShares:W,isAvailableLoading:A,precision:G,expirationEnabled:q,expirationPreset:Y,customDuration:re,customDurationUnit:te,setOutcome:N,setOrderType:C,setQuantity:U,setLimitPrice:X,setSellAll:se,setExpirationEnabled:_,setExpirationPreset:Se,setCustomDuration:B,setCustomDurationUnit:Pe,submit:yt}=Os({market:t,initialOutcome:o,slippageBps:i,onSuccess:l}),Le=useAuthCallback(yt),rt=useCallback(je=>{N(je),s?.(je);},[N,s]),nt=useMemo(()=>e?Sn(e):void 0,[e]),he=useMemo(()=>wn(t,{yesBid:d==="yes"?g:void 0,noBid:d==="no"?g:void 0}),[t,d,g]);return jsx($s,{event:nt,market:he,variant:r,outcome:d,orderType:p,quantity:m,limitPrice:c,estimatedReturn:f,isMarketDataLoading:v,isSubmitting:x,authStatus:b,isValid:w.isValid,validationErrors:w.errors,supportsLimitOrder:S,kycRequired:h,needsKyc:y,needsSetup:k,onSetupRequired:a,kycUrl:P,totalShares:O,activeOrderShares:F,availableShares:W,isAvailableLoading:A,precision:G,expirationEnabled:q,expirationPreset:Y,customDuration:re,customDurationUnit:te,oddsFormatter:u,onOutcomeChange:rt,onOrderTypeChange:C,onQuantityChange:U,onLimitPriceChange:X,onSellAll:se,onExpirationEnabledChange:_,onExpirationPresetChange:Se,onCustomDurationChange:B,onCustomDurationUnitChange:Pe,onSubmit:Le})}var Fo="predict-sell";function Vs({id:e=Fo}){return jsx(AsyncModal,{id:e,children:t=>jsx(Dp,{...t})})}function Dp({params:e,isOpen:t,onOpenChange:r}){let{t:o}=useTranslation(),{isMobile:n}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:n?"lg":"md",backdrop:"opaque",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{className:n?"":"p-2",children:[jsx(Wn,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,chain:e.chain,slippageBps:e.slippageBps,onSetupRequired:e.onSetupRequired,onSuccess:()=>r(false),variant:"flat"}),jsx("div",{className:"px-4 pb-4",children:jsx("button",{type:"button",onClick:()=>r(false),className:"w-full h-12 rounded-xl text-sm font-medium text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:o("common.cancel")})})]})})}):null}var zo=40,Kn=36,rn=480,Wo=rn-Kn;function Gs({event:e,walletAddress:t,onCancelOrder:r}){let{t:o}=useTranslation(),[n,i]=useState("positions"),s=useMemo(()=>e.markets?.map(p=>p.slug)??[],[e.markets]),{data:a}=usePositions({source:e.source,user:t??""}),l=useMemo(()=>!a?.positions||!t?0:s.length===0?a.positions.length:a.positions.filter(p=>p.market&&s.includes(p.market.slug)).length,[a?.positions,s,t]),d=[{key:"positions",label:l>0?`${o("predict.positions.title")} (${l})`:o("predict.positions.title")},{key:"orders",label:o("predict.openOrders.title")},{key:"trades",label:o("predict.tradeHistory.title")}];return jsxs("div",{className:"flex flex-col gap-y-2 mt-6 px-1 lg:px-4",children:[jsx("div",{className:"flex items-center gap-x-1 border-b border-border",children:d.map(p=>jsx("button",{type:"button",onClick:()=>i(p.key),className:cn("px-3 py-2 text-sm font-medium transition-colors cursor-pointer",n===p.key?"text-foreground border-b-2 border-primary":"text-neutral hover:text-foreground"),children:p.label},p.key))}),t?jsxs("div",{style:{height:rn},children:[n==="positions"&&jsx($p,{source:e.source,walletAddress:t,marketSlugs:s}),n==="orders"&&jsx(Vp,{source:e.source,walletAddress:t,marketSlugs:s,onCancelOrder:r}),n==="trades"&&jsx(Gp,{source:e.source,walletAddress:t})]}):jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:rn},children:o("predict.trade.connectWallet")})]})}function $p({source:e,walletAddress:t,marketSlugs:r}){let{t:o}=useTranslation(),{data:n,isLoading:i}=usePositions({source:e,user:t}),s=useMemo(()=>n?.positions?r.length===0?n.positions:n.positions.filter(a=>a.market&&r.includes(a.market.slug)):[],[n?.positions,r]);return i?jsx($o,{}):s.length===0?jsx(Uo,{message:o("predict.positions.empty")}):jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:Kn},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2 whitespace-nowrap",children:o("predict.positions.event")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.totalSize")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.value")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.avgPrice")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.markPrice")}),jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:o("predict.positions.pnl")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.payoutIfRight")}),jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:o("predict.positions.estSettlement")}),jsx("div",{className:"w-16 shrink-0"})]}),jsx(List,{style:{height:Wo},rowComponent:Kp,rowCount:s.length,rowHeight:zo,rowProps:{positions:s,closeLabel:o("predict.positions.close")}})]})}function Kp({index:e,style:t,positions:r,closeLabel:o}){let n=r[e];if(!n)return null;let i=n.pnl??0,s=n.pnl_percent??0,a=n.avg_price??0,l=n.current_price??0,u=i>0?"text-success":i<0?"text-danger":"text-foreground",d=i>0?"+":"",p=n.market?.outcomes?.[0]?.label??n.market?.question??"\u2014",m=n.side,c=n.size,f=n.size*l,g=n.market?.end_at?Xp(n.market.end_at):"\u2014";return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-xs lg:text-sm",children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxs("div",{className:"flex flex-col gap-y-0.5",children:[jsx("span",{className:"text-foreground truncate font-medium",children:p}),jsx("span",{className:cn("text-[10px] font-medium",m.toLowerCase()==="yes"?"text-primary":"text-secondary"),children:m})]})}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:n.size}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",f.toFixed(2)]}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:Un(a)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:Un(l)}),jsxs("div",{className:cn("flex-[1.5] pr-2 text-right font-mono whitespace-nowrap",u),children:[d,"$",Math.abs(i).toFixed(2),jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",d,s.toFixed(1),"%)"]})]}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",c.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:g}),jsx("div",{className:"w-16 shrink-0 text-right",children:jsx("button",{type:"button",className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors rounded px-2 py-0.5 border border-border hover:border-foreground/40",children:o})})]})}function Vp({source:e,walletAddress:t,marketSlugs:r,onCancelOrder:o}){let{t:n}=useTranslation(),{data:i,isLoading:s,fetchNextPage:a,hasNextPage:l}=useInfiniteOrders({source:e,wallet_address:t}),u=useCancelOrder(),d=useMemo(()=>{let x=i?.pages?.flatMap(S=>S.items)??[],b=new Set(["live","open","submitted","pending"]),w=x.filter(S=>b.has(S.status));return r.length>0&&(w=w.filter(S=>S.market_id&&r.includes(S.market_id))),w},[i?.pages,r]),p=useCallback(x=>{o?o(x.id):u.mutate({source:x.source,id:x.id});},[o,u]),m=d.length,c=m+(l?1:0),f=useCallback(x=>x<m,[m]),g=useCallback(async()=>{await a();},[a]),v=useInfiniteLoader({isRowLoaded:f,loadMoreRows:g,rowCount:c,threshold:5});return s?jsx($o,{}):d.length===0&&!l?jsx(Uo,{message:n("predict.openOrders.empty")}):jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:Kn},children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:n("predict.openOrders.side")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.openOrders.outcome")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.openOrders.type")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.openOrders.price")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.openOrders.filled")}),jsx("div",{className:"w-20 shrink-0 pr-2",children:n("predict.openOrders.status")}),jsx("div",{className:"w-16 shrink-0"})]}),jsx(List,{style:{height:Wo},onRowsRendered:v,rowComponent:jp,rowCount:c,rowHeight:zo,rowProps:{orders:d,itemCount:m,onCancel:p,isCancelling:u.isPending,cancelLabel:n("predict.openOrders.cancel")}})]})}function jp({index:e,style:t,orders:r,itemCount:o,onCancel:n,isCancelling:i,cancelLabel:s}){if(e>=o)return jsx("div",{style:t,className:"flex justify-center items-center",children:jsx(Spinner,{size:"sm"})});let a=r[e];if(!a)return null;let l=a.side==="BUY";return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:jsx("span",{className:cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",l?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:a.side})}),jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:a.outcome??"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-neutral capitalize",children:a.order_type??"limit"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:a.price?Un(parseFloat(a.price)):"\u2014"}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:[a.size_matched??"0","/",a.original_size??"\u2014"]}),jsx("div",{className:"w-20 shrink-0 pr-2",children:jsx(qp,{status:a.status})}),jsx("div",{className:"w-16 shrink-0 text-right",children:jsx("button",{type:"button",onClick:()=>n(a),disabled:i,className:"text-[10px] text-danger hover:text-danger/80 cursor-pointer disabled:opacity-50 transition-colors",children:i?jsx(Spinner,{size:"sm"}):s})})]})}function qp({status:e}){return jsx("span",{className:cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium capitalize",{live:"bg-success/10 text-success",open:"bg-success/10 text-success",submitted:"bg-warning/10 text-warning",pending:"bg-warning/10 text-warning",matched:"bg-primary/10 text-primary",cancelled:"bg-neutral/10 text-neutral",failed:"bg-danger/10 text-danger",expired:"bg-neutral/10 text-neutral"}[e]??"bg-neutral/10 text-neutral"),children:e})}function Gp({source:e,walletAddress:t}){let{t:r}=useTranslation(),{data:o,isLoading:n,fetchNextPage:i,hasNextPage:s}=useInfiniteTrades({source:e,wallet:t,limit:50}),a=useMemo(()=>o?.pages?.flatMap(c=>c.items)??[],[o?.pages]),l=a.length,u=l+(s?1:0),d=useCallback(c=>c<l,[l]),p=useCallback(async()=>{await i();},[i]),m=useInfiniteLoader({isRowLoaded:d,loadMoreRows:p,rowCount:u,threshold:5});return n?jsx($o,{}):a.length===0&&!s?jsx(Uo,{message:r("predict.tradeHistory.empty")}):jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:Kn},children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:r("predict.tradeHistory.side")}),jsx("div",{className:"flex-1 pr-2",children:r("predict.tradeHistory.outcome")}),jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.price")}),jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.qty")}),jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.total")}),jsx("div",{className:"flex-[1.5] pr-2 text-right",children:r("predict.tradeHistory.time")})]}),jsx(List,{style:{height:Wo},onRowsRendered:m,rowComponent:Yp,rowCount:u,rowHeight:zo,rowProps:{trades:a,itemCount:l}})]})}function Yp({index:e,style:t,trades:r,itemCount:o}){if(e>=o)return jsx("div",{style:t,className:"flex justify-center items-center",children:jsx(Spinner,{size:"sm"})});let n=r[e];if(!n)return null;let i=n.side?.toUpperCase()==="BUY",s=Qp(n.timestamp),a=n.price??0,l=n.usd_size??0;return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:jsx("span",{className:cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",i?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:n.side})}),jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:n.outcome??"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Un(a)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:n.size}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",l.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:s})]})}function Uo({message:e}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:rn},children:e})}function $o(){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:rn},children:Array.from({length:6}).map((e,t)=>jsx(Skeleton,{className:"h-8 w-full rounded-md"},t))})}function Un(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(1)}\xA2`}function Qp(e){let t=new Date(e*1e3),r=(t.getMonth()+1).toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),n=t.getHours().toString().padStart(2,"0"),i=t.getMinutes().toString().padStart(2,"0");return `${r}/${o} ${n}:${i}`}function Xp(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return "\u2014"}}var Ys=`
|
|
75
75
|
@keyframes detailShimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}
|
|
76
|
-
`,Gs={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:"detailShimmer 1.8s ease-in-out infinite",borderRadius:6};function me(e){return {...Gs,animationDelay:`${e}ms`}}function Zr({marketCount:e=4,showBack:t}){return jsxs(Fragment,{children:[jsx("style",{children:qs}),jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",gap:20},children:[t&&jsx("div",{style:{height:20}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[jsx("div",{style:{...Gs,width:64,height:64,borderRadius:10,flexShrink:0}}),jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:8},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsx("div",{style:{...me(0),height:14,width:48}}),jsx("div",{style:{...me(30),height:14,width:40}}),jsx("div",{style:{...me(60),height:14,width:40}})]}),jsx("div",{style:{...me(80),height:20,width:"80%",maxWidth:384,borderRadius:4}})]})]}),jsx("div",{style:{...me(100),height:16,width:192}}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:16},children:[jsx("div",{style:{...me(120),height:16,width:96}}),jsx("div",{style:{...me(140),height:16,width:80}})]}),jsx("div",{style:{...me(160),height:300,width:"100%",borderRadius:12}}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[jsx("div",{style:{...me(180),height:16,width:80}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsx("div",{style:{...me(200),height:28,width:200,borderRadius:8}}),jsx("div",{style:{...me(220),height:28,width:112,borderRadius:8}})]})]})]}),jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"8px 0"},children:jsx("div",{style:{...me(240),height:14,width:56}})}),Array.from({length:e}).map((r,o)=>jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 0",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsx("div",{style:{...me(260+o*40),width:28,height:28,borderRadius:8,flexShrink:0}}),jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:4},children:[jsx("div",{style:{...me(280+o*40),height:14,width:o%2===0?192:160}}),jsx("div",{style:{...me(300+o*40),height:10,width:64}})]}),jsx("div",{style:{...me(320+o*40),height:16,width:40}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsx("div",{style:{...me(340+o*40),height:32,width:80,borderRadius:8}}),jsx("div",{style:{...me(360+o*40),height:32,width:80,borderRadius:8}})]})]},o))]}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[jsx("div",{style:{...me(400),height:16,width:64}}),jsx("div",{style:{...me(420),height:14,width:"100%"}}),jsx("div",{style:{...me(440),height:14,width:"80%"}}),jsx("div",{style:{...me(460),height:14,width:"60%"}})]})]})]})}function Ys(){return jsxs(Fragment,{children:[jsx("style",{children:qs}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",padding:16},children:[jsx("div",{style:{...me(0),height:40,width:"100%",borderRadius:8}}),jsx("div",{style:{...me(60),height:96,width:"100%",borderRadius:8}}),jsx("div",{style:{...me(120),height:40,width:"100%",borderRadius:8}})]})]})}var ea="var(--color-bullish)",ta="var(--color-bearish)";function en(e){let t=Math.abs(e);return t>=1e9?`${parseFloat((e/1e9).toFixed(2))}B`:t>=1e6?`${parseFloat((e/1e6).toFixed(2))}M`:t>=1e3?`${parseFloat((e/1e3).toFixed(2))}K`:e.toLocaleString()}function Yp(e,t){return e<=0||t<=0?0:Math.pow(e/t,.3)}function Qp(e,t){let r=new Float64Array(101),o=new Float64Array(101);for(let c of e){let f=Math.round(c.price*100);f>=0&&f<=100&&(r[f]+=c.quantity);}for(let c of t){let f=Math.round(c.price*100);f>=0&&f<=100&&(o[f]+=c.quantity);}let n=0,i=0,s=new Float64Array(101),a=new Float64Array(101);for(let c=100;c>=0;c--)n+=r[c],i+=r[c]*c/100,s[c]=n,a[c]=i;let l=0,u=0,d=new Float64Array(101),p=new Float64Array(101);for(let c=0;c<=100;c++)l+=o[c],u+=o[c]*c/100,d[c]=l,p[c]=u;let m=Math.max(s[0]??0,d[100]??0);return Array.from({length:101},(c,f)=>{let g=s[f]>0,v=d[f]>0,x=s[f]||d[f],b=r[f]>0||o[f]>0;return {priceCents:f,displayHeight:Yp(x,m),opacity:x>0?b?1:.5:0,isBid:g,isAsk:v,bidCumTotal:s[f],askCumTotal:d[f],bidCumCost:a[f],askCumCost:p[f]}})}function Xp({info:e}){let{t}=useTranslation(),r=e.isBid?ea:ta,o=e.leftPct>65?void 0:`${e.leftPct}%`,n=e.leftPct>65?`${100-e.leftPct}%`:void 0;return jsxs("div",{style:{position:"absolute",top:8,left:o,right:n,zIndex:10,background:"rgba(17,24,39,0.95)",border:"1px solid rgba(255,255,255,0.08)",borderRadius:8,padding:"8px 12px",fontSize:12,color:"#f9fafb",minWidth:140,pointerEvents:"none"},children:[jsx("div",{style:{marginBottom:4,fontWeight:600},children:t("predict.orderBook.depthToPrice",{price:e.priceCents})}),jsx("div",{style:{color:r},children:t("predict.orderBook.depthContracts",{amount:en(Math.round(e.cumTotal))})}),jsxs("div",{style:{color:r},children:["$",en(Math.round(e.cumCost))]})]})}var Jp=memo(function({slot:t,onEnter:r,onLeave:o}){let n=useRef(null),i=t.isBid||t.isAsk,s=t.isBid?ea:t.isAsk?ta:void 0;return jsx("div",{style:{position:"absolute",left:`${t.priceCents}%`,width:"1%",height:"100%",boxSizing:"border-box",borderRight:t.priceCents<100?"1px solid transparent":"none",cursor:i?"crosshair":"default"},onMouseEnter:()=>r(t,n.current),onMouseLeave:o,children:i&&jsx("div",{ref:n,style:{position:"absolute",bottom:0,left:0,width:"100%",height:`${t.displayHeight*100}%`,backgroundColor:s,opacity:t.opacity}})})}),Zp=[0,10,20,30,40,50,60,70,80,90,100];function em(){return jsx("div",{className:"relative flex h-6 items-center border-b border-t border-border px-1",style:{background:"rgba(0,0,0,0.15)"},children:Zp.map(e=>jsx("span",{className:"absolute text-neutral font-normal",style:{fontSize:10,left:`${e}%`,transform:e===0?"translateX(0px)":e===100?"translateX(-100%)":"translateX(-50%)"},children:e},e))})}function ra({bids:e,asks:t}){let{t:r}=useTranslation(),o=useMemo(()=>Qp(e,t),[e,t]),n=useMemo(()=>{let p=e.length>0?Math.max(...e.map(c=>c.price)):0,m=t.length>0?Math.min(...t.map(c=>c.price)):1;return Math.round((p+m)/2*100)},[e,t]),i=useMemo(()=>o.some(p=>p.isBid||p.isAsk),[o]),[s,a]=useState(null),l=useRef(null),u=useCallback((p,m)=>{l.current&&(l.current.style.filter=""),m?(m.style.filter="brightness(1.5)",l.current=m):l.current=null,p.isBid||p.isAsk?a({priceCents:p.priceCents,isBid:p.isBid,cumTotal:p.isBid?p.bidCumTotal:p.askCumTotal,cumCost:p.isBid?p.bidCumCost:p.askCumCost,leftPct:p.priceCents}):a(null);},[]),d=useCallback(()=>{l.current&&(l.current.style.filter="",l.current=null),a(null);},[]);return i?jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",userSelect:"none",overflow:"hidden"},children:[jsxs("div",{style:{flex:1,position:"relative",width:"100%",overflow:"hidden"},children:[n>0&&jsx("div",{style:{position:"absolute",left:`${n}%`,top:0,bottom:0,width:1,backgroundImage:"repeating-linear-gradient(to bottom, #6b7280 0, #6b7280 4px, transparent 4px, transparent 8px)",zIndex:1,pointerEvents:"none"}}),s&&jsx(Xp,{info:s}),o.map(p=>jsx(Jp,{slot:p,onEnter:u,onLeave:d},p.priceCents))]}),jsx(em,{})]}):jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:r("predict.orderBook.noData")})}function la(e){let t=e*100,r=Math.round(t*10)/10;return Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`}function oa(){let{t:e}=useTranslation();return jsx("div",{className:"absolute inset-0 flex items-center justify-center text-neutral text-xs",children:jsx("span",{children:e("predict.orderBook.loading")})})}function ca({market:e,outcome:t="yes",onTradeAction:r,initialViewMode:o="depth",className:n,oddsFormatter:i}){let{t:s}=useTranslation(),[a,l]=useState(o),u=i??la,d=e.source,{data:p,isLoading:m,isFetching:c,refetch:f}=useRealtimeOrderbook({slug:e.slug,source:d,outcome:t}),g=useMemo(()=>(p?.bids??[]).map(S=>({price:S.price,quantity:S.size})),[p?.bids]),v=useMemo(()=>(p?.asks??[]).map(S=>({price:S.price,quantity:S.size})),[p?.asks]),x=useMemo(()=>g.length>0?Math.max(...g.map(S=>S.price)):null,[g]),b=useMemo(()=>v.length>0?Math.min(...v.map(S=>S.price)):null,[v]),w=useMemo(()=>{if(x==null||b==null)return null;let S=(b-x)*100;return Math.round(S*10)/10},[x,b]);return jsxs("div",{className:cn$1("flex flex-col",n??"h-[262px]"),children:[jsxs("div",{className:"flex h-9 items-center border-b border-border px-1 text-xs",children:[jsx("span",{className:"flex-1 text-left text-neutral",children:w!=null?`${s("predict.orderBook.spread")}: ${Number.isInteger(w)?`${w}\xA2`:`${w.toFixed(1)}\xA2`}`:null}),jsxs("span",{className:"flex flex-1 items-center justify-center gap-x-1 whitespace-nowrap",children:[x!=null&&jsxs("span",{style:{color:"var(--color-bullish)"},children:[s("predict.trade.bestBid"),": ",u(x)]}),x!=null&&b!=null&&jsx("span",{className:"text-neutral",children:"|"}),b!=null&&jsxs("span",{style:{color:"var(--color-bearish)"},children:[s("predict.trade.bestAsk"),": ",u(b)]})]}),jsxs("div",{className:"flex flex-1 items-center justify-end gap-x-2",children:[jsx("button",{type:"button",title:a==="depth"?"Orderbook":"Depth chart",onClick:()=>l(S=>S==="depth"?"table":"depth"),className:"flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground",children:a==="depth"?jsx(OrderbookTableIcon,{className:"h-4 w-4"}):jsx(OrderbookDepthIcon,{className:"h-4 w-4"})}),jsx("button",{type:"button",title:"Refresh",onClick:()=>f(),disabled:c,className:cn$1("flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground disabled:cursor-default disabled:opacity-50",c&&"animate-spin"),children:jsx(RefreshIcon,{className:"h-4 w-4"})})]})]}),jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[a==="depth"&&jsx(Fragment,{children:m?jsx(oa,{}):jsx(ra,{bids:g,asks:v})}),a==="table"&&jsx(Fragment,{children:m?jsx(oa,{}):jsx(sm,{bids:g,asks:v,bestBid:x??void 0,bestAsk:b??void 0,spread:w??void 0,oddsFormatter:i})})]})]})}var Vo=4,im=8;function sm({bids:e,asks:t,spread:r,oddsFormatter:o}){let{t:n}=useTranslation(),[i,s]=useState(false),a=i?im:Vo,l=t.length>Vo||e.length>Vo,u=useMemo(()=>[...t].sort((c,f)=>c.price-f.price).slice(0,a).reverse(),[t,a]),d=useMemo(()=>[...e].sort((c,f)=>f.price-c.price).slice(0,a),[e,a]),p=useMemo(()=>{let c=[...u,...d].map(f=>f.quantity);return Math.max(...c,1)},[u,d]);return u.length===0&&d.length===0?jsx("div",{className:"flex items-center justify-center h-full text-xs text-neutral",children:n("predict.orderBook.empty")}):jsxs("div",{className:"flex flex-col h-full overflow-y-auto text-xs font-mono select-none",children:[u.map(c=>jsx(ia,{price:c.price,quantity:c.quantity,side:"ask",maxQty:p,oddsFormatter:o},`ask-${c.price}`)),jsxs("div",{className:"relative flex items-center justify-center gap-x-2 py-1 border-y border-border text-neutral text-[10px]",children:[r!=null&&jsxs("span",{children:[n("predict.orderBook.spread"),":"," ",Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`]}),l&&jsx("button",{type:"button",onClick:()=>s(c=>!c),className:"absolute right-2 text-[10px] text-neutral transition-colors cursor-pointer hover:text-foreground",children:n(i?"predict.orderBook.collapse":"predict.orderBook.expand")})]}),d.map(c=>jsx(ia,{price:c.price,quantity:c.quantity,side:"bid",maxQty:p,oddsFormatter:o},`bid-${c.price}`)),jsxs("div",{className:"grid grid-cols-3 px-2 pt-2 pb-0.5 text-[10px] text-neutral border-t border-border",children:[jsx("span",{children:n("predict.orderBook.price")}),jsx("span",{className:"text-center",children:n("predict.orderBook.contracts")}),jsx("span",{className:"text-right",children:n("predict.orderBook.total")})]})]})}function ia({price:e,quantity:t,side:r,maxQty:o,oddsFormatter:n}){let i=r==="ask",s=Math.min(t/o*100,100),a=i?"bg-bearish/10":"bg-bullish/10",l=i?"text-bearish":"text-bullish",u=en(Math.round(t)),d=Math.round(t*e),p=`$${en(d)}`;return jsxs("div",{className:"relative grid grid-cols-3 px-2 py-1 hover:bg-content2 transition-colors cursor-default",children:[jsx("div",{className:`absolute inset-y-0 left-0 ${a} transition-[width] duration-200`,style:{width:`${s}%`}}),jsx("span",{className:`relative z-10 ${l}`,children:n?n(e):la(e)}),jsx("span",{className:"relative z-10 text-foreground text-center",children:u}),jsx("span",{className:"relative z-10 text-foreground text-right",children:p})]})}var Go=class extends Component{state={error:null};static getDerivedStateFromError(t){return {error:t}}componentDidCatch(t,r){}render(){return this.state.error?jsxs("div",{style:{height:this.props.fallbackHeight??320,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,color:"#6b7280",fontSize:13},children:[jsx("span",{children:"Chart unavailable"}),jsx("span",{style:{fontSize:11,opacity:.7},children:this.state.error.message})]}):this.props.children}},tn=4,da=["#22d3ee","#a3e635","#f97316","#f472b6","#a78bfa"];function xm(e,t){let r=new Date(e);return t===le.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function bm(e,t){let r=new Date(e);return t===le.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):t===le.ONE_WEEK?r.toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function pa(e){return `${(e*100).toFixed(2)}%`}var ym=[{range:le.ONE_DAY,label:"1D"},{range:le.ONE_WEEK,label:"1W"},{range:le.ONE_MONTH,label:"1M"},{range:le.ALL,label:"ALL"}];function km({value:e,onChange:t}){return jsx("div",{style:{display:"flex",alignItems:"center",gap:2},children:ym.map(({range:r,label:o})=>{let n=r===e;return jsx("button",{onClick:()=>t(r),style:{padding:"2px 8px",border:"none",background:"transparent",color:n?"#f9fafb":"#6b7280",fontWeight:n?700:400,fontSize:12,cursor:"pointer",borderRadius:4,letterSpacing:"0.02em",transition:"color 0.15s",userSelect:"none"},children:o},r)})})}function Sm(){let e=useRef(null),t=useRef(null),r=useCallback(n=>{let i=e.current,s=t.current;if(!i||!s)return;let a=i.getBoundingClientRect(),l=(n.clientX-a.left)/a.width*100;s.style.background=`linear-gradient(to right, transparent ${l}%, rgba(0,0,0,0.55) ${l}%)`,s.style.opacity="1";},[]),o=useCallback(()=>{t.current&&(t.current.style.opacity="0");},[]);return {wrapperRef:e,overlayRef:t,onMouseMove:r,onMouseLeave:o}}function wm({active:e,payload:t,label:r,labelMap:o,allSeries:n,range:i}){if(!e||!n?.length)return null;let s=new Map;t?.forEach(l=>s.set(l.dataKey,l));let a=n.map(l=>s.get(l.slug)??{dataKey:l.slug,value:void 0,stroke:l.color,color:l.color});return jsxs("div",{style:{background:"rgba(10,10,10,0.92)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:8,padding:"8px 12px",minWidth:180,backdropFilter:"blur(8px)",fontSize:12},children:[jsx("div",{style:{color:"#9ca3af",marginBottom:6,fontWeight:500},children:typeof r=="number"?bm(r,i):r}),a.map(l=>jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[jsx("span",{style:{display:"inline-block",width:3,height:14,borderRadius:2,background:l.stroke??l.color,flexShrink:0}}),jsx("span",{style:{color:"#9ca3af",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:120},children:o.get(l.dataKey)??l.dataKey}),jsx("span",{style:{color:"#f9fafb",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:l.value!=null?pa(l.value):"--"})]},l.dataKey))]})}function Pm({markets:e,selectedSlugs:t,colorMap:r,onToggle:o}){let[n,i]=useState(false),s=useRef(null);useEffect(()=>{if(!n)return;function u(d){s.current&&!s.current.contains(d.target)&&i(false);}return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[n]);let a=t.length>=tn,l=jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},children:[jsx("div",{style:{display:"flex",gap:3,flexShrink:0},children:t.map(u=>jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:r.get(u)??"#6b7280",display:"inline-block"}},u))}),jsx("span",{style:{color:"#e5e7eb",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.length===1?(()=>{let u=e.find(d=>d.slug===t[0]);return u?.outcomes?.[0]?.label??u?.question??"1 market"})():`${t.length} / ${e.length} markets`})]});return jsxs("div",{ref:s,style:{position:"relative",display:"inline-block",width:200},children:[jsxs("button",{onClick:()=>i(u=>!u),style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:8,border:"1px solid rgba(255,255,255,0.12)",background:"rgba(255,255,255,0.05)",cursor:"pointer",width:"100%",userSelect:"none"},children:[l,jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{flexShrink:0,transform:n?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.15s",color:"#6b7280"},children:jsx("path",{d:"M2 4l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),n&&jsxs("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,zIndex:50,background:"#111827",border:"1px solid rgba(255,255,255,0.1)",borderRadius:10,boxShadow:"0 8px 24px rgba(0,0,0,0.5)",minWidth:260,maxWidth:360,maxHeight:320,overflowY:"auto",padding:"6px 0"},children:[jsxs("div",{style:{padding:"4px 12px 8px",fontSize:11,color:"#6b7280",borderBottom:"1px solid rgba(255,255,255,0.06)",marginBottom:4},children:["Select up to ",tn," markets"]}),e.map((u,d)=>{let p=t.includes(u.slug),m=!p&&a,c=p&&t.length===1,f=r.get(u.slug)??"#6b7280",g=u.outcomes.find(x=>x.label.toLowerCase()==="yes")??u.outcomes[0],v=g?.price!=null?`${Math.round(g.price*100)}%`:null;return jsxs("button",{onClick:()=>{c||m||o(u.slug);},style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"7px 12px",border:"none",background:p?"rgba(255,255,255,0.05)":"transparent",cursor:m||c?"not-allowed":"pointer",opacity:m?.35:1,textAlign:"left",transition:"background 0.1s"},onMouseEnter:x=>{!m&&!c&&(x.currentTarget.style.background="rgba(255,255,255,0.07)");},onMouseLeave:x=>{x.currentTarget.style.background=p?"rgba(255,255,255,0.05)":"transparent";},children:[jsx("span",{style:{width:16,height:16,borderRadius:4,border:p?`2px solid ${f}`:"2px solid rgba(255,255,255,0.2)",background:p?`${f}30`:"transparent",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:p&&jsx("svg",{width:"9",height:"7",viewBox:"0 0 9 7",fill:"none",children:jsx("path",{d:"M1 3.5L3.5 6L8 1",stroke:f,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:f,flexShrink:0}}),jsx("span",{style:{color:p?"#f9fafb":"#9ca3af",fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u.outcomes?.[0]?.label??u.question}),v&&jsx("span",{style:{color:f,fontWeight:700,fontSize:12,flexShrink:0},children:v})]},u.id??`${d}-${u.slug}`)})]})]})}function Nm({series:e,colorMap:t,displayValues:r}){return jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px 24px",padding:"0 2px"},children:e.map(o=>{let n=t.get(o.marketSlug)??"#6b7280",i=r.get(o.marketSlug);return jsxs("div",{style:{display:"inline-flex",alignItems:"flex-start",gap:6},children:[jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:n,flexShrink:0,marginTop:3}}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:1},children:[jsx("span",{style:{color:"#9ca3af",fontSize:12,lineHeight:"17px",whiteSpace:"nowrap"},children:o.label}),jsx("span",{style:{color:"#f9fafb",fontSize:14,fontWeight:700,lineHeight:"20px",fontVariantNumeric:"tabular-nums"},children:i!=null?pa(i):"--"})]})]},o.marketSlug)})})}function Cm(e){let t=Math.floor(e.length/2);return e.length%2===1?e[t]:(e[t-1]+e[t])/2}function Mm(e,t){if(e.length<=t)return e;let r=[],o=e.length/t;for(let n=0;n<t;n++){let i=Math.floor(n*o),s=Math.min(Math.floor((n+1)*o),e.length),a=e.slice(i,s),l=a.map(u=>u.price).sort((u,d)=>u-d);r.push({timestamp:a[a.length-1].timestamp,price:Cm(l)});}return r}function Em(e,t=200){if(e.length===0)return [];let r=e.map(a=>({...a,data:Mm(a.data,t)})),o=new Set;r.forEach(a=>a.data.forEach(l=>o.add(l.timestamp)));let n=Array.from(o).sort((a,l)=>a-l),i=r.map(a=>{let l=new Map;return a.data.forEach(u=>l.set(u.timestamp,u.price)),{slug:a.marketSlug,map:l}}),s=new Map;return n.map(a=>{let l={timestamp:a};return i.forEach(({slug:u,map:d})=>{let p=d.get(a);if(p!==void 0)s.set(u,p),l[u]=p;else {let m=s.get(u);m!==void 0&&(l[u]=m);}}),l})}function ma(e){return jsx(Go,{children:jsx(Tm,{...e})})}function Tm({event:e,isLoading:t,className:r,volume:o,fillHeight:n=false}){let i=useMemo(()=>{let N=new Set;return (e.markets??[]).filter(M=>N.has(M.slug)?false:(N.add(M.slug),true))},[e.markets]),s=useMemo(()=>[...i].sort((N,M)=>{let U=X=>(X.outcomes.find(se=>se.label.toLowerCase()==="yes")??X.outcomes[0])?.price??0;return U(M)-U(N)}),[i]),[a,l]=useState(()=>s.slice(0,tn).map(N=>N.slug));useEffect(()=>{let N=new Set(i.map(M=>M.slug));l(M=>{let U=M.filter(X=>N.has(X));return U.length===M.length?M:U.length>0?U:s.slice(0,tn).map(X=>X.slug)});},[i,s]);let[u,d]=useState(Nn),p=useMemo(()=>{let N=new Map;return a.forEach((M,U)=>{N.set(M,da[U%da.length]);}),N},[a]),m=useMemo(()=>i.filter(N=>a.includes(N.slug)),[i,a]),{series:c,isLoading:f}=useMarketHistory(m,u),g=t||f,v=useMemo(()=>{if(c.length>0&&c.some(U=>U.data.length>0))return c;let N=Date.now(),M=864e5;return m.map(U=>{let se=(U.outcomes?.find(R=>R.label.toLowerCase()==="yes")??U.outcomes?.[0])?.price??.5;return {marketSlug:U.slug,label:U.outcomes?.[0]?.label??U.question,data:[{timestamp:N-7*M,price:se},{timestamp:N,price:se}]}})},[c,m]),x=useMemo(()=>u===le.ONE_DAY?96:u===le.ONE_WEEK?168:u===le.ONE_MONTH?180:300,[u]),b=useMemo(()=>Em(v,x),[v,x]),w=useMemo(()=>{if(b.length===0)return [0,1];let N=1/0,M=-1/0;if(a.forEach(X=>{b.forEach(se=>{let R=se[X];R!=null&&(R<N&&(N=R),R>M&&(M=R));});}),!isFinite(N))return [0,1];let U=Math.max((M-N)*.15,.05);return [Math.max(0,N-U),Math.min(1,M+U)]},[b,a]),S=useMemo(()=>{let N=new Map;return v.forEach(M=>{M.data.length>0&&N.set(M.marketSlug,M.data[M.data.length-1].price);}),N},[v]),h=useMemo(()=>{let N=new Map;return v.forEach(M=>N.set(M.marketSlug,M.label)),N},[v]),y=useMemo(()=>v.map(N=>({slug:N.marketSlug,color:p.get(N.marketSlug)??"#6b7280"})),[v,p]),{wrapperRef:k,overlayRef:P,onMouseMove:I,onMouseLeave:D}=Sm(),W=useCallback(N=>{l(M=>M.includes(N)?M.length<=1?M:M.filter(U=>U!==N):M.length>=tn?M:[...M,N]);},[]),[O,G]=useState(null),j=useRef(null),Q=useRef(""),re=useRef(0),te=!g&&b.length>0;return jsxs("div",{className:r,style:{display:"flex",flexDirection:"column",gap:12,...n?{height:"100%",minHeight:0}:null},children:[jsx(Nm,{series:v,colorMap:p,displayValues:O??S}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,...n?{flex:1,minHeight:0}:null},children:[jsx("div",{ref:k,style:{width:"100%",userSelect:"none",position:"relative",...n?{flex:1,minHeight:240}:{height:300}},onMouseMove:te?N=>{I(N),cancelAnimationFrame(re.current),re.current=requestAnimationFrame(()=>{G(j.current);});}:void 0,onMouseLeave:te?()=>{D(),cancelAnimationFrame(re.current),Q.current="",j.current=null,G(null);}:void 0,children:g?jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:jsx("div",{style:{width:28,height:28,borderRadius:"50%",border:"2.5px solid #22d3ee",borderTopColor:"transparent",animation:"spin 0.7s linear infinite"}})}):b.length===0?jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:"No price history data"}):jsxs(Fragment,{children:[jsx("div",{ref:P,style:{position:"absolute",inset:0,opacity:0,pointerEvents:"none",zIndex:1}}),jsx(ResponsiveContainer,{width:"100%",height:"100%",children:jsxs(LineChart,{data:b,margin:{top:8,right:16,left:0,bottom:0},children:[jsx(CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"#374151",opacity:.5}),jsx(XAxis,{dataKey:"timestamp",type:"number",scale:"time",domain:["dataMin","dataMax"],tickFormatter:N=>xm(N,u),axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},minTickGap:70}),jsx(YAxis,{domain:w,tickFormatter:N=>`${Math.round(N*100)}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},width:40,tickCount:6}),jsx(Tooltip,{content:N=>{let M=N;if(M.active&&M.payload?.length){let U=M.payload.map(X=>`${X.dataKey}:${X.value}`).join(",");if(U!==Q.current){Q.current=U;let X=new Map;M.payload.forEach(se=>{se.value!=null&&X.set(se.dataKey,se.value);}),j.current=X;}}return jsx(wm,{...M,labelMap:h,allSeries:y,range:u})},cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},wrapperStyle:{zIndex:2},isAnimationActive:false}),v.map(N=>{let M=p.get(N.marketSlug)??"#6b7280";return jsx(Line,{type:"linear",dataKey:N.marketSlug,stroke:M,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:M},connectNulls:true,isAnimationActive:false},N.marketSlug)}),O==null&&b.length>0&&v.map(N=>{let M=b[b.length-1],U=M[N.marketSlug];if(U==null)return null;let X=p.get(N.marketSlug)??"#6b7280";return jsx(ReferenceDot,{x:M.timestamp,y:U,ifOverflow:"extendDomain",shape:se=>{let{cx:R,cy:ke}=se;return R==null||ke==null?jsx("g",{}):jsxs("g",{children:[jsxs("circle",{cx:R,cy:ke,r:6,fill:X,opacity:.3,children:[jsx("animate",{attributeName:"r",values:"4;9;4",dur:"2s",repeatCount:"indefinite"}),jsx("animate",{attributeName:"opacity",values:"0.4;0.05;0.4",dur:"2s",repeatCount:"indefinite"})]}),jsx("circle",{cx:R,cy:ke,r:3.5,fill:X})]})}},`pulse-${N.marketSlug}`)})]})})]})}),jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"6px 8px",marginTop:6},children:[o!=null&&o>0&&jsxs("span",{style:{color:"#6b7280",fontSize:12},children:[formatAmountInUsd(o)," vol"]}),jsx("div",{style:{flex:1,minWidth:0}}),jsx(km,{value:u,onChange:d}),s.length>1&&jsx("div",{style:{width:"100%",display:"flex",alignItems:"center"},children:jsx(Pm,{markets:s,selectedSlugs:a,colorMap:p,onToggle:W})})]})]})]})}function qn(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function ga(e,t){let r=e.outcomes[t==="yes"?0:1];return r?.best_ask??r?.price}function Vm(e){return `${parseFloat((e*100).toFixed(2))}%`}function ha(e){let t=e*100;return t<1&&t>0?"< 1":parseFloat(t.toFixed(2)).toString()}function Gn(e){return e.outcomes?.[0]?.label??e.question}function jm(e){switch(e){case "polymarket":return "Polymarket";case "kalshi":return "Kalshi";default:return e}}function rn(e){if(!e)return "\u2014";let t=new Date(e);if(isNaN(t.getTime()))return "\u2014";let r=t.toLocaleString("default",{month:"short"}),o=t.getDate(),n=t.getFullYear(),i=t.getHours().toString().padStart(2,"0"),s=t.getMinutes().toString().padStart(2,"0");return `${r} ${o}, ${n} ${i}:${s}`}function va(e){let[t,r]=useState(0);if(useEffect(()=>{if(!e)return;r(Date.now());let d=setInterval(()=>r(Date.now()),1e3);return ()=>clearInterval(d)},[e]),!e||t===0)return null;let o=new Date(e).getTime();if(isNaN(o))return null;let n=o-t;if(n<=0)return null;let i=Math.floor(n/864e5),s=Math.floor(n%864e5/36e5),a=Math.floor(n%36e5/6e4),l=Math.floor(n%6e4/1e3),u=[];return i>0&&u.push(`${i}d`),u.push(`${String(s).padStart(2,"0")}h`),u.push(`${String(a).padStart(2,"0")}m`),u.push(`${String(l).padStart(2,"0")}s`),u.join(" ")}function xa(e){if(!e)return null;let t=new Date(e);if(isNaN(t.getTime()))return null;let r=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0"),n=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getDate().toString().padStart(2,"0"),s=t.getFullYear(),a=-t.getTimezoneOffset(),l=a>=0?"+":"-",u=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${o} ${n}/${i}/${s} (${l}${u})`}function Sa({event:e,onTradeAction:t}){let{t:r}=useTranslation(),{ref:o,isCollapsed:n}=useScrollCollapse(),i=useMemo(()=>{let p=[...e.markets||[]],m=p.filter(f=>f.status==="open").sort((f,g)=>qn(g)-qn(f)),c=p.filter(f=>f.status!=="open").sort((f,g)=>qn(g)-qn(f));return [...m,...c]},[e.markets]),s=e.status==="closed"||e.status==="voided",a=va(s?void 0:e.start_at),l=va(s?void 0:e.end_at),u=xa(e.start_at),d=xa(e.end_at);return jsxs("div",{className:"w-full flex flex-col gap-y-4 lg:gap-y-6",children:[jsxs("div",{ref:o,className:`sticky top-0 z-30 flex items-center backdrop-blur-md transition-all duration-300 ${n?"h-14 lg:h-16 gap-x-2 py-2 px-1 lg:px-4 -mx-1 lg:-mx-4 shadow-sm":"h-16 lg:h-20 gap-x-2 lg:gap-x-4"}`,children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",classNames:{base:"bg-transparent"},className:`flex-shrink-0 transition-all duration-300 ${n?"!h-10 !w-10 lg:!h-12 lg:!w-12":"!h-16 !w-16 lg:!h-20 lg:!w-20"}`}),jsxs("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[!n&&jsxs("div",{className:"flex items-center gap-1.5",children:[e.tags?.slice(0,3).map((p,m)=>jsxs(Fragment$1,{children:[m>0&&jsx("span",{className:"text-sm text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-sm text-neutral truncate",children:p.label})]},p.slug)),jsx(Qm,{source:e.source})]}),jsx("span",{className:`font-semibold truncate transition-all duration-300 ${n?"text-sm lg:text-base":"text-lg lg:text-xl"}`,children:e.title})]})]}),(a||l||s)&&jsx("div",{className:"flex items-center gap-x-2 text-xs lg:text-sm font-mono",children:s?d&&jsx("span",{className:"text-neutral",children:r("predict.event.endedAt",{time:d})}):a?jsxs(Fragment,{children:[jsx("span",{className:"text-foreground",children:r("predict.event.beginsIn",{time:a})}),u&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-neutral",children:u})]})]}):l?jsxs(Fragment,{children:[jsx("span",{className:"text-foreground",children:r("predict.event.endsIn",{time:l})}),d&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-neutral",children:d})]})]}):null}),jsx(ma,{event:e,volume:e.volume??void 0}),jsx(qm,{markets:i,onTradeAction:t}),jsx(Ym,{markets:i,event:e})]})}var ba=5;function qm({markets:e,onTradeAction:t}){let{t:r}=useTranslation(),{isDesktop:o}=useScreen(),[n,i]=useState(false),[s,a]=useState(null),l=useMemo(()=>{let v=new Set;return e.filter(x=>v.has(x.slug)?false:(v.add(x.slug),true))},[e]),u=l.find(v=>v.status==="open")?.slug,[d,p]=useState(u?`${u}:yes`:null);if(l.length===0)return null;let m=l.length>ba,c=n?l:l.slice(0,ba),f=v=>{a(x=>x===v?null:v);},g=(v,x,b)=>{p(`${v.slug}:${x}`),o&&a(v.slug),t?.(v,x,b);};return jsxs("div",{className:"flex flex-col",children:[jsxs("table",{className:"w-full border-collapse",children:[jsx("thead",{children:jsxs("tr",{children:[jsx("th",{}),jsx("th",{className:"py-2 text-left text-xs text-neutral font-normal lg:text-center lg:text-sm",children:r("predict.market.table.chance")}),jsx("th",{})]})}),jsx("tbody",{children:c.map((v,x)=>{let b=s===v.slug;return jsx(Gm,{market:v,activeYes:d===`${v.slug}:yes`,activeNo:d===`${v.slug}:no`,isExpanded:b,onToggleExpand:()=>f(v.slug),onTradeAction:g},v.id??`${x}-${v.slug}`)})})]}),m&&jsxs("button",{type:"button",onClick:()=>i(v=>!v),className:"flex w-full items-center justify-start gap-x-2 py-2 pl-1 text-xs text-neutral lg:pl-2 lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsx("span",{children:r(n?"predict.event.rules.collapse":"predict.event.moreMarketsLabel")}),jsx(ChevronDownIcon,{className:cn$1("h-4 w-4 transition-transform",n&&"rotate-180")})]})]})}function Gm({market:e,activeYes:t,activeNo:r,isExpanded:o,onToggleExpand:n,onTradeAction:i}){let{t:s}=useTranslation(),a=e.status==="open",l=e.volume?`${formatAmountInUsd(e.volume)} vol`:void 0,{data:u}=useRealtimeOrderbook({slug:e.slug,source:e.source,outcome:"yes"},{enabled:a}),{data:d}=useOrderbook({slug:e.slug,source:e.source,outcome:"no"},{enabled:false,refetchInterval:false}),p=pickBestAsk(u,"yes")??ga(e,"yes")??0,m=pickBestAsk(d,"no")??ga(e,"no");return jsxs(Fragment,{children:[jsxs("tr",{className:"cursor-pointer border-b border-border text-xs hover:bg-content2 lg:text-base",onClick:n,role:"button",tabIndex:0,onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),n());},children:[jsx("td",{className:"py-2 pl-1 lg:pl-2",children:jsxs("div",{className:"flex items-center gap-x-1 lg:gap-x-2",children:[e.image_url&&jsx(Avatar,{src:e.image_url,name:Gn(e)?.[0]||"?",radius:"lg",className:"size-5 shrink-0 lg:size-8",imgProps:{className:"object-cover"}}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-foreground truncate max-w-[200px] lg:max-w-[300px]",children:Gn(e)}),l&&jsx("span",{className:"text-[8px] text-neutral lg:text-xxs",children:l})]})]})}),jsx("td",{className:"py-2 text-left text-foreground lg:text-center",children:Vm(p)}),jsx("td",{className:"py-2 pr-1 lg:pr-2",children:a?jsxs("div",{className:"flex items-center justify-end gap-x-2",children:[jsx("button",{type:"button",className:cn$1("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all focus-visible:outline-2 focus-visible:outline-primary/40 focus-visible:outline-offset-2",t?"bg-primary text-primary-foreground":"bg-primary/10 text-primary"),onClick:c=>{c.stopPropagation(),i?.(e,"yes","buy");},children:s("predict.market.action.yes",{price:ha(p)})}),jsx("button",{type:"button",className:cn$1("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all focus-visible:outline-2 focus-visible:outline-primary/40 focus-visible:outline-offset-2",r?"bg-secondary text-secondary-foreground":"bg-secondary/10 text-secondary"),onClick:c=>{c.stopPropagation(),i?.(e,"no","buy");},children:m!=null?s("predict.market.action.no",{price:ha(m)}):s("predict.market.no")})]}):jsx("div",{className:"flex items-center justify-end",children:jsx("span",{className:cn$1("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",e.status==="closed"?"bg-neutral/10 text-neutral":e.status==="voided"?"bg-warning/10 text-warning":"bg-primary/10 text-primary"),children:e.status==="closed"?s("predict.event.status.closed"):e.status==="voided"?s("predict.event.status.voided"):s("predict.event.status.pending")})})})]}),o&&jsx("tr",{children:jsx("td",{colSpan:3,className:"pb-3",children:jsx("div",{className:"max-h-100 overflow-y-auto",children:jsx(ca,{market:e,outcome:r?"no":"yes",onTradeAction:i})})})})]})}function Ym({markets:e,event:t}){let{t:r}=useTranslation(),[o,n]=useState(false),[i,s]=useState(false),[a,l]=useState(0),u=e.filter(c=>c.rules&&c.rules.length>0||c.description);if(u.length===0)return null;let d=u[a]??u[0],p=d.rules&&d.rules.length>0?d.rules.join(`
|
|
76
|
+
`,Qs={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:"detailShimmer 1.8s ease-in-out infinite",borderRadius:6};function me(e){return {...Qs,animationDelay:`${e}ms`}}function nn({marketCount:e=4,showBack:t}){return jsxs(Fragment,{children:[jsx("style",{children:Ys}),jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",gap:20},children:[t&&jsx("div",{style:{height:20}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[jsx("div",{style:{...Qs,width:64,height:64,borderRadius:10,flexShrink:0}}),jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:8},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsx("div",{style:{...me(0),height:14,width:48}}),jsx("div",{style:{...me(30),height:14,width:40}}),jsx("div",{style:{...me(60),height:14,width:40}})]}),jsx("div",{style:{...me(80),height:20,width:"80%",maxWidth:384,borderRadius:4}})]})]}),jsx("div",{style:{...me(100),height:16,width:192}}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:16},children:[jsx("div",{style:{...me(120),height:16,width:96}}),jsx("div",{style:{...me(140),height:16,width:80}})]}),jsx("div",{style:{...me(160),height:300,width:"100%",borderRadius:12}}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[jsx("div",{style:{...me(180),height:16,width:80}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsx("div",{style:{...me(200),height:28,width:200,borderRadius:8}}),jsx("div",{style:{...me(220),height:28,width:112,borderRadius:8}})]})]})]}),jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"8px 0"},children:jsx("div",{style:{...me(240),height:14,width:56}})}),Array.from({length:e}).map((r,o)=>jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 0",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsx("div",{style:{...me(260+o*40),width:28,height:28,borderRadius:8,flexShrink:0}}),jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:4},children:[jsx("div",{style:{...me(280+o*40),height:14,width:o%2===0?192:160}}),jsx("div",{style:{...me(300+o*40),height:10,width:64}})]}),jsx("div",{style:{...me(320+o*40),height:16,width:40}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsx("div",{style:{...me(340+o*40),height:32,width:80,borderRadius:8}}),jsx("div",{style:{...me(360+o*40),height:32,width:80,borderRadius:8}})]})]},o))]}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[jsx("div",{style:{...me(400),height:16,width:64}}),jsx("div",{style:{...me(420),height:14,width:"100%"}}),jsx("div",{style:{...me(440),height:14,width:"80%"}}),jsx("div",{style:{...me(460),height:14,width:"60%"}})]})]})]})}function Xs(){return jsxs(Fragment,{children:[jsx("style",{children:Ys}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",padding:16},children:[jsx("div",{style:{...me(0),height:40,width:"100%",borderRadius:8}}),jsx("div",{style:{...me(60),height:96,width:"100%",borderRadius:8}}),jsx("div",{style:{...me(120),height:40,width:"100%",borderRadius:8}})]})]})}var ra="var(--color-bullish)",na="var(--color-bearish)";function on(e){let t=Math.abs(e);return t>=1e9?`${parseFloat((e/1e9).toFixed(2))}B`:t>=1e6?`${parseFloat((e/1e6).toFixed(2))}M`:t>=1e3?`${parseFloat((e/1e3).toFixed(2))}K`:e.toLocaleString()}function em(e,t){return e<=0||t<=0?0:Math.pow(e/t,.3)}function tm(e,t){let r=new Float64Array(101),o=new Float64Array(101);for(let c of e){let f=Math.round(c.price*100);f>=0&&f<=100&&(r[f]+=c.quantity);}for(let c of t){let f=Math.round(c.price*100);f>=0&&f<=100&&(o[f]+=c.quantity);}let n=0,i=0,s=new Float64Array(101),a=new Float64Array(101);for(let c=100;c>=0;c--)n+=r[c],i+=r[c]*c/100,s[c]=n,a[c]=i;let l=0,u=0,d=new Float64Array(101),p=new Float64Array(101);for(let c=0;c<=100;c++)l+=o[c],u+=o[c]*c/100,d[c]=l,p[c]=u;let m=Math.max(s[0]??0,d[100]??0);return Array.from({length:101},(c,f)=>{let g=s[f]>0,v=d[f]>0,x=s[f]||d[f],b=r[f]>0||o[f]>0;return {priceCents:f,displayHeight:em(x,m),opacity:x>0?b?1:.5:0,isBid:g,isAsk:v,bidCumTotal:s[f],askCumTotal:d[f],bidCumCost:a[f],askCumCost:p[f]}})}function rm({info:e}){let{t}=useTranslation(),r=e.isBid?ra:na,o=e.leftPct>65?void 0:`${e.leftPct}%`,n=e.leftPct>65?`${100-e.leftPct}%`:void 0;return jsxs("div",{style:{position:"absolute",top:8,left:o,right:n,zIndex:10,background:"rgba(17,24,39,0.95)",border:"1px solid rgba(255,255,255,0.08)",borderRadius:8,padding:"8px 12px",fontSize:12,color:"#f9fafb",minWidth:140,pointerEvents:"none"},children:[jsx("div",{style:{marginBottom:4,fontWeight:600},children:t("predict.orderBook.depthToPrice",{price:e.priceCents})}),jsx("div",{style:{color:r},children:t("predict.orderBook.depthContracts",{amount:on(Math.round(e.cumTotal))})}),jsxs("div",{style:{color:r},children:["$",on(Math.round(e.cumCost))]})]})}var nm=memo(function({slot:t,onEnter:r,onLeave:o}){let n=useRef(null),i=t.isBid||t.isAsk,s=t.isBid?ra:t.isAsk?na:void 0;return jsx("div",{style:{position:"absolute",left:`${t.priceCents}%`,width:"1%",height:"100%",boxSizing:"border-box",borderRight:t.priceCents<100?"1px solid transparent":"none",cursor:i?"crosshair":"default"},onMouseEnter:()=>r(t,n.current),onMouseLeave:o,children:i&&jsx("div",{ref:n,style:{position:"absolute",bottom:0,left:0,width:"100%",height:`${t.displayHeight*100}%`,backgroundColor:s,opacity:t.opacity}})})}),om=[0,10,20,30,40,50,60,70,80,90,100];function im(){return jsx("div",{className:"relative flex h-6 items-center border-b border-t border-border px-1",style:{background:"rgba(0,0,0,0.15)"},children:om.map(e=>jsx("span",{className:"absolute text-neutral font-normal",style:{fontSize:10,left:`${e}%`,transform:e===0?"translateX(0px)":e===100?"translateX(-100%)":"translateX(-50%)"},children:e},e))})}function oa({bids:e,asks:t}){let{t:r}=useTranslation(),o=useMemo(()=>tm(e,t),[e,t]),n=useMemo(()=>{let p=e.length>0?Math.max(...e.map(c=>c.price)):0,m=t.length>0?Math.min(...t.map(c=>c.price)):1;return Math.round((p+m)/2*100)},[e,t]),i=useMemo(()=>o.some(p=>p.isBid||p.isAsk),[o]),[s,a]=useState(null),l=useRef(null),u=useCallback((p,m)=>{l.current&&(l.current.style.filter=""),m?(m.style.filter="brightness(1.5)",l.current=m):l.current=null,p.isBid||p.isAsk?a({priceCents:p.priceCents,isBid:p.isBid,cumTotal:p.isBid?p.bidCumTotal:p.askCumTotal,cumCost:p.isBid?p.bidCumCost:p.askCumCost,leftPct:p.priceCents}):a(null);},[]),d=useCallback(()=>{l.current&&(l.current.style.filter="",l.current=null),a(null);},[]);return i?jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",userSelect:"none",overflow:"hidden"},children:[jsxs("div",{style:{flex:1,position:"relative",width:"100%",overflow:"hidden"},children:[n>0&&jsx("div",{style:{position:"absolute",left:`${n}%`,top:0,bottom:0,width:1,backgroundImage:"repeating-linear-gradient(to bottom, #6b7280 0, #6b7280 4px, transparent 4px, transparent 8px)",zIndex:1,pointerEvents:"none"}}),s&&jsx(rm,{info:s}),o.map(p=>jsx(nm,{slot:p,onEnter:u,onLeave:d},p.priceCents))]}),jsx(im,{})]}):jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:r("predict.orderBook.noData")})}function da(e){let t=e*100,r=Math.round(t*10)/10;return Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`}function sa(){let{t:e}=useTranslation();return jsx("div",{className:"absolute inset-0 flex items-center justify-center text-neutral text-xs",children:jsx("span",{children:e("predict.orderBook.loading")})})}function ua({market:e,outcome:t="yes",onTradeAction:r,initialViewMode:o="depth",className:n,oddsFormatter:i}){let{t:s}=useTranslation(),[a,l]=useState(o),u=i??da,d=e.source,{data:p,isLoading:m,isFetching:c,refetch:f}=useRealtimeOrderbook({slug:e.slug,source:d,outcome:t}),g=useMemo(()=>(p?.bids??[]).map(S=>({price:S.price,quantity:S.size})),[p?.bids]),v=useMemo(()=>(p?.asks??[]).map(S=>({price:S.price,quantity:S.size})),[p?.asks]),x=useMemo(()=>g.length>0?Math.max(...g.map(S=>S.price)):null,[g]),b=useMemo(()=>v.length>0?Math.min(...v.map(S=>S.price)):null,[v]),w=useMemo(()=>{if(x==null||b==null)return null;let S=(b-x)*100;return Math.round(S*10)/10},[x,b]);return jsxs("div",{className:cn("flex flex-col",n??"h-[262px]"),children:[jsxs("div",{className:"flex h-9 items-center border-b border-border px-1 text-xs",children:[jsx("span",{className:"flex-1 text-left text-neutral",children:w!=null?`${s("predict.orderBook.spread")}: ${Number.isInteger(w)?`${w}\xA2`:`${w.toFixed(1)}\xA2`}`:null}),jsxs("span",{className:"flex flex-1 items-center justify-center gap-x-1 whitespace-nowrap",children:[x!=null&&jsxs("span",{style:{color:"var(--color-bullish)"},children:[s("predict.trade.bestBid"),": ",u(x)]}),x!=null&&b!=null&&jsx("span",{className:"text-neutral",children:"|"}),b!=null&&jsxs("span",{style:{color:"var(--color-bearish)"},children:[s("predict.trade.bestAsk"),": ",u(b)]})]}),jsxs("div",{className:"flex flex-1 items-center justify-end gap-x-2",children:[jsx("button",{type:"button",title:a==="depth"?"Orderbook":"Depth chart",onClick:()=>l(S=>S==="depth"?"table":"depth"),className:"flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground",children:a==="depth"?jsx(OrderbookTableIcon,{className:"h-4 w-4"}):jsx(OrderbookDepthIcon,{className:"h-4 w-4"})}),jsx("button",{type:"button",title:"Refresh",onClick:()=>f(),disabled:c,className:cn("flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground disabled:cursor-default disabled:opacity-50",c&&"animate-spin"),children:jsx(RefreshIcon,{className:"h-4 w-4"})})]})]}),jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[a==="depth"&&jsx(Fragment,{children:m?jsx(sa,{}):jsx(oa,{bids:g,asks:v})}),a==="table"&&jsx(Fragment,{children:m?jsx(sa,{}):jsx(um,{bids:g,asks:v,bestBid:x??void 0,bestAsk:b??void 0,spread:w??void 0,oddsFormatter:i})})]})]})}var Vo=4,dm=8;function um({bids:e,asks:t,spread:r,oddsFormatter:o}){let{t:n}=useTranslation(),[i,s]=useState(false),a=i?dm:Vo,l=t.length>Vo||e.length>Vo,u=useMemo(()=>[...t].sort((c,f)=>c.price-f.price).slice(0,a).reverse(),[t,a]),d=useMemo(()=>[...e].sort((c,f)=>f.price-c.price).slice(0,a),[e,a]),p=useMemo(()=>{let c=[...u,...d].map(f=>f.quantity);return Math.max(...c,1)},[u,d]);return u.length===0&&d.length===0?jsx("div",{className:"flex items-center justify-center h-full text-xs text-neutral",children:n("predict.orderBook.empty")}):jsxs("div",{className:"flex flex-col h-full overflow-y-auto text-xs font-mono select-none",children:[u.map(c=>jsx(aa,{price:c.price,quantity:c.quantity,side:"ask",maxQty:p,oddsFormatter:o},`ask-${c.price}`)),jsxs("div",{className:"relative flex items-center justify-center gap-x-2 py-1 border-y border-border text-neutral text-[10px]",children:[r!=null&&jsxs("span",{children:[n("predict.orderBook.spread"),":"," ",Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`]}),l&&jsx("button",{type:"button",onClick:()=>s(c=>!c),className:"absolute right-2 text-[10px] text-neutral transition-colors cursor-pointer hover:text-foreground",children:n(i?"predict.orderBook.collapse":"predict.orderBook.expand")})]}),d.map(c=>jsx(aa,{price:c.price,quantity:c.quantity,side:"bid",maxQty:p,oddsFormatter:o},`bid-${c.price}`)),jsxs("div",{className:"grid grid-cols-3 px-2 pt-2 pb-0.5 text-[10px] text-neutral border-t border-border",children:[jsx("span",{children:n("predict.orderBook.price")}),jsx("span",{className:"text-center",children:n("predict.orderBook.contracts")}),jsx("span",{className:"text-right",children:n("predict.orderBook.total")})]})]})}function aa({price:e,quantity:t,side:r,maxQty:o,oddsFormatter:n}){let i=r==="ask",s=Math.min(t/o*100,100),a=i?"bg-bearish/10":"bg-bullish/10",l=i?"text-bearish":"text-bullish",u=on(Math.round(t)),d=Math.round(t*e),p=`$${on(d)}`;return jsxs("div",{className:"relative grid grid-cols-3 px-2 py-1 hover:bg-content2 transition-colors cursor-default",children:[jsx("div",{className:`absolute inset-y-0 left-0 ${a} transition-[width] duration-200`,style:{width:`${s}%`}}),jsx("span",{className:`relative z-10 ${l}`,children:n?n(e):da(e)}),jsx("span",{className:"relative z-10 text-foreground text-center",children:u}),jsx("span",{className:"relative z-10 text-foreground text-right",children:p})]})}var Go=class extends Component{state={error:null};static getDerivedStateFromError(t){return {error:t}}componentDidCatch(t,r){}render(){return this.state.error?jsxs("div",{style:{height:this.props.fallbackHeight??320,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,color:"#6b7280",fontSize:13},children:[jsx("span",{children:"Chart unavailable"}),jsx("span",{style:{fontSize:11,opacity:.7},children:this.state.error.message})]}):this.props.children}},sn=4,pa=["#22d3ee","#a3e635","#f97316","#f472b6","#a78bfa"];function wm(e,t){let r=new Date(e);return t===le.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Pm(e,t){let r=new Date(e);return t===le.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):t===le.ONE_WEEK?r.toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function fa(e){return `${(e*100).toFixed(2)}%`}var Nm=[{range:le.ONE_DAY,label:"1D"},{range:le.ONE_WEEK,label:"1W"},{range:le.ONE_MONTH,label:"1M"},{range:le.ALL,label:"ALL"}];function Cm({value:e,onChange:t}){return jsx("div",{style:{display:"flex",alignItems:"center",gap:2},children:Nm.map(({range:r,label:o})=>{let n=r===e;return jsx("button",{onClick:()=>t(r),style:{padding:"2px 8px",border:"none",background:"transparent",color:n?"#f9fafb":"#6b7280",fontWeight:n?700:400,fontSize:12,cursor:"pointer",borderRadius:4,letterSpacing:"0.02em",transition:"color 0.15s",userSelect:"none"},children:o},r)})})}function Mm(){let e=useRef(null),t=useRef(null),r=useCallback(n=>{let i=e.current,s=t.current;if(!i||!s)return;let a=i.getBoundingClientRect(),l=(n.clientX-a.left)/a.width*100;s.style.background=`linear-gradient(to right, transparent ${l}%, rgba(0,0,0,0.55) ${l}%)`,s.style.opacity="1";},[]),o=useCallback(()=>{t.current&&(t.current.style.opacity="0");},[]);return {wrapperRef:e,overlayRef:t,onMouseMove:r,onMouseLeave:o}}function Em({active:e,payload:t,label:r,labelMap:o,allSeries:n,range:i}){if(!e||!n?.length)return null;let s=new Map;t?.forEach(l=>s.set(l.dataKey,l));let a=n.map(l=>s.get(l.slug)??{dataKey:l.slug,value:void 0,stroke:l.color,color:l.color});return jsxs("div",{style:{background:"rgba(10,10,10,0.92)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:8,padding:"8px 12px",minWidth:180,backdropFilter:"blur(8px)",fontSize:12},children:[jsx("div",{style:{color:"#9ca3af",marginBottom:6,fontWeight:500},children:typeof r=="number"?Pm(r,i):r}),a.map(l=>jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[jsx("span",{style:{display:"inline-block",width:3,height:14,borderRadius:2,background:l.stroke??l.color,flexShrink:0}}),jsx("span",{style:{color:"#9ca3af",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:120},children:o.get(l.dataKey)??l.dataKey}),jsx("span",{style:{color:"#f9fafb",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:l.value!=null?fa(l.value):"--"})]},l.dataKey))]})}function Tm({markets:e,selectedSlugs:t,colorMap:r,onToggle:o}){let[n,i]=useState(false),s=useRef(null);useEffect(()=>{if(!n)return;function u(d){s.current&&!s.current.contains(d.target)&&i(false);}return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[n]);let a=t.length>=sn,l=jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},children:[jsx("div",{style:{display:"flex",gap:3,flexShrink:0},children:t.map(u=>jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:r.get(u)??"#6b7280",display:"inline-block"}},u))}),jsx("span",{style:{color:"#e5e7eb",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.length===1?(()=>{let u=e.find(d=>d.slug===t[0]);return u?.outcomes?.[0]?.label??u?.question??"1 market"})():`${t.length} / ${e.length} markets`})]});return jsxs("div",{ref:s,style:{position:"relative",display:"inline-block",width:200},children:[jsxs("button",{onClick:()=>i(u=>!u),style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:8,border:"1px solid rgba(255,255,255,0.12)",background:"rgba(255,255,255,0.05)",cursor:"pointer",width:"100%",userSelect:"none"},children:[l,jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{flexShrink:0,transform:n?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.15s",color:"#6b7280"},children:jsx("path",{d:"M2 4l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),n&&jsxs("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,zIndex:50,background:"#111827",border:"1px solid rgba(255,255,255,0.1)",borderRadius:10,boxShadow:"0 8px 24px rgba(0,0,0,0.5)",minWidth:260,maxWidth:360,maxHeight:320,overflowY:"auto",padding:"6px 0"},children:[jsxs("div",{style:{padding:"4px 12px 8px",fontSize:11,color:"#6b7280",borderBottom:"1px solid rgba(255,255,255,0.06)",marginBottom:4},children:["Select up to ",sn," markets"]}),e.map((u,d)=>{let p=t.includes(u.slug),m=!p&&a,c=p&&t.length===1,f=r.get(u.slug)??"#6b7280",g=u.outcomes.find(x=>x.label.toLowerCase()==="yes")??u.outcomes[0],v=g?.price!=null?`${Math.round(g.price*100)}%`:null;return jsxs("button",{onClick:()=>{c||m||o(u.slug);},style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"7px 12px",border:"none",background:p?"rgba(255,255,255,0.05)":"transparent",cursor:m||c?"not-allowed":"pointer",opacity:m?.35:1,textAlign:"left",transition:"background 0.1s"},onMouseEnter:x=>{!m&&!c&&(x.currentTarget.style.background="rgba(255,255,255,0.07)");},onMouseLeave:x=>{x.currentTarget.style.background=p?"rgba(255,255,255,0.05)":"transparent";},children:[jsx("span",{style:{width:16,height:16,borderRadius:4,border:p?`2px solid ${f}`:"2px solid rgba(255,255,255,0.2)",background:p?`${f}30`:"transparent",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:p&&jsx("svg",{width:"9",height:"7",viewBox:"0 0 9 7",fill:"none",children:jsx("path",{d:"M1 3.5L3.5 6L8 1",stroke:f,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:f,flexShrink:0}}),jsx("span",{style:{color:p?"#f9fafb":"#9ca3af",fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u.outcomes?.[0]?.label??u.question}),v&&jsx("span",{style:{color:f,fontWeight:700,fontSize:12,flexShrink:0},children:v})]},u.id??`${d}-${u.slug}`)})]})]})}function Lm({series:e,colorMap:t,displayValues:r}){return jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px 24px",padding:"0 2px"},children:e.map(o=>{let n=t.get(o.marketSlug)??"#6b7280",i=r.get(o.marketSlug);return jsxs("div",{style:{display:"inline-flex",alignItems:"flex-start",gap:6},children:[jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:n,flexShrink:0,marginTop:3}}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:1},children:[jsx("span",{style:{color:"#9ca3af",fontSize:12,lineHeight:"17px",whiteSpace:"nowrap"},children:o.label}),jsx("span",{style:{color:"#f9fafb",fontSize:14,fontWeight:700,lineHeight:"20px",fontVariantNumeric:"tabular-nums"},children:i!=null?fa(i):"--"})]})]},o.marketSlug)})})}function Rm(e){let t=Math.floor(e.length/2);return e.length%2===1?e[t]:(e[t-1]+e[t])/2}function _m(e,t){if(e.length<=t)return e;let r=[],o=e.length/t;for(let n=0;n<t;n++){let i=Math.floor(n*o),s=Math.min(Math.floor((n+1)*o),e.length),a=e.slice(i,s),l=a.map(u=>u.price).sort((u,d)=>u-d);r.push({timestamp:a[a.length-1].timestamp,price:Rm(l)});}return r}function Im(e,t=200){if(e.length===0)return [];let r=e.map(a=>({...a,data:_m(a.data,t)})),o=new Set;r.forEach(a=>a.data.forEach(l=>o.add(l.timestamp)));let n=Array.from(o).sort((a,l)=>a-l),i=r.map(a=>{let l=new Map;return a.data.forEach(u=>l.set(u.timestamp,u.price)),{slug:a.marketSlug,map:l}}),s=new Map;return n.map(a=>{let l={timestamp:a};return i.forEach(({slug:u,map:d})=>{let p=d.get(a);if(p!==void 0)s.set(u,p),l[u]=p;else {let m=s.get(u);m!==void 0&&(l[u]=m);}}),l})}function ga(e){return jsx(Go,{children:jsx(Om,{...e})})}function Om({event:e,isLoading:t,className:r,volume:o,fillHeight:n=false}){let i=useMemo(()=>{let N=new Set;return (e.markets??[]).filter(C=>N.has(C.slug)?false:(N.add(C.slug),true))},[e.markets]),s=useMemo(()=>[...i].sort((N,C)=>{let U=X=>(X.outcomes.find(se=>se.label.toLowerCase()==="yes")??X.outcomes[0])?.price??0;return U(C)-U(N)}),[i]),[a,l]=useState(()=>s.slice(0,sn).map(N=>N.slug));useEffect(()=>{let N=new Set(i.map(C=>C.slug));l(C=>{let U=C.filter(X=>N.has(X));return U.length===C.length?C:U.length>0?U:s.slice(0,sn).map(X=>X.slug)});},[i,s]);let[u,d]=useState(Nn),p=useMemo(()=>{let N=new Map;return a.forEach((C,U)=>{N.set(C,pa[U%pa.length]);}),N},[a]),m=useMemo(()=>i.filter(N=>a.includes(N.slug)),[i,a]),{series:c,isLoading:f}=useMarketHistory(m,u),g=t||f,v=useMemo(()=>{if(c.length>0&&c.some(U=>U.data.length>0))return c;let N=Date.now(),C=864e5;return m.map(U=>{let se=(U.outcomes?.find(_=>_.label.toLowerCase()==="yes")??U.outcomes?.[0])?.price??.5;return {marketSlug:U.slug,label:U.outcomes?.[0]?.label??U.question,data:[{timestamp:N-7*C,price:se},{timestamp:N,price:se}]}})},[c,m]),x=useMemo(()=>u===le.ONE_DAY?96:u===le.ONE_WEEK?168:u===le.ONE_MONTH?180:300,[u]),b=useMemo(()=>Im(v,x),[v,x]),w=useMemo(()=>{if(b.length===0)return [0,1];let N=1/0,C=-1/0;if(a.forEach(X=>{b.forEach(se=>{let _=se[X];_!=null&&(_<N&&(N=_),_>C&&(C=_));});}),!isFinite(N))return [0,1];let U=Math.max((C-N)*.15,.05);return [Math.max(0,N-U),Math.min(1,C+U)]},[b,a]),S=useMemo(()=>{let N=new Map;return v.forEach(C=>{C.data.length>0&&N.set(C.marketSlug,C.data[C.data.length-1].price);}),N},[v]),h=useMemo(()=>{let N=new Map;return v.forEach(C=>N.set(C.marketSlug,C.label)),N},[v]),y=useMemo(()=>v.map(N=>({slug:N.marketSlug,color:p.get(N.marketSlug)??"#6b7280"})),[v,p]),{wrapperRef:k,overlayRef:P,onMouseMove:O,onMouseLeave:F}=Mm(),W=useCallback(N=>{l(C=>C.includes(N)?C.length<=1?C:C.filter(U=>U!==N):C.length>=sn?C:[...C,N]);},[]),[A,G]=useState(null),q=useRef(null),Y=useRef(""),re=useRef(0),te=!g&&b.length>0;return jsxs("div",{className:r,style:{display:"flex",flexDirection:"column",gap:12,...n?{height:"100%",minHeight:0}:null},children:[jsx(Lm,{series:v,colorMap:p,displayValues:A??S}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,...n?{flex:1,minHeight:0}:null},children:[jsx("div",{ref:k,style:{width:"100%",userSelect:"none",position:"relative",...n?{flex:1,minHeight:240}:{height:300}},onMouseMove:te?N=>{O(N),cancelAnimationFrame(re.current),re.current=requestAnimationFrame(()=>{G(q.current);});}:void 0,onMouseLeave:te?()=>{F(),cancelAnimationFrame(re.current),Y.current="",q.current=null,G(null);}:void 0,children:g?jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:jsx("div",{style:{width:28,height:28,borderRadius:"50%",border:"2.5px solid #22d3ee",borderTopColor:"transparent",animation:"spin 0.7s linear infinite"}})}):b.length===0?jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:"No price history data"}):jsxs(Fragment,{children:[jsx("div",{ref:P,style:{position:"absolute",inset:0,opacity:0,pointerEvents:"none",zIndex:1}}),jsx(ResponsiveContainer,{width:"100%",height:"100%",children:jsxs(LineChart,{data:b,margin:{top:8,right:16,left:0,bottom:0},children:[jsx(CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"#374151",opacity:.5}),jsx(XAxis,{dataKey:"timestamp",type:"number",scale:"time",domain:["dataMin","dataMax"],tickFormatter:N=>wm(N,u),axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},minTickGap:70}),jsx(YAxis,{domain:w,tickFormatter:N=>`${Math.round(N*100)}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},width:40,tickCount:6}),jsx(Tooltip,{content:N=>{let C=N;if(C.active&&C.payload?.length){let U=C.payload.map(X=>`${X.dataKey}:${X.value}`).join(",");if(U!==Y.current){Y.current=U;let X=new Map;C.payload.forEach(se=>{se.value!=null&&X.set(se.dataKey,se.value);}),q.current=X;}}return jsx(Em,{...C,labelMap:h,allSeries:y,range:u})},cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},wrapperStyle:{zIndex:2},isAnimationActive:false}),v.map(N=>{let C=p.get(N.marketSlug)??"#6b7280";return jsx(Line,{type:"linear",dataKey:N.marketSlug,stroke:C,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:C},connectNulls:true,isAnimationActive:false},N.marketSlug)}),A==null&&b.length>0&&v.map(N=>{let C=b[b.length-1],U=C[N.marketSlug];if(U==null)return null;let X=p.get(N.marketSlug)??"#6b7280";return jsx(ReferenceDot,{x:C.timestamp,y:U,ifOverflow:"extendDomain",shape:se=>{let{cx:_,cy:Se}=se;return _==null||Se==null?jsx("g",{}):jsxs("g",{children:[jsxs("circle",{cx:_,cy:Se,r:6,fill:X,opacity:.3,children:[jsx("animate",{attributeName:"r",values:"4;9;4",dur:"2s",repeatCount:"indefinite"}),jsx("animate",{attributeName:"opacity",values:"0.4;0.05;0.4",dur:"2s",repeatCount:"indefinite"})]}),jsx("circle",{cx:_,cy:Se,r:3.5,fill:X})]})}},`pulse-${N.marketSlug}`)})]})})]})}),jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"6px 8px",marginTop:6},children:[o!=null&&o>0&&jsxs("span",{style:{color:"#6b7280",fontSize:12},children:[formatAmountInUsd(o)," vol"]}),jsx("div",{style:{flex:1,minWidth:0}}),jsx(Cm,{value:u,onChange:d}),s.length>1&&jsx("div",{style:{width:"100%",display:"flex",alignItems:"center"},children:jsx(Tm,{markets:s,selectedSlugs:a,colorMap:p,onToggle:W})})]})]})]})}function qn(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function va(e,t){let r=e.outcomes[t==="yes"?0:1];return r?.best_ask??r?.price}function Qm(e){return `${parseFloat((e*100).toFixed(2))}%`}function xa(e){let t=e*100;return t<1&&t>0?"< 1":parseFloat(t.toFixed(2)).toString()}function Gn(e){return e.outcomes?.[0]?.label??e.question}function Xm(e){switch(e){case "polymarket":return "Polymarket";case "kalshi":return "Kalshi";default:return e}}function an(e){if(!e)return "\u2014";let t=new Date(e);if(isNaN(t.getTime()))return "\u2014";let r=t.toLocaleString("default",{month:"short"}),o=t.getDate(),n=t.getFullYear(),i=t.getHours().toString().padStart(2,"0"),s=t.getMinutes().toString().padStart(2,"0");return `${r} ${o}, ${n} ${i}:${s}`}function ba(e){let[t,r]=useState(0);if(useEffect(()=>{if(!e)return;r(Date.now());let d=setInterval(()=>r(Date.now()),1e3);return ()=>clearInterval(d)},[e]),!e||t===0)return null;let o=new Date(e).getTime();if(isNaN(o))return null;let n=o-t;if(n<=0)return null;let i=Math.floor(n/864e5),s=Math.floor(n%864e5/36e5),a=Math.floor(n%36e5/6e4),l=Math.floor(n%6e4/1e3),u=[];return i>0&&u.push(`${i}d`),u.push(`${String(s).padStart(2,"0")}h`),u.push(`${String(a).padStart(2,"0")}m`),u.push(`${String(l).padStart(2,"0")}s`),u.join(" ")}function ya(e){if(!e)return null;let t=new Date(e);if(isNaN(t.getTime()))return null;let r=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0"),n=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getDate().toString().padStart(2,"0"),s=t.getFullYear(),a=-t.getTimezoneOffset(),l=a>=0?"+":"-",u=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${o} ${n}/${i}/${s} (${l}${u})`}function Pa({event:e,onTradeAction:t}){let{t:r}=useTranslation(),{ref:o,isCollapsed:n}=useScrollCollapse(),i=useMemo(()=>{let p=[...e.markets||[]],m=p.filter(f=>f.status==="open").sort((f,g)=>qn(g)-qn(f)),c=p.filter(f=>f.status!=="open").sort((f,g)=>qn(g)-qn(f));return [...m,...c]},[e.markets]),s=e.status==="closed"||e.status==="voided",a=ba(s?void 0:e.start_at),l=ba(s?void 0:e.end_at),u=ya(e.start_at),d=ya(e.end_at);return jsxs("div",{className:"w-full flex flex-col gap-y-4 lg:gap-y-6",children:[jsxs("div",{ref:o,className:`sticky top-0 z-30 flex items-center backdrop-blur-md transition-all duration-300 ${n?"h-14 lg:h-16 gap-x-2 py-2 px-1 lg:px-4 -mx-1 lg:-mx-4 shadow-sm":"h-16 lg:h-20 gap-x-2 lg:gap-x-4"}`,children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",classNames:{base:"bg-transparent"},className:`flex-shrink-0 transition-all duration-300 ${n?"!h-10 !w-10 lg:!h-12 lg:!w-12":"!h-16 !w-16 lg:!h-20 lg:!w-20"}`}),jsxs("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[!n&&jsxs("div",{className:"flex items-center gap-1.5",children:[e.tags?.slice(0,3).map((p,m)=>jsxs(Fragment$1,{children:[m>0&&jsx("span",{className:"text-sm text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-sm text-neutral truncate",children:p.label})]},p.slug)),jsx(tf,{source:e.source})]}),jsx("span",{className:`font-semibold truncate transition-all duration-300 ${n?"text-sm lg:text-base":"text-lg lg:text-xl"}`,children:e.title})]})]}),(a||l||s)&&jsx("div",{className:"flex items-center gap-x-2 text-xs lg:text-sm font-mono",children:s?d&&jsx("span",{className:"text-neutral",children:r("predict.event.endedAt",{time:d})}):a?jsxs(Fragment,{children:[jsx("span",{className:"text-foreground",children:r("predict.event.beginsIn",{time:a})}),u&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-neutral",children:u})]})]}):l?jsxs(Fragment,{children:[jsx("span",{className:"text-foreground",children:r("predict.event.endsIn",{time:l})}),d&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-neutral",children:d})]})]}):null}),jsx(ga,{event:e,volume:e.volume??void 0}),jsx(Jm,{markets:i,onTradeAction:t}),jsx(ef,{markets:i,event:e})]})}var ka=5;function Jm({markets:e,onTradeAction:t}){let{t:r}=useTranslation(),{isDesktop:o}=useScreen(),[n,i]=useState(false),[s,a]=useState(null),l=useMemo(()=>{let v=new Set;return e.filter(x=>v.has(x.slug)?false:(v.add(x.slug),true))},[e]),u=l.find(v=>v.status==="open")?.slug,[d,p]=useState(u?`${u}:yes`:null);if(l.length===0)return null;let m=l.length>ka,c=n?l:l.slice(0,ka),f=v=>{a(x=>x===v?null:v);},g=(v,x,b)=>{p(`${v.slug}:${x}`),o&&a(v.slug),t?.(v,x,b);};return jsxs("div",{className:"flex flex-col",children:[jsxs("table",{className:"w-full border-collapse",children:[jsx("thead",{children:jsxs("tr",{children:[jsx("th",{}),jsx("th",{className:"py-2 text-left text-xs text-neutral font-normal lg:text-center lg:text-sm",children:r("predict.market.table.chance")}),jsx("th",{})]})}),jsx("tbody",{children:c.map((v,x)=>{let b=s===v.slug;return jsx(Zm,{market:v,activeYes:d===`${v.slug}:yes`,activeNo:d===`${v.slug}:no`,isExpanded:b,onToggleExpand:()=>f(v.slug),onTradeAction:g},v.id??`${x}-${v.slug}`)})})]}),m&&jsxs("button",{type:"button",onClick:()=>i(v=>!v),className:"flex w-full items-center justify-start gap-x-2 py-2 pl-1 text-xs text-neutral lg:pl-2 lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsx("span",{children:r(n?"predict.event.rules.collapse":"predict.event.moreMarketsLabel")}),jsx(ChevronDownIcon,{className:cn("h-4 w-4 transition-transform",n&&"rotate-180")})]})]})}function Zm({market:e,activeYes:t,activeNo:r,isExpanded:o,onToggleExpand:n,onTradeAction:i}){let{t:s}=useTranslation(),a=e.status==="open",l=e.volume?`${formatAmountInUsd(e.volume)} vol`:void 0,{data:u}=useRealtimeOrderbook({slug:e.slug,source:e.source,outcome:"yes"},{enabled:a}),{data:d}=useOrderbook({slug:e.slug,source:e.source,outcome:"no"},{enabled:false,refetchInterval:false}),p=pickBestAsk(u,"yes")??va(e,"yes")??0,m=pickBestAsk(d,"no")??va(e,"no");return jsxs(Fragment,{children:[jsxs("tr",{className:"cursor-pointer border-b border-border text-xs hover:bg-content2 lg:text-base",onClick:n,role:"button",tabIndex:0,onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),n());},children:[jsx("td",{className:"py-2 pl-1 lg:pl-2",children:jsxs("div",{className:"flex items-center gap-x-1 lg:gap-x-2",children:[e.image_url&&jsx(Avatar,{src:e.image_url,name:Gn(e)?.[0]||"?",radius:"lg",className:"size-5 shrink-0 lg:size-8",imgProps:{className:"object-cover"}}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-foreground truncate max-w-[200px] lg:max-w-[300px]",children:Gn(e)}),l&&jsx("span",{className:"text-[8px] text-neutral lg:text-xxs",children:l})]})]})}),jsx("td",{className:"py-2 text-left text-foreground lg:text-center",children:Qm(p)}),jsx("td",{className:"py-2 pr-1 lg:pr-2",children:a?jsxs("div",{className:"flex items-center justify-end gap-x-2",children:[jsx("button",{type:"button",className:cn("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all focus-visible:outline-2 focus-visible:outline-primary/40 focus-visible:outline-offset-2",t?"bg-primary text-primary-foreground":"bg-primary/10 text-primary"),onClick:c=>{c.stopPropagation(),i?.(e,"yes","buy");},children:s("predict.market.action.yes",{price:xa(p)})}),jsx("button",{type:"button",className:cn("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all focus-visible:outline-2 focus-visible:outline-primary/40 focus-visible:outline-offset-2",r?"bg-secondary text-secondary-foreground":"bg-secondary/10 text-secondary"),onClick:c=>{c.stopPropagation(),i?.(e,"no","buy");},children:m!=null?s("predict.market.action.no",{price:xa(m)}):s("predict.market.no")})]}):jsx("div",{className:"flex items-center justify-end",children:jsx("span",{className:cn("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",e.status==="closed"?"bg-neutral/10 text-neutral":e.status==="voided"?"bg-warning/10 text-warning":"bg-primary/10 text-primary"),children:e.status==="closed"?s("predict.event.status.closed"):e.status==="voided"?s("predict.event.status.voided"):s("predict.event.status.pending")})})})]}),o&&jsx("tr",{children:jsx("td",{colSpan:3,className:"pb-3",children:jsx("div",{className:"max-h-100 overflow-y-auto",children:jsx(ua,{market:e,outcome:r?"no":"yes",onTradeAction:i})})})})]})}function ef({markets:e,event:t}){let{t:r}=useTranslation(),[o,n]=useState(false),[i,s]=useState(false),[a,l]=useState(0),u=e.filter(c=>c.rules&&c.rules.length>0||c.description);if(u.length===0)return null;let d=u[a]??u[0],p=d.rules&&d.rules.length>0?d.rules.join(`
|
|
77
77
|
|
|
78
|
-
`):d.description??"";if(!p)return null;let m=p.length>200&&!o?p.slice(0,200)+"...":p;return jsxs("div",{className:"flex flex-col gap-y-3",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-semibold text-foreground lg:text-base",children:r("predict.event.rules")}),u.length>1&&jsxs(Dropdown,{placement:"bottom-end",classNames:{content:"min-w-36 bg-content1 border border-border"},children:[jsx(DropdownTrigger,{children:jsx(Button,{size:"sm",variant:"bordered",radius:"lg",endContent:jsx(ChevronDownIcon,{className:"h-3.5 w-3.5"}),className:"text-xs text-foreground",children:Gn(d)})}),jsx(DropdownMenu,{"aria-label":"Select market rules",selectionMode:"single",selectedKeys:[String(a)],onAction:c=>{l(Number(c)),n(false);},classNames:{list:"gap-1"},itemClasses:{base:"rounded-md px-3 h-8"},children:u.map((c,f)=>jsx(DropdownItem,{className:cn$1(f===a?"bg-content2 text-foreground":"text-neutral","data-[hover=true]:bg-content2 data-[hover=true]:text-foreground"),children:Gn(c)},String(f)))})]})]}),jsx("div",{className:"text-xs text-foreground/80 lg:text-sm whitespace-pre-wrap",children:m}),p.length>200&&jsx("button",{type:"button",onClick:()=>n(c=>!c),className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors self-start",children:r(o?"predict.event.rules.collapse":"predict.event.showMore")}),jsxs("button",{type:"button",onClick:()=>s(c=>!c),className:"flex items-center justify-between w-full mt-2 text-xs font-medium text-neutral lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsx("span",{children:r("predict.event.timelineAndPayout")}),jsx(ChevronDownIcon,{className:cn$1("h-4 w-4 transition-transform",i&&"rotate-180")})]}),i&&jsxs(Fragment,{children:[jsx("div",{className:"flex flex-col",children:(()=>{let c=d.status,f=[];return d.created_at&&f.push({label:r("predict.event.timeline.created"),value:rn(d.created_at),isActive:true}),f.push({label:r("predict.event.timeline.open"),value:rn(d.start_at),isActive:c!=="pending"}),c==="voided"?f.push({label:r("predict.event.timeline.voided"),value:rn(d.closed_at??d.end_at),isActive:true}):c==="closed"?f.push({label:r("predict.event.timeline.closed"),value:rn(d.closed_at??d.end_at),isActive:true}):f.push({label:r("predict.event.timeline.close"),value:rn(d.end_at),isActive:false}),f})().map((c,f,g)=>jsxs("div",{className:"flex items-stretch gap-x-3",children:[jsxs("div",{className:"flex flex-col items-center w-3",children:[jsx("div",{className:`h-3 w-3 shrink-0 rounded-full border-2 mt-0.5 ${c.isActive?"border-primary bg-primary":"border-border bg-transparent"}`}),f<g.length-1&&jsx("div",{className:"w-px flex-1 bg-border"})]}),jsxs("div",{className:`flex flex-col ${f<g.length-1?"pb-4":""}`,children:[jsx("span",{className:"text-xs font-medium text-foreground lg:text-sm",children:c.label}),jsx("span",{className:"text-xs text-neutral lg:text-sm",children:c.value})]})]},c.label))}),jsxs("div",{className:"flex flex-wrap items-center gap-x-3 text-xxs text-neutral mt-2 lg:text-xs",children:[jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.event"),":"]})," ",jsx("span",{className:"text-foreground",children:t.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.market"),":"]})," ",jsx("span",{className:"text-foreground",children:d.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.source"),":"]})," ",jsx("span",{className:"text-foreground",children:jm(d.source)})]})]})]})]})}function Qm({source:e}){return jsxs("span",{className:"inline-flex items-center gap-x-1 text-neutral-400",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsx("span",{className:"text-neutral-600",children:"\xB7"}),e==="polymarket"?jsx(PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsx(KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}function wa({eventSlug:e,source:t,onTradeAction:r}){let{data:o,isLoading:n,error:i}=useEvent({slug:e,source:t});return n?jsx(Zr,{}):i||!o?jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:i?.message||"Event not found"}):jsx(Sa,{event:o,onTradeAction:r})}var tf={kalshi:{label:"KALSHI",color:"#00d492",bgColor:"rgba(0, 212, 146, 0.12)",icon:jsx(KalshiIcon,{className:"w-3.5 h-3.5 shrink-0"})},polymarket:{label:"POLYMARKET",color:"#50a2ff",bgColor:"rgba(43, 127, 255, 0.12)",icon:jsx(PolymarketIcon,{className:"w-3.5 h-3.5 shrink-0"})},dflow:{label:"DFLOW",color:"rgb(16, 185, 129)",bgColor:"rgba(16, 185, 129, 0.12)",icon:null}},rf={label:"Unknown",color:"rgb(156, 163, 175)",bgColor:"rgba(156, 163, 175, 0.12)",icon:null};function Ot(e){return tf[e]??rf}function Yy({source:e,className:t}){let r=Ot(e);return jsxs("span",{className:cn$1("inline-flex items-center gap-x-1 rounded-md px-1.5 py-0.5 text-xs font-medium",t),style:{backgroundColor:r.bgColor,color:r.color},children:[r.icon,r.label]})}var Na="rgba(39,39,42,0.6)",df="rgba(63,63,70,0.8)";function uf(e){return e==null?"-":formatAmountInUsd(e)}function Ma({eventSlug:e,source:t,limit:r=4,onEventClick:o,onEventHover:n}){let{t:i}=useTranslation(),{data:s,isLoading:a}=useSimilarEvents({slug:e,source:t,limit:r});return a||!s||s.length===0?null:jsxs("div",{className:"flex flex-col gap-y-3 mt-6 px-1 lg:px-0",children:[jsx("span",{style:{color:"#f4f4f5",fontSize:14,fontWeight:600},children:i("predict.similar.title")}),jsx("div",{className:"grid grid-cols-1 gap-2",children:s.map(l=>jsx(pf,{event:l,onClick:o,onHover:n},`${l.source}-${l.slug}`))})]})}function pf({event:e,onClick:t,onHover:r}){let{t:o}=useTranslation(),n=Ot(e.source),i=useMemo(()=>uf(e.volume),[e.volume]),s=e.tags?.[0];return jsxs("button",{type:"button",onClick:()=>t?.(e),onMouseEnter:a=>{a.currentTarget.style.borderColor=df,r?.(e);},onMouseLeave:a=>{a.currentTarget.style.borderColor=Na;},style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",borderRadius:14,border:`1px solid ${Na}`,background:"rgba(24,24,27,0.4)",cursor:"pointer",textAlign:"left",width:"100%",transition:"border-color 0.2s"},className:"group",children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title?.[0]||"?",radius:"full",className:"size-9 shrink-0 bg-transparent",imgProps:{className:"object-cover"}}),jsxs("div",{style:{display:"flex",flexDirection:"column",minWidth:0,flex:1,gap:2},children:[jsx("span",{style:{fontSize:13,fontWeight:500,color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.title}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,color:n.color,flexShrink:0},children:[n.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase"},children:n.label})]}),jsx("span",{style:{color:"#52525b"},children:"\xB7"}),jsxs("span",{style:{color:"#a1a1aa"},children:[i," ",o("predict.event.volume")]}),s&&jsxs(Fragment,{children:[jsx("span",{style:{color:"#52525b"},children:"\xB7"}),jsx("span",{style:{color:"#71717a"},children:s.label})]})]})]}),jsx(ChevronRightIcon,{width:14,height:14,className:"shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",style:{color:"#71717a"}})]})}function Qn(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function y1({eventSlug:e,source:t,chain:r,walletAddress:o,onSimilarEventClick:n,onSimilarEventHover:i,onBack:s,renderActivitySection:a,onInsufficientBalance:l,onSetupRequired:u,slippageBps:d}){let{t:p}=useTranslation(),{isDesktop:m}=useScreen(),{onOpen:c}=useAsyncModal(Vr),{onOpen:f}=useAsyncModal(Fo),{data:g,isLoading:v}=useEvent({slug:e,source:t}),x=useMemo(()=>{let P=[...g?.markets||[]],I=P.filter(W=>W.status==="open").sort((W,O)=>Qn(O)-Qn(W)),D=P.filter(W=>W.status!=="open").sort((W,O)=>Qn(O)-Qn(W));return [...I,...D]},[g?.markets]),[b,w]=useState(null),S=useCallback((P,I,D)=>{w(W=>({market:P,outcome:I,side:D,version:(W?.version??0)+1})),!m&&g&&(D==="sell"?f({params:{event:g,market:P,initialOutcome:I,chain:r,slippageBps:d,onSetupRequired:u}}):c({params:{event:g,market:P,initialOutcome:I,chain:r,slippageBps:d,onInsufficientBalance:l}}));},[m,g,r,d,c,f,l,u]),h=b?.market??x[0];if(v){let P=!!s;return m?jsxs("div",{className:"flex w-full max-w-6xl mx-auto gap-x-4 lg:gap-x-6",children:[jsx("div",{className:"min-w-0 flex-1 max-w-3xl",children:jsx(Zr,{showBack:P})}),jsx("aside",{className:"hidden lg:block w-[340px] xl:w-[380px] shrink-0",children:jsx("div",{className:"sticky top-4 max-h-[calc(100dvh-2rem)] overflow-y-auto scrollbar-thin",children:jsx(Ys,{})})})]}):jsx(Zr,{showBack:P})}let y=b?`${b.market.slug}-${b.version}`:h?.slug??"default",k=b?.side==="sell";return jsxs("div",{className:"flex w-full flex-col gap-y-4 pb-12 lg:max-w-7xl lg:gap-y-8 lg:pb-16 mx-auto",children:[jsxs("div",{className:"flex w-full justify-center gap-4 pt-4 lg:gap-6",children:[jsxs("div",{className:"flex-auto min-w-0 flex flex-col gap-y-4 px-4 lg:gap-y-6 lg:px-0",children:[s&&jsx("div",{className:"flex items-center justify-between",children:jsx(Button,{as:"a",onPress:s,startContent:jsx(ChevronLeftIcon,{className:"h-4 w-4"}),className:"text-neutral bg-transparent h-5 min-h-5 gap-x-2 p-0 text-base w-auto min-w-auto",children:p("common.back")})}),jsx(wa,{eventSlug:e,source:t,onTradeAction:S})]}),jsxs("div",{className:"hidden flex-none w-md flex-col gap-y-4 lg:sticky lg:top-4 lg:flex lg:self-start",children:[h&&(k?jsx(Wn,{event:g,market:h,initialOutcome:b?.outcome,chain:r,slippageBps:d,onSetupRequired:u},y):jsx(In,{event:g,market:h,initialOutcome:b?.outcome,chain:r,slippageBps:d,onInsufficientBalance:l},y)),g&&jsx(Ma,{eventSlug:e,source:g.source,onEventClick:n,onEventHover:i})]})]}),g&&jsx("div",{className:"flex w-full flex-col",children:a?a({event:g,walletAddress:o}):jsx(js,{event:g,walletAddress:o})}),jsx(On,{}),jsx($s,{}),jsx(Ts,{})]})}function Ta(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Cf(e){switch(e){case le.ONE_DAY:return {interval:"15m",limit:96};case le.ONE_WEEK:return {interval:"1h",limit:168};case le.ONE_MONTH:return {interval:"4h",limit:180};case le.ALL:return {interval:"1d",limit:300};default:return {interval:"1h",limit:100}}}var M1=e=>{let{candlestickMarketSlugs:t,chartRange:r=Nn,source:o}=e,n=usePredictClient(),i=useMemo(()=>Cf(r),[r]),{data:s,isLoading:a,error:l}=useEvent({slug:e.eventSlug,source:o}),u=useMemo(()=>{if(!s?.markets)return [];let f=new Set,g=s.markets.filter(x=>f.has(x.slug)?false:(f.add(x.slug),true));return (t&&t.length>0?t.slice(0,4).map(x=>g.find(b=>b.slug===x)).filter(x=>x!==void 0):[...g].sort((x,b)=>Ta(b)-Ta(x)).slice(0,4)).map(x=>x.slug)},[t,s?.markets]),d=useQueries({queries:u.map(f=>({queryKey:candlesticksQueryKey(f,i),queryFn:()=>n.listCandlesticks(f,i),enabled:u.length>0}))}),p=d.some(f=>f.isLoading),m=useMemo(()=>{let f=new Map;return u.forEach((g,v)=>{let x=d[v]?.error;x&&f.set(g,x);}),f},[u,d]),c=useMemo(()=>{let f=new Map;return u.forEach((g,v)=>{let x=d[v]?.data;x&&f.set(g,x);}),f},[u,d]);return {event:s,isEventLoading:a,eventError:l,candlestickParams:i,candlesticks:c,isCandlesticksLoading:p,candlestickErrors:m}};function Xo({comment:e,anonymousLabel:t,isReply:r=false}){let{profile:o}=e,n=o.name||o.pseudonym||t,i=useMemo(()=>Lf(e.created_at),[e.created_at]);return jsxs("div",{className:cn$1("flex gap-x-2.5 px-1 py-3 border-b border-border/40 lg:px-2",r&&"pl-8 lg:pl-9"),children:[jsx(Mf,{src:o.profile_image,name:n,className:cn$1("shrink-0",r?"size-6":"size-8 lg:size-7")}),jsxs("div",{className:"min-w-0 flex-1",children:[jsxs("div",{className:"flex items-baseline gap-x-2",children:[jsx("span",{className:"truncate text-sm font-medium text-foreground",children:n}),jsx("span",{className:"ml-auto shrink-0 text-xs text-neutral",children:i})]}),jsx("p",{className:"mt-1 whitespace-pre-wrap break-words text-sm leading-relaxed text-foreground/90",children:e.body}),jsxs("div",{className:"mt-2 flex items-center gap-x-1 text-neutral",children:[jsx(Ef,{className:"size-3.5"}),jsx("span",{className:"text-xs tabular-nums",children:e.reaction_count})]})]})]})}function Mf({src:e,name:t,className:r}){let o=t.trim().charAt(0).toUpperCase()||"?",n=useMemo(()=>Tf(t),[t]);return e?jsx("img",{src:e,alt:t,loading:"lazy",className:cn$1("rounded-full object-cover",r)}):jsx("span",{className:cn$1("flex items-center justify-center rounded-full text-xs font-semibold text-white",r),style:{backgroundColor:n},"aria-hidden":true,children:o})}function Ef({className:e}){return jsx("svg",{viewBox:"0 0 24 24",className:e,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":true,children:jsx("path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z"})})}function Tf(e){let t=0;for(let o=0;o<e.length;o++)t=e.charCodeAt(o)+((t<<5)-t);return `hsl(${Math.abs(t)%360}, 55%, 45%)`}function Lf(e){let t=new Date(e).getTime();if(Number.isNaN(t))return "";let r=Math.max(0,Math.floor((Date.now()-t)/1e3));if(r<60)return "now";let o=Math.floor(r/60);if(o<60)return `${o}m`;let n=Math.floor(o/60);if(n<24)return `${n}h`;let i=Math.floor(n/24);if(i<7)return `${i}d`;let s=Math.floor(i/7);return s<5?`${s}w`:new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}var zf={latest:{order:"createdAt",ascending:false},oldest:{order:"createdAt",ascending:true},mostLiked:{order:"reactionCount",ascending:false}},_a={latest:"predict.comments.sortLatest",oldest:"predict.comments.sortOldest",mostLiked:"predict.comments.sortMostLiked"},Wf=["latest","oldest","mostLiked"],Uf=600,$f=112;function Kf({slug:e,source:t,limit:r=20,height:o,className:n}){let{t:i}=useTranslation(),[s,a]=useState("latest"),[l,u]=useState(false),d=zf[s],{data:p,isLoading:m,isFetchingNextPage:c,hasNextPage:f,fetchNextPage:g}=useInfiniteComments({slug:e,source:t,limit:r,order:d.order,ascending:d.ascending,holders_only:l}),v=useMemo(()=>p?.pages?.flatMap(D=>D.items)??[],[p?.pages]),x=useRef(null),{height:b}=useResizeObserver({ref:x}),w=o??(b||Uf),S=useDynamicRowHeight({defaultRowHeight:$f,key:`${e}:${t}:${s}:${l}`}),h=v.length,y=h+(f?1:0),k=useCallback(D=>D<h,[h]),P=useCallback(async()=>{f&&!c&&await g();},[f,c,g]),I=useInfiniteLoader({isRowLoaded:k,loadMoreRows:P,rowCount:y,threshold:5});return jsxs("div",{className:cn$1("flex h-full w-full flex-col",n),children:[jsx(jf,{sort:s,onSortChange:a,holdersOnly:l,onHoldersOnlyChange:u}),jsx("div",{className:"min-h-0 flex-auto overflow-hidden",ref:x,children:m?jsx(qf,{}):v.length===0?jsx(Gf,{message:i("predict.comments.empty")}):jsx(List,{className:"no-scrollbar",style:{height:w},onRowsRendered:I,rowComponent:Vf,rowCount:y,rowHeight:S,rowProps:{comments:v,itemCount:h,anonymousLabel:i("predict.comments.anonymous")},overscanCount:4})})]})}function Vf({index:e,style:t,comments:r,itemCount:o,anonymousLabel:n}){if(e>=o)return jsx("div",{style:t,className:"flex items-center justify-center py-4",children:jsx(Spinner,{size:"sm"})});let i=r[e];return i?jsx("div",{style:t,children:jsx(Xo,{comment:i,anonymousLabel:n,isReply:!!i.parent_comment_id})}):null}function jf({sort:e,onSortChange:t,holdersOnly:r,onHoldersOnlyChange:o}){let{t:n}=useTranslation(),[i,s]=useState(false),a=useRef(null);return useEffect(()=>{if(!i)return;let l=d=>{a.current&&!a.current.contains(d.target)&&s(false);},u=d=>{d.key==="Escape"&&s(false);};return document.addEventListener("mousedown",l),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",u);}},[i]),jsxs("div",{className:"flex items-center justify-between gap-2 px-1 py-2 lg:px-2",children:[jsxs("div",{ref:a,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>s(l=>!l),className:"inline-flex items-center gap-x-1.5 rounded-lg border border-border bg-content2/40 px-3 py-1.5 text-sm text-foreground transition-colors hover:bg-content2 cursor-pointer",children:[jsx(Yf,{className:"size-3.5 text-neutral"}),jsx("span",{children:n(_a[e])}),jsx(Qf,{className:cn$1("size-3.5 text-neutral transition-transform",i&&"rotate-180")})]}),i&&jsx("div",{className:"absolute left-0 top-full z-20 mt-1.5 min-w-40 overflow-hidden rounded-xl border border-border bg-content1 p-1 shadow-xl",children:Wf.map(l=>{let u=l===e;return jsxs("button",{type:"button",onClick:()=>{t(l),s(false);},className:cn$1("flex w-full items-center gap-x-2 rounded-lg px-3 py-2 text-left text-sm transition-colors cursor-pointer",u?"bg-primary/10 text-primary":"text-neutral hover:bg-content2 hover:text-foreground"),children:[jsx("span",{className:"flex-1 font-medium",children:n(_a[l])}),u&&jsx(Ia,{className:"size-4 text-primary"})]},l)})})]}),jsxs("button",{type:"button",role:"switch","aria-checked":r,onClick:()=>o(!r),className:cn$1("inline-flex items-center gap-x-1.5 rounded-lg border px-3 py-1.5 text-sm transition-colors cursor-pointer",r?"border-primary/40 bg-primary/10 text-primary":"border-border bg-content2/40 text-neutral hover:text-foreground"),children:[jsx("span",{className:cn$1("flex size-4 items-center justify-center rounded border",r?"border-primary bg-primary":"border-neutral"),children:r&&jsx(Ia,{className:"size-3 text-background"})}),n("predict.comments.holdersOnly")]})]})}function qf(){return jsx("div",{className:"flex flex-col gap-y-4 px-1 py-3 lg:px-2",children:Array.from({length:6}).map((e,t)=>jsxs("div",{className:"flex gap-x-2.5",children:[jsx(Skeleton,{className:"size-8 shrink-0 rounded-full"}),jsxs("div",{className:"flex-1 space-y-2",children:[jsx(Skeleton,{className:"h-3 w-24 rounded"}),jsx(Skeleton,{className:"h-3 w-full rounded"}),jsx(Skeleton,{className:"h-3 w-2/3 rounded"})]})]},t))})}function Gf({message:e}){return jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[jsx(EmptyIcon,{width:28,height:28,className:"text-neutral"}),jsx("p",{className:"mt-2 text-sm text-neutral",children:e})]})}function Yf({className:e}){return jsxs("svg",{viewBox:"0 0 24 24",className:e,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":true,children:[jsx("path",{d:"m21 16-4 4-4-4"}),jsx("path",{d:"M17 20V4"}),jsx("path",{d:"m3 8 4-4 4 4"}),jsx("path",{d:"M7 4v16"})]})}function Qf({className:e}){return jsx("svg",{viewBox:"0 0 24 24",className:e,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":true,children:jsx("path",{d:"m6 9 6 6 6-6"})})}function Ia({className:e}){return jsx("svg",{viewBox:"0 0 24 24",className:e,fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":true,children:jsx("path",{d:"M20 6 9 17l-5-5"})})}var Zf=10,eg=atomWithStorage("liberfi:predict_search_histories",[],void 0,{getOnInit:true});function to(){let[e,t]=useAtom(eg),r=useCallback(n=>{let i=n.trim();i&&t(s=>{let a=s.filter(l=>l!==i);return [i,...a].slice(0,Zf)});},[t]),o=useCallback(()=>{t([]);},[t]);return {histories:e,addHistory:r,clearHistories:o}}function Ha({histories:e,onSelect:t,onClear:r,className:o}){let{t:n}=useTranslation();return e.length===0?null:jsxs("div",{className:cn$1("px-4 pb-4",o),children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-medium",children:n("predict.search.history")}),jsx(Button,{isIconOnly:true,size:"sm",className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsx(TrashIcon,{width:20,height:20})})]}),jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:e.map(i=>jsx(Chip,{size:"sm",variant:"bordered",className:cn$1("text-neutral","border-border border-1","cursor-pointer","hover:opacity-hover"),onClick:()=>t?.(i),children:i},i))})]})}function za({onSelect:e,className:t}){let{histories:r,clearHistories:o}=to();return jsx(Ha,{className:cn$1(t),histories:r,onSelect:e,onClear:o})}function Wa({value:e,onValueChange:t,onClear:r,onEscape:o,className:n}){let{t:i}=useTranslation();return jsx("div",{className:n,children:jsx(StyledInput,{autoFocus:true,variant:"bordered",radius:"lg",value:e,onValueChange:t,placeholder:i("predict.search.placeholder"),classNames:{inputWrapper:["!bg-[rgba(39,39,42,0.6)]","!border-[rgba(63,63,70,0.5)]","data-[hover=true]:!bg-[rgba(39,39,42,1)]","group-data-[focus=true]:!bg-[rgba(39,39,42,1)]","group-data-[focus=true]:!border-[rgba(63,63,70,0.8)]"].join(" ")},startContent:jsx(SearchIcon,{width:20,height:20,className:"text-neutral"}),endContent:e?jsx(Button,{isIconOnly:true,className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsx(XCloseIcon,{width:20,height:20})}):jsx(Kbd,{className:"min-w-8 justify-center text-xs text-neutral bg-transparent border border-[rgba(63,63,70,0.5)] rounded-lg cursor-pointer select-none",onMouseDown:s=>{s.preventDefault(),o?.();},children:"Esc"})})})}function yg(e){return e==null?"-":formatAmountInUsd(e)}function Ua({event:e,href:t,LinkComponent:r,onSelect:o,onHover:n,className:i}){let{t:s}=useTranslation(),a=e.tags?.[0],l=Ot(e.source),u=useMemo(()=>yg(e.volume),[e.volume]);return jsxs(Linkable,{href:t,LinkComponent:r,className:cn$1("group w-full h-full px-3 flex items-center gap-3","hover:cursor-pointer hover:bg-content2 rounded-lg","transition-colors duration-150",i),onClick:d=>{t&&o&&d.preventDefault(),o?.(e);},onMouseEnter:()=>n?.(e),children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"full",className:"h-10 w-10 flex-shrink-0"}),jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-center gap-y-0.5",children:[jsx("span",{className:"min-w-0 text-sm font-medium line-clamp-2 group-hover:text-primary transition-colors",children:e.title}),jsxs("div",{className:"flex items-center gap-x-2 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[jsxs("span",{className:"inline-flex items-center gap-x-1 shrink-0",style:{color:l.color},children:[l.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase"},children:l.label})]}),jsx("span",{className:"text-neutral-600",children:"\xB7"}),jsxs("span",{className:"text-neutral-400",children:[u," ",s("predict.event.volume")]}),a&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral-600",children:"\xB7"}),jsx("span",{className:"text-neutral-500",children:a.label})]})]})]}),jsx(ChevronRightIcon,{width:16,height:16,className:"shrink-0 text-neutral-500 opacity-0 group-hover:opacity-100 transition-opacity"})]})}function $a({keyword:e="",limit:t,source:r}){let{data:o,isLoading:n,isFetchingNextPage:i,hasNextPage:s,fetchNextPage:a}=useSearchEvents({keyword:e,limit:t,source:r,sort_by:e?void 0:"volume",sort_asc:e?void 0:false},{enabled:true});return {events:useMemo(()=>o?.pages.flatMap(u=>u.items).filter(u=>u!=null)??[],[o]),isLoading:n,isFetchingNextPage:i,hasNextPage:s??false,fetchNextPage:a}}var Lg=64;function qa({onSelect:e,getEventHref:t,LinkComponent:r,onHover:o,className:n,...i}){let{events:s,isLoading:a,isFetchingNextPage:l,hasNextPage:u,fetchNextPage:d}=$a(i),p=useRef(null),{height:m}=useResizeObserver({ref:p}),c=useCallback(x=>x<s.length,[s]),f=useCallback(async()=>{u&&!l&&await d();},[u,l,d]),g=useMemo(()=>u?s.length+1:s.length,[s,u]),v=useInfiniteLoader({isRowLoaded:c,loadMoreRows:f,rowCount:g,threshold:5});return a?jsx(_g,{className:n}):s.length===0?jsx(Ig,{className:n}):jsx("div",{className:cn$1("w-full h-full flex flex-col",n),children:jsx("div",{className:"flex-auto min-h-0",ref:p,children:jsx(List,{className:"no-scrollbar",style:{height:m},onRowsRendered:v,rowComponent:Rg,rowCount:g,rowHeight:Lg,rowProps:{events:s,onSelect:e,getEventHref:t,LinkComponent:r,onHover:o},overscanCount:5})})})}function Rg({index:e,style:t,events:r,onSelect:o,getEventHref:n,LinkComponent:i,onHover:s}){let a=r[e];return a?jsx("div",{style:t,children:jsx(Ua,{event:a,href:n?.(a),LinkComponent:i,onSelect:o,onHover:s})}):jsx("div",{style:t,className:"flex items-center justify-center",children:jsx(Spinner,{size:"sm"})})}function _g({className:e}){let{t}=useTranslation();return jsxs("div",{className:cn$1("flex items-center justify-center gap-2 py-16",e),children:[jsx(Spinner,{size:"sm"}),jsx("span",{className:"text-sm text-neutral",children:t("predict.search.loading")})]})}function Ig({className:e}){let{t}=useTranslation();return jsxs("div",{className:cn$1("flex flex-col items-center justify-center py-16",e),children:[jsx(EmptyIcon,{width:28,height:28,className:"text-neutral"}),jsx("p",{className:"mt-2 text-sm text-neutral",children:t("predict.search.noResults")})]})}function Xa({onKeywordChange:e}){let[t,r]=useState(""),[o,n]=useState(""),{addHistory:i}=to(),s=useCallbackRef(e),a=useCallbackRef(i),l=useMemo(()=>debounce(m=>{n(m),s(m),m&&a(m);},500),[s,a]),u=useCallback(m=>{r(m),l(m);},[l]),d=useCallback(m=>{l.cancel(),r(m),n(m),s(m),m&&a(m);},[l,s,a]),p=useCallback(()=>d(""),[d]);return {text:t,keyword:o,setText:u,setKeyword:d,clearKeyword:p}}function Ja({onKeywordChange:e,onSelectEvent:t,getEventHref:r,LinkComponent:o,onHover:n,onEscape:i,source:s}){let{text:a,keyword:l,setText:u,setKeyword:d,clearKeyword:p}=Xa({onKeywordChange:e});return jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsx(Wa,{value:a,onValueChange:u,onClear:p,onEscape:i}),!l&&jsx(za,{onSelect:d}),jsx(qa,{className:"flex-auto min-h-0",keyword:l,onSelect:t,getEventHref:r,LinkComponent:o,onHover:n,source:s})]})}var ri="predict-search";function bk({id:e=ri}){return jsx(AsyncModal,{id:e,children:t=>jsx(jg,{...t})})}function jg({params:e,isOpen:t,onOpenChange:r,onResult:o}){let{t:n}=useTranslation(),{isMobile:i}=useScreen(),s=useCallback(l=>{o(l);},[o]),a=useCallback(()=>{r(false);},[r]);return jsx(StyledModal,{isOpen:t,onOpenChange:r,size:i?"full":"lg",hideCloseButton:true,backdrop:"opaque",radius:"lg",children:jsxs(ModalContent,{className:"w-full h-full",style:{borderRadius:i?void 0:14,border:i?void 0:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:i?void 0:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"},children:[jsxs(ModalHeader,{className:"sm:hidden flex items-center justify-between pt-4 pb-2",children:[jsx("span",{className:"text-base font-semibold",children:n("predict.search.title")}),jsx(Button,{isIconOnly:true,onPress:()=>r(false),size:"sm",className:"bg-transparent min-w-6 w-6 h-6",children:jsx(XCloseIcon,{width:20,height:20})})]}),jsx(ModalBody,{className:"p-4",children:jsx(Ja,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectEvent:s,onEscape:a})})]})})}function Ek({onSelectEvent:e,modalParams:t,className:r}){let{t:o}=useTranslation(),{isDesktop:n}=useScreen(),{onOpen:i,onClose:s}=useAsyncModal(ri),a=useCallbackRef(e),l=useCallbackRef(async()=>{let d=await i({params:t});d&&a(d);}),u=useCallbackRef(()=>{s();});return useEffect(()=>{let d=p=>{let m=document.activeElement,c=!!m&&(m.tagName==="INPUT"||m.tagName==="TEXTAREA"||m.getAttribute("contenteditable")==="true");p.key==="/"&&!c&&(p.preventDefault(),l()),p.key==="Escape"&&(p.preventDefault(),u());};return window.addEventListener("keydown",d),()=>{window.removeEventListener("keydown",d);}},[l,u]),n?jsx(Button,{size:"sm",radius:"full",onPress:l,variant:"bordered",startContent:jsx(SearchIcon,{width:16,height:16,className:"text-foreground"}),endContent:jsx(Kbd,{className:"min-w-6 justify-center text-xs text-foreground bg-content3 rounded-lg",children:"/"}),className:cn$1("w-56 min-w-0 h-8 min-h-0 border-transparent hover:border-border bg-content2 pl-3 pr-1.5 text-neutral",r),children:o("predict.search.placeholder")}):jsx(Button,{size:"sm",radius:"full",isIconOnly:true,onPress:l,variant:"bordered",className:cn$1("w-8 min-w-0 h-8 min-h-0 border-1 border-border bg-content2",r),children:jsx(SearchIcon,{width:16,height:16,className:"text-foreground"})})}var oi=[{value:"spread",labelKey:"predict.matches.sort.spread",descKey:"predict.matches.sort.spreadDesc",icon:"trending-up"},{value:"volume",labelKey:"predict.matches.sort.volume",descKey:"predict.matches.sort.volumeDesc",icon:"chart-column"},{value:"confidence",labelKey:"predict.matches.sort.confidence",descKey:"predict.matches.sort.confidenceDesc",icon:"flame"}],cl=[{labelKey:"predict.matches.filter.noMinimum",label:"$0",value:0},{labelKey:null,label:"$100+",value:100},{labelKey:null,label:"$500+",value:500},{labelKey:null,label:"$1K+",value:1e3},{labelKey:null,label:"$5K+",value:5e3},{labelKey:null,label:"$10K+",value:1e4},{labelKey:null,label:"$50K+",value:5e4},{labelKey:null,label:"$100K+",value:1e5}],sl={display:"inline-flex",alignItems:"center",gap:8,borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"8px 12px",fontSize:14,color:"#d4d4d8",cursor:"pointer",transition:"all 0.15s"},al={position:"absolute",right:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function e0(e,t){if(!e)return "$5K+";let r=cl.find(o=>o.value===e);return r?r.labelKey?t(r.labelKey):r.label:`$${e}`}function dl({sortBy:e,onSortChange:t,sortAsc:r,onSortAscChange:o,minVolume:n,onMinVolumeChange:i,onRefresh:s}){let{t:a}=useTranslation(),[l,u]=useState(false),[d,p]=useState(false),[m,c]=useState(false),[f,g]=useState(false),v=useRef(null),x=useRef(null),b=oi.find(h=>h.value===e)??oi[0],w=useCallback(h=>{v.current&&!v.current.contains(h.target)&&u(false),x.current&&!x.current.contains(h.target)&&p(false);},[]);useEffect(()=>(document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)),[w]);let S=useCallback(()=>{s?.(),g(true),setTimeout(()=>g(false),700);},[s]);return jsxs(Fragment,{children:[jsx("style",{children:`
|
|
78
|
+
`):d.description??"";if(!p)return null;let m=p.length>200&&!o?p.slice(0,200)+"...":p;return jsxs("div",{className:"flex flex-col gap-y-3",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-semibold text-foreground lg:text-base",children:r("predict.event.rules")}),u.length>1&&jsxs(Dropdown,{placement:"bottom-end",classNames:{content:"min-w-36 bg-content1 border border-border"},children:[jsx(DropdownTrigger,{children:jsx(Button,{size:"sm",variant:"bordered",radius:"lg",endContent:jsx(ChevronDownIcon,{className:"h-3.5 w-3.5"}),className:"text-xs text-foreground",children:Gn(d)})}),jsx(DropdownMenu,{"aria-label":"Select market rules",selectionMode:"single",selectedKeys:[String(a)],onAction:c=>{l(Number(c)),n(false);},classNames:{list:"gap-1"},itemClasses:{base:"rounded-md px-3 h-8"},children:u.map((c,f)=>jsx(DropdownItem,{className:cn(f===a?"bg-content2 text-foreground":"text-neutral","data-[hover=true]:bg-content2 data-[hover=true]:text-foreground"),children:Gn(c)},String(f)))})]})]}),jsx("div",{className:"text-xs text-foreground/80 lg:text-sm whitespace-pre-wrap",children:m}),p.length>200&&jsx("button",{type:"button",onClick:()=>n(c=>!c),className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors self-start",children:r(o?"predict.event.rules.collapse":"predict.event.showMore")}),jsxs("button",{type:"button",onClick:()=>s(c=>!c),className:"flex items-center justify-between w-full mt-2 text-xs font-medium text-neutral lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsx("span",{children:r("predict.event.timelineAndPayout")}),jsx(ChevronDownIcon,{className:cn("h-4 w-4 transition-transform",i&&"rotate-180")})]}),i&&jsxs(Fragment,{children:[jsx("div",{className:"flex flex-col",children:(()=>{let c=d.status,f=[];return d.created_at&&f.push({label:r("predict.event.timeline.created"),value:an(d.created_at),isActive:true}),f.push({label:r("predict.event.timeline.open"),value:an(d.start_at),isActive:c!=="pending"}),c==="voided"?f.push({label:r("predict.event.timeline.voided"),value:an(d.closed_at??d.end_at),isActive:true}):c==="closed"?f.push({label:r("predict.event.timeline.closed"),value:an(d.closed_at??d.end_at),isActive:true}):f.push({label:r("predict.event.timeline.close"),value:an(d.end_at),isActive:false}),f})().map((c,f,g)=>jsxs("div",{className:"flex items-stretch gap-x-3",children:[jsxs("div",{className:"flex flex-col items-center w-3",children:[jsx("div",{className:`h-3 w-3 shrink-0 rounded-full border-2 mt-0.5 ${c.isActive?"border-primary bg-primary":"border-border bg-transparent"}`}),f<g.length-1&&jsx("div",{className:"w-px flex-1 bg-border"})]}),jsxs("div",{className:`flex flex-col ${f<g.length-1?"pb-4":""}`,children:[jsx("span",{className:"text-xs font-medium text-foreground lg:text-sm",children:c.label}),jsx("span",{className:"text-xs text-neutral lg:text-sm",children:c.value})]})]},c.label))}),jsxs("div",{className:"flex flex-wrap items-center gap-x-3 text-xxs text-neutral mt-2 lg:text-xs",children:[jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.event"),":"]})," ",jsx("span",{className:"text-foreground",children:t.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.market"),":"]})," ",jsx("span",{className:"text-foreground",children:d.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.source"),":"]})," ",jsx("span",{className:"text-foreground",children:Xm(d.source)})]})]})]})]})}function tf({source:e}){return jsxs("span",{className:"inline-flex items-center gap-x-1 text-neutral-400",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsx("span",{className:"text-neutral-600",children:"\xB7"}),e==="polymarket"?jsx(PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsx(KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}function Na({eventSlug:e,source:t,onTradeAction:r}){let{data:o,isLoading:n,error:i}=useEvent({slug:e,source:t});return n?jsx(nn,{}):i||!o?jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:i?.message||"Event not found"}):jsx(Pa,{event:o,onTradeAction:r})}var af={kalshi:{label:"KALSHI",color:"#00d492",bgColor:"rgba(0, 212, 146, 0.12)",icon:jsx(KalshiIcon,{className:"w-3.5 h-3.5 shrink-0"})},polymarket:{label:"POLYMARKET",color:"#50a2ff",bgColor:"rgba(43, 127, 255, 0.12)",icon:jsx(PolymarketIcon,{className:"w-3.5 h-3.5 shrink-0"})},dflow:{label:"DFLOW",color:"rgb(16, 185, 129)",bgColor:"rgba(16, 185, 129, 0.12)",icon:null}},lf={label:"Unknown",color:"rgb(156, 163, 175)",bgColor:"rgba(156, 163, 175, 0.12)",icon:null};function Dt(e){return af[e]??lf}function Zy({source:e,className:t}){let r=Dt(e);return jsxs("span",{className:cn("inline-flex items-center gap-x-1 rounded-md px-1.5 py-0.5 text-xs font-medium",t),style:{backgroundColor:r.bgColor,color:r.color},children:[r.icon,r.label]})}var Ma="rgba(39,39,42,0.6)",gf="rgba(63,63,70,0.8)";function hf(e){return e==null?"-":formatAmountInUsd(e)}function Ta({eventSlug:e,source:t,limit:r=4,onEventClick:o,onEventHover:n}){let{t:i}=useTranslation(),{data:s,isLoading:a}=useSimilarEvents({slug:e,source:t,limit:r});return a||!s||s.length===0?null:jsxs("div",{className:"flex flex-col gap-y-3 mt-6 px-1 lg:px-0",children:[jsx("span",{style:{color:"#f4f4f5",fontSize:14,fontWeight:600},children:i("predict.similar.title")}),jsx("div",{className:"grid grid-cols-1 gap-2",children:s.map(l=>jsx(vf,{event:l,onClick:o,onHover:n},`${l.source}-${l.slug}`))})]})}function vf({event:e,onClick:t,onHover:r}){let{t:o}=useTranslation(),n=Dt(e.source),i=useMemo(()=>hf(e.volume),[e.volume]),s=e.tags?.[0];return jsxs("button",{type:"button",onClick:()=>t?.(e),onMouseEnter:a=>{a.currentTarget.style.borderColor=gf,r?.(e);},onMouseLeave:a=>{a.currentTarget.style.borderColor=Ma;},style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",borderRadius:14,border:`1px solid ${Ma}`,background:"rgba(24,24,27,0.4)",cursor:"pointer",textAlign:"left",width:"100%",transition:"border-color 0.2s"},className:"group",children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title?.[0]||"?",radius:"full",className:"size-9 shrink-0 bg-transparent",imgProps:{className:"object-cover"}}),jsxs("div",{style:{display:"flex",flexDirection:"column",minWidth:0,flex:1,gap:2},children:[jsx("span",{style:{fontSize:13,fontWeight:500,color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.title}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,color:n.color,flexShrink:0},children:[n.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase"},children:n.label})]}),jsx("span",{style:{color:"#52525b"},children:"\xB7"}),jsxs("span",{style:{color:"#a1a1aa"},children:[i," ",o("predict.event.volume")]}),s&&jsxs(Fragment,{children:[jsx("span",{style:{color:"#52525b"},children:"\xB7"}),jsx("span",{style:{color:"#71717a"},children:s.label})]})]})]}),jsx(ChevronRightIcon,{width:14,height:14,className:"shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",style:{color:"#71717a"}})]})}function Qn(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function P1({eventSlug:e,source:t,chain:r,walletAddress:o,onSimilarEventClick:n,onSimilarEventHover:i,onBack:s,renderActivitySection:a,onInsufficientBalance:l,onSetupRequired:u,slippageBps:d}){let{t:p}=useTranslation(),{isDesktop:m}=useScreen(),{onOpen:c}=useAsyncModal(Yr),{onOpen:f}=useAsyncModal(Fo),{data:g,isLoading:v}=useEvent({slug:e,source:t}),x=useMemo(()=>{let P=[...g?.markets||[]],O=P.filter(W=>W.status==="open").sort((W,A)=>Qn(A)-Qn(W)),F=P.filter(W=>W.status!=="open").sort((W,A)=>Qn(A)-Qn(W));return [...O,...F]},[g?.markets]),[b,w]=useState(null),S=useCallback((P,O,F)=>{w(W=>({market:P,outcome:O,side:F,version:(W?.version??0)+1})),!m&&g&&(F==="sell"?f({params:{event:g,market:P,initialOutcome:O,chain:r,slippageBps:d,onSetupRequired:u}}):c({params:{event:g,market:P,initialOutcome:O,chain:r,slippageBps:d,onInsufficientBalance:l}}));},[m,g,r,d,c,f,l,u]),h=b?.market??x[0];if(v){let P=!!s;return m?jsxs("div",{className:"flex w-full max-w-6xl mx-auto gap-x-4 lg:gap-x-6",children:[jsx("div",{className:"min-w-0 flex-1 max-w-3xl",children:jsx(nn,{showBack:P})}),jsx("aside",{className:"hidden lg:block w-[340px] xl:w-[380px] shrink-0",children:jsx("div",{className:"sticky top-4 max-h-[calc(100dvh-2rem)] overflow-y-auto scrollbar-thin",children:jsx(Xs,{})})})]}):jsx(nn,{showBack:P})}let y=b?`${b.market.slug}-${b.version}`:h?.slug??"default",k=b?.side==="sell";return jsxs("div",{className:"flex w-full flex-col gap-y-4 pb-12 lg:max-w-7xl lg:gap-y-8 lg:pb-16 mx-auto",children:[jsxs("div",{className:"flex w-full justify-center gap-4 pt-4 lg:gap-6",children:[jsxs("div",{className:"flex-auto min-w-0 flex flex-col gap-y-4 px-4 lg:gap-y-6 lg:px-0",children:[s&&jsx("div",{className:"flex items-center justify-between",children:jsx(Button,{as:"a",onPress:s,startContent:jsx(ChevronLeftIcon,{className:"h-4 w-4"}),className:"text-neutral bg-transparent h-5 min-h-5 gap-x-2 p-0 text-base w-auto min-w-auto",children:p("common.back")})}),jsx(Na,{eventSlug:e,source:t,onTradeAction:S})]}),jsxs("div",{className:"hidden flex-none w-md flex-col gap-y-4 lg:sticky lg:top-4 lg:flex lg:self-start",children:[h&&(k?jsx(Wn,{event:g,market:h,initialOutcome:b?.outcome,chain:r,slippageBps:d,onSetupRequired:u},y):jsx(In,{event:g,market:h,initialOutcome:b?.outcome,chain:r,slippageBps:d,onInsufficientBalance:l},y)),g&&jsx(Ta,{eventSlug:e,source:g.source,onEventClick:n,onEventHover:i})]})]}),g&&jsx("div",{className:"flex w-full flex-col",children:a?a({event:g,walletAddress:o}):jsx(Gs,{event:g,walletAddress:o})}),jsx(On,{}),jsx(Vs,{}),jsx(Rs,{})]})}function Ra(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Rf(e){switch(e){case le.ONE_DAY:return {interval:"15m",limit:96};case le.ONE_WEEK:return {interval:"1h",limit:168};case le.ONE_MONTH:return {interval:"4h",limit:180};case le.ALL:return {interval:"1d",limit:300};default:return {interval:"1h",limit:100}}}var R1=e=>{let{candlestickMarketSlugs:t,chartRange:r=Nn,source:o}=e,n=usePredictClient(),i=useMemo(()=>Rf(r),[r]),{data:s,isLoading:a,error:l}=useEvent({slug:e.eventSlug,source:o}),u=useMemo(()=>{if(!s?.markets)return [];let f=new Set,g=s.markets.filter(x=>f.has(x.slug)?false:(f.add(x.slug),true));return (t&&t.length>0?t.slice(0,4).map(x=>g.find(b=>b.slug===x)).filter(x=>x!==void 0):[...g].sort((x,b)=>Ra(b)-Ra(x)).slice(0,4)).map(x=>x.slug)},[t,s?.markets]),d=useQueries({queries:u.map(f=>({queryKey:candlesticksQueryKey(f,i),queryFn:()=>n.listCandlesticks(f,i),enabled:u.length>0}))}),p=d.some(f=>f.isLoading),m=useMemo(()=>{let f=new Map;return u.forEach((g,v)=>{let x=d[v]?.error;x&&f.set(g,x);}),f},[u,d]),c=useMemo(()=>{let f=new Map;return u.forEach((g,v)=>{let x=d[v]?.data;x&&f.set(g,x);}),f},[u,d]);return {event:s,isEventLoading:a,eventError:l,candlestickParams:i,candlesticks:c,isCandlesticksLoading:p,candlestickErrors:m}};function Xo({comment:e,anonymousLabel:t,isReply:r=false}){let{profile:o}=e,n=o.name||o.pseudonym||t,i=useMemo(()=>Af(e.created_at),[e.created_at]);return jsxs("div",{className:cn("flex gap-x-2.5 px-1 py-3 border-b border-border/40 lg:px-2",r&&"pl-8 lg:pl-9"),children:[jsx(_f,{src:o.profile_image,name:n,className:cn("shrink-0",r?"size-6":"size-8 lg:size-7")}),jsxs("div",{className:"min-w-0 flex-1",children:[jsxs("div",{className:"flex items-baseline gap-x-2",children:[jsx("span",{className:"truncate text-sm font-medium text-foreground",children:n}),jsx("span",{className:"ml-auto shrink-0 text-xs text-neutral",children:i})]}),jsx("p",{className:"mt-1 whitespace-pre-wrap break-words text-sm leading-relaxed text-foreground/90",children:e.body}),jsxs("div",{className:"mt-2 flex items-center gap-x-1 text-neutral",children:[jsx(If,{className:"size-3.5"}),jsx("span",{className:"text-xs tabular-nums",children:e.reaction_count})]})]})]})}function _f({src:e,name:t,className:r}){let o=t.trim().charAt(0).toUpperCase()||"?",n=useMemo(()=>Of(t),[t]);return e?jsx("img",{src:e,alt:t,loading:"lazy",className:cn("rounded-full object-cover",r)}):jsx("span",{className:cn("flex items-center justify-center rounded-full text-xs font-semibold text-white",r),style:{backgroundColor:n},"aria-hidden":true,children:o})}function If({className:e}){return jsx("svg",{viewBox:"0 0 24 24",className:e,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":true,children:jsx("path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z"})})}function Of(e){let t=0;for(let o=0;o<e.length;o++)t=e.charCodeAt(o)+((t<<5)-t);return `hsl(${Math.abs(t)%360}, 55%, 45%)`}function Af(e){let t=new Date(e).getTime();if(Number.isNaN(t))return "";let r=Math.max(0,Math.floor((Date.now()-t)/1e3));if(r<60)return "now";let o=Math.floor(r/60);if(o<60)return `${o}m`;let n=Math.floor(o/60);if(n<24)return `${n}h`;let i=Math.floor(n/24);if(i<7)return `${i}d`;let s=Math.floor(i/7);return s<5?`${s}w`:new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}var Vf={latest:{order:"createdAt",ascending:false},oldest:{order:"createdAt",ascending:true},mostLiked:{order:"reactionCount",ascending:false}},Oa={latest:"predict.comments.sortLatest",oldest:"predict.comments.sortOldest",mostLiked:"predict.comments.sortMostLiked"},jf=["latest","oldest","mostLiked"],qf=600,Gf=112;function Yf({slug:e,source:t,limit:r=20,height:o,className:n}){let{t:i}=useTranslation(),[s,a]=useState("latest"),[l,u]=useState(false),d=Vf[s],{data:p,isLoading:m,isFetchingNextPage:c,hasNextPage:f,fetchNextPage:g}=useInfiniteComments({slug:e,source:t,limit:r,order:d.order,ascending:d.ascending,holders_only:l}),v=useMemo(()=>p?.pages?.flatMap(F=>F.items)??[],[p?.pages]),x=useRef(null),{height:b}=useResizeObserver({ref:x}),w=o??(b||qf),S=useDynamicRowHeight({defaultRowHeight:Gf,key:`${e}:${t}:${s}:${l}`}),h=v.length,y=h+(f?1:0),k=useCallback(F=>F<h,[h]),P=useCallback(async()=>{f&&!c&&await g();},[f,c,g]),O=useInfiniteLoader({isRowLoaded:k,loadMoreRows:P,rowCount:y,threshold:5});return jsxs("div",{className:cn("flex h-full w-full flex-col",n),children:[jsx(Xf,{sort:s,onSortChange:a,holdersOnly:l,onHoldersOnlyChange:u}),jsx("div",{className:"min-h-0 flex-auto overflow-hidden",ref:x,children:m?jsx(Jf,{}):v.length===0?jsx(Zf,{message:i("predict.comments.empty")}):jsx(List,{className:"no-scrollbar",style:{height:w},onRowsRendered:O,rowComponent:Qf,rowCount:y,rowHeight:S,rowProps:{comments:v,itemCount:h,anonymousLabel:i("predict.comments.anonymous")},overscanCount:4})})]})}function Qf({index:e,style:t,comments:r,itemCount:o,anonymousLabel:n}){if(e>=o)return jsx("div",{style:t,className:"flex items-center justify-center py-4",children:jsx(Spinner,{size:"sm"})});let i=r[e];return i?jsx("div",{style:t,children:jsx(Xo,{comment:i,anonymousLabel:n,isReply:!!i.parent_comment_id})}):null}function Xf({sort:e,onSortChange:t,holdersOnly:r,onHoldersOnlyChange:o}){let{t:n}=useTranslation(),[i,s]=useState(false),a=useRef(null);return useEffect(()=>{if(!i)return;let l=d=>{a.current&&!a.current.contains(d.target)&&s(false);},u=d=>{d.key==="Escape"&&s(false);};return document.addEventListener("mousedown",l),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",u);}},[i]),jsxs("div",{className:"flex items-center justify-between gap-2 px-1 py-2 lg:px-2",children:[jsxs("div",{ref:a,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>s(l=>!l),className:"inline-flex items-center gap-x-1.5 rounded-lg border border-border bg-content2/40 px-3 py-1.5 text-sm text-foreground transition-colors hover:bg-content2 cursor-pointer",children:[jsx(eg,{className:"size-3.5 text-neutral"}),jsx("span",{children:n(Oa[e])}),jsx(tg,{className:cn("size-3.5 text-neutral transition-transform",i&&"rotate-180")})]}),i&&jsx("div",{className:"absolute left-0 top-full z-20 mt-1.5 min-w-40 overflow-hidden rounded-xl border border-border bg-content1 p-1 shadow-xl",children:jf.map(l=>{let u=l===e;return jsxs("button",{type:"button",onClick:()=>{t(l),s(false);},className:cn("flex w-full items-center gap-x-2 rounded-lg px-3 py-2 text-left text-sm transition-colors cursor-pointer",u?"bg-primary/10 text-primary":"text-neutral hover:bg-content2 hover:text-foreground"),children:[jsx("span",{className:"flex-1 font-medium",children:n(Oa[l])}),u&&jsx(Aa,{className:"size-4 text-primary"})]},l)})})]}),jsxs("button",{type:"button",role:"switch","aria-checked":r,onClick:()=>o(!r),className:cn("inline-flex items-center gap-x-1.5 rounded-lg border px-3 py-1.5 text-sm transition-colors cursor-pointer",r?"border-primary/40 bg-primary/10 text-primary":"border-border bg-content2/40 text-neutral hover:text-foreground"),children:[jsx("span",{className:cn("flex size-4 items-center justify-center rounded border",r?"border-primary bg-primary":"border-neutral"),children:r&&jsx(Aa,{className:"size-3 text-background"})}),n("predict.comments.holdersOnly")]})]})}function Jf(){return jsx("div",{className:"flex flex-col gap-y-4 px-1 py-3 lg:px-2",children:Array.from({length:6}).map((e,t)=>jsxs("div",{className:"flex gap-x-2.5",children:[jsx(Skeleton,{className:"size-8 shrink-0 rounded-full"}),jsxs("div",{className:"flex-1 space-y-2",children:[jsx(Skeleton,{className:"h-3 w-24 rounded"}),jsx(Skeleton,{className:"h-3 w-full rounded"}),jsx(Skeleton,{className:"h-3 w-2/3 rounded"})]})]},t))})}function Zf({message:e}){return jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[jsx(EmptyIcon,{width:28,height:28,className:"text-neutral"}),jsx("p",{className:"mt-2 text-sm text-neutral",children:e})]})}function eg({className:e}){return jsxs("svg",{viewBox:"0 0 24 24",className:e,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":true,children:[jsx("path",{d:"m21 16-4 4-4-4"}),jsx("path",{d:"M17 20V4"}),jsx("path",{d:"m3 8 4-4 4 4"}),jsx("path",{d:"M7 4v16"})]})}function tg({className:e}){return jsx("svg",{viewBox:"0 0 24 24",className:e,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":true,children:jsx("path",{d:"m6 9 6 6 6-6"})})}function Aa({className:e}){return jsx("svg",{viewBox:"0 0 24 24",className:e,fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":true,children:jsx("path",{d:"M20 6 9 17l-5-5"})})}var og=10,ig=atomWithStorage("liberfi:predict_search_histories",[],void 0,{getOnInit:true});function to(){let[e,t]=useAtom(ig),r=useCallback(n=>{let i=n.trim();i&&t(s=>{let a=s.filter(l=>l!==i);return [i,...a].slice(0,og)});},[t]),o=useCallback(()=>{t([]);},[t]);return {histories:e,addHistory:r,clearHistories:o}}function Wa({histories:e,onSelect:t,onClear:r,className:o}){let{t:n}=useTranslation();return e.length===0?null:jsxs("div",{className:cn("px-4 pb-4",o),children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-medium",children:n("predict.search.history")}),jsx(Button,{isIconOnly:true,size:"sm",className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsx(TrashIcon,{width:20,height:20})})]}),jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:e.map(i=>jsx(Chip,{size:"sm",variant:"bordered",className:cn("text-neutral","border-border border-1","cursor-pointer","hover:opacity-hover"),onClick:()=>t?.(i),children:i},i))})]})}function Ua({onSelect:e,className:t}){let{histories:r,clearHistories:o}=to();return jsx(Wa,{className:cn(t),histories:r,onSelect:e,onClear:o})}function $a({value:e,onValueChange:t,onClear:r,onEscape:o,className:n}){let{t:i}=useTranslation();return jsx("div",{className:n,children:jsx(StyledInput,{autoFocus:true,variant:"bordered",radius:"lg",value:e,onValueChange:t,placeholder:i("predict.search.placeholder"),classNames:{inputWrapper:["!bg-[rgba(39,39,42,0.6)]","!border-[rgba(63,63,70,0.5)]","data-[hover=true]:!bg-[rgba(39,39,42,1)]","group-data-[focus=true]:!bg-[rgba(39,39,42,1)]","group-data-[focus=true]:!border-[rgba(63,63,70,0.8)]"].join(" ")},startContent:jsx(SearchIcon,{width:20,height:20,className:"text-neutral"}),endContent:e?jsx(Button,{isIconOnly:true,className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsx(XCloseIcon,{width:20,height:20})}):jsx(Kbd,{className:"min-w-8 justify-center text-xs text-neutral bg-transparent border border-[rgba(63,63,70,0.5)] rounded-lg cursor-pointer select-none",onMouseDown:s=>{s.preventDefault(),o?.();},children:"Esc"})})})}function Ng(e){return e==null?"-":formatAmountInUsd(e)}function Ka({event:e,href:t,LinkComponent:r,onSelect:o,onHover:n,className:i}){let{t:s}=useTranslation(),a=e.tags?.[0],l=Dt(e.source),u=useMemo(()=>Ng(e.volume),[e.volume]);return jsxs(Linkable,{href:t,LinkComponent:r,className:cn("group w-full h-full px-3 flex items-center gap-3","hover:cursor-pointer hover:bg-content2 rounded-lg","transition-colors duration-150",i),onClick:d=>{t&&o&&d.preventDefault(),o?.(e);},onMouseEnter:()=>n?.(e),children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"full",className:"h-10 w-10 flex-shrink-0"}),jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-center gap-y-0.5",children:[jsx("span",{className:"min-w-0 text-sm font-medium line-clamp-2 group-hover:text-primary transition-colors",children:e.title}),jsxs("div",{className:"flex items-center gap-x-2 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[jsxs("span",{className:"inline-flex items-center gap-x-1 shrink-0",style:{color:l.color},children:[l.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase"},children:l.label})]}),jsx("span",{className:"text-neutral-600",children:"\xB7"}),jsxs("span",{className:"text-neutral-400",children:[u," ",s("predict.event.volume")]}),a&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral-600",children:"\xB7"}),jsx("span",{className:"text-neutral-500",children:a.label})]})]})]}),jsx(ChevronRightIcon,{width:16,height:16,className:"shrink-0 text-neutral-500 opacity-0 group-hover:opacity-100 transition-opacity"})]})}function Va({keyword:e="",limit:t,source:r}){let{data:o,isLoading:n,isFetchingNextPage:i,hasNextPage:s,fetchNextPage:a}=useSearchEvents({keyword:e,limit:t,source:r,sort_by:e?void 0:"volume",sort_asc:e?void 0:false},{enabled:true});return {events:useMemo(()=>o?.pages.flatMap(u=>u.items).filter(u=>u!=null)??[],[o]),isLoading:n,isFetchingNextPage:i,hasNextPage:s??false,fetchNextPage:a}}var Ag=64;function Ya({onSelect:e,getEventHref:t,LinkComponent:r,onHover:o,className:n,...i}){let{events:s,isLoading:a,isFetchingNextPage:l,hasNextPage:u,fetchNextPage:d}=Va(i),p=useRef(null),{height:m}=useResizeObserver({ref:p}),c=useCallback(x=>x<s.length,[s]),f=useCallback(async()=>{u&&!l&&await d();},[u,l,d]),g=useMemo(()=>u?s.length+1:s.length,[s,u]),v=useInfiniteLoader({isRowLoaded:c,loadMoreRows:f,rowCount:g,threshold:5});return a?jsx(Fg,{className:n}):s.length===0?jsx(Bg,{className:n}):jsx("div",{className:cn("w-full h-full flex flex-col",n),children:jsx("div",{className:"flex-auto min-h-0",ref:p,children:jsx(List,{className:"no-scrollbar",style:{height:m},onRowsRendered:v,rowComponent:Dg,rowCount:g,rowHeight:Ag,rowProps:{events:s,onSelect:e,getEventHref:t,LinkComponent:r,onHover:o},overscanCount:5})})})}function Dg({index:e,style:t,events:r,onSelect:o,getEventHref:n,LinkComponent:i,onHover:s}){let a=r[e];return a?jsx("div",{style:t,children:jsx(Ka,{event:a,href:n?.(a),LinkComponent:i,onSelect:o,onHover:s})}):jsx("div",{style:t,className:"flex items-center justify-center",children:jsx(Spinner,{size:"sm"})})}function Fg({className:e}){let{t}=useTranslation();return jsxs("div",{className:cn("flex items-center justify-center gap-2 py-16",e),children:[jsx(Spinner,{size:"sm"}),jsx("span",{className:"text-sm text-neutral",children:t("predict.search.loading")})]})}function Bg({className:e}){let{t}=useTranslation();return jsxs("div",{className:cn("flex flex-col items-center justify-center py-16",e),children:[jsx(EmptyIcon,{width:28,height:28,className:"text-neutral"}),jsx("p",{className:"mt-2 text-sm text-neutral",children:t("predict.search.noResults")})]})}function Za({onKeywordChange:e}){let[t,r]=useState(""),[o,n]=useState(""),{addHistory:i}=to(),s=useCallbackRef(e),a=useCallbackRef(i),l=useMemo(()=>debounce(m=>{n(m),s(m),m&&a(m);},500),[s,a]),u=useCallback(m=>{r(m),l(m);},[l]),d=useCallback(m=>{l.cancel(),r(m),n(m),s(m),m&&a(m);},[l,s,a]),p=useCallback(()=>d(""),[d]);return {text:t,keyword:o,setText:u,setKeyword:d,clearKeyword:p}}function el({onKeywordChange:e,onSelectEvent:t,getEventHref:r,LinkComponent:o,onHover:n,onEscape:i,source:s}){let{text:a,keyword:l,setText:u,setKeyword:d,clearKeyword:p}=Za({onKeywordChange:e});return jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsx($a,{value:a,onValueChange:u,onClear:p,onEscape:i}),!l&&jsx(Ua,{onSelect:d}),jsx(Ya,{className:"flex-auto min-h-0",keyword:l,onSelect:t,getEventHref:r,LinkComponent:o,onHover:n,source:s})]})}var ri="predict-search";function wk({id:e=ri}){return jsx(AsyncModal,{id:e,children:t=>jsx(Xg,{...t})})}function Xg({params:e,isOpen:t,onOpenChange:r,onResult:o}){let{t:n}=useTranslation(),{isMobile:i}=useScreen(),s=useCallback(l=>{o(l);},[o]),a=useCallback(()=>{r(false);},[r]);return jsx(StyledModal,{isOpen:t,onOpenChange:r,size:i?"full":"lg",hideCloseButton:true,backdrop:"opaque",radius:"lg",children:jsxs(ModalContent,{className:"w-full h-full",style:{borderRadius:i?void 0:14,border:i?void 0:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:i?void 0:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"},children:[jsxs(ModalHeader,{className:"sm:hidden flex items-center justify-between pt-4 pb-2",children:[jsx("span",{className:"text-base font-semibold",children:n("predict.search.title")}),jsx(Button,{isIconOnly:true,onPress:()=>r(false),size:"sm",className:"bg-transparent min-w-6 w-6 h-6",children:jsx(XCloseIcon,{width:20,height:20})})]}),jsx(ModalBody,{className:"p-4",children:jsx(el,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectEvent:s,onEscape:a})})]})})}function _k({onSelectEvent:e,modalParams:t,className:r}){let{t:o}=useTranslation(),{isDesktop:n}=useScreen(),{onOpen:i,onClose:s}=useAsyncModal(ri),a=useCallbackRef(e),l=useCallbackRef(async()=>{let d=await i({params:t});d&&a(d);}),u=useCallbackRef(()=>{s();});return useEffect(()=>{let d=p=>{let m=document.activeElement,c=!!m&&(m.tagName==="INPUT"||m.tagName==="TEXTAREA"||m.getAttribute("contenteditable")==="true");p.key==="/"&&!c&&(p.preventDefault(),l()),p.key==="Escape"&&(p.preventDefault(),u());};return window.addEventListener("keydown",d),()=>{window.removeEventListener("keydown",d);}},[l,u]),n?jsx(Button,{size:"sm",radius:"full",onPress:l,variant:"bordered",startContent:jsx(SearchIcon,{width:16,height:16,className:"text-foreground"}),endContent:jsx(Kbd,{className:"min-w-6 justify-center text-xs text-foreground bg-content3 rounded-lg",children:"/"}),className:cn("w-56 min-w-0 h-8 min-h-0 border-transparent hover:border-border bg-content2 pl-3 pr-1.5 text-neutral",r),children:o("predict.search.placeholder")}):jsx(Button,{size:"sm",radius:"full",isIconOnly:true,onPress:l,variant:"bordered",className:cn("w-8 min-w-0 h-8 min-h-0 border-1 border-border bg-content2",r),children:jsx(SearchIcon,{width:16,height:16,className:"text-foreground"})})}var oi=[{value:"spread",labelKey:"predict.matches.sort.spread",descKey:"predict.matches.sort.spreadDesc",icon:"trending-up"},{value:"volume",labelKey:"predict.matches.sort.volume",descKey:"predict.matches.sort.volumeDesc",icon:"chart-column"},{value:"confidence",labelKey:"predict.matches.sort.confidence",descKey:"predict.matches.sort.confidenceDesc",icon:"flame"}],ul=[{labelKey:"predict.matches.filter.noMinimum",label:"$0",value:0},{labelKey:null,label:"$100+",value:100},{labelKey:null,label:"$500+",value:500},{labelKey:null,label:"$1K+",value:1e3},{labelKey:null,label:"$5K+",value:5e3},{labelKey:null,label:"$10K+",value:1e4},{labelKey:null,label:"$50K+",value:5e4},{labelKey:null,label:"$100K+",value:1e5}],ll={display:"inline-flex",alignItems:"center",gap:8,borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"8px 12px",fontSize:14,color:"#d4d4d8",cursor:"pointer",transition:"all 0.15s"},cl={position:"absolute",right:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function i0(e,t){if(!e)return "$5K+";let r=ul.find(o=>o.value===e);return r?r.labelKey?t(r.labelKey):r.label:`$${e}`}function pl({sortBy:e,onSortChange:t,sortAsc:r,onSortAscChange:o,minVolume:n,onMinVolumeChange:i,onRefresh:s}){let{t:a}=useTranslation(),[l,u]=useState(false),[d,p]=useState(false),[m,c]=useState(false),[f,g]=useState(false),v=useRef(null),x=useRef(null),b=oi.find(h=>h.value===e)??oi[0],w=useCallback(h=>{v.current&&!v.current.contains(h.target)&&u(false),x.current&&!x.current.contains(h.target)&&p(false);},[]);useEffect(()=>(document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)),[w]);let S=useCallback(()=>{s?.(),g(true),setTimeout(()=>g(false),700);},[s]);return jsxs(Fragment,{children:[jsx("style",{children:`
|
|
79
79
|
@keyframes matchRefreshSpin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}
|
|
80
80
|
.match-refresh-spin{animation:matchRefreshSpin .6s ease-in-out}
|
|
81
81
|
.match-btn:focus-visible{outline:2px solid #c7ff2e;outline-offset:2px;z-index:10}
|
|
82
|
-
`}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxs("div",{ref:v,style:{position:"relative"},children:[jsxs("button",{type:"button",className:"match-btn",style:
|
|
82
|
+
`}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxs("div",{ref:v,style:{position:"relative"},children:[jsxs("button",{type:"button",className:"match-btn",style:ll,onMouseEnter:h=>{h.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:h=>{h.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>{u(h=>!h),p(false);},children:[jsx(s0,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:a(b.labelKey)}),jsx(dl,{open:l})]}),l&&jsx("div",{style:{...cl,width:224,padding:4},children:oi.map(h=>{let y=e===h.value;return jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",gap:12,padding:"10px 12px",textAlign:"left",fontSize:14,border:"none",cursor:"pointer",transition:"all 0.15s",background:y?"rgba(199,255,46,0.08)":"transparent",color:y?"#c7ff2e":"#a1a1aa",borderRadius:10},onMouseEnter:k=>{y||(k.currentTarget.style.background="rgba(39,39,42,0.5)",k.currentTarget.style.color="#fff");},onMouseLeave:k=>{y||(k.currentTarget.style.background="transparent",k.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===h.value?o(!r):t(h.value),u(false);},children:[jsx("div",{style:{color:y?"#c7ff2e":"#71717a"},children:jsx(a0,{type:h.icon})}),jsxs("div",{style:{flex:1,textAlign:"left"},children:[jsx("div",{style:{fontWeight:500},children:a(h.labelKey)}),jsx("div",{style:{fontSize:11,color:"#71717a",marginTop:1},children:a(h.descKey)})]}),y&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 6 9 17l-5-5"})})]},h.value)})})]}),i&&jsxs("div",{ref:x,style:{position:"relative"},children:[jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxs("button",{type:"button",className:"match-btn",style:ll,onMouseEnter:h=>{h.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:h=>{h.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>{p(h=>!h),u(false);},children:[jsx(l0,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:i0(n,a)}),jsx(c0,{onMouseEnter:()=>c(true),onMouseLeave:()=>c(false)}),jsx(dl,{open:d})]}),m&&jsxs("div",{style:{position:"absolute",zIndex:100,top:"100%",marginTop:8,left:"50%",transform:"translateX(-50%)",width:256,padding:12,borderRadius:14,background:"rgba(24,24,27,1)",border:"1px solid rgba(63,63,70,0.5)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",pointerEvents:"none"},children:[jsx("div",{style:{position:"absolute",top:-6,left:"50%",transform:"translateX(-50%) rotate(45deg)",width:12,height:12,background:"rgba(24,24,27,1)",borderLeft:"1px solid rgba(63,63,70,0.5)",borderTop:"1px solid rgba(63,63,70,0.5)"}}),jsxs("div",{style:{position:"relative",fontSize:12,color:"#d4d4d8",lineHeight:1.625},children:[jsxs("div",{style:{fontWeight:600,color:"#fff",display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"})}),a("predict.matches.filter.liquidityFilter")]}),jsx("p",{style:{color:"#a1a1aa",margin:"0 0 4px"},children:a("predict.matches.filter.tooltipDesc")}),jsx("p",{style:{color:"#71717a",fontSize:11,margin:0},children:a("predict.matches.filter.tooltipNote")})]})]})]}),d&&jsxs("div",{style:{...cl,right:0,width:176},children:[jsx("div",{style:{padding:"8px 12px",borderBottom:"1px solid rgba(39,39,42,1)"},children:jsx("span",{style:{fontSize:11,fontWeight:500,color:"#71717a",textTransform:"uppercase",letterSpacing:"0.05em"},children:a("predict.matches.filter.minVolumeEach")})}),jsx("div",{style:{padding:4},children:ul.map(h=>{let y=h.value===0?!n:n===h.value;return jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",textAlign:"left",fontSize:14,border:"none",cursor:"pointer",background:y?"rgba(199,255,46,0.08)":"transparent",color:y?"#c7ff2e":"#a1a1aa",borderRadius:10,transition:"all 0.15s"},onMouseEnter:k=>{y||(k.currentTarget.style.background="rgba(39,39,42,0.5)",k.currentTarget.style.color="#fff");},onMouseLeave:k=>{y||(k.currentTarget.style.background="transparent",k.currentTarget.style.color="#a1a1aa");},onClick:()=>{i?.(h.value===0?void 0:h.value),p(false);},children:[jsx("span",{children:h.labelKey?a(h.labelKey):h.label}),y&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 6 9 17l-5-5"})})]},h.value)})})]})]}),s&&jsx("button",{type:"button",className:"match-btn",style:{borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",width:36,height:36,color:"#a1a1aa",cursor:"pointer",transition:"all 0.15s",display:"inline-flex",alignItems:"center",justifyContent:"center"},onMouseEnter:h=>{h.currentTarget.style.background="rgba(39,39,42,1)",h.currentTarget.style.color="#fff";},onMouseLeave:h=>{h.currentTarget.style.background="rgba(39,39,42,0.6)",h.currentTarget.style.color="#a1a1aa";},onClick:S,children:jsxs("svg",{className:f?"match-refresh-spin":void 0,viewBox:"0 0 24 24",style:{width:16,height:16},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),jsx("path",{d:"M21 3v5h-5"}),jsx("path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}),jsx("path",{d:"M8 16H3v5"})]})})]})]})}function s0(){return jsxs("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#a1a1aa"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"m21 16-4 4-4-4"}),jsx("path",{d:"M17 20V4"}),jsx("path",{d:"m3 8 4-4 4 4"}),jsx("path",{d:"M7 4v16"})]})}function a0({type:e}){let t={width:16,height:16},r={viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};return e==="trending-up"?jsxs("svg",{...r,style:t,children:[jsx("path",{d:"M16 7h6v6"}),jsx("path",{d:"m22 7-8.5 8.5-5-5L2 17"})]}):e==="chart-column"?jsxs("svg",{...r,style:t,children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}):jsx("svg",{...r,style:t,children:jsx("path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z"})})}function l0(){return jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#a1a1aa"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"})})}function c0({onMouseEnter:e,onMouseLeave:t}){return jsxs("svg",{viewBox:"0 0 24 24",className:"hidden sm:block",style:{width:12,height:12,color:"#52525b",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",onMouseEnter:e,onMouseLeave:t,children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M12 16v-4"}),jsx("path",{d:"M12 8h.01"})]})}function dl({open:e}){return jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#71717a",transition:"transform 0.15s",transform:e?"rotate(180deg)":void 0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"m6 9 6 6 6-6"})})}function m0(e){return formatAmountInUsd(e)}var f0=[{key:"activePairs",labelKey:"predict.matches.stats.activePairs",format:e=>formatAmount(e),valueColor:"#c7ff2e",gradientFrom:"rgba(199,255,46,0.18)",gradientTo:"rgba(199,255,46,0.04)",borderColor:"rgba(199,255,46,0.18)"},{key:"maxSpread",labelKey:"predict.matches.stats.maxSpread",format:e=>`${(e*100).toFixed(1)}%`,valueColor:"#f76816",gradientFrom:"rgba(247,104,22,0.18)",gradientTo:"rgba(247,104,22,0.04)",borderColor:"rgba(247,104,22,0.18)"},{key:"highSpreadCount",labelKey:"predict.matches.stats.highSpreadCount",format:e=>formatAmount(e),valueColor:"#17c964",gradientFrom:"rgba(23,201,100,0.18)",gradientTo:"rgba(23,201,100,0.04)",borderColor:"rgba(23,201,100,0.18)"},{key:"totalVolume",labelKey:"predict.matches.stats.totalVolume",format:m0,valueColor:"#f5a524",gradientFrom:"rgba(245,165,36,0.18)",gradientTo:"rgba(245,165,36,0.04)",borderColor:"rgba(245,165,36,0.18)"}];function fl({stats:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsx("style",{children:`
|
|
83
83
|
@keyframes match-live-ping{75%,100%{transform:scale(2.2);opacity:0}}
|
|
84
84
|
@keyframes match-live-breathe{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.55;transform:scale(.85)}}
|
|
85
85
|
@keyframes matchStatsEnter{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}
|
|
@@ -117,21 +117,21 @@ import {createContext,memo,useRef,forwardRef,useState,useImperativeHandle,useMem
|
|
|
117
117
|
.matches-stat-label{font-size:11px;line-height:16px;min-height:16px}
|
|
118
118
|
@media(min-width:640px){.matches-stat-label{font-size:12px;line-height:18px;min-height:18px}}
|
|
119
119
|
`}),jsxs("div",{className:"matches-hero-outer",style:{display:"flex",marginBottom:0},children:[jsxs("div",{className:"matches-hero-left",style:{display:"flex",flexDirection:"column",minWidth:0,flex:1,animation:"matchHeroTitleEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both"},children:[jsx("div",{className:"matches-hero-live",style:{display:"flex",marginBottom:16},children:jsxs("div",{className:"inline-flex items-center",style:{gap:8,borderRadius:9999,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"6px 12px",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)"},children:[jsxs("span",{style:{position:"relative",display:"flex",width:8,height:8},children:[jsx("span",{style:{position:"absolute",display:"inline-flex",width:"100%",height:"100%",borderRadius:9999,background:"#00d492",opacity:.75,animation:"match-live-ping 1.2s cubic-bezier(0,0,0.2,1) infinite"}}),jsx("span",{style:{position:"relative",display:"inline-flex",width:8,height:8,borderRadius:9999,background:"#00bc7d",animation:"match-live-breathe 2.4s ease-in-out infinite"}})]}),jsx("span",{style:{fontSize:12,fontWeight:500,color:"#d4d4d8",letterSpacing:"0.025em"},children:t("predict.matches.liveBadge")}),jsx("span",{style:{borderRadius:4,background:"rgba(199,255,46,0.12)",padding:"2px 6px",fontSize:10,fontWeight:600,color:"#c7ff2e",textTransform:"uppercase",border:"1px solid rgba(199,255,46,0.22)"},children:t("predict.matches.betaTag")})]})}),jsxs("h1",{className:"matches-hero-title",style:{fontFamily:"var(--font-dm-sans, 'DM Sans', sans-serif)",fontSize:46,fontWeight:700,letterSpacing:"-1.2px",lineHeight:1.2,color:"#fff",margin:"0 0 14px"},children:[jsxs("span",{style:{color:"#fff"},children:[t("predict.matches.titlePrefix")," "]}),jsx("span",{style:{backgroundImage:"linear-gradient(to right, #c7ff2e, #a0e515, #17c964)",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",backgroundClip:"text"},children:t("predict.matches.titleHighlight")})]}),jsx("p",{className:"matches-hero-subtitle matches-hero-subtitle-text",style:{lineHeight:1.6,color:"#71717a",maxWidth:460},children:String(t("predict.matches.heroSubtitle")).split(`
|
|
120
|
-
`).map((r,o)=>jsxs("span",{children:[o>0&&jsx("br",{className:"hidden sm:block"}),r,o===0?" ":""]},o))})]}),jsx("div",{className:"matches-stat-grid",style:{display:"grid",borderRadius:16,border:"1px solid rgba(39,39,42,0.5)",overflow:"hidden",flexShrink:0,backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",...e?{animation:"matchStatsEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:"0.1s"}:{}},children:
|
|
120
|
+
`).map((r,o)=>jsxs("span",{children:[o>0&&jsx("br",{className:"hidden sm:block"}),r,o===0?" ":""]},o))})]}),jsx("div",{className:"matches-stat-grid",style:{display:"grid",borderRadius:16,border:"1px solid rgba(39,39,42,0.5)",overflow:"hidden",flexShrink:0,backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",...e?{animation:"matchStatsEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:"0.1s"}:{}},children:f0.map((r,o)=>jsxs("div",{style:{padding:"16px 20px",background:e?`linear-gradient(to bottom, ${r.gradientFrom}, ${r.gradientTo})`:"rgba(255,255,255,0.02)",borderRight:o%2===0?"1px solid rgba(39,39,42,0.4)":"none",borderBottom:o<2?"1px solid rgba(39,39,42,0.4)":"none",...e?{animation:"matchStatCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:`${150+o*60}ms`}:{}},children:[jsx("div",{className:"matches-stat-val",style:{fontWeight:700,fontVariantNumeric:"tabular-nums",color:e?r.valueColor:"transparent",display:"flex",alignItems:"center"},children:e?r.format(e[r.key]??0):jsx("div",{style:{height:16,width:56,borderRadius:4,background:"rgba(255,255,255,0.06)",animation:"matchStatCardEnter 0.6s ease-out both",animationDelay:`${o*80}ms`}})}),jsx("div",{className:"matches-stat-label",style:{fontWeight:500,color:e?"#71717a":"transparent",marginTop:2,display:"flex",alignItems:"center"},children:e?t(r.labelKey):jsx("div",{style:{height:10,width:64,borderRadius:4,background:"rgba(255,255,255,0.04)",animation:"matchStatCardEnter 0.6s ease-out both",animationDelay:`${50+o*80}ms`}})})]},r.key))})]})]})}function ii(e){return e==null?"-":formatAmountInUsd(e)}function v0(e){return e==null?"narrow":e>=5?"wide":e>=3?"moderate":"narrow"}var xl={wide:{color:"#f76816",bandFrom:"rgba(247,104,22,0.14)",bandTo:"rgba(247,104,22,0.03)",gaugeActive:"#f76816",gaugeInactive:"rgba(247,104,22,0.15)"},moderate:{color:"#c7ff2e",bandFrom:"rgba(199,255,46,0.12)",bandTo:"rgba(199,255,46,0.02)",gaugeActive:"#c7ff2e",gaugeInactive:"rgba(199,255,46,0.15)"},narrow:{color:"#71717a",bandFrom:"rgba(113,113,122,0.08)",bandTo:"transparent",gaugeActive:"#71717a",gaugeInactive:"rgba(113,113,122,0.12)"}},x0={wide:{border:"rgba(247,104,22,0.4)",shadow:"0 2px 18px rgba(247,104,22,0.35)"},moderate:{border:"rgba(199,255,46,0.5)",shadow:"0 2px 20px rgba(199,255,46,0.45)"},narrow:{border:"rgba(113,113,122,0.5)",shadow:"0 2px 20px rgba(113,113,122,0.35)"}},gl={liquid_gap:{dot:"#17c964",label:"predict.matches.signalLiquidGap"},active_gap:{dot:"#c7ff2e",label:"predict.matches.signalActiveGap"},stale_gap:{dot:"#f5a524",label:"predict.matches.signalStaleGap"},stale_data:{dot:"#71717a",label:"predict.matches.signalStaleData"}};function b0(e){return e==null?null:e<120?"fresh":e<300?"aging":"stale"}var y0={fresh:"#17c964",aging:"#f5a524",stale:"#71717a"},k0={polymarket:{text:"#50a2ff",icon:"#50a2ff"},kalshi:{text:"#00d492",icon:"#00d492"}},S0={text:"#9ca3af",icon:"#9ca3af"};function w0(e){return k0[e]??S0}var P0=`
|
|
121
121
|
.match-card button:focus-visible,
|
|
122
122
|
.match-card a:focus-visible,
|
|
123
123
|
.match-card [role="button"]:focus-visible {
|
|
124
124
|
outline: 2px solid hsl(var(--heroui-primary) / 0.4);
|
|
125
125
|
outline-offset: 2px;
|
|
126
126
|
}
|
|
127
|
-
`;function y0({tier:e}){let t=hl[e],r=e==="wide"?5:e==="moderate"?3:1;return jsx("div",{style:{display:"flex",gap:2,alignItems:"center"},children:Array.from({length:5},(o,n)=>jsx("div",{style:{width:6,height:10,borderRadius:1.5,background:n<r?t.gaugeActive:t.gaugeInactive,transition:"background 0.2s"}},n))})}function k0(e){if(Array.isArray(e.legs)&&e.legs.length===2)return [e.legs[0],e.legs[1]];let t=(r,o,n)=>({source:r,event_title:o,event_slug:n?.event_slug??"",market_id:n?.id??0,market_slug:n?.slug??"",question:n?.question??"",status:n?.status??"open",outcomes:n?.outcomes,best_price:n?.outcomes?.[0]?.best_ask??n?.outcomes?.[0]?.price??void 0,vol_24h_usd:n?.volume_24h??void 0});return !e.market_a||!e.market_b?null:[t(e.source_a,e.event_a_title??"",e.market_a),t(e.source_b,e.event_b_title??"",e.market_b)]}function vl({match:e,onSelectMatch:t,getMatchHref:r,onSelectLeg:o,getLegHref:n,onHover:i,getMarketHref:s,LinkComponent:a}){let{t:l}=useTranslation(),u=k0(e);if(!u)return null;let[d,p]=u,m=e.spread_percent!=null?e.spread_percent:e.spread!=null?e.spread*100:null,c=p0(m),f=hl[c],g=d.best_price!=null&&p.best_price!=null?d.best_price<=p.best_price?d.source:p.source:null,v=d.event_title||p.event_title,x=e.signal_tag??"stale_data",b=ml[x]??ml.stale_data,w=r?.(e),S=jsxs(Fragment,{children:[jsx("style",{children:b0}),m!=null&&jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",background:`linear-gradient(90deg, ${f.bandFrom}, ${f.bandTo})`,borderBottom:"1px solid rgba(39,39,42,0.3)"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,flexShrink:0,color:f.color},fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),jsxs("span",{style:{fontSize:15,fontWeight:700,fontVariantNumeric:"tabular-nums",color:f.color},children:[m.toFixed(1),"%"]}),jsx("span",{style:{fontSize:10,fontWeight:500,color:"rgba(161,161,170,0.7)",textTransform:"uppercase",letterSpacing:"0.06em"},children:l("predict.matches.gap")})]}),jsx(y0,{tier:c})]}),jsxs("div",{style:{padding:"14px 14px 12px"},children:[jsx("h3",{style:{fontSize:13,fontWeight:600,lineHeight:1.4,letterSpacing:"-0.2px",color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",margin:"0 0 12px"},children:v}),jsxs("div",{style:{borderRadius:10,border:"1px solid rgba(39,39,42,0.4)",overflow:"hidden"},children:[jsx(fl,{leg:d,isCheaper:g===d.source,externalUrlFallback:s?.(e,d.source),internalHref:n?.(e,d),onSelect:o?()=>o(e,d):void 0,LinkComponent:a}),jsx("div",{style:{height:1,background:"rgba(39,39,42,0.3)"}}),jsx(fl,{leg:p,isCheaper:g===p.source,externalUrlFallback:s?.(e,p.source),internalHref:n?.(e,p),onSelect:o?()=>o(e,p):void 0,LinkComponent:a})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.15)",padding:"8px 14px"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,fontSize:10,color:"#71717a"},children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}),ii(e.combined_volume)]}),e.combined_volume_24h!=null&&e.combined_volume_24h>0&&jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z"})}),ii(e.combined_volume_24h)," ",l("predict.matches.vol24h")]}),e.age_seconds!=null&&jsxs("span",{title:l("predict.matches.updatedAgo",{seconds:e.age_seconds}),style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("polyline",{points:"12 6 12 12 16 14"})]}),S0(l,e.age_seconds)]})]}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,color:"#52525b"},children:[jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:b.dot,flexShrink:0}}),l(b.label)]})]})]}),h={display:"block",color:"inherit",textDecoration:"none",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",cursor:w||t?"pointer":void 0},y=P=>{let I=P.currentTarget,D=m0[c];I.style.borderColor=D.border,I.style.boxShadow=D.shadow,i?.(e);},k=P=>{let I=P.currentTarget;I.style.borderColor="rgba(39,39,42,0.6)",I.style.boxShadow="none";};return w&&a?jsx(a,{href:w,className:"group match-card",children:jsx("div",{style:h,onMouseEnter:y,onMouseLeave:k,onClick:()=>t?.(e),children:S})}):jsx("div",{className:"group match-card",role:t?"button":void 0,tabIndex:t?0:void 0,style:h,onMouseEnter:y,onMouseLeave:k,onClick:()=>t?.(e),onKeyDown:P=>{t&&(P.key==="Enter"||P.key===" ")&&(P.preventDefault(),t(e));},children:S})}function S0(e,t){if(t<60)return e("predict.matches.ageJustNow");if(t<3600){let o=Math.floor(t/60);return e("predict.matches.ageMinutes",{count:o})}let r=Math.floor(t/3600);return e("predict.matches.ageHours",{count:r})}function fl({leg:e,isCheaper:t,externalUrlFallback:r,internalHref:o,onSelect:n,LinkComponent:i}){let{t:s}=useTranslation(),a=Ot(e.source),l=x0(e.source),u=e.best_price,d=e.outcomes?.[0]?.label??null,p=e.external_url??r,m=f0(e.age_seconds),c=x=>{x.stopPropagation();},f=!!(o||n),g={display:"flex",alignItems:"center",gap:8,padding:"10px 12px",background:t?"rgba(199,255,46,0.03)":"transparent",cursor:f?"pointer":void 0,color:"inherit",textDecoration:"none"},v=jsxs(Fragment,{children:[t?jsx("span",{style:{fontSize:10,color:"#c7ff2e",flexShrink:0},children:"\u2605"}):jsx("span",{style:{width:10,flexShrink:0}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,width:100,flexShrink:0},children:[a.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",color:l.text,textTransform:"uppercase"},children:a.label}),m&&jsx("span",{title:e.age_seconds!=null?s("predict.matches.updatedAgo",{seconds:e.age_seconds}):void 0,style:{width:6,height:6,borderRadius:"50%",background:g0[m],flexShrink:0}})]}),jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:1},children:[d&&jsx("span",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d}),jsxs("span",{style:{fontSize:9,color:"#52525b"},children:[ii(e.vol_24h_usd)," ",s("predict.matches.vol24h")]})]}),jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:3,flexShrink:0},children:[jsx("span",{style:{fontSize:18,fontWeight:700,fontVariantNumeric:"tabular-nums",color:t?"#c7ff2e":"#f4f4f5"},children:u!=null?(u*100).toFixed(1):"-"}),jsx("span",{style:{fontSize:9,color:"#71717a"},children:s("predict.matches.centsYes")})]}),p?jsx("a",{href:p,target:"_blank",rel:"noopener noreferrer","aria-label":s("predict.matches.viewOn",{platform:a.label}),title:s("predict.matches.viewOn",{platform:a.label}),onClick:x=>x.stopPropagation(),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,borderRadius:4,color:"#71717a",flexShrink:0},onMouseEnter:x=>{x.currentTarget.style.color="#d4d4d8",x.currentTarget.style.background="rgba(255,255,255,0.05)";},onMouseLeave:x=>{x.currentTarget.style.color="#71717a",x.currentTarget.style.background="transparent";},children:jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M7 7h10v10"}),jsx("path",{d:"M7 17 17 7"})]})}):jsx("span",{style:{width:18,flexShrink:0}})]});return o&&i?jsx(i,{href:o,className:"match-card-leg-link",onClick:x=>{c(x),n?.();},children:jsx("div",{style:g,children:v})}):f?jsx("div",{role:"link",tabIndex:0,style:g,onClick:x=>{c(x),n?.();},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),c(x),n?.());},children:v}):jsx("div",{style:g,children:v})}var Sl=forwardRef(function({sortBy:t,sortAsc:r,minVolume:o,signal:n,onSelectMatch:i,getMatchHref:s,onSelectLeg:a,getLegHref:l,onSelect:u,onHover:d,getMarketHref:p,LinkComponent:m,onStatsChange:c},f){let{t:g}=useTranslation(),{data:v,hasNextPage:x,fetchNextPage:b,isFetchingNextPage:w,isLoading:S,isPlaceholderData:h,refetch:y}=useInfiniteMatchMarkets({sort_by:t,sort_asc:r,min_volume:o,signal:n,status:"active",limit:20},{placeholderData:keepPreviousData}),[k,P]=useState(0),[I,D]=useState(false);I&&!h?(D(false),P(te=>te+1)):h&&!I&&D(true),useImperativeHandle(f,()=>({refetch:()=>{y();}}),[y]);let W=useMemo(()=>v?.pages.flatMap(te=>te.items??[])??[],[v]),O=v?.pages[0]?.total,G=useMemo(()=>{let te=0,N=0,M=0;for(let U of W){let X=U.spread??0;X>te&&(te=X),X>=.03&&M++,U.combined_volume!=null&&(N+=U.combined_volume);}return {activePairs:O??W.length,maxSpread:te,highSpreadCount:M,totalVolume:N}},[W,O]);useEffect(()=>{G.activePairs>0&&c?.(G);},[G,c]);let j=useRef(null),Q=useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]);if(useEffect(()=>{let te=j.current;if(!te)return;let N=new IntersectionObserver(M=>{M[0]?.isIntersecting&&x&&!w&&b();},{rootMargin:"200px"});return N.observe(te),()=>N.disconnect()},[x,w,b]),useEffect(()=>{if(x)return document.documentElement.style.overscrollBehaviorY="none",()=>{document.documentElement.style.overscrollBehaviorY="";}},[x]),S)return jsx(L0,{});if(W.length===0)return jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"80px 0",color:"rgba(255,255,255,0.35)"},children:jsx("p",{style:{fontSize:18},children:g("predict.matches.empty")})});let re=!x&&W.length>0;return jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[jsx("style",{children:`
|
|
127
|
+
`;function N0({tier:e}){let t=xl[e],r=e==="wide"?5:e==="moderate"?3:1;return jsx("div",{style:{display:"flex",gap:2,alignItems:"center"},children:Array.from({length:5},(o,n)=>jsx("div",{style:{width:6,height:10,borderRadius:1.5,background:n<r?t.gaugeActive:t.gaugeInactive,transition:"background 0.2s"}},n))})}function C0(e){if(Array.isArray(e.legs)&&e.legs.length===2)return [e.legs[0],e.legs[1]];let t=(r,o,n)=>({source:r,event_title:o,event_slug:n?.event_slug??"",market_id:n?.id??0,market_slug:n?.slug??"",question:n?.question??"",status:n?.status??"open",outcomes:n?.outcomes,best_price:n?.outcomes?.[0]?.best_ask??n?.outcomes?.[0]?.price??void 0,vol_24h_usd:n?.volume_24h??void 0});return !e.market_a||!e.market_b?null:[t(e.source_a,e.event_a_title??"",e.market_a),t(e.source_b,e.event_b_title??"",e.market_b)]}function bl({match:e,onSelectMatch:t,getMatchHref:r,onSelectLeg:o,getLegHref:n,onHover:i,getMarketHref:s,LinkComponent:a}){let{t:l}=useTranslation(),u=C0(e);if(!u)return null;let[d,p]=u,m=e.spread_percent!=null?e.spread_percent:e.spread!=null?e.spread*100:null,c=v0(m),f=xl[c],g=d.best_price!=null&&p.best_price!=null?d.best_price<=p.best_price?d.source:p.source:null,v=d.event_title||p.event_title,x=e.signal_tag??"stale_data",b=gl[x]??gl.stale_data,w=r?.(e),S=jsxs(Fragment,{children:[jsx("style",{children:P0}),m!=null&&jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",background:`linear-gradient(90deg, ${f.bandFrom}, ${f.bandTo})`,borderBottom:"1px solid rgba(39,39,42,0.3)"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,flexShrink:0,color:f.color},fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),jsxs("span",{style:{fontSize:15,fontWeight:700,fontVariantNumeric:"tabular-nums",color:f.color},children:[m.toFixed(1),"%"]}),jsx("span",{style:{fontSize:10,fontWeight:500,color:"rgba(161,161,170,0.7)",textTransform:"uppercase",letterSpacing:"0.06em"},children:l("predict.matches.gap")})]}),jsx(N0,{tier:c})]}),jsxs("div",{style:{padding:"14px 14px 12px"},children:[jsx("h3",{style:{fontSize:13,fontWeight:600,lineHeight:1.4,letterSpacing:"-0.2px",color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",margin:"0 0 12px"},children:v}),jsxs("div",{style:{borderRadius:10,border:"1px solid rgba(39,39,42,0.4)",overflow:"hidden"},children:[jsx(hl,{leg:d,isCheaper:g===d.source,externalUrlFallback:s?.(e,d.source),internalHref:n?.(e,d),onSelect:o?()=>o(e,d):void 0,LinkComponent:a}),jsx("div",{style:{height:1,background:"rgba(39,39,42,0.3)"}}),jsx(hl,{leg:p,isCheaper:g===p.source,externalUrlFallback:s?.(e,p.source),internalHref:n?.(e,p),onSelect:o?()=>o(e,p):void 0,LinkComponent:a})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.15)",padding:"8px 14px"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,fontSize:10,color:"#71717a"},children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}),ii(e.combined_volume)]}),e.combined_volume_24h!=null&&e.combined_volume_24h>0&&jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z"})}),ii(e.combined_volume_24h)," ",l("predict.matches.vol24h")]}),e.age_seconds!=null&&jsxs("span",{title:l("predict.matches.updatedAgo",{seconds:e.age_seconds}),style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("polyline",{points:"12 6 12 12 16 14"})]}),M0(l,e.age_seconds)]})]}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,color:"#52525b"},children:[jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:b.dot,flexShrink:0}}),l(b.label)]})]})]}),h={display:"block",color:"inherit",textDecoration:"none",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",cursor:w||t?"pointer":void 0},y=P=>{let O=P.currentTarget,F=x0[c];O.style.borderColor=F.border,O.style.boxShadow=F.shadow,i?.(e);},k=P=>{let O=P.currentTarget;O.style.borderColor="rgba(39,39,42,0.6)",O.style.boxShadow="none";};return w&&a?jsx(a,{href:w,className:"group match-card",children:jsx("div",{style:h,onMouseEnter:y,onMouseLeave:k,onClick:()=>t?.(e),children:S})}):jsx("div",{className:"group match-card",role:t?"button":void 0,tabIndex:t?0:void 0,style:h,onMouseEnter:y,onMouseLeave:k,onClick:()=>t?.(e),onKeyDown:P=>{t&&(P.key==="Enter"||P.key===" ")&&(P.preventDefault(),t(e));},children:S})}function M0(e,t){if(t<60)return e("predict.matches.ageJustNow");if(t<3600){let o=Math.floor(t/60);return e("predict.matches.ageMinutes",{count:o})}let r=Math.floor(t/3600);return e("predict.matches.ageHours",{count:r})}function hl({leg:e,isCheaper:t,externalUrlFallback:r,internalHref:o,onSelect:n,LinkComponent:i}){let{t:s}=useTranslation(),a=Dt(e.source),l=w0(e.source),u=e.best_price,d=e.outcomes?.[0]?.label??null,p=e.external_url??r,m=b0(e.age_seconds),c=x=>{x.stopPropagation();},f=!!(o||n),g={display:"flex",alignItems:"center",gap:8,padding:"10px 12px",background:t?"rgba(199,255,46,0.03)":"transparent",cursor:f?"pointer":void 0,color:"inherit",textDecoration:"none"},v=jsxs(Fragment,{children:[t?jsx("span",{style:{fontSize:10,color:"#c7ff2e",flexShrink:0},children:"\u2605"}):jsx("span",{style:{width:10,flexShrink:0}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,width:100,flexShrink:0},children:[a.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",color:l.text,textTransform:"uppercase"},children:a.label}),m&&jsx("span",{title:e.age_seconds!=null?s("predict.matches.updatedAgo",{seconds:e.age_seconds}):void 0,style:{width:6,height:6,borderRadius:"50%",background:y0[m],flexShrink:0}})]}),jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:1},children:[d&&jsx("span",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d}),jsxs("span",{style:{fontSize:9,color:"#52525b"},children:[ii(e.vol_24h_usd)," ",s("predict.matches.vol24h")]})]}),jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:3,flexShrink:0},children:[jsx("span",{style:{fontSize:18,fontWeight:700,fontVariantNumeric:"tabular-nums",color:t?"#c7ff2e":"#f4f4f5"},children:u!=null?(u*100).toFixed(1):"-"}),jsx("span",{style:{fontSize:9,color:"#71717a"},children:s("predict.matches.centsYes")})]}),p?jsx("a",{href:p,target:"_blank",rel:"noopener noreferrer","aria-label":s("predict.matches.viewOn",{platform:a.label}),title:s("predict.matches.viewOn",{platform:a.label}),onClick:x=>x.stopPropagation(),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,borderRadius:4,color:"#71717a",flexShrink:0},onMouseEnter:x=>{x.currentTarget.style.color="#d4d4d8",x.currentTarget.style.background="rgba(255,255,255,0.05)";},onMouseLeave:x=>{x.currentTarget.style.color="#71717a",x.currentTarget.style.background="transparent";},children:jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M7 7h10v10"}),jsx("path",{d:"M7 17 17 7"})]})}):jsx("span",{style:{width:18,flexShrink:0}})]});return o&&i?jsx(i,{href:o,className:"match-card-leg-link",onClick:x=>{c(x),n?.();},children:jsx("div",{style:g,children:v})}):f?jsx("div",{role:"link",tabIndex:0,style:g,onClick:x=>{c(x),n?.();},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),c(x),n?.());},children:v}):jsx("div",{style:g,children:v})}var Pl=forwardRef(function({sortBy:t,sortAsc:r,minVolume:o,signal:n,onSelectMatch:i,getMatchHref:s,onSelectLeg:a,getLegHref:l,onSelect:u,onHover:d,getMarketHref:p,LinkComponent:m,onStatsChange:c},f){let{t:g}=useTranslation(),{data:v,hasNextPage:x,fetchNextPage:b,isFetchingNextPage:w,isLoading:S,isPlaceholderData:h,refetch:y}=useInfiniteMatchMarkets({sort_by:t,sort_asc:r,min_volume:o,signal:n,status:"active",limit:20},{placeholderData:keepPreviousData}),[k,P]=useState(0),[O,F]=useState(false);O&&!h?(F(false),P(te=>te+1)):h&&!O&&F(true),useImperativeHandle(f,()=>({refetch:()=>{y();}}),[y]);let W=useMemo(()=>v?.pages.flatMap(te=>te.items??[])??[],[v]),A=v?.pages[0]?.total,G=useMemo(()=>{let te=0,N=0,C=0;for(let U of W){let X=U.spread??0;X>te&&(te=X),X>=.03&&C++,U.combined_volume!=null&&(N+=U.combined_volume);}return {activePairs:A??W.length,maxSpread:te,highSpreadCount:C,totalVolume:N}},[W,A]);useEffect(()=>{G.activePairs>0&&c?.(G);},[G,c]);let q=useRef(null),Y=useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]);if(useEffect(()=>{let te=q.current;if(!te)return;let N=new IntersectionObserver(C=>{C[0]?.isIntersecting&&x&&!w&&b();},{rootMargin:"200px"});return N.observe(te),()=>N.disconnect()},[x,w,b]),useEffect(()=>{if(x)return document.documentElement.style.overscrollBehaviorY="none",()=>{document.documentElement.style.overscrollBehaviorY="";}},[x]),S)return jsx(A0,{});if(W.length===0)return jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"80px 0",color:"rgba(255,255,255,0.35)"},children:jsx("p",{style:{fontSize:18},children:g("predict.matches.empty")})});let re=!x&&W.length>0;return jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[jsx("style",{children:`
|
|
128
128
|
@media(max-width:1023px){.matches-card-grid{grid-template-columns:1fr!important}}
|
|
129
129
|
@keyframes matchCardEnter{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}
|
|
130
|
-
`}),jsx("div",{className:"matches-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:16},children:v?.pages.map(te=>te.items?.map((N,M)=>jsx("div",{style:{animation:`matchCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${M*35}ms both`},children:jsx(vl,{match:N,onSelectMatch:i,getMatchHref:s,onSelectLeg:a,getLegHref:l,onHover:d,onSelect:u,getMarketHref:p,LinkComponent:m})},`${k}-${N.match_id}-${N.source_a}-${N.market_a?.slug??M}`)))}),jsxs("div",{ref:j,style:{display:"flex",flexDirection:"column",alignItems:"center",gap:8,padding:"16px 0",minHeight:1},children:[jsx("style",{children:"@keyframes match-load-spin{to{transform:rotate(360deg)}}"}),w&&jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#71717a",fontSize:13},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:"match-load-spin 1s linear infinite"},children:jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),g("predict.matches.loadMore")]})]}),re&&jsx(T0,{onScrollToTop:Q})]})});function T0({onScrollToTop:e}){let{t}=useTranslation();return jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:16,padding:"24px 0"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:16,width:"100%"},children:[jsx("div",{style:{height:1,width:64,background:"rgba(82,82,91,0.5)"}}),jsx("span",{style:{fontSize:12,fontWeight:500,color:"#71717a"},children:t("predict.matches.endOfList")}),jsx("div",{style:{height:1,width:64,background:"rgba(82,82,91,0.5)"}})]}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:4,fontSize:12,fontWeight:500,color:"#a1a1aa",background:"none",border:"none",cursor:"pointer",padding:0},onClick:e,children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12 19V5"}),jsx("path",{d:"m5 12 7-7 7 7"})]}),jsx("span",{children:t("predict.matches.backToTop")})]})]})}function L0(){return jsxs(Fragment,{children:[jsx("style",{children:"@keyframes shimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}@media(max-width:1023px){.matches-skeleton-grid{grid-template-columns:1fr!important}}"}),jsx("div",{className:"matches-skeleton-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:16},children:Array.from({length:6}).map((e,t)=>jsx(R0,{index:t},t))})]})}function R0({index:e}){let r={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:`shimmer 1.8s ease-in-out infinite ${e*150}ms`,borderRadius:6};return jsxs("div",{style:{borderRadius:16,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden"},children:[jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",padding:"16px 16px 12px"},children:[jsx("div",{style:{...r,height:14,width:e%2===0?"75%":"60%"}}),jsx("div",{style:{...r,height:24,width:64,borderRadius:10,flexShrink:0,marginLeft:12}})]}),jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,padding:"0 16px"},children:[0,1].map(o=>jsxs("div",{style:{borderRadius:12,border:"1px solid rgba(255,255,255,0.04)",background:"rgba(255,255,255,0.02)",padding:12,display:"flex",flexDirection:"column",gap:8},children:[jsx("div",{style:{...r,height:10,width:72}}),jsx("div",{style:{...r,height:10,width:48}}),jsx("div",{style:{...r,height:20,width:56}}),jsx("div",{style:{...r,height:10,width:60,marginTop:4}})]},o))}),jsx("div",{style:{padding:"12px 16px"},children:jsx("div",{style:{...r,height:36,borderRadius:10,width:"100%"}})}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",padding:"10px 16px"},children:[jsxs("div",{style:{display:"flex",gap:12},children:[jsx("div",{style:{...r,height:10,width:40}}),jsx("div",{style:{...r,height:10,width:50}})]}),jsx("div",{style:{...r,height:10,width:56}})]})]})}var F0={spread:"predict.matches.topOpportunities",volume:"predict.matches.highestVolume",confidence:"predict.matches.trendingToday"};function B0(){let[e,t]=useState("");return useEffect(()=>{let r=()=>{let n=new Date;return `${String(n.getHours()).padStart(2,"0")}:${String(n.getMinutes()).padStart(2,"0")}`};t(r());let o=setInterval(()=>t(r()),1e4);return ()=>clearInterval(o)},[]),jsx("span",{children:e})}function H0({stats:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsx("style",{children:"@media(max-width:768px){.matches-status-bar{display:none!important}}"}),jsxs("div",{className:"matches-status-bar",style:{position:"fixed",bottom:0,left:0,right:0,height:28,display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 12px",background:"rgba(12,12,13,0.8)",borderTop:"1px solid rgba(39,39,42,0.6)",fontSize:11,color:"rgba(255,255,255,0.4)",zIndex:50,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",flexShrink:0},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,color:"#00bc7d"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12 20h.01"}),jsx("path",{d:"M2 8.82a15 15 0 0 1 20 0"}),jsx("path",{d:"M5 12.859a10 10 0 0 1 14 0"}),jsx("path",{d:"M8.5 16.429a5 5 0 0 1 7 0"})]}),jsx("span",{style:{color:"#00bc7d",fontWeight:500},children:t("predict.matches.status.live")})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)"}}),e&&jsxs("div",{className:"hidden sm:flex",style:{alignItems:"center",gap:12},children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"})}),jsx("span",{style:{color:"#52525b"},children:t("predict.matches.status.markets")}),jsx("span",{style:{color:"#d4d4d8",fontWeight:500,fontVariantNumeric:"tabular-nums"},children:formatAmount(e.activePairs)})]}),jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}),jsx("span",{style:{color:"#52525b"},children:t("predict.matches.status.vol24h")}),jsx("span",{style:{color:"#d4d4d8",fontWeight:500,fontVariantNumeric:"tabular-nums"},children:e.totalVolume>=1e6?`$${(e.totalVolume/1e6).toFixed(1)}M`:e.totalVolume>=1e3?`$${Math.round(e.totalVolume/1e3)}K`:`$${e.totalVolume}`})]})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("a",{href:"#",target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",textDecoration:"none",transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),jsx("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),jsx("path",{d:"M10 9H8"}),jsx("path",{d:"M16 13H8"}),jsx("path",{d:"M16 17H8"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.docs")})]}),jsxs("a",{href:"#",target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",textDecoration:"none",transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"currentColor",children:jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),jsx("span",{className:"hidden lg:inline",children:"X"})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)",margin:"0 4px"}}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.watchlist")})]}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2.5"}),jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.portfolio")})]}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),jsx("path",{d:"M12 17h.01"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.help")})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)",margin:"0 4px"}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("polyline",{points:"12 6 12 12 16 14"})]}),jsx(B0,{})]})]})]})]})}function gS({onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:o,onHover:n,onSelect:i,getMarketHref:s,LinkComponent:a,bgImageSrc:l}){let{t:u}=useTranslation(),[d,p]=useState("spread"),[m,c]=useState(false),[f,g]=useState(void 0),[v,x]=useState(),b=useRef(null),w=useCallback(k=>{p(k);},[]),S=useCallback(k=>{c(k);},[]),h=useCallback(k=>{startTransition(()=>{x(k);});},[]),y=useCallback(()=>{b.current?.refetch();},[]);return jsxs("div",{style:{minHeight:"100vh",position:"relative"},children:[jsx("style",{children:`
|
|
130
|
+
`}),jsx("div",{className:"matches-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:16},children:v?.pages.map(te=>te.items?.map((N,C)=>jsx("div",{style:{animation:`matchCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${C*35}ms both`},children:jsx(bl,{match:N,onSelectMatch:i,getMatchHref:s,onSelectLeg:a,getLegHref:l,onHover:d,onSelect:u,getMarketHref:p,LinkComponent:m})},`${k}-${N.match_id}-${N.source_a}-${N.market_a?.slug??C}`)))}),jsxs("div",{ref:q,style:{display:"flex",flexDirection:"column",alignItems:"center",gap:8,padding:"16px 0",minHeight:1},children:[jsx("style",{children:"@keyframes match-load-spin{to{transform:rotate(360deg)}}"}),w&&jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#71717a",fontSize:13},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:"match-load-spin 1s linear infinite"},children:jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),g("predict.matches.loadMore")]})]}),re&&jsx(O0,{onScrollToTop:Y})]})});function O0({onScrollToTop:e}){let{t}=useTranslation();return jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:16,padding:"24px 0"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:16,width:"100%"},children:[jsx("div",{style:{height:1,width:64,background:"rgba(82,82,91,0.5)"}}),jsx("span",{style:{fontSize:12,fontWeight:500,color:"#71717a"},children:t("predict.matches.endOfList")}),jsx("div",{style:{height:1,width:64,background:"rgba(82,82,91,0.5)"}})]}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:4,fontSize:12,fontWeight:500,color:"#a1a1aa",background:"none",border:"none",cursor:"pointer",padding:0},onClick:e,children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12 19V5"}),jsx("path",{d:"m5 12 7-7 7 7"})]}),jsx("span",{children:t("predict.matches.backToTop")})]})]})}function A0(){return jsxs(Fragment,{children:[jsx("style",{children:"@keyframes shimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}@media(max-width:1023px){.matches-skeleton-grid{grid-template-columns:1fr!important}}"}),jsx("div",{className:"matches-skeleton-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:16},children:Array.from({length:6}).map((e,t)=>jsx(D0,{index:t},t))})]})}function D0({index:e}){let r={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:`shimmer 1.8s ease-in-out infinite ${e*150}ms`,borderRadius:6};return jsxs("div",{style:{borderRadius:16,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden"},children:[jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",padding:"16px 16px 12px"},children:[jsx("div",{style:{...r,height:14,width:e%2===0?"75%":"60%"}}),jsx("div",{style:{...r,height:24,width:64,borderRadius:10,flexShrink:0,marginLeft:12}})]}),jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,padding:"0 16px"},children:[0,1].map(o=>jsxs("div",{style:{borderRadius:12,border:"1px solid rgba(255,255,255,0.04)",background:"rgba(255,255,255,0.02)",padding:12,display:"flex",flexDirection:"column",gap:8},children:[jsx("div",{style:{...r,height:10,width:72}}),jsx("div",{style:{...r,height:10,width:48}}),jsx("div",{style:{...r,height:20,width:56}}),jsx("div",{style:{...r,height:10,width:60,marginTop:4}})]},o))}),jsx("div",{style:{padding:"12px 16px"},children:jsx("div",{style:{...r,height:36,borderRadius:10,width:"100%"}})}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",padding:"10px 16px"},children:[jsxs("div",{style:{display:"flex",gap:12},children:[jsx("div",{style:{...r,height:10,width:40}}),jsx("div",{style:{...r,height:10,width:50}})]}),jsx("div",{style:{...r,height:10,width:56}})]})]})}var U0={spread:"predict.matches.topOpportunities",volume:"predict.matches.highestVolume",confidence:"predict.matches.trendingToday"};function $0(){let[e,t]=useState("");return useEffect(()=>{let r=()=>{let n=new Date;return `${String(n.getHours()).padStart(2,"0")}:${String(n.getMinutes()).padStart(2,"0")}`};t(r());let o=setInterval(()=>t(r()),1e4);return ()=>clearInterval(o)},[]),jsx("span",{children:e})}function K0({stats:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsx("style",{children:"@media(max-width:768px){.matches-status-bar{display:none!important}}"}),jsxs("div",{className:"matches-status-bar",style:{position:"fixed",bottom:0,left:0,right:0,height:28,display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 12px",background:"rgba(12,12,13,0.8)",borderTop:"1px solid rgba(39,39,42,0.6)",fontSize:11,color:"rgba(255,255,255,0.4)",zIndex:50,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",flexShrink:0},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,color:"#00bc7d"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12 20h.01"}),jsx("path",{d:"M2 8.82a15 15 0 0 1 20 0"}),jsx("path",{d:"M5 12.859a10 10 0 0 1 14 0"}),jsx("path",{d:"M8.5 16.429a5 5 0 0 1 7 0"})]}),jsx("span",{style:{color:"#00bc7d",fontWeight:500},children:t("predict.matches.status.live")})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)"}}),e&&jsxs("div",{className:"hidden sm:flex",style:{alignItems:"center",gap:12},children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"})}),jsx("span",{style:{color:"#52525b"},children:t("predict.matches.status.markets")}),jsx("span",{style:{color:"#d4d4d8",fontWeight:500,fontVariantNumeric:"tabular-nums"},children:formatAmount(e.activePairs)})]}),jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}),jsx("span",{style:{color:"#52525b"},children:t("predict.matches.status.vol24h")}),jsx("span",{style:{color:"#d4d4d8",fontWeight:500,fontVariantNumeric:"tabular-nums"},children:e.totalVolume>=1e6?`$${(e.totalVolume/1e6).toFixed(1)}M`:e.totalVolume>=1e3?`$${Math.round(e.totalVolume/1e3)}K`:`$${e.totalVolume}`})]})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("a",{href:"#",target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",textDecoration:"none",transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),jsx("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),jsx("path",{d:"M10 9H8"}),jsx("path",{d:"M16 13H8"}),jsx("path",{d:"M16 17H8"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.docs")})]}),jsxs("a",{href:"#",target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",textDecoration:"none",transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"currentColor",children:jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),jsx("span",{className:"hidden lg:inline",children:"X"})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)",margin:"0 4px"}}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.watchlist")})]}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2.5"}),jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.portfolio")})]}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),jsx("path",{d:"M12 17h.01"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.help")})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)",margin:"0 4px"}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("polyline",{points:"12 6 12 12 16 14"})]}),jsx($0,{})]})]})]})]})}function bS({onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:o,onHover:n,onSelect:i,getMarketHref:s,LinkComponent:a,bgImageSrc:l}){let{t:u}=useTranslation(),[d,p]=useState("spread"),[m,c]=useState(false),[f,g]=useState(void 0),[v,x]=useState(),b=useRef(null),w=useCallback(k=>{p(k);},[]),S=useCallback(k=>{c(k);},[]),h=useCallback(k=>{startTransition(()=>{x(k);});},[]),y=useCallback(()=>{b.current?.refetch();},[]);return jsxs("div",{style:{minHeight:"100vh",position:"relative"},children:[jsx("style",{children:`
|
|
131
131
|
@keyframes matchFadeIn{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}
|
|
132
132
|
.match-fade-in{animation:matchFadeIn .5s ease-out both}
|
|
133
133
|
.match-fade-in-d1{animation:matchFadeIn .5s ease-out .1s both}
|
|
134
134
|
.match-fade-in-d2{animation:matchFadeIn .5s ease-out .2s both}
|
|
135
|
-
`}),jsxs("div",{style:{position:"relative",overflow:"hidden",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:0,overflow:"hidden"},children:[l&&jsx("img",{src:l,alt:"","aria-hidden":"true",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",objectPosition:"center center",opacity:.3,mixBlendMode:"lighten",maskImage:"linear-gradient(to bottom, black 50%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 50%, transparent 100%)"}}),jsx("div",{style:{position:"absolute",inset:0,opacity:.025,backgroundImage:"radial-gradient(circle at 1px 1px, rgb(255 255 255) 1px, transparent 0)",backgroundSize:"20px 20px"}})]}),jsx("style",{children:".matches-hero-wrap{padding:40px 16px 32px}@media(min-width:640px){.matches-hero-wrap{padding:48px 24px 40px}}@media(min-width:1024px){.matches-hero-wrap{padding:52px 32px 44px}}"}),jsx("div",{className:"match-fade-in matches-hero-wrap",style:{position:"relative",zIndex:2,maxWidth:1152,margin:"0 auto"},children:jsx(pl,{stats:v})})]}),jsxs("div",{style:{position:"sticky",top:0,zIndex:40,background:"rgba(10,10,11,0.8)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsx("style",{children:".matches-toolbar-inner{padding:12px 16px}@media(min-width:640px){.matches-toolbar-inner{padding:12px 24px}}@media(min-width:1024px){.matches-toolbar-inner{padding:12px 32px}}"}),jsxs("div",{className:"matches-toolbar-inner",style:{maxWidth:1152,margin:"0 auto",display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,minWidth:0},children:[jsx("div",{className:"hidden sm:flex",style:{alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:10,background:"linear-gradient(to bottom right, rgba(199,255,46,0.15), rgba(23,201,100,0.15))",border:"1px solid rgba(199,255,46,0.15)",flexShrink:0},children:jsxs("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"}),jsx("path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"}),jsx("path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"})]})}),jsxs("div",{style:{minWidth:0},children:[jsx("h2",{style:{fontSize:14,fontWeight:600,color:"#fff",margin:0,letterSpacing:"-0.28px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u(F0[d])}),v&&v.activePairs>0&&jsx("p",{className:"hidden sm:block",style:{fontSize:11,color:"#71717a",margin:0},children:u("predict.matches.pairsFound",{count:v.activePairs})})]})]}),jsx(dl,{sortBy:d,onSortChange:w,sortAsc:m,onSortAscChange:S,minVolume:f,onMinVolumeChange:g,onRefresh:y})]})]}),jsx("style",{children:".matches-content-wrap{padding:24px 16px 80px}@media(min-width:640px){.matches-content-wrap{padding:32px 24px 80px}}@media(min-width:1024px){.matches-content-wrap{padding:24px 32px 80px}}"}),jsxs("div",{className:"match-fade-in-d2 matches-content-wrap",style:{position:"relative",maxWidth:1152,margin:"0 auto"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:16,padding:"8px 12px",borderRadius:8,border:"1px solid rgba(39,39,42,0.4)",background:"rgba(24,24,27,0.25)"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#52525b",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"})}),jsxs("p",{style:{fontSize:11,color:"#52525b",lineHeight:1.5,margin:0},children:[jsx("span",{style:{color:"#71717a",fontWeight:500},children:u("predict.matches.experimentalFeature")})," \u2014 ",u("predict.matches.disclaimer")]})]}),jsx(Sl,{ref:b,sortBy:d,sortAsc:m,minVolume:f,onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:o,onHover:n,onSelect:i,getMarketHref:s,LinkComponent:a,onStatsChange:h})]}),jsx(H0,{stats:v})]})}function ai(e){return e==null?"-":formatAmountInUsd(e)}var U0={polymarket:{text:"#50a2ff",border:"rgba(43,127,255,0.15)",hoverBorder:"rgba(43,127,255,0.3)",bg:"rgba(43,127,255,0.05)",priceColor:"rgba(244,244,245,1)",priceActiveColor:"rgba(244,244,245,1)"},kalshi:{text:"#00d492",border:"rgba(0,212,146,0.15)",hoverBorder:"rgba(0,212,146,0.3)",bg:"rgba(0,212,146,0.05)",priceColor:"#00d492",priceActiveColor:"#00d492"}},$0={text:"#9ca3af",border:"rgba(156,163,175,0.15)",hoverBorder:"rgba(156,163,175,0.3)",bg:"rgba(156,163,175,0.05)",priceColor:"rgba(244,244,245,1)",priceActiveColor:"rgba(244,244,245,1)"};function K0(e){return U0[e]??$0}function V0(e){if(!e.matched_markets?.length)return null;let t=null,r=-1;for(let o of e.matched_markets){let n=o.spread??0;n>r&&(r=n,t=o);}return t}function j0(e,t){let r=e.entries.find(a=>a.source===(t?.source_a??e.entries[0]?.source)),o=e.entries.find(a=>a.source===(t?.source_b??e.entries[1]?.source)),n=a=>{if(!a?.outcomes?.[0])return {name:null,price:null};let l=a.outcomes[0];return {name:l.label||null,price:l.best_ask??l.price??null}},i=n(t?.market_a),s=n(t?.market_b);return [{source:t?.source_a??r?.source??"unknown",outcomeName:i.name,yesPrice:i.price,volume:r?.event?.volume??null,event:r?.event},{source:t?.source_b??o?.source??"unknown",outcomeName:s.name,yesPrice:s.price,volume:o?.event?.volume??null,event:o?.event}]}function SS({group:e,onSelectEntry:t,getEventHref:r,LinkComponent:o}){let {t:n}=useTranslation(),i=useMemo(()=>V0(e),[e]),s=e.max_spread!=null?e.max_spread*100:null,[a,l]=useMemo(()=>j0(e,i),[e,i]),u=s!=null&&s>=3;a.yesPrice!=null&&l.yesPrice!=null?a.source==="kalshi"?a.yesPrice>l.yesPrice:l.yesPrice>a.yesPrice:false;let p=a.yesPrice!=null&&l.yesPrice!=null?a.yesPrice<=l.yesPrice?a:l:null,m=p?Ot(p.source):null,c=u?"amber":"violet";return jsxs("div",{className:"group",style:{borderRadius:16,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",position:"relative"},onMouseEnter:f=>{let g=f.currentTarget;g.style.borderColor="rgba(63,63,70,0.6)",g.style.boxShadow="0 10px 15px -3px rgba(0,0,0,0.2)";},onMouseLeave:f=>{let g=f.currentTarget;g.style.borderColor="rgba(39,39,42,0.6)",g.style.boxShadow="none";},children:[s!=null&&jsxs("span",{style:{position:"absolute",top:12,right:12,zIndex:10,display:"inline-flex",alignItems:"center",gap:4,borderRadius:10,padding:"4px 10px",fontSize:12,fontWeight:600,border:`1px solid ${u?"rgba(255,185,0,0.3)":s>=2?"rgba(166,132,255,0.3)":"rgba(156,163,175,0.3)"}`,background:u?"rgba(255,185,0,0.15)":s>=2?"rgba(166,132,255,0.15)":"rgba(156,163,175,0.12)",color:u?"#ffb900":s>=2?"#a684ff":"#9ca3af"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),s.toFixed(1),"%"]}),jsxs("div",{style:{padding:16},children:[jsx("h3",{style:{fontSize:14,fontWeight:600,lineHeight:1.375,letterSpacing:"-0.28px",color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",paddingRight:80,margin:"0 0 16px"},children:e.title}),jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[jsx(Nl,{data:a,isCheaper:p===a,onSelect:t,getEventHref:r,LinkComponent:o}),jsx(Nl,{data:l,isCheaper:p===l,onSelect:t,getEventHref:r,LinkComponent:o})]}),p&&m&&s!=null&&jsxs("div",{style:{marginTop:12,padding:"8px 12px",borderRadius:10,display:"flex",alignItems:"center",gap:8,cursor:"pointer",transition:"all 0.15s",border:`1px solid ${c==="amber"?"rgba(255,185,0,0.15)":"rgba(166,132,255,0.15)"}`,background:c==="amber"?"rgba(255,185,0,0.05)":"rgba(166,132,255,0.05)"},onClick:()=>p.event&&t?.(p.event),children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,flexShrink:0,color:c==="amber"?"#ffb900":"#a684ff"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),jsx("span",{style:{fontSize:11,fontWeight:500,color:c==="amber"?"rgba(255,185,0,0.9)":"rgba(166,132,255,0.9)"},children:n("predict.matches.buyEdge",{platform:p.source.charAt(0).toUpperCase()+p.source.slice(1),spread:s.toFixed(1)})}),jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,marginLeft:"auto",color:c==="amber"?"rgba(255,185,0,0.5)":"rgba(166,132,255,0.5)"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M5 12h14"}),jsx("path",{d:"m12 5 7 7-7 7"})]})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.2)",padding:"10px 16px"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,fontSize:10,color:"#71717a"},children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}),ai(e.combined_volume)]}),e.combined_volume_24h!=null&&e.combined_volume_24h>0&&jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z"})}),ai(e.combined_volume_24h)," ",n("predict.matches.vol24h")]})]}),e.confidence!=null&&jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,fontSize:10,color:"#52525b"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"})}),Math.round(e.confidence*100),"%"," ",n("predict.matches.match")]})]})]})}function Nl({data:e,isCheaper:t,onSelect:r,getEventHref:o,LinkComponent:n}){let{t:i}=useTranslation(),s=Ot(e.source),a=K0(e.source),l=e.event?o?.(e.event):void 0,u=jsxs("div",{style:{borderRadius:14,border:`1px solid ${a.border}`,background:a.bg,padding:12,cursor:l||r?"pointer":void 0,transition:"border-color 0.15s"},onMouseEnter:d=>{d.currentTarget.style.borderColor=a.hoverBorder;},onMouseLeave:d=>{d.currentTarget.style.borderColor=a.border;},onClick:()=>e.event&&r?.(e.event),children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[s.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.05em",color:a.text,textTransform:"uppercase"},children:s.label}),jsxs("svg",{viewBox:"0 0 24 24",className:"opacity-0 group-hover:opacity-100 transition-opacity",style:{width:10,height:10,color:"#52525b",marginLeft:"auto"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M7 7h10v10"}),jsx("path",{d:"M7 17 17 7"})]})]}),e.outcomeName&&jsx("div",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginBottom:8},children:e.outcomeName}),jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[jsx("span",{style:{fontSize:20,fontWeight:700,fontVariantNumeric:"tabular-nums",color:t?a.priceActiveColor:a.priceColor},children:e.yesPrice!=null?(e.yesPrice*100).toFixed(1):"-"}),jsx("span",{style:{fontSize:10,color:"#71717a"},children:i("predict.matches.centsYes")})]}),jsxs("div",{style:{fontSize:10,color:"#52525b",marginTop:6},children:[ai(e.volume)," ",i("predict.matches.volume")]})]});return l&&n?jsx(n,{href:l,className:"block",children:u}):u}function Q0(e){return formatAmountInUsd(e)}function ES({matches:e,total:t}){let{t:r}=useTranslation(),o=useMemo(()=>{let n=0,i=0,s=new Set;for(let a of e){a.max_spread!=null&&a.max_spread>n&&(n=a.max_spread),a.combined_volume!=null&&(i+=a.combined_volume);for(let l of a.entries)s.add(typeof l.source=="string"?l.source:"");}return {count:t??e.length,maxSpread:n,totalVolume:i,platformCount:s.size}},[e,t]);return jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 rounded-xl border border-border/60 bg-background/50 px-4 py-3 text-sm",children:[jsx(oo,{label:r("predict.matches.stats.matchedMarkets"),value:o.count.toLocaleString()}),jsx(li,{}),jsx(oo,{label:r("predict.matches.stats.totalVolume"),value:Q0(o.totalVolume)}),jsx(li,{}),jsx(oo,{label:r("predict.matches.stats.highestSpread"),value:`${(o.maxSpread*100).toFixed(1)}\xA2`,valueClassName:"text-green-400"}),jsx(li,{}),jsx(oo,{label:r("predict.matches.stats.platforms"),value:String(o.platformCount)})]})}function oo({label:e,value:t,valueClassName:r="text-slate-200"}){return jsxs("div",{className:"flex items-center gap-x-1.5",children:[jsxs("span",{className:"text-neutral-500",children:[e,":"]}),jsx("span",{className:`font-semibold ${r}`,children:t})]})}function li(){return jsx("span",{className:"hidden text-neutral-700 sm:inline",children:"|"})}function El(e){return `${(e*100).toFixed(1)}\xA2`}function X0(e){return e>=.05?"text-green-400":e>=.02?"text-yellow-400":"text-neutral-400"}function _S({spread:e,arbProfit:t,className:r}){if(e==null)return null;let o=t!=null&&t>0;return jsxs("div",{className:cn$1("flex items-center gap-x-2",r),children:[jsx("span",{className:cn$1("text-sm font-semibold",X0(e)),children:El(e)}),o&&jsxs("span",{className:"text-xs text-green-500/80",children:["+",El(t)]})]})}var cn=10,nh=64,_l=40,io=48;function Il({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:o}=useTranslation(),[n,i]=useState(1),{data:s,isLoading:a,fetchNextPage:l,hasNextPage:u,isFetchingNextPage:d}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:50}),{data:p,isLoading:m,fetchNextPage:c,hasNextPage:f,isFetchingNextPage:g}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:50}),v=a||m,x=d||g,b=u||f,w=useMemo(()=>{let O=[];return s?.pages&&O.push(...s.pages.flatMap(G=>G.items)),p?.pages&&O.push(...p.pages.flatMap(G=>G.items)),O.sort((G,j)=>(j.timestamp??0)-(G.timestamp??0)),O},[s,p]),S=Math.max(1,Math.ceil(w.length/cn)+(b?1:0)),h=(n-1)*cn,y=w.slice(h,h+cn),k=useCallback(()=>{i(O=>Math.max(1,O-1));},[]),P=useCallback(async()=>{n*cn>=w.length&&b&&(u&&await l(),f&&await c()),i(G=>G+1);},[n,w.length,b,u,f,l,c]),I=n>1,D=n*cn<w.length||b;if(v)return jsx(ch,{height:r});if(w.length===0&&!b)return jsx(lh,{message:o("predict.profile.noHistory"),height:r});let W=r-_l-io;return jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxs("div",{className:"hidden lg:flex items-center text-neutral text-xs font-normal shrink-0 border-b border-border/50",style:{height:_l},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:o("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.profile.action")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.profile.status")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.price")}),jsx("div",{className:"flex-[1.5] pr-2 text-right",children:o("predict.profile.depositWithdraw")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.pnl")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.fee")}),jsx("div",{className:"w-10 shrink-0"})]}),jsxs("div",{className:"hidden lg:block overflow-y-auto",style:{height:W},children:[y.map((O,G)=>jsx(oh,{trade:O},O.id??`${h+G}`)),x&&jsx("div",{className:"flex justify-center items-center py-4",children:jsx(Spinner,{size:"sm"})})]}),jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:io},children:[jsxs("button",{type:"button",disabled:!I,onClick:k,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",I?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",o("predict.profile.previous")]}),Array.from({length:Math.min(S,5)},(O,G)=>{let j=G+1;return jsx("button",{type:"button",onClick:()=>i(j),className:cn$1("w-8 h-8 rounded text-sm transition-colors cursor-pointer",j===n?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:j},j)}),jsxs("button",{type:"button",disabled:!D,onClick:P,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",D?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[o("predict.profile.next")," \u2192"]})]}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-io},children:y.map((O,G)=>jsx(ih,{trade:O},O.id??`m-${h+G}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:io},children:[jsx("button",{type:"button",disabled:!I,onClick:k,className:cn$1("text-sm cursor-pointer",I?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:n}),jsx("button",{type:"button",disabled:!D,onClick:P,className:cn$1("text-sm cursor-pointer",D?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function oh({trade:e}){let{t}=useTranslation(),r=e.type==="REDEEM",o=e.side?.toUpperCase()==="BUY",n=e.price??0,i=e.usd_size??0,s=Ol(e.type,t),a=r||o,l=a?"+":"-",u=a?"text-success":"text-foreground",d=e.event?.title??e.market?.question??"\u2014",p=e.event?.image_url,m=e.outcome??"",c=Bl(e.timestamp),f=Al(e),g=sh(e),v=ah(e);return jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:nh},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[p&&jsx("img",{src:p,alt:"",className:"w-8 h-8 rounded-full object-cover shrink-0"}),jsxs("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:[jsx("span",{className:"text-foreground truncate font-medium text-sm",children:d}),jsxs("span",{className:"text-[11px] text-neutral",children:[m&&jsx("span",{className:"mr-1",children:m}),jsx("span",{children:c})]})]})]})}),jsx("div",{className:"flex-1 pr-2",children:jsx("span",{className:cn$1("text-sm font-medium",r?"text-primary":o?"text-success":"text-danger"),children:t(r?"predict.profile.redeem":o?"predict.profile.buy":"predict.profile.sell")})}),jsx("div",{className:"flex-1 pr-2 text-sm text-foreground",children:s}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Fl(n)}),jsx("div",{className:cn$1("flex-[1.5] pr-2 text-right font-mono",u),children:i>0?jsxs(Fragment,{children:[l,"$",i.toFixed(2)]}):"\u2014"}),jsx("div",{className:cn$1("flex-1 pr-2 text-right font-mono",g!==null?g>=0?"text-success":"text-danger":"text-neutral"),children:g!==null?`${g>=0?"+":"-"}$${Math.abs(g).toFixed(2)}`:"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-neutral",children:v!==null?`$${v.toFixed(2)}`:"\u2014"}),jsx("div",{className:"w-10 shrink-0 text-right",children:f&&jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"text-neutral hover:text-foreground transition-colors","aria-label":"View transaction",children:jsx(Dl,{})})})]})}function ih({trade:e}){let{t}=useTranslation(),r=e.type==="REDEEM",o=e.side?.toUpperCase()==="BUY",n=e.price??0,i=e.usd_size??0,s=Ol(e.type,t),a=e.event?.title??e.market?.question??"\u2014",l=Bl(e.timestamp),u=Al(e);return jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.event?.image_url&&jsx("img",{src:e.event.image_url,alt:"",className:"w-6 h-6 rounded-full object-cover shrink-0"}),jsx("span",{className:"text-sm font-medium text-foreground line-clamp-2",children:a})]}),jsx("span",{className:"text-[11px] text-neutral whitespace-nowrap",children:l})]}),jsxs("div",{className:"flex items-center gap-4 text-xs flex-wrap",children:[jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.action")}),jsx("span",{className:cn$1("font-medium",r?"text-primary":o?"text-success":"text-danger"),children:t(r?"predict.profile.redeem":o?"predict.profile.buy":"predict.profile.sell")})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.status")}),jsx("span",{className:"text-foreground",children:s})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.price")}),jsx("span",{className:"font-mono text-foreground",children:Fl(n)})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.depositWithdraw")}),jsx("span",{className:"font-mono text-foreground",children:i>0?`$${i.toFixed(2)}`:"\u2014"})]}),u&&jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"ml-auto text-neutral hover:text-foreground transition-colors",children:jsx(Dl,{})})]})]})}function Ol(e,t){switch(e){case "TRADE":return t("predict.profile.filled");case "REDEEM":return t("predict.profile.claimed");case "SPLIT":case "MERGE":case "CONVERSION":return t("predict.profile.created");default:return e}}function Al(e){if(e.tx_hash)return e.source==="polymarket"?`https://polygonscan.com/tx/${e.tx_hash}`:`https://solscan.io/tx/${e.tx_hash}`}function sh(e){let t=e.provider_meta;if(t){let r=t.pnl??t.profit??t.realized_pnl??t["dflow.pnl"];if(typeof r=="number")return r;if(typeof r=="string"&&r!==""){let o=parseFloat(r);if(!Number.isNaN(o))return o}}return e.type==="REDEEM"&&e.usd_size!=null?e.usd_size:null}function ah(e){let t=e.provider_meta;if(t){let r=t.fee??t.fees??t.trading_fee??t["dflow.fee"];if(typeof r=="number")return r;if(typeof r=="string"&&r!==""){let o=parseFloat(r);if(!Number.isNaN(o))return o}}return null}function Dl(){return jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),jsx("polyline",{points:"15 3 21 3 21 9"}),jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})}function lh({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function ch({height:e}){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:e},children:Array.from({length:6}).map((t,r)=>jsx(Skeleton,{className:"h-12 w-full rounded-md"},r))})}function Fl(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function Bl(e){let t=new Date(e*1e3),r=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0"),n=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getFullYear(),a=t.getTimezoneOffset(),l=a<=0?"+":"-",u=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${o} ${n}/${i}/${s} (${l}${u})`}var dn=10,hh=64,zl=40,so=48;function Ul({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:o}=useTranslation(),n=useCancelOrder(),[i,s]=useState(1),{data:a,isLoading:l,fetchNextPage:u,hasNextPage:d,isFetchingNextPage:p}=useInfiniteOrders({source:"kalshi",wallet_address:e??""}),{data:m,isLoading:c,fetchNextPage:f,hasNextPage:g,isFetchingNextPage:v}=useInfiniteOrders({source:"polymarket",wallet_address:t??""}),x=l||c,b=p||v,w=d||g,S=useMemo(()=>{let j=[],Q=new Set(["live","open","submitted","pending"]);return a?.pages&&j.push(...a.pages.flatMap(re=>re.items).filter(re=>Q.has(re.status))),m?.pages&&j.push(...m.pages.flatMap(re=>re.items).filter(re=>Q.has(re.status))),j},[a,m]),h=useCallback(j=>{n.mutate({source:j.source,id:j.id});},[n]),y=Math.max(1,Math.ceil(S.length/dn)+(w?1:0)),k=(i-1)*dn,P=S.slice(k,k+dn),I=useCallback(()=>{s(j=>Math.max(1,j-1));},[]),D=useCallback(async()=>{i*dn>=S.length&&w&&(d&&await u(),g&&await f()),s(Q=>Q+1);},[i,S.length,w,d,g,u,f]),W=i>1,O=i*dn<S.length||w;if(x)return jsx(yh,{height:r});if(S.length===0&&!w)return jsx(bh,{message:o("predict.profile.noOrders"),height:r});let G=r-zl-so;return jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxs("div",{className:"hidden lg:flex items-center text-neutral text-xs font-normal shrink-0 border-b border-border/50",style:{height:zl},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:o("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.profile.action")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.profile.type")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.fillPrice")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.cost")})]}),jsxs("div",{className:"hidden lg:block overflow-y-auto",style:{height:G},children:[P.map(j=>jsx(vh,{order:j,onCancel:h},j.id)),b&&jsx("div",{className:"flex justify-center items-center py-4",children:jsx(Spinner,{size:"sm"})})]}),jsx(Wl,{className:"hidden lg:flex",currentPage:i,totalPages:y,canGoPrev:W,canGoNext:O,onPrev:I,onNext:D,onPage:s,t:o}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-so},children:P.map(j=>jsx(xh,{order:j,onCancel:h},j.id))}),jsx(Wl,{className:"lg:hidden",currentPage:i,totalPages:y,canGoPrev:W,canGoNext:O,onPrev:I,onNext:D,onPage:s,t:o,compact:true})]})}function vh({order:e,onCancel:t}){let{t:r}=useTranslation(),o=e.side==="BUY",n=e.price?parseFloat(e.price):0,i=e.in_amount?parseFloat(e.in_amount):n*parseFloat(e.original_size??"0");return jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:hh},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsx("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:jsx("span",{className:"text-foreground truncate font-medium",children:e.outcome??e.market_id??"\u2014"})})}),jsx("div",{className:"flex-1 pr-2",children:jsx("span",{className:cn$1("text-sm font-medium",o?"text-success":"text-danger"),children:r(o?"predict.profile.buy":"predict.profile.sell")})}),jsx("div",{className:"flex-1 pr-2 text-neutral capitalize text-sm",children:e.order_type??"limit"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:n>0?$l(n):"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:i>0?`$${i.toFixed(2)}`:"\u2014"})]})}function xh({order:e,onCancel:t}){let{t:r}=useTranslation(),o=e.side==="BUY",n=e.price?parseFloat(e.price):0;return jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:cn$1("text-xs font-medium px-1.5 py-0.5 rounded",o?"bg-success/10 text-success":"bg-danger/10 text-danger"),children:e.side}),jsx("span",{className:"text-sm text-foreground capitalize",children:e.outcome??"\u2014"})]}),jsx("span",{className:"text-xs text-neutral capitalize",children:e.order_type??"limit"})]}),jsxs("div",{className:"flex items-center gap-4 text-xs",children:[jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:r("predict.profile.fillPrice")}),jsx("span",{className:"font-mono text-foreground",children:n>0?$l(n):"\u2014"})]}),jsx("div",{className:"flex-1"}),jsx("button",{type:"button",onClick:()=>t(e),className:"text-xs text-danger hover:text-danger/80 cursor-pointer border border-border rounded px-2 py-1",children:r("predict.orders.cancel")})]})]})}function Wl({className:e,currentPage:t,totalPages:r,canGoPrev:o,canGoNext:n,onPrev:i,onNext:s,onPage:a,t:l,compact:u}){return u?jsxs("div",{className:cn$1("flex items-center justify-center gap-3 shrink-0",e),style:{height:so},children:[jsx("button",{type:"button",disabled:!o,onClick:i,className:cn$1("text-sm cursor-pointer",o?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:t}),jsx("button",{type:"button",disabled:!n,onClick:s,className:cn$1("text-sm cursor-pointer",n?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]}):jsxs("div",{className:cn$1("flex items-center justify-center gap-2 shrink-0",e),style:{height:so},children:[jsxs("button",{type:"button",disabled:!o,onClick:i,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",o?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",l("predict.profile.previous")]}),Array.from({length:Math.min(r,5)},(d,p)=>{let m=p+1;return jsx("button",{type:"button",onClick:()=>a(m),className:cn$1("w-8 h-8 rounded text-sm transition-colors cursor-pointer",m===t?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:m},m)}),jsxs("button",{type:"button",disabled:!n,onClick:s,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",n?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[l("predict.profile.next")," \u2192"]})]})}function bh({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function yh({height:e}){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:e},children:Array.from({length:6}).map((t,r)=>jsx(Skeleton,{className:"h-12 w-full rounded-md"},r))})}function $l(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}var mi=10,Ph=64,Kl=40,ao=48;function Vl({positions:e,isLoading:t,listHeight:r,onClosePosition:o,onEventClick:n}){let{t:i}=useTranslation(),[s,a]=useState(1),l=useCallback(()=>{for(let g of e)o?.(g);},[e,o]);if(t)return jsx(Eh,{height:r});if(e.length===0)return jsx(Mh,{message:i("predict.profile.noPositions"),height:r});let u=Math.max(1,Math.ceil(e.length/mi)),d=(s-1)*mi,p=e.slice(d,d+mi),m=s>1,c=s<u,f=r-Kl-ao;return jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxs("div",{className:"hidden lg:flex items-center text-neutral text-xs font-normal shrink-0 border-b border-border/50",style:{height:Kl},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:i("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.totalSize")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.value")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.avgPrice")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.markPrice")}),jsxs("div",{className:"flex-[1.5] pr-2 text-right",children:[jsx("span",{children:i("predict.profile.pnl")}),jsxs("span",{className:"text-[10px] ml-1 opacity-60",children:["(",i("predict.profile.pnlExcludeFees"),")"]})]}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.payoutIfRight")}),jsx("div",{className:"flex-[1.5] pr-2 text-right",children:i("predict.profile.estSettlement")}),jsx("div",{className:"w-20 shrink-0 text-right",children:o&&e.length>0&&jsx("button",{type:"button",onClick:l,className:"text-xs text-primary hover:text-primary/80 cursor-pointer transition-colors",children:i("predict.profile.closeAll")})})]}),jsx("div",{className:"hidden lg:block overflow-y-auto",style:{height:f},children:p.map((g,v)=>jsx(Nh,{position:g,onClosePosition:o,onEventClick:n},`${g.source}-${g.market?.slug??d+v}`))}),jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:ao},children:[jsxs("button",{type:"button",disabled:!m,onClick:()=>a(g=>Math.max(1,g-1)),className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",m?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",i("predict.profile.previous")]}),Array.from({length:Math.min(u,5)},(g,v)=>{let x=v+1;return jsx("button",{type:"button",onClick:()=>a(x),className:cn$1("w-8 h-8 rounded text-sm transition-colors cursor-pointer",x===s?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:x},x)}),jsxs("button",{type:"button",disabled:!c,onClick:()=>a(g=>g+1),className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",c?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[i("predict.profile.next")," \u2192"]})]}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-ao},children:p.map((g,v)=>jsx(Ch,{position:g,onClose:o,onEventClick:n},`${g.source}-${g.market?.slug??`m-${d+v}`}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:ao},children:[jsx("button",{type:"button",disabled:!m,onClick:()=>a(g=>Math.max(1,g-1)),className:cn$1("text-sm cursor-pointer",m?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:s}),jsx("button",{type:"button",disabled:!c,onClick:()=>a(g=>g+1),className:cn$1("text-sm cursor-pointer",c?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function Nh({position:e,onClosePosition:t,onEventClick:r}){let{t:o}=useTranslation(),n=e.pnl??0,i=e.pnl_percent??0,s=e.avg_price??0,a=e.current_price??0,l=e.current_value??e.size*a,u=e.size,d=n>0?"text-success":n<0?"text-danger":"text-foreground",p=n>0?"+":"",m=e.event?.title??e.market?.question??"\u2014",c=e.event?.image_url,f=e.side,g=e.market?.outcomes?.[0]?.label??"",v=e.market?.end_at?Th(e.market.end_at):"\u2014";return jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:Ph},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxs("button",{type:"button",className:"flex items-center gap-2.5 min-w-0 cursor-pointer text-left",onClick:()=>e.event&&r?.(e.event),children:[c&&jsx("img",{src:c,alt:"",className:"w-8 h-8 rounded-full object-cover shrink-0"}),jsxs("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:[jsx("span",{className:"text-foreground truncate font-medium text-sm",children:m}),jsxs("span",{className:"text-[11px] text-neutral",children:[jsx("span",{className:cn$1("font-medium",f.toLowerCase()==="yes"?"text-success":"text-danger"),children:f}),g&&jsxs(Fragment,{children:[jsx("span",{className:"mx-1",children:"\xB7"}),jsx("span",{children:g})]})]})]})]})}),jsx("div",{className:"flex-1 pr-2 text-right",children:jsxs("div",{className:"flex flex-col items-end",children:[jsxs("span",{className:"font-mono text-foreground",children:["$",l.toFixed(2)]}),jsx("span",{className:"text-[10px] text-neutral",children:o("predict.profile.contracts",{count:Kr(e.size)})})]})}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",(e.size*s).toFixed(2)]}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:fi(s)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:fi(a)}),jsxs("div",{className:cn$1("flex-[1.5] pr-2 text-right font-mono",d),children:[jsxs("span",{children:[p,"$",Math.abs(n).toFixed(2)]}),jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",p,i.toFixed(2),"%)"]})]}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",u.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap text-xs",children:v}),jsx("div",{className:"w-20 shrink-0 text-right",children:t&&jsxs("button",{type:"button",onClick:()=>t(e),className:"inline-flex items-center gap-1 text-xs text-neutral hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{className:"text-danger",children:"\u2715"}),o("predict.profile.close")]})})]})}function Ch({position:e,onClose:t,onEventClick:r}){let{t:o}=useTranslation(),n=e.pnl??0,i=e.pnl_percent??0,s=e.current_price??0,a=n>0?"text-success":n<0?"text-danger":"text-foreground",l=n>0?"+":"",u=e.event?.title??e.market?.question??"\u2014";return jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxs("button",{type:"button",className:"flex items-start justify-between gap-2 text-left cursor-pointer",onClick:()=>e.event&&r?.(e.event),children:[jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.event?.image_url&&jsx("img",{src:e.event.image_url,alt:"",className:"w-7 h-7 rounded-full object-cover shrink-0"}),jsx("span",{className:"text-sm font-medium text-foreground line-clamp-2",children:u})]}),jsx("span",{className:cn$1("shrink-0 text-xs font-medium px-1.5 py-0.5 rounded",e.side.toLowerCase()==="yes"?"bg-success/10 text-success":"bg-danger/10 text-danger"),children:e.side})]}),jsxs("div",{className:"flex items-center gap-4 text-xs flex-wrap",children:[jsx(lo,{label:o("predict.profile.totalSize"),value:Kr(e.size)}),jsx(lo,{label:o("predict.profile.markPrice"),value:fi(s)}),jsx(lo,{label:o("predict.profile.pnl"),value:`${l}$${Math.abs(n).toFixed(2)} (${l}${i.toFixed(1)}%)`,className:a}),jsx(lo,{label:o("predict.profile.payoutIfRight"),value:`$${e.size.toFixed(2)}`})]}),t&&jsx("div",{className:"flex justify-end",children:jsx("button",{type:"button",onClick:()=>t(e),className:"text-xs text-danger hover:text-danger/80 cursor-pointer transition-colors border border-border rounded px-2 py-1",children:o("predict.profile.close")})})]})}function lo({label:e,value:t,className:r}){return jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:e}),jsx("span",{className:cn$1("font-mono text-foreground",r),children:t})]})}function Mh({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function Eh({height:e}){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:e},children:Array.from({length:6}).map((t,r)=>jsx(Skeleton,{className:"h-12 w-full rounded-md"},r))})}function fi(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function Th(e){try{let t=new Date(e),r=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0"),n=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getFullYear(),a=t.getTimezoneOffset(),l=a<=0?"+":"-",u=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${o} ${n}/${i}/${s} (${l}${u})`}catch{return "\u2014"}}function ql({positions:e,trades:t,isLoading:r}){let{t:o}=useTranslation(),n=useMemo(()=>{let a=0,l=0;for(let c of e)a+=c.realized_pnl??0,l+=c.current_value??c.size*(c.current_price??0);let u=0,d=0,p=0;for(let c of t)u+=c.usd_size??0,c.type==="REDEEM"&&(p++,(c.usd_size??0)>0&&d++);let m=p>0?`${d} / ${p}`:"0 / 0";return {realizedPnl:a,positionsValue:l,volume:u,winRateStr:m}},[e,t]),i=n.realizedPnl>0?"text-success":n.realizedPnl<0?"text-danger":"text-foreground",s=n.realizedPnl>0?"+":"";return jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 py-8",children:[jsxs("div",{className:"flex flex-col gap-1",children:[jsx("span",{className:"text-xl text-neutral",children:o("predict.profile.realizedPnl")}),r?jsx(Skeleton,{className:"h-14 w-48 rounded-md"}):jsxs("span",{className:cn$1("text-5xl font-bold tabular-nums",i),children:[s,"$",Math.abs(n.realizedPnl).toFixed(2)]})]}),jsxs("div",{className:"flex items-end gap-8 sm:gap-10",children:[jsx(hi,{label:o("predict.profile.winRate"),value:n.winRateStr,isLoading:r}),jsx(hi,{label:o("predict.profile.positions"),value:`$${n.positionsValue.toFixed(2)}`,isLoading:r}),jsx(hi,{label:o("predict.profile.volume"),value:`$${n.volume.toFixed(2)}`,isLoading:r})]})]})}function hi({label:e,value:t,isLoading:r}){return jsxs("div",{className:"flex flex-col items-end gap-0.5",children:[jsx("span",{className:"text-sm text-neutral whitespace-nowrap",children:e}),r?jsx(Skeleton,{className:"h-6 w-14 rounded-md"}):jsx("span",{className:"text-base font-semibold tabular-nums text-foreground",children:t})]})}var vi=600;function Fh({solanaAddress:e,evmAddress:t,onClosePosition:r,onEventClick:o}){let{t:n}=useTranslation(),[i,s]=useState("positions"),a=!!(e||t),{data:l,isLoading:u}=usePositions({source:"kalshi",user:e??""}),{data:d,isLoading:p}=usePositions({source:"polymarket",user:t??""}),m=useMemo(()=>{let k=[];return l?.positions&&k.push(...l.positions),d?.positions&&k.push(...d.positions),k},[l,d]),c=u||p,{data:f,isLoading:g}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:100}),{data:v,isLoading:x}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:100}),b=useMemo(()=>[...f?.pages?.flatMap(P=>P.items)??[],...v?.pages?.flatMap(P=>P.items)??[]],[f,v]),w=c||g||x,S=m.length,y=[{key:"positions",label:S>0?`${n("predict.profile.positionsTab")} (${S})`:n("predict.profile.positionsTab")},{key:"orders",label:n("predict.profile.openOrdersTab")},{key:"history",label:n("predict.profile.historyTab")}];return a?jsxs("div",{className:"flex flex-col max-w-[1280px] mx-auto w-full px-4 max-sm:px-2",children:[jsx(ql,{positions:m,trades:b,isLoading:w}),jsx("div",{className:"flex items-center gap-1 border-b border-border",children:y.map(k=>jsx("button",{type:"button",onClick:()=>s(k.key),className:cn$1("px-3 py-3 text-base font-normal transition-colors cursor-pointer whitespace-nowrap",i===k.key?"text-foreground border-b-2 border-foreground":"text-neutral hover:text-foreground"),children:k.label},k.key))}),jsxs("div",{className:"py-2",children:[i==="positions"&&jsx(Vl,{positions:m,isLoading:c,listHeight:vi,onClosePosition:r,onEventClick:o}),i==="orders"&&jsx(Ul,{solanaAddress:e,evmAddress:t,listHeight:vi}),i==="history"&&jsx(Il,{solanaAddress:e,evmAddress:t,listHeight:vi})]})]}):jsx("div",{className:"flex items-center justify-center text-sm text-neutral py-24 px-4",children:n("predict.profile.connectWallet")})}function Tw({isOpen:e,onClose:t,safeDeployed:r,tokenApproved:o,onDeployAndApprove:n}){let{t:i}=useTranslation(),[s,a]=useState(false),[l,u]=useState(null),[d,p]=useState(false),m=r||d,c=o||d,f=m?"done":s?"running":"pending",g=c?"done":m&&s?"running":"pending",v=m&&c,x=useCallback(async()=>{u(null),p(false),a(true);try{await n(),p(!0);}catch(h){u(h instanceof Error?h.message:String(h));}finally{a(false);}},[n]),b=[{key:"step1",label:i("predict.setup.step1"),desc:i("predict.setup.step1Desc"),status:f},{key:"step2",label:i("predict.setup.step2"),desc:i("predict.setup.step2Desc"),status:g}],w=()=>{v?t():x();},S=i(v?"predict.setup.done":"predict.setup.setupButton");return jsx(StyledModal,{isOpen:e,onOpenChange:h=>{h||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:i("predict.setup.modalTitle")}),jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxs("div",{className:"px-5 pb-5 space-y-4",children:[jsx("p",{className:"text-[13px] text-zinc-400 text-left",children:i("predict.setup.modalDescription")}),jsx("div",{className:"space-y-2.5",children:b.map((h,y)=>jsxs("div",{className:"flex gap-3 rounded-[10px] border border-zinc-700/50 bg-zinc-800/50 px-3 py-3",children:[jsx(Uh,{index:y+1,status:h.status}),jsxs("div",{className:"flex-1 min-w-0 pt-0.5",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("p",{className:"text-sm font-medium text-zinc-200",children:h.label}),jsx("span",{className:`text-[11px] leading-none ${h.status==="done"?"text-[#c7ff2e]":h.status==="running"?"text-[#c7ff2e]/70":"text-zinc-500"}`,children:h.status==="done"?i("predict.setup.stepComplete"):h.status==="running"?i("predict.setup.stepRunning"):i("predict.setup.stepPending")})]}),jsx("p",{className:"text-xs text-zinc-500 mt-1",children:h.desc})]})]},h.key))}),l&&jsx("div",{className:"rounded-[10px] bg-red-500/10 border border-red-500/20 px-3 py-2",children:jsx("p",{className:"text-xs text-red-400",children:l})}),jsx("button",{type:"button",onClick:w,disabled:s,className:v?"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus":"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:s?jsxs("span",{className:"inline-flex items-center gap-2",children:[jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",children:[jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",className:"opacity-25"}),jsx("path",{d:"M4 12a8 8 0 018-8",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",className:"opacity-75"})]}),i("predict.setup.stepRunning")]}):S}),!v&&jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] text-sm text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:i("common.cancel")})]})]})})})}function Uh({index:e,status:t}){return t==="done"?jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-[#c7ff2e]/15 shrink-0",children:jsx("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#c7ff2e]",children:jsx("polyline",{points:"20 6 9 17 4 12"})})}):t==="running"?jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-[#c7ff2e]/10 shrink-0",children:jsxs("svg",{className:"animate-spin h-4 w-4 text-[#c7ff2e]",viewBox:"0 0 24 24",fill:"none",children:[jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",className:"opacity-25"}),jsx("path",{d:"M4 12a8 8 0 018-8",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",className:"opacity-75"})]})}):jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-zinc-700/50 text-xs font-bold text-zinc-400 shrink-0",children:e})}
|
|
136
|
-
export{
|
|
135
|
+
`}),jsxs("div",{style:{position:"relative",overflow:"hidden",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:0,overflow:"hidden"},children:[l&&jsx("img",{src:l,alt:"","aria-hidden":"true",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",objectPosition:"center center",opacity:.3,mixBlendMode:"lighten",maskImage:"linear-gradient(to bottom, black 50%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 50%, transparent 100%)"}}),jsx("div",{style:{position:"absolute",inset:0,opacity:.025,backgroundImage:"radial-gradient(circle at 1px 1px, rgb(255 255 255) 1px, transparent 0)",backgroundSize:"20px 20px"}})]}),jsx("style",{children:".matches-hero-wrap{padding:40px 16px 32px}@media(min-width:640px){.matches-hero-wrap{padding:48px 24px 40px}}@media(min-width:1024px){.matches-hero-wrap{padding:52px 32px 44px}}"}),jsx("div",{className:"match-fade-in matches-hero-wrap",style:{position:"relative",zIndex:2,maxWidth:1152,margin:"0 auto"},children:jsx(fl,{stats:v})})]}),jsxs("div",{style:{position:"sticky",top:0,zIndex:40,background:"rgba(10,10,11,0.8)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsx("style",{children:".matches-toolbar-inner{padding:12px 16px}@media(min-width:640px){.matches-toolbar-inner{padding:12px 24px}}@media(min-width:1024px){.matches-toolbar-inner{padding:12px 32px}}"}),jsxs("div",{className:"matches-toolbar-inner",style:{maxWidth:1152,margin:"0 auto",display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,minWidth:0},children:[jsx("div",{className:"hidden sm:flex",style:{alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:10,background:"linear-gradient(to bottom right, rgba(199,255,46,0.15), rgba(23,201,100,0.15))",border:"1px solid rgba(199,255,46,0.15)",flexShrink:0},children:jsxs("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"}),jsx("path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"}),jsx("path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"})]})}),jsxs("div",{style:{minWidth:0},children:[jsx("h2",{style:{fontSize:14,fontWeight:600,color:"#fff",margin:0,letterSpacing:"-0.28px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u(U0[d])}),v&&v.activePairs>0&&jsx("p",{className:"hidden sm:block",style:{fontSize:11,color:"#71717a",margin:0},children:u("predict.matches.pairsFound",{count:v.activePairs})})]})]}),jsx(pl,{sortBy:d,onSortChange:w,sortAsc:m,onSortAscChange:S,minVolume:f,onMinVolumeChange:g,onRefresh:y})]})]}),jsx("style",{children:".matches-content-wrap{padding:24px 16px 80px}@media(min-width:640px){.matches-content-wrap{padding:32px 24px 80px}}@media(min-width:1024px){.matches-content-wrap{padding:24px 32px 80px}}"}),jsxs("div",{className:"match-fade-in-d2 matches-content-wrap",style:{position:"relative",maxWidth:1152,margin:"0 auto"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:16,padding:"8px 12px",borderRadius:8,border:"1px solid rgba(39,39,42,0.4)",background:"rgba(24,24,27,0.25)"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#52525b",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"})}),jsxs("p",{style:{fontSize:11,color:"#52525b",lineHeight:1.5,margin:0},children:[jsx("span",{style:{color:"#71717a",fontWeight:500},children:u("predict.matches.experimentalFeature")})," \u2014 ",u("predict.matches.disclaimer")]})]}),jsx(Pl,{ref:b,sortBy:d,sortAsc:m,minVolume:f,onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:o,onHover:n,onSelect:i,getMarketHref:s,LinkComponent:a,onStatsChange:h})]}),jsx(K0,{stats:v})]})}function ai(e){return e==null?"-":formatAmountInUsd(e)}var q0={polymarket:{text:"#50a2ff",border:"rgba(43,127,255,0.15)",hoverBorder:"rgba(43,127,255,0.3)",bg:"rgba(43,127,255,0.05)",priceColor:"rgba(244,244,245,1)",priceActiveColor:"rgba(244,244,245,1)"},kalshi:{text:"#00d492",border:"rgba(0,212,146,0.15)",hoverBorder:"rgba(0,212,146,0.3)",bg:"rgba(0,212,146,0.05)",priceColor:"#00d492",priceActiveColor:"#00d492"}},G0={text:"#9ca3af",border:"rgba(156,163,175,0.15)",hoverBorder:"rgba(156,163,175,0.3)",bg:"rgba(156,163,175,0.05)",priceColor:"rgba(244,244,245,1)",priceActiveColor:"rgba(244,244,245,1)"};function Y0(e){return q0[e]??G0}function Q0(e){if(!e.matched_markets?.length)return null;let t=null,r=-1;for(let o of e.matched_markets){let n=o.spread??0;n>r&&(r=n,t=o);}return t}function X0(e,t){let r=e.entries.find(a=>a.source===(t?.source_a??e.entries[0]?.source)),o=e.entries.find(a=>a.source===(t?.source_b??e.entries[1]?.source)),n=a=>{if(!a?.outcomes?.[0])return {name:null,price:null};let l=a.outcomes[0];return {name:l.label||null,price:l.best_ask??l.price??null}},i=n(t?.market_a),s=n(t?.market_b);return [{source:t?.source_a??r?.source??"unknown",outcomeName:i.name,yesPrice:i.price,volume:r?.event?.volume??null,event:r?.event},{source:t?.source_b??o?.source??"unknown",outcomeName:s.name,yesPrice:s.price,volume:o?.event?.volume??null,event:o?.event}]}function CS({group:e,onSelectEntry:t,getEventHref:r,LinkComponent:o}){let {t:n}=useTranslation(),i=useMemo(()=>Q0(e),[e]),s=e.max_spread!=null?e.max_spread*100:null,[a,l]=useMemo(()=>X0(e,i),[e,i]),u=s!=null&&s>=3;a.yesPrice!=null&&l.yesPrice!=null?a.source==="kalshi"?a.yesPrice>l.yesPrice:l.yesPrice>a.yesPrice:false;let p=a.yesPrice!=null&&l.yesPrice!=null?a.yesPrice<=l.yesPrice?a:l:null,m=p?Dt(p.source):null,c=u?"amber":"violet";return jsxs("div",{className:"group",style:{borderRadius:16,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",position:"relative"},onMouseEnter:f=>{let g=f.currentTarget;g.style.borderColor="rgba(63,63,70,0.6)",g.style.boxShadow="0 10px 15px -3px rgba(0,0,0,0.2)";},onMouseLeave:f=>{let g=f.currentTarget;g.style.borderColor="rgba(39,39,42,0.6)",g.style.boxShadow="none";},children:[s!=null&&jsxs("span",{style:{position:"absolute",top:12,right:12,zIndex:10,display:"inline-flex",alignItems:"center",gap:4,borderRadius:10,padding:"4px 10px",fontSize:12,fontWeight:600,border:`1px solid ${u?"rgba(255,185,0,0.3)":s>=2?"rgba(166,132,255,0.3)":"rgba(156,163,175,0.3)"}`,background:u?"rgba(255,185,0,0.15)":s>=2?"rgba(166,132,255,0.15)":"rgba(156,163,175,0.12)",color:u?"#ffb900":s>=2?"#a684ff":"#9ca3af"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),s.toFixed(1),"%"]}),jsxs("div",{style:{padding:16},children:[jsx("h3",{style:{fontSize:14,fontWeight:600,lineHeight:1.375,letterSpacing:"-0.28px",color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",paddingRight:80,margin:"0 0 16px"},children:e.title}),jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[jsx(Ml,{data:a,isCheaper:p===a,onSelect:t,getEventHref:r,LinkComponent:o}),jsx(Ml,{data:l,isCheaper:p===l,onSelect:t,getEventHref:r,LinkComponent:o})]}),p&&m&&s!=null&&jsxs("div",{style:{marginTop:12,padding:"8px 12px",borderRadius:10,display:"flex",alignItems:"center",gap:8,cursor:"pointer",transition:"all 0.15s",border:`1px solid ${c==="amber"?"rgba(255,185,0,0.15)":"rgba(166,132,255,0.15)"}`,background:c==="amber"?"rgba(255,185,0,0.05)":"rgba(166,132,255,0.05)"},onClick:()=>p.event&&t?.(p.event),children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,flexShrink:0,color:c==="amber"?"#ffb900":"#a684ff"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),jsx("span",{style:{fontSize:11,fontWeight:500,color:c==="amber"?"rgba(255,185,0,0.9)":"rgba(166,132,255,0.9)"},children:n("predict.matches.buyEdge",{platform:p.source.charAt(0).toUpperCase()+p.source.slice(1),spread:s.toFixed(1)})}),jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,marginLeft:"auto",color:c==="amber"?"rgba(255,185,0,0.5)":"rgba(166,132,255,0.5)"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M5 12h14"}),jsx("path",{d:"m12 5 7 7-7 7"})]})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.2)",padding:"10px 16px"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,fontSize:10,color:"#71717a"},children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}),ai(e.combined_volume)]}),e.combined_volume_24h!=null&&e.combined_volume_24h>0&&jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z"})}),ai(e.combined_volume_24h)," ",n("predict.matches.vol24h")]})]}),e.confidence!=null&&jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,fontSize:10,color:"#52525b"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"})}),Math.round(e.confidence*100),"%"," ",n("predict.matches.match")]})]})]})}function Ml({data:e,isCheaper:t,onSelect:r,getEventHref:o,LinkComponent:n}){let{t:i}=useTranslation(),s=Dt(e.source),a=Y0(e.source),l=e.event?o?.(e.event):void 0,u=jsxs("div",{style:{borderRadius:14,border:`1px solid ${a.border}`,background:a.bg,padding:12,cursor:l||r?"pointer":void 0,transition:"border-color 0.15s"},onMouseEnter:d=>{d.currentTarget.style.borderColor=a.hoverBorder;},onMouseLeave:d=>{d.currentTarget.style.borderColor=a.border;},onClick:()=>e.event&&r?.(e.event),children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[s.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.05em",color:a.text,textTransform:"uppercase"},children:s.label}),jsxs("svg",{viewBox:"0 0 24 24",className:"opacity-0 group-hover:opacity-100 transition-opacity",style:{width:10,height:10,color:"#52525b",marginLeft:"auto"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M7 7h10v10"}),jsx("path",{d:"M7 17 17 7"})]})]}),e.outcomeName&&jsx("div",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginBottom:8},children:e.outcomeName}),jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[jsx("span",{style:{fontSize:20,fontWeight:700,fontVariantNumeric:"tabular-nums",color:t?a.priceActiveColor:a.priceColor},children:e.yesPrice!=null?(e.yesPrice*100).toFixed(1):"-"}),jsx("span",{style:{fontSize:10,color:"#71717a"},children:i("predict.matches.centsYes")})]}),jsxs("div",{style:{fontSize:10,color:"#52525b",marginTop:6},children:[ai(e.volume)," ",i("predict.matches.volume")]})]});return l&&n?jsx(n,{href:l,className:"block",children:u}):u}function th(e){return formatAmountInUsd(e)}function _S({matches:e,total:t}){let{t:r}=useTranslation(),o=useMemo(()=>{let n=0,i=0,s=new Set;for(let a of e){a.max_spread!=null&&a.max_spread>n&&(n=a.max_spread),a.combined_volume!=null&&(i+=a.combined_volume);for(let l of a.entries)s.add(typeof l.source=="string"?l.source:"");}return {count:t??e.length,maxSpread:n,totalVolume:i,platformCount:s.size}},[e,t]);return jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 rounded-xl border border-border/60 bg-background/50 px-4 py-3 text-sm",children:[jsx(oo,{label:r("predict.matches.stats.matchedMarkets"),value:o.count.toLocaleString()}),jsx(li,{}),jsx(oo,{label:r("predict.matches.stats.totalVolume"),value:th(o.totalVolume)}),jsx(li,{}),jsx(oo,{label:r("predict.matches.stats.highestSpread"),value:`${(o.maxSpread*100).toFixed(1)}\xA2`,valueClassName:"text-green-400"}),jsx(li,{}),jsx(oo,{label:r("predict.matches.stats.platforms"),value:String(o.platformCount)})]})}function oo({label:e,value:t,valueClassName:r="text-slate-200"}){return jsxs("div",{className:"flex items-center gap-x-1.5",children:[jsxs("span",{className:"text-neutral-500",children:[e,":"]}),jsx("span",{className:`font-semibold ${r}`,children:t})]})}function li(){return jsx("span",{className:"hidden text-neutral-700 sm:inline",children:"|"})}function Ll(e){return `${(e*100).toFixed(1)}\xA2`}function rh(e){return e>=.05?"text-green-400":e>=.02?"text-yellow-400":"text-neutral-400"}function DS({spread:e,arbProfit:t,className:r}){if(e==null)return null;let o=t!=null&&t>0;return jsxs("div",{className:cn("flex items-center gap-x-2",r),children:[jsx("span",{className:cn("text-sm font-semibold",rh(e)),children:Ll(e)}),o&&jsxs("span",{className:"text-xs text-green-500/80",children:["+",Ll(t)]})]})}var mn=10,lh=64,Ol=40,io=48;function Al({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:o}=useTranslation(),[n,i]=useState(1),{data:s,isLoading:a,fetchNextPage:l,hasNextPage:u,isFetchingNextPage:d}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:50}),{data:p,isLoading:m,fetchNextPage:c,hasNextPage:f,isFetchingNextPage:g}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:50}),v=a||m,x=d||g,b=u||f,w=useMemo(()=>{let A=[];return s?.pages&&A.push(...s.pages.flatMap(G=>G.items)),p?.pages&&A.push(...p.pages.flatMap(G=>G.items)),A.sort((G,q)=>(q.timestamp??0)-(G.timestamp??0)),A},[s,p]),S=Math.max(1,Math.ceil(w.length/mn)+(b?1:0)),h=(n-1)*mn,y=w.slice(h,h+mn),k=useCallback(()=>{i(A=>Math.max(1,A-1));},[]),P=useCallback(async()=>{n*mn>=w.length&&b&&(u&&await l(),f&&await c()),i(G=>G+1);},[n,w.length,b,u,f,l,c]),O=n>1,F=n*mn<w.length||b;if(v)return jsx(fh,{height:r});if(w.length===0&&!b)return jsx(mh,{message:o("predict.profile.noHistory"),height:r});let W=r-Ol-io;return jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxs("div",{className:"hidden lg:flex items-center text-neutral text-xs font-normal shrink-0 border-b border-border/50",style:{height:Ol},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:o("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.profile.action")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.profile.status")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.price")}),jsx("div",{className:"flex-[1.5] pr-2 text-right",children:o("predict.profile.depositWithdraw")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.pnl")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.fee")}),jsx("div",{className:"w-10 shrink-0"})]}),jsxs("div",{className:"hidden lg:block overflow-y-auto",style:{height:W},children:[y.map((A,G)=>jsx(ch,{trade:A},A.id??`${h+G}`)),x&&jsx("div",{className:"flex justify-center items-center py-4",children:jsx(Spinner,{size:"sm"})})]}),jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:io},children:[jsxs("button",{type:"button",disabled:!O,onClick:k,className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",O?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",o("predict.profile.previous")]}),Array.from({length:Math.min(S,5)},(A,G)=>{let q=G+1;return jsx("button",{type:"button",onClick:()=>i(q),className:cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",q===n?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:q},q)}),jsxs("button",{type:"button",disabled:!F,onClick:P,className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",F?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[o("predict.profile.next")," \u2192"]})]}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-io},children:y.map((A,G)=>jsx(dh,{trade:A},A.id??`m-${h+G}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:io},children:[jsx("button",{type:"button",disabled:!O,onClick:k,className:cn("text-sm cursor-pointer",O?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:n}),jsx("button",{type:"button",disabled:!F,onClick:P,className:cn("text-sm cursor-pointer",F?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function ch({trade:e}){let{t}=useTranslation(),r=e.type==="REDEEM",o=e.side?.toUpperCase()==="BUY",n=e.price??0,i=e.usd_size??0,s=Dl(e.type,t),a=r||o,l=a?"+":"-",u=a?"text-success":"text-foreground",d=e.event?.title??e.market?.question??"\u2014",p=e.event?.image_url,m=e.outcome??"",c=zl(e.timestamp),f=Fl(e),g=uh(e),v=ph(e);return jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:lh},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[p&&jsx("img",{src:p,alt:"",className:"w-8 h-8 rounded-full object-cover shrink-0"}),jsxs("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:[jsx("span",{className:"text-foreground truncate font-medium text-sm",children:d}),jsxs("span",{className:"text-[11px] text-neutral",children:[m&&jsx("span",{className:"mr-1",children:m}),jsx("span",{children:c})]})]})]})}),jsx("div",{className:"flex-1 pr-2",children:jsx("span",{className:cn("text-sm font-medium",r?"text-primary":o?"text-success":"text-danger"),children:t(r?"predict.profile.redeem":o?"predict.profile.buy":"predict.profile.sell")})}),jsx("div",{className:"flex-1 pr-2 text-sm text-foreground",children:s}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Hl(n)}),jsx("div",{className:cn("flex-[1.5] pr-2 text-right font-mono",u),children:i>0?jsxs(Fragment,{children:[l,"$",i.toFixed(2)]}):"\u2014"}),jsx("div",{className:cn("flex-1 pr-2 text-right font-mono",g!==null?g>=0?"text-success":"text-danger":"text-neutral"),children:g!==null?`${g>=0?"+":"-"}$${Math.abs(g).toFixed(2)}`:"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-neutral",children:v!==null?`$${v.toFixed(2)}`:"\u2014"}),jsx("div",{className:"w-10 shrink-0 text-right",children:f&&jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"text-neutral hover:text-foreground transition-colors","aria-label":"View transaction",children:jsx(Bl,{})})})]})}function dh({trade:e}){let{t}=useTranslation(),r=e.type==="REDEEM",o=e.side?.toUpperCase()==="BUY",n=e.price??0,i=e.usd_size??0,s=Dl(e.type,t),a=e.event?.title??e.market?.question??"\u2014",l=zl(e.timestamp),u=Fl(e);return jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.event?.image_url&&jsx("img",{src:e.event.image_url,alt:"",className:"w-6 h-6 rounded-full object-cover shrink-0"}),jsx("span",{className:"text-sm font-medium text-foreground line-clamp-2",children:a})]}),jsx("span",{className:"text-[11px] text-neutral whitespace-nowrap",children:l})]}),jsxs("div",{className:"flex items-center gap-4 text-xs flex-wrap",children:[jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.action")}),jsx("span",{className:cn("font-medium",r?"text-primary":o?"text-success":"text-danger"),children:t(r?"predict.profile.redeem":o?"predict.profile.buy":"predict.profile.sell")})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.status")}),jsx("span",{className:"text-foreground",children:s})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.price")}),jsx("span",{className:"font-mono text-foreground",children:Hl(n)})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.depositWithdraw")}),jsx("span",{className:"font-mono text-foreground",children:i>0?`$${i.toFixed(2)}`:"\u2014"})]}),u&&jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"ml-auto text-neutral hover:text-foreground transition-colors",children:jsx(Bl,{})})]})]})}function Dl(e,t){switch(e){case "TRADE":return t("predict.profile.filled");case "REDEEM":return t("predict.profile.claimed");case "SPLIT":case "MERGE":case "CONVERSION":return t("predict.profile.created");default:return e}}function Fl(e){if(e.tx_hash)return e.source==="polymarket"?`https://polygonscan.com/tx/${e.tx_hash}`:`https://solscan.io/tx/${e.tx_hash}`}function uh(e){let t=e.provider_meta;if(t){let r=t.pnl??t.profit??t.realized_pnl??t["dflow.pnl"];if(typeof r=="number")return r;if(typeof r=="string"&&r!==""){let o=parseFloat(r);if(!Number.isNaN(o))return o}}return e.type==="REDEEM"&&e.usd_size!=null?e.usd_size:null}function ph(e){let t=e.provider_meta;if(t){let r=t.fee??t.fees??t.trading_fee??t["dflow.fee"];if(typeof r=="number")return r;if(typeof r=="string"&&r!==""){let o=parseFloat(r);if(!Number.isNaN(o))return o}}return null}function Bl(){return jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),jsx("polyline",{points:"15 3 21 3 21 9"}),jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})}function mh({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function fh({height:e}){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:e},children:Array.from({length:6}).map((t,r)=>jsx(Skeleton,{className:"h-12 w-full rounded-md"},r))})}function Hl(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function zl(e){let t=new Date(e*1e3),r=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0"),n=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getFullYear(),a=t.getTimezoneOffset(),l=a<=0?"+":"-",u=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${o} ${n}/${i}/${s} (${l}${u})`}var fn=10,kh=64,Ul=40,so=48;function Kl({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:o}=useTranslation(),n=useCancelOrder(),[i,s]=useState(1),{data:a,isLoading:l,fetchNextPage:u,hasNextPage:d,isFetchingNextPage:p}=useInfiniteOrders({source:"kalshi",wallet_address:e??""}),{data:m,isLoading:c,fetchNextPage:f,hasNextPage:g,isFetchingNextPage:v}=useInfiniteOrders({source:"polymarket",wallet_address:t??""}),x=l||c,b=p||v,w=d||g,S=useMemo(()=>{let q=[],Y=new Set(["live","open","submitted","pending"]);return a?.pages&&q.push(...a.pages.flatMap(re=>re.items).filter(re=>Y.has(re.status))),m?.pages&&q.push(...m.pages.flatMap(re=>re.items).filter(re=>Y.has(re.status))),q},[a,m]),h=useCallback(q=>{n.mutate({source:q.source,id:q.id});},[n]),y=Math.max(1,Math.ceil(S.length/fn)+(w?1:0)),k=(i-1)*fn,P=S.slice(k,k+fn),O=useCallback(()=>{s(q=>Math.max(1,q-1));},[]),F=useCallback(async()=>{i*fn>=S.length&&w&&(d&&await u(),g&&await f()),s(Y=>Y+1);},[i,S.length,w,d,g,u,f]),W=i>1,A=i*fn<S.length||w;if(x)return jsx(Nh,{height:r});if(S.length===0&&!w)return jsx(Ph,{message:o("predict.profile.noOrders"),height:r});let G=r-Ul-so;return jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxs("div",{className:"hidden lg:flex items-center text-neutral text-xs font-normal shrink-0 border-b border-border/50",style:{height:Ul},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:o("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.profile.action")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.profile.type")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.fillPrice")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.cost")})]}),jsxs("div",{className:"hidden lg:block overflow-y-auto",style:{height:G},children:[P.map(q=>jsx(Sh,{order:q,onCancel:h},q.id)),b&&jsx("div",{className:"flex justify-center items-center py-4",children:jsx(Spinner,{size:"sm"})})]}),jsx($l,{className:"hidden lg:flex",currentPage:i,totalPages:y,canGoPrev:W,canGoNext:A,onPrev:O,onNext:F,onPage:s,t:o}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-so},children:P.map(q=>jsx(wh,{order:q,onCancel:h},q.id))}),jsx($l,{className:"lg:hidden",currentPage:i,totalPages:y,canGoPrev:W,canGoNext:A,onPrev:O,onNext:F,onPage:s,t:o,compact:true})]})}function Sh({order:e,onCancel:t}){let{t:r}=useTranslation(),o=e.side==="BUY",n=e.price?parseFloat(e.price):0,i=e.in_amount?parseFloat(e.in_amount):n*parseFloat(e.original_size??"0");return jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:kh},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsx("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:jsx("span",{className:"text-foreground truncate font-medium",children:e.outcome??e.market_id??"\u2014"})})}),jsx("div",{className:"flex-1 pr-2",children:jsx("span",{className:cn("text-sm font-medium",o?"text-success":"text-danger"),children:r(o?"predict.profile.buy":"predict.profile.sell")})}),jsx("div",{className:"flex-1 pr-2 text-neutral capitalize text-sm",children:e.order_type??"limit"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:n>0?Vl(n):"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:i>0?`$${i.toFixed(2)}`:"\u2014"})]})}function wh({order:e,onCancel:t}){let{t:r}=useTranslation(),o=e.side==="BUY",n=e.price?parseFloat(e.price):0;return jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:cn("text-xs font-medium px-1.5 py-0.5 rounded",o?"bg-success/10 text-success":"bg-danger/10 text-danger"),children:e.side}),jsx("span",{className:"text-sm text-foreground capitalize",children:e.outcome??"\u2014"})]}),jsx("span",{className:"text-xs text-neutral capitalize",children:e.order_type??"limit"})]}),jsxs("div",{className:"flex items-center gap-4 text-xs",children:[jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:r("predict.profile.fillPrice")}),jsx("span",{className:"font-mono text-foreground",children:n>0?Vl(n):"\u2014"})]}),jsx("div",{className:"flex-1"}),jsx("button",{type:"button",onClick:()=>t(e),className:"text-xs text-danger hover:text-danger/80 cursor-pointer border border-border rounded px-2 py-1",children:r("predict.orders.cancel")})]})]})}function $l({className:e,currentPage:t,totalPages:r,canGoPrev:o,canGoNext:n,onPrev:i,onNext:s,onPage:a,t:l,compact:u}){return u?jsxs("div",{className:cn("flex items-center justify-center gap-3 shrink-0",e),style:{height:so},children:[jsx("button",{type:"button",disabled:!o,onClick:i,className:cn("text-sm cursor-pointer",o?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:t}),jsx("button",{type:"button",disabled:!n,onClick:s,className:cn("text-sm cursor-pointer",n?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]}):jsxs("div",{className:cn("flex items-center justify-center gap-2 shrink-0",e),style:{height:so},children:[jsxs("button",{type:"button",disabled:!o,onClick:i,className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",o?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",l("predict.profile.previous")]}),Array.from({length:Math.min(r,5)},(d,p)=>{let m=p+1;return jsx("button",{type:"button",onClick:()=>a(m),className:cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",m===t?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:m},m)}),jsxs("button",{type:"button",disabled:!n,onClick:s,className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",n?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[l("predict.profile.next")," \u2192"]})]})}function Ph({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function Nh({height:e}){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:e},children:Array.from({length:6}).map((t,r)=>jsx(Skeleton,{className:"h-12 w-full rounded-md"},r))})}function Vl(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}var mi=10,Th=64,jl=40,ao=48;function ql({positions:e,isLoading:t,listHeight:r,onClosePosition:o,onEventClick:n}){let{t:i}=useTranslation(),[s,a]=useState(1),l=useCallback(()=>{for(let g of e)o?.(g);},[e,o]);if(t)return jsx(Ih,{height:r});if(e.length===0)return jsx(_h,{message:i("predict.profile.noPositions"),height:r});let u=Math.max(1,Math.ceil(e.length/mi)),d=(s-1)*mi,p=e.slice(d,d+mi),m=s>1,c=s<u,f=r-jl-ao;return jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxs("div",{className:"hidden lg:flex items-center text-neutral text-xs font-normal shrink-0 border-b border-border/50",style:{height:jl},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:i("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.totalSize")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.value")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.avgPrice")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.markPrice")}),jsxs("div",{className:"flex-[1.5] pr-2 text-right",children:[jsx("span",{children:i("predict.profile.pnl")}),jsxs("span",{className:"text-[10px] ml-1 opacity-60",children:["(",i("predict.profile.pnlExcludeFees"),")"]})]}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.payoutIfRight")}),jsx("div",{className:"flex-[1.5] pr-2 text-right",children:i("predict.profile.estSettlement")}),jsx("div",{className:"w-20 shrink-0 text-right",children:o&&e.length>0&&jsx("button",{type:"button",onClick:l,className:"text-xs text-primary hover:text-primary/80 cursor-pointer transition-colors",children:i("predict.profile.closeAll")})})]}),jsx("div",{className:"hidden lg:block overflow-y-auto",style:{height:f},children:p.map((g,v)=>jsx(Lh,{position:g,onClosePosition:o,onEventClick:n},`${g.source}-${g.market?.slug??d+v}`))}),jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:ao},children:[jsxs("button",{type:"button",disabled:!m,onClick:()=>a(g=>Math.max(1,g-1)),className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",m?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",i("predict.profile.previous")]}),Array.from({length:Math.min(u,5)},(g,v)=>{let x=v+1;return jsx("button",{type:"button",onClick:()=>a(x),className:cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",x===s?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:x},x)}),jsxs("button",{type:"button",disabled:!c,onClick:()=>a(g=>g+1),className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",c?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[i("predict.profile.next")," \u2192"]})]}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-ao},children:p.map((g,v)=>jsx(Rh,{position:g,onClose:o,onEventClick:n},`${g.source}-${g.market?.slug??`m-${d+v}`}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:ao},children:[jsx("button",{type:"button",disabled:!m,onClick:()=>a(g=>Math.max(1,g-1)),className:cn("text-sm cursor-pointer",m?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:s}),jsx("button",{type:"button",disabled:!c,onClick:()=>a(g=>g+1),className:cn("text-sm cursor-pointer",c?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function Lh({position:e,onClosePosition:t,onEventClick:r}){let{t:o}=useTranslation(),n=e.pnl??0,i=e.pnl_percent??0,s=e.avg_price??0,a=e.current_price??0,l=e.current_value??e.size*a,u=e.size,d=n>0?"text-success":n<0?"text-danger":"text-foreground",p=n>0?"+":"",m=e.event?.title??e.market?.question??"\u2014",c=e.event?.image_url,f=e.side,g=e.market?.outcomes?.[0]?.label??"",v=e.market?.end_at?Oh(e.market.end_at):"\u2014";return jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:Th},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxs("button",{type:"button",className:"flex items-center gap-2.5 min-w-0 cursor-pointer text-left",onClick:()=>e.event&&r?.(e.event),children:[c&&jsx("img",{src:c,alt:"",className:"w-8 h-8 rounded-full object-cover shrink-0"}),jsxs("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:[jsx("span",{className:"text-foreground truncate font-medium text-sm",children:m}),jsxs("span",{className:"text-[11px] text-neutral",children:[jsx("span",{className:cn("font-medium",f.toLowerCase()==="yes"?"text-success":"text-danger"),children:f}),g&&jsxs(Fragment,{children:[jsx("span",{className:"mx-1",children:"\xB7"}),jsx("span",{children:g})]})]})]})]})}),jsx("div",{className:"flex-1 pr-2 text-right",children:jsxs("div",{className:"flex flex-col items-end",children:[jsxs("span",{className:"font-mono text-foreground",children:["$",l.toFixed(2)]}),jsx("span",{className:"text-[10px] text-neutral",children:o("predict.profile.contracts",{count:Gr(e.size)})})]})}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",(e.size*s).toFixed(2)]}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:fi(s)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:fi(a)}),jsxs("div",{className:cn("flex-[1.5] pr-2 text-right font-mono",d),children:[jsxs("span",{children:[p,"$",Math.abs(n).toFixed(2)]}),jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",p,i.toFixed(2),"%)"]})]}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",u.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap text-xs",children:v}),jsx("div",{className:"w-20 shrink-0 text-right",children:t&&jsxs("button",{type:"button",onClick:()=>t(e),className:"inline-flex items-center gap-1 text-xs text-neutral hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{className:"text-danger",children:"\u2715"}),o("predict.profile.close")]})})]})}function Rh({position:e,onClose:t,onEventClick:r}){let{t:o}=useTranslation(),n=e.pnl??0,i=e.pnl_percent??0,s=e.current_price??0,a=n>0?"text-success":n<0?"text-danger":"text-foreground",l=n>0?"+":"",u=e.event?.title??e.market?.question??"\u2014";return jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxs("button",{type:"button",className:"flex items-start justify-between gap-2 text-left cursor-pointer",onClick:()=>e.event&&r?.(e.event),children:[jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.event?.image_url&&jsx("img",{src:e.event.image_url,alt:"",className:"w-7 h-7 rounded-full object-cover shrink-0"}),jsx("span",{className:"text-sm font-medium text-foreground line-clamp-2",children:u})]}),jsx("span",{className:cn("shrink-0 text-xs font-medium px-1.5 py-0.5 rounded",e.side.toLowerCase()==="yes"?"bg-success/10 text-success":"bg-danger/10 text-danger"),children:e.side})]}),jsxs("div",{className:"flex items-center gap-4 text-xs flex-wrap",children:[jsx(lo,{label:o("predict.profile.totalSize"),value:Gr(e.size)}),jsx(lo,{label:o("predict.profile.markPrice"),value:fi(s)}),jsx(lo,{label:o("predict.profile.pnl"),value:`${l}$${Math.abs(n).toFixed(2)} (${l}${i.toFixed(1)}%)`,className:a}),jsx(lo,{label:o("predict.profile.payoutIfRight"),value:`$${e.size.toFixed(2)}`})]}),t&&jsx("div",{className:"flex justify-end",children:jsx("button",{type:"button",onClick:()=>t(e),className:"text-xs text-danger hover:text-danger/80 cursor-pointer transition-colors border border-border rounded px-2 py-1",children:o("predict.profile.close")})})]})}function lo({label:e,value:t,className:r}){return jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:e}),jsx("span",{className:cn("font-mono text-foreground",r),children:t})]})}function _h({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function Ih({height:e}){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:e},children:Array.from({length:6}).map((t,r)=>jsx(Skeleton,{className:"h-12 w-full rounded-md"},r))})}function fi(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function Oh(e){try{let t=new Date(e),r=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0"),n=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getFullYear(),a=t.getTimezoneOffset(),l=a<=0?"+":"-",u=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${o} ${n}/${i}/${s} (${l}${u})`}catch{return "\u2014"}}function Yl({positions:e,trades:t,isLoading:r}){let{t:o}=useTranslation(),n=useMemo(()=>{let a=0,l=0;for(let c of e)a+=c.realized_pnl??0,l+=c.current_value??c.size*(c.current_price??0);let u=0,d=0,p=0;for(let c of t)u+=c.usd_size??0,c.type==="REDEEM"&&(p++,(c.usd_size??0)>0&&d++);let m=p>0?`${d} / ${p}`:"0 / 0";return {realizedPnl:a,positionsValue:l,volume:u,winRateStr:m}},[e,t]),i=n.realizedPnl>0?"text-success":n.realizedPnl<0?"text-danger":"text-foreground",s=n.realizedPnl>0?"+":"";return jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 py-8",children:[jsxs("div",{className:"flex flex-col gap-1",children:[jsx("span",{className:"text-xl text-neutral",children:o("predict.profile.realizedPnl")}),r?jsx(Skeleton,{className:"h-14 w-48 rounded-md"}):jsxs("span",{className:cn("text-5xl font-bold tabular-nums",i),children:[s,"$",Math.abs(n.realizedPnl).toFixed(2)]})]}),jsxs("div",{className:"flex items-end gap-8 sm:gap-10",children:[jsx(hi,{label:o("predict.profile.winRate"),value:n.winRateStr,isLoading:r}),jsx(hi,{label:o("predict.profile.positions"),value:`$${n.positionsValue.toFixed(2)}`,isLoading:r}),jsx(hi,{label:o("predict.profile.volume"),value:`$${n.volume.toFixed(2)}`,isLoading:r})]})]})}function hi({label:e,value:t,isLoading:r}){return jsxs("div",{className:"flex flex-col items-end gap-0.5",children:[jsx("span",{className:"text-sm text-neutral whitespace-nowrap",children:e}),r?jsx(Skeleton,{className:"h-6 w-14 rounded-md"}):jsx("span",{className:"text-base font-semibold tabular-nums text-foreground",children:t})]})}var vi=600;function Uh({solanaAddress:e,evmAddress:t,onClosePosition:r,onEventClick:o}){let{t:n}=useTranslation(),[i,s]=useState("positions"),a=!!(e||t),{data:l,isLoading:u}=usePositions({source:"kalshi",user:e??""}),{data:d,isLoading:p}=usePositions({source:"polymarket",user:t??""}),m=useMemo(()=>{let k=[];return l?.positions&&k.push(...l.positions),d?.positions&&k.push(...d.positions),k},[l,d]),c=u||p,{data:f,isLoading:g}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:100}),{data:v,isLoading:x}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:100}),b=useMemo(()=>[...f?.pages?.flatMap(P=>P.items)??[],...v?.pages?.flatMap(P=>P.items)??[]],[f,v]),w=c||g||x,S=m.length,y=[{key:"positions",label:S>0?`${n("predict.profile.positionsTab")} (${S})`:n("predict.profile.positionsTab")},{key:"orders",label:n("predict.profile.openOrdersTab")},{key:"history",label:n("predict.profile.historyTab")}];return a?jsxs("div",{className:"flex flex-col max-w-[1280px] mx-auto w-full px-4 max-sm:px-2",children:[jsx(Yl,{positions:m,trades:b,isLoading:w}),jsx("div",{className:"flex items-center gap-1 border-b border-border",children:y.map(k=>jsx("button",{type:"button",onClick:()=>s(k.key),className:cn("px-3 py-3 text-base font-normal transition-colors cursor-pointer whitespace-nowrap",i===k.key?"text-foreground border-b-2 border-foreground":"text-neutral hover:text-foreground"),children:k.label},k.key))}),jsxs("div",{className:"py-2",children:[i==="positions"&&jsx(ql,{positions:m,isLoading:c,listHeight:vi,onClosePosition:r,onEventClick:o}),i==="orders"&&jsx(Kl,{solanaAddress:e,evmAddress:t,listHeight:vi}),i==="history"&&jsx(Al,{solanaAddress:e,evmAddress:t,listHeight:vi})]})]}):jsx("div",{className:"flex items-center justify-center text-sm text-neutral py-24 px-4",children:n("predict.profile.connectWallet")})}function Iw({isOpen:e,onClose:t,safeDeployed:r,tokenApproved:o,onDeployAndApprove:n}){let{t:i}=useTranslation(),[s,a]=useState(false),[l,u]=useState(null),[d,p]=useState(false),m=r||d,c=o||d,f=m?"done":s?"running":"pending",g=c?"done":m&&s?"running":"pending",v=m&&c,x=useCallback(async()=>{u(null),p(false),a(true);try{await n(),p(!0);}catch(h){u(h instanceof Error?h.message:String(h));}finally{a(false);}},[n]),b=[{key:"step1",label:i("predict.setup.step1"),desc:i("predict.setup.step1Desc"),status:f},{key:"step2",label:i("predict.setup.step2"),desc:i("predict.setup.step2Desc"),status:g}],w=()=>{v?t():x();},S=i(v?"predict.setup.done":"predict.setup.setupButton");return jsx(StyledModal,{isOpen:e,onOpenChange:h=>{h||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:i("predict.setup.modalTitle")}),jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxs("div",{className:"px-5 pb-5 space-y-4",children:[jsx("p",{className:"text-[13px] text-zinc-400 text-left",children:i("predict.setup.modalDescription")}),jsx("div",{className:"space-y-2.5",children:b.map((h,y)=>jsxs("div",{className:"flex gap-3 rounded-[10px] border border-zinc-700/50 bg-zinc-800/50 px-3 py-3",children:[jsx(qh,{index:y+1,status:h.status}),jsxs("div",{className:"flex-1 min-w-0 pt-0.5",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("p",{className:"text-sm font-medium text-zinc-200",children:h.label}),jsx("span",{className:`text-[11px] leading-none ${h.status==="done"?"text-[#c7ff2e]":h.status==="running"?"text-[#c7ff2e]/70":"text-zinc-500"}`,children:h.status==="done"?i("predict.setup.stepComplete"):h.status==="running"?i("predict.setup.stepRunning"):i("predict.setup.stepPending")})]}),jsx("p",{className:"text-xs text-zinc-500 mt-1",children:h.desc})]})]},h.key))}),l&&jsx("div",{className:"rounded-[10px] bg-red-500/10 border border-red-500/20 px-3 py-2",children:jsx("p",{className:"text-xs text-red-400",children:l})}),jsx("button",{type:"button",onClick:w,disabled:s,className:v?"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus":"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:s?jsxs("span",{className:"inline-flex items-center gap-2",children:[jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",children:[jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",className:"opacity-25"}),jsx("path",{d:"M4 12a8 8 0 018-8",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",className:"opacity-75"})]}),i("predict.setup.stepRunning")]}):S}),!v&&jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] text-sm text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:i("common.cancel")})]})]})})})}function qh({index:e,status:t}){return t==="done"?jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-[#c7ff2e]/15 shrink-0",children:jsx("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#c7ff2e]",children:jsx("polyline",{points:"20 6 9 17 4 12"})})}):t==="running"?jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-[#c7ff2e]/10 shrink-0",children:jsxs("svg",{className:"animate-spin h-4 w-4 text-[#c7ff2e]",viewBox:"0 0 24 24",fill:"none",children:[jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",className:"opacity-25"}),jsx("path",{d:"M4 12a8 8 0 018-8",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",className:"opacity-75"})]})}):jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-zinc-700/50 text-xs font-bold text-zinc-400 shrink-0",children:e})}
|
|
136
|
+
export{cv as CHART_RANGE_DURATION,av as CHART_RANGE_PERIOD,lv as CHART_RANGE_SAMPLE_INTERVAL,Pn as CandlestickPeriod,Jh as CategoriesSkeleton,wi as CategoriesUI,Ci as CategoriesWidget,le as ChartRange,Xo as CommentItemUI,Nn as DEFAULT_CHART_RANGE,Qr as DEFAULT_FILTER_STATE,qr as DEFAULT_PAGE_SIZE,mv as DEFAULT_PRICE_HISTORY_INTERVAL,Yf as EventCommentsWidget,P1 as EventDetailPage,nn as EventDetailSkeleton,Pa as EventDetailUI,Na as EventDetailWidget,ms as EventItem,oa as EventMarketDepthChartUI,ua as EventMarketDetailWidget,ga as EventPriceChart,qi as EventsFilterUI,tb as EventsHero,Qx as EventsPage,Sx as EventsPageSkeleton,Eo as EventsSkeleton,Zi as EventsToolbarUI,xs as EventsUI,ys as EventsWidget,Rn as KycModal,So as MAX_PRICE_HISTORY_MARKETS,CS as MatchGroupCard,bl as MatchMarketCard,pl as MatchesFilterBar,fl as MatchesHero,bS as MatchesPage,_S as MatchesStatsBar,Pl as MatchesWidget,pv as ORDER_MAX_PRICE,uv as ORDER_MIN_PRICE,Cn as ORDER_MIN_QUANTITY,Mn as ORDER_MIN_USDC,dv as ORDER_PRICE_STEP,xc as POLYMARKET_SPORTS_TAKER_FEE_BPS,zu as PREDICT_REDEEM_MODAL_ID,ri as PREDICT_SEARCH_MODAL_ID,Fo as PREDICT_SELL_MODAL_ID,Yr as PREDICT_TRADE_MODAL_ID,fv as PRICE_HISTORY_SAMPLE_INTERVAL,Rs as PredictRedeemModal,wk as PredictSearchModal,Vs as PredictSellModal,On as PredictTradeModal,gc as PredictWalletProvider,Rr as PriceHistoryInterval,Uh as ProfilePage,Ts as RedeemFormWidget,Ji as SORT_PRESETS,ko as STATIC_CATEGORIES,_k as SearchEventsButton,Wa as SearchHistoryUI,Ua as SearchHistoryWidget,$a as SearchInputUI,Ka as SearchResultItemUI,Ya as SearchResultListWidget,el as SearchWidget,$s as SellFormUI,Wn as SellFormWidget,Iw as SetupModal,vf as SimilarEventCard,Ta as SimilarEventsSection,Zy as SourceBadge,DS as SpreadIndicator,Xs as TradeFormSkeleton,Vi as TradeFormUI,In as TradeFormWidget,Gs as UserActivitySection,_i as computeMaxBuyAmount,Mo as countActiveFilters,Ii as estimatePolymarketBuyFee,mr as fireCelebration,ve as floorToDecimals,on as formatKMB,Gr as formatShares,Dt as getSourceMeta,Ln as parsePolymarketError,Li as polymarketFeeFactor,En as resolveExpiration,Ri as resolvePolymarketDisplayFeeRateBps,Tn as roundToTickSize,R1 as useEventDetail,rs as useEventsInfinite,to as usePredictSearchHistory,pr as usePredictWallet,Va as useSearchResultListScript,Za as useSearchScript,Os as useSellForm,Di as useTradeForm};//# sourceMappingURL=index.mjs.map
|
|
137
137
|
//# sourceMappingURL=index.mjs.map
|