@liberfi.io/ui-predict 0.1.92 → 0.1.94

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.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import {createContext,memo,useRef,useCallback,useState,useContext,useMemo,useEffect,Fragment as Fragment$1,Component}from'react';import {cn as cn$1,Skeleton,toast,useDisclosure,Tabs,Tab,StyledNumberInput,StyledSwitch,Select,SelectItem,ChevronDownIcon,Button,Modal,ModalContent,ModalHeader,ModalBody,ModalFooter,useScreen,StyledModal,RefreshIcon,TimerIcon,DropletIcon,ChartLineIcon,CalendarIcon,StyledBadge,FilterIcon,Linkable,Avatar,ChevronUpIcon,PolymarketIcon,KalshiIcon,Spinner,OrderbookTableIcon,OrderbookDepthIcon,Dropdown,DropdownTrigger,DropdownMenu,DropdownItem,ChevronRightIcon,ChevronLeftIcon,TrashIcon,Chip,StyledInput,XCloseIcon,Kbd,SearchIcon,EmptyIcon}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,useSwitchChain,useAuthCallback}from'@liberfi.io/wallet-connector';import {useQueryClient,useQueries}from'@tanstack/react-query';import Zt from'canvas-confetti';import {ChartRange,useBalance,usePredictClient,PolymarketContext,useDFlowQuote,usePositions,useDFlowSubmit,useOrder,buildCtfExchangeDomain,buildOrderMessage,CTF_ORDER_TYPES,buildSignedOrder,buildPolymarketL2Headers,resolveEventsParams,useInfiniteEvents,useInfiniteOrders,useCancelOrder,useInfiniteTrades,useOrderbook,useMarketHistory,useEvent,useSimilarEvents,candlesticksQueryKey,useSearchEvents}from'@liberfi.io/react-predict';export{PredictClient,PredictContext,PredictProvider,PredictWsClient,createPredictClient,createPredictWsClient,useBalance,useCancelOrder,useCandlesticks,useDFlowKYC,useDFlowQuote,useDFlowSubmit,useEvent,useEvents,useInfiniteEvents,useMarket,useMarketHistory,useMarketTrades,useOrder,useOrderbook,useOrders,usePositions,usePredictClient,usePriceHistory,useSearchEvents,useSimilarEvents,useTrades}from'@liberfi.io/react-predict';import {ChainNamespace,Chain}from'@liberfi.io/types';import {SOLANA_TOKENS,debounce}from'@liberfi.io/utils';import {List}from'react-window';import {useInfiniteLoader}from'react-window-infinite-loader';import {useResizeObserver,useScrollCollapse,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';typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/ui-predict"]="0.1.92");var Zo="0.1.92";var es={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},Hr=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],jt=(()=>{let e=t=>{let n=Hr.indexOf(t);return n===-1?Hr.length:n};return Object.entries(es).map(([t,n])=>({slug:t,label:t,tags:(n??[]).map(o=>({slug:o,label:o}))})).sort((t,n)=>e(t.slug)-e(n.slug))})();function Wr({categories:e,selectedCategory:t,selectedTag:n,activeTags:o,onCategorySelect:r,onTagSelect:i,trailing:s,pulsingTab:l="Trending",className:a}){let{t:c}=useTranslation(),d=useCallback(()=>{r(null);},[r]),p=c("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-1 lg:px-2 lg:py-1",a),children:[jsxs("div",{className:"flex w-full items-center gap-2",children:[jsx("div",{className:"hideScrollbar min-w-0 flex-1 overflow-x-auto overflow-y-hidden",children:jsxs("div",{className:"flex min-h-8 items-stretch gap-x-2 lg:min-h-9",children:[jsx(Ur,{label:p,isSelected:t===null,onPress:d,showPulse:p===l}),jsx(os,{}),e.map(u=>jsx(Ur,{label:u.category,isSelected:t===u.category,onPress:()=>r(u.category),badge:u.badge,showPulse:u.category===l},u.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 pl-2 lg:w-full lg:gap-x-2",children:[jsx($r,{label:c("predict.categories.allMarkets"),isSelected:n===null,onPress:()=>i(null)}),o.map(u=>jsx($r,{label:u.label,icon:u.icon,isSelected:n===u.label,onPress:()=>i(u.label)},u.label))]})})]})}function Ur({label:e,isSelected:t,onPress:n,badge:o,showPulse:r}){return jsxs("button",{type:"button",onClick:n,className:cn$1("relative shrink-0 cursor-pointer whitespace-nowrap border-b p-1 text-base font-normal capitalize transition-colors",t?"border-primary/50 text-primary":"border-transparent text-neutral-500 hover:text-neutral-300"),children:[r?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 os(){return jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function $r({label:e,icon:t,isSelected:n,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-2 py-1 text-sm font-medium uppercase transition-colors cursor-pointer",n?"border-transparent bg-primary text-black":"border-border/80 text-neutral-200 hover:bg-primary/10 hover:text-primary"),children:[t&&jsx("span",{className:cn$1("iconify size-4",t)}),e]})}function rd({count:e=6}){return jsx("div",{className:"flex w-full flex-col gap-2 px-4 py-1 lg:px-2 lg:py-1",children:jsx("div",{className:"flex min-h-8 items-center gap-x-2 lg:min-h-9",children:Array.from({length:e}).map((t,n)=>jsx(Skeleton,{className:"h-6 w-16 shrink-0 rounded"},n))})})}function ss(e){return e.map(t=>({category:t.label,tags:t.tags.map(n=>n.label)}))}function as(e){return e?e.tags.map(t=>({label:t.label,icon:t.icon})):[]}function Vr({onSelect:e,trailing:t,className:n}){let[o,r]=useState(null),[i,s]=useState(null),l=useCallback(u=>{r(u),s(null),e?.({categorySlug:u,tagSlug:null});},[e]),a=useCallback(u=>{s(u),e?.({categorySlug:o,tagSlug:u});},[o,e]),c=ss(jt),d=jt.find(u=>u.slug===o),p=as(d);return jsx(Wr,{categories:c,selectedCategory:o,selectedTag:i,activeTags:p,onCategorySelect:l,onTagSelect:a,trailing:t,className:n})}function Yr(e){return {title:e.title,imageUrl:e.image_url}}function qr(e){let t=e.outcomes[0],n=e.outcomes[1];return {question:e.question,yesAsk:t?.best_ask??t?.price,noAsk:n?.best_ask??n?.price,yesBid:t?.best_bid,noBid:n?.best_bid,yesSubTitle:t?.label??"Yes",noSubTitle:n?.label??"No"}}var Qe=48,Gt=4,xt={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},oe={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},ht=oe.ALL,ud={[oe.ONE_DAY]:xt.ONE_MINUTE,[oe.ONE_WEEK]:xt.ONE_HOUR,[oe.ONE_MONTH]:xt.ONE_HOUR,[oe.ALL]:xt.ONE_DAY},pd={[oe.ONE_DAY]:300,[oe.ONE_WEEK]:3600,[oe.ONE_MONTH]:10800,[oe.ALL]:1440*60},md={[oe.ONE_DAY]:1440*60,[oe.ONE_WEEK]:10080*60,[oe.ONE_MONTH]:720*60*60,[oe.ALL]:null},Xt=1,fd=1,gd=1,vd=99,Be={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},xd=Be.ONE_WEEK,hd={[Be.ONE_HOUR]:60,[Be.SIX_HOURS]:60,[Be.ONE_DAY]:300,[Be.ONE_WEEK]:1800,[Be.MAX]:1800};var Xr=createContext(null);function Jt(){let e=useContext(Xr);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var us=3e4;function ps({pollingInterval:e=us,enabled:t=true,children:n}){let o=useWallets(),r=useMemo(()=>o.find(m=>m.chainNamespace===ChainNamespace.SOLANA&&m.isConnected)?.address,[o]),i=useMemo(()=>o.find(m=>m.chainNamespace===ChainNamespace.EVM&&m.isConnected)?.address,[o]),{data:s,isLoading:l,error:a}=useBalance({source:"kalshi",user:r??""},{enabled:t&&!!r,refetchInterval:e}),{data:c,isLoading:d,error:p}=useBalance({source:"polymarket",user:i??""},{enabled:t&&!!i,refetchInterval:e}),u=useMemo(()=>({solanaAddress:r,evmAddress:i,dflowUsdcBalance:s?Number(s.balance):0,polymarketUsdcBalance:c?Number(c.balance):0,isLoading:l||d,error:a??p??null}),[r,i,s,c,l,d,a,p]);return jsx(Xr.Provider,{value:u,children:n})}var Os={minutes:60,hours:3600,days:86400};function Is(e,t,n){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 r=new Date;return r.setUTCHours(23,59,59,0),Math.floor(r.getTime()/1e3)}case "custom":return o+t*Os[n]}}function en(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};Zt({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{Zt({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{Zt({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function tn({market:e,initialOutcome:t="yes",initialSide:n="buy"}){let{t:o}=useTranslation(),{status:r}=useAuth(),i=useWallets(),s=useSwitchChain(),l=usePredictClient(),a=useContext(PolymarketContext),c=useQueryClient(),d=e.source,p=d==="polymarket",u=i.find(N=>N.chainNamespace===ChainNamespace.SOLANA&&N.isConnected),m=i.find(N=>N.chainNamespace===ChainNamespace.EVM&&N.isConnected&&"switchChain"in N),f=r==="authenticated",g=u?.address,v=m?.address,[h,D]=useState(t),[T,M]=useState(n),[O,Z]=useState("market"),[R,ie]=useState(NaN),[K,fe]=useState(NaN),[Me,X]=useState(false),[Q,le]=useState(null),[he,be]=useState(false),[S,E]=useState(null),[I,y]=useState(false),[$,q]=useState("1h"),[z,Pe]=useState(30),[Re,Bt]=useState("minutes"),ye=null;try{let N=Jt();ye={dflowUsdcBalance:N.dflowUsdcBalance,polymarketUsdcBalance:N.polymarketUsdcBalance,isLoading:N.isLoading};}catch{}let ne=useMemo(()=>{let N=h==="yes"?0:1,B=e.outcomes[N];return T==="buy"?B?.best_ask??B?.price??.5:B?.best_bid??B?.price??.5},[e.outcomes,h,T]),Ht=useCallback(N=>{Z(N);},[]),Ut=useCallback(N=>{D(N),fe(NaN);},[]);useEffect(()=>{O==="limit"&&isNaN(K)&&fe(Math.round(ne*100)/100);},[O,K,ne]);let je=useMemo(()=>isNaN(R)||R<=0?0:T==="buy"?ne>0?R/ne:0:R,[T,R,ne]),Fe=useMemo(()=>isNaN(R)||R<=0?"0":String(Math.round(R*1e6)),[R]),C=e.provider_meta?.["dflow.yesMint"]??"",ce=e.provider_meta?.["dflow.noMint"]??"",Le=e.provider_meta?.["dflow.collateralMint"]||SOLANA_TOKENS.stablecoins.USDC.address,Rr=h==="yes"?C:ce,Ge=T==="buy"?Le:Rr,Xe=T==="buy"?Rr:Le,Ao=d==="kalshi"&&!!Ge&&!!Xe&&!!g&&Fe!=="0",{refetch:Lr}=useDFlowQuote({inputMint:Ge,outputMint:Xe,amount:Fe,userPublicKey:g??"",slippageBps:100},{enabled:Ao}),Or=d==="kalshi"?g??"":v??"",{data:Se,isLoading:Fo}=usePositions({source:d,user:Or},{enabled:!!Or}),mt=useMemo(()=>ye?d==="kalshi"?ye.dflowUsdcBalance:ye.polymarketUsdcBalance:Se&&Se.positions.reduce((B,Ne)=>Ne.side==="USDC"||Ne.side==="collateral"?B+(Ne.current_value??0):B,0)||null,[ye,Se,d]),Bo=ye?ye.isLoading:Fo,$t=useMemo(()=>Se?Se.positions.find(B=>B.side?.toLowerCase()==="yes"&&B.market?.slug===e.slug)?.size??0:null,[Se,e.slug]),Wt=useMemo(()=>Se?Se.positions.find(B=>B.side?.toLowerCase()==="no"&&B.market?.slug===e.slug)?.size??0:null,[Se,e.slug]),zt=useMemo(()=>O==="limit"&&p&&!isNaN(K)?K:ne,[O,p,K,ne]),ft=useMemo(()=>{if(isNaN(R)||R<=0)return 0;if(T==="buy")return R;let N=h==="yes"?e.outcomes[0]?.best_bid??0:e.outcomes[1]?.best_bid??0;return R*N},[T,h,R,e.outcomes]),Ir=useMemo(()=>isNaN(R)||R<=0?0:T==="buy"?zt>0?R/zt*1:0:ft,[T,R,zt,ft]),Ho=Ir-ft,Uo=useCallback(N=>{M(N),ie(NaN);},[]),$o=useCallback(N=>{if(isNaN(N)){ie(NaN);return}let B=Math.max(0,N),Ne=T==="buy"?Math.round(B*100)/100:Math.round(B);ie(Ne);},[T]),Wo=useCallback(N=>{if(isNaN(N)){fe(NaN);return}let B=Math.max(.01,Math.min(.99,N));fe(Math.round(B*100)/100);},[]),Kt=useMemo(()=>{let N=[];(isNaN(R)||R<Xt)&&N.push(`Minimum quantity is ${Xt}`),e.status!=="open"&&N.push("Market is not active"),T==="buy"&&mt!=null&&!isNaN(R)&&R>0&&R>mt&&N.push("Insufficient USDC balance");let B=h==="yes"?$t:Wt;return T==="sell"&&B!=null&&!isNaN(R)&&R>0&&R>B&&N.push("Insufficient shares"),O==="limit"&&p&&(isNaN(K)||K<.01||K>.99)&&N.push("Limit price must be between $0.01 and $0.99"),O==="limit"&&p&&I&&$==="custom"&&(isNaN(z)||z<=0)&&N.push(o("predict.trade.expiration.invalidDate")),{isValid:N.length===0,errors:N}},[R,e.status,T,mt,$t,Wt,h,O,p,K,I,$,z,o]),{mutateAsync:_r}=useDFlowSubmit(),{data:Vt}=useOrder({id:Q??"",source:d},{enabled:!!Q});useEffect(()=>{if(!Vt||!Q)return;let{status:N}=Vt;N==="closed"?(X(false),le(null),toast.success(o("predict.trade.submitSuccess")),en(),ie(NaN)):(N==="failed"||N==="expired")&&(X(false),le(null),toast.error(o("predict.trade.submitError")));},[Vt,Q,o]);let Dr=useCallback(async()=>{if(!g||!u)return;if(!Ge||!Xe){toast.error("Missing token mint addresses"),X(false);return}let N=await l.checkDFlowKYC(g);if(!N.verified){be(true),E(N.kyc_url||null),X(false);return}let we=(await Lr()).data?.transaction;if(!we){toast.error(o("predict.trade.submitError")),X(false);return}let ke=Uint8Array.from(atob(we),gt=>gt.charCodeAt(0)),Yt=await u.signTransaction(ke),qt=await _r({signedTransaction:btoa(String.fromCharCode(...Yt)),orderContext:{user_public_key:g,input_mint:Ge,output_mint:Xe,amount:Fe,price:String(ne),side:T==="buy"?"BUY":"SELL",outcome:h==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});le(qt.signature);},[g,u,l,Lr,_r,Ge,Xe,Fe,ne,T,h,e.slug,o]),Ar=useCallback(async()=>{if(!m||!a)return;let N=m.chain,B=N!==Chain.POLYGON;B&&await s(Chain.POLYGON);try{let Ne=await m.getEip1193Provider();if(!Ne){toast.error(o("predict.trade.submitError")),X(!1);return}let we={address:m.address,signatureType:0,signTypedData:async(Xo,Qo,Jo)=>await Ne.request({method:"eth_signTypedData_v4",params:[m.address,JSON.stringify({domain:Xo,types:Qo,message:Jo})]})},ke=a.credentials;if(!ke&&(await a.authenticate(we),ke=a.credentials,!ke))throw new Error("Polymarket authentication failed");let Yt=h==="yes"?0:1,qt=e.provider_meta?.[`polymarket.tokenId${Yt}`]??e.provider_meta?.["polymarket.conditionId"]??"",gt=e.provider_meta?.["polymarket.negRisk"]??!1,Ko=O==="limit"&&!isNaN(K)?K:ne,Fr={tokenId:qt,price:Ko,size:R,side:T==="buy"?"BUY":"SELL",orderType:O==="limit"?I?"GTD":"GTC":"FOK",tickSize:"0.01",negRisk:gt,...O==="limit"&&I&&{expiration:Is($,z,Re)}},Vo=buildCtfExchangeDomain(gt),Yo=buildOrderMessage({...Fr,signerAddress:we.address,signatureType:we.signatureType}),qo=await we.signTypedData(Vo,CTF_ORDER_TYPES,Yo),Br=buildSignedOrder({...Fr,signerAddress:we.address,signatureType:we.signatureType,signature:qo}),jo=JSON.stringify(Br),Go=await buildPolymarketL2Headers(ke.address,{apiKey:ke.apiKey,secret:ke.secret,passphrase:ke.passphrase,method:"POST",requestPath:"/api/v1/orders/polymarket",body:jo});await l.createPolymarketOrder(Br,Go),c.invalidateQueries({queryKey:["predict","orders"]}),c.invalidateQueries({queryKey:["predict","positions"]}),toast.success(o("predict.trade.submitSuccess")),en(),ie(NaN),X(!1);}finally{B&&N&&s(N).catch(()=>{});}},[m,a,s,h,e.provider_meta,O,K,ne,R,T,l,c,I,$,z,Re,o]),zo=useCallback(async()=>{if(!(!Kt.isValid||!f)){X(true),le(null),be(false);try{d==="kalshi"?await Dr():await Ar();}catch{toast.error(o("predict.trade.submitError")),X(false);}}},[Kt.isValid,f,d,Dr,Ar,o]);return {outcome:h,side:T,orderType:O,quantity:R,limitPrice:K,shares:je,estimatedCost:ft,potentialPayout:Ir,potentialProfit:Ho,usdcBalance:mt,yesTokenBalance:$t,noTokenBalance:Wt,isBalanceLoading:Bo,isSubmitting:Me,validation:Kt,supportsLimitOrder:p,kycRequired:he,kycUrl:S,expirationEnabled:I,expirationPreset:$,customDuration:z,customDurationUnit:Re,setOutcome:Ut,setSide:Uo,setOrderType:Ht,setQuantity:$o,setLimitPrice:Wo,setExpirationEnabled:y,setExpirationPreset:q,setCustomDuration:Pe,setCustomDurationUnit:Bt,submit:zo}}var Ys=`https://s1.chainstream.io/chains/sol/tokens/${SOLANA_TOKENS.stablecoins.USDC.address}/image.png`,qs=["5m","1h","12h","24h","eod","custom"],js={"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"},Gs=["minutes","hours","days"],Xs={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"};function cn({event:e,market:t,variant:n="bordered",outcome:o,side:r,orderType:i,quantity:s,limitPrice:l,shares:a,potentialProfit:c,potentialPayout:d,estimatedCost:p,usdcBalance:u,yesTokenBalance:m,noTokenBalance:f,isBalanceLoading:g,isSubmitting:v,isValid:h,validationErrors:D,supportsLimitOrder:T,kycRequired:M,kycUrl:O,expirationEnabled:Z,expirationPreset:R,customDuration:ie,customDurationUnit:K,onOutcomeChange:fe,onSideChange:Me,onOrderTypeChange:X,onQuantityChange:Q,onLimitPriceChange:le,onExpirationEnabledChange:he,onExpirationPresetChange:be,onCustomDurationChange:S,onCustomDurationUnitChange:E,onSubmit:I}){let{t:y}=useTranslation(),[$,q]=useState(false),z=useDisclosure();useEffect(()=>{M&&!z.isOpen&&z.onOpen();},[M]);let Pe=useMemo(()=>{let C=r==="buy"?o==="yes"?t.yesAsk:t.noAsk:o==="yes"?t.yesBid:t.noBid;return C!=null?parseFloat((Number(C)*100).toFixed(2)):null},[r,o,t]),Re=!isNaN(s)&&s>0,Bt=useMemo(()=>{if(v)return y("predict.trade.submitting");if(M)return y("predict.trade.kycRequired");if(!Re)return y("predict.trade.enterAmount");let C=y(r==="buy"?"predict.trade.buy":"predict.trade.sell"),ce=y(o==="yes"?"predict.trade.yes":"predict.trade.no"),Le=r==="buy"&&c>0?` \u2192 Win $${c.toFixed(2)}`:"";return `${C} ${ce}${Le}`},[v,M,Re,r,o,c,y]),ye=useMemo(()=>o==="yes"?"primary":"secondary",[o]),ne=()=>{Q(Math.floor((u??0)/2*100)/100);},Ht=()=>{Q(u??0);},[Ut,je]=useState(false),Fe=()=>{if(M){z.onOpen();return}if(!h){je(true);return}je(false),I();};return jsxs(Fragment,{children:[jsxs("div",{className:cn$1("flex w-full flex-col gap-y-4 p-4",n==="bordered"&&"rounded-xl border border-default-200 bg-content1"),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:o==="yes"?"text-bullish":"text-bearish",children:[y(r==="buy"?"predict.trade.buy":"predict.trade.sell")," ",y(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:[T?jsxs(Tabs,{variant:"underlined",selectedKey:i,onSelectionChange:C=>X(C),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsx(Tab,{title:y("predict.trade.market")},"market"),jsx(Tab,{title:y("predict.trade.limit")},"limit")]}):jsx("span",{className:"text-sm font-medium text-foreground",children:y("predict.trade.market")}),i==="limit"&&T?jsx(StyledNumberInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",value:isNaN(l)?void 0:parseFloat((l*100).toFixed(2)),onValueChange:C=>le(C/100),minValue:1,maxValue:99,step:1,formatOptions:{maximumFractionDigits: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"}}):Pe!=null&&jsxs("span",{className:"text-xl font-bold tabular-nums",children:[Pe," \xA2"]})]}),jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(C=>{let ce=C==="yes"?m:f;return jsxs("div",{className:"flex flex-1 flex-col gap-y-1",children:[jsxs("button",{type:"button",onClick:()=>fe(C),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${o===C?C==="yes"?"border-primary bg-primary-50 text-primary":"border-secondary bg-secondary-50 text-secondary":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsx("span",{children:y(C==="yes"?"predict.trade.yes":"predict.trade.no")}),(()=>{let Le=r==="buy"?C==="yes"?t.yesAsk:t.noAsk:C==="yes"?t.yesBid:t.noBid;return Le!=null?jsxs("span",{className:"ml-1 opacity-70",children:[parseFloat((Number(Le)*100).toFixed(2)),"\xA2"]}):null})()]}),r==="sell"&&o===C&&jsx("span",{className:"text-center text-xs text-foreground",children:g?"\u2013":`${ce??0} shares`})]},C)})}),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:y(r==="buy"?"predict.trade.youArePaying":"predict.trade.contracts")}),r==="buy"&&jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("img",{src:Ys,alt:"USDC",className:"h-3.5 w-3.5 rounded-full object-cover"}),jsx("span",{className:"font-medium text-foreground tabular-nums",children:u!=null?`${u.toFixed(2)} USDC`:"\u2013"}),jsx("button",{type:"button",onClick:ne,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:y("predict.trade.half")}),jsx("button",{type:"button",onClick:Ht,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:y("predict.trade.max")})]})]}),jsx(StyledNumberInput,{fullWidth:true,placeholder:"0",radius:"lg",size:"lg",value:isNaN(s)?void 0:s,onValueChange:C=>{je(false),Q(C);},minValue:0,step:r==="buy"?.01:1,formatOptions:r==="buy"?{maximumFractionDigits:2}:{maximumFractionDigits:0},startContent:r==="buy"?jsx("span",{className:"text-default-600 text-xl",children:"$"}):void 0,classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}},r),r==="sell"&&jsxs("div",{className:"flex gap-x-2 justify-end",children:[[25,50].map(C=>jsxs("button",{type:"button",onClick:()=>{Q(Math.floor((o==="yes"?m??0:f??0)*C/100));},className:"rounded-md bg-content2 px-2.5 py-1 text-xs font-medium text-default-600 transition-colors hover:bg-content3 cursor-pointer",children:[C,"%"]},C)),jsx("button",{type:"button",onClick:()=>{Q(o==="yes"?m??0:f??0);},className:"rounded-md bg-content2 px-2.5 py-1 text-xs font-medium text-default-600 transition-colors hover:bg-content3 cursor-pointer",children:y("common.all")})]}),Ut&&D.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:D.map(C=>jsx("span",{className:"text-xs text-danger",children:C},C))})]}),i==="limit"&&T&&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:y("predict.trade.setExpiration")}),jsx(StyledSwitch,{size:"sm",color:"primary",isSelected:Z,onValueChange:he,"aria-label":y("predict.trade.setExpiration")})]}),Z&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":y("predict.trade.setExpiration"),selectedKeys:[R],onSelectionChange:C=>{let ce=Array.from(C)[0];ce&&be(ce);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:qs.map(C=>jsx(SelectItem,{children:y(js[C])},C))}),R==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(ie)?void 0:ie,onValueChange:S,minValue:1,step:1,formatOptions:{maximumFractionDigits:0},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:[K],onSelectionChange:C=>{let ce=Array.from(C)[0];ce&&E(ce);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Gs.map(C=>jsx(SelectItem,{children:y(Xs[C])},C))})]})]})]}),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:()=>q(C=>!C),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{children:y("predict.trade.odds")}),jsx(ChevronDownIcon,{className:cn$1("h-3.5 w-3.5 transition-transform",$&&"rotate-180")})]}),Pe!=null&&jsxs("span",{className:"text-foreground font-medium tabular-nums",children:[Pe,"% chance"]})]}),$&&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:"Total Size"}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(s)&&s>0?`$${p.toFixed(2)}`:"\u2013"})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:"No. of Contracts"}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(a)&&a>0?parseFloat(a.toFixed(2)):"\u2013"})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:"Payout"}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(s)&&s>0?`$${d.toFixed(2)}`:"\u2013"})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:"Est. Profit"}),jsx("span",{className:"tabular-nums text-bullish",children:!isNaN(s)&&s>0&&c>0?`+$${c.toFixed(2)}`:"\u2013"})]})]})]}),jsx(Button,{color:ye,fullWidth:true,radius:"lg",size:"lg",isDisabled:!Re||v,isLoading:v,onPress:Fe,children:Bt})]}),jsx(Modal,{isOpen:z.isOpen,onClose:z.onClose,size:"md",children:jsxs(ModalContent,{children:[jsx(ModalHeader,{className:"flex flex-col gap-1",children:jsxs("span",{className:"text-lg",children:["\u{1F6E1}\uFE0F ",y("predict.trade.kycModalTitle")]})}),jsxs(ModalBody,{className:"gap-y-4",children:[jsx("p",{className:"text-sm text-default-600",children:y("predict.trade.kycModalDescription")}),jsxs("ul",{className:"flex flex-col gap-y-2 text-sm text-foreground",children:[jsxs("li",{className:"flex items-start gap-x-2",children:[jsx("span",{className:"mt-0.5 text-primary",children:"\u2713"}),jsx("span",{children:y("predict.trade.kycModalBullet1")})]}),jsxs("li",{className:"flex items-start gap-x-2",children:[jsx("span",{className:"mt-0.5 text-primary",children:"\u2713"}),jsx("span",{children:y("predict.trade.kycModalBullet2")})]}),jsxs("li",{className:"flex items-start gap-x-2",children:[jsx("span",{className:"mt-0.5 text-primary",children:"\u2713"}),jsx("span",{children:y("predict.trade.kycModalBullet3")})]})]}),jsx("p",{className:"text-xs text-default-400",children:y("predict.trade.kycModalNote")})]}),jsxs(ModalFooter,{children:[jsx(Button,{variant:"light",onPress:z.onClose,children:y("common.cancel")}),O&&jsx(Button,{color:"primary",onPress:()=>{window.open(O,"_blank","noopener,noreferrer"),z.onClose();},children:y("predict.trade.goToKYC")})]})]})})]})}function bt({event:e,market:t,variant:n,initialSide:o,initialOutcome:r,chain:i}){let{outcome:s,side:l,orderType:a,quantity:c,limitPrice:d,shares:p,estimatedCost:u,potentialPayout:m,potentialProfit:f,usdcBalance:g,yesTokenBalance:v,noTokenBalance:h,isBalanceLoading:D,isSubmitting:T,validation:M,supportsLimitOrder:O,kycRequired:Z,kycUrl:R,expirationEnabled:ie,expirationPreset:K,customDuration:fe,customDurationUnit:Me,setOutcome:X,setSide:Q,setOrderType:le,setQuantity:he,setLimitPrice:be,setExpirationEnabled:S,setExpirationPreset:E,setCustomDuration:I,setCustomDurationUnit:y,submit:$}=tn({market:t,initialSide:o,initialOutcome:r}),q=useAuthCallback($),z=useMemo(()=>e?Yr(e):void 0,[e]),Pe=useMemo(()=>qr(t),[t]);return jsx(cn,{event:z,market:Pe,variant:n,outcome:s,side:l,orderType:a,quantity:c,limitPrice:d,shares:p,estimatedCost:u,potentialPayout:m,potentialProfit:f,usdcBalance:g,yesTokenBalance:v,noTokenBalance:h,isBalanceLoading:D,isSubmitting:T,isValid:M.isValid,validationErrors:M.errors,supportsLimitOrder:O,kycRequired:Z,kycUrl:R,expirationEnabled:ie,expirationPreset:K,customDuration:fe,customDurationUnit:Me,onOutcomeChange:X,onSideChange:Q,onOrderTypeChange:le,onQuantityChange:he,onLimitPriceChange:be,onExpirationEnabledChange:S,onExpirationPresetChange:E,onCustomDurationChange:I,onCustomDurationUnitChange:y,onSubmit:q})}var Je="predict-trade";function yt({id:e=Je}){return jsx(AsyncModal,{id:e,children:t=>jsx(oa,{...t})})}function oa({params:e,isOpen:t,onOpenChange:n}){let{isMobile:o}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:n,size:o?"lg":"md",backdrop:"blur",radius:"lg",children:jsx(ModalContent,{children:jsx(ModalBody,{className:"p-2",children:jsx(bt,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,initialSide:"buy",chain:e.chain,variant:"flat"})})})}):null}var nr={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function or(e){let t=0;return e.source&&t++,e.timeRemaining&&t++,e.minVolume&&t++,e.minLiquidity&&t++,t}function pn({isOpen:e,onClose:t,value:n,onChange:o}){let{t:r}=useTranslation(),[i,s]=useState(n),l=useCallback(v=>{v?s(n):t();},[n,t]),a=useCallback(()=>{s(nr);},[]),c=useCallback(()=>{o(i),t();},[i,o,t]),d=useCallback((v,h)=>{s(D=>({...D,[v]:h}));},[]),p=useMemo(()=>or(i),[i]),u=useMemo(()=>[{value:void 0,label:r("predict.filter.all")},{value:"polymarket",label:r("predict.platform.polymarket")},{value:"kalshi",label:r("predict.platform.kalshi")}],[r]),m=useMemo(()=>[{value:void 0,label:r("predict.filter.all")},{value:"1d",label:r("predict.filter.lessThanDay")},{value:"7d",label:r("predict.filter.lessThanWeek")},{value:"30d",label:r("predict.filter.lessThanMonth")}],[r]),f=useMemo(()=>[{value:void 0,label:r("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[r]),g=useMemo(()=>[{value:void 0,label:r("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[r]);return jsx(StyledModal,{isOpen:e,onOpenChange:l,size:"md",scrollBehavior:"inside",children:jsxs(ModalContent,{children:[jsx(ModalHeader,{className:"px-4 py-2",children:jsx("span",{className:"text-base font-semibold",children:r("predict.filter.title")})}),jsxs(ModalBody,{className:"flex flex-col gap-5",children:[jsx(Nt,{label:r("predict.filter.platform"),children:jsx(wt,{options:u,selected:i.source,onSelect:v=>d("source",v)})}),jsx(Nt,{label:r("predict.filter.timeRemaining"),children:jsx(wt,{options:m,selected:i.timeRemaining,onSelect:v=>d("timeRemaining",v)})}),jsx(Nt,{label:r("predict.filter.minVolume"),children:jsx(wt,{options:f,selected:i.minVolume,onSelect:v=>d("minVolume",v)})}),jsx(Nt,{label:r("predict.filter.minLiquidity"),children:jsx(wt,{options:g,selected:i.minLiquidity,onSelect:v=>d("minLiquidity",v)})})]}),jsx(ModalFooter,{className:"px-4",children:jsxs("div",{className:"w-full flex justify-between items-center",children:[jsx(Button,{variant:"light",color:"default",size:"sm",radius:"full",startContent:jsx(RefreshIcon,{width:16,height:16}),onPress:a,children:r("predict.filter.reset")}),jsxs(Button,{color:"primary",size:"sm",radius:"full",onPress:c,children:[r("predict.filter.showResults"),p>0&&jsxs("span",{className:"ml-1 text-xs opacity-80",children:["(",p,")"]})]})]})})]})})}function Nt({label:e,children:t}){return jsxs("div",{className:"flex flex-col gap-2.5",children:[jsx("span",{className:"text-sm font-semibold text-foreground",children:e}),t]})}function wt({options:e,selected:t,onSelect:n,allowDeselect:o=true}){return jsx("div",{className:"flex flex-wrap gap-2",children:e.map(r=>{let i=t===r.value;return jsx("button",{type:"button",onClick:()=>{n(i&&o?void 0:r.value);},className:cn$1("shrink-0 rounded-lg px-3 py-1.5 text-xs font-medium transition-colors duration-150 cursor-pointer border",i?"bg-primary/15 text-primary border-primary/40":"bg-content2 text-foreground/60 border-default-100 hover:bg-default-100 hover:text-foreground"),children:r.label},r.value??"__all")})})}var vn={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},fn={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},ka=["start_time","volume","liquidity","ending_soon"];function xn({sortPreset:e,onSortChange:t,sortAsc:n,onSortAscChange:o,onFilterPress:r,filterCount:i=0,className:s}){let{t:l}=useTranslation(),[a,c]=useState(false),d=useRef(null);useEffect(()=>{if(!a)return;let u=f=>{d.current&&!d.current.contains(f.target)&&c(false);},m=f=>{f.key==="Escape"&&c(false);};return document.addEventListener("mousedown",u),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",m);}},[a]);let p=gn[e];return jsxs("div",{className:cn$1("flex items-center gap-2",s),children:[jsxs("div",{ref:d,className:"relative flex shrink-0 items-center rounded-full border border-border",children:[jsxs("button",{type:"button",onClick:()=>c(u=>!u),className:"flex shrink-0 items-center gap-2 px-3 py-1.5 text-xs font-medium text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:[jsx(p,{className:"size-[18px] shrink-0"}),jsx("span",{className:"whitespace-nowrap",children:l(fn[e])})]}),jsx("div",{className:"h-6 w-px bg-border"}),jsx("button",{type:"button",onClick:()=>o(!n),className:"px-2.5 py-1.5 text-xs text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:n?"\u2191":"\u2193"}),a&&jsx("div",{className:"absolute left-0 top-full z-20 mt-1 flex min-w-max flex-col gap-0.5 rounded-lg border border-border bg-content1 p-1 shadow-lg",children:ka.map(u=>{let m=gn[u];return jsxs("button",{type:"button",onClick:()=>{t(u),c(false);},className:cn$1("flex w-full items-center gap-2 rounded px-2.5 py-1.5 text-xs font-medium transition-colors cursor-pointer",u===e?"bg-primary/10 text-primary":"text-neutral hover:bg-content2 hover:text-foreground"),children:[jsx(m,{className:"size-4 shrink-0"}),jsx("span",{children:l(fn[u])})]},u)})})]}),jsx(StyledBadge,{content:i>0?i:void 0,color:"primary",size:"sm",isInvisible:i===0,children:jsxs("button",{type:"button",onClick:r,className:"flex shrink-0 items-center gap-2 rounded-full border border-border px-3 py-1.5 text-xs font-medium text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:[jsx(FilterIcon,{className:"size-[18px]"}),jsx("span",{className:"whitespace-nowrap",children:l("predict.filter.title")})]})})]})}var gn={start_time:CalendarIcon,volume:ChartLineIcon,liquidity:DropletIcon,ending_soon:TimerIcon};function yn(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]),{data:n,isLoading:o,isFetching:r,isFetchingNextPage:i,isError:s,error:l,hasNextPage:a,fetchNextPage:c,refetch:d}=useInfiniteEvents(t),p=useMemo(()=>n?.pages.flatMap(f=>f.items).filter(f=>f!=null)??[],[n]),u=useCallback(()=>{c();},[c]),m=useCallback(()=>{d();},[d]);return {data:p,isLoading:o,isFetching:r&&!i,isFetchingMore:i,isError:s,error:l??null,hasMore:a??false,fetchMore:u,refetch:m}}function sr({count:e=6}){return jsx("div",{className:"grid w-full grid-cols-1 gap-0 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:Array.from({length:e}).map((t,n)=>jsx("div",{className:"p-2",children:jsxs("div",{className:"flex h-full min-h-52 flex-col rounded-xl border border-border/90 bg-background p-3 lg:min-h-72 lg:p-4",children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx(Skeleton,{className:"size-10 shrink-0 rounded-lg"}),jsxs("div",{className:"flex flex-1 flex-col gap-1",children:[jsx(Skeleton,{className:"h-4 w-11/12 rounded"}),jsx(Skeleton,{className:"h-3 w-2/5 rounded"})]})]}),jsxs("div",{className:"mt-3 flex flex-1 flex-col gap-2 lg:gap-3",children:[jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsx(Skeleton,{className:"h-7 w-1/2 rounded"}),jsx(Skeleton,{className:"h-7 w-[85px] rounded-lg lg:h-9 lg:w-24"})]}),jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsx(Skeleton,{className:"h-7 w-3/5 rounded"}),jsx(Skeleton,{className:"h-7 w-[85px] rounded-lg lg:h-9 lg:w-24"})]}),jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsx(Skeleton,{className:"h-7 w-2/5 rounded"}),jsx(Skeleton,{className:"h-7 w-[85px] rounded-lg lg:h-9 lg:w-24"})]})]}),jsxs("div",{className:"mt-auto flex items-center justify-between pt-3",children:[jsx(Skeleton,{className:"h-3 w-20 rounded"}),jsx(Skeleton,{className:"h-3 w-24 rounded"})]})]})},n))})}function xu({count:e=48}){return jsxs("div",{className:"flex h-full w-full max-w-[1680px] mx-auto flex-col gap-y-3",children:[jsxs("div",{className:"flex min-h-8 items-center justify-between gap-3 lg:min-h-9",children:[jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[jsx(Skeleton,{className:"h-6 w-16 rounded"}),jsx(Skeleton,{className:"h-6 w-20 rounded"}),jsx(Skeleton,{className:"h-6 w-16 rounded"}),jsx(Skeleton,{className:"h-6 w-20 rounded"})]}),jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[jsx(Skeleton,{className:"h-7 w-28 rounded-full"}),jsx(Skeleton,{className:"h-7 w-24 rounded-full"})]})]}),jsx("div",{className:"min-h-0 flex-1",children:jsx(sr,{count:e})})]})}var Sn=3,ir={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},Cn={bg:"hsl(var(--heroui-secondary) / 0.14)",text:"hsl(var(--heroui-secondary))",shadow:"hsl(var(--heroui-secondary) / 0.18)"},Ia={bg:"rgba(239, 68, 68, 0.14)",text:"rgb(239, 68, 68)",shadow:"rgba(239, 68, 68, 0.18)"},tt=[{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 Nn(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)}function _a(e){let t=e.outcomes?.map(s=>s.label?.toLowerCase().trim()??"")??[];if(t.some(s=>s==="up")&&t.some(s=>s==="down"))return [ir,Ia];if(t.some(s=>s==="yes")&&t.some(s=>s==="no"))return [ir,Cn];let n=t[0]??"",o=t[1]??"",r=Nn(n)%tt.length,i=Nn(o)%tt.length;return i===r&&(i=(i+1)%tt.length),[tt[r],tt[i]]}function Da(e){let t=e.outcomes?.[0];return t?t.best_ask??t.price??null:null}function Tn(e){let t=Da(e);return t!=null?parseFloat((t*100).toFixed(2)):0}function Mn(e){return e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function wn(e){let t=e.outcomes?.[0],n=t?.best_ask??t?.price??0;return parseFloat((n*100).toFixed(2)).toString()}function kn(e){let t=e.outcomes?.[1];if(t){let r=t.best_ask??t.price??0;return parseFloat((r*100).toFixed(2)).toString()}let n=e.outcomes?.[0],o=n?.best_ask??n?.price??0;return parseFloat(((1-o)*100).toFixed(2)).toString()}function Aa(e){let t=new Date(e).getTime()-Date.now();if(t<=0)return null;let n=Math.floor(t/864e5),o=Math.floor(t%864e5/36e5),r=Math.floor(t%36e5/6e4),i=[];return n>0&&i.push(`${n}d`),o>0&&i.push(`${o}h`),i.push(`${r}m`),i.join(" ")}var Fa=`
1
+ import {createContext,memo,useRef,forwardRef,useState,useMemo,useImperativeHandle,useEffect,useCallback,useContext,Fragment as Fragment$1,Component}from'react';import {PolymarketIcon,KalshiIcon,cn as cn$1,Skeleton,toast,useDisclosure,Tabs,Tab,StyledNumberInput,StyledSwitch,Select,SelectItem,ChevronDownIcon,Button,Modal,ModalContent,ModalHeader,ModalBody,ModalFooter,useScreen,StyledModal,RefreshIcon,TimerIcon,DropletIcon,ChartLineIcon,CalendarIcon,StyledBadge,FilterIcon,Linkable,Avatar,ChevronUpIcon,Spinner,OrderbookTableIcon,OrderbookDepthIcon,Dropdown,DropdownTrigger,DropdownMenu,DropdownItem,ChevronRightIcon,ChevronLeftIcon,TrashIcon,Chip,StyledInput,XCloseIcon,Kbd,SearchIcon,EmptyIcon}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,useSwitchChain,useAuthCallback}from'@liberfi.io/wallet-connector';import {keepPreviousData,useQueryClient,useQueries}from'@tanstack/react-query';import Ir from'canvas-confetti';import {ChartRange,useInfiniteMatches,useBalance,usePredictClient,PolymarketContext,useDFlowQuote,usePositions,useDFlowSubmit,useOrder,buildCtfExchangeDomain,buildOrderMessage,CTF_ORDER_TYPES,buildSignedOrder,buildPolymarketL2Headers,resolveEventsParams,useInfiniteEvents,useInfiniteOrders,useCancelOrder,useInfiniteTrades,useOrderbook,useMarketHistory,useEvent,useSimilarEvents,candlesticksQueryKey,useSearchEvents}from'@liberfi.io/react-predict';export{PredictClient,PredictContext,PredictProvider,PredictWsClient,createPredictClient,createPredictWsClient,fetchMatchesPage,matchQueryKey,matchesQueryKey,useBalance,useCancelOrder,useCandlesticks,useDFlowKYC,useDFlowQuote,useDFlowSubmit,useEvent,useEvents,useInfiniteEvents,useInfiniteMatches,useInfiniteOrders,useInfiniteTrades,useMarket,useMarketHistory,useMarketTrades,useMatch,useOrder,useOrderbook,useOrders,usePositions,usePredictClient,usePriceHistory,useSearchEvents,useSimilarEvents,useTrades}from'@liberfi.io/react-predict';import {ChainNamespace,Chain}from'@liberfi.io/types';import {SOLANA_TOKENS,debounce}from'@liberfi.io/utils';import {List}from'react-window';import {useInfiniteLoader}from'react-window-infinite-loader';import {useResizeObserver,useScrollCollapse,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';typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/ui-predict"]="0.1.94");var Ia="0.1.94";var Oa={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},In=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],Mr=(()=>{let e=t=>{let r=In.indexOf(t);return r===-1?In.length:r};return Object.entries(Oa).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 Dn({categories:e,selectedCategory:t,selectedTag:r,activeTags:o,onCategorySelect:n,onTagSelect:a,trailing:i,pulsingTab:s="Trending",className:l}){let{t:c}=useTranslation(),u=useCallback(()=>{n(null);},[n]),d=c("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-1 lg:px-2 lg:py-1",l),children:[jsxs("div",{className:"flex w-full items-center gap-2",children:[jsx("div",{className:"hideScrollbar min-w-0 flex-1 overflow-x-auto overflow-y-hidden",children:jsxs("div",{className:"flex min-h-8 items-stretch gap-x-2 lg:min-h-9",children:[jsx(On,{label:d,isSelected:t===null,onPress:u,showPulse:d===s}),jsx(Ha,{}),e.map(p=>jsx(On,{label:p.category,isSelected:t===p.category,onPress:()=>n(p.category),badge:p.badge,showPulse:p.category===s},p.category))]})}),i&&jsx("div",{className:"flex-shrink-0",children:i})]}),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 pl-2 lg:w-full lg:gap-x-2",children:[jsx(An,{label:c("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>a(null)}),o.map(p=>jsx(An,{label:p.label,icon:p.icon,isSelected:r===p.label,onPress:()=>a(p.label)},p.label))]})})]})}function On({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 p-1 text-base font-normal 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 Ha(){return jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function An({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-2 py-1 text-sm font-medium uppercase transition-colors cursor-pointer",r?"border-transparent bg-primary text-black":"border-border/80 text-neutral-200 hover:bg-primary/10 hover:text-primary"),children:[t&&jsx("span",{className:cn$1("iconify size-4",t)}),e]})}function um({count:e=6}){return jsx("div",{className:"flex w-full flex-col gap-2 px-4 py-1 lg:px-2 lg:py-1",children:jsx("div",{className:"flex min-h-8 items-center gap-x-2 lg:min-h-9",children:Array.from({length:e}).map((t,r)=>jsx(Skeleton,{className:"h-6 w-16 shrink-0 rounded"},r))})})}function Ba(e){return e.map(t=>({category:t.label,tags:t.tags.map(r=>r.label)}))}function $a(e){return e?e.tags.map(t=>({label:t.label,icon:t.icon})):[]}function Bn({onSelect:e,trailing:t,className:r}){let[o,n]=useState(null),[a,i]=useState(null),s=useCallback(p=>{n(p),i(null),e?.({categorySlug:p,tagSlug:null});},[e]),l=useCallback(p=>{i(p),e?.({categorySlug:o,tagSlug:p});},[o,e]),c=Ba(Mr),u=Mr.find(p=>p.slug===o),d=$a(u);return jsx(Dn,{categories:c,selectedCategory:o,selectedTag:a,activeTags:d,onCategorySelect:s,onTagSelect:l,trailing:t,className:r})}function $n(e){return {title:e.title,imageUrl:e.image_url}}function Wn(e){let t=e.outcomes[0],r=e.outcomes[1];return {question:e.question,yesAsk:t?.best_ask??t?.price,noAsk:r?.best_ask??r?.price,yesBid:t?.best_bid,noBid:r?.best_bid,yesSubTitle:t?.label??"Yes",noSubTitle:r?.label??"No"}}var bt=48,Tr=4,Ut={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},Se={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},Kt=Se.ALL,ym={[Se.ONE_DAY]:Ut.ONE_MINUTE,[Se.ONE_WEEK]:Ut.ONE_HOUR,[Se.ONE_MONTH]:Ut.ONE_HOUR,[Se.ALL]:Ut.ONE_DAY},km={[Se.ONE_DAY]:300,[Se.ONE_WEEK]:3600,[Se.ONE_MONTH]:10800,[Se.ALL]:1440*60},Nm={[Se.ONE_DAY]:1440*60,[Se.ONE_WEEK]:10080*60,[Se.ONE_MONTH]:720*60*60,[Se.ALL]:null},Lr=1,Sm=1,wm=1,Pm=99,at={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},Cm=at.ONE_WEEK,Em={[at.ONE_HOUR]:60,[at.SIX_HOURS]:60,[at.ONE_DAY]:300,[at.ONE_WEEK]:1800,[at.MAX]:1800};var Kn=createContext(null);function _r(){let e=useContext(Kn);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var Va=3e4;function ja({pollingInterval:e=Va,enabled:t=true,children:r}){let o=useWallets(),n=useMemo(()=>o.find(m=>m.chainNamespace===ChainNamespace.SOLANA&&m.isConnected)?.address,[o]),a=useMemo(()=>o.find(m=>m.chainNamespace===ChainNamespace.EVM&&m.isConnected)?.address,[o]),{data:i,isLoading:s,error:l}=useBalance({source:"kalshi",user:n??""},{enabled:t&&!!n,refetchInterval:e}),{data:c,isLoading:u,error:d}=useBalance({source:"polymarket",user:a??""},{enabled:t&&!!a,refetchInterval:e}),p=useMemo(()=>({solanaAddress:n,evmAddress:a,dflowUsdcBalance:i?Number(i.balance):null,polymarketUsdcBalance:c?Number(c.balance):null,isLoading:s||u,error:l??d??null}),[n,a,i,c,s,u,l,d]);return jsx(Kn.Provider,{value:p,children:r})}var pi={minutes:60,hours:3600,days:86400};function mi(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*pi[r]}}function Yn(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};Ir({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{Ir({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{Ir({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function qn({market:e,initialOutcome:t="yes",initialSide:r="buy"}){let{t:o}=useTranslation(),{status:n}=useAuth(),a=useWallets(),i=useSwitchChain(),s=usePredictClient(),l=useContext(PolymarketContext),c=useQueryClient(),u=e.source,d=u==="polymarket",p=a.find(M=>M.chainNamespace===ChainNamespace.SOLANA&&M.isConnected),m=a.find(M=>M.chainNamespace===ChainNamespace.EVM&&M.isConnected&&"switchChain"in M),g=n==="authenticated",f=p?.address,h=m?.address,[x,R]=useState(t),[N,w]=useState(r),[v,B]=useState("market"),[b,X]=useState(NaN),[j,ie]=useState(NaN),[U,F]=useState(false),[W,$]=useState(null),[oe,pe]=useState(false),[C,A]=useState(null),[K,P]=useState(false),[ne,me]=useState("1h"),[le,Ve]=useState(30),[Qe,vr]=useState("minutes"),Ae=null;try{let M=_r();Ae={dflowUsdcBalance:M.dflowUsdcBalance,polymarketUsdcBalance:M.polymarketUsdcBalance,isLoading:M.isLoading};}catch{}let Ne=useMemo(()=>{let M=x==="yes"?0:1,J=e.outcomes[M];return N==="buy"?J?.best_ask??J?.price??.5:J?.best_bid??J?.price??.5},[e.outcomes,x,N]),br=useCallback(M=>{B(M);},[]),yr=useCallback(M=>{R(M),ie(NaN);},[]);useEffect(()=>{v==="limit"&&isNaN(j)&&ie(Math.round(Ne*100)/100);},[v,j,Ne]);let ht=useMemo(()=>isNaN(b)||b<=0?0:N==="buy"?Ne>0?b/Ne:0:b,[N,b,Ne]),st=useMemo(()=>isNaN(b)||b<=0?"0":String(Math.round(b*1e6)),[b]),D=e.provider_meta?.["dflow.yesMint"]??"",Ee=e.provider_meta?.["dflow.noMint"]??"",Ze=e.provider_meta?.["dflow.collateralMint"]||SOLANA_TOKENS.stablecoins.USDC.address,wn=x==="yes"?D:Ee,xt=N==="buy"?Ze:wn,vt=N==="buy"?wn:Ze,ha=u==="kalshi"&&!!xt&&!!vt&&!!f&&st!=="0",{refetch:Pn}=useDFlowQuote({inputMint:xt,outputMint:vt,amount:st,userPublicKey:f??"",slippageBps:100},{enabled:ha}),Cn=u==="kalshi"?f??"":h??"",{data:De,isLoading:xa}=usePositions({source:u,user:Cn},{enabled:!!Cn}),Bt=useMemo(()=>Ae?u==="kalshi"?Ae.dflowUsdcBalance:Ae.polymarketUsdcBalance:De&&De.positions.reduce((J,Fe)=>Fe.side==="USDC"||Fe.side==="collateral"?J+(Fe.current_value??0):J,0)||null,[Ae,De,u]),va=Ae?Ae.isLoading:xa,kr=useMemo(()=>De?De.positions.find(J=>J.side?.toLowerCase()==="yes"&&J.market?.slug===e.slug)?.size??0:null,[De,e.slug]),Nr=useMemo(()=>De?De.positions.find(J=>J.side?.toLowerCase()==="no"&&J.market?.slug===e.slug)?.size??0:null,[De,e.slug]),Sr=useMemo(()=>v==="limit"&&d&&!isNaN(j)?j:Ne,[v,d,j,Ne]),$t=useMemo(()=>{if(isNaN(b)||b<=0)return 0;if(N==="buy")return b;let M=x==="yes"?e.outcomes[0]?.best_bid??0:e.outcomes[1]?.best_bid??0;return b*M},[N,x,b,e.outcomes]),En=useMemo(()=>isNaN(b)||b<=0?0:N==="buy"?Sr>0?b/Sr*1:0:$t,[N,b,Sr,$t]),ba=En-$t,ya=useCallback(M=>{w(M),X(NaN);},[]),ka=useCallback(M=>{if(isNaN(M)){X(NaN);return}let J=Math.max(0,M),Fe=N==="buy"?Math.round(J*100)/100:Math.round(J);X(Fe);},[N]),Na=useCallback(M=>{if(isNaN(M)){ie(NaN);return}let J=Math.max(.01,Math.min(.99,M));ie(Math.round(J*100)/100);},[]),wr=useMemo(()=>{let M=[];(isNaN(b)||b<Lr)&&M.push(`Minimum quantity is ${Lr}`),e.status!=="open"&&M.push("Market is not active"),N==="buy"&&Bt!=null&&!isNaN(b)&&b>0&&b>Bt&&M.push("Insufficient USDC balance");let J=x==="yes"?kr:Nr;return N==="sell"&&J!=null&&!isNaN(b)&&b>0&&b>J&&M.push("Insufficient shares"),v==="limit"&&d&&(isNaN(j)||j<.01||j>.99)&&M.push("Limit price must be between $0.01 and $0.99"),v==="limit"&&d&&K&&ne==="custom"&&(isNaN(le)||le<=0)&&M.push(o("predict.trade.expiration.invalidDate")),{isValid:M.length===0,errors:M}},[b,e.status,N,Bt,kr,Nr,x,v,d,j,K,ne,le,o]),{mutateAsync:Mn}=useDFlowSubmit(),{data:Pr}=useOrder({id:W??"",source:u},{enabled:!!W});useEffect(()=>{if(!Pr||!W)return;let{status:M}=Pr;M==="closed"?(F(false),$(null),toast.success(o("predict.trade.submitSuccess")),Yn(),X(NaN)):(M==="failed"||M==="expired")&&(F(false),$(null),toast.error(o("predict.trade.submitError")));},[Pr,W,o]);let Tn=useCallback(async()=>{if(!f||!p)return;if(!xt||!vt){toast.error("Missing token mint addresses"),F(false);return}let M=await s.checkDFlowKYC(f);if(!M.verified){pe(true),A(M.kyc_url||null),F(false);return}let He=(await Pn()).data?.transaction;if(!He){toast.error(o("predict.trade.submitError")),F(false);return}let Be=Uint8Array.from(atob(He),Wt=>Wt.charCodeAt(0)),Cr=await p.signTransaction(Be),Er=await Mn({signedTransaction:btoa(String.fromCharCode(...Cr)),orderContext:{user_public_key:f,input_mint:xt,output_mint:vt,amount:st,price:String(Ne),side:N==="buy"?"BUY":"SELL",outcome:x==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});$(Er.signature);},[f,p,s,Pn,Mn,xt,vt,st,Ne,N,x,e.slug,o]),Ln=useCallback(async()=>{if(!m||!l)return;let M=m.chain,J=M!==Chain.POLYGON;J&&await i(Chain.POLYGON);try{let Fe=await m.getEip1193Provider();if(!Fe){toast.error(o("predict.trade.submitError")),F(!1);return}let He={address:m.address,signatureType:0,signTypedData:async(La,Ra,_a)=>await Fe.request({method:"eth_signTypedData_v4",params:[m.address,JSON.stringify({domain:La,types:Ra,message:_a})]})},Be=l.credentials;if(!Be&&(await l.authenticate(He),Be=l.credentials,!Be))throw new Error("Polymarket authentication failed");let Cr=x==="yes"?0:1,Er=e.provider_meta?.[`polymarket.tokenId${Cr}`]??e.provider_meta?.["polymarket.conditionId"]??"",Wt=e.provider_meta?.["polymarket.negRisk"]??!1,wa=v==="limit"&&!isNaN(j)?j:Ne,Rn={tokenId:Er,price:wa,size:b,side:N==="buy"?"BUY":"SELL",orderType:v==="limit"?K?"GTD":"GTC":"FOK",tickSize:"0.01",negRisk:Wt,...v==="limit"&&K&&{expiration:mi(ne,le,Qe)}},Pa=buildCtfExchangeDomain(Wt),Ca=buildOrderMessage({...Rn,signerAddress:He.address,signatureType:He.signatureType}),Ea=await He.signTypedData(Pa,CTF_ORDER_TYPES,Ca),_n=buildSignedOrder({...Rn,signerAddress:He.address,signatureType:He.signatureType,signature:Ea}),Ma=JSON.stringify(_n),Ta=await buildPolymarketL2Headers(Be.address,{apiKey:Be.apiKey,secret:Be.secret,passphrase:Be.passphrase,method:"POST",requestPath:"/api/v1/orders/polymarket",body:Ma});await s.createPolymarketOrder(_n,Ta),c.invalidateQueries({queryKey:["predict","orders"]}),c.invalidateQueries({queryKey:["predict","positions"]}),toast.success(o("predict.trade.submitSuccess")),Yn(),X(NaN),F(!1);}finally{J&&M&&i(M).catch(()=>{});}},[m,l,i,x,e.provider_meta,v,j,Ne,b,N,s,c,K,ne,le,Qe,o]),Sa=useCallback(async()=>{if(!(!wr.isValid||!g)){F(true),$(null),pe(false);try{u==="kalshi"?await Tn():await Ln();}catch{toast.error(o("predict.trade.submitError")),F(false);}}},[wr.isValid,g,u,Tn,Ln,o]);return {outcome:x,side:N,orderType:v,quantity:b,limitPrice:j,shares:ht,estimatedCost:$t,potentialPayout:En,potentialProfit:ba,usdcBalance:Bt,yesTokenBalance:kr,noTokenBalance:Nr,isBalanceLoading:va,isSubmitting:U,validation:wr,supportsLimitOrder:d,kycRequired:oe,kycUrl:C,expirationEnabled:K,expirationPreset:ne,customDuration:le,customDurationUnit:Qe,setOutcome:yr,setSide:ya,setOrderType:br,setQuantity:ka,setLimitPrice:Na,setExpirationEnabled:P,setExpirationPreset:me,setCustomDuration:Ve,setCustomDurationUnit:vr,submit:Sa}}var Ci=`https://s1.chainstream.io/chains/sol/tokens/${SOLANA_TOKENS.stablecoins.USDC.address}/image.png`,Ei=["5m","1h","12h","24h","eod","custom"],Mi={"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"},Ti=["minutes","hours","days"],Li={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"};function ro({event:e,market:t,variant:r="bordered",outcome:o,side:n,orderType:a,quantity:i,limitPrice:s,shares:l,potentialProfit:c,potentialPayout:u,estimatedCost:d,usdcBalance:p,yesTokenBalance:m,noTokenBalance:g,isBalanceLoading:f,isSubmitting:h,isValid:x,validationErrors:R,supportsLimitOrder:N,kycRequired:w,kycUrl:v,expirationEnabled:B,expirationPreset:b,customDuration:X,customDurationUnit:j,onOutcomeChange:ie,onSideChange:U,onOrderTypeChange:F,onQuantityChange:W,onLimitPriceChange:$,onExpirationEnabledChange:oe,onExpirationPresetChange:pe,onCustomDurationChange:C,onCustomDurationUnitChange:A,onSubmit:K}){let{t:P}=useTranslation(),[ne,me]=useState(false),le=useDisclosure();useEffect(()=>{w&&!le.isOpen&&le.onOpen();},[w]);let Ve=useMemo(()=>{let D=n==="buy"?o==="yes"?t.yesAsk:t.noAsk:o==="yes"?t.yesBid:t.noBid;return D!=null?parseFloat((Number(D)*100).toFixed(2)):null},[n,o,t]),Qe=!isNaN(i)&&i>0,vr=useMemo(()=>{if(h)return P("predict.trade.submitting");if(w)return P("predict.trade.kycRequired");if(!Qe)return P("predict.trade.enterAmount");let D=P(n==="buy"?"predict.trade.buy":"predict.trade.sell"),Ee=P(o==="yes"?"predict.trade.yes":"predict.trade.no"),Ze=n==="buy"&&c>0?` \u2192 Win $${c.toFixed(2)}`:"";return `${D} ${Ee}${Ze}`},[h,w,Qe,n,o,c,P]),Ae=useMemo(()=>o==="yes"?"primary":"secondary",[o]),Ne=()=>{W(Math.floor((p??0)/2*100)/100);},br=()=>{W(p??0);},[yr,ht]=useState(false),st=()=>{if(w){le.onOpen();return}if(!x){ht(true);return}ht(false),K();};return jsxs(Fragment,{children:[jsxs("div",{className:cn$1("flex w-full flex-col gap-y-4 p-4",r==="bordered"&&"rounded-xl border border-default-200 bg-content1"),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:o==="yes"?"text-bullish":"text-bearish",children:[P(n==="buy"?"predict.trade.buy":"predict.trade.sell")," ",P(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:[N?jsxs(Tabs,{variant:"underlined",selectedKey:a,onSelectionChange:D=>F(D),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsx(Tab,{title:P("predict.trade.market")},"market"),jsx(Tab,{title:P("predict.trade.limit")},"limit")]}):jsx("span",{className:"text-sm font-medium text-foreground",children:P("predict.trade.market")}),a==="limit"&&N?jsx(StyledNumberInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",value:isNaN(s)?void 0:parseFloat((s*100).toFixed(2)),onValueChange:D=>$(D/100),minValue:1,maxValue:99,step:1,formatOptions:{maximumFractionDigits: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"}}):Ve!=null&&jsxs("span",{className:"text-xl font-bold tabular-nums",children:[Ve," \xA2"]})]}),jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(D=>{let Ee=D==="yes"?m:g;return jsxs("div",{className:"flex flex-1 flex-col gap-y-1",children:[jsxs("button",{type:"button",onClick:()=>ie(D),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${o===D?D==="yes"?"border-primary bg-primary-50 text-primary":"border-secondary bg-secondary-50 text-secondary":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsx("span",{children:P(D==="yes"?"predict.trade.yes":"predict.trade.no")}),(()=>{let Ze=n==="buy"?D==="yes"?t.yesAsk:t.noAsk:D==="yes"?t.yesBid:t.noBid;return Ze!=null?jsxs("span",{className:"ml-1 opacity-70",children:[parseFloat((Number(Ze)*100).toFixed(2)),"\xA2"]}):null})()]}),n==="sell"&&o===D&&jsx("span",{className:"text-center text-xs text-foreground",children:f?"\u2013":`${Ee??0} shares`})]},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:P(n==="buy"?"predict.trade.youArePaying":"predict.trade.contracts")}),n==="buy"&&jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("img",{src:Ci,alt:"USDC",className:"h-3.5 w-3.5 rounded-full object-cover"}),jsx("span",{className:"font-medium text-foreground tabular-nums",children:p!=null?`${p.toFixed(2)} USDC`:"\u2013"}),jsx("button",{type:"button",onClick:Ne,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:P("predict.trade.half")}),jsx("button",{type:"button",onClick:br,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:P("predict.trade.max")})]})]}),jsx(StyledNumberInput,{fullWidth:true,placeholder:"0",radius:"lg",size:"lg",value:isNaN(i)?void 0:i,onValueChange:D=>{ht(false),W(D);},minValue:0,step:n==="buy"?.01:1,formatOptions:n==="buy"?{maximumFractionDigits:2}:{maximumFractionDigits:0},startContent:n==="buy"?jsx("span",{className:"text-default-600 text-xl",children:"$"}):void 0,classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}},n),n==="sell"&&jsxs("div",{className:"flex gap-x-2 justify-end",children:[[25,50].map(D=>jsxs("button",{type:"button",onClick:()=>{W(Math.floor((o==="yes"?m??0:g??0)*D/100));},className:"rounded-md bg-content2 px-2.5 py-1 text-xs font-medium text-default-600 transition-colors hover:bg-content3 cursor-pointer",children:[D,"%"]},D)),jsx("button",{type:"button",onClick:()=>{W(o==="yes"?m??0:g??0);},className:"rounded-md bg-content2 px-2.5 py-1 text-xs font-medium text-default-600 transition-colors hover:bg-content3 cursor-pointer",children:P("common.all")})]}),yr&&R.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:R.map(D=>jsx("span",{className:"text-xs text-danger",children:D},D))})]}),a==="limit"&&N&&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:P("predict.trade.setExpiration")}),jsx(StyledSwitch,{size:"sm",color:"primary",isSelected:B,onValueChange:oe,"aria-label":P("predict.trade.setExpiration")})]}),B&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":P("predict.trade.setExpiration"),selectedKeys:[b],onSelectionChange:D=>{let Ee=Array.from(D)[0];Ee&&pe(Ee);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Ei.map(D=>jsx(SelectItem,{children:P(Mi[D])},D))}),b==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(X)?void 0:X,onValueChange:C,minValue:1,step:1,formatOptions:{maximumFractionDigits:0},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:D=>{let Ee=Array.from(D)[0];Ee&&A(Ee);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Ti.map(D=>jsx(SelectItem,{children:P(Li[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:()=>me(D=>!D),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{children:P("predict.trade.odds")}),jsx(ChevronDownIcon,{className:cn$1("h-3.5 w-3.5 transition-transform",ne&&"rotate-180")})]}),Ve!=null&&jsxs("span",{className:"text-foreground font-medium tabular-nums",children:[Ve,"% chance"]})]}),ne&&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:"Total Size"}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${d.toFixed(2)}`:"\u2013"})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:"No. of Contracts"}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(l)&&l>0?parseFloat(l.toFixed(2)):"\u2013"})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:"Payout"}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${u.toFixed(2)}`:"\u2013"})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:"Est. Profit"}),jsx("span",{className:"tabular-nums text-bullish",children:!isNaN(i)&&i>0&&c>0?`+$${c.toFixed(2)}`:"\u2013"})]})]})]}),jsx(Button,{color:Ae,fullWidth:true,radius:"lg",size:"lg",isDisabled:!Qe||h,isLoading:h,onPress:st,children:vr})]}),jsx(Modal,{isOpen:le.isOpen,onClose:le.onClose,size:"md",children:jsxs(ModalContent,{children:[jsx(ModalHeader,{className:"flex flex-col gap-1",children:jsxs("span",{className:"text-lg",children:["\u{1F6E1}\uFE0F ",P("predict.trade.kycModalTitle")]})}),jsxs(ModalBody,{className:"gap-y-4",children:[jsx("p",{className:"text-sm text-default-600",children:P("predict.trade.kycModalDescription")}),jsxs("ul",{className:"flex flex-col gap-y-2 text-sm text-foreground",children:[jsxs("li",{className:"flex items-start gap-x-2",children:[jsx("span",{className:"mt-0.5 text-primary",children:"\u2713"}),jsx("span",{children:P("predict.trade.kycModalBullet1")})]}),jsxs("li",{className:"flex items-start gap-x-2",children:[jsx("span",{className:"mt-0.5 text-primary",children:"\u2713"}),jsx("span",{children:P("predict.trade.kycModalBullet2")})]}),jsxs("li",{className:"flex items-start gap-x-2",children:[jsx("span",{className:"mt-0.5 text-primary",children:"\u2713"}),jsx("span",{children:P("predict.trade.kycModalBullet3")})]})]}),jsx("p",{className:"text-xs text-default-400",children:P("predict.trade.kycModalNote")})]}),jsxs(ModalFooter,{children:[jsx(Button,{variant:"light",onPress:le.onClose,children:P("common.cancel")}),v&&jsx(Button,{color:"primary",onPress:()=>{window.open(v,"_blank","noopener,noreferrer"),le.onClose();},children:P("predict.trade.goToKYC")})]})]})})]})}function Vt({event:e,market:t,variant:r,initialSide:o,initialOutcome:n,chain:a}){let{outcome:i,side:s,orderType:l,quantity:c,limitPrice:u,shares:d,estimatedCost:p,potentialPayout:m,potentialProfit:g,usdcBalance:f,yesTokenBalance:h,noTokenBalance:x,isBalanceLoading:R,isSubmitting:N,validation:w,supportsLimitOrder:v,kycRequired:B,kycUrl:b,expirationEnabled:X,expirationPreset:j,customDuration:ie,customDurationUnit:U,setOutcome:F,setSide:W,setOrderType:$,setQuantity:oe,setLimitPrice:pe,setExpirationEnabled:C,setExpirationPreset:A,setCustomDuration:K,setCustomDurationUnit:P,submit:ne}=qn({market:t,initialSide:o,initialOutcome:n}),me=useAuthCallback(ne),le=useMemo(()=>e?$n(e):void 0,[e]),Ve=useMemo(()=>Wn(t),[t]);return jsx(ro,{event:le,market:Ve,variant:r,outcome:i,side:s,orderType:l,quantity:c,limitPrice:u,shares:d,estimatedCost:p,potentialPayout:m,potentialProfit:g,usdcBalance:f,yesTokenBalance:h,noTokenBalance:x,isBalanceLoading:R,isSubmitting:N,isValid:w.isValid,validationErrors:w.errors,supportsLimitOrder:v,kycRequired:B,kycUrl:b,expirationEnabled:X,expirationPreset:j,customDuration:ie,customDurationUnit:U,onOutcomeChange:F,onSideChange:W,onOrderTypeChange:$,onQuantityChange:oe,onLimitPriceChange:pe,onExpirationEnabledChange:C,onExpirationPresetChange:A,onCustomDurationChange:K,onCustomDurationUnitChange:P,onSubmit:me})}var yt="predict-trade";function jt({id:e=yt}){return jsx(AsyncModal,{id:e,children:t=>jsx(Hi,{...t})})}function Hi({params:e,isOpen:t,onOpenChange:r}){let{isMobile:o}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:o?"lg":"md",backdrop:"blur",radius:"lg",children:jsx(ModalContent,{children:jsx(ModalBody,{className:"p-2",children:jsx(Vt,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,initialSide:"buy",chain:e.chain,variant:"flat"})})})}):null}var Fr={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function Hr(e){let t=0;return e.source&&t++,e.timeRemaining&&t++,e.minVolume&&t++,e.minLiquidity&&t++,t}function so({isOpen:e,onClose:t,value:r,onChange:o}){let{t:n}=useTranslation(),[a,i]=useState(r),s=useCallback(h=>{h?i(r):t();},[r,t]),l=useCallback(()=>{i(Fr);},[]),c=useCallback(()=>{o(a),t();},[a,o,t]),u=useCallback((h,x)=>{i(R=>({...R,[h]:x}));},[]),d=useMemo(()=>Hr(a),[a]),p=useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"polymarket",label:n("predict.platform.polymarket")},{value:"kalshi",label:n("predict.platform.kalshi")}],[n]),m=useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"1d",label:n("predict.filter.lessThanDay")},{value:"7d",label:n("predict.filter.lessThanWeek")},{value:"30d",label:n("predict.filter.lessThanMonth")}],[n]),g=useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[n]),f=useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[n]);return jsx(StyledModal,{isOpen:e,onOpenChange:s,size:"md",scrollBehavior:"inside",children:jsxs(ModalContent,{children:[jsx(ModalHeader,{className:"px-4 py-2",children:jsx("span",{className:"text-base font-semibold",children:n("predict.filter.title")})}),jsxs(ModalBody,{className:"flex flex-col gap-5",children:[jsx(Yt,{label:n("predict.filter.platform"),children:jsx(qt,{options:p,selected:a.source,onSelect:h=>u("source",h)})}),jsx(Yt,{label:n("predict.filter.timeRemaining"),children:jsx(qt,{options:m,selected:a.timeRemaining,onSelect:h=>u("timeRemaining",h)})}),jsx(Yt,{label:n("predict.filter.minVolume"),children:jsx(qt,{options:g,selected:a.minVolume,onSelect:h=>u("minVolume",h)})}),jsx(Yt,{label:n("predict.filter.minLiquidity"),children:jsx(qt,{options:f,selected:a.minLiquidity,onSelect:h=>u("minLiquidity",h)})})]}),jsx(ModalFooter,{className:"px-4",children:jsxs("div",{className:"w-full flex justify-between items-center",children:[jsx(Button,{variant:"light",color:"default",size:"sm",radius:"full",startContent:jsx(RefreshIcon,{width:16,height:16}),onPress:l,children:n("predict.filter.reset")}),jsxs(Button,{color:"primary",size:"sm",radius:"full",onPress:c,children:[n("predict.filter.showResults"),d>0&&jsxs("span",{className:"ml-1 text-xs opacity-80",children:["(",d,")"]})]})]})})]})})}function Yt({label:e,children:t}){return jsxs("div",{className:"flex flex-col gap-2.5",children:[jsx("span",{className:"text-sm font-semibold text-foreground",children:e}),t]})}function qt({options:e,selected:t,onSelect:r,allowDeselect:o=true}){return jsx("div",{className:"flex flex-wrap gap-2",children:e.map(n=>{let a=t===n.value;return jsx("button",{type:"button",onClick:()=>{r(a&&o?void 0:n.value);},className:cn$1("shrink-0 rounded-lg px-3 py-1.5 text-xs font-medium transition-colors duration-150 cursor-pointer border",a?"bg-primary/15 text-primary border-primary/40":"bg-content2 text-foreground/60 border-default-100 hover:bg-default-100 hover:text-foreground"),children:n.label},n.value??"__all")})})}var co={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},io={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},ol=["start_time","volume","liquidity","ending_soon"];function uo({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:o,onFilterPress:n,filterCount:a=0,className:i}){let{t:s}=useTranslation(),[l,c]=useState(false),u=useRef(null);useEffect(()=>{if(!l)return;let p=g=>{u.current&&!u.current.contains(g.target)&&c(false);},m=g=>{g.key==="Escape"&&c(false);};return document.addEventListener("mousedown",p),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",m);}},[l]);let d=lo[e];return jsxs("div",{className:cn$1("flex items-center gap-2",i),children:[jsxs("div",{ref:u,className:"relative flex shrink-0 items-center rounded-full border border-border",children:[jsxs("button",{type:"button",onClick:()=>c(p=>!p),className:"flex shrink-0 items-center gap-2 px-3 py-1.5 text-xs font-medium text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:[jsx(d,{className:"size-[18px] shrink-0"}),jsx("span",{className:"whitespace-nowrap",children:s(io[e])})]}),jsx("div",{className:"h-6 w-px bg-border"}),jsx("button",{type:"button",onClick:()=>o(!r),className:"px-2.5 py-1.5 text-xs text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:r?"\u2191":"\u2193"}),l&&jsx("div",{className:"absolute left-0 top-full z-20 mt-1 flex min-w-max flex-col gap-0.5 rounded-lg border border-border bg-content1 p-1 shadow-lg",children:ol.map(p=>{let m=lo[p];return jsxs("button",{type:"button",onClick:()=>{t(p),c(false);},className:cn$1("flex w-full items-center gap-2 rounded px-2.5 py-1.5 text-xs font-medium transition-colors cursor-pointer",p===e?"bg-primary/10 text-primary":"text-neutral hover:bg-content2 hover:text-foreground"),children:[jsx(m,{className:"size-4 shrink-0"}),jsx("span",{children:s(io[p])})]},p)})})]}),jsx(StyledBadge,{content:a>0?a:void 0,color:"primary",size:"sm",isInvisible:a===0,children:jsxs("button",{type:"button",onClick:n,className:"flex shrink-0 items-center gap-2 rounded-full border border-border px-3 py-1.5 text-xs font-medium text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:[jsx(FilterIcon,{className:"size-[18px]"}),jsx("span",{className:"whitespace-nowrap",children:s("predict.filter.title")})]})})]})}var lo={start_time:CalendarIcon,volume:ChartLineIcon,liquidity:DropletIcon,ending_soon:TimerIcon};function fo(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]),{data:r,isLoading:o,isFetching:n,isFetchingNextPage:a,isError:i,error:s,hasNextPage:l,fetchNextPage:c,refetch:u}=useInfiniteEvents(t),d=useMemo(()=>r?.pages.flatMap(g=>g.items).filter(g=>g!=null)??[],[r]),p=useCallback(()=>{c();},[c]),m=useCallback(()=>{u();},[u]);return {data:d,isLoading:o,isFetching:n&&!a,isFetchingMore:a,isError:i,error:s??null,hasMore:l??false,fetchMore:p,refetch:m}}function Br({count:e=6}){return jsx("div",{className:"grid w-full grid-cols-1 gap-0 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:Array.from({length:e}).map((t,r)=>jsx("div",{className:"p-2",children:jsxs("div",{className:"flex h-full min-h-52 flex-col rounded-xl border border-border/90 bg-background p-3 lg:min-h-72 lg:p-4",children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx(Skeleton,{className:"size-10 shrink-0 rounded-lg"}),jsxs("div",{className:"flex flex-1 flex-col gap-1",children:[jsx(Skeleton,{className:"h-4 w-11/12 rounded"}),jsx(Skeleton,{className:"h-3 w-2/5 rounded"})]})]}),jsxs("div",{className:"mt-3 flex flex-1 flex-col gap-2 lg:gap-3",children:[jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsx(Skeleton,{className:"h-7 w-1/2 rounded"}),jsx(Skeleton,{className:"h-7 w-[85px] rounded-lg lg:h-9 lg:w-24"})]}),jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsx(Skeleton,{className:"h-7 w-3/5 rounded"}),jsx(Skeleton,{className:"h-7 w-[85px] rounded-lg lg:h-9 lg:w-24"})]}),jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsx(Skeleton,{className:"h-7 w-2/5 rounded"}),jsx(Skeleton,{className:"h-7 w-[85px] rounded-lg lg:h-9 lg:w-24"})]})]}),jsxs("div",{className:"mt-auto flex items-center justify-between pt-3",children:[jsx(Skeleton,{className:"h-3 w-20 rounded"}),jsx(Skeleton,{className:"h-3 w-24 rounded"})]})]})},r))})}function Ef({count:e=48}){return jsxs("div",{className:"flex h-full w-full max-w-[1680px] mx-auto flex-col gap-y-3",children:[jsxs("div",{className:"flex min-h-8 items-center justify-between gap-3 lg:min-h-9",children:[jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[jsx(Skeleton,{className:"h-6 w-16 rounded"}),jsx(Skeleton,{className:"h-6 w-20 rounded"}),jsx(Skeleton,{className:"h-6 w-16 rounded"}),jsx(Skeleton,{className:"h-6 w-20 rounded"})]}),jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[jsx(Skeleton,{className:"h-7 w-28 rounded-full"}),jsx(Skeleton,{className:"h-7 w-24 rounded-full"})]})]}),jsx("div",{className:"min-h-0 flex-1",children:jsx(Br,{count:e})})]})}var go=3,Wr={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},ko={bg:"hsl(var(--heroui-secondary) / 0.14)",text:"hsl(var(--heroui-secondary))",shadow:"hsl(var(--heroui-secondary) / 0.18)"},ml={bg:"rgba(239, 68, 68, 0.14)",text:"rgb(239, 68, 68)",shadow:"rgba(239, 68, 68, 0.18)"},St=[{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 ho(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 fl(e){let t=e.outcomes?.map(i=>i.label?.toLowerCase().trim()??"")??[];if(t.some(i=>i==="up")&&t.some(i=>i==="down"))return [Wr,ml];if(t.some(i=>i==="yes")&&t.some(i=>i==="no"))return [Wr,ko];let r=t[0]??"",o=t[1]??"",n=ho(r)%St.length,a=ho(o)%St.length;return a===n&&(a=(a+1)%St.length),[St[n],St[a]]}function gl(e){let t=e.outcomes?.[0];return t?t.best_ask??t.price??null:null}function No(e){let t=gl(e);return t!=null?parseFloat((t*100).toFixed(2)):0}function So(e){return e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function xo(e){let t=e.outcomes?.[0],r=t?.best_ask??t?.price??0;return parseFloat((r*100).toFixed(2)).toString()}function vo(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 hl(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),a=[];return r>0&&a.push(`${r}d`),o>0&&a.push(`${o}h`),a.push(`${n}m`),a.join(" ")}var xl=`
2
2
  .badge-shine { position: relative; overflow: hidden; }
3
3
  .badge-shine::after {
4
4
  content: "";
@@ -16,7 +16,36 @@ import {createContext,memo,useRef,useCallback,useState,useContext,useMemo,useEff
16
16
  60% { transform: translate(200%); }
17
17
  100% { transform: translate(200%); }
18
18
  }
19
- `;function Rn({event:e,href:t,LinkComponent:n,onSelect:o,onSelectOutcome:r,onHover:i}){let[s,l]=useState(null),a=e.markets??[],c=useMemo(()=>a.length>2?[...a].sort((M,O)=>(O.outcomes?.[0]?.price??0)-(M.outcomes?.[0]?.price??0)):a,[a]),d=c.filter(M=>M.status==="open"),p=c.length===1,u=d.slice(0,Sn),m=d.length-Sn,f=useMemo(()=>`$${Math.round(e.volume??0).toLocaleString("en-US")}`,[e.volume]),g=s?d.find(M=>M.slug===s)??null:null,v=!!g||p,h=()=>{v||o?.(e);},D=M=>{M.stopPropagation(),g&&(M.preventDefault(),l(null));},T=M=>{M.stopPropagation(),t||(M.preventDefault(),o?.(e));};return jsxs("div",{className:cn$1("group flex h-full w-full flex-col rounded-xl","min-h-52 border border-border/90 bg-background p-3","lg:min-h-72 lg:max-w-md lg:p-4","gap-y-1.5 lg:gap-y-4","transition duration-300","hover:border-primary/40 hover:shadow-card-glow","focus-within:border-primary/40 focus-within:shadow-card-glow",!v&&"cursor-pointer"),onMouseEnter:()=>i?.(e),onClick:h,children:[jsx("style",{children:Fa}),jsx(Ba,{event:e,href:t,LinkComponent:n,onClick:D,isExpanded:v}),jsx("div",{className:"flex flex-1 flex-col",children:p?jsx(Ya,{market:d[0],event:e,formattedVolume:f,href:t,LinkComponent:n,onSelect:o,onSelectOutcome:r}):g?jsx(qa,{market:g,event:e,onCollapse:()=>l(null),onSelectOutcome:r}):jsx(Ka,{displayedMarkets:u,moreCount:m,formattedVolume:f,source:e.source,href:t,LinkComponent:n,onMarketClick:M=>l(M.slug),onShowMore:T})})]})}function Ba({event:e,href:t,LinkComponent:n,onClick:o,isExpanded:r}){let i=e.start_at?Aa(e.start_at):null;return jsxs(Linkable,{href:t,LinkComponent:n,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",r&&"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(Ua,{event:e})]})}function Ha(e){let t=[];if(e.status==="closed")return t.push({kind:"closed"}),t.slice(0,2);let n=e.tags?.some(r=>r.label?.toLowerCase()==="crypto"),o=e.tags?.some(r=>r.label?.toLowerCase()==="live");if(n&&e.end_at){let r=new Date(e.end_at).getTime()-Date.now(),i=300*1e3,s=900*1e3;if(r>0&&r<=s){let l=r<=i?"#ef4444":"#f59e0b";t.push({kind:"crypto-short",label:r<=i?"5m":"15m",color:l});}}return o&&t.push({kind:"live"}),t.slice(0,2)}function Ua({event:e}){let t=useMemo(()=>Ha(e),[e]);return t.length===0?null:jsx("div",{className:"flex flex-shrink-0 flex-col items-end gap-1",children:t.map((n,o)=>{switch(n.kind){case "live":return jsx($a,{},o);case "crypto-short":return jsx(Wa,{label:n.label,color:n.color},o);case "closed":return jsx(za,{},o)}})})}function $a(){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 Wa({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 za(){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 Ka({displayedMarkets:e,moreCount:t,formattedVolume:n,source:o,href:r,LinkComponent:i,onMarketClick:s,onShowMore:l}){let{t:a}=useTranslation();return jsxs(Fragment,{children:[e.length>0&&jsx("div",{className:"flex w-full flex-1 flex-col gap-y-0.5 lg:gap-y-2",children:e.map(c=>{let d=Tn(c);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:p=>{p.stopPropagation(),s(c);},children:[jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 line-clamp-1 lg:text-sm",children:c.outcomes?.[0]?.label??c.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:Mn(d)}),jsx(Va,{})]})]},c.slug)})}),jsxs("div",{className:"mt-auto flex items-center justify-between pt-3",children:[t>0?jsxs(Linkable,{href:r,LinkComponent:i,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-neutral-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:l,children:[a("predict.event.showMore"),jsx(On,{className:"h-3 w-3"})]}):jsx("div",{}),jsxs("span",{className:"inline-flex items-center gap-x-1.5 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[n," ",a("predict.event.volume"),jsx(In,{source:o})]})]})]})}function Pn({bgColor:e,textColor:t,shadowColor:n,onClick:o,children:r}){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":n,"--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:l=>{let a=l.currentTarget;a.style.setProperty("--shadow-offset","2px"),a.style.transform="translateY(2px)";},onMouseLeave:l=>{let a=l.currentTarget;a.style.setProperty("--shadow-offset","4px"),a.style.transform="translateY(0px)";},onClick:o,children:r})}function Ln({market:e,event:t,onSelectOutcome:n,dynamicColors:o=false,labelFormat:r="action"}){let{t:i}=useTranslation(),[s,l]=o?_a(e):[ir,Cn],a=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",c=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",d=r==="label"&&a===c?"action":r,p=d==="label"?`${e.outcomes?.[0]?.label??"Yes"} ${wn(e)}\xA2`:i("predict.market.action.yes",{price:wn(e)}),u=d==="label"?`${e.outcomes?.[1]?.label??"No"} ${kn(e)}\xA2`:i("predict.market.action.no",{price:kn(e)});return jsxs("div",{className:"flex gap-2",children:[jsx(Pn,{bgColor:s.bg,textColor:s.text,shadowColor:s.shadow,onClick:m=>{m.stopPropagation(),n?.(t,e,"yes");},children:p}),jsx(Pn,{bgColor:l.bg,textColor:l.text,shadowColor:l.shadow,onClick:m=>{m.stopPropagation(),n?.(t,e,"no");},children:u})]})}function Va(){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 Ya({market:e,event:t,formattedVolume:n,href:o,LinkComponent:r,onSelect:i,onSelectOutcome:s}){let{t:l}=useTranslation();return jsxs(Fragment,{children:[jsx("div",{className:"flex-1",children:jsx(Ln,{market:e,event:t,onSelectOutcome:s,dynamicColors:true,labelFormat:"label"})}),jsxs("div",{className:"mt-auto flex items-center justify-between pt-3",children:[jsxs(Linkable,{href:o,LinkComponent:r,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-neutral-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:c=>{c.stopPropagation(),o||(c.preventDefault(),i?.(t));},children:[l("predict.event.viewEvent"),jsx(On,{className:"h-3 w-3"})]}),jsxs("span",{className:"inline-flex items-center gap-x-1.5 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[n," ",l("predict.event.volume"),jsx(In,{source:t.source})]})]})]})}function qa({market:e,event:t,onCollapse:n,onSelectOutcome:o}){let{t:r}=useTranslation(),i=Tn(e);return jsxs(Fragment,{children:[jsxs("div",{className:"flex-1",children:[jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between cursor-pointer",onClick:s=>{s.stopPropagation(),n();},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:Mn(i)}),jsx(ChevronUpIcon,{className:"h-4 w-4 text-neutral-400"})]})]}),jsx("div",{className:"mt-3",children:jsx(Ln,{market:e,event:t,onSelectOutcome:o,labelFormat:"action"})})]}),jsxs("button",{type:"button",className:"mt-auto flex items-center gap-x-1 pt-4 text-[10px] font-normal text-neutral-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:s=>{s.stopPropagation(),n();},children:[jsx(ja,{className:"h-3 w-3"}),r("predict.event.back")]})]})}function On({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 ja({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 In({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 ei=768,Dn=1024,ti=1280,ri=8,ni=224,oi=304,si=114;function ai(e){return e>=ti?4:e>=Dn?3:e>=ei?2:1}function ii(e){return e>=Dn?oi:ni}function An({events:e,hasMore:t=false,onFetchMore:n,onSelect:o,onSelectOutcome:r,getEventHref:i,LinkComponent:s,onHover:l}){let a=useRef(null),c=useRef(null),{width:d=0,height:p=0}=useResizeObserver({ref:a}),u=ai(d),m=ii(d),f=Math.ceil(e.length/u)||0,g=!t&&e.length>0,v=f+(t?1:0)+(g?1:0),h=useCallback(O=>O<f,[f]),D=useCallback(async()=>{n?.();},[n]),T=useInfiniteLoader({isRowLoaded:h,loadMoreRows:D,rowCount:v,threshold:3}),M=useCallback(()=>{c.current?.scrollToRow({index:0,behavior:"smooth"});},[]);return jsx("div",{ref:a,className:"@container w-full h-full",children:p>0&&jsx(List,{listRef:c,className:"no-scrollbar",style:{height:p},onRowsRendered:T,rowComponent:li,rowCount:v,rowHeight:O=>g&&O===v-1?si:(m),rowProps:{events:e,columnCount:u,dataRowCount:f,showEndOfList:g,totalRowCount:v,onSelect:o,onSelectOutcome:r,getEventHref:i,LinkComponent:s,onHover:l,onScrollToTop:M}})})}function li({index:e,style:t,events:n,columnCount:o,dataRowCount:r,showEndOfList:i,totalRowCount:s,onSelect:l,onSelectOutcome:a,getEventHref:c,LinkComponent:d,onHover:p,onScrollToTop:u}){if(i&&e===s-1)return jsx("div",{style:t,children:jsx(ci,{onScrollToTop:u})});if(e>=r)return jsx("div",{style:t,className:"flex justify-center items-start pt-4",children:jsx(Spinner,{size:"sm"})});let m=e*o,f=n.slice(m,m+o),g=o-f.length;return jsx("div",{style:t,children:jsxs("div",{className:"flex w-full h-full",children:[f.map(v=>v==null?null:jsx("div",{className:"flex-1 min-w-0 flex",style:{padding:ri},children:jsx(Rn,{event:v,href:c?.(v),LinkComponent:d,onSelect:l,onSelectOutcome:a,onHover:p})},v.slug)),g>0&&Array.from({length:g}).map((v,h)=>jsx("div",{style:{flex:1,minWidth:0}},`spacer-${h}`))]})})}function ci({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 Bn({tagSlugSelection:e,limit:t=48,status:n,sort_by:o,sort_asc:r,source:i,with_markets:s,timeRemaining:l,minVolume:a,minLiquidity:c,onSelect:d,onSelectOutcome:p,getEventHref:u,LinkComponent:m,onHover:f}){let{data:g,hasMore:v,fetchMore:h,isFetching:D}=yn({tagSlugSelection:e,limit:t,status:n,sort_by:o,sort_asc:r,source:i,with_markets:s,timeRemaining:l,minVolume:a,minLiquidity:c});return D?jsx(sr,{count:48}):jsx(An,{events:g,hasMore:v,onFetchMore:h,onSelect:d,onSelectOutcome:p,getEventHref:u,LinkComponent:m,onHover:f})}function ju({onSelect:e,onSelectOutcome:t,getEventHref:n,LinkComponent:o,onHover:r}){let[i,s]=useState({categorySlug:null,tagSlug:null}),[l,a]=useState(nr),{isOpen:c,onOpen:d,onClose:p}=useDisclosure(),{onOpen:u}=useAsyncModal(Je),m=useCallback((O,Z,R)=>{t?.(O,Z,R),u({params:{event:O,market:Z,initialOutcome:R}});},[t,u]),f=useCallback(O=>{s(O);},[]),g=useCallback(O=>{a(Z=>({...Z,sortPreset:O}));},[]),v=useCallback(O=>{a(Z=>({...Z,sortAsc:O}));},[]),h=useCallback(O=>{a(O);},[]),D=useMemo(()=>vn[l.sortPreset].sort_by,[l.sortPreset]),T=useMemo(()=>or(l),[l]),M=useMemo(()=>jsx(xn,{sortPreset:l.sortPreset,onSortChange:g,sortAsc:l.sortAsc,onSortAscChange:v,onFilterPress:d,filterCount:T}),[l.sortPreset,l.sortAsc,T,g,v,d]);return jsxs("div",{className:"flex h-full w-full max-w-[1680px] mx-auto flex-col gap-y-3",children:[jsx(Vr,{onSelect:f,trailing:M}),jsx(pn,{isOpen:c,onClose:p,value:l,onChange:h}),jsx("div",{className:"min-h-0 flex-1",children:jsx(Bn,{tagSlugSelection:i,sort_by:D,sort_asc:l.sortAsc,source:l.source,timeRemaining:l.timeRemaining,minVolume:l.minVolume,minLiquidity:l.minLiquidity,onSelect:e,onSelectOutcome:m,getEventHref:n,LinkComponent:o,onHover:r})}),jsx(yt,{})]})}var fr=40,Ct=36,st=480,gr=st-Ct;function Wn({event:e,walletAddress:t,onCancelOrder:n}){let{t:o}=useTranslation(),[r,i]=useState("positions"),s=useMemo(()=>e.markets?.map(p=>p.slug)??[],[e.markets]),{data:l}=usePositions({source:e.source,user:t??""}),a=useMemo(()=>!l?.positions||!t?0:s.length===0?l.positions.length:l.positions.filter(p=>p.market&&s.includes(p.market.slug)).length,[l?.positions,s,t]),d=[{key:"positions",label:a>0?`${o("predict.positions.title")} (${a})`: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",r===p.key?"text-foreground border-b-2 border-primary":"text-neutral hover:text-foreground"),children:p.label},p.key))}),t?jsxs("div",{style:{height:st},children:[r==="positions"&&jsx(hi,{source:e.source,walletAddress:t,marketSlugs:s}),r==="orders"&&jsx(yi,{source:e.source,walletAddress:t,marketSlugs:s,onCancelOrder:n}),r==="trades"&&jsx(wi,{source:e.source,walletAddress:t})]}):jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:st},children:o("predict.trade.connectWallet")})]})}function hi({source:e,walletAddress:t,marketSlugs:n}){let{t:o}=useTranslation(),{data:r,isLoading:i}=usePositions({source:e,user:t}),s=useMemo(()=>r?.positions?n.length===0?r.positions:r.positions.filter(l=>l.market&&n.includes(l.market.slug)):[],[r?.positions,n]);return i?jsx(xr,{}):s.length===0?jsx(vr,{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:Ct},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:gr},rowComponent:bi,rowCount:s.length,rowHeight:fr,rowProps:{positions:s,closeLabel:o("predict.positions.close")}})]})}function bi({index:e,style:t,positions:n,closeLabel:o}){let r=n[e];if(!r)return null;let i=r.pnl??0,s=r.pnl_percent??0,l=r.avg_price??0,a=r.current_price??0,c=i>0?"text-success":i<0?"text-danger":"text-foreground",d=i>0?"+":"",p=r.market?.outcomes?.[0]?.label??r.market?.question??"\u2014",u=r.side,m=r.size,f=r.size*a,g=r.market?.end_at?Ei(r.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",u.toLowerCase()==="yes"?"text-primary":"text-secondary"),children:u})]})}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:r.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:Pt(l)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:Pt(a)}),jsxs("div",{className:cn$1("flex-[1.5] pr-2 text-right font-mono whitespace-nowrap",c),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:["$",m.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 yi({source:e,walletAddress:t,marketSlugs:n,onCancelOrder:o}){let{t:r}=useTranslation(),{data:i,isLoading:s,fetchNextPage:l,hasNextPage:a}=useInfiniteOrders({source:e,wallet_address:t}),c=useCancelOrder(),d=useMemo(()=>{let h=i?.pages?.flatMap(M=>M.items)??[],D=new Set(["live","open","submitted","pending"]),T=h.filter(M=>D.has(M.status));return n.length>0&&(T=T.filter(M=>M.market_id&&n.includes(M.market_id))),T},[i?.pages,n]),p=useCallback(h=>{o?o(h.id):c.mutate({source:h.source,id:h.id});},[o,c]),u=d.length,m=u+(a?1:0),f=useCallback(h=>h<u,[u]),g=useCallback(async()=>{await l();},[l]),v=useInfiniteLoader({isRowLoaded:f,loadMoreRows:g,rowCount:m,threshold:5});return s?jsx(xr,{}):d.length===0&&!a?jsx(vr,{message:r("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:Ct},children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:r("predict.openOrders.side")}),jsx("div",{className:"flex-1 pr-2",children:r("predict.openOrders.outcome")}),jsx("div",{className:"flex-1 pr-2",children:r("predict.openOrders.type")}),jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.openOrders.price")}),jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.openOrders.filled")}),jsx("div",{className:"w-20 shrink-0 pr-2",children:r("predict.openOrders.status")}),jsx("div",{className:"w-16 shrink-0"})]}),jsx(List,{style:{height:gr},onRowsRendered:v,rowComponent:Si,rowCount:m,rowHeight:fr,rowProps:{orders:d,itemCount:u,onCancel:p,isCancelling:c.isPending,cancelLabel:r("predict.openOrders.cancel")}})]})}function Si({index:e,style:t,orders:n,itemCount:o,onCancel:r,isCancelling:i,cancelLabel:s}){if(e>=o)return jsx("div",{style:t,className:"flex justify-center items-center",children:jsx(Spinner,{size:"sm"})});let l=n[e];if(!l)return null;let a=l.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",a?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:l.side})}),jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:l.outcome??"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-neutral capitalize",children:l.order_type??"limit"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:l.price?Pt(parseFloat(l.price)):"\u2014"}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:[l.size_matched??"0","/",l.original_size??"\u2014"]}),jsx("div",{className:"w-20 shrink-0 pr-2",children:jsx(Ni,{status:l.status})}),jsx("div",{className:"w-16 shrink-0 text-right",children:jsx("button",{type:"button",onClick:()=>r(l),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 Ni({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 wi({source:e,walletAddress:t}){let{t:n}=useTranslation(),{data:o,isLoading:r,fetchNextPage:i,hasNextPage:s}=useInfiniteTrades({source:e,wallet:t,limit:50}),l=useMemo(()=>o?.pages?.flatMap(m=>m.items)??[],[o?.pages]),a=l.length,c=a+(s?1:0),d=useCallback(m=>m<a,[a]),p=useCallback(async()=>{await i();},[i]),u=useInfiniteLoader({isRowLoaded:d,loadMoreRows:p,rowCount:c,threshold:5});return r?jsx(xr,{}):l.length===0&&!s?jsx(vr,{message:n("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:Ct},children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:n("predict.tradeHistory.side")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.tradeHistory.outcome")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.tradeHistory.price")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.tradeHistory.qty")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.tradeHistory.total")}),jsx("div",{className:"flex-[1.5] pr-2 text-right",children:n("predict.tradeHistory.time")})]}),jsx(List,{style:{height:gr},onRowsRendered:u,rowComponent:ki,rowCount:c,rowHeight:fr,rowProps:{trades:l,itemCount:a}})]})}function ki({index:e,style:t,trades:n,itemCount:o}){if(e>=o)return jsx("div",{style:t,className:"flex justify-center items-center",children:jsx(Spinner,{size:"sm"})});let r=n[e];if(!r)return null;let i=r.side?.toUpperCase()==="BUY",s=Pi(r.timestamp),l=r.price??0,a=r.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:r.side})}),jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:r.outcome??"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Pt(l)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:r.size}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",a.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:s})]})}function vr({message:e}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:st},children:e})}function xr(){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:st},children:Array.from({length:6}).map((e,t)=>jsx(Skeleton,{className:"h-8 w-full rounded-md"},t))})}function Pt(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(1)}\xA2`}function Pi(e){let t=new Date(e*1e3),n=(t.getMonth()+1).toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),r=t.getHours().toString().padStart(2,"0"),i=t.getMinutes().toString().padStart(2,"0");return `${n}/${o} ${r}:${i}`}function Ei(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return "\u2014"}}function at({marketCount:e=4,showBack:t}){return jsxs("div",{className:"flex w-full flex-col gap-4 animate-pulse lg:gap-6",children:[t&&jsx("div",{className:"h-5"}),jsxs("div",{className:"flex items-center gap-x-2 h-16 lg:h-20 lg:gap-x-4",children:[jsx(Skeleton,{className:"size-16 shrink-0 rounded-lg lg:size-20"}),jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[jsxs("div",{className:"flex items-center gap-1.5",children:[jsx(Skeleton,{className:"h-3.5 w-12 rounded"}),jsx(Skeleton,{className:"h-3.5 w-10 rounded"}),jsx(Skeleton,{className:"h-3.5 w-10 rounded"})]}),jsx(Skeleton,{className:"h-5 w-full max-w-sm rounded lg:h-6"})]})]}),jsx(Skeleton,{className:"h-4 w-48 rounded"}),jsxs("div",{className:"flex flex-col gap-3",children:[jsxs("div",{className:"flex items-center gap-4",children:[jsx(Skeleton,{className:"h-4 w-24 rounded"}),jsx(Skeleton,{className:"h-4 w-20 rounded"})]}),jsx(Skeleton,{className:"h-[300px] w-full rounded-xl"}),jsxs("div",{className:"flex items-center justify-between",children:[jsx(Skeleton,{className:"h-4 w-20 rounded"}),jsxs("div",{className:"flex items-center gap-2",children:[jsx(Skeleton,{className:"h-7 w-[200px] rounded-lg"}),jsx(Skeleton,{className:"h-7 w-28 rounded-lg"})]})]})]}),jsxs("div",{className:"flex flex-col",children:[jsxs("div",{className:"flex items-center py-2",children:[jsx("div",{className:"flex-1"}),jsx(Skeleton,{className:"h-3.5 w-14 rounded"}),jsx("div",{className:"flex-1"})]}),Array.from({length:e}).map((n,o)=>jsxs("div",{className:"flex items-center gap-x-2 border-b border-border py-2.5 lg:gap-x-3",children:[jsx(Skeleton,{className:"size-5 shrink-0 rounded-lg lg:size-8"}),jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[jsx(Skeleton,{className:"h-3.5 w-32 rounded lg:h-4 lg:w-48"}),jsx(Skeleton,{className:"h-2.5 w-16 rounded"})]}),jsx(Skeleton,{className:"h-4 w-10 rounded"}),jsxs("div",{className:"flex items-center gap-2",children:[jsx(Skeleton,{className:"h-8 w-16 rounded-lg lg:w-24"}),jsx(Skeleton,{className:"h-8 w-16 rounded-lg lg:w-24"})]})]},o))]}),jsxs("div",{className:"flex flex-col gap-2",children:[jsx(Skeleton,{className:"h-4 w-16 rounded"}),jsx(Skeleton,{className:"h-3.5 w-full rounded"}),jsx(Skeleton,{className:"h-3.5 w-4/5 rounded"}),jsx(Skeleton,{className:"h-3.5 w-3/5 rounded"})]})]})}function zn(){return jsxs("div",{className:"flex flex-col gap-3 rounded-xl border border-border p-4 animate-pulse",children:[jsx(Skeleton,{className:"h-10 w-full rounded-lg"}),jsx(Skeleton,{className:"h-24 w-full rounded-lg"}),jsx(Skeleton,{className:"h-10 w-full rounded-lg"})]})}var qn="var(--color-bullish)",jn="var(--color-bearish)";function it(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 Mi(e,t){return e<=0||t<=0?0:Math.pow(e/t,.3)}function Ri(e,t){let n=new Float64Array(101),o=new Float64Array(101);for(let m of e){let f=Math.round(m.price*100);f>=0&&f<=100&&(n[f]+=m.quantity);}for(let m of t){let f=Math.round(m.price*100);f>=0&&f<=100&&(o[f]+=m.quantity);}let r=0,i=0,s=new Float64Array(101),l=new Float64Array(101);for(let m=100;m>=0;m--)r+=n[m],i+=n[m]*m/100,s[m]=r,l[m]=i;let a=0,c=0,d=new Float64Array(101),p=new Float64Array(101);for(let m=0;m<=100;m++)a+=o[m],c+=o[m]*m/100,d[m]=a,p[m]=c;let u=Math.max(s[0]??0,d[100]??0);return Array.from({length:101},(m,f)=>{let g=s[f]>0,v=d[f]>0,h=s[f]||d[f],D=n[f]>0||o[f]>0;return {priceCents:f,displayHeight:Mi(h,u),opacity:h>0?D?1:.5:0,isBid:g,isAsk:v,bidCumTotal:s[f],askCumTotal:d[f],bidCumCost:l[f],askCumCost:p[f]}})}function Li({info:e}){let{t}=useTranslation(),n=e.isBid?qn:jn,o=e.leftPct>65?void 0:`${e.leftPct}%`,r=e.leftPct>65?`${100-e.leftPct}%`:void 0;return jsxs("div",{style:{position:"absolute",top:8,left:o,right:r,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:n},children:t("predict.orderBook.depthContracts",{amount:it(Math.round(e.cumTotal))})}),jsxs("div",{style:{color:n},children:["$",it(Math.round(e.cumCost))]})]})}var Oi=memo(function({slot:t,onEnter:n,onLeave:o}){let r=useRef(null),i=t.isBid||t.isAsk,s=t.isBid?qn:t.isAsk?jn: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:()=>n(t,r.current),onMouseLeave:o,children:i&&jsx("div",{ref:r,style:{position:"absolute",bottom:0,left:0,width:"100%",height:`${t.displayHeight*100}%`,backgroundColor:s,opacity:t.opacity}})})}),Ii=[0,10,20,30,40,50,60,70,80,90,100];function _i(){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:Ii.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 Gn({bids:e,asks:t}){let{t:n}=useTranslation(),o=useMemo(()=>Ri(e,t),[e,t]),r=useMemo(()=>{let p=e.length>0?Math.max(...e.map(m=>m.price)):0,u=t.length>0?Math.min(...t.map(m=>m.price)):1;return Math.round((p+u)/2*100)},[e,t]),i=useMemo(()=>o.some(p=>p.isBid||p.isAsk),[o]),[s,l]=useState(null),a=useRef(null),c=useCallback((p,u)=>{a.current&&(a.current.style.filter=""),u?(u.style.filter="brightness(1.5)",a.current=u):a.current=null,p.isBid||p.isAsk?l({priceCents:p.priceCents,isBid:p.isBid,cumTotal:p.isBid?p.bidCumTotal:p.askCumTotal,cumCost:p.isBid?p.bidCumCost:p.askCumCost,leftPct:p.priceCents}):l(null);},[]),d=useCallback(()=>{a.current&&(a.current.style.filter="",a.current=null),l(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:[r>0&&jsx("div",{style:{position:"absolute",left:`${r}%`,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(Li,{info:s}),o.map(p=>jsx(Oi,{slot:p,onEnter:c,onLeave:d},p.priceCents))]}),jsx(_i,{})]}):jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:n("predict.orderBook.noData")})}function br(e){let t=e*100,n=Math.round(t*10)/10;return Number.isInteger(n)?`${n}\xA2`:`${n.toFixed(1)}\xA2`}function Xn(){let{t:e}=useTranslation();return jsxs("div",{className:"flex items-center justify-center gap-x-2 h-full text-neutral text-xs",children:[jsx(Spinner,{size:"sm"}),jsx("span",{children:e("predict.orderBook.loading")})]})}function eo({market:e,outcome:t="yes",onTradeAction:n}){let{t:o}=useTranslation(),[r,i]=useState("depth"),s=t==="no",l=e.source,{data:a,isLoading:c}=useOrderbook({slug:e.slug,source:l}),d=useMemo(()=>((s?a?.asks:a?.bids)??[]).map(v=>({price:s?1-v.price:v.price,quantity:v.size})),[a?.bids,a?.asks,s]),p=useMemo(()=>((s?a?.bids:a?.asks)??[]).map(v=>({price:s?1-v.price:v.price,quantity:v.size})),[a?.bids,a?.asks,s]),u=useMemo(()=>d.length>0?Math.max(...d.map(g=>g.price)):null,[d]),m=useMemo(()=>p.length>0?Math.min(...p.map(g=>g.price)):null,[p]),f=useMemo(()=>{if(u==null||m==null)return null;let g=(m-u)*100;return Math.round(g*10)/10},[u,m]);return jsxs("div",{className:"flex flex-col 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:f!=null?`${o("predict.orderBook.spread")}: ${Number.isInteger(f)?`${f}\xA2`:`${f.toFixed(1)}\xA2`}`:null}),jsxs("span",{className:"flex flex-1 items-center justify-center gap-x-1 whitespace-nowrap",children:[u!=null&&jsxs("span",{style:{color:"var(--color-bullish)"},children:[o("predict.trade.bestBid"),": ",br(u)]}),u!=null&&m!=null&&jsx("span",{className:"text-neutral",children:"|"}),m!=null&&jsxs("span",{style:{color:"var(--color-bearish)"},children:[o("predict.trade.bestAsk"),": ",br(m)]})]}),jsx("div",{className:"flex flex-1 justify-end",children:jsx("button",{type:"button",title:r==="depth"?"Orderbook":"Depth chart",onClick:()=>i(g=>g==="depth"?"table":"depth"),className:"flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground",children:r==="depth"?jsx(OrderbookTableIcon,{className:"h-4 w-4"}):jsx(OrderbookDepthIcon,{className:"h-4 w-4"})})})]}),jsxs("div",{className:"flex-1 min-h-0 overflow-hidden",children:[r==="depth"&&jsx(Fragment,{children:c?jsx(Xn,{}):jsx(Gn,{bids:d,asks:p})}),r==="table"&&jsx(Fragment,{children:c?jsx(Xn,{}):jsx(Ui,{bids:d,asks:p,bestBid:u??void 0,bestAsk:m??void 0,spread:f??void 0})})]})]})}var Qn=8;function Ui({bids:e,asks:t,spread:n}){let{t:o}=useTranslation(),r=useMemo(()=>[...t].sort((a,c)=>a.price-c.price).slice(0,Qn).reverse(),[t]),i=useMemo(()=>[...e].sort((a,c)=>c.price-a.price).slice(0,Qn),[e]),s=useMemo(()=>{let a=[...r,...i].map(c=>c.quantity);return Math.max(...a,1)},[r,i]);return r.length===0&&i.length===0?jsx("div",{className:"flex items-center justify-center h-full text-xs text-neutral",children:o("predict.orderBook.empty")}):jsxs("div",{className:"flex flex-col h-full overflow-y-auto text-xs font-mono select-none",children:[r.map(a=>jsx(Jn,{price:a.price,quantity:a.quantity,side:"ask",maxQty:s},`ask-${a.price}`)),jsx("div",{className:"flex items-center justify-center gap-x-2 py-1 border-y border-border text-neutral text-[10px]",children:n!=null&&jsxs("span",{children:[o("predict.orderBook.spread"),":"," ",Number.isInteger(n)?`${n}\xA2`:`${n.toFixed(1)}\xA2`]})}),i.map(a=>jsx(Jn,{price:a.price,quantity:a.quantity,side:"bid",maxQty:s},`bid-${a.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:o("predict.orderBook.price")}),jsx("span",{className:"text-center",children:o("predict.orderBook.contracts")}),jsx("span",{className:"text-right",children:o("predict.orderBook.total")})]})]})}function Jn({price:e,quantity:t,side:n,maxQty:o}){let r=n==="ask",i=Math.min(t/o*100,100),s=r?"bg-bearish/10":"bg-bullish/10",l=r?"text-bearish":"text-bullish",a=it(Math.round(t)),c=Math.round(t*e),d=`$${it(c)}`;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 ${s} transition-[width] duration-200`,style:{width:`${i}%`}}),jsx("span",{className:`relative z-10 ${l}`,children:br(e)}),jsx("span",{className:"relative z-10 text-foreground text-center",children:a}),jsx("span",{className:"relative z-10 text-foreground text-right",children:d})]})}var Nr=class extends Component{state={error:null};static getDerivedStateFromError(t){return {error:t}}componentDidCatch(t,n){}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}},Rt=4,to=["#22d3ee","#a3e635","#f97316","#f472b6","#a78bfa"];function Ji(e,t){let n=new Date(e);return t===ChartRange.ONE_DAY?n.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):n.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Zi(e,t){let n=new Date(e);return t===ChartRange.ONE_DAY?n.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):t===ChartRange.ONE_WEEK?n.toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:false}):n.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function ro(e){return `${(e*100).toFixed(2)}%`}var el=[{range:ChartRange.ONE_DAY,label:"1D"},{range:ChartRange.ONE_WEEK,label:"1W"},{range:ChartRange.ONE_MONTH,label:"1M"},{range:ChartRange.ALL,label:"ALL"}];function tl({value:e,onChange:t}){return jsx("div",{style:{display:"flex",alignItems:"center",gap:2},children:el.map(({range:n,label:o})=>{let r=n===e;return jsx("button",{onClick:()=>t(n),style:{padding:"2px 8px",border:"none",background:"transparent",color:r?"#f9fafb":"#6b7280",fontWeight:r?700:400,fontSize:12,cursor:"pointer",borderRadius:4,letterSpacing:"0.02em",transition:"color 0.15s",userSelect:"none"},children:o},n)})})}function rl(){let e=useRef(null),t=useRef(null),n=useCallback(r=>{let i=e.current,s=t.current;if(!i||!s)return;let l=i.getBoundingClientRect(),a=(r.clientX-l.left)/l.width*100;s.style.background=`linear-gradient(to right, transparent ${a}%, rgba(0,0,0,0.55) ${a}%)`,s.style.opacity="1";},[]),o=useCallback(()=>{t.current&&(t.current.style.opacity="0");},[]);return {wrapperRef:e,overlayRef:t,onMouseMove:n,onMouseLeave:o}}function nl({active:e,payload:t,label:n,labelMap:o,allSeries:r,range:i}){if(!e||!r?.length)return null;let s=new Map;t?.forEach(a=>s.set(a.dataKey,a));let l=r.map(a=>s.get(a.slug)??{dataKey:a.slug,value:void 0,stroke:a.color,color:a.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 n=="number"?Zi(n,i):n}),l.map(a=>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:a.stroke??a.color,flexShrink:0}}),jsx("span",{style:{color:"#9ca3af",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:120},children:o.get(a.dataKey)??a.dataKey}),jsx("span",{style:{color:"#f9fafb",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:a.value!=null?ro(a.value):"--"})]},a.dataKey))]})}function ol({markets:e,selectedSlugs:t,colorMap:n,onToggle:o}){let[r,i]=useState(false),s=useRef(null);useEffect(()=>{if(!r)return;function c(d){s.current&&!s.current.contains(d.target)&&i(false);}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[r]);let l=t.length>=Rt,a=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(c=>jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:n.get(c)??"#6b7280",display:"inline-block"}},c))}),jsx("span",{style:{color:"#e5e7eb",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.length===1?(()=>{let c=e.find(d=>d.slug===t[0]);return c?.outcomes?.[0]?.label??c?.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(c=>!c),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:[a,jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{flexShrink:0,transform:r?"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"})})]}),r&&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 ",Rt," markets"]}),e.map(c=>{let d=t.includes(c.slug),p=!d&&l,u=d&&t.length===1,m=n.get(c.slug)??"#6b7280",f=c.outcomes.find(v=>v.label.toLowerCase()==="yes")??c.outcomes[0],g=f?.price!=null?`${Math.round(f.price*100)}%`:null;return jsxs("button",{onClick:()=>{u||p||o(c.slug);},style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"7px 12px",border:"none",background:d?"rgba(255,255,255,0.05)":"transparent",cursor:p||u?"not-allowed":"pointer",opacity:p?.35:1,textAlign:"left",transition:"background 0.1s"},onMouseEnter:v=>{!p&&!u&&(v.currentTarget.style.background="rgba(255,255,255,0.07)");},onMouseLeave:v=>{v.currentTarget.style.background=d?"rgba(255,255,255,0.05)":"transparent";},children:[jsx("span",{style:{width:16,height:16,borderRadius:4,border:d?`2px solid ${m}`:"2px solid rgba(255,255,255,0.2)",background:d?`${m}30`:"transparent",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:d&&jsx("svg",{width:"9",height:"7",viewBox:"0 0 9 7",fill:"none",children:jsx("path",{d:"M1 3.5L3.5 6L8 1",stroke:m,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:m,flexShrink:0}}),jsx("span",{style:{color:d?"#f9fafb":"#9ca3af",fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c.outcomes?.[0]?.label??c.question}),g&&jsx("span",{style:{color:m,fontWeight:700,fontSize:12,flexShrink:0},children:g})]},c.slug)})]})]})}function sl({series:e,colorMap:t,displayValues:n}){return jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px 24px",padding:"0 2px"},children:e.map(o=>{let r=t.get(o.marketSlug)??"#6b7280",i=n.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:r,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?ro(i):"--"})]})]},o.marketSlug)})})}function al(e){let t=Math.floor(e.length/2);return e.length%2===1?e[t]:(e[t-1]+e[t])/2}function il(e,t){if(e.length<=t)return e;let n=[],o=e.length/t;for(let r=0;r<t;r++){let i=Math.floor(r*o),s=Math.min(Math.floor((r+1)*o),e.length),l=e.slice(i,s),a=l.map(c=>c.price).sort((c,d)=>c-d);n.push({timestamp:l[l.length-1].timestamp,price:al(a)});}return n}function ll(e,t=200){if(e.length===0)return [];let n=e.map(l=>({...l,data:il(l.data,t)})),o=new Set;n.forEach(l=>l.data.forEach(a=>o.add(a.timestamp)));let r=Array.from(o).sort((l,a)=>l-a),i=n.map(l=>{let a=new Map;return l.data.forEach(c=>a.set(c.timestamp,c.price)),{slug:l.marketSlug,map:a}}),s=new Map;return r.map(l=>{let a={timestamp:l};return i.forEach(({slug:c,map:d})=>{let p=d.get(l);if(p!==void 0)s.set(c,p),a[c]=p;else {let u=s.get(c);u!==void 0&&(a[c]=u);}}),a})}function no(e){return jsx(Nr,{children:jsx(cl,{...e})})}function cl({event:e,isLoading:t,className:n,volume:o}){let r=useMemo(()=>(e.markets??[]).filter(S=>S.status==="open"),[e.markets]),i=useMemo(()=>[...r].sort((S,E)=>{let I=y=>(y.outcomes.find($=>$.label.toLowerCase()==="yes")??y.outcomes[0])?.price??0;return I(E)-I(S)}),[r]),[s,l]=useState(()=>i.slice(0,Rt).map(S=>S.slug)),[a,c]=useState(ht),d=useMemo(()=>{let S=new Map;return s.forEach((E,I)=>{S.set(E,to[I%to.length]);}),S},[s]),p=useMemo(()=>r.filter(S=>s.includes(S.slug)),[r,s]),{series:u,isLoading:m}=useMarketHistory(p,a),f=t||m,g=useMemo(()=>{if(u.length>0&&u.some(I=>I.data.length>0))return u;let S=Date.now(),E=864e5;return p.map(I=>{let $=(I.outcomes?.find(q=>q.label.toLowerCase()==="yes")??I.outcomes?.[0])?.price??.5;return {marketSlug:I.slug,label:I.outcomes?.[0]?.label??I.question,data:[{timestamp:S-7*E,price:$},{timestamp:S,price:$}]}})},[u,p]),v=useMemo(()=>a===ChartRange.ONE_DAY?96:a===ChartRange.ONE_WEEK?168:a===ChartRange.ONE_MONTH?180:300,[a]),h=useMemo(()=>ll(g,v),[g,v]),D=useMemo(()=>{if(h.length===0)return [0,1];let S=1/0,E=-1/0;if(s.forEach(y=>{h.forEach($=>{let q=$[y];q!=null&&(q<S&&(S=q),q>E&&(E=q));});}),!isFinite(S))return [0,1];let I=Math.max((E-S)*.15,.05);return [Math.max(0,S-I),Math.min(1,E+I)]},[h,s]),T=useMemo(()=>{let S=new Map;return g.forEach(E=>{E.data.length>0&&S.set(E.marketSlug,E.data[E.data.length-1].price);}),S},[g]),M=useMemo(()=>{let S=new Map;return g.forEach(E=>S.set(E.marketSlug,E.label)),S},[g]),O=useMemo(()=>g.map(S=>({slug:S.marketSlug,color:d.get(S.marketSlug)??"#6b7280"})),[g,d]),{wrapperRef:Z,overlayRef:R,onMouseMove:ie,onMouseLeave:K}=rl(),fe=useCallback(S=>{l(E=>E.includes(S)?E.length<=1?E:E.filter(I=>I!==S):E.length>=Rt?E:[...E,S]);},[]),[Me,X]=useState(null),Q=useRef(null),le=useRef(""),he=useRef(0),be=!f&&h.length>0;return jsxs("div",{className:n,style:{display:"flex",flexDirection:"column",gap:12},children:[jsx(sl,{series:g,colorMap:d,displayValues:Me??T}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0},children:[jsx("div",{ref:Z,style:{height:300,width:"100%",userSelect:"none",position:"relative"},onMouseMove:be?S=>{ie(S),cancelAnimationFrame(he.current),he.current=requestAnimationFrame(()=>{X(Q.current);});}:void 0,onMouseLeave:be?()=>{K(),cancelAnimationFrame(he.current),le.current="",Q.current=null,X(null);}:void 0,children:f?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"}})}):h.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:R,style:{position:"absolute",inset:0,opacity:0,pointerEvents:"none",zIndex:1}}),jsx(ResponsiveContainer,{width:"100%",height:"100%",children:jsxs(LineChart,{data:h,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:S=>Ji(S,a),axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},minTickGap:70}),jsx(YAxis,{domain:D,tickFormatter:S=>`${Math.round(S*100)}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},width:40,tickCount:6}),jsx(Tooltip,{content:S=>{let E=S;if(E.active&&E.payload?.length){let I=E.payload.map(y=>`${y.dataKey}:${y.value}`).join(",");if(I!==le.current){le.current=I;let y=new Map;E.payload.forEach($=>{$.value!=null&&y.set($.dataKey,$.value);}),Q.current=y;}}return jsx(nl,{...E,labelMap:M,allSeries:O,range:a})},cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},wrapperStyle:{zIndex:2},isAnimationActive:false}),g.map(S=>{let E=d.get(S.marketSlug)??"#6b7280";return jsx(Line,{type:"linear",dataKey:S.marketSlug,stroke:E,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:E},connectNulls:true,isAnimationActive:false},S.marketSlug)}),Me==null&&h.length>0&&g.map(S=>{let E=h[h.length-1],I=E[S.marketSlug];if(I==null)return null;let y=d.get(S.marketSlug)??"#6b7280";return jsx(ReferenceDot,{x:E.timestamp,y:I,ifOverflow:"extendDomain",shape:$=>{let{cx:q,cy:z}=$;return q==null||z==null?jsx("g",{}):jsxs("g",{children:[jsxs("circle",{cx:q,cy:z,r:6,fill:y,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:q,cy:z,r:3.5,fill:y})]})}},`pulse-${S.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:["$",Math.round(o).toLocaleString()," vol"]}),jsx("div",{style:{flex:1,minWidth:0}}),jsx(tl,{value:a,onChange:c}),i.length>1&&jsx("div",{style:{width:"100%",display:"flex",alignItems:"center"},children:jsx(ol,{markets:i,selectedSlugs:s,colorMap:d,onToggle:fe})})]})]})]})}function ct(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function wl(e){return `${parseFloat((e*100).toFixed(2))}%`}function oo(e){let t=e*100;return t<1&&t>0?"< 1":parseFloat(t.toFixed(2)).toString()}function Lt(e){return e.outcomes?.[0]?.label??e.question}function kl(e){switch(e){case "polymarket":return "Polymarket";case "kalshi":return "Kalshi";default:return e}}function lt(e){if(!e)return "\u2014";let t=new Date(e);if(isNaN(t.getTime()))return "\u2014";let n=t.toLocaleString("default",{month:"short"}),o=t.getDate(),r=t.getFullYear(),i=t.getHours().toString().padStart(2,"0"),s=t.getMinutes().toString().padStart(2,"0");return `${n} ${o}, ${r} ${i}:${s}`}function so(e){let[t,n]=useState(Date.now());if(useEffect(()=>{if(!e)return;let d=setInterval(()=>n(Date.now()),1e3);return ()=>clearInterval(d)},[e]),!e)return null;let o=new Date(e).getTime();if(isNaN(o))return null;let r=o-t;if(r<=0)return null;let i=Math.floor(r/864e5),s=Math.floor(r%864e5/36e5),l=Math.floor(r%36e5/6e4),a=Math.floor(r%6e4/1e3),c=[];return i>0&&c.push(`${i}d`),c.push(`${String(s).padStart(2,"0")}h`),c.push(`${String(l).padStart(2,"0")}m`),c.push(`${String(a).padStart(2,"0")}s`),c.join(" ")}function ao(e){if(!e)return null;let t=new Date(e);if(isNaN(t.getTime()))return null;let n=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0"),r=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getDate().toString().padStart(2,"0"),s=t.getFullYear(),l=-t.getTimezoneOffset(),a=l>=0?"+":"-",c=String(Math.abs(Math.floor(l/60))).padStart(2,"0");return `${n}:${o} ${r}/${i}/${s} (${a}${c})`}function co({event:e,onTradeAction:t}){let{t:n}=useTranslation(),{ref:o,isCollapsed:r}=useScrollCollapse(),i=useMemo(()=>{let p=[...e.markets||[]],u=p.filter(f=>f.status==="open").sort((f,g)=>ct(g)-ct(f)),m=p.filter(f=>f.status!=="open").sort((f,g)=>ct(g)-ct(f));return [...u,...m]},[e.markets]),s=e.status==="closed"||e.status==="voided",l=so(s?void 0:e.start_at),a=so(s?void 0:e.end_at),c=ao(e.start_at),d=ao(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 ${r?"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 ${r?"!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:[!r&&jsxs("div",{className:"flex items-center gap-1.5",children:[e.tags?.slice(0,3).map((p,u)=>jsxs(Fragment$1,{children:[u>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(Tl,{source:e.source})]}),jsx("span",{className:`font-semibold truncate transition-all duration-300 ${r?"text-sm lg:text-base":"text-lg lg:text-xl"}`,children:e.title})]})]}),(l||a||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:n("predict.event.endedAt",{time:d})}):l?jsxs(Fragment,{children:[jsx("span",{className:"text-foreground",children:n("predict.event.beginsIn",{time:l})}),c&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-neutral",children:c})]})]}):a?jsxs(Fragment,{children:[jsx("span",{className:"text-foreground",children:n("predict.event.endsIn",{time:a})}),d&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-neutral",children:d})]})]}):null}),jsx(no,{event:e,volume:e.volume??void 0}),jsx(Pl,{markets:i,onTradeAction:t}),jsx(Cl,{markets:i,event:e})]})}var io=5;function Pl({markets:e,onTradeAction:t}){let{t:n}=useTranslation(),{isMobile:o}=useScreen(),[r,i]=useState(false),[s,l]=useState(null),a=e.find(g=>g.status==="open")?.slug,[c,d]=useState(a?`${a}:yes`:null);if(e.length===0)return null;let p=e.length>io,u=r?e:e.slice(0,io),m=g=>{l(v=>v===g?null:g);},f=(g,v,h)=>{d(`${g.slug}:${v}`),o||l(g.slug),t?.(g,v,h);};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:n("predict.market.table.chance")}),jsx("th",{})]})}),jsx("tbody",{children:u.map(g=>{let v=ct(g),h=g.outcomes[1]?.best_ask??g.outcomes[1]?.price,D=s===g.slug;return jsx(El,{market:g,yesPrice:v,noPrice:h??void 0,activeYes:c===`${g.slug}:yes`,activeNo:c===`${g.slug}:no`,isExpanded:D,onToggleExpand:()=>m(g.slug),onTradeAction:f},g.slug)})})]}),p&&jsxs("button",{type:"button",onClick:()=>i(g=>!g),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:n(r?"predict.event.rules.collapse":"predict.event.moreMarketsLabel")}),jsx(ChevronDownIcon,{className:cn$1("h-4 w-4 transition-transform",r&&"rotate-180")})]})]})}function El({market:e,yesPrice:t,noPrice:n,activeYes:o,activeNo:r,isExpanded:i,onToggleExpand:s,onTradeAction:l}){let{t:a}=useTranslation(),c=e.status==="open",d=e.volume?`$${Math.round(e.volume).toLocaleString("en-US")} vol`:void 0;return jsxs(Fragment,{children:[jsxs("tr",{className:"cursor-pointer border-b border-border text-xs hover:bg-content2 lg:text-base",onClick:s,role:"button",tabIndex:0,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),s());},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:Lt(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:Lt(e)}),d&&jsx("span",{className:"text-[8px] text-neutral lg:text-xxs",children:d})]})]})}),jsx("td",{className:"py-2 text-left text-foreground lg:text-center",children:wl(t)}),jsx("td",{className:"py-2 pr-1 lg:pr-2",children:c?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",o?"bg-primary text-primary-foreground":"bg-primary/10 text-primary"),onClick:p=>{p.stopPropagation(),l?.(e,"yes","buy");},children:a("predict.market.action.yes",{price:oo(t)})}),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",r?"bg-secondary text-secondary-foreground":"bg-secondary/10 text-secondary"),onClick:p=>{p.stopPropagation(),l?.(e,"no","buy");},children:n!=null?a("predict.market.action.no",{price:oo(n)}):a("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"?a("predict.event.status.closed"):e.status==="voided"?a("predict.event.status.voided"):a("predict.event.status.pending")})})})]}),i&&jsx("tr",{children:jsx("td",{colSpan:3,className:"pb-3",children:jsx("div",{className:"max-h-100 overflow-y-auto",children:jsx(eo,{market:e,outcome:r?"no":"yes",onTradeAction:l})})})})]})}function Cl({markets:e,event:t}){let{t:n}=useTranslation(),[o,r]=useState(false),[i,s]=useState(false),[l,a]=useState(0),c=e.filter(m=>m.rules&&m.rules.length>0||m.description);if(c.length===0)return null;let d=c[l]??c[0],p=d.rules&&d.rules.length>0?d.rules.join(`
19
+ `;function wo({event:e,href:t,LinkComponent:r,onSelect:o,onSelectOutcome:n,onHover:a}){let[i,s]=useState(null),l=e.markets??[],c=useMemo(()=>l.length>2?[...l].sort((w,v)=>(v.outcomes?.[0]?.price??0)-(w.outcomes?.[0]?.price??0)):l,[l]),u=c.filter(w=>w.status==="open"),d=c.length===1,p=u.slice(0,go),m=u.length-go,g=useMemo(()=>`$${Math.round(e.volume??0).toLocaleString("en-US")}`,[e.volume]),f=i?u.find(w=>w.slug===i)??null:null,h=!!f||d,x=()=>{h||o?.(e);},R=w=>{w.stopPropagation(),f&&(w.preventDefault(),s(null));},N=w=>{w.stopPropagation(),t||(w.preventDefault(),o?.(e));};return jsxs("div",{className:cn$1("group flex h-full w-full flex-col rounded-xl","min-h-52 border border-border/90 bg-background p-3","lg:min-h-72 lg:max-w-md lg:p-4","gap-y-1.5 lg:gap-y-4","transition duration-300","hover:border-primary/40 hover:shadow-card-glow","focus-within:border-primary/40 focus-within:shadow-card-glow",!h&&"cursor-pointer"),onMouseEnter:()=>a?.(e),onClick:x,children:[jsx("style",{children:xl}),jsx(vl,{event:e,href:t,LinkComponent:r,onClick:R,isExpanded:h}),jsx("div",{className:"flex flex-1 flex-col",children:d?jsx(Cl,{market:u[0],event:e,formattedVolume:g,href:t,LinkComponent:r,onSelect:o,onSelectOutcome:n}):f?jsx(El,{market:f,event:e,onCollapse:()=>s(null),onSelectOutcome:n}):jsx(wl,{displayedMarkets:p,moreCount:m,formattedVolume:g,source:e.source,href:t,LinkComponent:r,onMarketClick:w=>s(w.slug),onShowMore:N})})]})}function vl({event:e,href:t,LinkComponent:r,onClick:o,isExpanded:n}){let a=e.start_at?hl(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}),a&&jsxs("span",{className:"text-[10px] leading-4 text-neutral-500",children:["Live in ",a]})]}),jsx(yl,{event:e})]})}function bl(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(),a=300*1e3,i=900*1e3;if(n>0&&n<=i){let s=n<=a?"#ef4444":"#f59e0b";t.push({kind:"crypto-short",label:n<=a?"5m":"15m",color:s});}}return o&&t.push({kind:"live"}),t.slice(0,2)}function yl({event:e}){let t=useMemo(()=>bl(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(kl,{},o);case "crypto-short":return jsx(Nl,{label:r.label,color:r.color},o);case "closed":return jsx(Sl,{},o)}})})}function kl(){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 Nl({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 Sl(){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 wl({displayedMarkets:e,moreCount:t,formattedVolume:r,source:o,href:n,LinkComponent:a,onMarketClick:i,onShowMore:s}){let{t:l}=useTranslation();return jsxs(Fragment,{children:[e.length>0&&jsx("div",{className:"flex w-full flex-1 flex-col gap-y-0.5 lg:gap-y-2",children:e.map(c=>{let u=No(c);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:d=>{d.stopPropagation(),i(c);},children:[jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 line-clamp-1 lg:text-sm",children:c.outcomes?.[0]?.label??c.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:So(u)}),jsx(Pl,{})]})]},c.slug)})}),jsxs("div",{className:"mt-auto flex items-center justify-between pt-3",children:[t>0?jsxs(Linkable,{href:n,LinkComponent:a,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-neutral-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:s,children:[l("predict.event.showMore"),jsx(Co,{className:"h-3 w-3"})]}):jsx("div",{}),jsxs("span",{className:"inline-flex items-center gap-x-1.5 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[r," ",l("predict.event.volume"),jsx(Eo,{source:o})]})]})]})}function bo({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:s=>{let l=s.currentTarget;l.style.setProperty("--shadow-offset","2px"),l.style.transform="translateY(2px)";},onMouseLeave:s=>{let l=s.currentTarget;l.style.setProperty("--shadow-offset","4px"),l.style.transform="translateY(0px)";},onClick:o,children:n})}function Po({market:e,event:t,onSelectOutcome:r,dynamicColors:o=false,labelFormat:n="action"}){let{t:a}=useTranslation(),[i,s]=o?fl(e):[Wr,ko],l=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",c=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",u=n==="label"&&l===c?"action":n,d=u==="label"?`${e.outcomes?.[0]?.label??"Yes"} ${xo(e)}\xA2`:a("predict.market.action.yes",{price:xo(e)}),p=u==="label"?`${e.outcomes?.[1]?.label??"No"} ${vo(e)}\xA2`:a("predict.market.action.no",{price:vo(e)});return jsxs("div",{className:"flex gap-2",children:[jsx(bo,{bgColor:i.bg,textColor:i.text,shadowColor:i.shadow,onClick:m=>{m.stopPropagation(),r?.(t,e,"yes");},children:d}),jsx(bo,{bgColor:s.bg,textColor:s.text,shadowColor:s.shadow,onClick:m=>{m.stopPropagation(),r?.(t,e,"no");},children:p})]})}function Pl(){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 Cl({market:e,event:t,formattedVolume:r,href:o,LinkComponent:n,onSelect:a,onSelectOutcome:i}){let{t:s}=useTranslation();return jsxs(Fragment,{children:[jsx("div",{className:"flex-1",children:jsx(Po,{market:e,event:t,onSelectOutcome:i,dynamicColors:true,labelFormat:"label"})}),jsxs("div",{className:"mt-auto flex items-center justify-between pt-3",children:[jsxs(Linkable,{href:o,LinkComponent:n,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-neutral-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:c=>{c.stopPropagation(),o||(c.preventDefault(),a?.(t));},children:[s("predict.event.viewEvent"),jsx(Co,{className:"h-3 w-3"})]}),jsxs("span",{className:"inline-flex items-center gap-x-1.5 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[r," ",s("predict.event.volume"),jsx(Eo,{source:t.source})]})]})]})}function El({market:e,event:t,onCollapse:r,onSelectOutcome:o}){let{t:n}=useTranslation(),a=No(e);return jsxs(Fragment,{children:[jsxs("div",{className:"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:So(a)}),jsx(ChevronUpIcon,{className:"h-4 w-4 text-neutral-400"})]})]}),jsx("div",{className:"mt-3",children:jsx(Po,{market:e,event:t,onSelectOutcome:o,labelFormat:"action"})})]}),jsxs("button",{type:"button",className:"mt-auto flex items-center gap-x-1 pt-4 text-[10px] font-normal text-neutral-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:i=>{i.stopPropagation(),r();},children:[jsx(Ml,{className:"h-3 w-3"}),n("predict.event.back")]})]})}function Co({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 Ml({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 Eo({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 Ol=768,To=1024,Al=1280,Dl=8,Fl=224,Hl=304,Bl=114;function $l(e){return e>=Al?4:e>=To?3:e>=Ol?2:1}function Wl(e){return e>=To?Hl:Fl}function Lo({events:e,hasMore:t=false,onFetchMore:r,onSelect:o,onSelectOutcome:n,getEventHref:a,LinkComponent:i,onHover:s}){let l=useRef(null),c=useRef(null),{width:u=0,height:d=0}=useResizeObserver({ref:l}),p=$l(u),m=Wl(u),g=Math.ceil(e.length/p)||0,f=!t&&e.length>0,h=g+(t?1:0)+(f?1:0),x=useCallback(v=>v<g,[g]),R=useCallback(async()=>{r?.();},[r]),N=useInfiniteLoader({isRowLoaded:x,loadMoreRows:R,rowCount:h,threshold:3}),w=useCallback(()=>{c.current?.scrollToRow({index:0,behavior:"smooth"});},[]);return jsx("div",{ref:l,className:"@container w-full h-full",children:d>0&&jsx(List,{listRef:c,className:"no-scrollbar",style:{height:d},onRowsRendered:N,rowComponent:zl,rowCount:h,rowHeight:v=>f&&v===h-1?Bl:(m),rowProps:{events:e,columnCount:p,dataRowCount:g,showEndOfList:f,totalRowCount:h,onSelect:o,onSelectOutcome:n,getEventHref:a,LinkComponent:i,onHover:s,onScrollToTop:w}})})}function zl({index:e,style:t,events:r,columnCount:o,dataRowCount:n,showEndOfList:a,totalRowCount:i,onSelect:s,onSelectOutcome:l,getEventHref:c,LinkComponent:u,onHover:d,onScrollToTop:p}){if(a&&e===i-1)return jsx("div",{style:t,children:jsx(Ul,{onScrollToTop:p})});if(e>=n)return jsx("div",{style:t,className:"flex justify-center items-start pt-4",children:jsx(Spinner,{size:"sm"})});let m=e*o,g=r.slice(m,m+o),f=o-g.length;return jsx("div",{style:t,children:jsxs("div",{className:"flex w-full h-full",children:[g.map(h=>h==null?null:jsx("div",{className:"flex-1 min-w-0 flex",style:{padding:Dl},children:jsx(wo,{event:h,href:c?.(h),LinkComponent:u,onSelect:s,onSelectOutcome:l,onHover:d})},h.slug)),f>0&&Array.from({length:f}).map((h,x)=>jsx("div",{style:{flex:1,minWidth:0}},`spacer-${x}`))]})})}function Ul({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 _o({tagSlugSelection:e,limit:t=48,status:r,sort_by:o,sort_asc:n,source:a,with_markets:i,timeRemaining:s,minVolume:l,minLiquidity:c,onSelect:u,onSelectOutcome:d,getEventHref:p,LinkComponent:m,onHover:g}){let{data:f,hasMore:h,fetchMore:x,isFetching:R}=fo({tagSlugSelection:e,limit:t,status:r,sort_by:o,sort_asc:n,source:a,with_markets:i,timeRemaining:s,minVolume:l,minLiquidity:c});return R?jsx(Br,{count:48}):jsx(Lo,{events:f,hasMore:h,onFetchMore:x,onSelect:u,onSelectOutcome:d,getEventHref:p,LinkComponent:m,onHover:g})}function og({onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:o,onHover:n}){let[a,i]=useState({categorySlug:null,tagSlug:null}),[s,l]=useState(Fr),{isOpen:c,onOpen:u,onClose:d}=useDisclosure(),{onOpen:p}=useAsyncModal(yt),m=useCallback((v,B,b)=>{t?.(v,B,b),p({params:{event:v,market:B,initialOutcome:b}});},[t,p]),g=useCallback(v=>{i(v);},[]),f=useCallback(v=>{l(B=>({...B,sortPreset:v}));},[]),h=useCallback(v=>{l(B=>({...B,sortAsc:v}));},[]),x=useCallback(v=>{l(v);},[]),R=useMemo(()=>co[s.sortPreset].sort_by,[s.sortPreset]),N=useMemo(()=>Hr(s),[s]),w=useMemo(()=>jsx(uo,{sortPreset:s.sortPreset,onSortChange:f,sortAsc:s.sortAsc,onSortAscChange:h,onFilterPress:u,filterCount:N}),[s.sortPreset,s.sortAsc,N,f,h,u]);return jsxs("div",{className:"flex h-full w-full max-w-[1680px] mx-auto flex-col gap-y-3",children:[jsx(Bn,{onSelect:g,trailing:w}),jsx(so,{isOpen:c,onClose:d,value:s,onChange:x}),jsx("div",{className:"min-h-0 flex-1",children:jsx(_o,{tagSlugSelection:a,sort_by:R,sort_asc:s.sortAsc,source:s.source,timeRemaining:s.timeRemaining,minVolume:s.minVolume,minLiquidity:s.minLiquidity,onSelect:e,onSelectOutcome:m,getEventHref:r,LinkComponent:o,onHover:n})}),jsx(jt,{})]})}var Yr=40,Jt=36,Et=480,qr=Et-Jt;function Do({event:e,walletAddress:t,onCancelOrder:r}){let{t:o}=useTranslation(),[n,a]=useState("positions"),i=useMemo(()=>e.markets?.map(d=>d.slug)??[],[e.markets]),{data:s}=usePositions({source:e.source,user:t??""}),l=useMemo(()=>!s?.positions||!t?0:i.length===0?s.positions.length:s.positions.filter(d=>d.market&&i.includes(d.market.slug)).length,[s?.positions,i,t]),u=[{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:u.map(d=>jsx("button",{type:"button",onClick:()=>a(d.key),className:cn$1("px-3 py-2 text-sm font-medium transition-colors cursor-pointer",n===d.key?"text-foreground border-b-2 border-primary":"text-neutral hover:text-foreground"),children:d.label},d.key))}),t?jsxs("div",{style:{height:Et},children:[n==="positions"&&jsx(Zl,{source:e.source,walletAddress:t,marketSlugs:i}),n==="orders"&&jsx(ec,{source:e.source,walletAddress:t,marketSlugs:i,onCancelOrder:r}),n==="trades"&&jsx(nc,{source:e.source,walletAddress:t})]}):jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:Et},children:o("predict.trade.connectWallet")})]})}function Zl({source:e,walletAddress:t,marketSlugs:r}){let{t:o}=useTranslation(),{data:n,isLoading:a}=usePositions({source:e,user:t}),i=useMemo(()=>n?.positions?r.length===0?n.positions:n.positions.filter(s=>s.market&&r.includes(s.market.slug)):[],[n?.positions,r]);return a?jsx(Qr,{}):i.length===0?jsx(Xr,{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:Jt},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:qr},rowComponent:Jl,rowCount:i.length,rowHeight:Yr,rowProps:{positions:i,closeLabel:o("predict.positions.close")}})]})}function Jl({index:e,style:t,positions:r,closeLabel:o}){let n=r[e];if(!n)return null;let a=n.pnl??0,i=n.pnl_percent??0,s=n.avg_price??0,l=n.current_price??0,c=a>0?"text-success":a<0?"text-danger":"text-foreground",u=a>0?"+":"",d=n.market?.outcomes?.[0]?.label??n.market?.question??"\u2014",p=n.side,m=n.size,g=n.size*l,f=n.market?.end_at?ac(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:d}),jsx("span",{className:cn$1("text-[10px] font-medium",p.toLowerCase()==="yes"?"text-primary":"text-secondary"),children:p})]})}),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:["$",g.toFixed(2)]}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:Qt(s)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:Qt(l)}),jsxs("div",{className:cn$1("flex-[1.5] pr-2 text-right font-mono whitespace-nowrap",c),children:[u,"$",Math.abs(a).toFixed(2),jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",u,i.toFixed(1),"%)"]})]}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",m.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:f}),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 ec({source:e,walletAddress:t,marketSlugs:r,onCancelOrder:o}){let{t:n}=useTranslation(),{data:a,isLoading:i,fetchNextPage:s,hasNextPage:l}=useInfiniteOrders({source:e,wallet_address:t}),c=useCancelOrder(),u=useMemo(()=>{let x=a?.pages?.flatMap(w=>w.items)??[],R=new Set(["live","open","submitted","pending"]),N=x.filter(w=>R.has(w.status));return r.length>0&&(N=N.filter(w=>w.market_id&&r.includes(w.market_id))),N},[a?.pages,r]),d=useCallback(x=>{o?o(x.id):c.mutate({source:x.source,id:x.id});},[o,c]),p=u.length,m=p+(l?1:0),g=useCallback(x=>x<p,[p]),f=useCallback(async()=>{await s();},[s]),h=useInfiniteLoader({isRowLoaded:g,loadMoreRows:f,rowCount:m,threshold:5});return i?jsx(Qr,{}):u.length===0&&!l?jsx(Xr,{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:Jt},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:qr},onRowsRendered:h,rowComponent:tc,rowCount:m,rowHeight:Yr,rowProps:{orders:u,itemCount:p,onCancel:d,isCancelling:c.isPending,cancelLabel:n("predict.openOrders.cancel")}})]})}function tc({index:e,style:t,orders:r,itemCount:o,onCancel:n,isCancelling:a,cancelLabel:i}){if(e>=o)return jsx("div",{style:t,className:"flex justify-center items-center",children:jsx(Spinner,{size:"sm"})});let s=r[e];if(!s)return null;let l=s.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:s.side})}),jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:s.outcome??"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-neutral capitalize",children:s.order_type??"limit"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:s.price?Qt(parseFloat(s.price)):"\u2014"}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:[s.size_matched??"0","/",s.original_size??"\u2014"]}),jsx("div",{className:"w-20 shrink-0 pr-2",children:jsx(rc,{status:s.status})}),jsx("div",{className:"w-16 shrink-0 text-right",children:jsx("button",{type:"button",onClick:()=>n(s),disabled:a,className:"text-[10px] text-danger hover:text-danger/80 cursor-pointer disabled:opacity-50 transition-colors",children:a?jsx(Spinner,{size:"sm"}):i})})]})}function rc({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 nc({source:e,walletAddress:t}){let{t:r}=useTranslation(),{data:o,isLoading:n,fetchNextPage:a,hasNextPage:i}=useInfiniteTrades({source:e,wallet:t,limit:50}),s=useMemo(()=>o?.pages?.flatMap(m=>m.items)??[],[o?.pages]),l=s.length,c=l+(i?1:0),u=useCallback(m=>m<l,[l]),d=useCallback(async()=>{await a();},[a]),p=useInfiniteLoader({isRowLoaded:u,loadMoreRows:d,rowCount:c,threshold:5});return n?jsx(Qr,{}):s.length===0&&!i?jsx(Xr,{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:Jt},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:qr},onRowsRendered:p,rowComponent:oc,rowCount:c,rowHeight:Yr,rowProps:{trades:s,itemCount:l}})]})}function oc({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 a=n.side?.toUpperCase()==="BUY",i=sc(n.timestamp),s=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",a?"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:Qt(s)}),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:i})]})}function Xr({message:e}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:Et},children:e})}function Qr(){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:Et},children:Array.from({length:6}).map((e,t)=>jsx(Skeleton,{className:"h-8 w-full rounded-md"},t))})}function Qt(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(1)}\xA2`}function sc(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"),a=t.getMinutes().toString().padStart(2,"0");return `${r}/${o} ${n}:${a}`}function ac(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return "\u2014"}}function Mt({marketCount:e=4,showBack:t}){return jsxs("div",{className:"flex w-full flex-col gap-4 animate-pulse lg:gap-6",children:[t&&jsx("div",{className:"h-5"}),jsxs("div",{className:"flex items-center gap-x-2 h-16 lg:h-20 lg:gap-x-4",children:[jsx(Skeleton,{className:"size-16 shrink-0 rounded-lg lg:size-20"}),jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[jsxs("div",{className:"flex items-center gap-1.5",children:[jsx(Skeleton,{className:"h-3.5 w-12 rounded"}),jsx(Skeleton,{className:"h-3.5 w-10 rounded"}),jsx(Skeleton,{className:"h-3.5 w-10 rounded"})]}),jsx(Skeleton,{className:"h-5 w-full max-w-sm rounded lg:h-6"})]})]}),jsx(Skeleton,{className:"h-4 w-48 rounded"}),jsxs("div",{className:"flex flex-col gap-3",children:[jsxs("div",{className:"flex items-center gap-4",children:[jsx(Skeleton,{className:"h-4 w-24 rounded"}),jsx(Skeleton,{className:"h-4 w-20 rounded"})]}),jsx(Skeleton,{className:"h-[300px] w-full rounded-xl"}),jsxs("div",{className:"flex items-center justify-between",children:[jsx(Skeleton,{className:"h-4 w-20 rounded"}),jsxs("div",{className:"flex items-center gap-2",children:[jsx(Skeleton,{className:"h-7 w-[200px] rounded-lg"}),jsx(Skeleton,{className:"h-7 w-28 rounded-lg"})]})]})]}),jsxs("div",{className:"flex flex-col",children:[jsxs("div",{className:"flex items-center py-2",children:[jsx("div",{className:"flex-1"}),jsx(Skeleton,{className:"h-3.5 w-14 rounded"}),jsx("div",{className:"flex-1"})]}),Array.from({length:e}).map((r,o)=>jsxs("div",{className:"flex items-center gap-x-2 border-b border-border py-2.5 lg:gap-x-3",children:[jsx(Skeleton,{className:"size-5 shrink-0 rounded-lg lg:size-8"}),jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[jsx(Skeleton,{className:"h-3.5 w-32 rounded lg:h-4 lg:w-48"}),jsx(Skeleton,{className:"h-2.5 w-16 rounded"})]}),jsx(Skeleton,{className:"h-4 w-10 rounded"}),jsxs("div",{className:"flex items-center gap-2",children:[jsx(Skeleton,{className:"h-8 w-16 rounded-lg lg:w-24"}),jsx(Skeleton,{className:"h-8 w-16 rounded-lg lg:w-24"})]})]},o))]}),jsxs("div",{className:"flex flex-col gap-2",children:[jsx(Skeleton,{className:"h-4 w-16 rounded"}),jsx(Skeleton,{className:"h-3.5 w-full rounded"}),jsx(Skeleton,{className:"h-3.5 w-4/5 rounded"}),jsx(Skeleton,{className:"h-3.5 w-3/5 rounded"})]})]})}function Fo(){return jsxs("div",{className:"flex flex-col gap-3 rounded-xl border border-border p-4 animate-pulse",children:[jsx(Skeleton,{className:"h-10 w-full rounded-lg"}),jsx(Skeleton,{className:"h-24 w-full rounded-lg"}),jsx(Skeleton,{className:"h-10 w-full rounded-lg"})]})}var Wo="var(--color-bullish)",zo="var(--color-bearish)";function Tt(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 cc(e,t){return e<=0||t<=0?0:Math.pow(e/t,.3)}function dc(e,t){let r=new Float64Array(101),o=new Float64Array(101);for(let m of e){let g=Math.round(m.price*100);g>=0&&g<=100&&(r[g]+=m.quantity);}for(let m of t){let g=Math.round(m.price*100);g>=0&&g<=100&&(o[g]+=m.quantity);}let n=0,a=0,i=new Float64Array(101),s=new Float64Array(101);for(let m=100;m>=0;m--)n+=r[m],a+=r[m]*m/100,i[m]=n,s[m]=a;let l=0,c=0,u=new Float64Array(101),d=new Float64Array(101);for(let m=0;m<=100;m++)l+=o[m],c+=o[m]*m/100,u[m]=l,d[m]=c;let p=Math.max(i[0]??0,u[100]??0);return Array.from({length:101},(m,g)=>{let f=i[g]>0,h=u[g]>0,x=i[g]||u[g],R=r[g]>0||o[g]>0;return {priceCents:g,displayHeight:cc(x,p),opacity:x>0?R?1:.5:0,isBid:f,isAsk:h,bidCumTotal:i[g],askCumTotal:u[g],bidCumCost:s[g],askCumCost:d[g]}})}function uc({info:e}){let{t}=useTranslation(),r=e.isBid?Wo:zo,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:Tt(Math.round(e.cumTotal))})}),jsxs("div",{style:{color:r},children:["$",Tt(Math.round(e.cumCost))]})]})}var pc=memo(function({slot:t,onEnter:r,onLeave:o}){let n=useRef(null),a=t.isBid||t.isAsk,i=t.isBid?Wo:t.isAsk?zo: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:a?"crosshair":"default"},onMouseEnter:()=>r(t,n.current),onMouseLeave:o,children:a&&jsx("div",{ref:n,style:{position:"absolute",bottom:0,left:0,width:"100%",height:`${t.displayHeight*100}%`,backgroundColor:i,opacity:t.opacity}})})}),mc=[0,10,20,30,40,50,60,70,80,90,100];function fc(){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:mc.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 Uo({bids:e,asks:t}){let{t:r}=useTranslation(),o=useMemo(()=>dc(e,t),[e,t]),n=useMemo(()=>{let d=e.length>0?Math.max(...e.map(m=>m.price)):0,p=t.length>0?Math.min(...t.map(m=>m.price)):1;return Math.round((d+p)/2*100)},[e,t]),a=useMemo(()=>o.some(d=>d.isBid||d.isAsk),[o]),[i,s]=useState(null),l=useRef(null),c=useCallback((d,p)=>{l.current&&(l.current.style.filter=""),p?(p.style.filter="brightness(1.5)",l.current=p):l.current=null,d.isBid||d.isAsk?s({priceCents:d.priceCents,isBid:d.isBid,cumTotal:d.isBid?d.bidCumTotal:d.askCumTotal,cumCost:d.isBid?d.bidCumCost:d.askCumCost,leftPct:d.priceCents}):s(null);},[]),u=useCallback(()=>{l.current&&(l.current.style.filter="",l.current=null),s(null);},[]);return a?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"}}),i&&jsx(uc,{info:i}),o.map(d=>jsx(pc,{slot:d,onEnter:c,onLeave:u},d.priceCents))]}),jsx(fc,{})]}):jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:r("predict.orderBook.noData")})}function Jr(e){let t=e*100,r=Math.round(t*10)/10;return Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`}function Ko(){let{t:e}=useTranslation();return jsxs("div",{className:"flex items-center justify-center gap-x-2 h-full text-neutral text-xs",children:[jsx(Spinner,{size:"sm"}),jsx("span",{children:e("predict.orderBook.loading")})]})}function Yo({market:e,outcome:t="yes",onTradeAction:r}){let{t:o}=useTranslation(),[n,a]=useState("depth"),i=t==="no",s=e.source,{data:l,isLoading:c}=useOrderbook({slug:e.slug,source:s}),u=useMemo(()=>((i?l?.asks:l?.bids)??[]).map(h=>({price:i?1-h.price:h.price,quantity:h.size})),[l?.bids,l?.asks,i]),d=useMemo(()=>((i?l?.bids:l?.asks)??[]).map(h=>({price:i?1-h.price:h.price,quantity:h.size})),[l?.bids,l?.asks,i]),p=useMemo(()=>u.length>0?Math.max(...u.map(f=>f.price)):null,[u]),m=useMemo(()=>d.length>0?Math.min(...d.map(f=>f.price)):null,[d]),g=useMemo(()=>{if(p==null||m==null)return null;let f=(m-p)*100;return Math.round(f*10)/10},[p,m]);return jsxs("div",{className:"flex flex-col 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:g!=null?`${o("predict.orderBook.spread")}: ${Number.isInteger(g)?`${g}\xA2`:`${g.toFixed(1)}\xA2`}`:null}),jsxs("span",{className:"flex flex-1 items-center justify-center gap-x-1 whitespace-nowrap",children:[p!=null&&jsxs("span",{style:{color:"var(--color-bullish)"},children:[o("predict.trade.bestBid"),": ",Jr(p)]}),p!=null&&m!=null&&jsx("span",{className:"text-neutral",children:"|"}),m!=null&&jsxs("span",{style:{color:"var(--color-bearish)"},children:[o("predict.trade.bestAsk"),": ",Jr(m)]})]}),jsx("div",{className:"flex flex-1 justify-end",children:jsx("button",{type:"button",title:n==="depth"?"Orderbook":"Depth chart",onClick:()=>a(f=>f==="depth"?"table":"depth"),className:"flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground",children:n==="depth"?jsx(OrderbookTableIcon,{className:"h-4 w-4"}):jsx(OrderbookDepthIcon,{className:"h-4 w-4"})})})]}),jsxs("div",{className:"flex-1 min-h-0 overflow-hidden",children:[n==="depth"&&jsx(Fragment,{children:c?jsx(Ko,{}):jsx(Uo,{bids:u,asks:d})}),n==="table"&&jsx(Fragment,{children:c?jsx(Ko,{}):jsx(yc,{bids:u,asks:d,bestBid:p??void 0,bestAsk:m??void 0,spread:g??void 0})})]})]})}var Vo=8;function yc({bids:e,asks:t,spread:r}){let{t:o}=useTranslation(),n=useMemo(()=>[...t].sort((l,c)=>l.price-c.price).slice(0,Vo).reverse(),[t]),a=useMemo(()=>[...e].sort((l,c)=>c.price-l.price).slice(0,Vo),[e]),i=useMemo(()=>{let l=[...n,...a].map(c=>c.quantity);return Math.max(...l,1)},[n,a]);return n.length===0&&a.length===0?jsx("div",{className:"flex items-center justify-center h-full text-xs text-neutral",children:o("predict.orderBook.empty")}):jsxs("div",{className:"flex flex-col h-full overflow-y-auto text-xs font-mono select-none",children:[n.map(l=>jsx(jo,{price:l.price,quantity:l.quantity,side:"ask",maxQty:i},`ask-${l.price}`)),jsx("div",{className:"flex items-center justify-center gap-x-2 py-1 border-y border-border text-neutral text-[10px]",children:r!=null&&jsxs("span",{children:[o("predict.orderBook.spread"),":"," ",Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`]})}),a.map(l=>jsx(jo,{price:l.price,quantity:l.quantity,side:"bid",maxQty:i},`bid-${l.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:o("predict.orderBook.price")}),jsx("span",{className:"text-center",children:o("predict.orderBook.contracts")}),jsx("span",{className:"text-right",children:o("predict.orderBook.total")})]})]})}function jo({price:e,quantity:t,side:r,maxQty:o}){let n=r==="ask",a=Math.min(t/o*100,100),i=n?"bg-bearish/10":"bg-bullish/10",s=n?"text-bearish":"text-bullish",l=Tt(Math.round(t)),c=Math.round(t*e),u=`$${Tt(c)}`;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 ${i} transition-[width] duration-200`,style:{width:`${a}%`}}),jsx("span",{className:`relative z-10 ${s}`,children:Jr(e)}),jsx("span",{className:"relative z-10 text-foreground text-center",children:l}),jsx("span",{className:"relative z-10 text-foreground text-right",children:u})]})}var rn=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}},rr=4,qo=["#22d3ee","#a3e635","#f97316","#f472b6","#a78bfa"];function _c(e,t){let r=new Date(e);return t===ChartRange.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Ic(e,t){let r=new Date(e);return t===ChartRange.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):t===ChartRange.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 Xo(e){return `${(e*100).toFixed(2)}%`}var Oc=[{range:ChartRange.ONE_DAY,label:"1D"},{range:ChartRange.ONE_WEEK,label:"1W"},{range:ChartRange.ONE_MONTH,label:"1M"},{range:ChartRange.ALL,label:"ALL"}];function Ac({value:e,onChange:t}){return jsx("div",{style:{display:"flex",alignItems:"center",gap:2},children:Oc.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 Dc(){let e=useRef(null),t=useRef(null),r=useCallback(n=>{let a=e.current,i=t.current;if(!a||!i)return;let s=a.getBoundingClientRect(),l=(n.clientX-s.left)/s.width*100;i.style.background=`linear-gradient(to right, transparent ${l}%, rgba(0,0,0,0.55) ${l}%)`,i.style.opacity="1";},[]),o=useCallback(()=>{t.current&&(t.current.style.opacity="0");},[]);return {wrapperRef:e,overlayRef:t,onMouseMove:r,onMouseLeave:o}}function Fc({active:e,payload:t,label:r,labelMap:o,allSeries:n,range:a}){if(!e||!n?.length)return null;let i=new Map;t?.forEach(l=>i.set(l.dataKey,l));let s=n.map(l=>i.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"?Ic(r,a):r}),s.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?Xo(l.value):"--"})]},l.dataKey))]})}function Hc({markets:e,selectedSlugs:t,colorMap:r,onToggle:o}){let[n,a]=useState(false),i=useRef(null);useEffect(()=>{if(!n)return;function c(u){i.current&&!i.current.contains(u.target)&&a(false);}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[n]);let s=t.length>=rr,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(c=>jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:r.get(c)??"#6b7280",display:"inline-block"}},c))}),jsx("span",{style:{color:"#e5e7eb",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.length===1?(()=>{let c=e.find(u=>u.slug===t[0]);return c?.outcomes?.[0]?.label??c?.question??"1 market"})():`${t.length} / ${e.length} markets`})]});return jsxs("div",{ref:i,style:{position:"relative",display:"inline-block",width:200},children:[jsxs("button",{onClick:()=>a(c=>!c),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 ",rr," markets"]}),e.map(c=>{let u=t.includes(c.slug),d=!u&&s,p=u&&t.length===1,m=r.get(c.slug)??"#6b7280",g=c.outcomes.find(h=>h.label.toLowerCase()==="yes")??c.outcomes[0],f=g?.price!=null?`${Math.round(g.price*100)}%`:null;return jsxs("button",{onClick:()=>{p||d||o(c.slug);},style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"7px 12px",border:"none",background:u?"rgba(255,255,255,0.05)":"transparent",cursor:d||p?"not-allowed":"pointer",opacity:d?.35:1,textAlign:"left",transition:"background 0.1s"},onMouseEnter:h=>{!d&&!p&&(h.currentTarget.style.background="rgba(255,255,255,0.07)");},onMouseLeave:h=>{h.currentTarget.style.background=u?"rgba(255,255,255,0.05)":"transparent";},children:[jsx("span",{style:{width:16,height:16,borderRadius:4,border:u?`2px solid ${m}`:"2px solid rgba(255,255,255,0.2)",background:u?`${m}30`:"transparent",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:u&&jsx("svg",{width:"9",height:"7",viewBox:"0 0 9 7",fill:"none",children:jsx("path",{d:"M1 3.5L3.5 6L8 1",stroke:m,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:m,flexShrink:0}}),jsx("span",{style:{color:u?"#f9fafb":"#9ca3af",fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c.outcomes?.[0]?.label??c.question}),f&&jsx("span",{style:{color:m,fontWeight:700,fontSize:12,flexShrink:0},children:f})]},c.slug)})]})]})}function Bc({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",a=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:a!=null?Xo(a):"--"})]})]},o.marketSlug)})})}function $c(e){let t=Math.floor(e.length/2);return e.length%2===1?e[t]:(e[t-1]+e[t])/2}function Wc(e,t){if(e.length<=t)return e;let r=[],o=e.length/t;for(let n=0;n<t;n++){let a=Math.floor(n*o),i=Math.min(Math.floor((n+1)*o),e.length),s=e.slice(a,i),l=s.map(c=>c.price).sort((c,u)=>c-u);r.push({timestamp:s[s.length-1].timestamp,price:$c(l)});}return r}function zc(e,t=200){if(e.length===0)return [];let r=e.map(s=>({...s,data:Wc(s.data,t)})),o=new Set;r.forEach(s=>s.data.forEach(l=>o.add(l.timestamp)));let n=Array.from(o).sort((s,l)=>s-l),a=r.map(s=>{let l=new Map;return s.data.forEach(c=>l.set(c.timestamp,c.price)),{slug:s.marketSlug,map:l}}),i=new Map;return n.map(s=>{let l={timestamp:s};return a.forEach(({slug:c,map:u})=>{let d=u.get(s);if(d!==void 0)i.set(c,d),l[c]=d;else {let p=i.get(c);p!==void 0&&(l[c]=p);}}),l})}function Qo(e){return jsx(rn,{children:jsx(Uc,{...e})})}function Uc({event:e,isLoading:t,className:r,volume:o}){let n=useMemo(()=>(e.markets??[]).filter(C=>C.status==="open"),[e.markets]),a=useMemo(()=>[...n].sort((C,A)=>{let K=P=>(P.outcomes.find(ne=>ne.label.toLowerCase()==="yes")??P.outcomes[0])?.price??0;return K(A)-K(C)}),[n]),[i,s]=useState(()=>a.slice(0,rr).map(C=>C.slug)),[l,c]=useState(Kt),u=useMemo(()=>{let C=new Map;return i.forEach((A,K)=>{C.set(A,qo[K%qo.length]);}),C},[i]),d=useMemo(()=>n.filter(C=>i.includes(C.slug)),[n,i]),{series:p,isLoading:m}=useMarketHistory(d,l),g=t||m,f=useMemo(()=>{if(p.length>0&&p.some(K=>K.data.length>0))return p;let C=Date.now(),A=864e5;return d.map(K=>{let ne=(K.outcomes?.find(me=>me.label.toLowerCase()==="yes")??K.outcomes?.[0])?.price??.5;return {marketSlug:K.slug,label:K.outcomes?.[0]?.label??K.question,data:[{timestamp:C-7*A,price:ne},{timestamp:C,price:ne}]}})},[p,d]),h=useMemo(()=>l===ChartRange.ONE_DAY?96:l===ChartRange.ONE_WEEK?168:l===ChartRange.ONE_MONTH?180:300,[l]),x=useMemo(()=>zc(f,h),[f,h]),R=useMemo(()=>{if(x.length===0)return [0,1];let C=1/0,A=-1/0;if(i.forEach(P=>{x.forEach(ne=>{let me=ne[P];me!=null&&(me<C&&(C=me),me>A&&(A=me));});}),!isFinite(C))return [0,1];let K=Math.max((A-C)*.15,.05);return [Math.max(0,C-K),Math.min(1,A+K)]},[x,i]),N=useMemo(()=>{let C=new Map;return f.forEach(A=>{A.data.length>0&&C.set(A.marketSlug,A.data[A.data.length-1].price);}),C},[f]),w=useMemo(()=>{let C=new Map;return f.forEach(A=>C.set(A.marketSlug,A.label)),C},[f]),v=useMemo(()=>f.map(C=>({slug:C.marketSlug,color:u.get(C.marketSlug)??"#6b7280"})),[f,u]),{wrapperRef:B,overlayRef:b,onMouseMove:X,onMouseLeave:j}=Dc(),ie=useCallback(C=>{s(A=>A.includes(C)?A.length<=1?A:A.filter(K=>K!==C):A.length>=rr?A:[...A,C]);},[]),[U,F]=useState(null),W=useRef(null),$=useRef(""),oe=useRef(0),pe=!g&&x.length>0;return jsxs("div",{className:r,style:{display:"flex",flexDirection:"column",gap:12},children:[jsx(Bc,{series:f,colorMap:u,displayValues:U??N}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0},children:[jsx("div",{ref:B,style:{height:300,width:"100%",userSelect:"none",position:"relative"},onMouseMove:pe?C=>{X(C),cancelAnimationFrame(oe.current),oe.current=requestAnimationFrame(()=>{F(W.current);});}:void 0,onMouseLeave:pe?()=>{j(),cancelAnimationFrame(oe.current),$.current="",W.current=null,F(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"}})}):x.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:b,style:{position:"absolute",inset:0,opacity:0,pointerEvents:"none",zIndex:1}}),jsx(ResponsiveContainer,{width:"100%",height:"100%",children:jsxs(LineChart,{data:x,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:C=>_c(C,l),axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},minTickGap:70}),jsx(YAxis,{domain:R,tickFormatter:C=>`${Math.round(C*100)}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},width:40,tickCount:6}),jsx(Tooltip,{content:C=>{let A=C;if(A.active&&A.payload?.length){let K=A.payload.map(P=>`${P.dataKey}:${P.value}`).join(",");if(K!==$.current){$.current=K;let P=new Map;A.payload.forEach(ne=>{ne.value!=null&&P.set(ne.dataKey,ne.value);}),W.current=P;}}return jsx(Fc,{...A,labelMap:w,allSeries:v,range:l})},cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},wrapperStyle:{zIndex:2},isAnimationActive:false}),f.map(C=>{let A=u.get(C.marketSlug)??"#6b7280";return jsx(Line,{type:"linear",dataKey:C.marketSlug,stroke:A,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:A},connectNulls:true,isAnimationActive:false},C.marketSlug)}),U==null&&x.length>0&&f.map(C=>{let A=x[x.length-1],K=A[C.marketSlug];if(K==null)return null;let P=u.get(C.marketSlug)??"#6b7280";return jsx(ReferenceDot,{x:A.timestamp,y:K,ifOverflow:"extendDomain",shape:ne=>{let{cx:me,cy:le}=ne;return me==null||le==null?jsx("g",{}):jsxs("g",{children:[jsxs("circle",{cx:me,cy:le,r:6,fill:P,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:me,cy:le,r:3.5,fill:P})]})}},`pulse-${C.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:["$",Math.round(o).toLocaleString()," vol"]}),jsx("div",{style:{flex:1,minWidth:0}}),jsx(Ac,{value:l,onChange:c}),a.length>1&&jsx("div",{style:{width:"100%",display:"flex",alignItems:"center"},children:jsx(Hc,{markets:a,selectedSlugs:i,colorMap:u,onToggle:ie})})]})]})]})}function Rt(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function nd(e){return `${parseFloat((e*100).toFixed(2))}%`}function Zo(e){let t=e*100;return t<1&&t>0?"< 1":parseFloat(t.toFixed(2)).toString()}function nr(e){return e.outcomes?.[0]?.label??e.question}function od(e){switch(e){case "polymarket":return "Polymarket";case "kalshi":return "Kalshi";default:return e}}function Lt(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(),a=t.getHours().toString().padStart(2,"0"),i=t.getMinutes().toString().padStart(2,"0");return `${r} ${o}, ${n} ${a}:${i}`}function Jo(e){let[t,r]=useState(Date.now());if(useEffect(()=>{if(!e)return;let u=setInterval(()=>r(Date.now()),1e3);return ()=>clearInterval(u)},[e]),!e)return null;let o=new Date(e).getTime();if(isNaN(o))return null;let n=o-t;if(n<=0)return null;let a=Math.floor(n/864e5),i=Math.floor(n%864e5/36e5),s=Math.floor(n%36e5/6e4),l=Math.floor(n%6e4/1e3),c=[];return a>0&&c.push(`${a}d`),c.push(`${String(i).padStart(2,"0")}h`),c.push(`${String(s).padStart(2,"0")}m`),c.push(`${String(l).padStart(2,"0")}s`),c.join(" ")}function es(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"),a=t.getDate().toString().padStart(2,"0"),i=t.getFullYear(),s=-t.getTimezoneOffset(),l=s>=0?"+":"-",c=String(Math.abs(Math.floor(s/60))).padStart(2,"0");return `${r}:${o} ${n}/${a}/${i} (${l}${c})`}function ns({event:e,onTradeAction:t}){let{t:r}=useTranslation(),{ref:o,isCollapsed:n}=useScrollCollapse(),a=useMemo(()=>{let d=[...e.markets||[]],p=d.filter(g=>g.status==="open").sort((g,f)=>Rt(f)-Rt(g)),m=d.filter(g=>g.status!=="open").sort((g,f)=>Rt(f)-Rt(g));return [...p,...m]},[e.markets]),i=e.status==="closed"||e.status==="voided",s=Jo(i?void 0:e.start_at),l=Jo(i?void 0:e.end_at),c=es(e.start_at),u=es(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((d,p)=>jsxs(Fragment$1,{children:[p>0&&jsx("span",{className:"text-sm text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-sm text-neutral truncate",children:d.label})]},d.slug)),jsx(ld,{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})]})]}),(s||l||i)&&jsx("div",{className:"flex items-center gap-x-2 text-xs lg:text-sm font-mono",children:i?u&&jsx("span",{className:"text-neutral",children:r("predict.event.endedAt",{time:u})}):s?jsxs(Fragment,{children:[jsx("span",{className:"text-foreground",children:r("predict.event.beginsIn",{time:s})}),c&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-neutral",children:c})]})]}):l?jsxs(Fragment,{children:[jsx("span",{className:"text-foreground",children:r("predict.event.endsIn",{time:l})}),u&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-neutral",children:u})]})]}):null}),jsx(Qo,{event:e,volume:e.volume??void 0}),jsx(sd,{markets:a,onTradeAction:t}),jsx(id,{markets:a,event:e})]})}var ts=5;function sd({markets:e,onTradeAction:t}){let{t:r}=useTranslation(),{isMobile:o}=useScreen(),[n,a]=useState(false),[i,s]=useState(null),l=e.find(f=>f.status==="open")?.slug,[c,u]=useState(l?`${l}:yes`:null);if(e.length===0)return null;let d=e.length>ts,p=n?e:e.slice(0,ts),m=f=>{s(h=>h===f?null:f);},g=(f,h,x)=>{u(`${f.slug}:${h}`),o||s(f.slug),t?.(f,h,x);};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:p.map(f=>{let h=Rt(f),x=f.outcomes[1]?.best_ask??f.outcomes[1]?.price,R=i===f.slug;return jsx(ad,{market:f,yesPrice:h,noPrice:x??void 0,activeYes:c===`${f.slug}:yes`,activeNo:c===`${f.slug}:no`,isExpanded:R,onToggleExpand:()=>m(f.slug),onTradeAction:g},f.slug)})})]}),d&&jsxs("button",{type:"button",onClick:()=>a(f=>!f),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 ad({market:e,yesPrice:t,noPrice:r,activeYes:o,activeNo:n,isExpanded:a,onToggleExpand:i,onTradeAction:s}){let{t:l}=useTranslation(),c=e.status==="open",u=e.volume?`$${Math.round(e.volume).toLocaleString("en-US")} vol`:void 0;return jsxs(Fragment,{children:[jsxs("tr",{className:"cursor-pointer border-b border-border text-xs hover:bg-content2 lg:text-base",onClick:i,role:"button",tabIndex:0,onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),i());},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:nr(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:nr(e)}),u&&jsx("span",{className:"text-[8px] text-neutral lg:text-xxs",children:u})]})]})}),jsx("td",{className:"py-2 text-left text-foreground lg:text-center",children:nd(t)}),jsx("td",{className:"py-2 pr-1 lg:pr-2",children:c?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",o?"bg-primary text-primary-foreground":"bg-primary/10 text-primary"),onClick:d=>{d.stopPropagation(),s?.(e,"yes","buy");},children:l("predict.market.action.yes",{price:Zo(t)})}),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",n?"bg-secondary text-secondary-foreground":"bg-secondary/10 text-secondary"),onClick:d=>{d.stopPropagation(),s?.(e,"no","buy");},children:r!=null?l("predict.market.action.no",{price:Zo(r)}):l("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"?l("predict.event.status.closed"):e.status==="voided"?l("predict.event.status.voided"):l("predict.event.status.pending")})})})]}),a&&jsx("tr",{children:jsx("td",{colSpan:3,className:"pb-3",children:jsx("div",{className:"max-h-100 overflow-y-auto",children:jsx(Yo,{market:e,outcome:n?"no":"yes",onTradeAction:s})})})})]})}function id({markets:e,event:t}){let{t:r}=useTranslation(),[o,n]=useState(false),[a,i]=useState(false),[s,l]=useState(0),c=e.filter(m=>m.rules&&m.rules.length>0||m.description);if(c.length===0)return null;let u=c[s]??c[0],d=u.rules&&u.rules.length>0?u.rules.join(`
20
20
 
21
- `):d.description??"";if(!p)return null;let u=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:n("predict.event.rules")}),c.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:Lt(d)})}),jsx(DropdownMenu,{"aria-label":"Select market rules",selectionMode:"single",selectedKeys:[String(l)],onAction:m=>{a(Number(m)),r(false);},classNames:{list:"gap-1"},itemClasses:{base:"rounded-md px-3 h-8"},children:c.map((m,f)=>jsx(DropdownItem,{className:cn$1(f===l?"bg-content2 text-foreground":"text-neutral","data-[hover=true]:bg-content2 data-[hover=true]:text-foreground"),children:Lt(m)},String(f)))})]})]}),jsx("div",{className:"text-xs text-foreground/80 lg:text-sm whitespace-pre-wrap",children:u}),p.length>200&&jsx("button",{type:"button",onClick:()=>r(m=>!m),className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors self-start",children:n(o?"predict.event.rules.collapse":"predict.event.showMore")}),jsxs("button",{type:"button",onClick:()=>s(m=>!m),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:n("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 m=d.status,f=[];return d.created_at&&f.push({label:n("predict.event.timeline.created"),value:lt(d.created_at),isActive:true}),f.push({label:n("predict.event.timeline.open"),value:lt(d.start_at),isActive:m!=="pending"}),m==="voided"?f.push({label:n("predict.event.timeline.voided"),value:lt(d.closed_at??d.end_at),isActive:true}):m==="closed"?f.push({label:n("predict.event.timeline.closed"),value:lt(d.closed_at??d.end_at),isActive:true}):f.push({label:n("predict.event.timeline.close"),value:lt(d.end_at),isActive:false}),f})().map((m,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 ${m.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:m.label}),jsx("span",{className:"text-xs text-neutral lg:text-sm",children:m.value})]})]},m.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:[n("predict.event.id.event"),":"]})," ",jsx("span",{className:"text-foreground",children:t.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[n("predict.event.id.market"),":"]})," ",jsx("span",{className:"text-foreground",children:d.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[n("predict.event.id.source"),":"]})," ",jsx("span",{className:"text-foreground",children:kl(d.source)})]})]})]})]})}function Tl({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 uo({eventSlug:e,source:t,onTradeAction:n}){let{data:o,isLoading:r,error:i}=useEvent({slug:e,source:t});return r?jsx(at,{}):i||!o?jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:i?.message||"Event not found"}):jsx(co,{event:o,onTradeAction:n})}function po({eventSlug:e,source:t,limit:n=4,onEventClick:o}){let{t:r}=useTranslation(),{data:i,isLoading:s}=useSimilarEvents({slug:e,source:t,limit:n});return s||!i||i.length===0?null:jsxs("div",{className:"flex flex-col gap-y-3 mt-6 px-1 lg:px-0",children:[jsx("span",{className:"text-sm font-semibold text-foreground lg:text-base",children:r("predict.similar.title")}),jsx("div",{className:"grid grid-cols-1 gap-3",children:i.map(l=>jsx(_l,{event:l,onClick:o},l.slug))})]})}function _l({event:e,onClick:t}){let n=e.volume;return jsxs("button",{type:"button",onClick:()=>t?.(e),className:"flex items-center gap-x-3 rounded-xl border border-border p-3 hover:bg-content2 transition-colors cursor-pointer text-left w-full",children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title?.[0]||"?",radius:"lg",className:"size-8 shrink-0 bg-transparent",imgProps:{className:"object-cover"}}),jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[jsx("span",{className:"text-sm font-medium text-foreground truncate",children:e.title}),n!=null&&n>0&&jsxs("span",{className:"text-xs text-neutral",children:["$",Math.round(n).toLocaleString()," vol"]})]}),jsx(ChevronRightIcon,{className:"h-4 w-4 text-neutral shrink-0"})]})}function mo(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function dm({eventSlug:e,source:t,chain:n,walletAddress:o,onSimilarEventClick:r,onBack:i}){let{t:s}=useTranslation(),{isMobile:l}=useScreen(),{onOpen:a}=useAsyncModal(Je),{data:c,isLoading:d}=useEvent({slug:e,source:t}),p=useMemo(()=>[...c?.markets||[]].sort((h,D)=>mo(D)-mo(h)),[c?.markets]),[u,m]=useState(null),f=useCallback((h,D,T)=>{m(M=>({market:h,outcome:D,side:T,version:(M?.version??0)+1})),l&&c&&a({params:{event:c,market:h,initialOutcome:D,chain:n}});},[l,c,n,a]),g=u?.market??p[0];if(d){let h=!!i;return l?jsx(at,{showBack:h}):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(at,{showBack:h})}),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(zn,{})})})]})}let v=u?`${u.market.slug}-${u.version}`:g?.slug??"default";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:[i&&jsx("div",{className:"flex items-center justify-between",children:jsx(Button,{as:"a",onPress:i,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:s("common.back")})}),jsx(uo,{eventSlug:e,source:t,onTradeAction:f})]}),jsxs("div",{className:"hidden flex-none w-md flex-col gap-y-4 lg:sticky lg:top-4 lg:flex lg:self-start",children:[g&&jsx(bt,{event:c,market:g,initialSide:u?.side,initialOutcome:u?.outcome,chain:n},v),c&&jsx(po,{eventSlug:e,source:c.source,onEventClick:r})]})]}),c&&jsx("div",{className:"flex w-full flex-col",children:jsx(Wn,{event:c,walletAddress:o})}),jsx(yt,{})]})}function fo(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function jl(e){switch(e){case ChartRange.ONE_DAY:return {interval:"15m",limit:96};case ChartRange.ONE_WEEK:return {interval:"1h",limit:168};case ChartRange.ONE_MONTH:return {interval:"4h",limit:180};case ChartRange.ALL:return {interval:"1d",limit:300};default:return {interval:"1h",limit:100}}}var xm=e=>{let{candlestickMarketSlugs:t,chartRange:n=ht,source:o}=e,r=usePredictClient(),i=useMemo(()=>jl(n),[n]),{data:s,isLoading:l,error:a}=useEvent({slug:e.eventSlug,source:o}),c=useMemo(()=>s?.markets?(t&&t.length>0?t.slice(0,4).map(g=>s.markets.find(v=>v.slug===g)).filter(g=>g!==void 0):[...s.markets].sort((g,v)=>fo(v)-fo(g)).slice(0,4)).map(g=>g.slug):[],[t,s?.markets]),d=useQueries({queries:c.map(f=>({queryKey:candlesticksQueryKey(f,i),queryFn:()=>r.listCandlesticks(f,i),enabled:c.length>0}))}),p=d.some(f=>f.isLoading),u=useMemo(()=>{let f=new Map;return c.forEach((g,v)=>{let h=d[v]?.error;h&&f.set(g,h);}),f},[c,d]),m=useMemo(()=>{let f=new Map;return c.forEach((g,v)=>{let h=d[v]?.data;h&&f.set(g,h);}),f},[c,d]);return {event:s,isEventLoading:l,eventError:a,candlestickParams:i,candlesticks:m,isCandlesticksLoading:p,candlestickErrors:u}};var Ql=10,Jl=atomWithStorage("liberfi:predict_search_histories",[],void 0,{getOnInit:true});function At(){let[e,t]=useAtom(Jl),n=useCallback(r=>{let i=r.trim();i&&t(s=>{let l=s.filter(a=>a!==i);return [i,...l].slice(0,Ql)});},[t]),o=useCallback(()=>{t([]);},[t]);return {histories:e,addHistory:n,clearHistories:o}}function ho({histories:e,onSelect:t,onClear:n,className:o}){let{t:r}=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:r("predict.search.history")}),jsx(Button,{isIconOnly:true,size:"sm",className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:n,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 bo({onSelect:e,className:t}){let{histories:n,clearHistories:o}=At();return jsx(ho,{className:cn$1(t),histories:n,onSelect:e,onClear:o})}function yo({value:e,onValueChange:t,onClear:n,onEscape:o,className:r}){let{t:i}=useTranslation();return jsx("div",{className:r,children:jsx(StyledInput,{autoFocus:true,variant:"flat",radius:"full",value:e,onValueChange:t,placeholder:i("predict.search.placeholder"),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:n,children:jsx(XCloseIcon,{width:20,height:20})}):jsx(Kbd,{className:"min-w-8 justify-center text-xs text-neutral bg-transparent border border-border rounded-full cursor-pointer select-none",onMouseDown:s=>{s.preventDefault(),o?.();},children:"Esc"})})})}function No({event:e,href:t,LinkComponent:n,onSelect:o,onHover:r,className:i}){let{t:s}=useTranslation(),l=e.tags?.[0],a=useMemo(()=>`$${Math.round(e.volume??0).toLocaleString("en-US")}`,[e.volume]);return jsxs(Linkable,{href:t,LinkComponent:n,className:cn$1("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:c=>{t&&o&&c.preventDefault(),o?.(e);},onMouseEnter:()=>r?.(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 truncate",children:e.title}),jsxs("div",{className:"flex items-center gap-x-2 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[l&&jsx("span",{className:cn$1("inline-flex items-center","rounded-full px-1.5 py-0.5","text-[10px] font-semibold leading-none uppercase","bg-primary/15 text-primary"),children:l.label}),jsxs("span",{className:"inline-flex items-center gap-x-1.5",children:[a," ",s("predict.event.volume"),jsx(xc,{source:e.source})]})]})]})]})}function xc({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 wo({keyword:e="",limit:t,source:n}){let{data:o,isLoading:r,isFetchingNextPage:i,hasNextPage:s,fetchNextPage:l}=useSearchEvents({keyword:e,limit:t,source:n},{enabled:true});return {events:useMemo(()=>o?.pages.flatMap(c=>c.items).filter(c=>c!=null)??[],[o]),isLoading:r,isFetchingNextPage:i,hasNextPage:s??false,fetchNextPage:l}}var Ec=56;function Co({onSelect:e,getEventHref:t,LinkComponent:n,onHover:o,className:r,...i}){let{events:s,isLoading:l,isFetchingNextPage:a,hasNextPage:c,fetchNextPage:d}=wo(i),p=useRef(null),{height:u}=useResizeObserver({ref:p}),m=useCallback(h=>h<s.length,[s]),f=useCallback(async()=>{c&&!a&&await d();},[c,a,d]),g=useMemo(()=>c?s.length+1:s.length,[s,c]),v=useInfiniteLoader({isRowLoaded:m,loadMoreRows:f,rowCount:g,threshold:5});return l?jsx(Tc,{className:r}):s.length===0?jsx(Mc,{className:r}):jsx("div",{className:cn$1("w-full h-full flex flex-col",r),children:jsx("div",{className:"flex-auto min-h-0",ref:p,children:jsx(List,{style:{height:u},onRowsRendered:v,rowComponent:Cc,rowCount:g,rowHeight:Ec,rowProps:{events:s,onSelect:e,getEventHref:t,LinkComponent:n,onHover:o},overscanCount:5})})})}function Cc({index:e,style:t,events:n,onSelect:o,getEventHref:r,LinkComponent:i,onHover:s}){let l=n[e];return l?jsx("div",{style:t,children:jsx(No,{event:l,href:r?.(l),LinkComponent:i,onSelect:o,onHover:s})}):jsx("div",{style:t,className:"flex items-center justify-center",children:jsx(Spinner,{size:"sm"})})}function Tc({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 Mc({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 Lo({onKeywordChange:e}){let[t,n]=useState(""),[o,r]=useState(""),{addHistory:i}=At(),s=useCallbackRef(e),l=useCallbackRef(i),a=useMemo(()=>debounce(u=>{r(u),s(u),u&&l(u);},500),[s,l]),c=useCallback(u=>{n(u),a(u);},[a]),d=useCallback(u=>{a.cancel(),n(u),r(u),s(u),u&&l(u);},[a,s,l]),p=useCallback(()=>d(""),[d]);return {text:t,keyword:o,setText:c,setKeyword:d,clearKeyword:p}}function Oo({onKeywordChange:e,onSelectEvent:t,getEventHref:n,LinkComponent:o,onHover:r,onEscape:i,source:s}){let{text:l,keyword:a,setText:c,setKeyword:d,clearKeyword:p}=Lo({onKeywordChange:e});return jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsx(yo,{value:l,onValueChange:c,onClear:p,onEscape:i}),!a&&jsx(bo,{onSelect:d}),jsx(Co,{className:"flex-auto min-h-0",keyword:a,onSelect:t,getEventHref:n,LinkComponent:o,onHover:r,source:s})]})}var Tr="predict-search";function Bf({id:e=Tr}){return jsx(AsyncModal,{id:e,children:t=>jsx(Wc,{...t})})}function Wc({params:e,isOpen:t,onOpenChange:n,onResult:o}){let{t:r}=useTranslation(),{isMobile:i}=useScreen(),s=useCallback(a=>{o(a);},[o]),l=useCallback(()=>{n(false);},[n]);return jsx(StyledModal,{isOpen:t,onOpenChange:n,size:i?"full":"lg",hideCloseButton:true,backdrop:"blur",radius:"lg",children:jsxs(ModalContent,{className:"w-full h-full",children:[jsxs(ModalHeader,{className:"sm:hidden flex items-center justify-between pt-4 pb-2",children:[jsx("span",{className:"text-base font-semibold",children:r("predict.search.title")}),jsx(Button,{isIconOnly:true,onPress:()=>n(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(Oo,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectEvent:s,onEscape:l})})]})})}function qf({onSelectEvent:e,modalParams:t,className:n}){let{t:o}=useTranslation(),{isDesktop:r,isMobile:i}=useScreen(),{onOpen:s,onClose:l}=useAsyncModal(Tr),a=useCallbackRef(e),c=useCallbackRef(async()=>{let p=await s({params:t});p&&a(p);}),d=useCallbackRef(()=>{l();});return useEffect(()=>{let p=u=>{let m=document.activeElement,f=!!m&&(m.tagName==="INPUT"||m.tagName==="TEXTAREA"||m.getAttribute("contenteditable")==="true");u.key==="/"&&!f&&(u.preventDefault(),c()),u.key==="Escape"&&(u.preventDefault(),d());};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p);}},[c,d]),jsx(Button,{size:"sm",radius:"full",isIconOnly:!r,onPress:c,variant:i?"flat":"bordered",startContent:r?jsx(SearchIcon,{className:"text-neutral"}):void 0,endContent:r?jsx(Kbd,{className:"ml-auto min-w-6 justify-center text-xs bg-transparent border border-border rounded-full",children:"/"}):void 0,className:cn$1(r&&"min-w-56 justify-start pl-3 pr-1.5 text-neutral",n),children:r?o("predict.search.placeholder"):jsx(SearchIcon,{className:"text-neutral"})})}export{md as CHART_RANGE_DURATION,ud as CHART_RANGE_PERIOD,pd as CHART_RANGE_SAMPLE_INTERVAL,xt as CandlestickPeriod,rd as CategoriesSkeleton,Wr as CategoriesUI,Vr as CategoriesWidget,oe as ChartRange,ht as DEFAULT_CHART_RANGE,nr as DEFAULT_FILTER_STATE,Qe as DEFAULT_PAGE_SIZE,xd as DEFAULT_PRICE_HISTORY_INTERVAL,dm as EventDetailPage,at as EventDetailSkeleton,co as EventDetailUI,uo as EventDetailWidget,Rn as EventItem,Gn as EventMarketDepthChartUI,eo as EventMarketDetailWidget,no as EventPriceChart,pn as EventsFilterUI,ju as EventsPage,xu as EventsPageSkeleton,sr as EventsSkeleton,xn as EventsToolbarUI,An as EventsUI,Bn as EventsWidget,Gt as MAX_PRICE_HISTORY_MARKETS,vd as ORDER_MAX_PRICE,gd as ORDER_MIN_PRICE,Xt as ORDER_MIN_QUANTITY,fd as ORDER_PRICE_STEP,Tr as PREDICT_SEARCH_MODAL_ID,Je as PREDICT_TRADE_MODAL_ID,hd as PRICE_HISTORY_SAMPLE_INTERVAL,Bf as PredictSearchModal,yt as PredictTradeModal,ps as PredictWalletProvider,Be as PriceHistoryInterval,vn as SORT_PRESETS,jt as STATIC_CATEGORIES,qf as SearchEventsButton,ho as SearchHistoryUI,bo as SearchHistoryWidget,yo as SearchInputUI,No as SearchResultItemUI,Co as SearchResultListWidget,Oo as SearchWidget,_l as SimilarEventCard,po as SimilarEventsSection,zn as TradeFormSkeleton,cn as TradeFormUI,bt as TradeFormWidget,Wn as UserActivitySection,or as countActiveFilters,it as formatKMB,xm as useEventDetail,yn as useEventsInfinite,At as usePredictSearchHistory,Jt as usePredictWallet,wo as useSearchResultListScript,Lo as useSearchScript,tn as useTradeForm,Zo as version};//# sourceMappingURL=index.mjs.map
21
+ `):u.description??"";if(!d)return null;let p=d.length>200&&!o?d.slice(0,200)+"...":d;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")}),c.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:nr(u)})}),jsx(DropdownMenu,{"aria-label":"Select market rules",selectionMode:"single",selectedKeys:[String(s)],onAction:m=>{l(Number(m)),n(false);},classNames:{list:"gap-1"},itemClasses:{base:"rounded-md px-3 h-8"},children:c.map((m,g)=>jsx(DropdownItem,{className:cn$1(g===s?"bg-content2 text-foreground":"text-neutral","data-[hover=true]:bg-content2 data-[hover=true]:text-foreground"),children:nr(m)},String(g)))})]})]}),jsx("div",{className:"text-xs text-foreground/80 lg:text-sm whitespace-pre-wrap",children:p}),d.length>200&&jsx("button",{type:"button",onClick:()=>n(m=>!m),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:()=>i(m=>!m),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",a&&"rotate-180")})]}),a&&jsxs(Fragment,{children:[jsx("div",{className:"flex flex-col",children:(()=>{let m=u.status,g=[];return u.created_at&&g.push({label:r("predict.event.timeline.created"),value:Lt(u.created_at),isActive:true}),g.push({label:r("predict.event.timeline.open"),value:Lt(u.start_at),isActive:m!=="pending"}),m==="voided"?g.push({label:r("predict.event.timeline.voided"),value:Lt(u.closed_at??u.end_at),isActive:true}):m==="closed"?g.push({label:r("predict.event.timeline.closed"),value:Lt(u.closed_at??u.end_at),isActive:true}):g.push({label:r("predict.event.timeline.close"),value:Lt(u.end_at),isActive:false}),g})().map((m,g,f)=>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 ${m.isActive?"border-primary bg-primary":"border-border bg-transparent"}`}),g<f.length-1&&jsx("div",{className:"w-px flex-1 bg-border"})]}),jsxs("div",{className:`flex flex-col ${g<f.length-1?"pb-4":""}`,children:[jsx("span",{className:"text-xs font-medium text-foreground lg:text-sm",children:m.label}),jsx("span",{className:"text-xs text-neutral lg:text-sm",children:m.value})]})]},m.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:u.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.source"),":"]})," ",jsx("span",{className:"text-foreground",children:od(u.source)})]})]})]})]})}function ld({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 os({eventSlug:e,source:t,onTradeAction:r}){let{data:o,isLoading:n,error:a}=useEvent({slug:e,source:t});return n?jsx(Mt,{}):a||!o?jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:a?.message||"Event not found"}):jsx(ns,{event:o,onTradeAction:r})}function ss({eventSlug:e,source:t,limit:r=4,onEventClick:o}){let{t:n}=useTranslation(),{data:a,isLoading:i}=useSimilarEvents({slug:e,source:t,limit:r});return i||!a||a.length===0?null:jsxs("div",{className:"flex flex-col gap-y-3 mt-6 px-1 lg:px-0",children:[jsx("span",{className:"text-sm font-semibold text-foreground lg:text-base",children:n("predict.similar.title")}),jsx("div",{className:"grid grid-cols-1 gap-3",children:a.map(s=>jsx(fd,{event:s,onClick:o},s.slug))})]})}function fd({event:e,onClick:t}){let r=e.volume;return jsxs("button",{type:"button",onClick:()=>t?.(e),className:"flex items-center gap-x-3 rounded-xl border border-border p-3 hover:bg-content2 transition-colors cursor-pointer text-left w-full",children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title?.[0]||"?",radius:"lg",className:"size-8 shrink-0 bg-transparent",imgProps:{className:"object-cover"}}),jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[jsx("span",{className:"text-sm font-medium text-foreground truncate",children:e.title}),r!=null&&r>0&&jsxs("span",{className:"text-xs text-neutral",children:["$",Math.round(r).toLocaleString()," vol"]})]}),jsx(ChevronRightIcon,{className:"h-4 w-4 text-neutral shrink-0"})]})}function as(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function y0({eventSlug:e,source:t,chain:r,walletAddress:o,onSimilarEventClick:n,onBack:a}){let{t:i}=useTranslation(),{isMobile:s}=useScreen(),{onOpen:l}=useAsyncModal(yt),{data:c,isLoading:u}=useEvent({slug:e,source:t}),d=useMemo(()=>[...c?.markets||[]].sort((x,R)=>as(R)-as(x)),[c?.markets]),[p,m]=useState(null),g=useCallback((x,R,N)=>{m(w=>({market:x,outcome:R,side:N,version:(w?.version??0)+1})),s&&c&&l({params:{event:c,market:x,initialOutcome:R,chain:r}});},[s,c,r,l]),f=p?.market??d[0];if(u){let x=!!a;return s?jsx(Mt,{showBack:x}):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(Mt,{showBack:x})}),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(Fo,{})})})]})}let h=p?`${p.market.slug}-${p.version}`:f?.slug??"default";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:[a&&jsx("div",{className:"flex items-center justify-between",children:jsx(Button,{as:"a",onPress:a,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:i("common.back")})}),jsx(os,{eventSlug:e,source:t,onTradeAction:g})]}),jsxs("div",{className:"hidden flex-none w-md flex-col gap-y-4 lg:sticky lg:top-4 lg:flex lg:self-start",children:[f&&jsx(Vt,{event:c,market:f,initialSide:p?.side,initialOutcome:p?.outcome,chain:r},h),c&&jsx(ss,{eventSlug:e,source:c.source,onEventClick:n})]})]}),c&&jsx("div",{className:"flex w-full flex-col",children:jsx(Do,{event:c,walletAddress:o})}),jsx(jt,{})]})}function is(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Md(e){switch(e){case ChartRange.ONE_DAY:return {interval:"15m",limit:96};case ChartRange.ONE_WEEK:return {interval:"1h",limit:168};case ChartRange.ONE_MONTH:return {interval:"4h",limit:180};case ChartRange.ALL:return {interval:"1d",limit:300};default:return {interval:"1h",limit:100}}}var E0=e=>{let{candlestickMarketSlugs:t,chartRange:r=Kt,source:o}=e,n=usePredictClient(),a=useMemo(()=>Md(r),[r]),{data:i,isLoading:s,error:l}=useEvent({slug:e.eventSlug,source:o}),c=useMemo(()=>i?.markets?(t&&t.length>0?t.slice(0,4).map(f=>i.markets.find(h=>h.slug===f)).filter(f=>f!==void 0):[...i.markets].sort((f,h)=>is(h)-is(f)).slice(0,4)).map(f=>f.slug):[],[t,i?.markets]),u=useQueries({queries:c.map(g=>({queryKey:candlesticksQueryKey(g,a),queryFn:()=>n.listCandlesticks(g,a),enabled:c.length>0}))}),d=u.some(g=>g.isLoading),p=useMemo(()=>{let g=new Map;return c.forEach((f,h)=>{let x=u[h]?.error;x&&g.set(f,x);}),g},[c,u]),m=useMemo(()=>{let g=new Map;return c.forEach((f,h)=>{let x=u[h]?.data;x&&g.set(f,x);}),g},[c,u]);return {event:i,isEventLoading:s,eventError:l,candlestickParams:a,candlesticks:m,isCandlesticksLoading:d,candlestickErrors:p}};var Rd=10,_d=atomWithStorage("liberfi:predict_search_histories",[],void 0,{getOnInit:true});function lr(){let[e,t]=useAtom(_d),r=useCallback(n=>{let a=n.trim();a&&t(i=>{let s=i.filter(l=>l!==a);return [a,...s].slice(0,Rd)});},[t]),o=useCallback(()=>{t([]);},[t]);return {histories:e,addHistory:r,clearHistories:o}}function us({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(a=>jsx(Chip,{size:"sm",variant:"bordered",className:cn$1("text-neutral","border-border border-1","cursor-pointer","hover:opacity-hover"),onClick:()=>t?.(a),children:a},a))})]})}function ps({onSelect:e,className:t}){let{histories:r,clearHistories:o}=lr();return jsx(us,{className:cn$1(t),histories:r,onSelect:e,onClear:o})}function ms({value:e,onValueChange:t,onClear:r,onEscape:o,className:n}){let{t:a}=useTranslation();return jsx("div",{className:n,children:jsx(StyledInput,{autoFocus:true,variant:"flat",radius:"full",value:e,onValueChange:t,placeholder:a("predict.search.placeholder"),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-border rounded-full cursor-pointer select-none",onMouseDown:i=>{i.preventDefault(),o?.();},children:"Esc"})})})}function gs({event:e,href:t,LinkComponent:r,onSelect:o,onHover:n,className:a}){let{t:i}=useTranslation(),s=e.tags?.[0],l=useMemo(()=>`$${Math.round(e.volume??0).toLocaleString("en-US")}`,[e.volume]);return jsxs(Linkable,{href:t,LinkComponent:r,className:cn$1("w-full h-full px-3 flex items-center gap-3","hover:cursor-pointer hover:bg-content2 rounded-lg","transition-colors duration-150",a),onClick:c=>{t&&o&&c.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 truncate",children:e.title}),jsxs("div",{className:"flex items-center gap-x-2 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[s&&jsx("span",{className:cn$1("inline-flex items-center","rounded-full px-1.5 py-0.5","text-[10px] font-semibold leading-none uppercase","bg-primary/15 text-primary"),children:s.label}),jsxs("span",{className:"inline-flex items-center gap-x-1.5",children:[l," ",i("predict.event.volume"),jsx(Qd,{source:e.source})]})]})]})]})}function Qd({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 hs({keyword:e="",limit:t,source:r}){let{data:o,isLoading:n,isFetchingNextPage:a,hasNextPage:i,fetchNextPage:s}=useSearchEvents({keyword:e,limit:t,source:r},{enabled:true});return {events:useMemo(()=>o?.pages.flatMap(c=>c.items).filter(c=>c!=null)??[],[o]),isLoading:n,isFetchingNextPage:a,hasNextPage:i??false,fetchNextPage:s}}var au=56;function ys({onSelect:e,getEventHref:t,LinkComponent:r,onHover:o,className:n,...a}){let{events:i,isLoading:s,isFetchingNextPage:l,hasNextPage:c,fetchNextPage:u}=hs(a),d=useRef(null),{height:p}=useResizeObserver({ref:d}),m=useCallback(x=>x<i.length,[i]),g=useCallback(async()=>{c&&!l&&await u();},[c,l,u]),f=useMemo(()=>c?i.length+1:i.length,[i,c]),h=useInfiniteLoader({isRowLoaded:m,loadMoreRows:g,rowCount:f,threshold:5});return s?jsx(lu,{className:n}):i.length===0?jsx(cu,{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:d,children:jsx(List,{style:{height:p},onRowsRendered:h,rowComponent:iu,rowCount:f,rowHeight:au,rowProps:{events:i,onSelect:e,getEventHref:t,LinkComponent:r,onHover:o},overscanCount:5})})})}function iu({index:e,style:t,events:r,onSelect:o,getEventHref:n,LinkComponent:a,onHover:i}){let s=r[e];return s?jsx("div",{style:t,children:jsx(gs,{event:s,href:n?.(s),LinkComponent:a,onSelect:o,onHover:i})}):jsx("div",{style:t,className:"flex items-center justify-center",children:jsx(Spinner,{size:"sm"})})}function lu({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 cu({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 ws({onKeywordChange:e}){let[t,r]=useState(""),[o,n]=useState(""),{addHistory:a}=lr(),i=useCallbackRef(e),s=useCallbackRef(a),l=useMemo(()=>debounce(p=>{n(p),i(p),p&&s(p);},500),[i,s]),c=useCallback(p=>{r(p),l(p);},[l]),u=useCallback(p=>{l.cancel(),r(p),n(p),i(p),p&&s(p);},[l,i,s]),d=useCallback(()=>u(""),[u]);return {text:t,keyword:o,setText:c,setKeyword:u,clearKeyword:d}}function Ps({onKeywordChange:e,onSelectEvent:t,getEventHref:r,LinkComponent:o,onHover:n,onEscape:a,source:i}){let{text:s,keyword:l,setText:c,setKeyword:u,clearKeyword:d}=ws({onKeywordChange:e});return jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsx(ms,{value:s,onValueChange:c,onClear:d,onEscape:a}),!l&&jsx(ps,{onSelect:u}),jsx(ys,{className:"flex-auto min-h-0",keyword:l,onSelect:t,getEventHref:r,LinkComponent:o,onHover:n,source:i})]})}var cn="predict-search";function Gh({id:e=cn}){return jsx(AsyncModal,{id:e,children:t=>jsx(Nu,{...t})})}function Nu({params:e,isOpen:t,onOpenChange:r,onResult:o}){let{t:n}=useTranslation(),{isMobile:a}=useScreen(),i=useCallback(l=>{o(l);},[o]),s=useCallback(()=>{r(false);},[r]);return jsx(StyledModal,{isOpen:t,onOpenChange:r,size:a?"full":"lg",hideCloseButton:true,backdrop:"blur",radius:"lg",children:jsxs(ModalContent,{className:"w-full h-full",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(Ps,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectEvent:i,onEscape:s})})]})})}function rx({onSelectEvent:e,modalParams:t,className:r}){let{t:o}=useTranslation(),{isDesktop:n,isMobile:a}=useScreen(),{onOpen:i,onClose:s}=useAsyncModal(cn),l=useCallbackRef(e),c=useCallbackRef(async()=>{let d=await i({params:t});d&&l(d);}),u=useCallbackRef(()=>{s();});return useEffect(()=>{let d=p=>{let m=document.activeElement,g=!!m&&(m.tagName==="INPUT"||m.tagName==="TEXTAREA"||m.getAttribute("contenteditable")==="true");p.key==="/"&&!g&&(p.preventDefault(),c()),p.key==="Escape"&&(p.preventDefault(),u());};return window.addEventListener("keydown",d),()=>{window.removeEventListener("keydown",d);}},[c,u]),jsx(Button,{size:"sm",radius:"full",isIconOnly:!n,onPress:c,variant:a?"flat":"bordered",startContent:n?jsx(SearchIcon,{className:"text-neutral"}):void 0,endContent:n?jsx(Kbd,{className:"ml-auto min-w-6 justify-center text-xs bg-transparent border border-border rounded-full",children:"/"}):void 0,className:cn$1(n&&"min-w-56 justify-start pl-3 pr-1.5 text-neutral",r),children:n?o("predict.search.placeholder"):jsx(SearchIcon,{className:"text-neutral"})})}var un=[{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"}],Os=[{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}],Rs={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"},_s={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 _u(e,t){if(!e)return "$5K+";let r=Os.find(o=>o.value===e);return r?r.labelKey?t(r.labelKey):r.label:`$${e}`}function As({sortBy:e,onSortChange:t,sortAsc:r,onSortAscChange:o,minVolume:n,onMinVolumeChange:a,onRefresh:i}){let{t:s}=useTranslation(),[l,c]=useState(false),[u,d]=useState(false),[p,m]=useState(false),[g,f]=useState(false),h=useRef(null),x=useRef(null),R=un.find(v=>v.value===e)??un[0],N=useCallback(v=>{h.current&&!h.current.contains(v.target)&&c(false),x.current&&!x.current.contains(v.target)&&d(false);},[]);useEffect(()=>(document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)),[N]);let w=useCallback(()=>{i?.(),f(true),setTimeout(()=>f(false),700);},[i]);return jsxs(Fragment,{children:[jsx("style",{children:`
22
+ @keyframes matchRefreshSpin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}
23
+ .match-refresh-spin{animation:matchRefreshSpin .6s ease-in-out}
24
+ `}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxs("div",{ref:h,style:{position:"relative"},children:[jsxs("button",{type:"button",style:Rs,onMouseEnter:v=>{v.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:v=>{v.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>{c(v=>!v),d(false);},children:[jsx(Iu,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:s(R.labelKey)}),jsx(Is,{open:l})]}),l&&jsx("div",{style:{..._s,width:224,padding:4},children:un.map(v=>{let B=e===v.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:B?"rgba(139,92,246,0.1)":"transparent",color:B?"#c4b5fd":"#a1a1aa",borderRadius:10},onMouseEnter:b=>{B||(b.currentTarget.style.background="rgba(39,39,42,0.5)",b.currentTarget.style.color="#fff");},onMouseLeave:b=>{B||(b.currentTarget.style.background="transparent",b.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===v.value?o(!r):t(v.value),c(false);},children:[jsx("div",{style:{color:B?"#a78bfa":"#71717a"},children:jsx(Ou,{type:v.icon})}),jsxs("div",{style:{flex:1,textAlign:"left"},children:[jsx("div",{style:{fontWeight:500},children:s(v.labelKey)}),jsx("div",{style:{fontSize:11,color:"#71717a",marginTop:1},children:s(v.descKey)})]}),B&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#a78bfa",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 6 9 17l-5-5"})})]},v.value)})})]}),a&&jsxs("div",{ref:x,style:{position:"relative"},children:[jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxs("button",{type:"button",style:Rs,onMouseEnter:v=>{v.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:v=>{v.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>{d(v=>!v),c(false);},children:[jsx(Au,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:_u(n,s)}),jsx(Du,{onMouseEnter:()=>m(true),onMouseLeave:()=>m(false)}),jsx(Is,{open:u})]}),p&&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:"#a78bfa",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"})}),s("predict.matches.filter.liquidityFilter")]}),jsx("p",{style:{color:"#a1a1aa",margin:"0 0 4px"},children:s("predict.matches.filter.tooltipDesc")}),jsx("p",{style:{color:"#71717a",fontSize:11,margin:0},children:s("predict.matches.filter.tooltipNote")})]})]})]}),u&&jsxs("div",{style:{..._s,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:s("predict.matches.filter.minVolumeEach")})}),jsx("div",{style:{padding:4},children:Os.map(v=>{let B=v.value===0?!n:n===v.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:B?"rgba(139,92,246,0.1)":"transparent",color:B?"#c4b5fd":"#a1a1aa",borderRadius:10,transition:"all 0.15s"},onMouseEnter:b=>{B||(b.currentTarget.style.background="rgba(39,39,42,0.5)",b.currentTarget.style.color="#fff");},onMouseLeave:b=>{B||(b.currentTarget.style.background="transparent",b.currentTarget.style.color="#a1a1aa");},onClick:()=>{a?.(v.value===0?void 0:v.value),d(false);},children:[jsx("span",{children:v.labelKey?s(v.labelKey):v.label}),B&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#a78bfa"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 6 9 17l-5-5"})})]},v.value)})})]})]}),i&&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"},onMouseEnter:v=>{v.currentTarget.style.background="rgba(39,39,42,1)",v.currentTarget.style.color="#fff";},onMouseLeave:v=>{v.currentTarget.style.background="rgba(39,39,42,0.6)",v.currentTarget.style.color="#a1a1aa";},onClick:w,children:jsxs("svg",{className:g?"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 Iu(){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 Ou({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 Au(){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 Du({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 Is({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 Bu(e){return e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e3?`$${(e/1e3).toFixed(0)}K`:`$${e.toFixed(0)}`}var $u=[{key:"activePairs",labelKey:"predict.matches.stats.activePairs",format:e=>e.toLocaleString(),valueColor:"#a684ff",gradientFrom:"rgba(142,81,255,0.2)",gradientTo:"rgba(142,81,255,0.05)",borderColor:"rgba(142,81,255,0.2)"},{key:"maxSpread",labelKey:"predict.matches.stats.maxSpread",format:e=>`${(e*100).toFixed(1)}%`,valueColor:"#ffb900",gradientFrom:"rgba(254,154,0,0.2)",gradientTo:"rgba(254,154,0,0.05)",borderColor:"rgba(254,154,0,0.2)"},{key:"highSpreadCount",labelKey:"predict.matches.stats.highSpreadCount",format:e=>e.toLocaleString(),valueColor:"#00d492",gradientFrom:"rgba(0,188,125,0.2)",gradientTo:"rgba(0,188,125,0.05)",borderColor:"rgba(0,188,125,0.2)"},{key:"totalVolume",labelKey:"predict.matches.stats.totalVolume",format:Bu,valueColor:"#00d3f3",gradientFrom:"rgba(0,184,219,0.2)",gradientTo:"rgba(0,184,219,0.05)",borderColor:"rgba(0,184,219,0.2)"}];function Ds({stats:e}){let{t}=useTranslation();return jsxs("div",{className:"flex flex-col items-center text-center",style:{marginBottom:0},children:[jsx("style",{children:`
25
+ .matches-hero-title{font-size:30px!important}
26
+ @media(min-width:640px){.matches-hero-title{font-size:36px!important}}
27
+ @media(min-width:1024px){.matches-hero-title{font-size:48px!important}}
28
+ @media(max-width:639px){.matches-hero-stats{grid-template-columns:repeat(2,1fr)!important}}
29
+ .matches-stat-card{padding:12px}
30
+ @media(min-width:640px){.matches-stat-card{padding:16px}}
31
+ .matches-stat-val{font-size:18px;line-height:25px;min-height:25px}
32
+ @media(min-width:640px){.matches-stat-val{font-size:20px;line-height:28px;min-height:28px}}
33
+ .matches-stat-label{font-size:10px;line-height:14px;min-height:14px}
34
+ @media(min-width:640px){.matches-stat-label{font-size:12px;line-height:16px;min-height:16px}}
35
+ @keyframes matchStatsEnter{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}
36
+ @keyframes matchStatCardEnter{from{opacity:0;transform:translateY(12px) scale(0.97)}to{opacity:1;transform:translateY(0) scale(1)}}
37
+ `}),jsx("style",{children:`
38
+ @keyframes match-live-ping{75%,100%{transform:scale(2.2);opacity:0}}
39
+ @keyframes match-live-breathe{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.55;transform:scale(.85)}}
40
+ `}),jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:24},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(142,81,255,0.2)",padding:"2px 6px",fontSize:10,fontWeight:600,color:"#c4b4ff",textTransform:"uppercase",border:"1px solid rgba(142,81,255,0.3)"},children:t("predict.matches.betaTag")})]})}),jsxs("div",{style:{textAlign:"center",marginBottom:32},children:[jsxs("h1",{className:"matches-hero-title",style:{fontFamily:"var(--font-dm-sans, 'DM Sans', sans-serif)",fontSize:48,fontWeight:700,letterSpacing:"-1.2px",lineHeight:"48px",color:"#fff",margin:"0 0 16px"},children:[jsxs("span",{style:{color:"#fff"},children:[t("predict.matches.titlePrefix")," "]}),jsx("span",{style:{backgroundImage:"linear-gradient(to right, #a684ff, #ed6aff, #00d3f3)",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",backgroundClip:"text"},children:t("predict.matches.titleHighlight")})]}),jsx("style",{children:".matches-hero-subtitle{font-size:14px}@media(min-width:640px){.matches-hero-subtitle{font-size:16px}}"}),jsx("p",{className:"matches-hero-subtitle",style:{lineHeight:1.625,color:"#71717a",maxWidth:576,margin:"0 auto",textAlign:"center"},children:String(t("predict.matches.heroSubtitle")).split(`
41
+ `).map((r,o)=>jsxs("span",{children:[o>0&&jsx("br",{className:"hidden sm:block"}),r,o===0?" ":""]},o))})]}),jsx("div",{className:"matches-hero-stats",style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:12,width:"100%",maxWidth:672,...e?{animation:"matchStatsEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both"}:{}},children:$u.map((r,o)=>jsxs("div",{className:"matches-stat-card",style:{borderRadius:14,border:`1px solid ${e?r.borderColor:"rgba(255,255,255,0.06)"}`,background:e?`linear-gradient(to bottom, ${r.gradientFrom}, ${r.gradientTo})`:"rgba(255,255,255,0.02)",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",...e?{animation:"matchStatCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:`${o*60}ms`}:{}},children:[jsx("div",{className:"matches-stat-val",style:{fontWeight:700,color:e?r.valueColor:"transparent",display:"flex",alignItems:"center"},children:e?r.format(e[r.key]):jsx("div",{style:{height:14,width:60,borderRadius:4,background:"rgba(255,255,255,0.06)"}})}),jsx("div",{className:"matches-stat-label",style:{fontWeight:500,color:e?"#71717a":"transparent",display:"flex",alignItems:"center"},children:e?t(r.labelKey):jsx("div",{style:{height:8,width:80,borderRadius:4,background:"rgba(255,255,255,0.04)"}})})]},r.key))})]})}var Ku={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}},Vu={label:"Unknown",color:"rgb(156, 163, 175)",bgColor:"rgba(156, 163, 175, 0.12)",icon:null};function ur(e){return Ku[e]??Vu}function Px({source:e,className:t}){let r=ur(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]})}function pn(e){return e==null?"-":e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e3?`$${Math.round(e/1e3)}K`:`$${e.toFixed(0)}`}var Gu={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"}},Yu={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 qu(e){return Gu[e]??Yu}function Xu(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 Qu(e,t){let r=e.entries.find(s=>s.source===(t?.source_a??e.entries[0]?.source)),o=e.entries.find(s=>s.source===(t?.source_b??e.entries[1]?.source)),n=s=>{if(!s?.outcomes?.[0])return {name:null,price:null};let l=s.outcomes[0];return {name:l.label||null,price:l.best_ask??l.price??null}},a=n(t?.market_a),i=n(t?.market_b);return [{source:t?.source_a??r?.source??"unknown",outcomeName:a.name,yesPrice:a.price,volume:r?.event?.volume??null,event:r?.event},{source:t?.source_b??o?.source??"unknown",outcomeName:i.name,yesPrice:i.price,volume:o?.event?.volume??null,event:o?.event}]}function Ws({group:e,onSelectEntry:t,getEventHref:r,LinkComponent:o}){let {t:n}=useTranslation(),a=useMemo(()=>Xu(e),[e]),i=e.max_spread!=null?e.max_spread*100:null,[s,l]=useMemo(()=>Qu(e,a),[e,a]),c=i!=null&&i>=3;s.yesPrice!=null&&l.yesPrice!=null?s.source==="kalshi"?s.yesPrice>l.yesPrice:l.yesPrice>s.yesPrice:false;let d=s.yesPrice!=null&&l.yesPrice!=null?s.yesPrice<=l.yesPrice?s:l:null,p=d?ur(d.source):null,m=c?"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:g=>{let f=g.currentTarget;f.style.borderColor="rgba(63,63,70,0.6)",f.style.boxShadow="0 10px 15px -3px rgba(0,0,0,0.2)";},onMouseLeave:g=>{let f=g.currentTarget;f.style.borderColor="rgba(39,39,42,0.6)",f.style.boxShadow="none";},children:[i!=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 ${c?"rgba(255,185,0,0.3)":i>=2?"rgba(166,132,255,0.3)":"rgba(156,163,175,0.3)"}`,background:c?"rgba(255,185,0,0.15)":i>=2?"rgba(166,132,255,0.15)":"rgba(156,163,175,0.12)",color:c?"#ffb900":i>=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"})}),i.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(Bs,{data:s,isCheaper:d===s,onSelect:t,getEventHref:r,LinkComponent:o}),jsx(Bs,{data:l,isCheaper:d===l,onSelect:t,getEventHref:r,LinkComponent:o})]}),d&&p&&i!=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 ${m==="amber"?"rgba(255,185,0,0.15)":"rgba(166,132,255,0.15)"}`,background:m==="amber"?"rgba(255,185,0,0.05)":"rgba(166,132,255,0.05)"},onClick:()=>d.event&&t?.(d.event),children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,flexShrink:0,color:m==="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:m==="amber"?"rgba(255,185,0,0.9)":"rgba(166,132,255,0.9)"},children:n("predict.matches.buyEdge",{platform:d.source.charAt(0).toUpperCase()+d.source.slice(1),spread:i.toFixed(1)})}),jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,marginLeft:"auto",color:m==="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"})]}),pn(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"})}),pn(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 Bs({data:e,isCheaper:t,onSelect:r,getEventHref:o,LinkComponent:n}){let{t:a}=useTranslation(),i=ur(e.source),s=qu(e.source),l=e.event?o?.(e.event):void 0,c=jsxs("div",{style:{borderRadius:14,border:`1px solid ${s.border}`,background:s.bg,padding:12,cursor:l||r?"pointer":void 0,transition:"border-color 0.15s"},onMouseEnter:u=>{u.currentTarget.style.borderColor=s.hoverBorder;},onMouseLeave:u=>{u.currentTarget.style.borderColor=s.border;},onClick:()=>e.event&&r?.(e.event),children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[i.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.05em",color:s.text,textTransform:"uppercase"},children:i.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?s.priceActiveColor:s.priceColor},children:e.yesPrice!=null?(e.yesPrice*100).toFixed(1):"-"}),jsx("span",{style:{fontSize:10,color:"#71717a"},children:a("predict.matches.centsYes")})]}),jsxs("div",{style:{fontSize:10,color:"#52525b",marginTop:6},children:[pn(e.volume)," ",a("predict.matches.volume")]})]});return l&&n?jsx(n,{href:l,className:"block",children:c}):c}var Us=forwardRef(function({sortBy:t,sortAsc:r,minVolume:o,onSelectEntry:n,getEventHref:a,LinkComponent:i,onStatsChange:s},l){let{t:c}=useTranslation(),u=useRef(null),{data:d,hasNextPage:p,fetchNextPage:m,isFetchingNextPage:g,isLoading:f,isPlaceholderData:h,refetch:x}=useInfiniteMatches({sort_by:t,sort_asc:r,min_volume:o,status:"active",limit:20},{placeholderData:keepPreviousData}),[R,N]=useState(0),[w,v]=useState(false);w&&!h?(v(false),N(U=>U+1)):h&&!w&&v(true);let B=useMemo(()=>{let U=d?.pages;return !U||U.length<=1?0:U.slice(0,-1).reduce((F,W)=>F+(W.items?.length??0),0)},[d?.pages]);useImperativeHandle(l,()=>({refetch:()=>{x();}}),[x]);let b=useMemo(()=>d?.pages.flatMap(U=>U.items??[])??[],[d]),X=d?.pages[0]?.total,j=useMemo(()=>{let U=d?.pages[0]?.stats;if(U)return {activePairs:U.total_matches,maxSpread:U.max_spread/100,highSpreadCount:U.matches_over_3_percent,totalVolume:U.total_volume};let F=0,W=0,$=0;for(let oe of b)oe.max_spread!=null&&(oe.max_spread>F&&(F=oe.max_spread),oe.max_spread>=.03&&$++),oe.combined_volume!=null&&(W+=oe.combined_volume);return {activePairs:X??b.length,maxSpread:F,highSpreadCount:$,totalVolume:W}},[d,b,X]);useEffect(()=>{j.activePairs>0&&s?.(j);},[j,s]);let ie=useCallback(()=>{p&&!g&&m();},[p,g,m]);return f?jsx(ap,{}):b.length===0?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:c("predict.matches.empty")})}):jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[jsx("style",{children:`
42
+ @media(max-width:1023px){.matches-card-grid{grid-template-columns:1fr!important}}
43
+ @keyframes matchCardEnter{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}
44
+ `}),jsx("div",{className:"matches-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:16},children:b.map((U,F)=>jsx("div",{style:{animation:`matchCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${Math.max(0,F-B)*35}ms both`},children:jsx(Ws,{group:U,onSelectEntry:n,getEventHref:a,LinkComponent:i})},`${R}-${U.id}`))}),p&&jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:8,padding:"16px 0"},children:[jsxs("button",{ref:u,disabled:g,onClick:ie,style:{display:"flex",alignItems:"center",gap:8,padding:"12px 24px",background:"rgba(39,39,42,0.6)",border:"1px solid rgba(63,63,70,0.5)",borderRadius:14,color:"#d4d4d8",fontSize:16,fontWeight:500,cursor:g?"wait":"pointer",opacity:g?.5:1,transition:"background 0.15s, color 0.15s, opacity 0.15s"},onMouseEnter:U=>{g||(U.currentTarget.style.background="rgba(39,39,42,0.9)",U.currentTarget.style.color="#fff");},onMouseLeave:U=>{U.currentTarget.style.background="rgba(39,39,42,0.6)",U.currentTarget.style.color="#d4d4d8";},children:[g?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"})}):jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"m6 9 6 6 6-6"})}),c("predict.matches.loadMore")]}),jsx("style",{children:"@keyframes match-load-spin{to{transform:rotate(360deg)}}"}),X!=null&&jsx("span",{style:{fontSize:12,color:"rgba(255,255,255,0.35)"},children:c("predict.matches.showing",{current:b.length,total:X})})]})]})});function ap(){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, 1fr)",gap:16},children:Array.from({length:6}).map((e,t)=>jsx(ip,{index:t},t))})]})}function ip({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 up={spread:"predict.matches.topOpportunities",volume:"predict.matches.highestVolume",confidence:"predict.matches.trendingToday"};function pp(){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 mp({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:e.activePairs.toLocaleString()})]}),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(pp,{})]})]})]})]})}function Vx({onSelectEntry:e,getEventHref:t,LinkComponent:r,bgImageSrc:o}){let{t:n}=useTranslation(),[a,i]=useState("spread"),[s,l]=useState(false),[c,u]=useState(5e3),[d,p]=useState(),m=useRef(null),g=useCallback(R=>{i(R);},[]),f=useCallback(R=>{l(R);},[]),h=useCallback(R=>{p(R);},[]),x=useCallback(()=>{m.current?.refetch();},[]);return jsxs("div",{style:{minHeight:"100vh",position:"relative"},children:[o&&jsx("img",{src:o,alt:"","aria-hidden":"true",style:{position:"fixed",inset:0,width:"100%",height:"100%",objectFit:"cover",objectPosition:"bottom",opacity:.25,pointerEvents:"none",zIndex:0}}),jsx("style",{children:`
45
+ @keyframes matchFadeIn{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}
46
+ .match-fade-in{animation:matchFadeIn .5s ease-out both}
47
+ .match-fade-in-d1{animation:matchFadeIn .5s ease-out .1s both}
48
+ .match-fade-in-d2{animation:matchFadeIn .5s ease-out .2s both}
49
+ `}),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"},children:[jsx("div",{style:{position:"absolute",inset:0,background:"linear-gradient(to bottom right, rgba(46,16,101,0.2), transparent 50%, rgba(8,51,68,0.1))"}}),jsx("div",{style:{position:"absolute",inset:0,opacity:.03,backgroundImage:"radial-gradient(circle at 1px 1px, rgb(255 255 255) 1px, transparent 0)",backgroundSize:"24px 24px"}}),jsx("div",{style:{position:"absolute",top:0,left:"25%",width:384,height:384,background:"rgba(139,92,246,0.05)",borderRadius:9999,filter:"blur(96px)"}}),jsx("div",{style:{position:"absolute",bottom:0,right:"25%",width:384,height:384,background:"rgba(6,182,212,0.05)",borderRadius:9999,filter:"blur(96px)"}})]}),jsx("style",{children:".matches-hero-wrap{padding:48px 16px 40px}@media(min-width:640px){.matches-hero-wrap{padding:64px 24px 56px}}@media(min-width:1024px){.matches-hero-wrap{padding:64px 32px 56px}}"}),jsx("div",{className:"match-fade-in matches-hero-wrap",style:{position:"relative",maxWidth:1152,margin:"0 auto"},children:jsx(Ds,{stats:d})})]}),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(142,81,255,0.2), rgba(225,42,251,0.2))",border:"1px solid rgba(142,81,255,0.2)",flexShrink:0},children:jsxs("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#a684ff"},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:n(up[a])}),d&&d.activePairs>0&&jsx("p",{className:"hidden sm:block",style:{fontSize:11,color:"#71717a",margin:0},children:n("predict.matches.pairsFound",{count:d.activePairs})})]})]}),jsx(As,{sortBy:a,onSortChange:g,sortAsc:s,onSortAscChange:f,minVolume:c,onMinVolumeChange:u,onRefresh:x})]})]}),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:[jsx(Us,{ref:m,sortBy:a,sortAsc:s,minVolume:c,onSelectEntry:e,getEventHref:t,LinkComponent:r,onStatsChange:h}),jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12,marginTop:48,padding:16,borderRadius:12,border:"1px solid rgba(39,39,42,0.5)",background:"rgba(24,24,27,0.3)"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#71717a",flexShrink:0,marginTop:1},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("div",{children:[jsx("p",{style:{fontSize:12,fontWeight:500,color:"#a1a1aa",margin:"0 0 4px"},children:n("predict.matches.experimentalFeature")}),jsx("p",{style:{fontSize:11,color:"#52525b",lineHeight:1.625,margin:0},children:n("predict.matches.disclaimer")})]})]})]}),jsx(mp,{stats:d})]})}function xp(e){return e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e3?`$${(e/1e3).toFixed(1)}K`:`$${e.toFixed(0)}`}function Xx({matches:e,total:t}){let{t:r}=useTranslation(),o=useMemo(()=>{let n=0,a=0,i=new Set;for(let s of e){s.max_spread!=null&&s.max_spread>n&&(n=s.max_spread),s.combined_volume!=null&&(a+=s.combined_volume);for(let l of s.entries)i.add(typeof l.source=="string"?l.source:"");}return {count:t??e.length,maxSpread:n,totalVolume:a,platformCount:i.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(mr,{label:r("predict.matches.stats.matchedMarkets"),value:o.count.toLocaleString()}),jsx(fn,{}),jsx(mr,{label:r("predict.matches.stats.totalVolume"),value:xp(o.totalVolume)}),jsx(fn,{}),jsx(mr,{label:r("predict.matches.stats.highestSpread"),value:`${(o.maxSpread*100).toFixed(1)}\xA2`,valueClassName:"text-green-400"}),jsx(fn,{}),jsx(mr,{label:r("predict.matches.stats.platforms"),value:String(o.platformCount)})]})}function mr({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 fn(){return jsx("span",{className:"hidden text-neutral-700 sm:inline",children:"|"})}function js(e){return `${(e*100).toFixed(1)}\xA2`}function vp(e){return e>=.05?"text-green-400":e>=.02?"text-yellow-400":"text-neutral-400"}function ev({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",vp(e)),children:js(e)}),o&&jsxs("span",{className:"text-xs text-green-500/80",children:["+",js(t)]})]})}var Dt=10,wp=64,Xs=40,fr=48;function Qs({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:o}=useTranslation(),[n,a]=useState(1),{data:i,isLoading:s,fetchNextPage:l,hasNextPage:c,isFetchingNextPage:u}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:50}),{data:d,isLoading:p,fetchNextPage:m,hasNextPage:g,isFetchingNextPage:f}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:50}),h=s||p,x=u||f,R=c||g,N=useMemo(()=>{let F=[];return i?.pages&&F.push(...i.pages.flatMap(W=>W.items)),d?.pages&&F.push(...d.pages.flatMap(W=>W.items)),F.sort((W,$)=>($.timestamp??0)-(W.timestamp??0)),F},[i,d]),w=Math.max(1,Math.ceil(N.length/Dt)+(R?1:0)),v=(n-1)*Dt,B=N.slice(v,v+Dt),b=useCallback(()=>{a(F=>Math.max(1,F-1));},[]),X=useCallback(async()=>{n*Dt>=N.length&&R&&(c&&await l(),g&&await m()),a(W=>W+1);},[n,N.length,R,c,g,l,m]),j=n>1,ie=n*Dt<N.length||R;if(h)return jsx(Lp,{height:r});if(N.length===0&&!R)return jsx(Tp,{message:o("predict.profile.noHistory"),height:r});let U=r-Xs-fr;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:Xs},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:U},children:[B.map((F,W)=>jsx(Pp,{trade:F},F.id??`${v+W}`)),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:fr},children:[jsxs("button",{type:"button",disabled:!j,onClick:b,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",j?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",o("predict.profile.previous")]}),Array.from({length:Math.min(w,5)},(F,W)=>{let $=W+1;return jsx("button",{type:"button",onClick:()=>a($),className:cn$1("w-8 h-8 rounded text-sm transition-colors cursor-pointer",$===n?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:$},$)}),jsxs("button",{type:"button",disabled:!ie,onClick:X,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",ie?"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-fr},children:B.map((F,W)=>jsx(Cp,{trade:F},F.id??`m-${v+W}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:fr},children:[jsx("button",{type:"button",disabled:!j,onClick:b,className:cn$1("text-sm cursor-pointer",j?"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:!ie,onClick:X,className:cn$1("text-sm cursor-pointer",ie?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function Pp({trade:e}){let{t}=useTranslation(),r=e.side?.toUpperCase()==="BUY",o=e.price??0,n=e.usd_size??0,a=Zs(e.type,t),i=r,s=i?"+":"-",l=i?"text-success":"text-foreground",c=e.event?.title??e.market?.question??"\u2014",u=e.event?.image_url,d=e.outcome??"",p=ra(e.timestamp),m=Js(e),g=Ep(e),f=Mp(e);return jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:wp},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:[u&&jsx("img",{src:u,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:c}),jsxs("span",{className:"text-[11px] text-neutral",children:[d&&jsx("span",{className:"mr-1",children:d}),jsx("span",{children:p})]})]})]})}),jsx("div",{className:"flex-1 pr-2",children:jsx("span",{className:cn$1("text-sm font-medium",r?"text-success":"text-danger"),children:t(r?"predict.profile.buy":"predict.profile.sell")})}),jsx("div",{className:"flex-1 pr-2 text-sm text-foreground",children:a}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:ta(o)}),jsx("div",{className:cn$1("flex-[1.5] pr-2 text-right font-mono",l),children:n>0?jsxs(Fragment,{children:[s,"$",n.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:f!==null?`$${f.toFixed(2)}`:"\u2014"}),jsx("div",{className:"w-10 shrink-0 text-right",children:m&&jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"text-neutral hover:text-foreground transition-colors","aria-label":"View transaction",children:jsx(ea,{})})})]})}function Cp({trade:e}){let{t}=useTranslation(),r=e.side?.toUpperCase()==="BUY",o=e.price??0,n=e.usd_size??0,a=Zs(e.type,t),i=e.event?.title??e.market?.question??"\u2014",s=ra(e.timestamp),l=Js(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:i})]}),jsx("span",{className:"text-[11px] text-neutral whitespace-nowrap",children:s})]}),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-success":"text-danger"),children:t(r?"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:a})]}),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:ta(o)})]}),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:n>0?`$${n.toFixed(2)}`:"\u2014"})]}),l&&jsx("a",{href:l,target:"_blank",rel:"noopener noreferrer",className:"ml-auto text-neutral hover:text-foreground transition-colors",children:jsx(ea,{})})]})]})}function Zs(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 Js(e){if(e.tx_hash)return e.source==="polymarket"?`https://polygonscan.com/tx/${e.tx_hash}`:`https://solscan.io/tx/${e.tx_hash}`}function Ep(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 Mp(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 ea(){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 Tp({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function Lp({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 ta(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function ra(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"),a=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getFullYear(),s=t.getTimezoneOffset(),l=s<=0?"+":"-",c=String(Math.abs(Math.floor(s/60))).padStart(2,"0");return `${r}:${o} ${n}/${a}/${i} (${l}${c})`}var Ft=10,Fp=64,oa=40,gr=48;function aa({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:o}=useTranslation(),n=useCancelOrder(),[a,i]=useState(1),{data:s,isLoading:l,fetchNextPage:c,hasNextPage:u,isFetchingNextPage:d}=useInfiniteOrders({source:"kalshi",wallet_address:e??""}),{data:p,isLoading:m,fetchNextPage:g,hasNextPage:f,isFetchingNextPage:h}=useInfiniteOrders({source:"polymarket",wallet_address:t??""}),x=l||m,R=d||h,N=u||f,w=useMemo(()=>{let $=[],oe=new Set(["live","open","submitted","pending"]);return s?.pages&&$.push(...s.pages.flatMap(pe=>pe.items).filter(pe=>oe.has(pe.status))),p?.pages&&$.push(...p.pages.flatMap(pe=>pe.items).filter(pe=>oe.has(pe.status))),$},[s,p]),v=useCallback($=>{n.mutate({source:$.source,id:$.id});},[n]),B=Math.max(1,Math.ceil(w.length/Ft)+(N?1:0)),b=(a-1)*Ft,X=w.slice(b,b+Ft),j=useCallback(()=>{i($=>Math.max(1,$-1));},[]),ie=useCallback(async()=>{a*Ft>=w.length&&N&&(u&&await c(),f&&await g()),i(oe=>oe+1);},[a,w.length,N,u,f,c,g]),U=a>1,F=a*Ft<w.length||N;if(x)return jsx(Wp,{height:r});if(w.length===0&&!N)return jsx($p,{message:o("predict.profile.noOrders"),height:r});let W=r-oa-gr;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:oa},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:W},children:[X.map($=>jsx(Hp,{order:$,onCancel:v},$.id)),R&&jsx("div",{className:"flex justify-center items-center py-4",children:jsx(Spinner,{size:"sm"})})]}),jsx(sa,{className:"hidden lg:flex",currentPage:a,totalPages:B,canGoPrev:U,canGoNext:F,onPrev:j,onNext:ie,onPage:i,t:o}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-gr},children:X.map($=>jsx(Bp,{order:$,onCancel:v},$.id))}),jsx(sa,{className:"lg:hidden",currentPage:a,totalPages:B,canGoPrev:U,canGoNext:F,onPrev:j,onNext:ie,onPage:i,t:o,compact:true})]})}function Hp({order:e,onCancel:t}){let{t:r}=useTranslation(),o=e.side==="BUY",n=e.price?parseFloat(e.price):0,a=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:Fp},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?ia(n):"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:a>0?`$${a.toFixed(2)}`:"\u2014"})]})}function Bp({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?ia(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 sa({className:e,currentPage:t,totalPages:r,canGoPrev:o,canGoNext:n,onPrev:a,onNext:i,onPage:s,t:l,compact:c}){return c?jsxs("div",{className:cn$1("flex items-center justify-center gap-3 shrink-0",e),style:{height:gr},children:[jsx("button",{type:"button",disabled:!o,onClick:a,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:i,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:gr},children:[jsxs("button",{type:"button",disabled:!o,onClick:a,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)},(u,d)=>{let p=d+1;return jsx("button",{type:"button",onClick:()=>s(p),className:cn$1("w-8 h-8 rounded text-sm transition-colors cursor-pointer",p===t?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:p},p)}),jsxs("button",{type:"button",disabled:!n,onClick:i,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 $p({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function Wp({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 ia(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}var bn=10,Vp=64,la=40,hr=48;function ca({positions:e,isLoading:t,listHeight:r,onClosePosition:o,onEventClick:n}){let{t:a}=useTranslation(),[i,s]=useState(1),l=useCallback(()=>{for(let f of e)o?.(f);},[e,o]);if(t)return jsx(qp,{height:r});if(e.length===0)return jsx(Yp,{message:a("predict.profile.noPositions"),height:r});let c=Math.max(1,Math.ceil(e.length/bn)),u=(i-1)*bn,d=e.slice(u,u+bn),p=i>1,m=i<c,g=r-la-hr;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:la},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:a("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2 text-right",children:a("predict.profile.totalSize")}),jsx("div",{className:"flex-1 pr-2 text-right",children:a("predict.profile.value")}),jsx("div",{className:"flex-1 pr-2 text-right",children:a("predict.profile.avgPrice")}),jsx("div",{className:"flex-1 pr-2 text-right",children:a("predict.profile.markPrice")}),jsxs("div",{className:"flex-[1.5] pr-2 text-right",children:[jsx("span",{children:a("predict.profile.pnl")}),jsxs("span",{className:"text-[10px] ml-1 opacity-60",children:["(",a("predict.profile.pnlExcludeFees"),")"]})]}),jsx("div",{className:"flex-1 pr-2 text-right",children:a("predict.profile.payoutIfRight")}),jsx("div",{className:"flex-[1.5] pr-2 text-right",children:a("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:a("predict.profile.closeAll")})})]}),jsx("div",{className:"hidden lg:block overflow-y-auto",style:{height:g},children:d.map((f,h)=>jsx(jp,{position:f,onClosePosition:o,onEventClick:n},f.market?.slug??`${u+h}`))}),jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:hr},children:[jsxs("button",{type:"button",disabled:!p,onClick:()=>s(f=>Math.max(1,f-1)),className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",p?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",a("predict.profile.previous")]}),Array.from({length:Math.min(c,5)},(f,h)=>{let x=h+1;return jsx("button",{type:"button",onClick:()=>s(x),className:cn$1("w-8 h-8 rounded text-sm transition-colors cursor-pointer",x===i?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:x},x)}),jsxs("button",{type:"button",disabled:!m,onClick:()=>s(f=>f+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:[a("predict.profile.next")," \u2192"]})]}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-hr},children:d.map((f,h)=>jsx(Gp,{position:f,onClose:o,onEventClick:n},f.market?.slug??`m-${u+h}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:hr},children:[jsx("button",{type:"button",disabled:!p,onClick:()=>s(f=>Math.max(1,f-1)),className:cn$1("text-sm cursor-pointer",p?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:i}),jsx("button",{type:"button",disabled:!m,onClick:()=>s(f=>f+1),className:cn$1("text-sm cursor-pointer",m?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function jp({position:e,onClosePosition:t,onEventClick:r}){let{t:o}=useTranslation(),n=e.pnl??0,a=e.pnl_percent??0,i=e.avg_price??0,s=e.current_price??0,l=e.current_value??e.size*s,c=e.size,u=n>0?"text-success":n<0?"text-danger":"text-foreground",d=n>0?"+":"",p=e.event?.title??e.market?.question??"\u2014",m=e.event?.image_url,g=e.side,f=e.market?.outcomes?.[0]?.label??"",h=e.market?.end_at?Xp(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:Vp},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:[m&&jsx("img",{src:m,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:p}),jsxs("span",{className:"text-[11px] text-neutral",children:[jsx("span",{className:cn$1("font-medium",g.toLowerCase()==="yes"?"text-success":"text-danger"),children:g}),f&&jsxs(Fragment,{children:[jsx("span",{className:"mx-1",children:"\xB7"}),jsx("span",{children:f})]})]})]})]})}),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:e.size})})]})}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",(e.size*i).toFixed(2)]}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:yn(i)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:yn(s)}),jsxs("div",{className:cn$1("flex-[1.5] pr-2 text-right font-mono",u),children:[jsxs("span",{children:[d,"$",Math.abs(n).toFixed(2)]}),jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",d,a.toFixed(2),"%)"]})]}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",c.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap text-xs",children:h}),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 Gp({position:e,onClose:t,onEventClick:r}){let{t:o}=useTranslation(),n=e.pnl??0,a=e.pnl_percent??0,i=e.current_price??0,s=n>0?"text-success":n<0?"text-danger":"text-foreground",l=n>0?"+":"",c=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:c})]}),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(xr,{label:o("predict.profile.totalSize"),value:`${e.size}`}),jsx(xr,{label:o("predict.profile.markPrice"),value:yn(i)}),jsx(xr,{label:o("predict.profile.pnl"),value:`${l}$${Math.abs(n).toFixed(2)} (${l}${a.toFixed(1)}%)`,className:s}),jsx(xr,{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 xr({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 Yp({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function qp({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 yn(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function Xp(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"),a=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getFullYear(),s=t.getTimezoneOffset(),l=s<=0?"+":"-",c=String(Math.abs(Math.floor(s/60))).padStart(2,"0");return `${r}:${o} ${n}/${a}/${i} (${l}${c})`}catch{return "\u2014"}}function ua({positions:e,trades:t,isLoading:r}){let{t:o}=useTranslation(),n=useMemo(()=>{let s=0,l=0;for(let m of e)s+=m.realized_pnl??0,l+=m.current_value??m.size*(m.current_price??0);let c=0,u=0,d=0;for(let m of t)c+=m.usd_size??0,m.type==="REDEEM"&&(d++,(m.usd_size??0)>0&&u++);let p=d>0?`${u} / ${d}`:"0 / 0";return {realizedPnl:s,positionsValue:l,volume:c,winRateStr:p}},[e,t]),a=n.realizedPnl>0?"text-success":n.realizedPnl<0?"text-danger":"text-foreground",i=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",a),children:[i,"$",Math.abs(n.realizedPnl).toFixed(2)]})]}),jsxs("div",{className:"flex items-end gap-8 sm:gap-10",children:[jsx(Nn,{label:o("predict.profile.winRate"),value:n.winRateStr,isLoading:r}),jsx(Nn,{label:o("predict.profile.positions"),value:`$${n.positionsValue.toFixed(2)}`,isLoading:r}),jsx(Nn,{label:o("predict.profile.volume"),value:`$${n.volume.toFixed(2)}`,isLoading:r})]})]})}function Nn({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 Sn=600;function om({solanaAddress:e,evmAddress:t,onClosePosition:r,onEventClick:o}){let{t:n}=useTranslation(),[a,i]=useState("positions"),s=!!(e||t),{data:l,isLoading:c}=usePositions({source:"kalshi",user:e??""}),{data:u,isLoading:d}=usePositions({source:"polymarket",user:t??""}),p=useMemo(()=>{let b=[];return l?.positions&&b.push(...l.positions),u?.positions&&b.push(...u.positions),b},[l,u]),m=c||d,{data:g,isLoading:f}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:100}),{data:h,isLoading:x}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:100}),R=useMemo(()=>[...g?.pages?.flatMap(X=>X.items)??[],...h?.pages?.flatMap(X=>X.items)??[]],[g,h]),N=m||f||x,w=p.length,B=[{key:"positions",label:w>0?`${n("predict.profile.positionsTab")} (${w})`:n("predict.profile.positionsTab")},{key:"orders",label:n("predict.profile.openOrdersTab")},{key:"history",label:n("predict.profile.historyTab")}];return s?jsxs("div",{className:"flex flex-col max-w-[1280px] mx-auto w-full px-4 max-sm:px-2",children:[jsx(ua,{positions:p,trades:R,isLoading:N}),jsx("div",{className:"flex items-center gap-1 border-b border-border",children:B.map(b=>jsx("button",{type:"button",onClick:()=>i(b.key),className:cn$1("px-3 py-3 text-base font-normal transition-colors cursor-pointer whitespace-nowrap",a===b.key?"text-foreground border-b-2 border-foreground":"text-neutral hover:text-foreground"),children:b.label},b.key))}),jsxs("div",{className:"py-2",children:[a==="positions"&&jsx(ca,{positions:p,isLoading:m,listHeight:Sn,onClosePosition:r,onEventClick:o}),a==="orders"&&jsx(aa,{solanaAddress:e,evmAddress:t,listHeight:Sn}),a==="history"&&jsx(Qs,{solanaAddress:e,evmAddress:t,listHeight:Sn})]})]}):jsx("div",{className:"flex items-center justify-center text-sm text-neutral py-24 px-4",children:n("predict.profile.connectWallet")})}
50
+ export{Nm as CHART_RANGE_DURATION,ym as CHART_RANGE_PERIOD,km as CHART_RANGE_SAMPLE_INTERVAL,Ut as CandlestickPeriod,um as CategoriesSkeleton,Dn as CategoriesUI,Bn as CategoriesWidget,Se as ChartRange,Kt as DEFAULT_CHART_RANGE,Fr as DEFAULT_FILTER_STATE,bt as DEFAULT_PAGE_SIZE,Cm as DEFAULT_PRICE_HISTORY_INTERVAL,y0 as EventDetailPage,Mt as EventDetailSkeleton,ns as EventDetailUI,os as EventDetailWidget,wo as EventItem,Uo as EventMarketDepthChartUI,Yo as EventMarketDetailWidget,Qo as EventPriceChart,so as EventsFilterUI,og as EventsPage,Ef as EventsPageSkeleton,Br as EventsSkeleton,uo as EventsToolbarUI,Lo as EventsUI,_o as EventsWidget,Tr as MAX_PRICE_HISTORY_MARKETS,Ws as MatchGroupCard,As as MatchesFilterBar,Ds as MatchesHero,Vx as MatchesPage,Xx as MatchesStatsBar,Us as MatchesWidget,Pm as ORDER_MAX_PRICE,wm as ORDER_MIN_PRICE,Lr as ORDER_MIN_QUANTITY,Sm as ORDER_PRICE_STEP,cn as PREDICT_SEARCH_MODAL_ID,yt as PREDICT_TRADE_MODAL_ID,Em as PRICE_HISTORY_SAMPLE_INTERVAL,Gh as PredictSearchModal,jt as PredictTradeModal,ja as PredictWalletProvider,at as PriceHistoryInterval,om as ProfilePage,co as SORT_PRESETS,Mr as STATIC_CATEGORIES,rx as SearchEventsButton,us as SearchHistoryUI,ps as SearchHistoryWidget,ms as SearchInputUI,gs as SearchResultItemUI,ys as SearchResultListWidget,Ps as SearchWidget,fd as SimilarEventCard,ss as SimilarEventsSection,Px as SourceBadge,ev as SpreadIndicator,Fo as TradeFormSkeleton,ro as TradeFormUI,Vt as TradeFormWidget,Do as UserActivitySection,Hr as countActiveFilters,Tt as formatKMB,ur as getSourceMeta,E0 as useEventDetail,fo as useEventsInfinite,lr as usePredictSearchHistory,_r as usePredictWallet,hs as useSearchResultListScript,ws as useSearchScript,qn as useTradeForm,Ia as version};//# sourceMappingURL=index.mjs.map
22
51
  //# sourceMappingURL=index.mjs.map