@liberfi.io/ui-predict 4.0.30 → 4.0.32

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,9 +1,9 @@
1
- import {createContext,memo,useRef,forwardRef,useState,useImperativeHandle,useMemo,useEffect,useCallback,useContext,Fragment as Fragment$1,startTransition,Component}from'react';import {PolymarketIcon,KalshiIcon,cn as cn$1,Skeleton,toast,StyledModal,ModalContent,useDisclosure,Tabs,Tab,StyledInput,StyledSwitch,Select,SelectItem,StyledNumberInput,ChevronDownIcon,Button,Spinner,useScreen,TimerIcon,DropletIcon,ChartLineIcon,CalendarIcon,Linkable,Avatar,ChevronUpIcon,OrderbookTableIcon,OrderbookDepthIcon,RefreshIcon,Dropdown,DropdownTrigger,DropdownMenu,DropdownItem,ChevronRightIcon,ChevronLeftIcon,TrashIcon,Chip,XCloseIcon,Kbd,SearchIcon,EmptyIcon,ModalHeader,ModalBody}from'@liberfi.io/ui';import {AsyncModal,useAsyncModal}from'@liberfi.io/ui-scaffold';import {useTranslation}from'@liberfi.io/i18n';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useWallets,useAuth,useAuthCallback}from'@liberfi.io/wallet-connector';import {keepPreviousData,useQueryClient,useQueries}from'@tanstack/react-query';import {useInfiniteMatchMarkets,useBalance,useDFlowKYC,usePolymarketSetup,usePredictClient,PolymarketContext,useTickSize,useFeeRate,useRealtimeOrderbook,pickBestAsk,walkOrderbook,usePositions,useDFlowQuote,useDFlowSubmit,useOrder,buildCtfExchangeDomain,buildOrderMessage,CTF_ORDER_TYPES,buildSignedOrder,buildClobPayload,buildPolymarketL2Headers,resolveEventsParams,useInfiniteEvents,useRedeemPosition,pickBestBid,useAvailableShares,getPolymarketSharesPrecision,useInfiniteOrders,useCancelOrder,useInfiniteTrades,useOrderbook,useMarketHistory,useEvent,useSimilarEvents,candlesticksQueryKey,useSearchEvents}from'@liberfi.io/react-predict';export{PredictClient,PredictContext,PredictProvider,PredictWsClient,createPredictClient,createPredictWsClient,eventStatsQueryKey,fetchMatchMarketsPage,fetchMatchesPage,matchMarketsQueryKey,matchQueryKey,matchesQueryKey,useBalance,useCancelOrder,useCandlesticks,useDFlowKYC,useDFlowQuote,useDFlowSubmit,useEvent,useEventStats,useEvents,useInfiniteEvents,useInfiniteMatchMarkets,useInfiniteMatches,useInfiniteOrders,useInfiniteTrades,useMarket,useMarketHistory,useMarketTrades,useMatch,useOrder,useOrderbook,useOrders,usePositions,usePredictClient,usePriceHistory,useRedeemPosition,useSearchEvents,useSimilarEvents,useTrades}from'@liberfi.io/react-predict';import {ChainNamespace,Chain}from'@liberfi.io/types';import {SOLANA_TOKENS,formatAmountInUsd,formatAmount,debounce}from'@liberfi.io/utils';import to from'canvas-confetti';import {List}from'react-window';import {useInfiniteLoader}from'react-window-infinite-loader';import {useScrollCollapse,useResizeObserver,useCallbackRef}from'@liberfi.io/hooks';import {ResponsiveContainer,LineChart,CartesianGrid,XAxis,YAxis,Tooltip,Line,ReferenceDot}from'recharts';import {useAtom}from'jotai';import {atomWithStorage}from'jotai/utils';var Tl={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},Xo=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],Jn=(()=>{let e=t=>{let r=Xo.indexOf(t);return r===-1?Xo.length:r};return Object.entries(Tl).map(([t,r])=>({slug:t,label:t,tags:(r??[]).map(n=>({slug:n,label:n}))})).sort((t,r)=>e(t.slug)-e(r.slug))})();function ei({categories:e,selectedCategory:t,selectedTag:r,activeTags:n,onCategorySelect:o,onTagSelect:i,trailing:s,pulsingTab:a="Trending",className:l}){let{t:c}=useTranslation(),d=useCallback(()=>{o(null);},[o]),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-2.5 lg:px-4 lg:py-2",l),children:[jsx("style",{children:".cat-primary-row{display:flex;width:100%;flex-direction:column;gap:8px}@media(min-width:1024px){.cat-primary-row{flex-direction:row;align-items:center}}.cat-primary-row>.cat-tabs{min-width:0;overflow-x:auto;overflow-y:hidden;-ms-overflow-style:none;scrollbar-width:none}.cat-primary-row>.cat-tabs::-webkit-scrollbar{display:none}@media(min-width:1024px){.cat-primary-row>.cat-tabs{flex:1 1 0%}}"}),jsxs("div",{className:"cat-primary-row",children:[jsx("div",{className:"cat-tabs hideScrollbar",children:jsxs("div",{className:"flex min-h-9 items-stretch gap-x-3 lg:min-h-10",children:[jsx(Jo,{label:p,isSelected:t===null,onPress:d,showPulse:p===a}),jsx(Il,{}),e.map(m=>jsx(Jo,{label:m.category,isSelected:t===m.category,onPress:()=>o(m.category),badge:m.badge,showPulse:m.category===a},m.category))]})}),s&&jsx("div",{className:"flex-shrink-0",children:s})]}),t&&n.length>0&&jsx("div",{className:"hideScrollbar overflow-x-auto overflow-y-hidden flex items-center",children:jsxs("div",{className:"flex gap-x-1.5 pl-1 lg:w-full lg:gap-x-2",children:[jsx(Zo,{label:c("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>i(null)}),n.map(m=>jsx(Zo,{label:m.label,icon:m.icon,isSelected:r===m.label,onPress:()=>i(m.label)},m.label))]})})]})}function Jo({label:e,isSelected:t,onPress:r,badge:n,showPulse:o}){return jsxs("button",{type:"button",onClick:r,className:cn$1("relative shrink-0 cursor-pointer whitespace-nowrap border-b px-2.5 py-1.5 text-sm font-medium capitalize transition-colors",t?"border-primary/50 text-primary":"border-transparent text-neutral-500 hover:text-neutral-300"),children:[o?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,n&&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:n})]})}function Il(){return jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function Zo({label:e,icon:t,isSelected:r,onPress:n}){return jsxs("button",{type:"button",onClick:n,className:cn$1("flex shrink-0 items-center justify-center gap-x-1 min-w-14 rounded-2xl border px-3 py-1.5 text-sm font-medium uppercase transition-colors cursor-pointer",r?"border-primary/40 bg-primary/15 text-primary":"border-border/80 text-neutral-500 hover:bg-primary/10 hover:text-primary"),children:[t&&jsx("span",{className:cn$1("iconify size-4",t)}),e]})}function Y0({count:e=6}){return jsx("div",{className:"flex w-full flex-col gap-2 px-4 py-2.5 lg:px-4 lg:py-2",children:jsx("div",{className:"flex min-h-9 items-center gap-x-3 lg:min-h-10",children:Array.from({length:e}).map((t,r)=>jsx(Skeleton,{className:"h-6 w-16 shrink-0 rounded"},r))})})}function Ol(e){return e.map(t=>({category:t.label,tags:t.tags.map(r=>r.label)}))}function Dl(e){return e?e.tags.map(t=>({label:t.label,icon:t.icon})):[]}function ni({onSelect:e,trailing:t,className:r}){let[n,o]=useState(null),[i,s]=useState(null),a=useCallback(m=>{o(m),s(null),e?.({categorySlug:m,tagSlug:null});},[e]),l=useCallback(m=>{s(m),e?.({categorySlug:n,tagSlug:m});},[n,e]),c=Ol(Jn),d=Jn.find(m=>m.slug===n),p=Dl(d);return jsx(ei,{categories:c,selectedCategory:n,selectedTag:i,activeTags:p,onCategorySelect:a,onTagSelect:l,trailing:t,className:r})}function an(e){return {title:e.title,imageUrl:e.image_url}}function ln(e,t){let r=e.outcomes[0],n=e.outcomes[1];return {question:e.question,yesAsk:t?.yesAsk??r?.best_ask??r?.price,noAsk:t?.noAsk??n?.best_ask??n?.price,yesBid:t?.yesBid??r?.best_bid,noBid:t?.noBid??n?.best_bid,yesSubTitle:r?.label??"Yes",noSubTitle:n?.label??"No"}}var Lr=24,Zn=4,cn={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},ie={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},dn=ie.ALL,oh={[ie.ONE_DAY]:cn.ONE_MINUTE,[ie.ONE_WEEK]:cn.ONE_HOUR,[ie.ONE_MONTH]:cn.ONE_HOUR,[ie.ALL]:cn.ONE_DAY},ih={[ie.ONE_DAY]:300,[ie.ONE_WEEK]:3600,[ie.ONE_MONTH]:10800,[ie.ALL]:1440*60},sh={[ie.ONE_DAY]:1440*60,[ie.ONE_WEEK]:10080*60,[ie.ONE_MONTH]:720*60*60,[ie.ALL]:null},un=1,pn=1,ah=1,lh=1,ch=99,fr={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},dh=fr.ONE_WEEK,uh={[fr.ONE_HOUR]:60,[fr.SIX_HOURS]:60,[fr.ONE_DAY]:300,[fr.ONE_WEEK]:1800,[fr.MAX]:1800};var si=createContext(null);function er(){let e=useContext(si);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var Ul=1e4;function $l({pollingInterval:e=Ul,enabled:t=true,children:r}){let n=useWallets(),o=useMemo(()=>n.find(x=>x.chainNamespace===ChainNamespace.SOLANA&&x.isConnected)?.address,[n]),i=useMemo(()=>n.find(x=>x.chainNamespace===ChainNamespace.EVM&&x.isConnected)?.address,[n]),{data:s,isLoading:a,isFetching:l,error:c}=useBalance({source:"kalshi",user:o??""},{enabled:t&&!!o,refetchInterval:e}),{data:d,isLoading:p}=useDFlowKYC(o,{enabled:t&&!!o,refetchInterval:3e4}),{data:m,isLoading:u}=usePolymarketSetup(i,{enabled:t&&!!i,refetchInterval:3e4}),f=m?.safe_address,h=m?.verified??false,{data:g,isLoading:v,isFetching:S,error:w}=useBalance({source:"polymarket",user:i??""},{enabled:t&&h&&!!i,refetchInterval:e}),N=useMemo(()=>({solanaAddress:o,evmAddress:i,polymarketSafeAddress:f,kalshiUsdcBalance:s?Number(s.balance):null,polymarketUsdcBalance:h&&g?Number(g.balance):null,kalshiKycVerified:d?.verified??false,kalshiKycUrl:d?.kyc_url??null,kalshiKycLoading:p,polymarketSetupVerified:h,polymarketSafeDeployed:m?.safe_deployed??false,polymarketTokenApproved:m?.token_approved??false,polymarketSetupLoading:u,isLoading:a||v,isFetching:l||S,error:c??w??null}),[o,i,f,s,g,h,d,p,m,u,a,v,l,S,c,w]);return jsx(si.Provider,{value:N,children:r})}var Vl={minutes:60,hours:3600,days:86400};function mn(e,t,r){let n=Math.floor(Date.now()/1e3);switch(e){case "5m":return n+300;case "1h":return n+3600;case "12h":return n+720*60;case "24h":return n+1440*60;case "eod":{let o=new Date;return o.setUTCHours(23,59,59,0),Math.floor(o.getTime()/1e3)}case "custom":return n+t*Vl[r]}}function fn(e,t){let r=parseFloat(t);return !r||r<=0?e:Math.round(e/r)*r}function xe(e,t){let r=Math.pow(10,t);return Math.floor(e*r)/r}function gn(e,t,r){let n=e.match(/Size\s*\(([\d.]+)\)\s*lower than the minimum:\s*([\d.]+)/i);if(n)return t("predict.trade.polymarket.minOrderSize",{current:n[1],min:n[2]});let o=e.match(/balance:\s*(\d+),\s*sum of active orders:\s*(\d+)/i);if(o){let s=parseInt(o[1],10)/1e6,a=parseInt(o[2],10)/1e6,l=Math.max(0,s-a);return t("predict.trade.polymarket.insufficientBalance",{total:xe(s,2).toFixed(2),active:xe(a,2).toFixed(2),available:xe(l,2).toFixed(2)})}return /not enough balance/i.test(e)?t(r==="sell"?"predict.trade.insufficientShares":"predict.trade.insufficientBalance"):/max accuracy of/i.test(e)?t("predict.trade.polymarket.decimalAccuracy"):/tick size/i.test(e)?t("predict.trade.polymarket.tickSizeError"):/couldn.*fully filled|FOK.*filled or killed/i.test(e)?t("predict.trade.polymarket.fokNotFilled"):e.replace(/order\s+0x[a-f0-9]+\s+is invalid\.\s*/i,"")||e}function Rr(e,t=2){return parseFloat(xe(e,t).toFixed(t)).toString()}function tr(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};to({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{to({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{to({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function di({market:e,initialOutcome:t="yes",slippageBps:r=100,onInsufficientBalance:n}){let{t:o}=useTranslation(),{status:i}=useAuth(),s=useWallets(),a=usePredictClient(),l=useContext(PolymarketContext),c=useQueryClient(),d=e.source,p=d==="polymarket",m=s.find(I=>I.chainNamespace===ChainNamespace.SOLANA&&I.isConnected),u=s.find(I=>I.chainNamespace===ChainNamespace.EVM&&I.isConnected&&"switchChain"in I),f=i==="authenticated",h=m?.address,g=u?.address,v=useMemo(()=>{if(d!=="polymarket")return;let I=e.provider_meta?.["polymarket.clobTokenIds"];return I?(typeof I=="string"?JSON.parse(I):I)[0]:void 0},[d,e.provider_meta]),{data:S,isLoading:w}=useTickSize(v),N=S?.minimum_tick_size?String(S.minimum_tick_size):"0.01",{data:x,isLoading:T}=useFeeRate(v),k=String(x?.base_fee??0),[L,H]=useState(t),[D,A]=useState("market"),[P,W]=useState(NaN),[O,ae]=useState(NaN),[X,Y]=useState(false),[b,y]=useState(null),[V,G]=useState(false),[J,le]=useState(false),[ve,_e]=useState("1h"),[Ie,Ee]=useState(30),[st,Ye]=useState("minutes"),Ue=null,He=false,pt=null,Qe;try{let I=er();Ue={kalshiUsdcBalance:I.kalshiUsdcBalance,polymarketUsdcBalance:I.polymarketUsdcBalance,isLoading:I.isLoading},He=I.kalshiKycVerified,pt=I.kalshiKycUrl,Qe=I.polymarketSafeAddress;}catch{}let{data:F}=useRealtimeOrderbook({slug:e.slug,source:d},{enabled:e.status==="open"}),ee=useMemo(()=>{let I=pickBestAsk(F,L);if(I!=null&&I>0)return I;let De=L==="yes"?0:1,Ve=e.outcomes[De];return Ve?.best_ask??Ve?.price??.5},[F,e.outcomes,L]),Ke=useCallback(I=>{A(I);},[]),Ht=useCallback(I=>{H(I),ae(NaN);},[]);useEffect(()=>{D==="limit"&&isNaN(O)&&ae(Math.round(ee*100)/100);},[D,O,ee]);let Se=useMemo(()=>isNaN(P)||P<=0?0:ee>0?P/ee:0,[P,ee]),Oe=useMemo(()=>walkOrderbook({orderbook:F,outcome:L,side:"buy",sharesNeeded:Se,slippageBps:r}),[F,L,Se,r]),_=useMemo(()=>Oe.status==="ok"&&Oe.worstPrice!=null&&Oe.worstPrice>0?Oe.worstPrice:ee,[Oe,ee]),we=useMemo(()=>isNaN(P)||P<=0?"0":String(Math.round(P*1e6)),[P]),Pt=e.provider_meta?.["dflow.yesMint"]??"",jt=e.provider_meta?.["dflow.noMint"]??"",jn=SOLANA_TOKENS.stablecoins.USDC.address,wr=L==="yes"?Pt:jt,Nt=jn,at=wr,$e=d==="kalshi"?h??"":g??"",{data:Pr,isLoading:Gn}=usePositions({source:d,user:$e},{enabled:!!$e}),qn=d==="kalshi"&&!!Nt&&!!at&&!!h&&we!=="0",{refetch:Ct}=useDFlowQuote({inputMint:Nt,outputMint:at,amount:we,userPublicKey:h??"",slippageBps:100},{enabled:qn}),Mt=useMemo(()=>Ue?d==="kalshi"?Ue.kalshiUsdcBalance:Ue.polymarketUsdcBalance:Pr&&Pr.positions.reduce((De,Ve)=>Ve.side==="USDC"||Ve.side==="collateral"?De+(Ve.current_value??0):De,0)||null,[Ue,Pr,d]),Yn=Ue?Ue.isLoading:Gn,Qr=useMemo(()=>D==="limit"&&p&&!isNaN(O)?O:ee,[D,p,O,ee]),Nr=useMemo(()=>isNaN(P)||P<=0?0:P,[P]),Xr=useMemo(()=>isNaN(P)||P<=0?0:Qr>0?P/Qr*1:0,[P,Qr]),Gt=Xr-Nr,qt=useCallback(I=>{if(isNaN(I)){W(NaN);return}W(Math.round(Math.max(0,I)*100)/100);},[]),Yt=useCallback(I=>{if(isNaN(I)){ae(NaN);return}let De=Math.max(.01,Math.min(.99,I));ae(Math.round(De*100)/100);},[]),Et=useCallback(()=>{W(NaN),ae(NaN),A("market"),le(false),_e("1h"),Ee(30),Ye("minutes");},[]),Cr=useMemo(()=>{let I=[];return isNaN(P)||P<=0?I.push(o("predict.trade.minAmountUsd",{amount:pn})):P<pn&&I.push(o("predict.trade.minAmountUsd",{amount:pn})),e.status!=="open"&&I.push(o("predict.trade.marketNotActive")),Mt!=null&&!isNaN(P)&&P>0&&P>xe(Mt,2)&&I.push(o("predict.trade.insufficientBalance")),D==="limit"&&p&&(isNaN(O)||O<.01||O>.99)&&I.push(o("predict.trade.limitPriceRange")),D==="limit"&&p&&J&&ve==="custom"&&(isNaN(Ie)||Ie<=0)&&I.push(o("predict.trade.expiration.invalidDate")),d==="polymarket"&&D==="market"&&!isNaN(P)&&P>0&&Se>0&&(Oe.status==="insufficient_liquidity"?I.push(o("predict.trade.insufficientLiquidity",{available:xe(Oe.totalAvailable,2)})):Oe.status==="exceeds_slippage"&&I.push(o("predict.trade.priceImpactTooHigh",{impact:(Oe.priceImpactBps/100).toFixed(2),slippage:(r/100).toFixed(2)}))),{isValid:I.length===0,errors:I}},[P,e.status,Mt,D,p,O,J,ve,Ie,d,Se,Oe,r,o]),Jr=useMemo(()=>Mt==null||isNaN(P)||P<=0?false:P>xe(Mt,2),[Mt,P]),Mr=useCallback(()=>{n?.(d);},[n,d]),{mutateAsync:Xe}=useDFlowSubmit(),{data:pr}=useOrder({id:b??"",source:d},{enabled:!!b});useEffect(()=>{if(!pr||!b)return;let{status:I}=pr;I==="closed"?(y(null),Y(false),toast.success(o("predict.trade.submitSuccess")),tr(),Et(),c.invalidateQueries({queryKey:["predict","positions"]})):(I==="failed"||I==="expired")&&(Y(false),y(null),toast.error(o("predict.trade.submitError")));},[pr,b,c,Et,o]);let Zr=useCallback(async()=>{if(!h||!m)return;if(!Nt||!at){toast.error("Missing token mint addresses"),Y(false);return}if(!He){G(true),Y(false);return}let ht=(await Ct()).data?.transaction;if(!ht){toast.error(o("predict.trade.submitError")),Y(false);return}let vt=Uint8Array.from(atob(ht),Xt=>Xt.charCodeAt(0)),lt=await m.signTransaction(vt),Qt=await Xe({signedTransaction:btoa(String.fromCharCode(...lt)),orderContext:{user_public_key:h,input_mint:Nt,output_mint:at,amount:we,price:String(ee),side:"BUY",outcome:L==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});y(Qt.signature);},[h,m,Ct,Xe,Nt,at,we,ee,L,e.slug,o,He]),en=useCallback(async()=>{if(!u||!l)return;let I=u.chain,De=I!==Chain.POLYGON;De&&await u.switchChain(Chain.POLYGON);try{let Ve=await u.getEip1193Provider();if(!Ve){toast.error(o("predict.trade.submitError")),Y(!1);return}let ht=!!Qe,vt={address:u.address,signatureType:ht?2:0,signTypedData:async(Lt,Xn,Yo,nn)=>{let Wt=[];"name"in Lt&&Wt.push({name:"name",type:"string"}),"version"in Lt&&Wt.push({name:"version",type:"string"}),"chainId"in Lt&&Wt.push({name:"chainId",type:"uint256"}),"verifyingContract"in Lt&&Wt.push({name:"verifyingContract",type:"address"}),"salt"in Lt&&Wt.push({name:"salt",type:"bytes32"});let on={EIP712Domain:Wt,...Xn};return await Ve.request({method:"eth_signTypedData_v4",params:[u.address,JSON.stringify({domain:Lt,types:on,primaryType:Yo,message:nn})]})}},lt=l.credentials??await l.authenticate(vt),Qt=L==="yes"?0:1,Xt="",xt=e.provider_meta?.["polymarket.clobTokenIds"];xt&&(Xt=(typeof xt=="string"?JSON.parse(xt):xt)[Qt]??"");let Er=e.provider_meta?.["polymarket.negRisk"]??!1,tn=D==="limit"&&!isNaN(O)?O:_,Tr=fn(tn,N),C=D==="limit"?J?"GTD":"GTC":"FOK",Pe=D==="market"?P:Tr>0?P/Tr:0,Ae={tokenId:Xt,price:Tr,size:Pe,side:"BUY",orderType:C,tickSize:N,negRisk:Er,...Qe&&{funderAddress:Qe},...D==="limit"&&J&&{expiration:mn(ve,Ie,st)}},ze=buildCtfExchangeDomain(Er),ct=buildOrderMessage({...Ae,signerAddress:vt.address,signatureType:vt.signatureType,feeRateBps:k}),je=await vt.signTypedData(ze,CTF_ORDER_TYPES,"Order",ct),Tt=buildSignedOrder(ct,je,Ae.orderType),Te=buildClobPayload(Tt,lt.apiKey),zt=JSON.stringify(Te),rn=await buildPolymarketL2Headers(lt.address,{apiKey:lt.apiKey,secret:lt.secret,passphrase:lt.passphrase,method:"POST",requestPath:"/order",body:zt});await a.createPolymarketOrder(Te,rn),c.invalidateQueries({queryKey:["predict","orders"]}),c.invalidateQueries({queryKey:["predict","positions"]}),toast.success(o("predict.trade.submitSuccess")),tr(),Et(),Y(!1);}finally{De&&I&&u.switchChain(I).catch(()=>{});}},[u,l,L,e.provider_meta,D,O,_,P,a,c,J,ve,Ie,st,Et,o,N,k,Qe]),Qn=useCallback(async()=>{if(!(!Cr.isValid||!f)){Y(true),y(null),G(false);try{d==="kalshi"?await Zr():await en();}catch(I){let De=I instanceof Error?I.message:"",Ve=d==="polymarket"&&De?gn(De,o,"buy"):De||void 0;toast.error(Ve||o("predict.trade.submitError")),Y(false);}}},[Cr.isValid,f,d,Zr,en,o]);return {outcome:L,orderType:D,quantity:P,limitPrice:O,shares:Se,estimatedCost:Nr,potentialPayout:Xr,potentialProfit:Gt,pricePerShare:ee,usdcBalance:Mt,isBalanceLoading:Yn,isMarketDataLoading:d==="polymarket"&&(T||w),isSubmitting:X,validation:Cr,isInsufficientBalance:Jr,source:d,supportsLimitOrder:p,kycRequired:V,kycUrl:pt,expirationEnabled:J,expirationPreset:ve,customDuration:Ie,customDurationUnit:st,setOutcome:Ht,setOrderType:Ke,setQuantity:qt,setLimitPrice:Yt,setExpirationEnabled:le,setExpirationPreset:_e,setCustomDuration:Ee,setCustomDurationUnit:Ye,submit:Qn,notifyInsufficientBalance:Mr}}function hn({isOpen:e,onClose:t,kycUrl:r}){let{t:n}=useTranslation();return jsx(StyledModal,{isOpen:e,onOpenChange:o=>{o||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:n("predict.trade.kycModalTitle")}),jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxs("div",{className:"px-5 pb-5",children:[jsx("p",{className:"text-[13px] text-zinc-400 mb-4 text-left",children:n("predict.trade.kycModalDescription")}),jsx("div",{className:"flex flex-col gap-2 mb-4",children:["predict.trade.kycModalBullet1","predict.trade.kycModalBullet2","predict.trade.kycModalBullet3"].map(o=>jsxs("div",{className:"flex items-center gap-2.5 text-[13px] text-zinc-300",children:[jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#c7ff2e] shrink-0",children:jsx("polyline",{points:"20 6 9 17 4 12"})}),jsx("span",{children:n(o)})]},o))}),r&&jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[13px] text-[#c7ff2e]/70 hover:text-[#c7ff2e] transition-colors mb-3",children:[n("predict.trade.goToKYC")," \u2192"]}),jsx("p",{className:"text-[11px] text-zinc-500 mb-5",children:n("predict.trade.kycModalNote")}),jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:n("common.ok")})]})]})})})}var Ec=`https://s1.chainstream.io/chains/sol/tokens/${SOLANA_TOKENS.stablecoins.USDC.address}/image.png`,Tc=["5m","1h","12h","24h","eod","custom"],Lc={"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"},Rc=["minutes","hours","days"],_c={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},Ic={maximumFractionDigits:0};function xi({event:e,market:t,variant:r="bordered",outcome:n,orderType:o,quantity:i,limitPrice:s,shares:a,potentialProfit:l,potentialPayout:c,estimatedCost:d,usdcBalance:p,isBalanceLoading:m,isMarketDataLoading:u,isSubmitting:f,isValid:h,validationErrors:g,isInsufficientBalance:v,onInsufficientBalance:S,supportsLimitOrder:w,kycRequired:N,kycUrl:x,expirationEnabled:T,expirationPreset:k,customDuration:L,customDurationUnit:H,onOutcomeChange:D,onOrderTypeChange:A,onQuantityChange:P,onLimitPriceChange:W,onExpirationEnabledChange:O,onExpirationPresetChange:ae,onCustomDurationChange:X,onCustomDurationUnitChange:Y,onSubmit:b}){let{t:y}=useTranslation(),[V,G]=useState(false),J=useDisclosure(),[le,ve]=useState(""),_e=useRef(false);useEffect(()=>{_e.current||ve(isNaN(i)?"":String(i));},[i]);let[Ie,Ee]=useState(""),st=useRef(false);useEffect(()=>{st.current||(isNaN(s)?Ee(""):Ee(String(parseFloat((s*100).toFixed(2)))));},[s]);let Ye=useCallback(_=>{if(_!==""&&!/^\d*\.?\d{0,2}$/.test(_))return;if(Ee(_),_===""||_==="."){W(NaN);return}let Pt=parseFloat(_);isNaN(Pt)||W(Pt/100);},[W]),Ue=useCallback(_=>{if(_!==""&&!/^\d*\.?\d{0,2}$/.test(_))return;if(ve(_),Se(false),_===""||_==="."){P(NaN);return}let Pt=parseFloat(_);isNaN(Pt)||P(Pt);},[P]);useEffect(()=>{N&&!J.isOpen&&J.onOpen();},[N]);let He=useMemo(()=>{let _=n==="yes"?t.yesAsk:t.noAsk;return _!=null?parseFloat((Number(_)*100).toFixed(2)):null},[n,t]),pt=!isNaN(i)&&i>0,Qe=useMemo(()=>{if(m)return y("predict.trade.loadingBalance");if(u)return y("predict.trade.loadingMarketData");if(f)return y("predict.trade.submitting");if(N)return y("predict.trade.kycRequired");if(!pt)return y("predict.trade.enterAmount");let _=y(n==="yes"?"predict.trade.yes":"predict.trade.no"),we=l>0?` \u2192 Win $${l.toFixed(2)}`:"";return `${y("predict.trade.buy")} ${_}${we}`},[m,u,f,N,pt,n,l,y]),F=useMemo(()=>n==="yes"?"primary":"secondary",[n]),ee=()=>{P(Math.floor((p??0)/2*100)/100);},Ke=()=>{P(xe(p??0,2));},[Ht,Se]=useState(false),Oe=()=>{if(N){J.onOpen();return}if(v&&S){Se(false),S();return}if(!h){Se(true);return}Se(false),b();};return jsxs(Fragment,{children:[jsxs("div",{className:"flex w-full flex-col gap-y-4 p-4",style:r==="bordered"?{borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",transition:"border-color 0.2s"}:void 0,onMouseEnter:_=>{r==="bordered"&&(_.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:_=>{r==="bordered"&&(_.currentTarget.style.borderColor="rgba(39,39,42,0.6)");},children:[e&&jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxs("span",{className:n==="yes"?"text-bullish":"text-bearish",children:[y("predict.trade.buy")," ",y(n==="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:[w?jsxs(Tabs,{variant:"underlined",selectedKey:o,onSelectionChange:_=>A(_),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")}),o==="limit"&&w?jsx(StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:Ie,onChange:_=>Ye(_.target.value),onFocus:()=>{st.current=true;},onBlur:()=>{st.current=false,isNaN(s)?Ee(""):Ee(String(parseFloat((s*100).toFixed(2))));},endContent:jsx("span",{className:"text-xl font-bold tabular-nums text-foreground",children:"\xA2"}),classNames:{base:"w-28",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 rounded-lg px-2 h-9 min-h-9",input:"text-xl font-bold tabular-nums text-right"}}):He!=null&&jsxs("span",{className:"text-xl font-bold tabular-nums",children:[He," \xA2"]})]}),jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(_=>{let we=_==="yes"?t.yesAsk:t.noAsk;return jsx("div",{className:"flex flex-1 flex-col gap-y-1",children:jsxs("button",{type:"button",onClick:()=>D(_),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${n===_?_==="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(_==="yes"?"predict.trade.yes":"predict.trade.no")}),we!=null&&jsxs("span",{className:"ml-1 opacity-70",children:[parseFloat((Number(we)*100).toFixed(2)),"\xA2"]})]})},_)})}),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("predict.trade.youArePaying")}),jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("img",{src:Ec,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?`${xe(p,2).toFixed(2)} USDC`:"\u2013"}),jsx("button",{type:"button",onClick:ee,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:Ke,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(StyledInput,{"aria-label":"Trade amount",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:le,onChange:_=>Ue(_.target.value),onFocus:()=>{_e.current=true;},onBlur:()=>{_e.current=false,ve(isNaN(i)?"":String(i));},startContent:jsx("span",{className:"text-default-600 text-xl",children:"$"}),classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}}),Ht&&g.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:g.map(_=>jsx("span",{className:"text-xs text-danger",children:_},_))})]}),o==="limit"&&w&&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:T,onValueChange:O,"aria-label":y("predict.trade.setExpiration")})]}),T&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":y("predict.trade.setExpiration"),selectedKeys:[k],onSelectionChange:_=>{let we=Array.from(_)[0];we&&ae(we);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Tc.map(_=>jsx(SelectItem,{children:y(Lc[_])},_))}),k==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(L)?void 0:L,onValueChange:X,minValue:1,step:1,formatOptions:Ic,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:[H],onSelectionChange:_=>{let we=Array.from(_)[0];we&&Y(we);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Rc.map(_=>jsx(SelectItem,{children:y(_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:()=>G(_=>!_),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",V&&"rotate-180")})]}),He!=null&&jsx("span",{className:"text-foreground font-medium tabular-nums",children:y("predict.trade.chance",{percent:He})})]}),V&&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:y("predict.trade.totalSize")}),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:y("predict.trade.numContracts")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(a)&&a>0?Rr(a):"\u2013"})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:y("predict.trade.payout")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${c.toFixed(2)}`:"\u2013"})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:y("predict.trade.estProfit")}),jsx("span",{className:"tabular-nums text-bullish",children:!isNaN(i)&&i>0&&l>0?`+$${l.toFixed(2)}`:"\u2013"})]})]})]}),jsx(Button,{color:F,fullWidth:true,radius:"lg",size:"lg",isDisabled:m||u||!pt||f,isLoading:f||m||u,spinner:jsx(Spinner,{size:"sm",color:"current"}),onPress:Oe,children:Qe})]}),jsx(hn,{isOpen:J.isOpen,onClose:J.onClose,kycUrl:x})]})}function xn({event:e,market:t,variant:r,initialOutcome:n,chain:o,slippageBps:i,onInsufficientBalance:s}){let{outcome:a,orderType:l,quantity:c,limitPrice:d,shares:p,estimatedCost:m,potentialPayout:u,potentialProfit:f,pricePerShare:h,usdcBalance:g,isBalanceLoading:v,isMarketDataLoading:S,isSubmitting:w,validation:N,isInsufficientBalance:x,supportsLimitOrder:T,kycRequired:k,kycUrl:L,expirationEnabled:H,expirationPreset:D,customDuration:A,customDurationUnit:P,setOutcome:W,setOrderType:O,setQuantity:ae,setLimitPrice:X,setExpirationEnabled:Y,setExpirationPreset:b,setCustomDuration:y,setCustomDurationUnit:V,submit:G,notifyInsufficientBalance:J}=di({market:t,initialOutcome:n,slippageBps:i,onInsufficientBalance:s}),le=useAuthCallback(G),ve=useMemo(()=>e?an(e):void 0,[e]),_e=useMemo(()=>ln(t,{yesAsk:a==="yes"?h:void 0,noAsk:a==="no"?h:void 0}),[t,a,h]);return jsx(xi,{event:ve,market:_e,variant:r,outcome:a,orderType:l,quantity:c,limitPrice:d,shares:p,estimatedCost:m,potentialPayout:u,potentialProfit:f,usdcBalance:g,isBalanceLoading:v,isMarketDataLoading:S,isSubmitting:w,isValid:N.isValid,validationErrors:N.errors,isInsufficientBalance:x,onInsufficientBalance:s?J:void 0,supportsLimitOrder:T,kycRequired:k,kycUrl:L,expirationEnabled:H,expirationPreset:D,customDuration:A,customDurationUnit:P,onOutcomeChange:W,onOrderTypeChange:O,onQuantityChange:ae,onLimitPriceChange:X,onExpirationEnabledChange:Y,onExpirationPresetChange:b,onCustomDurationChange:y,onCustomDurationUnitChange:V,onSubmit:le})}var _r="predict-trade";function bn({id:e=_r}){return jsx(AsyncModal,{id:e,children:t=>jsx(Wc,{...t})})}function Wc({params:e,isOpen:t,onOpenChange:r}){let{t:n}=useTranslation(),{isMobile:o}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:o?"lg":"md",backdrop:"blur",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{className:o?"":"p-2",children:[jsx(xn,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,chain:e.chain,slippageBps:e.slippageBps,variant:"flat",onInsufficientBalance:e.onInsufficientBalance}),jsx("div",{className:"px-4 pb-4",children:jsx("button",{type:"button",onClick:()=>r(false),className:"w-full h-12 rounded-xl text-sm font-medium text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:n("common.cancel")})})]})})}):null}var oo={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function io(e){let t=0;return e.source&&t++,e.timeRemaining&&t++,e.minVolume&&t++,e.minLiquidity&&t++,t}function yi({isOpen:e,onClose:t,value:r,onChange:n}){let{t:o}=useTranslation(),[i,s]=useState(r),a=useCallback(g=>{g?s(r):t();},[r,t]),l=useCallback(()=>{s(oo);},[]),c=useCallback(()=>{n(i),t();},[i,n,t]),d=useCallback((g,v)=>{s(S=>({...S,[g]:v}));},[]),p=useMemo(()=>io(i),[i]),m=useMemo(()=>[{value:void 0,label:o("predict.filter.all")},{value:"polymarket",label:o("predict.platform.polymarket")},{value:"kalshi",label:o("predict.platform.kalshi")}],[o]),u=useMemo(()=>[{value:void 0,label:o("predict.filter.all")},{value:"1d",label:o("predict.filter.lessThanDay")},{value:"7d",label:o("predict.filter.lessThanWeek")},{value:"30d",label:o("predict.filter.lessThanMonth")}],[o]),f=useMemo(()=>[{value:void 0,label:o("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[o]),h=useMemo(()=>[{value:void 0,label:o("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[o]);return jsx(StyledModal,{isOpen:e,onOpenChange:a,size:"md",backdrop:"blur",scrollBehavior:"inside",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:o("predict.filter.title")}),jsx(Gc,{onClick:()=>a(false)})]}),jsxs("div",{style:{padding:"0 20px 16px",display:"flex",flexDirection:"column",gap:20},children:[jsx(kn,{label:o("predict.filter.platform"),children:jsx(Sn,{options:m,selected:i.source,onSelect:g=>d("source",g)})}),jsx(kn,{label:o("predict.filter.timeRemaining"),children:jsx(Sn,{options:u,selected:i.timeRemaining,onSelect:g=>d("timeRemaining",g)})}),jsx(kn,{label:o("predict.filter.minVolume"),children:jsx(Sn,{options:f,selected:i.minVolume,onSelect:g=>d("minVolume",g)})}),jsx(kn,{label:o("predict.filter.minLiquidity"),children:jsx(Sn,{options:h,selected:i.minLiquidity,onSelect:g=>d("minLiquidity",g)})})]}),jsxs("div",{className:"flex items-center gap-3 px-5 py-4",style:{borderTop:"1px solid rgba(39,39,42,0.5)"},children:[jsx("button",{type:"button",className:"inline-flex items-center justify-center py-2.5 px-5 rounded-[10px] text-zinc-400 text-sm font-medium hover:text-white transition-colors cursor-pointer",onClick:l,children:o("predict.filter.reset")}),jsxs("button",{type:"button",className:"flex-1 inline-flex items-center justify-center gap-2 py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer",onClick:c,children:[o("predict.filter.showResults"),p>0&&jsxs("span",{style:{opacity:.7},children:["(",p,")"]})]})]})]})})})}function kn({label:e,children:t}){return jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[jsx("span",{style:{fontSize:11,fontWeight:500,color:"#71717a",textTransform:"uppercase",letterSpacing:"0.05em"},children:e}),t]})}function Gc({onClick:e}){return jsx("button",{type:"button",onClick:e,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}function Sn({options:e,selected:t,onSelect:r,allowDeselect:n=true}){return jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:e.map(o=>{let i=t===o.value;return jsx("button",{type:"button",onClick:()=>{r(i&&n?void 0:o.value);},style:{flexShrink:0,borderRadius:10,padding:"6px 14px",fontSize:13,fontWeight:500,cursor:"pointer",transition:"all 0.15s",border:i?"1px solid rgba(199,255,46,0.3)":"1px solid rgba(63,63,70,0.5)",background:i?"rgba(199,255,46,0.08)":"rgba(39,39,42,0.4)",color:i?"#c7ff2e":"#a1a1aa"},onMouseEnter:s=>{i||(s.currentTarget.style.background="rgba(39,39,42,0.8)",s.currentTarget.style.color="#fff");},onMouseLeave:s=>{i||(s.currentTarget.style.background="rgba(39,39,42,0.4)",s.currentTarget.style.color="#a1a1aa");},children:o.label},o.value??"__all")})})}var Ni={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},Si={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},rd=["start_time","volume","liquidity","ending_soon"],wi={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"},nd={position:"absolute",left:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function Ci({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:n,onFilterPress:o,filterCount:i=0,className:s}){let{t:a}=useTranslation(),[l,c]=useState(false),d=useRef(null),p=useCallback(u=>{d.current&&!d.current.contains(u.target)&&c(false);},[]);useEffect(()=>(document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)),[p]),useEffect(()=>{if(!l)return;let u=f=>{f.key==="Escape"&&c(false);};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[l]);let m=Pi[e];return jsxs("div",{className:s,style:{display:"flex",alignItems:"center",gap:8},children:[jsxs("div",{ref:d,style:{position:"relative"},children:[jsxs("button",{type:"button",style:wi,onMouseEnter:u=>{u.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:u=>{u.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>c(u=>!u),children:[jsx(od,{}),jsx(m,{className:"size-4 shrink-0",style:{color:"#a1a1aa"}}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:a(Si[e])}),jsx(sd,{open:l})]}),l&&jsx("div",{style:{...nd,width:224,padding:4},children:rd.map(u=>{let f=Pi[u],h=e===u;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:h?"rgba(199,255,46,0.08)":"transparent",color:h?"#c7ff2e":"#a1a1aa",borderRadius:10},onMouseEnter:g=>{h||(g.currentTarget.style.background="rgba(39,39,42,0.5)",g.currentTarget.style.color="#fff");},onMouseLeave:g=>{h||(g.currentTarget.style.background="transparent",g.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===u?n(!r):t(u),c(false);},children:[jsx(f,{className:"size-4 shrink-0",style:{color:h?"#c7ff2e":"#71717a"}}),jsx("span",{style:{flex:1,fontWeight:500},children:a(Si[u])}),h&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 6 9 17l-5-5"})})]},u)})})]}),jsx("button",{type:"button",style:{borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",width:36,height:36,color:"#a1a1aa",cursor:"pointer",transition:"all 0.15s",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:14},onMouseEnter:u=>{u.currentTarget.style.background="rgba(39,39,42,1)",u.currentTarget.style.color="#fff";},onMouseLeave:u=>{u.currentTarget.style.background="rgba(39,39,42,0.6)",u.currentTarget.style.color="#a1a1aa";},onClick:()=>n(!r),children:r?"\u2191":"\u2193"}),jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxs("button",{type:"button",style:wi,onMouseEnter:u=>{u.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:u=>{u.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:o,children:[jsx(id,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:a("predict.filter.title")})]}),i>0&&jsx("span",{style:{position:"absolute",top:-4,right:-4,minWidth:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,background:"#c7ff2e",color:"#000",fontSize:10,fontWeight:600,padding:"0 4px"},children:i})]})]})}var Pi={start_time:CalendarIcon,volume:ChartLineIcon,liquidity:DropletIcon,ending_soon:TimerIcon};function od(){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 id(){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 sd({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 Ti(e={}){let t=useMemo(()=>resolveEventsParams(e),[e.tagSlugSelection,e.limit,e.status,e.sort_by,e.sort_asc,e.source,e.with_markets,e.minVolume,e.minLiquidity,e.timeRemaining,e.markets_limit]),{data:r,isLoading:n,isFetching:o,isFetchingNextPage:i,isError:s,error:a,hasNextPage:l,fetchNextPage:c,refetch:d}=useInfiniteEvents(t),p=useMemo(()=>r?.pages.flatMap(f=>f.items).filter(f=>f!=null)??[],[r]),m=useCallback(()=>{c();},[c]),u=useCallback(()=>{d();},[d]);return {data:p,isLoading:n,isFetching:o&&!i,isFetchingMore:i,isError:s,error:a??null,hasMore:l??false,fetchMore:m,refetch:u}}var Li=`
1
+ import {createContext,memo,useRef,forwardRef,useState,useImperativeHandle,useMemo,useEffect,useCallback,useContext,Fragment as Fragment$1,startTransition,Component}from'react';import {PolymarketIcon,KalshiIcon,cn,Skeleton,toast,StyledModal,ModalContent,useDisclosure,Tabs,Tab,StyledInput,StyledSwitch,Select,SelectItem,StyledNumberInput,ChevronDownIcon,Button,Spinner,useScreen,TimerIcon,DropletIcon,ChartLineIcon,CalendarIcon,Linkable,Avatar,ChevronUpIcon,OrderbookTableIcon,OrderbookDepthIcon,RefreshIcon,Dropdown,DropdownTrigger,DropdownMenu,DropdownItem,ChevronRightIcon,ChevronLeftIcon,EmptyIcon,TrashIcon,Chip,XCloseIcon,Kbd,SearchIcon,ModalHeader,ModalBody}from'@liberfi.io/ui';import {AsyncModal,useAsyncModal}from'@liberfi.io/ui-scaffold';import {useTranslation}from'@liberfi.io/i18n';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useWallets,useAuth,useAuthCallback}from'@liberfi.io/wallet-connector';import {keepPreviousData,useQueryClient,useQueries}from'@tanstack/react-query';import {useInfiniteMatchMarkets,useBalance,useDFlowKYC,usePolymarketSetup,usePredictClient,PolymarketContext,useTickSize,useFeeRate,useRealtimeOrderbook,pickBestAsk,walkOrderbook,usePositions,useDFlowQuote,useDFlowSubmit,useOrder,buildCtfExchangeDomain,buildOrderMessage,CTF_ORDER_TYPES,buildSignedOrder,buildClobPayload,buildPolymarketL2Headers,resolveEventsParams,useInfiniteEvents,useRedeemPosition,pickBestBid,useAvailableShares,getPolymarketSharesPrecision,useInfiniteOrders,useCancelOrder,useInfiniteTrades,useOrderbook,useMarketHistory,useEvent,useSimilarEvents,candlesticksQueryKey,useInfiniteComments,useSearchEvents}from'@liberfi.io/react-predict';export{PredictClient,PredictContext,PredictProvider,PredictWsClient,createPredictClient,createPredictWsClient,eventStatsQueryKey,fetchMatchMarketsPage,fetchMatchesPage,matchMarketsQueryKey,matchQueryKey,matchesQueryKey,useBalance,useCancelOrder,useCandlesticks,useDFlowKYC,useDFlowQuote,useDFlowSubmit,useEvent,useEventStats,useEvents,useInfiniteEvents,useInfiniteMatchMarkets,useInfiniteMatches,useInfiniteOrders,useInfiniteTrades,useMarket,useMarketHistory,useMarketTrades,useMatch,useOrder,useOrderbook,useOrders,usePositions,usePredictClient,usePriceHistory,useRedeemPosition,useSearchEvents,useSimilarEvents,useTrades}from'@liberfi.io/react-predict';import {ChainNamespace,Chain}from'@liberfi.io/types';import {SOLANA_TOKENS,formatAmountInUsd,formatAmount,debounce}from'@liberfi.io/utils';import lo from'canvas-confetti';import {List,useDynamicRowHeight}from'react-window';import {useInfiniteLoader}from'react-window-infinite-loader';import {useScrollCollapse,useResizeObserver,useCallbackRef}from'@liberfi.io/hooks';import {ResponsiveContainer,LineChart,CartesianGrid,XAxis,YAxis,Tooltip,Line,ReferenceDot}from'recharts';import {useAtom}from'jotai';import {atomWithStorage}from'jotai/utils';var Vl={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},si=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],io=(()=>{let e=t=>{let r=si.indexOf(t);return r===-1?si.length:r};return Object.entries(Vl).map(([t,r])=>({slug:t,label:t,tags:(r??[]).map(n=>({slug:n,label:n}))})).sort((t,r)=>e(t.slug)-e(r.slug))})();function ci({categories:e,selectedCategory:t,selectedTag:r,activeTags:n,onCategorySelect:o,onTagSelect:i,trailing:s,pulsingTab:a="Trending",className:l}){let{t:c}=useTranslation(),d=useCallback(()=>{o(null);},[o]),p=c("predict.categories.trending");return jsxs("div",{className:cn("sticky top-0 z-30 flex w-full flex-col justify-between gap-2 px-4 py-2.5 lg:px-4 lg:py-2",l),children:[jsx("style",{children:".cat-primary-row{display:flex;width:100%;flex-direction:column;gap:8px}@media(min-width:1024px){.cat-primary-row{flex-direction:row;align-items:center}}.cat-primary-row>.cat-tabs{min-width:0;overflow-x:auto;overflow-y:hidden;-ms-overflow-style:none;scrollbar-width:none}.cat-primary-row>.cat-tabs::-webkit-scrollbar{display:none}@media(min-width:1024px){.cat-primary-row>.cat-tabs{flex:1 1 0%}}"}),jsxs("div",{className:"cat-primary-row",children:[jsx("div",{className:"cat-tabs hideScrollbar",children:jsxs("div",{className:"flex min-h-9 items-stretch gap-x-3 lg:min-h-10",children:[jsx(ai,{label:p,isSelected:t===null,onPress:d,showPulse:p===a}),jsx(Yl,{}),e.map(m=>jsx(ai,{label:m.category,isSelected:t===m.category,onPress:()=>o(m.category),badge:m.badge,showPulse:m.category===a},m.category))]})}),s&&jsx("div",{className:"flex-shrink-0",children:s})]}),t&&n.length>0&&jsx("div",{className:"hideScrollbar overflow-x-auto overflow-y-hidden flex items-center",children:jsxs("div",{className:"flex gap-x-1.5 pl-1 lg:w-full lg:gap-x-2",children:[jsx(li,{label:c("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>i(null)}),n.map(m=>jsx(li,{label:m.label,icon:m.icon,isSelected:r===m.label,onPress:()=>i(m.label)},m.label))]})})]})}function ai({label:e,isSelected:t,onPress:r,badge:n,showPulse:o}){return jsxs("button",{type:"button",onClick:r,className:cn("relative shrink-0 cursor-pointer whitespace-nowrap border-b px-2.5 py-1.5 text-sm font-medium capitalize transition-colors",t?"border-primary/50 text-primary":"border-transparent text-neutral-500 hover:text-neutral-300"),children:[o?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,n&&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:n})]})}function Yl(){return jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function li({label:e,icon:t,isSelected:r,onPress:n}){return jsxs("button",{type:"button",onClick:n,className:cn("flex shrink-0 items-center justify-center gap-x-1 min-w-14 rounded-2xl border px-3 py-1.5 text-sm font-medium uppercase transition-colors cursor-pointer",r?"border-primary/40 bg-primary/15 text-primary":"border-border/80 text-neutral-500 hover:bg-primary/10 hover:text-primary"),children:[t&&jsx("span",{className:cn("iconify size-4",t)}),e]})}function Oh({count:e=6}){return jsx("div",{className:"flex w-full flex-col gap-2 px-4 py-2.5 lg:px-4 lg:py-2",children:jsx("div",{className:"flex min-h-9 items-center gap-x-3 lg:min-h-10",children:Array.from({length:e}).map((t,r)=>jsx(Skeleton,{className:"h-6 w-16 shrink-0 rounded"},r))})})}function Ql(e){return e.map(t=>({category:t.label,tags:t.tags.map(r=>r.label)}))}function Xl(e){return e?e.tags.map(t=>({label:t.label,icon:t.icon})):[]}function pi({onSelect:e,trailing:t,className:r}){let[n,o]=useState(null),[i,s]=useState(null),a=useCallback(m=>{o(m),s(null),e?.({categorySlug:m,tagSlug:null});},[e]),l=useCallback(m=>{s(m),e?.({categorySlug:n,tagSlug:m});},[n,e]),c=Ql(io),d=io.find(m=>m.slug===n),p=Xl(d);return jsx(ci,{categories:c,selectedCategory:n,selectedTag:i,activeTags:p,onCategorySelect:a,onTagSelect:l,trailing:t,className:r})}function pn(e){return {title:e.title,imageUrl:e.image_url}}function mn(e,t){let r=e.outcomes[0],n=e.outcomes[1];return {question:e.question,yesAsk:t?.yesAsk??r?.best_ask??r?.price,noAsk:t?.noAsk??n?.best_ask??n?.price,yesBid:t?.yesBid??r?.best_bid,noBid:t?.noBid??n?.best_bid,yesSubTitle:r?.label??"Yes",noSubTitle:n?.label??"No"}}var Ir=24,so=4,fn={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},se={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},gn=se.ALL,$h={[se.ONE_DAY]:fn.ONE_MINUTE,[se.ONE_WEEK]:fn.ONE_HOUR,[se.ONE_MONTH]:fn.ONE_HOUR,[se.ALL]:fn.ONE_DAY},Kh={[se.ONE_DAY]:300,[se.ONE_WEEK]:3600,[se.ONE_MONTH]:10800,[se.ALL]:1440*60},Vh={[se.ONE_DAY]:1440*60,[se.ONE_WEEK]:10080*60,[se.ONE_MONTH]:720*60*60,[se.ALL]:null},hn=1,vn=1,jh=1,Gh=1,qh=99,vr={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},Yh=vr.ONE_WEEK,Qh={[vr.ONE_HOUR]:60,[vr.SIX_HOURS]:60,[vr.ONE_DAY]:300,[vr.ONE_WEEK]:1800,[vr.MAX]:1800};var gi=createContext(null);function nr(){let e=useContext(gi);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var oc=1e4;function ic({pollingInterval:e=oc,enabled:t=true,children:r}){let n=useWallets(),o=useMemo(()=>n.find(x=>x.chainNamespace===ChainNamespace.SOLANA&&x.isConnected)?.address,[n]),i=useMemo(()=>n.find(x=>x.chainNamespace===ChainNamespace.EVM&&x.isConnected)?.address,[n]),{data:s,isLoading:a,isFetching:l,error:c}=useBalance({source:"kalshi",user:o??""},{enabled:t&&!!o,refetchInterval:e}),{data:d,isLoading:p}=useDFlowKYC(o,{enabled:t&&!!o,refetchInterval:3e4}),{data:m,isLoading:u}=usePolymarketSetup(i,{enabled:t&&!!i,refetchInterval:3e4}),f=m?.safe_address,h=m?.verified??false,{data:g,isLoading:v,isFetching:S,error:w}=useBalance({source:"polymarket",user:i??""},{enabled:t&&h&&!!i,refetchInterval:e}),P=useMemo(()=>({solanaAddress:o,evmAddress:i,polymarketSafeAddress:f,kalshiUsdcBalance:s?Number(s.balance):null,polymarketUsdcBalance:h&&g?Number(g.balance):null,kalshiKycVerified:d?.verified??false,kalshiKycUrl:d?.kyc_url??null,kalshiKycLoading:p,polymarketSetupVerified:h,polymarketSafeDeployed:m?.safe_deployed??false,polymarketTokenApproved:m?.token_approved??false,polymarketSetupLoading:u,isLoading:a||v,isFetching:l||S,error:c??w??null}),[o,i,f,s,g,h,d,p,m,u,a,v,l,S,c,w]);return jsx(gi.Provider,{value:P,children:r})}var ac={minutes:60,hours:3600,days:86400};function xn(e,t,r){let n=Math.floor(Date.now()/1e3);switch(e){case "5m":return n+300;case "1h":return n+3600;case "12h":return n+720*60;case "24h":return n+1440*60;case "eod":{let o=new Date;return o.setUTCHours(23,59,59,0),Math.floor(o.getTime()/1e3)}case "custom":return n+t*ac[r]}}function bn(e,t){let r=parseFloat(t);return !r||r<=0?e:Math.round(e/r)*r}function be(e,t){let r=Math.pow(10,t);return Math.floor(e*r)/r}function yn(e,t,r){let n=e.match(/Size\s*\(([\d.]+)\)\s*lower than the minimum:\s*([\d.]+)/i);if(n)return t("predict.trade.polymarket.minOrderSize",{current:n[1],min:n[2]});let o=e.match(/balance:\s*(\d+),\s*sum of active orders:\s*(\d+)/i);if(o){let s=parseInt(o[1],10)/1e6,a=parseInt(o[2],10)/1e6,l=Math.max(0,s-a);return t("predict.trade.polymarket.insufficientBalance",{total:be(s,2).toFixed(2),active:be(a,2).toFixed(2),available:be(l,2).toFixed(2)})}return /not enough balance/i.test(e)?t(r==="sell"?"predict.trade.insufficientShares":"predict.trade.insufficientBalance"):/max accuracy of/i.test(e)?t("predict.trade.polymarket.decimalAccuracy"):/tick size/i.test(e)?t("predict.trade.polymarket.tickSizeError"):/couldn.*fully filled|FOK.*filled or killed/i.test(e)?t("predict.trade.polymarket.fokNotFilled"):e.replace(/order\s+0x[a-f0-9]+\s+is invalid\.\s*/i,"")||e}function Or(e,t=2){return parseFloat(be(e,t).toFixed(t)).toString()}function or(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};lo({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{lo({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{lo({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function bi({market:e,initialOutcome:t="yes",slippageBps:r=100,onInsufficientBalance:n}){let{t:o}=useTranslation(),{status:i}=useAuth(),s=useWallets(),a=usePredictClient(),l=useContext(PolymarketContext),c=useQueryClient(),d=e.source,p=d==="polymarket",m=s.find(O=>O.chainNamespace===ChainNamespace.SOLANA&&O.isConnected),u=s.find(O=>O.chainNamespace===ChainNamespace.EVM&&O.isConnected&&"switchChain"in O),f=i==="authenticated",h=m?.address,g=u?.address,v=useMemo(()=>{if(d!=="polymarket")return;let O=e.provider_meta?.["polymarket.clobTokenIds"];return O?(typeof O=="string"?JSON.parse(O):O)[0]:void 0},[d,e.provider_meta]),{data:S,isLoading:w}=useTickSize(v),P=S?.minimum_tick_size?String(S.minimum_tick_size):"0.01",{data:x,isLoading:E}=useFeeRate(v),k=String(x?.base_fee??0),[T,B]=useState(t),[R,A]=useState("market"),[N,W]=useState(NaN),[D,le]=useState(NaN),[X,Y]=useState(false),[b,y]=useState(null),[$,j]=useState(false),[J,ce]=useState(false),[xe,Ie]=useState("1h"),[Oe,Te]=useState(30),[at,Qe]=useState("minutes"),$e=null,ze=false,mt=null,Xe;try{let O=nr();$e={kalshiUsdcBalance:O.kalshiUsdcBalance,polymarketUsdcBalance:O.polymarketUsdcBalance,isLoading:O.isLoading},ze=O.kalshiKycVerified,mt=O.kalshiKycUrl,Xe=O.polymarketSafeAddress;}catch{}let{data:F}=useRealtimeOrderbook({slug:e.slug,source:d},{enabled:e.status==="open"}),ee=useMemo(()=>{let O=pickBestAsk(F,T);if(O!=null&&O>0)return O;let Ae=T==="yes"?0:1,je=e.outcomes[Ae];return je?.best_ask??je?.price??.5},[F,e.outcomes,T]),Ve=useCallback(O=>{A(O);},[]),Ut=useCallback(O=>{B(O),le(NaN);},[]);useEffect(()=>{R==="limit"&&isNaN(D)&&le(Math.round(ee*100)/100);},[R,D,ee]);let we=useMemo(()=>isNaN(N)||N<=0?0:ee>0?N/ee:0,[N,ee]),De=useMemo(()=>walkOrderbook({orderbook:F,outcome:T,side:"buy",sharesNeeded:we,slippageBps:r}),[F,T,we,r]),I=useMemo(()=>De.status==="ok"&&De.worstPrice!=null&&De.worstPrice>0?De.worstPrice:ee,[De,ee]),Ne=useMemo(()=>isNaN(N)||N<=0?"0":String(Math.round(N*1e6)),[N]),Mt=e.provider_meta?.["dflow.yesMint"]??"",Yt=e.provider_meta?.["dflow.noMint"]??"",Zn=SOLANA_TOKENS.stablecoins.USDC.address,Cr=T==="yes"?Mt:Yt,Et=Zn,lt=Cr,Ke=d==="kalshi"?h??"":g??"",{data:Mr,isLoading:eo}=usePositions({source:d,user:Ke},{enabled:!!Ke}),to=d==="kalshi"&&!!Et&&!!lt&&!!h&&Ne!=="0",{refetch:Tt}=useDFlowQuote({inputMint:Et,outputMint:lt,amount:Ne,userPublicKey:h??"",slippageBps:100},{enabled:to}),Lt=useMemo(()=>$e?d==="kalshi"?$e.kalshiUsdcBalance:$e.polymarketUsdcBalance:Mr&&Mr.positions.reduce((Ae,je)=>je.side==="USDC"||je.side==="collateral"?Ae+(je.current_value??0):Ae,0)||null,[$e,Mr,d]),ro=$e?$e.isLoading:eo,tn=useMemo(()=>R==="limit"&&p&&!isNaN(D)?D:ee,[R,p,D,ee]),Er=useMemo(()=>isNaN(N)||N<=0?0:N,[N]),rn=useMemo(()=>isNaN(N)||N<=0?0:tn>0?N/tn*1:0,[N,tn]),Qt=rn-Er,Xt=useCallback(O=>{if(isNaN(O)){W(NaN);return}W(Math.round(Math.max(0,O)*100)/100);},[]),Jt=useCallback(O=>{if(isNaN(O)){le(NaN);return}let Ae=Math.max(.01,Math.min(.99,O));le(Math.round(Ae*100)/100);},[]),Rt=useCallback(()=>{W(NaN),le(NaN),A("market"),ce(false),Ie("1h"),Te(30),Qe("minutes");},[]),Tr=useMemo(()=>{let O=[];return isNaN(N)||N<=0?O.push(o("predict.trade.minAmountUsd",{amount:vn})):N<vn&&O.push(o("predict.trade.minAmountUsd",{amount:vn})),e.status!=="open"&&O.push(o("predict.trade.marketNotActive")),Lt!=null&&!isNaN(N)&&N>0&&N>be(Lt,2)&&O.push(o("predict.trade.insufficientBalance")),R==="limit"&&p&&(isNaN(D)||D<.01||D>.99)&&O.push(o("predict.trade.limitPriceRange")),R==="limit"&&p&&J&&xe==="custom"&&(isNaN(Oe)||Oe<=0)&&O.push(o("predict.trade.expiration.invalidDate")),d==="polymarket"&&R==="market"&&!isNaN(N)&&N>0&&we>0&&(De.status==="insufficient_liquidity"?O.push(o("predict.trade.insufficientLiquidity",{available:be(De.totalAvailable,2)})):De.status==="exceeds_slippage"&&O.push(o("predict.trade.priceImpactTooHigh",{impact:(De.priceImpactBps/100).toFixed(2),slippage:(r/100).toFixed(2)}))),{isValid:O.length===0,errors:O}},[N,e.status,Lt,R,p,D,J,xe,Oe,d,we,De,r,o]),nn=useMemo(()=>Lt==null||isNaN(N)||N<=0?false:N>be(Lt,2),[Lt,N]),Lr=useCallback(()=>{n?.(d);},[n,d]),{mutateAsync:Je}=useDFlowSubmit(),{data:gr}=useOrder({id:b??"",source:d},{enabled:!!b});useEffect(()=>{if(!gr||!b)return;let{status:O}=gr;O==="closed"?(y(null),Y(false),toast.success(o("predict.trade.submitSuccess")),or(),Rt(),c.invalidateQueries({queryKey:["predict","positions"]})):(O==="failed"||O==="expired")&&(Y(false),y(null),toast.error(o("predict.trade.submitError")));},[gr,b,c,Rt,o]);let on=useCallback(async()=>{if(!h||!m)return;if(!Et||!lt){toast.error("Missing token mint addresses"),Y(false);return}if(!ze){j(true),Y(false);return}let vt=(await Tt()).data?.transaction;if(!vt){toast.error(o("predict.trade.submitError")),Y(false);return}let xt=Uint8Array.from(atob(vt),er=>er.charCodeAt(0)),ct=await m.signTransaction(xt),Zt=await Je({signedTransaction:btoa(String.fromCharCode(...ct)),orderContext:{user_public_key:h,input_mint:Et,output_mint:lt,amount:Ne,price:String(ee),side:"BUY",outcome:T==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});y(Zt.signature);},[h,m,Tt,Je,Et,lt,Ne,ee,T,e.slug,o,ze]),sn=useCallback(async()=>{if(!u||!l)return;let O=u.chain,Ae=O!==Chain.POLYGON;Ae&&await u.switchChain(Chain.POLYGON);try{let je=await u.getEip1193Provider();if(!je){toast.error(o("predict.trade.submitError")),Y(!1);return}let vt=!!Xe,xt={address:u.address,signatureType:vt?2:0,signTypedData:async(It,oo,oi,cn)=>{let Kt=[];"name"in It&&Kt.push({name:"name",type:"string"}),"version"in It&&Kt.push({name:"version",type:"string"}),"chainId"in It&&Kt.push({name:"chainId",type:"uint256"}),"verifyingContract"in It&&Kt.push({name:"verifyingContract",type:"address"}),"salt"in It&&Kt.push({name:"salt",type:"bytes32"});let dn={EIP712Domain:Kt,...oo};return await je.request({method:"eth_signTypedData_v4",params:[u.address,JSON.stringify({domain:It,types:dn,primaryType:oi,message:cn})]})}},ct=l.credentials??await l.authenticate(xt),Zt=T==="yes"?0:1,er="",bt=e.provider_meta?.["polymarket.clobTokenIds"];bt&&(er=(typeof bt=="string"?JSON.parse(bt):bt)[Zt]??"");let Rr=e.provider_meta?.["polymarket.negRisk"]??!1,an=R==="limit"&&!isNaN(D)?D:I,_r=bn(an,P),C=R==="limit"?J?"GTD":"GTC":"FOK",Pe=R==="market"?N:_r>0?N/_r:0,Fe={tokenId:er,price:_r,size:Pe,side:"BUY",orderType:C,tickSize:P,negRisk:Rr,...Xe&&{funderAddress:Xe},...R==="limit"&&J&&{expiration:xn(xe,Oe,at)}},We=buildCtfExchangeDomain(Rr),dt=buildOrderMessage({...Fe,signerAddress:xt.address,signatureType:xt.signatureType,feeRateBps:k}),Ge=await xt.signTypedData(We,CTF_ORDER_TYPES,"Order",dt),_t=buildSignedOrder(dt,Ge,Fe.orderType),Le=buildClobPayload(_t,ct.apiKey),$t=JSON.stringify(Le),ln=await buildPolymarketL2Headers(ct.address,{apiKey:ct.apiKey,secret:ct.secret,passphrase:ct.passphrase,method:"POST",requestPath:"/order",body:$t});await a.createPolymarketOrder(Le,ln),c.invalidateQueries({queryKey:["predict","orders"]}),c.invalidateQueries({queryKey:["predict","positions"]}),toast.success(o("predict.trade.submitSuccess")),or(),Rt(),Y(!1);}finally{Ae&&O&&u.switchChain(O).catch(()=>{});}},[u,l,T,e.provider_meta,R,D,I,N,a,c,J,xe,Oe,at,Rt,o,P,k,Xe]),no=useCallback(async()=>{if(!(!Tr.isValid||!f)){Y(true),y(null),j(false);try{d==="kalshi"?await on():await sn();}catch(O){let Ae=O instanceof Error?O.message:"",je=d==="polymarket"&&Ae?yn(Ae,o,"buy"):Ae||void 0;toast.error(je||o("predict.trade.submitError")),Y(false);}}},[Tr.isValid,f,d,on,sn,o]);return {outcome:T,orderType:R,quantity:N,limitPrice:D,shares:we,estimatedCost:Er,potentialPayout:rn,potentialProfit:Qt,pricePerShare:ee,usdcBalance:Lt,isBalanceLoading:ro,isMarketDataLoading:d==="polymarket"&&(E||w),isSubmitting:X,validation:Tr,isInsufficientBalance:nn,source:d,supportsLimitOrder:p,kycRequired:$,kycUrl:mt,expirationEnabled:J,expirationPreset:xe,customDuration:Oe,customDurationUnit:at,setOutcome:Ut,setOrderType:Ve,setQuantity:Xt,setLimitPrice:Jt,setExpirationEnabled:ce,setExpirationPreset:Ie,setCustomDuration:Te,setCustomDurationUnit:Qe,submit:no,notifyInsufficientBalance:Lr}}function kn({isOpen:e,onClose:t,kycUrl:r}){let{t:n}=useTranslation();return jsx(StyledModal,{isOpen:e,onOpenChange:o=>{o||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:n("predict.trade.kycModalTitle")}),jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxs("div",{className:"px-5 pb-5",children:[jsx("p",{className:"text-[13px] text-zinc-400 mb-4 text-left",children:n("predict.trade.kycModalDescription")}),jsx("div",{className:"flex flex-col gap-2 mb-4",children:["predict.trade.kycModalBullet1","predict.trade.kycModalBullet2","predict.trade.kycModalBullet3"].map(o=>jsxs("div",{className:"flex items-center gap-2.5 text-[13px] text-zinc-300",children:[jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#c7ff2e] shrink-0",children:jsx("polyline",{points:"20 6 9 17 4 12"})}),jsx("span",{children:n(o)})]},o))}),r&&jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[13px] text-[#c7ff2e]/70 hover:text-[#c7ff2e] transition-colors mb-3",children:[n("predict.trade.goToKYC")," \u2192"]}),jsx("p",{className:"text-[11px] text-zinc-500 mb-5",children:n("predict.trade.kycModalNote")}),jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:n("common.ok")})]})]})})})}var Kc=`https://s1.chainstream.io/chains/sol/tokens/${SOLANA_TOKENS.stablecoins.USDC.address}/image.png`,Vc=["5m","1h","12h","24h","eod","custom"],jc={"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"},Gc=["minutes","hours","days"],qc={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},Yc={maximumFractionDigits:0};function Mi({event:e,market:t,variant:r="bordered",outcome:n,orderType:o,quantity:i,limitPrice:s,shares:a,potentialProfit:l,potentialPayout:c,estimatedCost:d,usdcBalance:p,isBalanceLoading:m,isMarketDataLoading:u,isSubmitting:f,isValid:h,validationErrors:g,isInsufficientBalance:v,onInsufficientBalance:S,supportsLimitOrder:w,kycRequired:P,kycUrl:x,expirationEnabled:E,expirationPreset:k,customDuration:T,customDurationUnit:B,onOutcomeChange:R,onOrderTypeChange:A,onQuantityChange:N,onLimitPriceChange:W,onExpirationEnabledChange:D,onExpirationPresetChange:le,onCustomDurationChange:X,onCustomDurationUnitChange:Y,onSubmit:b}){let{t:y}=useTranslation(),[$,j]=useState(false),J=useDisclosure(),[ce,xe]=useState(""),Ie=useRef(false);useEffect(()=>{Ie.current||xe(isNaN(i)?"":String(i));},[i]);let[Oe,Te]=useState(""),at=useRef(false);useEffect(()=>{at.current||(isNaN(s)?Te(""):Te(String(parseFloat((s*100).toFixed(2)))));},[s]);let Qe=useCallback(I=>{if(I!==""&&!/^\d*\.?\d{0,2}$/.test(I))return;if(Te(I),I===""||I==="."){W(NaN);return}let Mt=parseFloat(I);isNaN(Mt)||W(Mt/100);},[W]),$e=useCallback(I=>{if(I!==""&&!/^\d*\.?\d{0,2}$/.test(I))return;if(xe(I),we(false),I===""||I==="."){N(NaN);return}let Mt=parseFloat(I);isNaN(Mt)||N(Mt);},[N]);useEffect(()=>{P&&!J.isOpen&&J.onOpen();},[P]);let ze=useMemo(()=>{let I=n==="yes"?t.yesAsk:t.noAsk;return I!=null?parseFloat((Number(I)*100).toFixed(2)):null},[n,t]),mt=!isNaN(i)&&i>0,Xe=useMemo(()=>{if(m)return y("predict.trade.loadingBalance");if(u)return y("predict.trade.loadingMarketData");if(f)return y("predict.trade.submitting");if(P)return y("predict.trade.kycRequired");if(!mt)return y("predict.trade.enterAmount");let I=y(n==="yes"?"predict.trade.yes":"predict.trade.no"),Ne=l>0?` \u2192 Win $${l.toFixed(2)}`:"";return `${y("predict.trade.buy")} ${I}${Ne}`},[m,u,f,P,mt,n,l,y]),F=useMemo(()=>n==="yes"?"primary":"secondary",[n]),ee=()=>{N(Math.floor((p??0)/2*100)/100);},Ve=()=>{N(be(p??0,2));},[Ut,we]=useState(false),De=()=>{if(P){J.onOpen();return}if(v&&S){we(false),S();return}if(!h){we(true);return}we(false),b();};return jsxs(Fragment,{children:[jsxs("div",{className:"flex w-full flex-col gap-y-4 p-4",style:r==="bordered"?{borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",transition:"border-color 0.2s"}:void 0,onMouseEnter:I=>{r==="bordered"&&(I.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:I=>{r==="bordered"&&(I.currentTarget.style.borderColor="rgba(39,39,42,0.6)");},children:[e&&jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxs("span",{className:n==="yes"?"text-bullish":"text-bearish",children:[y("predict.trade.buy")," ",y(n==="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:[w?jsxs(Tabs,{variant:"underlined",selectedKey:o,onSelectionChange:I=>A(I),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")}),o==="limit"&&w?jsx(StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:Oe,onChange:I=>Qe(I.target.value),onFocus:()=>{at.current=true;},onBlur:()=>{at.current=false,isNaN(s)?Te(""):Te(String(parseFloat((s*100).toFixed(2))));},endContent:jsx("span",{className:"text-xl font-bold tabular-nums text-foreground",children:"\xA2"}),classNames:{base:"w-28",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 rounded-lg px-2 h-9 min-h-9",input:"text-xl font-bold tabular-nums text-right"}}):ze!=null&&jsxs("span",{className:"text-xl font-bold tabular-nums",children:[ze," \xA2"]})]}),jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(I=>{let Ne=I==="yes"?t.yesAsk:t.noAsk;return jsx("div",{className:"flex flex-1 flex-col gap-y-1",children:jsxs("button",{type:"button",onClick:()=>R(I),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${n===I?I==="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(I==="yes"?"predict.trade.yes":"predict.trade.no")}),Ne!=null&&jsxs("span",{className:"ml-1 opacity-70",children:[parseFloat((Number(Ne)*100).toFixed(2)),"\xA2"]})]})},I)})}),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("predict.trade.youArePaying")}),jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("img",{src:Kc,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?`${be(p,2).toFixed(2)} USDC`:"\u2013"}),jsx("button",{type:"button",onClick:ee,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:Ve,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(StyledInput,{"aria-label":"Trade amount",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:ce,onChange:I=>$e(I.target.value),onFocus:()=>{Ie.current=true;},onBlur:()=>{Ie.current=false,xe(isNaN(i)?"":String(i));},startContent:jsx("span",{className:"text-default-600 text-xl",children:"$"}),classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}}),Ut&&g.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:g.map(I=>jsx("span",{className:"text-xs text-danger",children:I},I))})]}),o==="limit"&&w&&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:E,onValueChange:D,"aria-label":y("predict.trade.setExpiration")})]}),E&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":y("predict.trade.setExpiration"),selectedKeys:[k],onSelectionChange:I=>{let Ne=Array.from(I)[0];Ne&&le(Ne);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Vc.map(I=>jsx(SelectItem,{children:y(jc[I])},I))}),k==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(T)?void 0:T,onValueChange:X,minValue:1,step:1,formatOptions:Yc,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:[B],onSelectionChange:I=>{let Ne=Array.from(I)[0];Ne&&Y(Ne);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Gc.map(I=>jsx(SelectItem,{children:y(qc[I])},I))})]})]})]}),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:()=>j(I=>!I),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("h-3.5 w-3.5 transition-transform",$&&"rotate-180")})]}),ze!=null&&jsx("span",{className:"text-foreground font-medium tabular-nums",children:y("predict.trade.chance",{percent:ze})})]}),$&&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:y("predict.trade.totalSize")}),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:y("predict.trade.numContracts")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(a)&&a>0?Or(a):"\u2013"})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:y("predict.trade.payout")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${c.toFixed(2)}`:"\u2013"})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:y("predict.trade.estProfit")}),jsx("span",{className:"tabular-nums text-bullish",children:!isNaN(i)&&i>0&&l>0?`+$${l.toFixed(2)}`:"\u2013"})]})]})]}),jsx(Button,{color:F,fullWidth:true,radius:"lg",size:"lg",isDisabled:m||u||!mt||f,isLoading:f||m||u,spinner:jsx(Spinner,{size:"sm",color:"current"}),onPress:De,children:Xe})]}),jsx(kn,{isOpen:J.isOpen,onClose:J.onClose,kycUrl:x})]})}function wn({event:e,market:t,variant:r,initialOutcome:n,chain:o,slippageBps:i,onInsufficientBalance:s}){let{outcome:a,orderType:l,quantity:c,limitPrice:d,shares:p,estimatedCost:m,potentialPayout:u,potentialProfit:f,pricePerShare:h,usdcBalance:g,isBalanceLoading:v,isMarketDataLoading:S,isSubmitting:w,validation:P,isInsufficientBalance:x,supportsLimitOrder:E,kycRequired:k,kycUrl:T,expirationEnabled:B,expirationPreset:R,customDuration:A,customDurationUnit:N,setOutcome:W,setOrderType:D,setQuantity:le,setLimitPrice:X,setExpirationEnabled:Y,setExpirationPreset:b,setCustomDuration:y,setCustomDurationUnit:$,submit:j,notifyInsufficientBalance:J}=bi({market:t,initialOutcome:n,slippageBps:i,onInsufficientBalance:s}),ce=useAuthCallback(j),xe=useMemo(()=>e?pn(e):void 0,[e]),Ie=useMemo(()=>mn(t,{yesAsk:a==="yes"?h:void 0,noAsk:a==="no"?h:void 0}),[t,a,h]);return jsx(Mi,{event:xe,market:Ie,variant:r,outcome:a,orderType:l,quantity:c,limitPrice:d,shares:p,estimatedCost:m,potentialPayout:u,potentialProfit:f,usdcBalance:g,isBalanceLoading:v,isMarketDataLoading:S,isSubmitting:w,isValid:P.isValid,validationErrors:P.errors,isInsufficientBalance:x,onInsufficientBalance:s?J:void 0,supportsLimitOrder:E,kycRequired:k,kycUrl:T,expirationEnabled:B,expirationPreset:R,customDuration:A,customDurationUnit:N,onOutcomeChange:W,onOrderTypeChange:D,onQuantityChange:le,onLimitPriceChange:X,onExpirationEnabledChange:Y,onExpirationPresetChange:b,onCustomDurationChange:y,onCustomDurationUnitChange:$,onSubmit:ce})}var Dr="predict-trade";function Nn({id:e=Dr}){return jsx(AsyncModal,{id:e,children:t=>jsx(nd,{...t})})}function nd({params:e,isOpen:t,onOpenChange:r}){let{t:n}=useTranslation(),{isMobile:o}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:o?"lg":"md",backdrop:"blur",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{className:o?"":"p-2",children:[jsx(wn,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,chain:e.chain,slippageBps:e.slippageBps,variant:"flat",onInsufficientBalance:e.onInsufficientBalance}),jsx("div",{className:"px-4 pb-4",children:jsx("button",{type:"button",onClick:()=>r(false),className:"w-full h-12 rounded-xl text-sm font-medium text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:n("common.cancel")})})]})})}):null}var po={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function mo(e){let t=0;return e.source&&t++,e.timeRemaining&&t++,e.minVolume&&t++,e.minLiquidity&&t++,t}function Ti({isOpen:e,onClose:t,value:r,onChange:n}){let{t:o}=useTranslation(),[i,s]=useState(r),a=useCallback(g=>{g?s(r):t();},[r,t]),l=useCallback(()=>{s(po);},[]),c=useCallback(()=>{n(i),t();},[i,n,t]),d=useCallback((g,v)=>{s(S=>({...S,[g]:v}));},[]),p=useMemo(()=>mo(i),[i]),m=useMemo(()=>[{value:void 0,label:o("predict.filter.all")},{value:"polymarket",label:o("predict.platform.polymarket")},{value:"kalshi",label:o("predict.platform.kalshi")}],[o]),u=useMemo(()=>[{value:void 0,label:o("predict.filter.all")},{value:"1d",label:o("predict.filter.lessThanDay")},{value:"7d",label:o("predict.filter.lessThanWeek")},{value:"30d",label:o("predict.filter.lessThanMonth")}],[o]),f=useMemo(()=>[{value:void 0,label:o("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[o]),h=useMemo(()=>[{value:void 0,label:o("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[o]);return jsx(StyledModal,{isOpen:e,onOpenChange:a,size:"md",backdrop:"blur",scrollBehavior:"inside",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:o("predict.filter.title")}),jsx(cd,{onClick:()=>a(false)})]}),jsxs("div",{style:{padding:"0 20px 16px",display:"flex",flexDirection:"column",gap:20},children:[jsx(Cn,{label:o("predict.filter.platform"),children:jsx(Mn,{options:m,selected:i.source,onSelect:g=>d("source",g)})}),jsx(Cn,{label:o("predict.filter.timeRemaining"),children:jsx(Mn,{options:u,selected:i.timeRemaining,onSelect:g=>d("timeRemaining",g)})}),jsx(Cn,{label:o("predict.filter.minVolume"),children:jsx(Mn,{options:f,selected:i.minVolume,onSelect:g=>d("minVolume",g)})}),jsx(Cn,{label:o("predict.filter.minLiquidity"),children:jsx(Mn,{options:h,selected:i.minLiquidity,onSelect:g=>d("minLiquidity",g)})})]}),jsxs("div",{className:"flex items-center gap-3 px-5 py-4",style:{borderTop:"1px solid rgba(39,39,42,0.5)"},children:[jsx("button",{type:"button",className:"inline-flex items-center justify-center py-2.5 px-5 rounded-[10px] text-zinc-400 text-sm font-medium hover:text-white transition-colors cursor-pointer",onClick:l,children:o("predict.filter.reset")}),jsxs("button",{type:"button",className:"flex-1 inline-flex items-center justify-center gap-2 py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer",onClick:c,children:[o("predict.filter.showResults"),p>0&&jsxs("span",{style:{opacity:.7},children:["(",p,")"]})]})]})]})})})}function Cn({label:e,children:t}){return jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[jsx("span",{style:{fontSize:11,fontWeight:500,color:"#71717a",textTransform:"uppercase",letterSpacing:"0.05em"},children:e}),t]})}function cd({onClick:e}){return jsx("button",{type:"button",onClick:e,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}function Mn({options:e,selected:t,onSelect:r,allowDeselect:n=true}){return jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:e.map(o=>{let i=t===o.value;return jsx("button",{type:"button",onClick:()=>{r(i&&n?void 0:o.value);},style:{flexShrink:0,borderRadius:10,padding:"6px 14px",fontSize:13,fontWeight:500,cursor:"pointer",transition:"all 0.15s",border:i?"1px solid rgba(199,255,46,0.3)":"1px solid rgba(63,63,70,0.5)",background:i?"rgba(199,255,46,0.08)":"rgba(39,39,42,0.4)",color:i?"#c7ff2e":"#a1a1aa"},onMouseEnter:s=>{i||(s.currentTarget.style.background="rgba(39,39,42,0.8)",s.currentTarget.style.color="#fff");},onMouseLeave:s=>{i||(s.currentTarget.style.background="rgba(39,39,42,0.4)",s.currentTarget.style.color="#a1a1aa");},children:o.label},o.value??"__all")})})}var Oi={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},Ri={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},xd=["start_time","volume","liquidity","ending_soon"],_i={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"},bd={position:"absolute",left:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function Di({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:n,onFilterPress:o,filterCount:i=0,className:s}){let{t:a}=useTranslation(),[l,c]=useState(false),d=useRef(null),p=useCallback(u=>{d.current&&!d.current.contains(u.target)&&c(false);},[]);useEffect(()=>(document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)),[p]),useEffect(()=>{if(!l)return;let u=f=>{f.key==="Escape"&&c(false);};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[l]);let m=Ii[e];return jsxs("div",{className:s,style:{display:"flex",alignItems:"center",gap:8},children:[jsxs("div",{ref:d,style:{position:"relative"},children:[jsxs("button",{type:"button",style:_i,onMouseEnter:u=>{u.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:u=>{u.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>c(u=>!u),children:[jsx(yd,{}),jsx(m,{className:"size-4 shrink-0",style:{color:"#a1a1aa"}}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:a(Ri[e])}),jsx(Sd,{open:l})]}),l&&jsx("div",{style:{...bd,width:224,padding:4},children:xd.map(u=>{let f=Ii[u],h=e===u;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:h?"rgba(199,255,46,0.08)":"transparent",color:h?"#c7ff2e":"#a1a1aa",borderRadius:10},onMouseEnter:g=>{h||(g.currentTarget.style.background="rgba(39,39,42,0.5)",g.currentTarget.style.color="#fff");},onMouseLeave:g=>{h||(g.currentTarget.style.background="transparent",g.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===u?n(!r):t(u),c(false);},children:[jsx(f,{className:"size-4 shrink-0",style:{color:h?"#c7ff2e":"#71717a"}}),jsx("span",{style:{flex:1,fontWeight:500},children:a(Ri[u])}),h&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 6 9 17l-5-5"})})]},u)})})]}),jsx("button",{type:"button",style:{borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",width:36,height:36,color:"#a1a1aa",cursor:"pointer",transition:"all 0.15s",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:14},onMouseEnter:u=>{u.currentTarget.style.background="rgba(39,39,42,1)",u.currentTarget.style.color="#fff";},onMouseLeave:u=>{u.currentTarget.style.background="rgba(39,39,42,0.6)",u.currentTarget.style.color="#a1a1aa";},onClick:()=>n(!r),children:r?"\u2191":"\u2193"}),jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxs("button",{type:"button",style:_i,onMouseEnter:u=>{u.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:u=>{u.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:o,children:[jsx(kd,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:a("predict.filter.title")})]}),i>0&&jsx("span",{style:{position:"absolute",top:-4,right:-4,minWidth:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,background:"#c7ff2e",color:"#000",fontSize:10,fontWeight:600,padding:"0 4px"},children:i})]})]})}var Ii={start_time:CalendarIcon,volume:ChartLineIcon,liquidity:DropletIcon,ending_soon:TimerIcon};function yd(){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 kd(){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 Sd({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 Bi(e={}){let t=useMemo(()=>resolveEventsParams(e),[e.tagSlugSelection,e.limit,e.status,e.sort_by,e.sort_asc,e.source,e.with_markets,e.minVolume,e.minLiquidity,e.timeRemaining,e.markets_limit]),{data:r,isLoading:n,isFetching:o,isFetchingNextPage:i,isError:s,error:a,hasNextPage:l,fetchNextPage:c,refetch:d}=useInfiniteEvents(t),p=useMemo(()=>r?.pages.flatMap(f=>f.items).filter(f=>f!=null)??[],[r]),m=useCallback(()=>{c();},[c]),u=useCallback(()=>{d();},[d]);return {data:p,isLoading:n,isFetching:o&&!i,isFetchingMore:i,isError:s,error:a??null,hasMore:l??false,fetchMore:m,refetch:u}}var Hi=`
2
2
  @keyframes evtShimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}
3
3
  @media(max-width:1279px){.evt-skel-grid{grid-template-columns:repeat(3,1fr)!important}}
4
4
  @media(max-width:1023px){.evt-skel-grid{grid-template-columns:repeat(2,1fr)!important}.evt-skel-card{min-height:200px!important}}
5
5
  @media(max-width:767px){.evt-skel-grid{grid-template-columns:1fr!important}}
6
- `,Ri={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:"evtShimmer 1.8s ease-in-out infinite",borderRadius:6};function wn(e){return {...Ri,animationDelay:`${e}ms`}}function so({count:e=6}){return jsxs(Fragment,{children:[jsx("style",{children:Li}),jsx("div",{className:"evt-skel-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",width:"100%"},children:Array.from({length:e}).map((t,r)=>jsx(cd,{index:r},r))})]})}function cd({index:e}){let t=e*120,r={...Ri,animationDelay:`${t}ms`},n=e%3===0?"85%":e%3===1?"70%":"60%";return jsx("div",{style:{padding:8},children:jsxs("div",{className:"evt-skel-card",style:{display:"flex",flexDirection:"column",minHeight:248,borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 14px 8px"},children:[jsx("div",{style:{...r,width:36,height:36,borderRadius:10,flexShrink:0}}),jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6},children:[jsx("div",{style:{...r,height:12,width:n}}),jsx("div",{style:{...r,height:10,width:"40%"}})]})]}),jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,padding:"4px 14px 14px",flex:1},children:[0,1,2].map(o=>jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[jsx("div",{style:{...r,height:11,width:o===0?"55%":o===1?"45%":"35%"}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsx("div",{style:{...r,height:11,width:32}}),jsx("div",{style:{...r,height:28,width:80,borderRadius:8}})]})]},o))}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.15)",padding:"8px 14px"},children:[jsx("div",{style:{...r,height:10,width:56}}),jsx("div",{style:{...r,height:10,width:72}})]})]})})}function dd(){return jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px"},children:[jsx("div",{style:{display:"flex",alignItems:"center",gap:10,minHeight:40,flex:1},children:[48,64,48,56,72,56].map((e,t)=>jsx("div",{style:{...wn(t*50),height:28,width:e,borderRadius:6}},t))}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[jsx("div",{style:{...wn(0),height:36,width:120,borderRadius:10}}),jsx("div",{style:{...wn(50),height:36,width:36,borderRadius:10}}),jsx("div",{style:{...wn(100),height:36,width:80,borderRadius:10}})]})]})}function yv({count:e=24}){return jsxs("div",{style:{minHeight:"100vh",position:"relative",width:"100%",maxWidth:1680,margin:"0 auto"},children:[jsx("style",{children:Li}),jsx("div",{style:{position:"sticky",top:0,zIndex:40,background:"rgba(10,10,11,0.8)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:jsx(dd,{})}),jsx("div",{style:{padding:"12px 8px 80px"},children:jsx(so,{count:e})})]})}var _i=3,yd={polymarket:{border:"rgba(80,162,255,0.4)",shadow:"0 2px 18px rgba(80,162,255,0.45)"},kalshi:{border:"rgba(0,212,146,0.4)",shadow:"0 2px 18px rgba(0,212,146,0.45)"}},kd={border:"hsl(var(--heroui-primary) / 0.4)",shadow:"0 2px 18px hsl(var(--heroui-primary) / 0.45)"},lo={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},Fi={bg:"hsl(var(--heroui-secondary) / 0.14)",text:"hsl(var(--heroui-secondary))",shadow:"hsl(var(--heroui-secondary) / 0.18)"},Sd={bg:"rgba(239, 68, 68, 0.14)",text:"rgb(239, 68, 68)",shadow:"rgba(239, 68, 68, 0.18)"},Or=[{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 Ii(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 wd(e){let t=e.outcomes?.map(s=>s.label?.toLowerCase().trim()??"")??[];if(t.some(s=>s==="up")&&t.some(s=>s==="down"))return [lo,Sd];if(t.some(s=>s==="yes")&&t.some(s=>s==="no"))return [lo,Fi];let r=t[0]??"",n=t[1]??"",o=Ii(r)%Or.length,i=Ii(n)%Or.length;return i===o&&(i=(i+1)%Or.length),[Or[o],Or[i]]}function Pd(e){let t=e.outcomes?.[0];return t?t.best_ask??t.price??null:null}function Bi(e){let t=Pd(e);return t!=null?parseFloat((t*100).toFixed(2)):0}function Hi(e){return e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function Oi(e){let t=e.outcomes?.[0],r=t?.best_ask??t?.price??0;return parseFloat((r*100).toFixed(2)).toString()}function Di(e){let t=e.outcomes?.[1];if(t){let o=t.best_ask??t.price??0;return parseFloat((o*100).toFixed(2)).toString()}let r=e.outcomes?.[0],n=r?.best_ask??r?.price??0;return parseFloat(((1-n)*100).toFixed(2)).toString()}function Nd(e){let t=new Date(e).getTime()-Date.now();if(t<=0)return null;let r=Math.floor(t/864e5),n=Math.floor(t%864e5/36e5),o=Math.floor(t%36e5/6e4),i=[];return r>0&&i.push(`${r}d`),n>0&&i.push(`${n}h`),i.push(`${o}m`),i.join(" ")}var Cd=`
6
+ `,zi={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:"evtShimmer 1.8s ease-in-out infinite",borderRadius:6};function En(e){return {...zi,animationDelay:`${e}ms`}}function fo({count:e=6}){return jsxs(Fragment,{children:[jsx("style",{children:Hi}),jsx("div",{className:"evt-skel-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",width:"100%"},children:Array.from({length:e}).map((t,r)=>jsx(Pd,{index:r},r))})]})}function Pd({index:e}){let t=e*120,r={...zi,animationDelay:`${t}ms`},n=e%3===0?"85%":e%3===1?"70%":"60%";return jsx("div",{style:{padding:8},children:jsxs("div",{className:"evt-skel-card",style:{display:"flex",flexDirection:"column",minHeight:248,borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 14px 8px"},children:[jsx("div",{style:{...r,width:36,height:36,borderRadius:10,flexShrink:0}}),jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6},children:[jsx("div",{style:{...r,height:12,width:n}}),jsx("div",{style:{...r,height:10,width:"40%"}})]})]}),jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,padding:"4px 14px 14px",flex:1},children:[0,1,2].map(o=>jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[jsx("div",{style:{...r,height:11,width:o===0?"55%":o===1?"45%":"35%"}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsx("div",{style:{...r,height:11,width:32}}),jsx("div",{style:{...r,height:28,width:80,borderRadius:8}})]})]},o))}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.15)",padding:"8px 14px"},children:[jsx("div",{style:{...r,height:10,width:56}}),jsx("div",{style:{...r,height:10,width:72}})]})]})})}function Cd(){return jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px"},children:[jsx("div",{style:{display:"flex",alignItems:"center",gap:10,minHeight:40,flex:1},children:[48,64,48,56,72,56].map((e,t)=>jsx("div",{style:{...En(t*50),height:28,width:e,borderRadius:6}},t))}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[jsx("div",{style:{...En(0),height:36,width:120,borderRadius:10}}),jsx("div",{style:{...En(50),height:36,width:36,borderRadius:10}}),jsx("div",{style:{...En(100),height:36,width:80,borderRadius:10}})]})]})}function ix({count:e=24}){return jsxs("div",{style:{minHeight:"100vh",position:"relative",width:"100%",maxWidth:1680,margin:"0 auto"},children:[jsx("style",{children:Hi}),jsx("div",{style:{position:"sticky",top:0,zIndex:40,background:"rgba(10,10,11,0.8)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:jsx(Cd,{})}),jsx("div",{style:{padding:"12px 8px 80px"},children:jsx(fo,{count:e})})]})}var Wi=3,Ad={polymarket:{border:"rgba(80,162,255,0.4)",shadow:"0 2px 18px rgba(80,162,255,0.45)"},kalshi:{border:"rgba(0,212,146,0.4)",shadow:"0 2px 18px rgba(0,212,146,0.45)"}},Fd={border:"hsl(var(--heroui-primary) / 0.4)",shadow:"0 2px 18px hsl(var(--heroui-primary) / 0.45)"},ho={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},ji={bg:"hsl(var(--heroui-secondary) / 0.14)",text:"hsl(var(--heroui-secondary))",shadow:"hsl(var(--heroui-secondary) / 0.18)"},Bd={bg:"rgba(239, 68, 68, 0.14)",text:"rgb(239, 68, 68)",shadow:"rgba(239, 68, 68, 0.18)"},Fr=[{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 Ui(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 Hd(e){let t=e.outcomes?.map(s=>s.label?.toLowerCase().trim()??"")??[];if(t.some(s=>s==="up")&&t.some(s=>s==="down"))return [ho,Bd];if(t.some(s=>s==="yes")&&t.some(s=>s==="no"))return [ho,ji];let r=t[0]??"",n=t[1]??"",o=Ui(r)%Fr.length,i=Ui(n)%Fr.length;return i===o&&(i=(i+1)%Fr.length),[Fr[o],Fr[i]]}function zd(e){let t=e.outcomes?.[0];return t?t.best_ask??t.price??null:null}function Gi(e){let t=zd(e);return t!=null?parseFloat((t*100).toFixed(2)):0}function qi(e){return e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function $i(e){let t=e.outcomes?.[0],r=t?.best_ask??t?.price??0;return parseFloat((r*100).toFixed(2)).toString()}function Ki(e){let t=e.outcomes?.[1];if(t){let o=t.best_ask??t.price??0;return parseFloat((o*100).toFixed(2)).toString()}let r=e.outcomes?.[0],n=r?.best_ask??r?.price??0;return parseFloat(((1-n)*100).toFixed(2)).toString()}function Wd(e){let t=new Date(e).getTime()-Date.now();if(t<=0)return null;let r=Math.floor(t/864e5),n=Math.floor(t%864e5/36e5),o=Math.floor(t%36e5/6e4),i=[];return r>0&&i.push(`${r}d`),n>0&&i.push(`${n}h`),i.push(`${o}m`),i.join(" ")}var Ud=`
7
7
  .badge-shine { position: relative; overflow: hidden; }
8
8
  .badge-shine::after {
9
9
  content: "";
@@ -27,13 +27,13 @@ import {createContext,memo,useRef,forwardRef,useState,useImperativeHandle,useMem
27
27
  outline: 2px solid hsl(var(--heroui-primary) / 0.4);
28
28
  outline-offset: 2px;
29
29
  }
30
- `;function zi({event:e,href:t,LinkComponent:r,onSelect:n,onSelectOutcome:o,onHover:i}){let[s,a]=useState(null),l=e.markets??[],d=useMemo(()=>l.length>2?[...l].sort((x,T)=>(T.outcomes?.[0]?.price??0)-(x.outcomes?.[0]?.price??0)):l,[l]).filter(x=>x.status==="open"),p=d.length===1,m=d.slice(0,_i),u=d.length-_i,f=useMemo(()=>formatAmountInUsd(e.volume??0),[e.volume]),h=s?d.find(x=>x.slug===s)??null:null,g=!!h||p,v=()=>{g||n?.(e);},S=x=>{x.stopPropagation(),h&&(x.preventDefault(),a(null));},w=x=>{x.stopPropagation(),t||(x.preventDefault(),n?.(e));},N=p?jsx(Bd,{event:e,formattedVolume:f,href:t,LinkComponent:r,onSelect:n}):h?jsx(zd,{onCollapse:()=>a(null)}):jsx(Od,{moreCount:u,formattedVolume:f,source:e.source,href:t,LinkComponent:r,onShowMore:w});return jsxs("div",{className:"group evt-card",style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",cursor:g?void 0:"pointer"},onMouseEnter:x=>{let T=x.currentTarget,k=yd[e.source]??kd;T.style.borderColor=k.border,T.style.boxShadow=k.shadow,i?.(e);},onMouseLeave:x=>{let T=x.currentTarget;T.style.borderColor="rgba(39,39,42,0.6)",T.style.boxShadow="none";},onClick:v,children:[jsx("style",{children:Cd}),jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,padding:"14px 14px 12px",gap:8},children:[jsx(Md,{event:e,href:t,LinkComponent:r,onClick:S,isExpanded:g}),jsx("div",{style:{display:"flex",flexDirection:"column",flex:1},children:p?jsx(Fd,{market:d[0],event:e,onSelectOutcome:o}):h?jsx(Hd,{market:h,event:e,onCollapse:()=>a(null),onSelectOutcome:o}):jsx(Id,{displayedMarkets:m,onMarketClick:x=>a(x.slug)})})]}),jsx(Dd,{children:N})]})}function Md({event:e,href:t,LinkComponent:r,onClick:n,isExpanded:o}){let i=e.start_at?Nd(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:n,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",o&&"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(Td,{event:e})]})}function Ed(e){let t=[];if(e.status==="closed")return t.push({kind:"closed"}),t.slice(0,2);let r=e.tags?.some(o=>o.label?.toLowerCase()==="crypto"),n=e.tags?.some(o=>o.label?.toLowerCase()==="live");if(r&&e.end_at){let o=new Date(e.end_at).getTime()-Date.now(),i=300*1e3,s=900*1e3;if(o>0&&o<=s){let a=o<=i?"#ef4444":"#f59e0b";t.push({kind:"crypto-short",label:o<=i?"5m":"15m",color:a});}}return n&&t.push({kind:"live"}),t.slice(0,2)}function Td({event:e}){let t=useMemo(()=>Ed(e),[e]);return t.length===0?null:jsx("div",{className:"flex flex-shrink-0 flex-col items-end gap-1",children:t.map((r,n)=>{switch(r.kind){case "live":return jsx(Ld,{},n);case "crypto-short":return jsx(Rd,{label:r.label,color:r.color},n);case "closed":return jsx(_d,{},n)}})})}function Ld(){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 Rd({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 _d(){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 Id({displayedMarkets:e,onMarketClick:t}){return e.length>0?jsx("div",{className:"flex w-full flex-1 flex-col gap-y-0.5 lg:gap-y-2",children:e.map(r=>{let n=Bi(r);return jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between gap-x-2 transition-opacity hover:cursor-pointer hover:opacity-80",onClick:o=>{o.stopPropagation(),t(r);},children:[jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 line-clamp-1 lg:text-sm",children:r.outcomes?.[0]?.label??r.question}),jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:Hi(n)}),jsx(Ad,{})]})]},r.id??`${r.source}-${r.slug}`)})}):null}function Od({moreCount:e,formattedVolume:t,source:r,href:n,LinkComponent:o,onShowMore:i}){let{t:s}=useTranslation();return jsxs(Fragment,{children:[e>0?jsxs(Linkable,{href:n,LinkComponent:o,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-zinc-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:i,children:[s("predict.event.showMore"),jsx(Ui,{className:"h-3 w-3"})]}):jsx("div",{}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[t," ",s("predict.event.volume"),jsx($i,{source:r})]})]})}function Dd({children:e}){return jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.15)",padding:"8px 14px",marginTop:"auto"},children:e})}function Ai({bgColor:e,textColor:t,shadowColor:r,onClick:n,children:o}){return jsx("button",{type:"button",className:"flex h-12 flex-1 w-full items-center justify-center gap-x-1 overflow-hidden rounded-lg p-3 text-base font-normal hover:cursor-pointer will-change-transform [-webkit-tap-highlight-color:transparent]",style:{backgroundColor:e,color:t,"--shadow-color":r,"--shadow-offset":"4px",boxShadow:"inset 0 -1px 0 rgba(255,255,255,0.08), 0 var(--shadow-offset, 4px) 0 var(--shadow-color, rgba(0,0,0,0.22))",transition:"transform .12s, box-shadow .12s, opacity .14s"},onMouseEnter:a=>{let l=a.currentTarget;l.style.setProperty("--shadow-offset","2px"),l.style.transform="translateY(2px)";},onMouseLeave:a=>{let l=a.currentTarget;l.style.setProperty("--shadow-offset","4px"),l.style.transform="translateY(0px)";},onClick:n,children:o})}function Wi({market:e,event:t,onSelectOutcome:r,dynamicColors:n=false,labelFormat:o="action"}){let{t:i}=useTranslation(),[s,a]=n?wd(e):[lo,Fi],l=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",c=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",d=o==="label"&&l===c?"action":o,p=d==="label"?`${e.outcomes?.[0]?.label??"Yes"} ${Oi(e)}\xA2`:i("predict.market.action.yes",{price:Oi(e)}),m=d==="label"?`${e.outcomes?.[1]?.label??"No"} ${Di(e)}\xA2`:i("predict.market.action.no",{price:Di(e)});return jsxs("div",{className:"flex gap-2",children:[jsx(Ai,{bgColor:s.bg,textColor:s.text,shadowColor:s.shadow,onClick:u=>{u.stopPropagation(),r?.(t,e,"yes");},children:p}),jsx(Ai,{bgColor:a.bg,textColor:a.text,shadowColor:a.shadow,onClick:u=>{u.stopPropagation(),r?.(t,e,"no");},children:m})]})}function Ad(){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 Fd({market:e,event:t,onSelectOutcome:r}){return jsx("div",{style:{flex:1},children:jsx(Wi,{market:e,event:t,onSelectOutcome:r,dynamicColors:true,labelFormat:"label"})})}function Bd({event:e,formattedVolume:t,href:r,LinkComponent:n,onSelect:o}){let{t:i}=useTranslation();return jsxs(Fragment,{children:[jsxs(Linkable,{href:r,LinkComponent:n,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-zinc-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:a=>{a.stopPropagation(),r||(a.preventDefault(),o?.(e));},children:[i("predict.event.viewEvent"),jsx(Ui,{className:"h-3 w-3"})]}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[t," ",i("predict.event.volume"),jsx($i,{source:e.source})]})]})}function Hd({market:e,event:t,onCollapse:r,onSelectOutcome:n}){let o=Bi(e);return jsxs("div",{style:{flex:1},children:[jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between cursor-pointer",onClick:i=>{i.stopPropagation(),r();},children:[jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 lg:text-sm",children:e.outcomes?.[0]?.label??e.question}),jsxs("div",{className:"flex items-center gap-x-1 flex-shrink-0",children:[jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:Hi(o)}),jsx(ChevronUpIcon,{className:"h-4 w-4 text-neutral-400"})]})]}),jsx("div",{style:{marginTop:12},children:jsx(Wi,{market:e,event:t,onSelectOutcome:n,labelFormat:"action"})})]})}function zd({onCollapse:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsxs("button",{type:"button",className:"flex items-center gap-x-1 text-[10px] font-normal transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",style:{color:"#71717a"},onClick:r=>{r.stopPropagation(),e();},children:[jsx(Wd,{className:"h-3 w-3"}),t("predict.event.back")]}),jsx("div",{})]})}function Ui({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 Wd({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 $i({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 Vd=8;function Vi({events:e,hasMore:t=false,isFetchingMore:r=false,onFetchMore:n,onSelect:o,onSelectOutcome:i,getEventHref:s,LinkComponent:a,onHover:l}){let{t:c}=useTranslation(),d=useRef(null);useEffect(()=>{let u=d.current;if(!u)return;let f=new IntersectionObserver(h=>{h[0]?.isIntersecting&&t&&!r&&n?.();},{rootMargin:"300px"});return f.observe(u),()=>f.disconnect()},[t,r,n]);let p=useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]),m=!t&&e.length>0;return jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[jsx("style",{children:`
30
+ `;function Yi({event:e,href:t,LinkComponent:r,onSelect:n,onSelectOutcome:o,onHover:i}){let[s,a]=useState(null),l=e.markets??[],d=useMemo(()=>l.length>2?[...l].sort((x,E)=>(E.outcomes?.[0]?.price??0)-(x.outcomes?.[0]?.price??0)):l,[l]).filter(x=>x.status==="open"),p=d.length===1,m=d.slice(0,Wi),u=d.length-Wi,f=useMemo(()=>formatAmountInUsd(e.volume??0),[e.volume]),h=s?d.find(x=>x.slug===s)??null:null,g=!!h||p,v=()=>{g||n?.(e);},S=x=>{x.stopPropagation(),h&&(x.preventDefault(),a(null));},w=x=>{x.stopPropagation(),t||(x.preventDefault(),n?.(e));},P=p?jsx(eu,{event:e,formattedVolume:f,href:t,LinkComponent:r,onSelect:n}):h?jsx(ru,{onCollapse:()=>a(null)}):jsx(Qd,{moreCount:u,formattedVolume:f,source:e.source,href:t,LinkComponent:r,onShowMore:w});return jsxs("div",{className:"group evt-card",style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",cursor:g?void 0:"pointer"},onMouseEnter:x=>{let E=x.currentTarget,k=Ad[e.source]??Fd;E.style.borderColor=k.border,E.style.boxShadow=k.shadow,i?.(e);},onMouseLeave:x=>{let E=x.currentTarget;E.style.borderColor="rgba(39,39,42,0.6)",E.style.boxShadow="none";},onClick:v,children:[jsx("style",{children:Ud}),jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,padding:"14px 14px 12px",gap:8},children:[jsx($d,{event:e,href:t,LinkComponent:r,onClick:S,isExpanded:g}),jsx("div",{style:{display:"flex",flexDirection:"column",flex:1},children:p?jsx(Zd,{market:d[0],event:e,onSelectOutcome:o}):h?jsx(tu,{market:h,event:e,onCollapse:()=>a(null),onSelectOutcome:o}):jsx(Yd,{displayedMarkets:m,onMarketClick:x=>a(x.slug)})})]}),jsx(Xd,{children:P})]})}function $d({event:e,href:t,LinkComponent:r,onClick:n,isExpanded:o}){let i=e.start_at?Wd(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:n,children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",className:"h-8 w-8 flex-shrink-0 transition-transform duration-300 group-hover/header:scale-110 lg:h-12 lg:w-12",classNames:{base:"bg-transparent"}}),jsxs("div",{className:"flex min-w-0 flex-1 flex-col justify-center gap-y-0.5",children:[jsx("p",{className:cn("min-w-0 text-sm font-semibold leading-snug text-slate-200 line-clamp-2 lg:text-base",o&&"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(Vd,{event:e})]})}function Kd(e){let t=[];if(e.status==="closed")return t.push({kind:"closed"}),t.slice(0,2);let r=e.tags?.some(o=>o.label?.toLowerCase()==="crypto"),n=e.tags?.some(o=>o.label?.toLowerCase()==="live");if(r&&e.end_at){let o=new Date(e.end_at).getTime()-Date.now(),i=300*1e3,s=900*1e3;if(o>0&&o<=s){let a=o<=i?"#ef4444":"#f59e0b";t.push({kind:"crypto-short",label:o<=i?"5m":"15m",color:a});}}return n&&t.push({kind:"live"}),t.slice(0,2)}function Vd({event:e}){let t=useMemo(()=>Kd(e),[e]);return t.length===0?null:jsx("div",{className:"flex flex-shrink-0 flex-col items-end gap-1",children:t.map((r,n)=>{switch(r.kind){case "live":return jsx(jd,{},n);case "crypto-short":return jsx(Gd,{label:r.label,color:r.color},n);case "closed":return jsx(qd,{},n)}})})}function jd(){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 Gd({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 qd(){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 Yd({displayedMarkets:e,onMarketClick:t}){return e.length>0?jsx("div",{className:"flex w-full flex-1 flex-col gap-y-0.5 lg:gap-y-2",children:e.map(r=>{let n=Gi(r);return jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between gap-x-2 transition-opacity hover:cursor-pointer hover:opacity-80",onClick:o=>{o.stopPropagation(),t(r);},children:[jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 line-clamp-1 lg:text-sm",children:r.outcomes?.[0]?.label??r.question}),jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:qi(n)}),jsx(Jd,{})]})]},r.id??`${r.source}-${r.slug}`)})}):null}function Qd({moreCount:e,formattedVolume:t,source:r,href:n,LinkComponent:o,onShowMore:i}){let{t:s}=useTranslation();return jsxs(Fragment,{children:[e>0?jsxs(Linkable,{href:n,LinkComponent:o,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-zinc-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:i,children:[s("predict.event.showMore"),jsx(Xi,{className:"h-3 w-3"})]}):jsx("div",{}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[t," ",s("predict.event.volume"),jsx(Ji,{source:r})]})]})}function Xd({children:e}){return jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.15)",padding:"8px 14px",marginTop:"auto"},children:e})}function Vi({bgColor:e,textColor:t,shadowColor:r,onClick:n,children:o}){return jsx("button",{type:"button",className:"flex h-12 flex-1 w-full items-center justify-center gap-x-1 overflow-hidden rounded-lg p-3 text-base font-normal hover:cursor-pointer will-change-transform [-webkit-tap-highlight-color:transparent]",style:{backgroundColor:e,color:t,"--shadow-color":r,"--shadow-offset":"4px",boxShadow:"inset 0 -1px 0 rgba(255,255,255,0.08), 0 var(--shadow-offset, 4px) 0 var(--shadow-color, rgba(0,0,0,0.22))",transition:"transform .12s, box-shadow .12s, opacity .14s"},onMouseEnter:a=>{let l=a.currentTarget;l.style.setProperty("--shadow-offset","2px"),l.style.transform="translateY(2px)";},onMouseLeave:a=>{let l=a.currentTarget;l.style.setProperty("--shadow-offset","4px"),l.style.transform="translateY(0px)";},onClick:n,children:o})}function Qi({market:e,event:t,onSelectOutcome:r,dynamicColors:n=false,labelFormat:o="action"}){let{t:i}=useTranslation(),[s,a]=n?Hd(e):[ho,ji],l=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",c=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",d=o==="label"&&l===c?"action":o,p=d==="label"?`${e.outcomes?.[0]?.label??"Yes"} ${$i(e)}\xA2`:i("predict.market.action.yes",{price:$i(e)}),m=d==="label"?`${e.outcomes?.[1]?.label??"No"} ${Ki(e)}\xA2`:i("predict.market.action.no",{price:Ki(e)});return jsxs("div",{className:"flex gap-2",children:[jsx(Vi,{bgColor:s.bg,textColor:s.text,shadowColor:s.shadow,onClick:u=>{u.stopPropagation(),r?.(t,e,"yes");},children:p}),jsx(Vi,{bgColor:a.bg,textColor:a.text,shadowColor:a.shadow,onClick:u=>{u.stopPropagation(),r?.(t,e,"no");},children:m})]})}function Jd(){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 Zd({market:e,event:t,onSelectOutcome:r}){return jsx("div",{style:{flex:1},children:jsx(Qi,{market:e,event:t,onSelectOutcome:r,dynamicColors:true,labelFormat:"label"})})}function eu({event:e,formattedVolume:t,href:r,LinkComponent:n,onSelect:o}){let{t:i}=useTranslation();return jsxs(Fragment,{children:[jsxs(Linkable,{href:r,LinkComponent:n,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-zinc-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:a=>{a.stopPropagation(),r||(a.preventDefault(),o?.(e));},children:[i("predict.event.viewEvent"),jsx(Xi,{className:"h-3 w-3"})]}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[t," ",i("predict.event.volume"),jsx(Ji,{source:e.source})]})]})}function tu({market:e,event:t,onCollapse:r,onSelectOutcome:n}){let o=Gi(e);return jsxs("div",{style:{flex:1},children:[jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between cursor-pointer",onClick:i=>{i.stopPropagation(),r();},children:[jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 lg:text-sm",children:e.outcomes?.[0]?.label??e.question}),jsxs("div",{className:"flex items-center gap-x-1 flex-shrink-0",children:[jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:qi(o)}),jsx(ChevronUpIcon,{className:"h-4 w-4 text-neutral-400"})]})]}),jsx("div",{style:{marginTop:12},children:jsx(Qi,{market:e,event:t,onSelectOutcome:n,labelFormat:"action"})})]})}function ru({onCollapse:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsxs("button",{type:"button",className:"flex items-center gap-x-1 text-[10px] font-normal transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",style:{color:"#71717a"},onClick:r=>{r.stopPropagation(),e();},children:[jsx(nu,{className:"h-3 w-3"}),t("predict.event.back")]}),jsx("div",{})]})}function Xi({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 nu({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 Ji({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 au=8;function es({events:e,hasMore:t=false,isFetchingMore:r=false,onFetchMore:n,onSelect:o,onSelectOutcome:i,getEventHref:s,LinkComponent:a,onHover:l}){let{t:c}=useTranslation(),d=useRef(null);useEffect(()=>{let u=d.current;if(!u)return;let f=new IntersectionObserver(h=>{h[0]?.isIntersecting&&t&&!r&&n?.();},{rootMargin:"300px"});return f.observe(u),()=>f.disconnect()},[t,r,n]);let p=useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]),m=!t&&e.length>0;return jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[jsx("style",{children:`
31
31
  @keyframes eventCardEnter{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}
32
32
  @keyframes evt-load-spin{to{transform:rotate(360deg)}}
33
33
  @media(max-width:767px){.evt-card-grid{grid-template-columns:1fr!important}}
34
34
  @media(min-width:768px) and (max-width:1023px){.evt-card-grid{grid-template-columns:repeat(2,1fr)!important}}
35
35
  @media(min-width:1024px) and (max-width:1279px){.evt-card-grid{grid-template-columns:repeat(3,1fr)!important}}
36
- `}),jsx("div",{className:"evt-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)"},children:e.map((u,f)=>u==null?null:jsx("div",{style:{padding:Vd,animation:`eventCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${f%4*35}ms both`},children:jsx(zi,{event:u,href:s?.(u),LinkComponent:a,onSelect:o,onSelectOutcome:i,onHover:l})},`${u.source}-${u.slug}`))}),jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",alignItems:"center",gap:8,padding:"16px 0",minHeight:1},children:r&&jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#71717a",fontSize:13},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:"evt-load-spin 1s linear infinite"},children:jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),c("predict.events.loadMore")]})}),m&&jsx(jd,{onScrollToTop:p})]})}function jd({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 Gi({tagSlugSelection:e,limit:t=24,status:r,sort_by:n,sort_asc:o,source:i,with_markets:s,timeRemaining:a,minVolume:l,minLiquidity:c,markets_limit:d,onSelect:p,onSelectOutcome:m,getEventHref:u,LinkComponent:f,onHover:h}){let{data:g,hasMore:v,fetchMore:S,isFetching:w,isFetchingMore:N}=Ti({tagSlugSelection:e,limit:t,status:r,sort_by:n,sort_asc:o,source:i,with_markets:s,timeRemaining:a,minVolume:l,minLiquidity:c,markets_limit:d});return w?jsx(so,{count:24}):jsx(Vi,{events:g,hasMore:v,isFetchingMore:N,onFetchMore:S,onSelect:p,onSelectOutcome:m,getEventHref:u,LinkComponent:f,onHover:h})}function qv({onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:n,onHover:o,bgImageSrc:i,onInsufficientBalance:s}){let[a,l]=useState({categorySlug:null,tagSlug:null}),[c,d]=useState(oo),{isOpen:p,onOpen:m,onClose:u}=useDisclosure(),{onOpen:f}=useAsyncModal(_r),h=useCallback((k,L,H)=>{t?.(k,L,H),f({params:{event:k,market:L,initialOutcome:H,onInsufficientBalance:s}});},[t,f,s]),g=useCallback(k=>{l(k);},[]),v=useCallback(k=>{d(L=>({...L,sortPreset:k}));},[]),S=useCallback(k=>{d(L=>({...L,sortAsc:k}));},[]),w=useCallback(k=>{d(k);},[]),N=useMemo(()=>Ni[c.sortPreset].sort_by,[c.sortPreset]),x=useMemo(()=>io(c),[c]),T=useMemo(()=>jsx(Ci,{sortPreset:c.sortPreset,onSortChange:v,sortAsc:c.sortAsc,onSortAscChange:S,onFilterPress:m,filterCount:x}),[c.sortPreset,c.sortAsc,x,v,S,m]);return jsxs("div",{style:{minHeight:"100vh",position:"relative",width:"100%",maxWidth:1680,margin:"0 auto"},children:[jsx("div",{style:{position:"sticky",top:0,zIndex:40,background:"rgba(10,10,11,0.8)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:jsx(ni,{onSelect:g,trailing:T})}),jsxs("div",{style:{padding:"12px 8px 80px"},children:[jsx(yi,{isOpen:p,onClose:u,value:c,onChange:w}),jsx(Gi,{tagSlugSelection:a,sort_by:N,sort_asc:c.sortAsc,source:c.source,timeRemaining:c.timeRemaining,minVolume:c.minVolume,minLiquidity:c.minLiquidity,onSelect:e,onSelectOutcome:h,getEventHref:r,LinkComponent:n,onHover:o})]}),jsx(bn,{})]})}function Xi(e){return formatAmountInUsd(e)}var Xd=[{key:"total_events",labelKey:"predict.events.stats.totalEvents",format:e=>formatAmount(e),valueColor:"#c7ff2e",gradientFrom:"rgba(199,255,46,0.18)",gradientTo:"rgba(199,255,46,0.04)"},{key:"total_volume_24h",labelKey:"predict.events.stats.volume24h",format:Xi,valueColor:"#f76816",gradientFrom:"rgba(247,104,22,0.18)",gradientTo:"rgba(247,104,22,0.04)"},{key:"avg_liquidity",labelKey:"predict.events.stats.avgLiquidity",format:Xi,valueColor:"#17c964",gradientFrom:"rgba(23,201,100,0.18)",gradientTo:"rgba(23,201,100,0.04)"},{key:"active_sources",labelKey:"predict.events.stats.activeSources",format:e=>formatAmount(e),valueColor:"#f5a524",gradientFrom:"rgba(245,165,36,0.18)",gradientTo:"rgba(245,165,36,0.04)"}];function Zv({stats:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsx("style",{children:`
36
+ `}),jsx("div",{className:"evt-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)"},children:e.map((u,f)=>u==null?null:jsx("div",{style:{padding:au,animation:`eventCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${f%4*35}ms both`},children:jsx(Yi,{event:u,href:s?.(u),LinkComponent:a,onSelect:o,onSelectOutcome:i,onHover:l})},`${u.source}-${u.slug}`))}),jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",alignItems:"center",gap:8,padding:"16px 0",minHeight:1},children:r&&jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#71717a",fontSize:13},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:"evt-load-spin 1s linear infinite"},children:jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),c("predict.events.loadMore")]})}),m&&jsx(lu,{onScrollToTop:p})]})}function lu({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 rs({tagSlugSelection:e,limit:t=24,status:r,sort_by:n,sort_asc:o,source:i,with_markets:s,timeRemaining:a,minVolume:l,minLiquidity:c,markets_limit:d,onSelect:p,onSelectOutcome:m,getEventHref:u,LinkComponent:f,onHover:h}){let{data:g,hasMore:v,fetchMore:S,isFetching:w,isFetchingMore:P}=Bi({tagSlugSelection:e,limit:t,status:r,sort_by:n,sort_asc:o,source:i,with_markets:s,timeRemaining:a,minVolume:l,minLiquidity:c,markets_limit:d});return w?jsx(fo,{count:24}):jsx(es,{events:g,hasMore:v,isFetchingMore:P,onFetchMore:S,onSelect:p,onSelectOutcome:m,getEventHref:u,LinkComponent:f,onHover:h})}function Ix({onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:n,onHover:o,bgImageSrc:i,onInsufficientBalance:s}){let[a,l]=useState({categorySlug:null,tagSlug:null}),[c,d]=useState(po),{isOpen:p,onOpen:m,onClose:u}=useDisclosure(),{onOpen:f}=useAsyncModal(Dr),h=useCallback((k,T,B)=>{t?.(k,T,B),f({params:{event:k,market:T,initialOutcome:B,onInsufficientBalance:s}});},[t,f,s]),g=useCallback(k=>{l(k);},[]),v=useCallback(k=>{d(T=>({...T,sortPreset:k}));},[]),S=useCallback(k=>{d(T=>({...T,sortAsc:k}));},[]),w=useCallback(k=>{d(k);},[]),P=useMemo(()=>Oi[c.sortPreset].sort_by,[c.sortPreset]),x=useMemo(()=>mo(c),[c]),E=useMemo(()=>jsx(Di,{sortPreset:c.sortPreset,onSortChange:v,sortAsc:c.sortAsc,onSortAscChange:S,onFilterPress:m,filterCount:x}),[c.sortPreset,c.sortAsc,x,v,S,m]);return jsxs("div",{style:{minHeight:"100vh",position:"relative",width:"100%",maxWidth:1680,margin:"0 auto"},children:[jsx("div",{style:{position:"sticky",top:0,zIndex:40,background:"rgba(10,10,11,0.8)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:jsx(pi,{onSelect:g,trailing:E})}),jsxs("div",{style:{padding:"12px 8px 80px"},children:[jsx(Ti,{isOpen:p,onClose:u,value:c,onChange:w}),jsx(rs,{tagSlugSelection:a,sort_by:P,sort_asc:c.sortAsc,source:c.source,timeRemaining:c.timeRemaining,minVolume:c.minVolume,minLiquidity:c.minLiquidity,onSelect:e,onSelectOutcome:h,getEventHref:r,LinkComponent:n,onHover:o})]}),jsx(Nn,{})]})}function ss(e){return formatAmountInUsd(e)}var mu=[{key:"total_events",labelKey:"predict.events.stats.totalEvents",format:e=>formatAmount(e),valueColor:"#c7ff2e",gradientFrom:"rgba(199,255,46,0.18)",gradientTo:"rgba(199,255,46,0.04)"},{key:"total_volume_24h",labelKey:"predict.events.stats.volume24h",format:ss,valueColor:"#f76816",gradientFrom:"rgba(247,104,22,0.18)",gradientTo:"rgba(247,104,22,0.04)"},{key:"avg_liquidity",labelKey:"predict.events.stats.avgLiquidity",format:ss,valueColor:"#17c964",gradientFrom:"rgba(23,201,100,0.18)",gradientTo:"rgba(23,201,100,0.04)"},{key:"active_sources",labelKey:"predict.events.stats.activeSources",format:e=>formatAmount(e),valueColor:"#f5a524",gradientFrom:"rgba(245,165,36,0.18)",gradientTo:"rgba(245,165,36,0.04)"}];function Bx({stats:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsx("style",{children:`
37
37
  @keyframes evt-live-ping{75%,100%{transform:scale(2.2);opacity:0}}
38
38
  @keyframes evt-live-breathe{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.55;transform:scale(.85)}}
39
39
  @keyframes evtHeroTitleEnter{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}
@@ -71,15 +71,15 @@ import {createContext,memo,useRef,forwardRef,useState,useImperativeHandle,useMem
71
71
  .evt-stat-label{font-size:11px;line-height:16px;min-height:16px;white-space:nowrap}
72
72
  @media(min-width:640px){.evt-stat-label{font-size:12px;line-height:18px;min-height:18px}}
73
73
  `}),jsxs("div",{className:"evt-hero-outer",children:[jsxs("div",{className:"evt-hero-left",style:{minWidth:0,flex:1,animation:"evtHeroTitleEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both"},children:[jsx("div",{className:"evt-hero-live",style:{marginBottom:16},children:jsxs("div",{className:"inline-flex items-center",style:{gap:8,borderRadius:9999,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"6px 12px",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)"},children:[jsxs("span",{style:{position:"relative",display:"flex",width:8,height:8},children:[jsx("span",{style:{position:"absolute",display:"inline-flex",width:"100%",height:"100%",borderRadius:9999,background:"#00d492",opacity:.75,animation:"evt-live-ping 1.2s cubic-bezier(0,0,0.2,1) infinite"}}),jsx("span",{style:{position:"relative",display:"inline-flex",width:8,height:8,borderRadius:9999,background:"#00bc7d",animation:"evt-live-breathe 2.4s ease-in-out infinite"}})]}),jsx("span",{style:{fontSize:12,fontWeight:500,color:"#d4d4d8",letterSpacing:"0.025em"},children:t("predict.events.liveBadge")})]})}),jsxs("h1",{className:"evt-hero-title",style:{fontFamily:"var(--font-dm-sans, 'DM Sans', sans-serif)",fontWeight:700,letterSpacing:"-1.2px",lineHeight:1.2,color:"#fff",margin:"0 0 14px"},children:[jsxs("span",{style:{color:"#fff"},children:[t("predict.events.titlePrefix")," "]}),jsx("span",{style:{backgroundImage:"linear-gradient(to right, #c7ff2e, #a0e515, #17c964)",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",backgroundClip:"text"},children:t("predict.events.titleHighlight")})]}),jsx("p",{className:"evt-hero-subtitle evt-hero-subtitle-text",style:{lineHeight:1.6,color:"#71717a",maxWidth:460},children:String(t("predict.events.heroSubtitle")).split(`
74
- `).map((r,n)=>jsxs("span",{children:[n>0&&jsx("br",{className:"hidden sm:block"}),r,n===0?" ":""]},n))})]}),jsx("div",{className:"evt-stat-grid",style:e?{animation:"evtStatsEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:"0.1s"}:{},children:Xd.map((r,n)=>jsxs("div",{style:{padding:"14px 16px",background:e?`linear-gradient(to bottom, ${r.gradientFrom}, ${r.gradientTo})`:"rgba(255,255,255,0.02)",borderRight:n%2===0?"1px solid rgba(39,39,42,0.4)":"none",borderBottom:n<2?"1px solid rgba(39,39,42,0.4)":"none",...e?{animation:"evtStatCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:`${150+n*60}ms`}:{}},children:[jsx("div",{className:"evt-stat-val",style:{fontWeight:700,fontVariantNumeric:"tabular-nums",color:e?r.valueColor:"transparent",display:"flex",alignItems:"center"},children:e?r.format(e[r.key]):jsx("div",{style:{height:16,width:56,borderRadius:4,background:"rgba(255,255,255,0.06)",animation:"evtStatCardEnter 0.6s ease-out both",animationDelay:`${n*80}ms`}})}),jsx("div",{className:"evt-stat-label",style:{fontWeight:500,color:e?"#71717a":"transparent",marginTop:2,display:"flex",alignItems:"center"},children:e?t(r.labelKey):jsx("div",{style:{height:10,width:64,borderRadius:4,background:"rgba(255,255,255,0.04)",animation:"evtStatCardEnter 0.6s ease-out both",animationDelay:`${50+n*80}ms`}})})]},r.key))})]})]})}function rs({event:e,market:t,position:r,onSuccess:n,onCancel:o}){let{t:i}=useTranslation(),{mutateAsync:s}=useRedeemPosition(),{evmAddress:a}=er(),l=useWallets(),[c,d]=useState("idle"),[p,m]=useState(null),u=t.provider_meta?.["polymarket.conditionId"],f=t.provider_meta?.["polymarket.negRisk"]??false,h=a??"",g=useMemo(()=>l.find(P=>P.chainNamespace===ChainNamespace.EVM&&P.isConnected),[l]),v=ts(r.side,t.outcomes),w=t.outcomes?.[v]?.label??r.side,N=t.result!=null?ts(t.result,t.outcomes):-1,T=(N>=0?t.outcomes?.[N]:void 0)?.label??t.result??"",k=t.result!=null?v===N:true,L=useMemo(()=>k?r.size:0,[k,r.size]),H=useCallback(async()=>{if(!(!u||!h||!g)){d("pending"),m(null);try{let P=await g.getEip1193Provider();if(!P)throw new Error("EIP-1193 provider unavailable");await s({wallet_address:h,condition_id:u,neg_risk:f,signMessage:async W=>await P.request({method:"personal_sign",params:[W,h]})}),d("success"),n?.();}catch(P){d("error"),m(P instanceof Error?P.message:i("predict.redeem.error"));}}},[u,h,f,g,s,n,i]),D=useAuthCallback(H),A=c==="idle"&&!!u&&!!h&&!!g&&r.redeemable;return jsxs("div",{className:"flex flex-col gap-4 p-4",children:[jsx("div",{className:"text-base font-medium text-white",children:e?.title??t.question}),jsxs("div",{className:"flex flex-col gap-2 rounded-xl bg-[rgba(39,39,42,0.4)] p-3",children:[jsx(Pn,{label:i("predict.positions.side"),value:w,valueClassName:k?"text-green-400":"text-red-400"}),t.result!=null&&jsx(Pn,{label:i("predict.redeem.result"),value:T,valueClassName:"text-green-400"}),jsx(Pn,{label:i("predict.positions.size"),value:r.size.toFixed(2)}),jsx(Pn,{label:i("predict.redeem.expectedPayout"),value:`$${L.toFixed(2)}`,valueClassName:L>0?"text-green-400":"text-zinc-400"})]}),!k&&L===0&&jsx("p",{className:"text-sm text-zinc-500",children:i("predict.redeem.noWinnings")}),c==="error"&&p&&jsx("p",{className:"text-sm text-red-400",children:p}),c==="success"&&jsx("p",{className:"text-sm text-green-400",children:i("predict.redeem.success")}),jsxs("div",{className:"flex flex-col gap-2",children:[c!=="success"&&jsx(Button,{color:"success",className:"w-full h-12 rounded-xl text-sm font-semibold",isDisabled:!A,isLoading:c==="pending",onPress:D,spinner:jsx(Spinner,{size:"sm",color:"current"}),children:i("predict.redeem.confirm")}),o&&c!=="success"&&jsx("button",{type:"button",onClick:o,className:"w-full h-12 rounded-xl text-sm font-medium text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:i("common.cancel")}),c==="success"&&o&&jsx(Button,{className:"w-full h-12 rounded-xl text-sm font-medium",onPress:o,children:i("common.ok")})]})]})}function Pn({label:e,value:t,valueClassName:r="text-white"}){return jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm text-zinc-400",children:e}),jsx("span",{className:`text-sm font-medium ${r}`,children:t})]})}function ts(e,t){let r=e.toLowerCase();if(r==="yes")return 0;if(r==="no"||!t)return 1;let n=t.findIndex(o=>o.label.toLowerCase()===r);return n>=0?n:1}var uu="predict-redeem";function os({id:e=uu}){return jsx(AsyncModal,{id:e,children:t=>jsx(pu,{...t})})}function pu({params:e,isOpen:t,onOpenChange:r}){let{t:n}=useTranslation(),{isMobile:o}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:o?"lg":"md",backdrop:"blur",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{className:o?"":"p-2",children:[jsxs("div",{className:"px-4 pt-4 pb-1",children:[jsx("h3",{className:"text-lg font-semibold text-white",children:n("predict.redeem.title")}),jsx("p",{className:"text-sm text-zinc-400 mt-1",children:n("predict.redeem.description")})]}),jsx(rs,{event:e.event,market:e.market,position:e.position,onSuccess:()=>{setTimeout(()=>r(false),1500);},onCancel:()=>r(false)})]})})}):null}function cs({market:e,initialOutcome:t="yes",slippageBps:r=100}){let{t:n}=useTranslation(),{status:o}=useAuth(),i=useWallets(),s=usePredictClient(),a=useContext(PolymarketContext),l=useQueryClient(),c=e.source,d=c==="polymarket",p=i.find(C=>C.chainNamespace===ChainNamespace.SOLANA&&C.isConnected),m=i.find(C=>C.chainNamespace===ChainNamespace.EVM&&C.isConnected&&"switchChain"in C),u=o==="authenticated",f=p?.address,h=m?.address,g=useMemo(()=>{if(c!=="polymarket")return;let C=e.provider_meta?.["polymarket.clobTokenIds"];return C?(typeof C=="string"?JSON.parse(C):C)[0]:void 0},[c,e.provider_meta]),{data:v,isLoading:S}=useTickSize(g),w=v?.minimum_tick_size?String(v.minimum_tick_size):"0.01",{data:N,isLoading:x}=useFeeRate(g),T=String(N?.base_fee??0),[k,L]=useState(t),[H,D]=useState("market"),[A,P]=useState(NaN),[W,O]=useState(NaN),[ae,X]=useState(false),[Y,b]=useState(false),[y,V]=useState(null),[G,J]=useState(null),[le,ve]=useState(false),[_e,Ie]=useState(false),[Ee,st]=useState("1h"),[Ye,Ue]=useState(30),[He,pt]=useState("minutes"),Qe=false,F=null,ee;try{let C=er();Qe=C.kalshiKycVerified,F=C.kalshiKycUrl,ee=C.polymarketSafeAddress;}catch{}let Ke=useCallback(async()=>{if(!m||!a)return null;let C=await m.getEip1193Provider();if(!C)return null;let Pe=!!ee,Ae={address:m.address,signatureType:Pe?2:0,signTypedData:async(ze,ct,je,Tt)=>{let Te=[];"name"in ze&&Te.push({name:"name",type:"string"}),"version"in ze&&Te.push({name:"version",type:"string"}),"chainId"in ze&&Te.push({name:"chainId",type:"uint256"}),"verifyingContract"in ze&&Te.push({name:"verifyingContract",type:"address"}),"salt"in ze&&Te.push({name:"salt",type:"bytes32"});let zt={EIP712Domain:Te,...ct};return await C.request({method:"eth_signTypedData_v4",params:[m.address,JSON.stringify({domain:ze,types:zt,primaryType:je,message:Tt})]})}};return a.credentials??await a.authenticate(Ae)},[ee,m,a]),{data:Ht}=useRealtimeOrderbook({slug:e.slug,source:c},{enabled:e.status==="open"}),Se=useMemo(()=>{let C=pickBestBid(Ht,k);if(C!=null&&C>0)return C;let Pe=k==="yes"?0:1,Ae=e.outcomes[Pe];return Ae?.best_bid??Ae?.price??.5},[Ht,e.outcomes,k]),Oe=c==="kalshi"?f??"":h??"",{data:_,isLoading:we}=usePositions({source:c,user:Oe},{enabled:!!Oe,refetchInterval:3e4}),Pt=useCallback(async()=>{let C=await Ke();return C?await buildPolymarketL2Headers(C.address,{apiKey:C.apiKey,secret:C.secret,passphrase:C.passphrase,method:"GET",requestPath:"/data/orders",body:""}):{}},[Ke]),{data:jt,isLoading:jn}=useAvailableShares({source:c,user:Oe,market:e.slug,side:k},c==="polymarket"?{getHeaders:Pt}:void 0,{enabled:!!Oe&&!!e.slug,refetchOnMount:"always"}),wr=jt?.total_shares??0,Nt=jt?.active_order_shares??0,at=jt?.available_shares??0,$e=useMemo(()=>c==="polymarket"?getPolymarketSharesPrecision(w):jt?.precision??0,[c,w,jt?.precision]),Pr=jn||we,Gn=e.provider_meta?.["dflow.yesMint"]??"",qn=e.provider_meta?.["dflow.noMint"]??"",Ct=SOLANA_TOKENS.stablecoins.USDC.address,Mt=e.provider_meta?.["dflow.collateralMint"]||"",Yn=k==="yes"?Gn:qn,Nr=useMemo(()=>_?_.positions.find(C=>C.side?.toLowerCase()===k&&C.market?.slug===e.slug)??null:null,[_,e.slug,k])?.market?.provider_meta,Xr=Nr?.["dflow.outcomeMint"]||Yn,Gt=Nr?.["dflow.collateralMint"]||Mt,qt=Xr,Yt=Gt||Ct,Et=useMemo(()=>isNaN(A)||A<=0?"0":String(Math.round(A*1e6)),[A]),Cr=c==="kalshi"&&!!qt&&!!Yt&&!!f&&Et!=="0",{refetch:Jr}=useDFlowQuote({inputMint:qt,outputMint:Yt,amount:Et,userPublicKey:f??"",slippageBps:100},{enabled:Cr}),Mr=useMemo(()=>isNaN(A)||A<=0?0:A,[A]),Xe=useMemo(()=>walkOrderbook({orderbook:Ht,outcome:k,side:"sell",sharesNeeded:Mr,slippageBps:r}),[Ht,k,Mr,r]),pr=useMemo(()=>Xe.status==="ok"&&Xe.worstPrice!=null&&Xe.worstPrice>0?Xe.worstPrice:Se,[Xe,Se]),Zr=useMemo(()=>{if(isNaN(A)||A<=0)return 0;let C=H==="limit"&&d&&!isNaN(W)?W:Se;return A*C},[A,H,d,W,Se]),en=useCallback(C=>{L(C),O(NaN),P(NaN),b(false);},[]),Qn=useCallback(C=>{D(C);},[]);useEffect(()=>{H==="limit"&&O(Math.round(Se*100)/100);},[H,k]);let I=useCallback(C=>{if(b(false),isNaN(C)){P(NaN);return}P(xe(Math.max(0,C),$e));},[$e]),De=useCallback(()=>{b(true),P(xe(at,$e));},[at,$e]),Ve=useCallback(C=>{if(isNaN(C)){O(NaN);return}let Pe=Math.max(.01,Math.min(.99,C));O(Math.round(Pe*100)/100);},[]),ht=useCallback(()=>{P(NaN),O(NaN),D("market"),b(false),Ie(false),st("1h"),Ue(30),pt("minutes");},[]),vt=useMemo(()=>{let C=[];return isNaN(A)||A<=0?C.push(n("predict.trade.minQuantity",{amount:un})):A<un&&C.push(n("predict.trade.minQuantity",{amount:un})),e.status!=="open"&&C.push(n("predict.trade.marketNotActive")),!isNaN(A)&&A>0&&!Y&&A>at&&C.push(n("predict.trade.insufficientSharesDetail",{total:xe(wr,$e).toFixed($e),active:xe(Nt,$e).toFixed($e),available:xe(at,$e).toFixed($e)})),H==="limit"&&d&&(isNaN(W)||W<.01||W>.99)&&C.push(n("predict.trade.limitPriceRange")),H==="limit"&&d&&_e&&Ee==="custom"&&(isNaN(Ye)||Ye<=0)&&C.push(n("predict.trade.expiration.invalidDate")),c==="polymarket"&&H==="market"&&!isNaN(A)&&A>0&&(Xe.status==="insufficient_liquidity"?C.push(n("predict.trade.insufficientLiquidity",{available:xe(Xe.totalAvailable,2)})):Xe.status==="exceeds_slippage"&&C.push(n("predict.trade.priceImpactTooHigh",{impact:(Xe.priceImpactBps/100).toFixed(2),slippage:(r/100).toFixed(2)}))),{isValid:C.length===0,errors:C}},[A,e.status,at,wr,Nt,Y,H,d,W,_e,Ee,Ye,$e,c,Xe,r,n]),{mutateAsync:lt}=useDFlowSubmit(),{data:Qt}=useOrder({id:y??"",source:c},{enabled:!!y}),Xt=useCallback(async()=>{if(!G||!f||!p)return;let{cashAmount:C,collateral:Pe}=G;J(null);try{let ze=(await s.createDFlowQuote({inputMint:Pe,outputMint:Ct,amount:C,userPublicKey:f,slippageBps:100}))?.transaction;if(!ze)return;let ct=Uint8Array.from(atob(ze),Tt=>Tt.charCodeAt(0)),je=await p.signTransaction(ct);await lt({signedTransaction:btoa(String.fromCharCode(...je)),orderContext:{user_public_key:f,input_mint:Pe,output_mint:Ct,amount:C,price:"1",side:"SELL",outcome:"",market_slug:"",slippage_bps:100}});}catch{}},[G,f,p,s,lt,Ct]),xt=useCallback(()=>{l.invalidateQueries({queryKey:["predict","positions"]}),l.invalidateQueries({queryKey:["predict","orders"]}),l.invalidateQueries({queryKey:["predict","available-shares"]});},[l]);useEffect(()=>{if(!Qt||!y)return;let{status:C}=Qt;C==="closed"?(V(null),G?Xt().finally(()=>{X(false),toast.success(n("predict.trade.submitSuccess")),tr(),xt(),ht();}):(X(false),toast.success(n("predict.trade.submitSuccess")),tr(),xt(),ht())):(C==="failed"||C==="expired")&&(X(false),V(null),J(null),toast.error(n("predict.trade.submitError")));},[Qt,y,G,Xt,xt,ht,n]);let Er=useCallback(async()=>{if(!f||!p)return;if(!qt||!Yt){toast.error("Missing token mint addresses"),X(false);return}if(!Qe){ve(true),X(false);return}let Ae=(await Jr()).data,ze=Ae?.transaction;if(!ze){toast.error(n("predict.trade.submitError")),X(false);return}if(Gt&&Gt!==Ct){let Te=String(Ae?.outAmount??"");Te&&Te!=="0"&&J({cashAmount:Te,collateral:Gt});}let ct=Uint8Array.from(atob(ze),Te=>Te.charCodeAt(0)),je=await p.signTransaction(ct),Tt=await lt({signedTransaction:btoa(String.fromCharCode(...je)),orderContext:{user_public_key:f,input_mint:qt,output_mint:Yt,amount:Et,price:String(Se),side:"SELL",outcome:k==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});V(Tt.signature);},[f,p,Jr,lt,qt,Yt,Et,Se,k,e.slug,Gt,Ct,n,Qe]),tn=useCallback(async()=>{if(!m||!a)return;let C=m.chain,Pe=C!==Chain.POLYGON;Pe&&await m.switchChain(Chain.POLYGON);try{let Ae=await m.getEip1193Provider();if(!Ae){toast.error(n("predict.trade.submitError")),X(!1);return}let ze=!!ee,ct={address:m.address,signatureType:ze?2:0,signTypedData:async(Jt,Nl,Cl,Ml)=>{let mr=[];"name"in Jt&&mr.push({name:"name",type:"string"}),"version"in Jt&&mr.push({name:"version",type:"string"}),"chainId"in Jt&&mr.push({name:"chainId",type:"uint256"}),"verifyingContract"in Jt&&mr.push({name:"verifyingContract",type:"address"}),"salt"in Jt&&mr.push({name:"salt",type:"bytes32"});let El={EIP712Domain:mr,...Nl};return await Ae.request({method:"eth_signTypedData_v4",params:[m.address,JSON.stringify({domain:Jt,types:El,primaryType:Cl,message:Ml})]})}},je=await Ke();if(!je){toast.error(n("predict.trade.submitError")),X(!1);return}let Tt=k==="yes"?0:1,Te="",zt=e.provider_meta?.["polymarket.clobTokenIds"];zt&&(Te=(typeof zt=="string"?JSON.parse(zt):zt)[Tt]??"");let rn=e.provider_meta?.["polymarket.negRisk"]??!1,Lt=H==="limit"&&!isNaN(W)?W:pr,Xn=fn(Lt,w),nn={tokenId:Te,price:Xn,size:A,side:"SELL",orderType:H==="limit"?_e?"GTD":"GTC":"FOK",tickSize:w,negRisk:rn,...ee&&{funderAddress:ee},...H==="limit"&&_e&&{expiration:mn(Ee,Ye,He)}},Wt=buildCtfExchangeDomain(rn),on=buildOrderMessage({...nn,signerAddress:ct.address,signatureType:ct.signatureType,feeRateBps:T}),kl=await ct.signTypedData(Wt,CTF_ORDER_TYPES,"Order",on),Sl=buildSignedOrder(on,kl,nn.orderType),Qo=buildClobPayload(Sl,je.apiKey),wl=JSON.stringify(Qo),Pl=await buildPolymarketL2Headers(je.address,{apiKey:je.apiKey,secret:je.secret,passphrase:je.passphrase,method:"POST",requestPath:"/order",body:wl});await s.createPolymarketOrder(Qo,Pl),xt(),toast.success(n("predict.trade.submitSuccess")),tr(),ht(),X(!1);}finally{Pe&&C&&m.switchChain(C).catch(()=>{});}},[m,a,Ke,k,e.provider_meta,H,W,pr,A,s,xt,_e,Ee,Ye,He,ht,n,w,T,e.slug]),Tr=useCallback(async()=>{if(!(!vt.isValid||!u)){X(true),V(null),ve(false);try{c==="kalshi"?await Er():await tn();}catch(C){let Pe=C instanceof Error?C.message:"",Ae=c==="polymarket"&&Pe?gn(Pe,n,"sell"):Pe||void 0;toast.error(Ae||n("predict.trade.submitError")),X(false);}}},[vt.isValid,u,c,Er,tn,n]);return {outcome:k,orderType:H,quantity:A,limitPrice:W,shares:Mr,estimatedReturn:Zr,pricePerShare:Se,isMarketDataLoading:c==="polymarket"&&(x||S),isSubmitting:ae,validation:vt,supportsLimitOrder:d,kycRequired:le,kycUrl:F,totalShares:wr,activeOrderShares:Nt,availableShares:at,isAvailableLoading:Pr,isSellAll:Y,precision:$e,expirationEnabled:_e,expirationPreset:Ee,customDuration:Ye,customDurationUnit:He,setOutcome:en,setOrderType:Qn,setQuantity:I,setLimitPrice:Ve,setSellAll:De,setExpirationEnabled:Ie,setExpirationPreset:st,setCustomDuration:Ue,setCustomDurationUnit:pt,submit:Tr}}var Ku=["5m","1h","12h","24h","eod","custom"],Vu={"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"},ju=["minutes","hours","days"],Gu={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},qu={maximumFractionDigits:0};function xs({event:e,market:t,variant:r="bordered",outcome:n,orderType:o,quantity:i,limitPrice:s,estimatedReturn:a,isMarketDataLoading:l,isSubmitting:c,isValid:d,validationErrors:p,supportsLimitOrder:m,kycRequired:u,kycUrl:f,totalShares:h,activeOrderShares:g,availableShares:v,isAvailableLoading:S,precision:w,expirationEnabled:N,expirationPreset:x,customDuration:T,customDurationUnit:k,onOutcomeChange:L,onOrderTypeChange:H,onQuantityChange:D,onLimitPriceChange:A,onSellAll:P,onExpirationEnabledChange:W,onExpirationPresetChange:O,onCustomDurationChange:ae,onCustomDurationUnitChange:X,onSubmit:Y}){let{t:b}=useTranslation(),[y,V]=useState(false),G=useDisclosure(),[J,le]=useState(""),ve=useRef(false);useEffect(()=>{ve.current||le(isNaN(i)?"":String(i));},[i]);let[_e,Ie]=useState(""),Ee=useRef(false);useEffect(()=>{Ee.current||(isNaN(s)?Ie(""):Ie(String(parseFloat((s*100).toFixed(2)))));},[s]);let st=useCallback(F=>{if(F!==""&&!/^\d*\.?\d{0,2}$/.test(F))return;if(Ie(F),F===""||F==="."){A(NaN);return}let Ke=parseFloat(F);isNaN(Ke)||A(Ke/100);},[A]),Ye=useCallback(F=>{let ee=new RegExp(`^\\d*\\.?\\d{0,${w}}$`);if(F!==""&&!ee.test(F))return;if(le(F),V(false),F===""||F==="."){D(NaN);return}let Ke=parseFloat(F);isNaN(Ke)||D(Ke);},[D,w]);useEffect(()=>{u&&!G.isOpen&&G.onOpen();},[u]);let Ue=useMemo(()=>{let F=n==="yes"?t.yesBid:t.noBid;return F!=null?parseFloat((Number(F)*100).toFixed(2)):null},[n,t]),He=!isNaN(i)&&i>0,pt=useMemo(()=>{if(S)return b("predict.trade.loadingBalance");if(l)return b("predict.trade.loadingMarketData");if(c)return b("predict.trade.submitting");if(u)return b("predict.trade.kycRequired");if(!He)return b("predict.trade.enterAmount");let F=b(n==="yes"?"predict.trade.yes":"predict.trade.no");return `${b("predict.trade.sell")} ${F}`},[S,l,c,u,He,n,b]),Qe=()=>{if(u){G.onOpen();return}if(!d){V(true);return}V(false),Y();};return jsxs(Fragment,{children:[jsxs("div",{className:"flex w-full flex-col gap-y-4 p-4",style:r==="bordered"?{borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",transition:"border-color 0.2s"}:void 0,onMouseEnter:F=>{r==="bordered"&&(F.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:F=>{r==="bordered"&&(F.currentTarget.style.borderColor="rgba(39,39,42,0.6)");},children:[e&&jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxs("span",{className:"text-bearish",children:[b("predict.trade.sell")," ",b(n==="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:[m?jsxs(Tabs,{variant:"underlined",selectedKey:o,onSelectionChange:F=>H(F),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsx(Tab,{title:b("predict.trade.market")},"market"),jsx(Tab,{title:b("predict.trade.limit")},"limit")]}):jsx("span",{className:"text-sm font-medium text-foreground",children:b("predict.trade.market")}),o==="limit"&&m?jsx(StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:_e,onChange:F=>st(F.target.value),onFocus:()=>{Ee.current=true;},onBlur:()=>{Ee.current=false,isNaN(s)?Ie(""):Ie(String(parseFloat((s*100).toFixed(2))));},endContent:jsx("span",{className:"text-xl font-bold tabular-nums text-foreground",children:"\xA2"}),classNames:{base:"w-28",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 rounded-lg px-2 h-9 min-h-9",input:"text-xl font-bold tabular-nums text-right"}}):Ue!=null&&jsxs("span",{className:"text-xl font-bold tabular-nums",children:[Ue," \xA2"]})]}),jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsx("span",{className:"text-sm font-medium text-foreground",children:b("predict.trade.sellContracts")}),jsxs("div",{className:"flex items-center gap-x-2",children:[[25,50].map(F=>{let ee=Math.pow(10,w);return jsxs("button",{type:"button",onClick:()=>{D(Math.floor(v*F/100*ee)/ee);},className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:[F,"%"]},F)}),jsx("button",{type:"button",onClick:P,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:b("common.all")})]})]}),jsx(StyledInput,{"aria-label":"Sell quantity",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:J,onChange:F=>Ye(F.target.value),onFocus:()=>{ve.current=true;},onBlur:()=>{ve.current=false,le(isNaN(i)?"":String(i));},classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}}),y&&p.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:p.map(F=>jsx("span",{className:"text-xs text-danger",children:F},F))})]}),jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-neutral-500",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:b("predict.trade.totalShares")}),jsx("span",{className:"tabular-nums text-foreground",children:S?"\u2013":`${xe(h,w).toFixed(w)}${b("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:b("predict.trade.activeOrders")}),jsx("span",{className:"tabular-nums text-warning",children:S?"\u2013":g>0?`-${xe(g,w).toFixed(w)}${b("predict.trade.sharesUnit")}`:`0${b("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:b("predict.trade.availableShares")}),jsx("span",{className:"tabular-nums text-success font-medium",children:S?"\u2013":`${xe(v,w).toFixed(w)}${b("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:b("predict.trade.estReturn")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${a.toFixed(2)}`:"\u2013"})]})]}),o==="limit"&&m&&jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-medium text-primary",children:b("predict.trade.setExpiration")}),jsx(StyledSwitch,{size:"sm",color:"primary",isSelected:N,onValueChange:W,"aria-label":b("predict.trade.setExpiration")})]}),N&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":b("predict.trade.setExpiration"),selectedKeys:[x],onSelectionChange:F=>{let ee=Array.from(F)[0];ee&&O(ee);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Ku.map(F=>jsx(SelectItem,{children:b(Vu[F])},F))}),x==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(T)?void 0:T,onValueChange:ae,minValue:1,step:1,formatOptions:qu,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:F=>{let ee=Array.from(F)[0];ee&&X(ee);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:ju.map(F=>jsx(SelectItem,{children:b(Gu[F])},F))})]})]})]}),jsx(Button,{color:"secondary",fullWidth:true,radius:"lg",size:"lg",isDisabled:S||l||!He||c,isLoading:c||S||l,spinner:jsx(Spinner,{size:"sm",color:"current"}),onPress:Qe,children:pt})]}),jsx(hn,{isOpen:G.isOpen,onClose:G.onClose,kycUrl:f})]})}function Cn({event:e,market:t,variant:r,initialOutcome:n,chain:o,slippageBps:i}){let{outcome:s,orderType:a,quantity:l,limitPrice:c,estimatedReturn:d,pricePerShare:p,isMarketDataLoading:m,isSubmitting:u,validation:f,supportsLimitOrder:h,kycRequired:g,kycUrl:v,totalShares:S,activeOrderShares:w,availableShares:N,isAvailableLoading:x,precision:T,expirationEnabled:k,expirationPreset:L,customDuration:H,customDurationUnit:D,setOutcome:A,setOrderType:P,setQuantity:W,setLimitPrice:O,setSellAll:ae,setExpirationEnabled:X,setExpirationPreset:Y,setCustomDuration:b,setCustomDurationUnit:y,submit:V}=cs({market:t,initialOutcome:n,slippageBps:i}),G=useAuthCallback(V),J=useMemo(()=>e?an(e):void 0,[e]),le=useMemo(()=>ln(t,{yesBid:s==="yes"?p:void 0,noBid:s==="no"?p:void 0}),[t,s,p]);return jsx(xs,{event:J,market:le,variant:r,outcome:s,orderType:a,quantity:l,limitPrice:c,estimatedReturn:d,isMarketDataLoading:m,isSubmitting:u,isValid:f.isValid,validationErrors:f.errors,supportsLimitOrder:h,kycRequired:g,kycUrl:v,totalShares:S,activeOrderShares:w,availableShares:N,isAvailableLoading:x,precision:T,expirationEnabled:k,expirationPreset:L,customDuration:H,customDurationUnit:D,onOutcomeChange:A,onOrderTypeChange:P,onQuantityChange:W,onLimitPriceChange:O,onSellAll:ae,onExpirationEnabledChange:X,onExpirationPresetChange:Y,onCustomDurationChange:b,onCustomDurationUnitChange:y,onSubmit:G})}var go="predict-sell";function ys({id:e=go}){return jsx(AsyncModal,{id:e,children:t=>jsx(rp,{...t})})}function rp({params:e,isOpen:t,onOpenChange:r}){let{t:n}=useTranslation(),{isMobile:o}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:o?"lg":"md",backdrop:"blur",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{className:o?"":"p-2",children:[jsx(Cn,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,chain:e.chain,slippageBps:e.slippageBps,variant:"flat"}),jsx("div",{className:"px-4 pb-4",children:jsx("button",{type:"button",onClick:()=>r(false),className:"w-full h-12 rounded-xl text-sm font-medium text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:n("common.cancel")})})]})})}):null}var xo=40,Tn=36,Hr=480,bo=Hr-Tn;function ws({event:e,walletAddress:t,onCancelOrder:r}){let{t:n}=useTranslation(),[o,i]=useState("positions"),s=useMemo(()=>e.markets?.map(p=>p.slug)??[],[e.markets]),{data:a}=usePositions({source:e.source,user:t??""}),l=useMemo(()=>!a?.positions||!t?0:s.length===0?a.positions.length:a.positions.filter(p=>p.market&&s.includes(p.market.slug)).length,[a?.positions,s,t]),d=[{key:"positions",label:l>0?`${n("predict.positions.title")} (${l})`:n("predict.positions.title")},{key:"orders",label:n("predict.openOrders.title")},{key:"trades",label:n("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",o===p.key?"text-foreground border-b-2 border-primary":"text-neutral hover:text-foreground"),children:p.label},p.key))}),t?jsxs("div",{style:{height:Hr},children:[o==="positions"&&jsx(cp,{source:e.source,walletAddress:t,marketSlugs:s}),o==="orders"&&jsx(up,{source:e.source,walletAddress:t,marketSlugs:s,onCancelOrder:r}),o==="trades"&&jsx(fp,{source:e.source,walletAddress:t})]}):jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:Hr},children:n("predict.trade.connectWallet")})]})}function cp({source:e,walletAddress:t,marketSlugs:r}){let{t:n}=useTranslation(),{data:o,isLoading:i}=usePositions({source:e,user:t}),s=useMemo(()=>o?.positions?r.length===0?o.positions:o.positions.filter(a=>a.market&&r.includes(a.market.slug)):[],[o?.positions,r]);return i?jsx(ko,{}):s.length===0?jsx(yo,{message:n("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:Tn},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2 whitespace-nowrap",children:n("predict.positions.event")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.totalSize")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.value")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.avgPrice")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.markPrice")}),jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:n("predict.positions.pnl")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.payoutIfRight")}),jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:n("predict.positions.estSettlement")}),jsx("div",{className:"w-16 shrink-0"})]}),jsx(List,{style:{height:bo},rowComponent:dp,rowCount:s.length,rowHeight:xo,rowProps:{positions:s,closeLabel:n("predict.positions.close")}})]})}function dp({index:e,style:t,positions:r,closeLabel:n}){let o=r[e];if(!o)return null;let i=o.pnl??0,s=o.pnl_percent??0,a=o.avg_price??0,l=o.current_price??0,c=i>0?"text-success":i<0?"text-danger":"text-foreground",d=i>0?"+":"",p=o.market?.outcomes?.[0]?.label??o.market?.question??"\u2014",m=o.side,u=o.size,f=o.size*l,h=o.market?.end_at?vp(o.market.end_at):"\u2014";return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-xs lg:text-sm",children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxs("div",{className:"flex flex-col gap-y-0.5",children:[jsx("span",{className:"text-foreground truncate font-medium",children:p}),jsx("span",{className:cn$1("text-[10px] font-medium",m.toLowerCase()==="yes"?"text-primary":"text-secondary"),children:m})]})}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:o.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:Mn(a)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:Mn(l)}),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:["$",u.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:h}),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:n})})]})}function up({source:e,walletAddress:t,marketSlugs:r,onCancelOrder:n}){let{t:o}=useTranslation(),{data:i,isLoading:s,fetchNextPage:a,hasNextPage:l}=useInfiniteOrders({source:e,wallet_address:t}),c=useCancelOrder(),d=useMemo(()=>{let v=i?.pages?.flatMap(N=>N.items)??[],S=new Set(["live","open","submitted","pending"]),w=v.filter(N=>S.has(N.status));return r.length>0&&(w=w.filter(N=>N.market_id&&r.includes(N.market_id))),w},[i?.pages,r]),p=useCallback(v=>{n?n(v.id):c.mutate({source:v.source,id:v.id});},[n,c]),m=d.length,u=m+(l?1:0),f=useCallback(v=>v<m,[m]),h=useCallback(async()=>{await a();},[a]),g=useInfiniteLoader({isRowLoaded:f,loadMoreRows:h,rowCount:u,threshold:5});return s?jsx(ko,{}):d.length===0&&!l?jsx(yo,{message:o("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:Tn},children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:o("predict.openOrders.side")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.openOrders.outcome")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.openOrders.type")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.openOrders.price")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.openOrders.filled")}),jsx("div",{className:"w-20 shrink-0 pr-2",children:o("predict.openOrders.status")}),jsx("div",{className:"w-16 shrink-0"})]}),jsx(List,{style:{height:bo},onRowsRendered:g,rowComponent:pp,rowCount:u,rowHeight:xo,rowProps:{orders:d,itemCount:m,onCancel:p,isCancelling:c.isPending,cancelLabel:o("predict.openOrders.cancel")}})]})}function pp({index:e,style:t,orders:r,itemCount:n,onCancel:o,isCancelling:i,cancelLabel:s}){if(e>=n)return jsx("div",{style:t,className:"flex justify-center items-center",children:jsx(Spinner,{size:"sm"})});let a=r[e];if(!a)return null;let l=a.side==="BUY";return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:jsx("span",{className:cn$1("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",l?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:a.side})}),jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:a.outcome??"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-neutral capitalize",children:a.order_type??"limit"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:a.price?Mn(parseFloat(a.price)):"\u2014"}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:[a.size_matched??"0","/",a.original_size??"\u2014"]}),jsx("div",{className:"w-20 shrink-0 pr-2",children:jsx(mp,{status:a.status})}),jsx("div",{className:"w-16 shrink-0 text-right",children:jsx("button",{type:"button",onClick:()=>o(a),disabled:i,className:"text-[10px] text-danger hover:text-danger/80 cursor-pointer disabled:opacity-50 transition-colors",children:i?jsx(Spinner,{size:"sm"}):s})})]})}function mp({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 fp({source:e,walletAddress:t}){let{t:r}=useTranslation(),{data:n,isLoading:o,fetchNextPage:i,hasNextPage:s}=useInfiniteTrades({source:e,wallet:t,limit:50}),a=useMemo(()=>n?.pages?.flatMap(u=>u.items)??[],[n?.pages]),l=a.length,c=l+(s?1:0),d=useCallback(u=>u<l,[l]),p=useCallback(async()=>{await i();},[i]),m=useInfiniteLoader({isRowLoaded:d,loadMoreRows:p,rowCount:c,threshold:5});return o?jsx(ko,{}):a.length===0&&!s?jsx(yo,{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:Tn},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:bo},onRowsRendered:m,rowComponent:gp,rowCount:c,rowHeight:xo,rowProps:{trades:a,itemCount:l}})]})}function gp({index:e,style:t,trades:r,itemCount:n}){if(e>=n)return jsx("div",{style:t,className:"flex justify-center items-center",children:jsx(Spinner,{size:"sm"})});let o=r[e];if(!o)return null;let i=o.side?.toUpperCase()==="BUY",s=hp(o.timestamp),a=o.price??0,l=o.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:o.side})}),jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:o.outcome??"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Mn(a)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:o.size}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",l.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:s})]})}function yo({message:e}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:Hr},children:e})}function ko(){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:Hr},children:Array.from({length:6}).map((e,t)=>jsx(Skeleton,{className:"h-8 w-full rounded-md"},t))})}function Mn(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(1)}\xA2`}function hp(e){let t=new Date(e*1e3),r=(t.getMonth()+1).toString().padStart(2,"0"),n=t.getDate().toString().padStart(2,"0"),o=t.getHours().toString().padStart(2,"0"),i=t.getMinutes().toString().padStart(2,"0");return `${r}/${n} ${o}:${i}`}function vp(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return "\u2014"}}var Ps=`
74
+ `).map((r,n)=>jsxs("span",{children:[n>0&&jsx("br",{className:"hidden sm:block"}),r,n===0?" ":""]},n))})]}),jsx("div",{className:"evt-stat-grid",style:e?{animation:"evtStatsEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:"0.1s"}:{},children:mu.map((r,n)=>jsxs("div",{style:{padding:"14px 16px",background:e?`linear-gradient(to bottom, ${r.gradientFrom}, ${r.gradientTo})`:"rgba(255,255,255,0.02)",borderRight:n%2===0?"1px solid rgba(39,39,42,0.4)":"none",borderBottom:n<2?"1px solid rgba(39,39,42,0.4)":"none",...e?{animation:"evtStatCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:`${150+n*60}ms`}:{}},children:[jsx("div",{className:"evt-stat-val",style:{fontWeight:700,fontVariantNumeric:"tabular-nums",color:e?r.valueColor:"transparent",display:"flex",alignItems:"center"},children:e?r.format(e[r.key]):jsx("div",{style:{height:16,width:56,borderRadius:4,background:"rgba(255,255,255,0.06)",animation:"evtStatCardEnter 0.6s ease-out both",animationDelay:`${n*80}ms`}})}),jsx("div",{className:"evt-stat-label",style:{fontWeight:500,color:e?"#71717a":"transparent",marginTop:2,display:"flex",alignItems:"center"},children:e?t(r.labelKey):jsx("div",{style:{height:10,width:64,borderRadius:4,background:"rgba(255,255,255,0.04)",animation:"evtStatCardEnter 0.6s ease-out both",animationDelay:`${50+n*80}ms`}})})]},r.key))})]})]})}function us({event:e,market:t,position:r,onSuccess:n,onCancel:o}){let{t:i}=useTranslation(),{mutateAsync:s}=useRedeemPosition(),{evmAddress:a}=nr(),l=useWallets(),[c,d]=useState("idle"),[p,m]=useState(null),u=t.provider_meta?.["polymarket.conditionId"],f=t.provider_meta?.["polymarket.negRisk"]??false,h=a??"",g=useMemo(()=>l.find(N=>N.chainNamespace===ChainNamespace.EVM&&N.isConnected),[l]),v=ds(r.side,t.outcomes),w=t.outcomes?.[v]?.label??r.side,P=t.result!=null?ds(t.result,t.outcomes):-1,E=(P>=0?t.outcomes?.[P]:void 0)?.label??t.result??"",k=t.result!=null?v===P:true,T=useMemo(()=>k?r.size:0,[k,r.size]),B=useCallback(async()=>{if(!(!u||!h||!g)){d("pending"),m(null);try{let N=await g.getEip1193Provider();if(!N)throw new Error("EIP-1193 provider unavailable");await s({wallet_address:h,condition_id:u,neg_risk:f,signMessage:async W=>await N.request({method:"personal_sign",params:[W,h]})}),d("success"),n?.();}catch(N){d("error"),m(N instanceof Error?N.message:i("predict.redeem.error"));}}},[u,h,f,g,s,n,i]),R=useAuthCallback(B),A=c==="idle"&&!!u&&!!h&&!!g&&r.redeemable;return jsxs("div",{className:"flex flex-col gap-4 p-4",children:[jsx("div",{className:"text-base font-medium text-white",children:e?.title??t.question}),jsxs("div",{className:"flex flex-col gap-2 rounded-xl bg-[rgba(39,39,42,0.4)] p-3",children:[jsx(Tn,{label:i("predict.positions.side"),value:w,valueClassName:k?"text-green-400":"text-red-400"}),t.result!=null&&jsx(Tn,{label:i("predict.redeem.result"),value:E,valueClassName:"text-green-400"}),jsx(Tn,{label:i("predict.positions.size"),value:r.size.toFixed(2)}),jsx(Tn,{label:i("predict.redeem.expectedPayout"),value:`$${T.toFixed(2)}`,valueClassName:T>0?"text-green-400":"text-zinc-400"})]}),!k&&T===0&&jsx("p",{className:"text-sm text-zinc-500",children:i("predict.redeem.noWinnings")}),c==="error"&&p&&jsx("p",{className:"text-sm text-red-400",children:p}),c==="success"&&jsx("p",{className:"text-sm text-green-400",children:i("predict.redeem.success")}),jsxs("div",{className:"flex flex-col gap-2",children:[c!=="success"&&jsx(Button,{color:"success",className:"w-full h-12 rounded-xl text-sm font-semibold",isDisabled:!A,isLoading:c==="pending",onPress:R,spinner:jsx(Spinner,{size:"sm",color:"current"}),children:i("predict.redeem.confirm")}),o&&c!=="success"&&jsx("button",{type:"button",onClick:o,className:"w-full h-12 rounded-xl text-sm font-medium text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:i("common.cancel")}),c==="success"&&o&&jsx(Button,{className:"w-full h-12 rounded-xl text-sm font-medium",onPress:o,children:i("common.ok")})]})]})}function Tn({label:e,value:t,valueClassName:r="text-white"}){return jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm text-zinc-400",children:e}),jsx("span",{className:`text-sm font-medium ${r}`,children:t})]})}function ds(e,t){let r=e.toLowerCase();if(r==="yes")return 0;if(r==="no"||!t)return 1;let n=t.findIndex(o=>o.label.toLowerCase()===r);return n>=0?n:1}var Mu="predict-redeem";function ms({id:e=Mu}){return jsx(AsyncModal,{id:e,children:t=>jsx(Eu,{...t})})}function Eu({params:e,isOpen:t,onOpenChange:r}){let{t:n}=useTranslation(),{isMobile:o}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:o?"lg":"md",backdrop:"blur",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{className:o?"":"p-2",children:[jsxs("div",{className:"px-4 pt-4 pb-1",children:[jsx("h3",{className:"text-lg font-semibold text-white",children:n("predict.redeem.title")}),jsx("p",{className:"text-sm text-zinc-400 mt-1",children:n("predict.redeem.description")})]}),jsx(us,{event:e.event,market:e.market,position:e.position,onSuccess:()=>{setTimeout(()=>r(false),1500);},onCancel:()=>r(false)})]})})}):null}function xs({market:e,initialOutcome:t="yes",slippageBps:r=100}){let{t:n}=useTranslation(),{status:o}=useAuth(),i=useWallets(),s=usePredictClient(),a=useContext(PolymarketContext),l=useQueryClient(),c=e.source,d=c==="polymarket",p=i.find(C=>C.chainNamespace===ChainNamespace.SOLANA&&C.isConnected),m=i.find(C=>C.chainNamespace===ChainNamespace.EVM&&C.isConnected&&"switchChain"in C),u=o==="authenticated",f=p?.address,h=m?.address,g=useMemo(()=>{if(c!=="polymarket")return;let C=e.provider_meta?.["polymarket.clobTokenIds"];return C?(typeof C=="string"?JSON.parse(C):C)[0]:void 0},[c,e.provider_meta]),{data:v,isLoading:S}=useTickSize(g),w=v?.minimum_tick_size?String(v.minimum_tick_size):"0.01",{data:P,isLoading:x}=useFeeRate(g),E=String(P?.base_fee??0),[k,T]=useState(t),[B,R]=useState("market"),[A,N]=useState(NaN),[W,D]=useState(NaN),[le,X]=useState(false),[Y,b]=useState(false),[y,$]=useState(null),[j,J]=useState(null),[ce,xe]=useState(false),[Ie,Oe]=useState(false),[Te,at]=useState("1h"),[Qe,$e]=useState(30),[ze,mt]=useState("minutes"),Xe=false,F=null,ee;try{let C=nr();Xe=C.kalshiKycVerified,F=C.kalshiKycUrl,ee=C.polymarketSafeAddress;}catch{}let Ve=useCallback(async()=>{if(!m||!a)return null;let C=await m.getEip1193Provider();if(!C)return null;let Pe=!!ee,Fe={address:m.address,signatureType:Pe?2:0,signTypedData:async(We,dt,Ge,_t)=>{let Le=[];"name"in We&&Le.push({name:"name",type:"string"}),"version"in We&&Le.push({name:"version",type:"string"}),"chainId"in We&&Le.push({name:"chainId",type:"uint256"}),"verifyingContract"in We&&Le.push({name:"verifyingContract",type:"address"}),"salt"in We&&Le.push({name:"salt",type:"bytes32"});let $t={EIP712Domain:Le,...dt};return await C.request({method:"eth_signTypedData_v4",params:[m.address,JSON.stringify({domain:We,types:$t,primaryType:Ge,message:_t})]})}};return a.credentials??await a.authenticate(Fe)},[ee,m,a]),{data:Ut}=useRealtimeOrderbook({slug:e.slug,source:c},{enabled:e.status==="open"}),we=useMemo(()=>{let C=pickBestBid(Ut,k);if(C!=null&&C>0)return C;let Pe=k==="yes"?0:1,Fe=e.outcomes[Pe];return Fe?.best_bid??Fe?.price??.5},[Ut,e.outcomes,k]),De=c==="kalshi"?f??"":h??"",{data:I,isLoading:Ne}=usePositions({source:c,user:De},{enabled:!!De,refetchInterval:3e4}),Mt=useCallback(async()=>{let C=await Ve();return C?await buildPolymarketL2Headers(C.address,{apiKey:C.apiKey,secret:C.secret,passphrase:C.passphrase,method:"GET",requestPath:"/data/orders",body:""}):{}},[Ve]),{data:Yt,isLoading:Zn}=useAvailableShares({source:c,user:De,market:e.slug,side:k},c==="polymarket"?{getHeaders:Mt}:void 0,{enabled:!!De&&!!e.slug,refetchOnMount:"always"}),Cr=Yt?.total_shares??0,Et=Yt?.active_order_shares??0,lt=Yt?.available_shares??0,Ke=useMemo(()=>c==="polymarket"?getPolymarketSharesPrecision(w):Yt?.precision??0,[c,w,Yt?.precision]),Mr=Zn||Ne,eo=e.provider_meta?.["dflow.yesMint"]??"",to=e.provider_meta?.["dflow.noMint"]??"",Tt=SOLANA_TOKENS.stablecoins.USDC.address,Lt=e.provider_meta?.["dflow.collateralMint"]||"",ro=k==="yes"?eo:to,Er=useMemo(()=>I?I.positions.find(C=>C.side?.toLowerCase()===k&&C.market?.slug===e.slug)??null:null,[I,e.slug,k])?.market?.provider_meta,rn=Er?.["dflow.outcomeMint"]||ro,Qt=Er?.["dflow.collateralMint"]||Lt,Xt=rn,Jt=Qt||Tt,Rt=useMemo(()=>isNaN(A)||A<=0?"0":String(Math.round(A*1e6)),[A]),Tr=c==="kalshi"&&!!Xt&&!!Jt&&!!f&&Rt!=="0",{refetch:nn}=useDFlowQuote({inputMint:Xt,outputMint:Jt,amount:Rt,userPublicKey:f??"",slippageBps:100},{enabled:Tr}),Lr=useMemo(()=>isNaN(A)||A<=0?0:A,[A]),Je=useMemo(()=>walkOrderbook({orderbook:Ut,outcome:k,side:"sell",sharesNeeded:Lr,slippageBps:r}),[Ut,k,Lr,r]),gr=useMemo(()=>Je.status==="ok"&&Je.worstPrice!=null&&Je.worstPrice>0?Je.worstPrice:we,[Je,we]),on=useMemo(()=>{if(isNaN(A)||A<=0)return 0;let C=B==="limit"&&d&&!isNaN(W)?W:we;return A*C},[A,B,d,W,we]),sn=useCallback(C=>{T(C),D(NaN),N(NaN),b(false);},[]),no=useCallback(C=>{R(C);},[]);useEffect(()=>{B==="limit"&&D(Math.round(we*100)/100);},[B,k]);let O=useCallback(C=>{if(b(false),isNaN(C)){N(NaN);return}N(be(Math.max(0,C),Ke));},[Ke]),Ae=useCallback(()=>{b(true),N(be(lt,Ke));},[lt,Ke]),je=useCallback(C=>{if(isNaN(C)){D(NaN);return}let Pe=Math.max(.01,Math.min(.99,C));D(Math.round(Pe*100)/100);},[]),vt=useCallback(()=>{N(NaN),D(NaN),R("market"),b(false),Oe(false),at("1h"),$e(30),mt("minutes");},[]),xt=useMemo(()=>{let C=[];return isNaN(A)||A<=0?C.push(n("predict.trade.minQuantity",{amount:hn})):A<hn&&C.push(n("predict.trade.minQuantity",{amount:hn})),e.status!=="open"&&C.push(n("predict.trade.marketNotActive")),!isNaN(A)&&A>0&&!Y&&A>lt&&C.push(n("predict.trade.insufficientSharesDetail",{total:be(Cr,Ke).toFixed(Ke),active:be(Et,Ke).toFixed(Ke),available:be(lt,Ke).toFixed(Ke)})),B==="limit"&&d&&(isNaN(W)||W<.01||W>.99)&&C.push(n("predict.trade.limitPriceRange")),B==="limit"&&d&&Ie&&Te==="custom"&&(isNaN(Qe)||Qe<=0)&&C.push(n("predict.trade.expiration.invalidDate")),c==="polymarket"&&B==="market"&&!isNaN(A)&&A>0&&(Je.status==="insufficient_liquidity"?C.push(n("predict.trade.insufficientLiquidity",{available:be(Je.totalAvailable,2)})):Je.status==="exceeds_slippage"&&C.push(n("predict.trade.priceImpactTooHigh",{impact:(Je.priceImpactBps/100).toFixed(2),slippage:(r/100).toFixed(2)}))),{isValid:C.length===0,errors:C}},[A,e.status,lt,Cr,Et,Y,B,d,W,Ie,Te,Qe,Ke,c,Je,r,n]),{mutateAsync:ct}=useDFlowSubmit(),{data:Zt}=useOrder({id:y??"",source:c},{enabled:!!y}),er=useCallback(async()=>{if(!j||!f||!p)return;let{cashAmount:C,collateral:Pe}=j;J(null);try{let We=(await s.createDFlowQuote({inputMint:Pe,outputMint:Tt,amount:C,userPublicKey:f,slippageBps:100}))?.transaction;if(!We)return;let dt=Uint8Array.from(atob(We),_t=>_t.charCodeAt(0)),Ge=await p.signTransaction(dt);await ct({signedTransaction:btoa(String.fromCharCode(...Ge)),orderContext:{user_public_key:f,input_mint:Pe,output_mint:Tt,amount:C,price:"1",side:"SELL",outcome:"",market_slug:"",slippage_bps:100}});}catch{}},[j,f,p,s,ct,Tt]),bt=useCallback(()=>{l.invalidateQueries({queryKey:["predict","positions"]}),l.invalidateQueries({queryKey:["predict","orders"]}),l.invalidateQueries({queryKey:["predict","available-shares"]});},[l]);useEffect(()=>{if(!Zt||!y)return;let{status:C}=Zt;C==="closed"?($(null),j?er().finally(()=>{X(false),toast.success(n("predict.trade.submitSuccess")),or(),bt(),vt();}):(X(false),toast.success(n("predict.trade.submitSuccess")),or(),bt(),vt())):(C==="failed"||C==="expired")&&(X(false),$(null),J(null),toast.error(n("predict.trade.submitError")));},[Zt,y,j,er,bt,vt,n]);let Rr=useCallback(async()=>{if(!f||!p)return;if(!Xt||!Jt){toast.error("Missing token mint addresses"),X(false);return}if(!Xe){xe(true),X(false);return}let Fe=(await nn()).data,We=Fe?.transaction;if(!We){toast.error(n("predict.trade.submitError")),X(false);return}if(Qt&&Qt!==Tt){let Le=String(Fe?.outAmount??"");Le&&Le!=="0"&&J({cashAmount:Le,collateral:Qt});}let dt=Uint8Array.from(atob(We),Le=>Le.charCodeAt(0)),Ge=await p.signTransaction(dt),_t=await ct({signedTransaction:btoa(String.fromCharCode(...Ge)),orderContext:{user_public_key:f,input_mint:Xt,output_mint:Jt,amount:Rt,price:String(we),side:"SELL",outcome:k==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});$(_t.signature);},[f,p,nn,ct,Xt,Jt,Rt,we,k,e.slug,Qt,Tt,n,Xe]),an=useCallback(async()=>{if(!m||!a)return;let C=m.chain,Pe=C!==Chain.POLYGON;Pe&&await m.switchChain(Chain.POLYGON);try{let Fe=await m.getEip1193Provider();if(!Fe){toast.error(n("predict.trade.submitError")),X(!1);return}let We=!!ee,dt={address:m.address,signatureType:We?2:0,signTypedData:async(tr,Wl,Ul,$l)=>{let hr=[];"name"in tr&&hr.push({name:"name",type:"string"}),"version"in tr&&hr.push({name:"version",type:"string"}),"chainId"in tr&&hr.push({name:"chainId",type:"uint256"}),"verifyingContract"in tr&&hr.push({name:"verifyingContract",type:"address"}),"salt"in tr&&hr.push({name:"salt",type:"bytes32"});let Kl={EIP712Domain:hr,...Wl};return await Fe.request({method:"eth_signTypedData_v4",params:[m.address,JSON.stringify({domain:tr,types:Kl,primaryType:Ul,message:$l})]})}},Ge=await Ve();if(!Ge){toast.error(n("predict.trade.submitError")),X(!1);return}let _t=k==="yes"?0:1,Le="",$t=e.provider_meta?.["polymarket.clobTokenIds"];$t&&(Le=(typeof $t=="string"?JSON.parse($t):$t)[_t]??"");let ln=e.provider_meta?.["polymarket.negRisk"]??!1,It=B==="limit"&&!isNaN(W)?W:gr,oo=bn(It,w),cn={tokenId:Le,price:oo,size:A,side:"SELL",orderType:B==="limit"?Ie?"GTD":"GTC":"FOK",tickSize:w,negRisk:ln,...ee&&{funderAddress:ee},...B==="limit"&&Ie&&{expiration:xn(Te,Qe,ze)}},Kt=buildCtfExchangeDomain(ln),dn=buildOrderMessage({...cn,signerAddress:dt.address,signatureType:dt.signatureType,feeRateBps:E}),Fl=await dt.signTypedData(Kt,CTF_ORDER_TYPES,"Order",dn),Bl=buildSignedOrder(dn,Fl,cn.orderType),ii=buildClobPayload(Bl,Ge.apiKey),Hl=JSON.stringify(ii),zl=await buildPolymarketL2Headers(Ge.address,{apiKey:Ge.apiKey,secret:Ge.secret,passphrase:Ge.passphrase,method:"POST",requestPath:"/order",body:Hl});await s.createPolymarketOrder(ii,zl),bt(),toast.success(n("predict.trade.submitSuccess")),or(),vt(),X(!1);}finally{Pe&&C&&m.switchChain(C).catch(()=>{});}},[m,a,Ve,k,e.provider_meta,B,W,gr,A,s,bt,Ie,Te,Qe,ze,vt,n,w,E,e.slug]),_r=useCallback(async()=>{if(!(!xt.isValid||!u)){X(true),$(null),xe(false);try{c==="kalshi"?await Rr():await an();}catch(C){let Pe=C instanceof Error?C.message:"",Fe=c==="polymarket"&&Pe?yn(Pe,n,"sell"):Pe||void 0;toast.error(Fe||n("predict.trade.submitError")),X(false);}}},[xt.isValid,u,c,Rr,an,n]);return {outcome:k,orderType:B,quantity:A,limitPrice:W,shares:Lr,estimatedReturn:on,pricePerShare:we,isMarketDataLoading:c==="polymarket"&&(x||S),isSubmitting:le,validation:xt,supportsLimitOrder:d,kycRequired:ce,kycUrl:F,totalShares:Cr,activeOrderShares:Et,availableShares:lt,isAvailableLoading:Mr,isSellAll:Y,precision:Ke,expirationEnabled:Ie,expirationPreset:Te,customDuration:Qe,customDurationUnit:ze,setOutcome:sn,setOrderType:no,setQuantity:O,setLimitPrice:je,setSellAll:Ae,setExpirationEnabled:Oe,setExpirationPreset:at,setCustomDuration:$e,setCustomDurationUnit:mt,submit:_r}}var sp=["5m","1h","12h","24h","eod","custom"],ap={"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"},lp=["minutes","hours","days"],cp={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},dp={maximumFractionDigits:0};function Ms({event:e,market:t,variant:r="bordered",outcome:n,orderType:o,quantity:i,limitPrice:s,estimatedReturn:a,isMarketDataLoading:l,isSubmitting:c,isValid:d,validationErrors:p,supportsLimitOrder:m,kycRequired:u,kycUrl:f,totalShares:h,activeOrderShares:g,availableShares:v,isAvailableLoading:S,precision:w,expirationEnabled:P,expirationPreset:x,customDuration:E,customDurationUnit:k,onOutcomeChange:T,onOrderTypeChange:B,onQuantityChange:R,onLimitPriceChange:A,onSellAll:N,onExpirationEnabledChange:W,onExpirationPresetChange:D,onCustomDurationChange:le,onCustomDurationUnitChange:X,onSubmit:Y}){let{t:b}=useTranslation(),[y,$]=useState(false),j=useDisclosure(),[J,ce]=useState(""),xe=useRef(false);useEffect(()=>{xe.current||ce(isNaN(i)?"":String(i));},[i]);let[Ie,Oe]=useState(""),Te=useRef(false);useEffect(()=>{Te.current||(isNaN(s)?Oe(""):Oe(String(parseFloat((s*100).toFixed(2)))));},[s]);let at=useCallback(F=>{if(F!==""&&!/^\d*\.?\d{0,2}$/.test(F))return;if(Oe(F),F===""||F==="."){A(NaN);return}let Ve=parseFloat(F);isNaN(Ve)||A(Ve/100);},[A]),Qe=useCallback(F=>{let ee=new RegExp(`^\\d*\\.?\\d{0,${w}}$`);if(F!==""&&!ee.test(F))return;if(ce(F),$(false),F===""||F==="."){R(NaN);return}let Ve=parseFloat(F);isNaN(Ve)||R(Ve);},[R,w]);useEffect(()=>{u&&!j.isOpen&&j.onOpen();},[u]);let $e=useMemo(()=>{let F=n==="yes"?t.yesBid:t.noBid;return F!=null?parseFloat((Number(F)*100).toFixed(2)):null},[n,t]),ze=!isNaN(i)&&i>0,mt=useMemo(()=>{if(S)return b("predict.trade.loadingBalance");if(l)return b("predict.trade.loadingMarketData");if(c)return b("predict.trade.submitting");if(u)return b("predict.trade.kycRequired");if(!ze)return b("predict.trade.enterAmount");let F=b(n==="yes"?"predict.trade.yes":"predict.trade.no");return `${b("predict.trade.sell")} ${F}`},[S,l,c,u,ze,n,b]),Xe=()=>{if(u){j.onOpen();return}if(!d){$(true);return}$(false),Y();};return jsxs(Fragment,{children:[jsxs("div",{className:"flex w-full flex-col gap-y-4 p-4",style:r==="bordered"?{borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",transition:"border-color 0.2s"}:void 0,onMouseEnter:F=>{r==="bordered"&&(F.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:F=>{r==="bordered"&&(F.currentTarget.style.borderColor="rgba(39,39,42,0.6)");},children:[e&&jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxs("span",{className:"text-bearish",children:[b("predict.trade.sell")," ",b(n==="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:[m?jsxs(Tabs,{variant:"underlined",selectedKey:o,onSelectionChange:F=>B(F),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsx(Tab,{title:b("predict.trade.market")},"market"),jsx(Tab,{title:b("predict.trade.limit")},"limit")]}):jsx("span",{className:"text-sm font-medium text-foreground",children:b("predict.trade.market")}),o==="limit"&&m?jsx(StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:Ie,onChange:F=>at(F.target.value),onFocus:()=>{Te.current=true;},onBlur:()=>{Te.current=false,isNaN(s)?Oe(""):Oe(String(parseFloat((s*100).toFixed(2))));},endContent:jsx("span",{className:"text-xl font-bold tabular-nums text-foreground",children:"\xA2"}),classNames:{base:"w-28",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 rounded-lg px-2 h-9 min-h-9",input:"text-xl font-bold tabular-nums text-right"}}):$e!=null&&jsxs("span",{className:"text-xl font-bold tabular-nums",children:[$e," \xA2"]})]}),jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsx("span",{className:"text-sm font-medium text-foreground",children:b("predict.trade.sellContracts")}),jsxs("div",{className:"flex items-center gap-x-2",children:[[25,50].map(F=>{let ee=Math.pow(10,w);return jsxs("button",{type:"button",onClick:()=>{R(Math.floor(v*F/100*ee)/ee);},className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:[F,"%"]},F)}),jsx("button",{type:"button",onClick:N,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:b("common.all")})]})]}),jsx(StyledInput,{"aria-label":"Sell quantity",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:J,onChange:F=>Qe(F.target.value),onFocus:()=>{xe.current=true;},onBlur:()=>{xe.current=false,ce(isNaN(i)?"":String(i));},classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}}),y&&p.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:p.map(F=>jsx("span",{className:"text-xs text-danger",children:F},F))})]}),jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-neutral-500",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:b("predict.trade.totalShares")}),jsx("span",{className:"tabular-nums text-foreground",children:S?"\u2013":`${be(h,w).toFixed(w)}${b("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:b("predict.trade.activeOrders")}),jsx("span",{className:"tabular-nums text-warning",children:S?"\u2013":g>0?`-${be(g,w).toFixed(w)}${b("predict.trade.sharesUnit")}`:`0${b("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:b("predict.trade.availableShares")}),jsx("span",{className:"tabular-nums text-success font-medium",children:S?"\u2013":`${be(v,w).toFixed(w)}${b("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:b("predict.trade.estReturn")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${a.toFixed(2)}`:"\u2013"})]})]}),o==="limit"&&m&&jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-medium text-primary",children:b("predict.trade.setExpiration")}),jsx(StyledSwitch,{size:"sm",color:"primary",isSelected:P,onValueChange:W,"aria-label":b("predict.trade.setExpiration")})]}),P&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":b("predict.trade.setExpiration"),selectedKeys:[x],onSelectionChange:F=>{let ee=Array.from(F)[0];ee&&D(ee);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:sp.map(F=>jsx(SelectItem,{children:b(ap[F])},F))}),x==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(E)?void 0:E,onValueChange:le,minValue:1,step:1,formatOptions:dp,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:F=>{let ee=Array.from(F)[0];ee&&X(ee);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:lp.map(F=>jsx(SelectItem,{children:b(cp[F])},F))})]})]})]}),jsx(Button,{color:"secondary",fullWidth:true,radius:"lg",size:"lg",isDisabled:S||l||!ze||c,isLoading:c||S||l,spinner:jsx(Spinner,{size:"sm",color:"current"}),onPress:Xe,children:mt})]}),jsx(kn,{isOpen:j.isOpen,onClose:j.onClose,kycUrl:f})]})}function Rn({event:e,market:t,variant:r,initialOutcome:n,chain:o,slippageBps:i}){let{outcome:s,orderType:a,quantity:l,limitPrice:c,estimatedReturn:d,pricePerShare:p,isMarketDataLoading:m,isSubmitting:u,validation:f,supportsLimitOrder:h,kycRequired:g,kycUrl:v,totalShares:S,activeOrderShares:w,availableShares:P,isAvailableLoading:x,precision:E,expirationEnabled:k,expirationPreset:T,customDuration:B,customDurationUnit:R,setOutcome:A,setOrderType:N,setQuantity:W,setLimitPrice:D,setSellAll:le,setExpirationEnabled:X,setExpirationPreset:Y,setCustomDuration:b,setCustomDurationUnit:y,submit:$}=xs({market:t,initialOutcome:n,slippageBps:i}),j=useAuthCallback($),J=useMemo(()=>e?pn(e):void 0,[e]),ce=useMemo(()=>mn(t,{yesBid:s==="yes"?p:void 0,noBid:s==="no"?p:void 0}),[t,s,p]);return jsx(Ms,{event:J,market:ce,variant:r,outcome:s,orderType:a,quantity:l,limitPrice:c,estimatedReturn:d,isMarketDataLoading:m,isSubmitting:u,isValid:f.isValid,validationErrors:f.errors,supportsLimitOrder:h,kycRequired:g,kycUrl:v,totalShares:S,activeOrderShares:w,availableShares:P,isAvailableLoading:x,precision:E,expirationEnabled:k,expirationPreset:T,customDuration:B,customDurationUnit:R,onOutcomeChange:A,onOrderTypeChange:N,onQuantityChange:W,onLimitPriceChange:D,onSellAll:le,onExpirationEnabledChange:X,onExpirationPresetChange:Y,onCustomDurationChange:b,onCustomDurationUnitChange:y,onSubmit:j})}var So="predict-sell";function Ts({id:e=So}){return jsx(AsyncModal,{id:e,children:t=>jsx(xp,{...t})})}function xp({params:e,isOpen:t,onOpenChange:r}){let{t:n}=useTranslation(),{isMobile:o}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:o?"lg":"md",backdrop:"blur",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{className:o?"":"p-2",children:[jsx(Rn,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,chain:e.chain,slippageBps:e.slippageBps,variant:"flat"}),jsx("div",{className:"px-4 pb-4",children:jsx("button",{type:"button",onClick:()=>r(false),className:"w-full h-12 rounded-xl text-sm font-medium text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:n("common.cancel")})})]})})}):null}var Po=40,On=36,Ur=480,Co=Ur-On;function _s({event:e,walletAddress:t,onCancelOrder:r}){let{t:n}=useTranslation(),[o,i]=useState("positions"),s=useMemo(()=>e.markets?.map(p=>p.slug)??[],[e.markets]),{data:a}=usePositions({source:e.source,user:t??""}),l=useMemo(()=>!a?.positions||!t?0:s.length===0?a.positions.length:a.positions.filter(p=>p.market&&s.includes(p.market.slug)).length,[a?.positions,s,t]),d=[{key:"positions",label:l>0?`${n("predict.positions.title")} (${l})`:n("predict.positions.title")},{key:"orders",label:n("predict.openOrders.title")},{key:"trades",label:n("predict.tradeHistory.title")}];return jsxs("div",{className:"flex flex-col gap-y-2 mt-6 px-1 lg:px-4",children:[jsx("div",{className:"flex items-center gap-x-1 border-b border-border",children:d.map(p=>jsx("button",{type:"button",onClick:()=>i(p.key),className:cn("px-3 py-2 text-sm font-medium transition-colors cursor-pointer",o===p.key?"text-foreground border-b-2 border-primary":"text-neutral hover:text-foreground"),children:p.label},p.key))}),t?jsxs("div",{style:{height:Ur},children:[o==="positions"&&jsx(Pp,{source:e.source,walletAddress:t,marketSlugs:s}),o==="orders"&&jsx(Mp,{source:e.source,walletAddress:t,marketSlugs:s,onCancelOrder:r}),o==="trades"&&jsx(Lp,{source:e.source,walletAddress:t})]}):jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:Ur},children:n("predict.trade.connectWallet")})]})}function Pp({source:e,walletAddress:t,marketSlugs:r}){let{t:n}=useTranslation(),{data:o,isLoading:i}=usePositions({source:e,user:t}),s=useMemo(()=>o?.positions?r.length===0?o.positions:o.positions.filter(a=>a.market&&r.includes(a.market.slug)):[],[o?.positions,r]);return i?jsx(Eo,{}):s.length===0?jsx(Mo,{message:n("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:On},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2 whitespace-nowrap",children:n("predict.positions.event")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.totalSize")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.value")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.avgPrice")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.markPrice")}),jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:n("predict.positions.pnl")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.payoutIfRight")}),jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:n("predict.positions.estSettlement")}),jsx("div",{className:"w-16 shrink-0"})]}),jsx(List,{style:{height:Co},rowComponent:Cp,rowCount:s.length,rowHeight:Po,rowProps:{positions:s,closeLabel:n("predict.positions.close")}})]})}function Cp({index:e,style:t,positions:r,closeLabel:n}){let o=r[e];if(!o)return null;let i=o.pnl??0,s=o.pnl_percent??0,a=o.avg_price??0,l=o.current_price??0,c=i>0?"text-success":i<0?"text-danger":"text-foreground",d=i>0?"+":"",p=o.market?.outcomes?.[0]?.label??o.market?.question??"\u2014",m=o.side,u=o.size,f=o.size*l,h=o.market?.end_at?Ip(o.market.end_at):"\u2014";return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-xs lg:text-sm",children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxs("div",{className:"flex flex-col gap-y-0.5",children:[jsx("span",{className:"text-foreground truncate font-medium",children:p}),jsx("span",{className:cn("text-[10px] font-medium",m.toLowerCase()==="yes"?"text-primary":"text-secondary"),children:m})]})}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:o.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:_n(a)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:_n(l)}),jsxs("div",{className:cn("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:["$",u.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:h}),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:n})})]})}function Mp({source:e,walletAddress:t,marketSlugs:r,onCancelOrder:n}){let{t:o}=useTranslation(),{data:i,isLoading:s,fetchNextPage:a,hasNextPage:l}=useInfiniteOrders({source:e,wallet_address:t}),c=useCancelOrder(),d=useMemo(()=>{let v=i?.pages?.flatMap(P=>P.items)??[],S=new Set(["live","open","submitted","pending"]),w=v.filter(P=>S.has(P.status));return r.length>0&&(w=w.filter(P=>P.market_id&&r.includes(P.market_id))),w},[i?.pages,r]),p=useCallback(v=>{n?n(v.id):c.mutate({source:v.source,id:v.id});},[n,c]),m=d.length,u=m+(l?1:0),f=useCallback(v=>v<m,[m]),h=useCallback(async()=>{await a();},[a]),g=useInfiniteLoader({isRowLoaded:f,loadMoreRows:h,rowCount:u,threshold:5});return s?jsx(Eo,{}):d.length===0&&!l?jsx(Mo,{message:o("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:On},children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:o("predict.openOrders.side")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.openOrders.outcome")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.openOrders.type")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.openOrders.price")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.openOrders.filled")}),jsx("div",{className:"w-20 shrink-0 pr-2",children:o("predict.openOrders.status")}),jsx("div",{className:"w-16 shrink-0"})]}),jsx(List,{style:{height:Co},onRowsRendered:g,rowComponent:Ep,rowCount:u,rowHeight:Po,rowProps:{orders:d,itemCount:m,onCancel:p,isCancelling:c.isPending,cancelLabel:o("predict.openOrders.cancel")}})]})}function Ep({index:e,style:t,orders:r,itemCount:n,onCancel:o,isCancelling:i,cancelLabel:s}){if(e>=n)return jsx("div",{style:t,className:"flex justify-center items-center",children:jsx(Spinner,{size:"sm"})});let a=r[e];if(!a)return null;let l=a.side==="BUY";return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:jsx("span",{className:cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",l?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:a.side})}),jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:a.outcome??"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-neutral capitalize",children:a.order_type??"limit"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:a.price?_n(parseFloat(a.price)):"\u2014"}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:[a.size_matched??"0","/",a.original_size??"\u2014"]}),jsx("div",{className:"w-20 shrink-0 pr-2",children:jsx(Tp,{status:a.status})}),jsx("div",{className:"w-16 shrink-0 text-right",children:jsx("button",{type:"button",onClick:()=>o(a),disabled:i,className:"text-[10px] text-danger hover:text-danger/80 cursor-pointer disabled:opacity-50 transition-colors",children:i?jsx(Spinner,{size:"sm"}):s})})]})}function Tp({status:e}){return jsx("span",{className:cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium capitalize",{live:"bg-success/10 text-success",open:"bg-success/10 text-success",submitted:"bg-warning/10 text-warning",pending:"bg-warning/10 text-warning",matched:"bg-primary/10 text-primary",cancelled:"bg-neutral/10 text-neutral",failed:"bg-danger/10 text-danger",expired:"bg-neutral/10 text-neutral"}[e]??"bg-neutral/10 text-neutral"),children:e})}function Lp({source:e,walletAddress:t}){let{t:r}=useTranslation(),{data:n,isLoading:o,fetchNextPage:i,hasNextPage:s}=useInfiniteTrades({source:e,wallet:t,limit:50}),a=useMemo(()=>n?.pages?.flatMap(u=>u.items)??[],[n?.pages]),l=a.length,c=l+(s?1:0),d=useCallback(u=>u<l,[l]),p=useCallback(async()=>{await i();},[i]),m=useInfiniteLoader({isRowLoaded:d,loadMoreRows:p,rowCount:c,threshold:5});return o?jsx(Eo,{}):a.length===0&&!s?jsx(Mo,{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:On},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:Co},onRowsRendered:m,rowComponent:Rp,rowCount:c,rowHeight:Po,rowProps:{trades:a,itemCount:l}})]})}function Rp({index:e,style:t,trades:r,itemCount:n}){if(e>=n)return jsx("div",{style:t,className:"flex justify-center items-center",children:jsx(Spinner,{size:"sm"})});let o=r[e];if(!o)return null;let i=o.side?.toUpperCase()==="BUY",s=_p(o.timestamp),a=o.price??0,l=o.usd_size??0;return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:jsx("span",{className:cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",i?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:o.side})}),jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:o.outcome??"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:_n(a)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:o.size}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",l.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:s})]})}function Mo({message:e}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:Ur},children:e})}function Eo(){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:Ur},children:Array.from({length:6}).map((e,t)=>jsx(Skeleton,{className:"h-8 w-full rounded-md"},t))})}function _n(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(1)}\xA2`}function _p(e){let t=new Date(e*1e3),r=(t.getMonth()+1).toString().padStart(2,"0"),n=t.getDate().toString().padStart(2,"0"),o=t.getHours().toString().padStart(2,"0"),i=t.getMinutes().toString().padStart(2,"0");return `${r}/${n} ${o}:${i}`}function Ip(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return "\u2014"}}var Is=`
75
75
  @keyframes detailShimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}
76
- `,Ns={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:"detailShimmer 1.8s ease-in-out infinite",borderRadius:6};function ue(e){return {...Ns,animationDelay:`${e}ms`}}function zr({marketCount:e=4,showBack:t}){return jsxs(Fragment,{children:[jsx("style",{children:Ps}),jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",gap:20},children:[t&&jsx("div",{style:{height:20}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[jsx("div",{style:{...Ns,width:64,height:64,borderRadius:10,flexShrink:0}}),jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:8},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsx("div",{style:{...ue(0),height:14,width:48}}),jsx("div",{style:{...ue(30),height:14,width:40}}),jsx("div",{style:{...ue(60),height:14,width:40}})]}),jsx("div",{style:{...ue(80),height:20,width:"80%",maxWidth:384,borderRadius:4}})]})]}),jsx("div",{style:{...ue(100),height:16,width:192}}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:16},children:[jsx("div",{style:{...ue(120),height:16,width:96}}),jsx("div",{style:{...ue(140),height:16,width:80}})]}),jsx("div",{style:{...ue(160),height:300,width:"100%",borderRadius:12}}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[jsx("div",{style:{...ue(180),height:16,width:80}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsx("div",{style:{...ue(200),height:28,width:200,borderRadius:8}}),jsx("div",{style:{...ue(220),height:28,width:112,borderRadius:8}})]})]})]}),jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"8px 0"},children:jsx("div",{style:{...ue(240),height:14,width:56}})}),Array.from({length:e}).map((r,n)=>jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 0",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsx("div",{style:{...ue(260+n*40),width:28,height:28,borderRadius:8,flexShrink:0}}),jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:4},children:[jsx("div",{style:{...ue(280+n*40),height:14,width:n%2===0?192:160}}),jsx("div",{style:{...ue(300+n*40),height:10,width:64}})]}),jsx("div",{style:{...ue(320+n*40),height:16,width:40}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsx("div",{style:{...ue(340+n*40),height:32,width:80,borderRadius:8}}),jsx("div",{style:{...ue(360+n*40),height:32,width:80,borderRadius:8}})]})]},n))]}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[jsx("div",{style:{...ue(400),height:16,width:64}}),jsx("div",{style:{...ue(420),height:14,width:"100%"}}),jsx("div",{style:{...ue(440),height:14,width:"80%"}}),jsx("div",{style:{...ue(460),height:14,width:"60%"}})]})]})]})}function Cs(){return jsxs(Fragment,{children:[jsx("style",{children:Ps}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",padding:16},children:[jsx("div",{style:{...ue(0),height:40,width:"100%",borderRadius:8}}),jsx("div",{style:{...ue(60),height:96,width:"100%",borderRadius:8}}),jsx("div",{style:{...ue(120),height:40,width:"100%",borderRadius:8}})]})]})}var Rs="var(--color-bullish)",_s="var(--color-bearish)";function Wr(e){let t=Math.abs(e);return t>=1e9?`${parseFloat((e/1e9).toFixed(2))}B`:t>=1e6?`${parseFloat((e/1e6).toFixed(2))}M`:t>=1e3?`${parseFloat((e/1e3).toFixed(2))}K`:e.toLocaleString()}function yp(e,t){return e<=0||t<=0?0:Math.pow(e/t,.3)}function kp(e,t){let r=new Float64Array(101),n=new Float64Array(101);for(let u of e){let f=Math.round(u.price*100);f>=0&&f<=100&&(r[f]+=u.quantity);}for(let u of t){let f=Math.round(u.price*100);f>=0&&f<=100&&(n[f]+=u.quantity);}let o=0,i=0,s=new Float64Array(101),a=new Float64Array(101);for(let u=100;u>=0;u--)o+=r[u],i+=r[u]*u/100,s[u]=o,a[u]=i;let l=0,c=0,d=new Float64Array(101),p=new Float64Array(101);for(let u=0;u<=100;u++)l+=n[u],c+=n[u]*u/100,d[u]=l,p[u]=c;let m=Math.max(s[0]??0,d[100]??0);return Array.from({length:101},(u,f)=>{let h=s[f]>0,g=d[f]>0,v=s[f]||d[f],S=r[f]>0||n[f]>0;return {priceCents:f,displayHeight:yp(v,m),opacity:v>0?S?1:.5:0,isBid:h,isAsk:g,bidCumTotal:s[f],askCumTotal:d[f],bidCumCost:a[f],askCumCost:p[f]}})}function Sp({info:e}){let{t}=useTranslation(),r=e.isBid?Rs:_s,n=e.leftPct>65?void 0:`${e.leftPct}%`,o=e.leftPct>65?`${100-e.leftPct}%`:void 0;return jsxs("div",{style:{position:"absolute",top:8,left:n,right:o,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:Wr(Math.round(e.cumTotal))})}),jsxs("div",{style:{color:r},children:["$",Wr(Math.round(e.cumCost))]})]})}var wp=memo(function({slot:t,onEnter:r,onLeave:n}){let o=useRef(null),i=t.isBid||t.isAsk,s=t.isBid?Rs:t.isAsk?_s:void 0;return jsx("div",{style:{position:"absolute",left:`${t.priceCents}%`,width:"1%",height:"100%",boxSizing:"border-box",borderRight:t.priceCents<100?"1px solid transparent":"none",cursor:i?"crosshair":"default"},onMouseEnter:()=>r(t,o.current),onMouseLeave:n,children:i&&jsx("div",{ref:o,style:{position:"absolute",bottom:0,left:0,width:"100%",height:`${t.displayHeight*100}%`,backgroundColor:s,opacity:t.opacity}})})}),Pp=[0,10,20,30,40,50,60,70,80,90,100];function Np(){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:Pp.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 Is({bids:e,asks:t}){let{t:r}=useTranslation(),n=useMemo(()=>kp(e,t),[e,t]),o=useMemo(()=>{let p=e.length>0?Math.max(...e.map(u=>u.price)):0,m=t.length>0?Math.min(...t.map(u=>u.price)):1;return Math.round((p+m)/2*100)},[e,t]),i=useMemo(()=>n.some(p=>p.isBid||p.isAsk),[n]),[s,a]=useState(null),l=useRef(null),c=useCallback((p,m)=>{l.current&&(l.current.style.filter=""),m?(m.style.filter="brightness(1.5)",l.current=m):l.current=null,p.isBid||p.isAsk?a({priceCents:p.priceCents,isBid:p.isBid,cumTotal:p.isBid?p.bidCumTotal:p.askCumTotal,cumCost:p.isBid?p.bidCumCost:p.askCumCost,leftPct:p.priceCents}):a(null);},[]),d=useCallback(()=>{l.current&&(l.current.style.filter="",l.current=null),a(null);},[]);return i?jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",userSelect:"none",overflow:"hidden"},children:[jsxs("div",{style:{flex:1,position:"relative",width:"100%",overflow:"hidden"},children:[o>0&&jsx("div",{style:{position:"absolute",left:`${o}%`,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(Sp,{info:s}),n.map(p=>jsx(wp,{slot:p,onEnter:c,onLeave:d},p.priceCents))]}),jsx(Np,{})]}):jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:r("predict.orderBook.noData")})}function wo(e){let t=e*100,r=Math.round(t*10)/10;return Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`}function Ds(){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 Hs({market:e,outcome:t="yes",onTradeAction:r,initialViewMode:n="depth",className:o}){let{t:i}=useTranslation(),[s,a]=useState(n),l=t==="no",c=e.source,{data:d,isLoading:p,isFetching:m,refetch:u}=useOrderbook({slug:e.slug,source:c}),f=useMemo(()=>((l?d?.asks:d?.bids)??[]).map(N=>({price:l?1-N.price:N.price,quantity:N.size})),[d?.bids,d?.asks,l]),h=useMemo(()=>((l?d?.bids:d?.asks)??[]).map(N=>({price:l?1-N.price:N.price,quantity:N.size})),[d?.bids,d?.asks,l]),g=useMemo(()=>f.length>0?Math.max(...f.map(w=>w.price)):null,[f]),v=useMemo(()=>h.length>0?Math.min(...h.map(w=>w.price)):null,[h]),S=useMemo(()=>{if(g==null||v==null)return null;let w=(v-g)*100;return Math.round(w*10)/10},[g,v]);return jsxs("div",{className:cn$1("flex flex-col",o??"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:S!=null?`${i("predict.orderBook.spread")}: ${Number.isInteger(S)?`${S}\xA2`:`${S.toFixed(1)}\xA2`}`:null}),jsxs("span",{className:"flex flex-1 items-center justify-center gap-x-1 whitespace-nowrap",children:[g!=null&&jsxs("span",{style:{color:"var(--color-bullish)"},children:[i("predict.trade.bestBid"),": ",wo(g)]}),g!=null&&v!=null&&jsx("span",{className:"text-neutral",children:"|"}),v!=null&&jsxs("span",{style:{color:"var(--color-bearish)"},children:[i("predict.trade.bestAsk"),": ",wo(v)]})]}),jsxs("div",{className:"flex flex-1 items-center justify-end gap-x-2",children:[jsx("button",{type:"button",title:s==="depth"?"Orderbook":"Depth chart",onClick:()=>a(w=>w==="depth"?"table":"depth"),className:"flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground",children:s==="depth"?jsx(OrderbookTableIcon,{className:"h-4 w-4"}):jsx(OrderbookDepthIcon,{className:"h-4 w-4"})}),jsx("button",{type:"button",title:"Refresh",onClick:()=>u(),disabled:m,className:cn$1("flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground disabled:cursor-default disabled:opacity-50",m&&"animate-spin"),children:jsx(RefreshIcon,{className:"h-4 w-4"})})]})]}),jsxs("div",{className:"flex-1 min-h-0 overflow-hidden",children:[s==="depth"&&jsx(Fragment,{children:p?jsx(Ds,{}):jsx(Is,{bids:f,asks:h})}),s==="table"&&jsx(Fragment,{children:p?jsx(Ds,{}):jsx(_p,{bids:f,asks:h,bestBid:g??void 0,bestAsk:v??void 0,spread:S??void 0})})]})]})}var As=8;function _p({bids:e,asks:t,spread:r}){let{t:n}=useTranslation(),o=useMemo(()=>[...t].sort((l,c)=>l.price-c.price).slice(0,As).reverse(),[t]),i=useMemo(()=>[...e].sort((l,c)=>c.price-l.price).slice(0,As),[e]),s=useMemo(()=>{let l=[...o,...i].map(c=>c.quantity);return Math.max(...l,1)},[o,i]);return o.length===0&&i.length===0?jsx("div",{className:"flex items-center justify-center h-full text-xs text-neutral",children:n("predict.orderBook.empty")}):jsxs("div",{className:"flex flex-col h-full overflow-y-auto text-xs font-mono select-none",children:[o.map(l=>jsx(Fs,{price:l.price,quantity:l.quantity,side:"ask",maxQty:s},`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:[n("predict.orderBook.spread"),":"," ",Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`]})}),i.map(l=>jsx(Fs,{price:l.price,quantity:l.quantity,side:"bid",maxQty:s},`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:n("predict.orderBook.price")}),jsx("span",{className:"text-center",children:n("predict.orderBook.contracts")}),jsx("span",{className:"text-right",children:n("predict.orderBook.total")})]})]})}function Fs({price:e,quantity:t,side:r,maxQty:n}){let o=r==="ask",i=Math.min(t/n*100,100),s=o?"bg-bearish/10":"bg-bullish/10",a=o?"text-bearish":"text-bullish",l=Wr(Math.round(t)),c=Math.round(t*e),d=`$${Wr(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 ${a}`,children:wo(e)}),jsx("span",{className:"relative z-10 text-foreground text-center",children:l}),jsx("span",{className:"relative z-10 text-foreground text-right",children:d})]})}var Co=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}},_n=4,zs=["#22d3ee","#a3e635","#f97316","#f472b6","#a78bfa"];function Vp(e,t){let r=new Date(e);return t===ie.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function jp(e,t){let r=new Date(e);return t===ie.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):t===ie.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 Ws(e){return `${(e*100).toFixed(2)}%`}var Gp=[{range:ie.ONE_DAY,label:"1D"},{range:ie.ONE_WEEK,label:"1W"},{range:ie.ONE_MONTH,label:"1M"},{range:ie.ALL,label:"ALL"}];function qp({value:e,onChange:t}){return jsx("div",{style:{display:"flex",alignItems:"center",gap:2},children:Gp.map(({range:r,label:n})=>{let o=r===e;return jsx("button",{onClick:()=>t(r),style:{padding:"2px 8px",border:"none",background:"transparent",color:o?"#f9fafb":"#6b7280",fontWeight:o?700:400,fontSize:12,cursor:"pointer",borderRadius:4,letterSpacing:"0.02em",transition:"color 0.15s",userSelect:"none"},children:n},r)})})}function Yp(){let e=useRef(null),t=useRef(null),r=useCallback(o=>{let i=e.current,s=t.current;if(!i||!s)return;let a=i.getBoundingClientRect(),l=(o.clientX-a.left)/a.width*100;s.style.background=`linear-gradient(to right, transparent ${l}%, rgba(0,0,0,0.55) ${l}%)`,s.style.opacity="1";},[]),n=useCallback(()=>{t.current&&(t.current.style.opacity="0");},[]);return {wrapperRef:e,overlayRef:t,onMouseMove:r,onMouseLeave:n}}function Qp({active:e,payload:t,label:r,labelMap:n,allSeries:o,range:i}){if(!e||!o?.length)return null;let s=new Map;t?.forEach(l=>s.set(l.dataKey,l));let a=o.map(l=>s.get(l.slug)??{dataKey:l.slug,value:void 0,stroke:l.color,color:l.color});return jsxs("div",{style:{background:"rgba(10,10,10,0.92)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:8,padding:"8px 12px",minWidth:180,backdropFilter:"blur(8px)",fontSize:12},children:[jsx("div",{style:{color:"#9ca3af",marginBottom:6,fontWeight:500},children:typeof r=="number"?jp(r,i):r}),a.map(l=>jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[jsx("span",{style:{display:"inline-block",width:3,height:14,borderRadius:2,background:l.stroke??l.color,flexShrink:0}}),jsx("span",{style:{color:"#9ca3af",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:120},children:n.get(l.dataKey)??l.dataKey}),jsx("span",{style:{color:"#f9fafb",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:l.value!=null?Ws(l.value):"--"})]},l.dataKey))]})}function Xp({markets:e,selectedSlugs:t,colorMap:r,onToggle:n}){let[o,i]=useState(false),s=useRef(null);useEffect(()=>{if(!o)return;function c(d){s.current&&!s.current.contains(d.target)&&i(false);}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[o]);let a=t.length>=_n,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(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:[l,jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{flexShrink:0,transform:o?"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"})})]}),o&&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 ",_n," markets"]}),e.map((c,d)=>{let p=t.includes(c.slug),m=!p&&a,u=p&&t.length===1,f=r.get(c.slug)??"#6b7280",h=c.outcomes.find(v=>v.label.toLowerCase()==="yes")??c.outcomes[0],g=h?.price!=null?`${Math.round(h.price*100)}%`:null;return jsxs("button",{onClick:()=>{u||m||n(c.slug);},style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"7px 12px",border:"none",background:p?"rgba(255,255,255,0.05)":"transparent",cursor:m||u?"not-allowed":"pointer",opacity:m?.35:1,textAlign:"left",transition:"background 0.1s"},onMouseEnter:v=>{!m&&!u&&(v.currentTarget.style.background="rgba(255,255,255,0.07)");},onMouseLeave:v=>{v.currentTarget.style.background=p?"rgba(255,255,255,0.05)":"transparent";},children:[jsx("span",{style:{width:16,height:16,borderRadius:4,border:p?`2px solid ${f}`:"2px solid rgba(255,255,255,0.2)",background:p?`${f}30`:"transparent",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:p&&jsx("svg",{width:"9",height:"7",viewBox:"0 0 9 7",fill:"none",children:jsx("path",{d:"M1 3.5L3.5 6L8 1",stroke:f,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:f,flexShrink:0}}),jsx("span",{style:{color:p?"#f9fafb":"#9ca3af",fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c.outcomes?.[0]?.label??c.question}),g&&jsx("span",{style:{color:f,fontWeight:700,fontSize:12,flexShrink:0},children:g})]},c.id??`${d}-${c.slug}`)})]})]})}function Jp({series:e,colorMap:t,displayValues:r}){return jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px 24px",padding:"0 2px"},children:e.map(n=>{let o=t.get(n.marketSlug)??"#6b7280",i=r.get(n.marketSlug);return jsxs("div",{style:{display:"inline-flex",alignItems:"flex-start",gap:6},children:[jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:o,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:n.label}),jsx("span",{style:{color:"#f9fafb",fontSize:14,fontWeight:700,lineHeight:"20px",fontVariantNumeric:"tabular-nums"},children:i!=null?Ws(i):"--"})]})]},n.marketSlug)})})}function Zp(e){let t=Math.floor(e.length/2);return e.length%2===1?e[t]:(e[t-1]+e[t])/2}function em(e,t){if(e.length<=t)return e;let r=[],n=e.length/t;for(let o=0;o<t;o++){let i=Math.floor(o*n),s=Math.min(Math.floor((o+1)*n),e.length),a=e.slice(i,s),l=a.map(c=>c.price).sort((c,d)=>c-d);r.push({timestamp:a[a.length-1].timestamp,price:Zp(l)});}return r}function tm(e,t=200){if(e.length===0)return [];let r=e.map(a=>({...a,data:em(a.data,t)})),n=new Set;r.forEach(a=>a.data.forEach(l=>n.add(l.timestamp)));let o=Array.from(n).sort((a,l)=>a-l),i=r.map(a=>{let l=new Map;return a.data.forEach(c=>l.set(c.timestamp,c.price)),{slug:a.marketSlug,map:l}}),s=new Map;return o.map(a=>{let l={timestamp:a};return i.forEach(({slug:c,map:d})=>{let p=d.get(a);if(p!==void 0)s.set(c,p),l[c]=p;else {let m=s.get(c);m!==void 0&&(l[c]=m);}}),l})}function Us(e){return jsx(Co,{children:jsx(rm,{...e})})}function rm({event:e,isLoading:t,className:r,volume:n,fillHeight:o=false}){let i=useMemo(()=>{let b=new Set;return (e.markets??[]).filter(y=>y.status!=="open"||b.has(y.slug)?false:(b.add(y.slug),true))},[e.markets]),s=useMemo(()=>[...i].sort((b,y)=>{let V=G=>(G.outcomes.find(J=>J.label.toLowerCase()==="yes")??G.outcomes[0])?.price??0;return V(y)-V(b)}),[i]),[a,l]=useState(()=>s.slice(0,_n).map(b=>b.slug)),[c,d]=useState(dn),p=useMemo(()=>{let b=new Map;return a.forEach((y,V)=>{b.set(y,zs[V%zs.length]);}),b},[a]),m=useMemo(()=>i.filter(b=>a.includes(b.slug)),[i,a]),{series:u,isLoading:f}=useMarketHistory(m,c),h=t||f,g=useMemo(()=>{if(u.length>0&&u.some(V=>V.data.length>0))return u;let b=Date.now(),y=864e5;return m.map(V=>{let J=(V.outcomes?.find(le=>le.label.toLowerCase()==="yes")??V.outcomes?.[0])?.price??.5;return {marketSlug:V.slug,label:V.outcomes?.[0]?.label??V.question,data:[{timestamp:b-7*y,price:J},{timestamp:b,price:J}]}})},[u,m]),v=useMemo(()=>c===ie.ONE_DAY?96:c===ie.ONE_WEEK?168:c===ie.ONE_MONTH?180:300,[c]),S=useMemo(()=>tm(g,v),[g,v]),w=useMemo(()=>{if(S.length===0)return [0,1];let b=1/0,y=-1/0;if(a.forEach(G=>{S.forEach(J=>{let le=J[G];le!=null&&(le<b&&(b=le),le>y&&(y=le));});}),!isFinite(b))return [0,1];let V=Math.max((y-b)*.15,.05);return [Math.max(0,b-V),Math.min(1,y+V)]},[S,a]),N=useMemo(()=>{let b=new Map;return g.forEach(y=>{y.data.length>0&&b.set(y.marketSlug,y.data[y.data.length-1].price);}),b},[g]),x=useMemo(()=>{let b=new Map;return g.forEach(y=>b.set(y.marketSlug,y.label)),b},[g]),T=useMemo(()=>g.map(b=>({slug:b.marketSlug,color:p.get(b.marketSlug)??"#6b7280"})),[g,p]),{wrapperRef:k,overlayRef:L,onMouseMove:H,onMouseLeave:D}=Yp(),A=useCallback(b=>{l(y=>y.includes(b)?y.length<=1?y:y.filter(V=>V!==b):y.length>=_n?y:[...y,b]);},[]),[P,W]=useState(null),O=useRef(null),ae=useRef(""),X=useRef(0),Y=!h&&S.length>0;return jsxs("div",{className:r,style:{display:"flex",flexDirection:"column",gap:12,...o?{height:"100%",minHeight:0}:null},children:[jsx(Jp,{series:g,colorMap:p,displayValues:P??N}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,...o?{flex:1,minHeight:0}:null},children:[jsx("div",{ref:k,style:{width:"100%",userSelect:"none",position:"relative",...o?{flex:1,minHeight:240}:{height:300}},onMouseMove:Y?b=>{H(b),cancelAnimationFrame(X.current),X.current=requestAnimationFrame(()=>{W(O.current);});}:void 0,onMouseLeave:Y?()=>{D(),cancelAnimationFrame(X.current),ae.current="",O.current=null,W(null);}:void 0,children:h?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"}})}):S.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:L,style:{position:"absolute",inset:0,opacity:0,pointerEvents:"none",zIndex:1}}),jsx(ResponsiveContainer,{width:"100%",height:"100%",children:jsxs(LineChart,{data:S,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:b=>Vp(b,c),axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},minTickGap:70}),jsx(YAxis,{domain:w,tickFormatter:b=>`${Math.round(b*100)}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},width:40,tickCount:6}),jsx(Tooltip,{content:b=>{let y=b;if(y.active&&y.payload?.length){let V=y.payload.map(G=>`${G.dataKey}:${G.value}`).join(",");if(V!==ae.current){ae.current=V;let G=new Map;y.payload.forEach(J=>{J.value!=null&&G.set(J.dataKey,J.value);}),O.current=G;}}return jsx(Qp,{...y,labelMap:x,allSeries:T,range:c})},cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},wrapperStyle:{zIndex:2},isAnimationActive:false}),g.map(b=>{let y=p.get(b.marketSlug)??"#6b7280";return jsx(Line,{type:"linear",dataKey:b.marketSlug,stroke:y,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:y},connectNulls:true,isAnimationActive:false},b.marketSlug)}),P==null&&S.length>0&&g.map(b=>{let y=S[S.length-1],V=y[b.marketSlug];if(V==null)return null;let G=p.get(b.marketSlug)??"#6b7280";return jsx(ReferenceDot,{x:y.timestamp,y:V,ifOverflow:"extendDomain",shape:J=>{let{cx:le,cy:ve}=J;return le==null||ve==null?jsx("g",{}):jsxs("g",{children:[jsxs("circle",{cx:le,cy:ve,r:6,fill:G,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:le,cy:ve,r:3.5,fill:G})]})}},`pulse-${b.marketSlug}`)})]})})]})}),jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"6px 8px",marginTop:6},children:[n!=null&&n>0&&jsxs("span",{style:{color:"#6b7280",fontSize:12},children:[formatAmountInUsd(n)," vol"]}),jsx("div",{style:{flex:1,minWidth:0}}),jsx(qp,{value:c,onChange:d}),s.length>1&&jsx("div",{style:{width:"100%",display:"flex",alignItems:"center"},children:jsx(Xp,{markets:s,selectedSlugs:a,colorMap:p,onToggle:A})})]})]})]})}function In(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Ks(e,t){let r=e.outcomes[t==="yes"?0:1];return r?.best_ask??r?.price}function vm(e){return `${parseFloat((e*100).toFixed(2))}%`}function Vs(e){let t=e*100;return t<1&&t>0?"< 1":parseFloat(t.toFixed(2)).toString()}function On(e){return e.outcomes?.[0]?.label??e.question}function xm(e){switch(e){case "polymarket":return "Polymarket";case "kalshi":return "Kalshi";default:return e}}function Ur(e){if(!e)return "\u2014";let t=new Date(e);if(isNaN(t.getTime()))return "\u2014";let r=t.toLocaleString("default",{month:"short"}),n=t.getDate(),o=t.getFullYear(),i=t.getHours().toString().padStart(2,"0"),s=t.getMinutes().toString().padStart(2,"0");return `${r} ${n}, ${o} ${i}:${s}`}function js(e){let[t,r]=useState(0);if(useEffect(()=>{if(!e)return;r(Date.now());let d=setInterval(()=>r(Date.now()),1e3);return ()=>clearInterval(d)},[e]),!e||t===0)return null;let n=new Date(e).getTime();if(isNaN(n))return null;let o=n-t;if(o<=0)return null;let i=Math.floor(o/864e5),s=Math.floor(o%864e5/36e5),a=Math.floor(o%36e5/6e4),l=Math.floor(o%6e4/1e3),c=[];return i>0&&c.push(`${i}d`),c.push(`${String(s).padStart(2,"0")}h`),c.push(`${String(a).padStart(2,"0")}m`),c.push(`${String(l).padStart(2,"0")}s`),c.join(" ")}function Gs(e){if(!e)return null;let t=new Date(e);if(isNaN(t.getTime()))return null;let r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getDate().toString().padStart(2,"0"),s=t.getFullYear(),a=-t.getTimezoneOffset(),l=a>=0?"+":"-",c=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${s} (${l}${c})`}function Xs({event:e,onTradeAction:t}){let{t:r}=useTranslation(),{ref:n,isCollapsed:o}=useScrollCollapse(),i=useMemo(()=>{let p=[...e.markets||[]],m=p.filter(f=>f.status==="open").sort((f,h)=>In(h)-In(f)),u=p.filter(f=>f.status!=="open").sort((f,h)=>In(h)-In(f));return [...m,...u]},[e.markets]),s=e.status==="closed"||e.status==="voided",a=js(s?void 0:e.start_at),l=js(s?void 0:e.end_at),c=Gs(e.start_at),d=Gs(e.end_at);return jsxs("div",{className:"w-full flex flex-col gap-y-4 lg:gap-y-6",children:[jsxs("div",{ref:n,className:`sticky top-0 z-30 flex items-center backdrop-blur-md transition-all duration-300 ${o?"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 ${o?"!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:[!o&&jsxs("div",{className:"flex items-center gap-1.5",children:[e.tags?.slice(0,3).map((p,m)=>jsxs(Fragment$1,{children:[m>0&&jsx("span",{className:"text-sm text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-sm text-neutral truncate",children:p.label})]},p.slug)),jsx(Sm,{source:e.source})]}),jsx("span",{className:`font-semibold truncate transition-all duration-300 ${o?"text-sm lg:text-base":"text-lg lg:text-xl"}`,children:e.title})]})]}),(a||l||s)&&jsx("div",{className:"flex items-center gap-x-2 text-xs lg:text-sm font-mono",children:s?d&&jsx("span",{className:"text-neutral",children:r("predict.event.endedAt",{time:d})}):a?jsxs(Fragment,{children:[jsx("span",{className:"text-foreground",children:r("predict.event.beginsIn",{time:a})}),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})}),d&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-neutral",children:d})]})]}):null}),jsx(Us,{event:e,volume:e.volume??void 0}),jsx(bm,{markets:i,onTradeAction:t}),jsx(km,{markets:i,event:e})]})}var qs=5;function bm({markets:e,onTradeAction:t}){let{t:r}=useTranslation(),{isDesktop:n}=useScreen(),[o,i]=useState(false),[s,a]=useState(null),l=useMemo(()=>{let g=new Set;return e.filter(v=>g.has(v.slug)?false:(g.add(v.slug),true))},[e]),c=l.find(g=>g.status==="open")?.slug,[d,p]=useState(c?`${c}:yes`:null);if(l.length===0)return null;let m=l.length>qs,u=o?l:l.slice(0,qs),f=g=>{a(v=>v===g?null:g);},h=(g,v,S)=>{p(`${g.slug}:${v}`),n&&a(g.slug),t?.(g,v,S);};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:u.map((g,v)=>{let S=s===g.slug;return jsx(ym,{market:g,activeYes:d===`${g.slug}:yes`,activeNo:d===`${g.slug}:no`,isExpanded:S,onToggleExpand:()=>f(g.slug),onTradeAction:h},g.id??`${v}-${g.slug}`)})})]}),m&&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:r(o?"predict.event.rules.collapse":"predict.event.moreMarketsLabel")}),jsx(ChevronDownIcon,{className:cn$1("h-4 w-4 transition-transform",o&&"rotate-180")})]})]})}function ym({market:e,activeYes:t,activeNo:r,isExpanded:n,onToggleExpand:o,onTradeAction:i}){let{t:s}=useTranslation(),a=e.status==="open",l=e.volume?`${formatAmountInUsd(e.volume)} vol`:void 0,{data:c}=useRealtimeOrderbook({slug:e.slug,source:e.source},{enabled:a}),d=pickBestAsk(c,"yes")??Ks(e,"yes")??0,p=pickBestAsk(c,"no")??Ks(e,"no");return jsxs(Fragment,{children:[jsxs("tr",{className:"cursor-pointer border-b border-border text-xs hover:bg-content2 lg:text-base",onClick:o,role:"button",tabIndex:0,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),o());},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:On(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:On(e)}),l&&jsx("span",{className:"text-[8px] text-neutral lg:text-xxs",children:l})]})]})}),jsx("td",{className:"py-2 text-left text-foreground lg:text-center",children:vm(d)}),jsx("td",{className:"py-2 pr-1 lg:pr-2",children:a?jsxs("div",{className:"flex items-center justify-end gap-x-2",children:[jsx("button",{type:"button",className:cn$1("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all focus-visible:outline-2 focus-visible:outline-primary/40 focus-visible:outline-offset-2",t?"bg-primary text-primary-foreground":"bg-primary/10 text-primary"),onClick:m=>{m.stopPropagation(),i?.(e,"yes","buy");},children:s("predict.market.action.yes",{price:Vs(d)})}),jsx("button",{type:"button",className:cn$1("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all focus-visible:outline-2 focus-visible:outline-primary/40 focus-visible:outline-offset-2",r?"bg-secondary text-secondary-foreground":"bg-secondary/10 text-secondary"),onClick:m=>{m.stopPropagation(),i?.(e,"no","buy");},children:p!=null?s("predict.market.action.no",{price:Vs(p)}):s("predict.market.no")})]}):jsx("div",{className:"flex items-center justify-end",children:jsx("span",{className:cn$1("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",e.status==="closed"?"bg-neutral/10 text-neutral":e.status==="voided"?"bg-warning/10 text-warning":"bg-primary/10 text-primary"),children:e.status==="closed"?s("predict.event.status.closed"):e.status==="voided"?s("predict.event.status.voided"):s("predict.event.status.pending")})})})]}),n&&jsx("tr",{children:jsx("td",{colSpan:3,className:"pb-3",children:jsx("div",{className:"max-h-100 overflow-y-auto",children:jsx(Hs,{market:e,outcome:r?"no":"yes",onTradeAction:i})})})})]})}function km({markets:e,event:t}){let{t:r}=useTranslation(),[n,o]=useState(false),[i,s]=useState(false),[a,l]=useState(0),c=e.filter(u=>u.rules&&u.rules.length>0||u.description);if(c.length===0)return null;let d=c[a]??c[0],p=d.rules&&d.rules.length>0?d.rules.join(`
76
+ `,Os={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:"detailShimmer 1.8s ease-in-out infinite",borderRadius:6};function pe(e){return {...Os,animationDelay:`${e}ms`}}function $r({marketCount:e=4,showBack:t}){return jsxs(Fragment,{children:[jsx("style",{children:Is}),jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",gap:20},children:[t&&jsx("div",{style:{height:20}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[jsx("div",{style:{...Os,width:64,height:64,borderRadius:10,flexShrink:0}}),jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:8},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsx("div",{style:{...pe(0),height:14,width:48}}),jsx("div",{style:{...pe(30),height:14,width:40}}),jsx("div",{style:{...pe(60),height:14,width:40}})]}),jsx("div",{style:{...pe(80),height:20,width:"80%",maxWidth:384,borderRadius:4}})]})]}),jsx("div",{style:{...pe(100),height:16,width:192}}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:16},children:[jsx("div",{style:{...pe(120),height:16,width:96}}),jsx("div",{style:{...pe(140),height:16,width:80}})]}),jsx("div",{style:{...pe(160),height:300,width:"100%",borderRadius:12}}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[jsx("div",{style:{...pe(180),height:16,width:80}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsx("div",{style:{...pe(200),height:28,width:200,borderRadius:8}}),jsx("div",{style:{...pe(220),height:28,width:112,borderRadius:8}})]})]})]}),jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"8px 0"},children:jsx("div",{style:{...pe(240),height:14,width:56}})}),Array.from({length:e}).map((r,n)=>jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 0",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsx("div",{style:{...pe(260+n*40),width:28,height:28,borderRadius:8,flexShrink:0}}),jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:4},children:[jsx("div",{style:{...pe(280+n*40),height:14,width:n%2===0?192:160}}),jsx("div",{style:{...pe(300+n*40),height:10,width:64}})]}),jsx("div",{style:{...pe(320+n*40),height:16,width:40}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsx("div",{style:{...pe(340+n*40),height:32,width:80,borderRadius:8}}),jsx("div",{style:{...pe(360+n*40),height:32,width:80,borderRadius:8}})]})]},n))]}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[jsx("div",{style:{...pe(400),height:16,width:64}}),jsx("div",{style:{...pe(420),height:14,width:"100%"}}),jsx("div",{style:{...pe(440),height:14,width:"80%"}}),jsx("div",{style:{...pe(460),height:14,width:"60%"}})]})]})]})}function Ds(){return jsxs(Fragment,{children:[jsx("style",{children:Is}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",padding:16},children:[jsx("div",{style:{...pe(0),height:40,width:"100%",borderRadius:8}}),jsx("div",{style:{...pe(60),height:96,width:"100%",borderRadius:8}}),jsx("div",{style:{...pe(120),height:40,width:"100%",borderRadius:8}})]})]})}var zs="var(--color-bullish)",Ws="var(--color-bearish)";function Kr(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 Ap(e,t){return e<=0||t<=0?0:Math.pow(e/t,.3)}function Fp(e,t){let r=new Float64Array(101),n=new Float64Array(101);for(let u of e){let f=Math.round(u.price*100);f>=0&&f<=100&&(r[f]+=u.quantity);}for(let u of t){let f=Math.round(u.price*100);f>=0&&f<=100&&(n[f]+=u.quantity);}let o=0,i=0,s=new Float64Array(101),a=new Float64Array(101);for(let u=100;u>=0;u--)o+=r[u],i+=r[u]*u/100,s[u]=o,a[u]=i;let l=0,c=0,d=new Float64Array(101),p=new Float64Array(101);for(let u=0;u<=100;u++)l+=n[u],c+=n[u]*u/100,d[u]=l,p[u]=c;let m=Math.max(s[0]??0,d[100]??0);return Array.from({length:101},(u,f)=>{let h=s[f]>0,g=d[f]>0,v=s[f]||d[f],S=r[f]>0||n[f]>0;return {priceCents:f,displayHeight:Ap(v,m),opacity:v>0?S?1:.5:0,isBid:h,isAsk:g,bidCumTotal:s[f],askCumTotal:d[f],bidCumCost:a[f],askCumCost:p[f]}})}function Bp({info:e}){let{t}=useTranslation(),r=e.isBid?zs:Ws,n=e.leftPct>65?void 0:`${e.leftPct}%`,o=e.leftPct>65?`${100-e.leftPct}%`:void 0;return jsxs("div",{style:{position:"absolute",top:8,left:n,right:o,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:Kr(Math.round(e.cumTotal))})}),jsxs("div",{style:{color:r},children:["$",Kr(Math.round(e.cumCost))]})]})}var Hp=memo(function({slot:t,onEnter:r,onLeave:n}){let o=useRef(null),i=t.isBid||t.isAsk,s=t.isBid?zs:t.isAsk?Ws:void 0;return jsx("div",{style:{position:"absolute",left:`${t.priceCents}%`,width:"1%",height:"100%",boxSizing:"border-box",borderRight:t.priceCents<100?"1px solid transparent":"none",cursor:i?"crosshair":"default"},onMouseEnter:()=>r(t,o.current),onMouseLeave:n,children:i&&jsx("div",{ref:o,style:{position:"absolute",bottom:0,left:0,width:"100%",height:`${t.displayHeight*100}%`,backgroundColor:s,opacity:t.opacity}})})}),zp=[0,10,20,30,40,50,60,70,80,90,100];function Wp(){return jsx("div",{className:"relative flex h-6 items-center border-b border-t border-border px-1",style:{background:"rgba(0,0,0,0.15)"},children:zp.map(e=>jsx("span",{className:"absolute text-neutral font-normal",style:{fontSize:10,left:`${e}%`,transform:e===0?"translateX(0px)":e===100?"translateX(-100%)":"translateX(-50%)"},children:e},e))})}function Us({bids:e,asks:t}){let{t:r}=useTranslation(),n=useMemo(()=>Fp(e,t),[e,t]),o=useMemo(()=>{let p=e.length>0?Math.max(...e.map(u=>u.price)):0,m=t.length>0?Math.min(...t.map(u=>u.price)):1;return Math.round((p+m)/2*100)},[e,t]),i=useMemo(()=>n.some(p=>p.isBid||p.isAsk),[n]),[s,a]=useState(null),l=useRef(null),c=useCallback((p,m)=>{l.current&&(l.current.style.filter=""),m?(m.style.filter="brightness(1.5)",l.current=m):l.current=null,p.isBid||p.isAsk?a({priceCents:p.priceCents,isBid:p.isBid,cumTotal:p.isBid?p.bidCumTotal:p.askCumTotal,cumCost:p.isBid?p.bidCumCost:p.askCumCost,leftPct:p.priceCents}):a(null);},[]),d=useCallback(()=>{l.current&&(l.current.style.filter="",l.current=null),a(null);},[]);return i?jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",userSelect:"none",overflow:"hidden"},children:[jsxs("div",{style:{flex:1,position:"relative",width:"100%",overflow:"hidden"},children:[o>0&&jsx("div",{style:{position:"absolute",left:`${o}%`,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(Bp,{info:s}),n.map(p=>jsx(Hp,{slot:p,onEnter:c,onLeave:d},p.priceCents))]}),jsx(Wp,{})]}):jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:r("predict.orderBook.noData")})}function Lo(e){let t=e*100,r=Math.round(t*10)/10;return Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`}function Ks(){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 qs({market:e,outcome:t="yes",onTradeAction:r,initialViewMode:n="depth",className:o}){let{t:i}=useTranslation(),[s,a]=useState(n),l=t==="no",c=e.source,{data:d,isLoading:p,isFetching:m,refetch:u}=useOrderbook({slug:e.slug,source:c}),f=useMemo(()=>((l?d?.asks:d?.bids)??[]).map(P=>({price:l?1-P.price:P.price,quantity:P.size})),[d?.bids,d?.asks,l]),h=useMemo(()=>((l?d?.bids:d?.asks)??[]).map(P=>({price:l?1-P.price:P.price,quantity:P.size})),[d?.bids,d?.asks,l]),g=useMemo(()=>f.length>0?Math.max(...f.map(w=>w.price)):null,[f]),v=useMemo(()=>h.length>0?Math.min(...h.map(w=>w.price)):null,[h]),S=useMemo(()=>{if(g==null||v==null)return null;let w=(v-g)*100;return Math.round(w*10)/10},[g,v]);return jsxs("div",{className:cn("flex flex-col",o??"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:S!=null?`${i("predict.orderBook.spread")}: ${Number.isInteger(S)?`${S}\xA2`:`${S.toFixed(1)}\xA2`}`:null}),jsxs("span",{className:"flex flex-1 items-center justify-center gap-x-1 whitespace-nowrap",children:[g!=null&&jsxs("span",{style:{color:"var(--color-bullish)"},children:[i("predict.trade.bestBid"),": ",Lo(g)]}),g!=null&&v!=null&&jsx("span",{className:"text-neutral",children:"|"}),v!=null&&jsxs("span",{style:{color:"var(--color-bearish)"},children:[i("predict.trade.bestAsk"),": ",Lo(v)]})]}),jsxs("div",{className:"flex flex-1 items-center justify-end gap-x-2",children:[jsx("button",{type:"button",title:s==="depth"?"Orderbook":"Depth chart",onClick:()=>a(w=>w==="depth"?"table":"depth"),className:"flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground",children:s==="depth"?jsx(OrderbookTableIcon,{className:"h-4 w-4"}):jsx(OrderbookDepthIcon,{className:"h-4 w-4"})}),jsx("button",{type:"button",title:"Refresh",onClick:()=>u(),disabled:m,className:cn("flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground disabled:cursor-default disabled:opacity-50",m&&"animate-spin"),children:jsx(RefreshIcon,{className:"h-4 w-4"})})]})]}),jsxs("div",{className:"flex-1 min-h-0 overflow-hidden",children:[s==="depth"&&jsx(Fragment,{children:p?jsx(Ks,{}):jsx(Us,{bids:f,asks:h})}),s==="table"&&jsx(Fragment,{children:p?jsx(Ks,{}):jsx(qp,{bids:f,asks:h,bestBid:g??void 0,bestAsk:v??void 0,spread:S??void 0})})]})]})}var Vs=8;function qp({bids:e,asks:t,spread:r}){let{t:n}=useTranslation(),o=useMemo(()=>[...t].sort((l,c)=>l.price-c.price).slice(0,Vs).reverse(),[t]),i=useMemo(()=>[...e].sort((l,c)=>c.price-l.price).slice(0,Vs),[e]),s=useMemo(()=>{let l=[...o,...i].map(c=>c.quantity);return Math.max(...l,1)},[o,i]);return o.length===0&&i.length===0?jsx("div",{className:"flex items-center justify-center h-full text-xs text-neutral",children:n("predict.orderBook.empty")}):jsxs("div",{className:"flex flex-col h-full overflow-y-auto text-xs font-mono select-none",children:[o.map(l=>jsx(js,{price:l.price,quantity:l.quantity,side:"ask",maxQty:s},`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:[n("predict.orderBook.spread"),":"," ",Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`]})}),i.map(l=>jsx(js,{price:l.price,quantity:l.quantity,side:"bid",maxQty:s},`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:n("predict.orderBook.price")}),jsx("span",{className:"text-center",children:n("predict.orderBook.contracts")}),jsx("span",{className:"text-right",children:n("predict.orderBook.total")})]})]})}function js({price:e,quantity:t,side:r,maxQty:n}){let o=r==="ask",i=Math.min(t/n*100,100),s=o?"bg-bearish/10":"bg-bullish/10",a=o?"text-bearish":"text-bullish",l=Kr(Math.round(t)),c=Math.round(t*e),d=`$${Kr(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 ${a}`,children:Lo(e)}),jsx("span",{className:"relative z-10 text-foreground text-center",children:l}),jsx("span",{className:"relative z-10 text-foreground text-right",children:d})]})}var Io=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}},Vr=4,Ys=["#22d3ee","#a3e635","#f97316","#f472b6","#a78bfa"];function sm(e,t){let r=new Date(e);return t===se.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function am(e,t){let r=new Date(e);return t===se.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):t===se.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 Xs(e){return `${(e*100).toFixed(2)}%`}var lm=[{range:se.ONE_DAY,label:"1D"},{range:se.ONE_WEEK,label:"1W"},{range:se.ONE_MONTH,label:"1M"},{range:se.ALL,label:"ALL"}];function cm({value:e,onChange:t}){return jsx("div",{style:{display:"flex",alignItems:"center",gap:2},children:lm.map(({range:r,label:n})=>{let o=r===e;return jsx("button",{onClick:()=>t(r),style:{padding:"2px 8px",border:"none",background:"transparent",color:o?"#f9fafb":"#6b7280",fontWeight:o?700:400,fontSize:12,cursor:"pointer",borderRadius:4,letterSpacing:"0.02em",transition:"color 0.15s",userSelect:"none"},children:n},r)})})}function dm(){let e=useRef(null),t=useRef(null),r=useCallback(o=>{let i=e.current,s=t.current;if(!i||!s)return;let a=i.getBoundingClientRect(),l=(o.clientX-a.left)/a.width*100;s.style.background=`linear-gradient(to right, transparent ${l}%, rgba(0,0,0,0.55) ${l}%)`,s.style.opacity="1";},[]),n=useCallback(()=>{t.current&&(t.current.style.opacity="0");},[]);return {wrapperRef:e,overlayRef:t,onMouseMove:r,onMouseLeave:n}}function um({active:e,payload:t,label:r,labelMap:n,allSeries:o,range:i}){if(!e||!o?.length)return null;let s=new Map;t?.forEach(l=>s.set(l.dataKey,l));let a=o.map(l=>s.get(l.slug)??{dataKey:l.slug,value:void 0,stroke:l.color,color:l.color});return jsxs("div",{style:{background:"rgba(10,10,10,0.92)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:8,padding:"8px 12px",minWidth:180,backdropFilter:"blur(8px)",fontSize:12},children:[jsx("div",{style:{color:"#9ca3af",marginBottom:6,fontWeight:500},children:typeof r=="number"?am(r,i):r}),a.map(l=>jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[jsx("span",{style:{display:"inline-block",width:3,height:14,borderRadius:2,background:l.stroke??l.color,flexShrink:0}}),jsx("span",{style:{color:"#9ca3af",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:120},children:n.get(l.dataKey)??l.dataKey}),jsx("span",{style:{color:"#f9fafb",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:l.value!=null?Xs(l.value):"--"})]},l.dataKey))]})}function pm({markets:e,selectedSlugs:t,colorMap:r,onToggle:n}){let[o,i]=useState(false),s=useRef(null);useEffect(()=>{if(!o)return;function c(d){s.current&&!s.current.contains(d.target)&&i(false);}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[o]);let a=t.length>=Vr,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(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:[l,jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{flexShrink:0,transform:o?"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"})})]}),o&&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 ",Vr," markets"]}),e.map((c,d)=>{let p=t.includes(c.slug),m=!p&&a,u=p&&t.length===1,f=r.get(c.slug)??"#6b7280",h=c.outcomes.find(v=>v.label.toLowerCase()==="yes")??c.outcomes[0],g=h?.price!=null?`${Math.round(h.price*100)}%`:null;return jsxs("button",{onClick:()=>{u||m||n(c.slug);},style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"7px 12px",border:"none",background:p?"rgba(255,255,255,0.05)":"transparent",cursor:m||u?"not-allowed":"pointer",opacity:m?.35:1,textAlign:"left",transition:"background 0.1s"},onMouseEnter:v=>{!m&&!u&&(v.currentTarget.style.background="rgba(255,255,255,0.07)");},onMouseLeave:v=>{v.currentTarget.style.background=p?"rgba(255,255,255,0.05)":"transparent";},children:[jsx("span",{style:{width:16,height:16,borderRadius:4,border:p?`2px solid ${f}`:"2px solid rgba(255,255,255,0.2)",background:p?`${f}30`:"transparent",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:p&&jsx("svg",{width:"9",height:"7",viewBox:"0 0 9 7",fill:"none",children:jsx("path",{d:"M1 3.5L3.5 6L8 1",stroke:f,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:f,flexShrink:0}}),jsx("span",{style:{color:p?"#f9fafb":"#9ca3af",fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c.outcomes?.[0]?.label??c.question}),g&&jsx("span",{style:{color:f,fontWeight:700,fontSize:12,flexShrink:0},children:g})]},c.id??`${d}-${c.slug}`)})]})]})}function mm({series:e,colorMap:t,displayValues:r}){return jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px 24px",padding:"0 2px"},children:e.map(n=>{let o=t.get(n.marketSlug)??"#6b7280",i=r.get(n.marketSlug);return jsxs("div",{style:{display:"inline-flex",alignItems:"flex-start",gap:6},children:[jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:o,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:n.label}),jsx("span",{style:{color:"#f9fafb",fontSize:14,fontWeight:700,lineHeight:"20px",fontVariantNumeric:"tabular-nums"},children:i!=null?Xs(i):"--"})]})]},n.marketSlug)})})}function fm(e){let t=Math.floor(e.length/2);return e.length%2===1?e[t]:(e[t-1]+e[t])/2}function gm(e,t){if(e.length<=t)return e;let r=[],n=e.length/t;for(let o=0;o<t;o++){let i=Math.floor(o*n),s=Math.min(Math.floor((o+1)*n),e.length),a=e.slice(i,s),l=a.map(c=>c.price).sort((c,d)=>c-d);r.push({timestamp:a[a.length-1].timestamp,price:fm(l)});}return r}function hm(e,t=200){if(e.length===0)return [];let r=e.map(a=>({...a,data:gm(a.data,t)})),n=new Set;r.forEach(a=>a.data.forEach(l=>n.add(l.timestamp)));let o=Array.from(n).sort((a,l)=>a-l),i=r.map(a=>{let l=new Map;return a.data.forEach(c=>l.set(c.timestamp,c.price)),{slug:a.marketSlug,map:l}}),s=new Map;return o.map(a=>{let l={timestamp:a};return i.forEach(({slug:c,map:d})=>{let p=d.get(a);if(p!==void 0)s.set(c,p),l[c]=p;else {let m=s.get(c);m!==void 0&&(l[c]=m);}}),l})}function Js(e){return jsx(Io,{children:jsx(vm,{...e})})}function vm({event:e,isLoading:t,className:r,volume:n,fillHeight:o=false}){let i=useMemo(()=>{let b=new Set;return (e.markets??[]).filter(y=>y.status!=="open"||b.has(y.slug)?false:(b.add(y.slug),true))},[e.markets]),s=useMemo(()=>[...i].sort((b,y)=>{let $=j=>(j.outcomes.find(J=>J.label.toLowerCase()==="yes")??j.outcomes[0])?.price??0;return $(y)-$(b)}),[i]),[a,l]=useState(()=>s.slice(0,Vr).map(b=>b.slug));useEffect(()=>{let b=new Set(i.map(y=>y.slug));l(y=>{let $=y.filter(j=>b.has(j));return $.length===y.length?y:$.length>0?$:s.slice(0,Vr).map(j=>j.slug)});},[i,s]);let[c,d]=useState(gn),p=useMemo(()=>{let b=new Map;return a.forEach((y,$)=>{b.set(y,Ys[$%Ys.length]);}),b},[a]),m=useMemo(()=>i.filter(b=>a.includes(b.slug)),[i,a]),{series:u,isLoading:f}=useMarketHistory(m,c),h=t||f,g=useMemo(()=>{if(u.length>0&&u.some($=>$.data.length>0))return u;let b=Date.now(),y=864e5;return m.map($=>{let J=($.outcomes?.find(ce=>ce.label.toLowerCase()==="yes")??$.outcomes?.[0])?.price??.5;return {marketSlug:$.slug,label:$.outcomes?.[0]?.label??$.question,data:[{timestamp:b-7*y,price:J},{timestamp:b,price:J}]}})},[u,m]),v=useMemo(()=>c===se.ONE_DAY?96:c===se.ONE_WEEK?168:c===se.ONE_MONTH?180:300,[c]),S=useMemo(()=>hm(g,v),[g,v]),w=useMemo(()=>{if(S.length===0)return [0,1];let b=1/0,y=-1/0;if(a.forEach(j=>{S.forEach(J=>{let ce=J[j];ce!=null&&(ce<b&&(b=ce),ce>y&&(y=ce));});}),!isFinite(b))return [0,1];let $=Math.max((y-b)*.15,.05);return [Math.max(0,b-$),Math.min(1,y+$)]},[S,a]),P=useMemo(()=>{let b=new Map;return g.forEach(y=>{y.data.length>0&&b.set(y.marketSlug,y.data[y.data.length-1].price);}),b},[g]),x=useMemo(()=>{let b=new Map;return g.forEach(y=>b.set(y.marketSlug,y.label)),b},[g]),E=useMemo(()=>g.map(b=>({slug:b.marketSlug,color:p.get(b.marketSlug)??"#6b7280"})),[g,p]),{wrapperRef:k,overlayRef:T,onMouseMove:B,onMouseLeave:R}=dm(),A=useCallback(b=>{l(y=>y.includes(b)?y.length<=1?y:y.filter($=>$!==b):y.length>=Vr?y:[...y,b]);},[]),[N,W]=useState(null),D=useRef(null),le=useRef(""),X=useRef(0),Y=!h&&S.length>0;return jsxs("div",{className:r,style:{display:"flex",flexDirection:"column",gap:12,...o?{height:"100%",minHeight:0}:null},children:[jsx(mm,{series:g,colorMap:p,displayValues:N??P}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,...o?{flex:1,minHeight:0}:null},children:[jsx("div",{ref:k,style:{width:"100%",userSelect:"none",position:"relative",...o?{flex:1,minHeight:240}:{height:300}},onMouseMove:Y?b=>{B(b),cancelAnimationFrame(X.current),X.current=requestAnimationFrame(()=>{W(D.current);});}:void 0,onMouseLeave:Y?()=>{R(),cancelAnimationFrame(X.current),le.current="",D.current=null,W(null);}:void 0,children:h?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"}})}):S.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:T,style:{position:"absolute",inset:0,opacity:0,pointerEvents:"none",zIndex:1}}),jsx(ResponsiveContainer,{width:"100%",height:"100%",children:jsxs(LineChart,{data:S,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:b=>sm(b,c),axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},minTickGap:70}),jsx(YAxis,{domain:w,tickFormatter:b=>`${Math.round(b*100)}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},width:40,tickCount:6}),jsx(Tooltip,{content:b=>{let y=b;if(y.active&&y.payload?.length){let $=y.payload.map(j=>`${j.dataKey}:${j.value}`).join(",");if($!==le.current){le.current=$;let j=new Map;y.payload.forEach(J=>{J.value!=null&&j.set(J.dataKey,J.value);}),D.current=j;}}return jsx(um,{...y,labelMap:x,allSeries:E,range:c})},cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},wrapperStyle:{zIndex:2},isAnimationActive:false}),g.map(b=>{let y=p.get(b.marketSlug)??"#6b7280";return jsx(Line,{type:"linear",dataKey:b.marketSlug,stroke:y,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:y},connectNulls:true,isAnimationActive:false},b.marketSlug)}),N==null&&S.length>0&&g.map(b=>{let y=S[S.length-1],$=y[b.marketSlug];if($==null)return null;let j=p.get(b.marketSlug)??"#6b7280";return jsx(ReferenceDot,{x:y.timestamp,y:$,ifOverflow:"extendDomain",shape:J=>{let{cx:ce,cy:xe}=J;return ce==null||xe==null?jsx("g",{}):jsxs("g",{children:[jsxs("circle",{cx:ce,cy:xe,r:6,fill:j,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:ce,cy:xe,r:3.5,fill:j})]})}},`pulse-${b.marketSlug}`)})]})})]})}),jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"6px 8px",marginTop:6},children:[n!=null&&n>0&&jsxs("span",{style:{color:"#6b7280",fontSize:12},children:[formatAmountInUsd(n)," vol"]}),jsx("div",{style:{flex:1,minWidth:0}}),jsx(cm,{value:c,onChange:d}),s.length>1&&jsx("div",{style:{width:"100%",display:"flex",alignItems:"center"},children:jsx(pm,{markets:s,selectedSlugs:a,colorMap:p,onToggle:A})})]})]})]})}function Fn(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function ea(e,t){let r=e.outcomes[t==="yes"?0:1];return r?.best_ask??r?.price}function _m(e){return `${parseFloat((e*100).toFixed(2))}%`}function ta(e){let t=e*100;return t<1&&t>0?"< 1":parseFloat(t.toFixed(2)).toString()}function Bn(e){return e.outcomes?.[0]?.label??e.question}function Im(e){switch(e){case "polymarket":return "Polymarket";case "kalshi":return "Kalshi";default:return e}}function jr(e){if(!e)return "\u2014";let t=new Date(e);if(isNaN(t.getTime()))return "\u2014";let r=t.toLocaleString("default",{month:"short"}),n=t.getDate(),o=t.getFullYear(),i=t.getHours().toString().padStart(2,"0"),s=t.getMinutes().toString().padStart(2,"0");return `${r} ${n}, ${o} ${i}:${s}`}function ra(e){let[t,r]=useState(0);if(useEffect(()=>{if(!e)return;r(Date.now());let d=setInterval(()=>r(Date.now()),1e3);return ()=>clearInterval(d)},[e]),!e||t===0)return null;let n=new Date(e).getTime();if(isNaN(n))return null;let o=n-t;if(o<=0)return null;let i=Math.floor(o/864e5),s=Math.floor(o%864e5/36e5),a=Math.floor(o%36e5/6e4),l=Math.floor(o%6e4/1e3),c=[];return i>0&&c.push(`${i}d`),c.push(`${String(s).padStart(2,"0")}h`),c.push(`${String(a).padStart(2,"0")}m`),c.push(`${String(l).padStart(2,"0")}s`),c.join(" ")}function na(e){if(!e)return null;let t=new Date(e);if(isNaN(t.getTime()))return null;let r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getDate().toString().padStart(2,"0"),s=t.getFullYear(),a=-t.getTimezoneOffset(),l=a>=0?"+":"-",c=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${s} (${l}${c})`}function aa({event:e,onTradeAction:t}){let{t:r}=useTranslation(),{ref:n,isCollapsed:o}=useScrollCollapse(),i=useMemo(()=>{let p=[...e.markets||[]],m=p.filter(f=>f.status==="open").sort((f,h)=>Fn(h)-Fn(f)),u=p.filter(f=>f.status!=="open").sort((f,h)=>Fn(h)-Fn(f));return [...m,...u]},[e.markets]),s=e.status==="closed"||e.status==="voided",a=ra(s?void 0:e.start_at),l=ra(s?void 0:e.end_at),c=na(e.start_at),d=na(e.end_at);return jsxs("div",{className:"w-full flex flex-col gap-y-4 lg:gap-y-6",children:[jsxs("div",{ref:n,className:`sticky top-0 z-30 flex items-center backdrop-blur-md transition-all duration-300 ${o?"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 ${o?"!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:[!o&&jsxs("div",{className:"flex items-center gap-1.5",children:[e.tags?.slice(0,3).map((p,m)=>jsxs(Fragment$1,{children:[m>0&&jsx("span",{className:"text-sm text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-sm text-neutral truncate",children:p.label})]},p.slug)),jsx(Fm,{source:e.source})]}),jsx("span",{className:`font-semibold truncate transition-all duration-300 ${o?"text-sm lg:text-base":"text-lg lg:text-xl"}`,children:e.title})]})]}),(a||l||s)&&jsx("div",{className:"flex items-center gap-x-2 text-xs lg:text-sm font-mono",children:s?d&&jsx("span",{className:"text-neutral",children:r("predict.event.endedAt",{time:d})}):a?jsxs(Fragment,{children:[jsx("span",{className:"text-foreground",children:r("predict.event.beginsIn",{time:a})}),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})}),d&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-neutral",children:d})]})]}):null}),jsx(Js,{event:e,volume:e.volume??void 0}),jsx(Om,{markets:i,onTradeAction:t}),jsx(Am,{markets:i,event:e})]})}var oa=5;function Om({markets:e,onTradeAction:t}){let{t:r}=useTranslation(),{isDesktop:n}=useScreen(),[o,i]=useState(false),[s,a]=useState(null),l=useMemo(()=>{let g=new Set;return e.filter(v=>g.has(v.slug)?false:(g.add(v.slug),true))},[e]),c=l.find(g=>g.status==="open")?.slug,[d,p]=useState(c?`${c}:yes`:null);if(l.length===0)return null;let m=l.length>oa,u=o?l:l.slice(0,oa),f=g=>{a(v=>v===g?null:g);},h=(g,v,S)=>{p(`${g.slug}:${v}`),n&&a(g.slug),t?.(g,v,S);};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:u.map((g,v)=>{let S=s===g.slug;return jsx(Dm,{market:g,activeYes:d===`${g.slug}:yes`,activeNo:d===`${g.slug}:no`,isExpanded:S,onToggleExpand:()=>f(g.slug),onTradeAction:h},g.id??`${v}-${g.slug}`)})})]}),m&&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:r(o?"predict.event.rules.collapse":"predict.event.moreMarketsLabel")}),jsx(ChevronDownIcon,{className:cn("h-4 w-4 transition-transform",o&&"rotate-180")})]})]})}function Dm({market:e,activeYes:t,activeNo:r,isExpanded:n,onToggleExpand:o,onTradeAction:i}){let{t:s}=useTranslation(),a=e.status==="open",l=e.volume?`${formatAmountInUsd(e.volume)} vol`:void 0,{data:c}=useRealtimeOrderbook({slug:e.slug,source:e.source},{enabled:a}),d=pickBestAsk(c,"yes")??ea(e,"yes")??0,p=pickBestAsk(c,"no")??ea(e,"no");return jsxs(Fragment,{children:[jsxs("tr",{className:"cursor-pointer border-b border-border text-xs hover:bg-content2 lg:text-base",onClick:o,role:"button",tabIndex:0,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),o());},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:Bn(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:Bn(e)}),l&&jsx("span",{className:"text-[8px] text-neutral lg:text-xxs",children:l})]})]})}),jsx("td",{className:"py-2 text-left text-foreground lg:text-center",children:_m(d)}),jsx("td",{className:"py-2 pr-1 lg:pr-2",children:a?jsxs("div",{className:"flex items-center justify-end gap-x-2",children:[jsx("button",{type:"button",className:cn("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all focus-visible:outline-2 focus-visible:outline-primary/40 focus-visible:outline-offset-2",t?"bg-primary text-primary-foreground":"bg-primary/10 text-primary"),onClick:m=>{m.stopPropagation(),i?.(e,"yes","buy");},children:s("predict.market.action.yes",{price:ta(d)})}),jsx("button",{type:"button",className:cn("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all focus-visible:outline-2 focus-visible:outline-primary/40 focus-visible:outline-offset-2",r?"bg-secondary text-secondary-foreground":"bg-secondary/10 text-secondary"),onClick:m=>{m.stopPropagation(),i?.(e,"no","buy");},children:p!=null?s("predict.market.action.no",{price:ta(p)}):s("predict.market.no")})]}):jsx("div",{className:"flex items-center justify-end",children:jsx("span",{className:cn("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",e.status==="closed"?"bg-neutral/10 text-neutral":e.status==="voided"?"bg-warning/10 text-warning":"bg-primary/10 text-primary"),children:e.status==="closed"?s("predict.event.status.closed"):e.status==="voided"?s("predict.event.status.voided"):s("predict.event.status.pending")})})})]}),n&&jsx("tr",{children:jsx("td",{colSpan:3,className:"pb-3",children:jsx("div",{className:"max-h-100 overflow-y-auto",children:jsx(qs,{market:e,outcome:r?"no":"yes",onTradeAction:i})})})})]})}function Am({markets:e,event:t}){let{t:r}=useTranslation(),[n,o]=useState(false),[i,s]=useState(false),[a,l]=useState(0),c=e.filter(u=>u.rules&&u.rules.length>0||u.description);if(c.length===0)return null;let d=c[a]??c[0],p=d.rules&&d.rules.length>0?d.rules.join(`
77
77
 
78
- `):d.description??"";if(!p)return null;let m=p.length>200&&!n?p.slice(0,200)+"...":p;return jsxs("div",{className:"flex flex-col gap-y-3",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-semibold text-foreground lg:text-base",children:r("predict.event.rules")}),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:On(d)})}),jsx(DropdownMenu,{"aria-label":"Select market rules",selectionMode:"single",selectedKeys:[String(a)],onAction:u=>{l(Number(u)),o(false);},classNames:{list:"gap-1"},itemClasses:{base:"rounded-md px-3 h-8"},children:c.map((u,f)=>jsx(DropdownItem,{className:cn$1(f===a?"bg-content2 text-foreground":"text-neutral","data-[hover=true]:bg-content2 data-[hover=true]:text-foreground"),children:On(u)},String(f)))})]})]}),jsx("div",{className:"text-xs text-foreground/80 lg:text-sm whitespace-pre-wrap",children:m}),p.length>200&&jsx("button",{type:"button",onClick:()=>o(u=>!u),className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors self-start",children:r(n?"predict.event.rules.collapse":"predict.event.showMore")}),jsxs("button",{type:"button",onClick:()=>s(u=>!u),className:"flex items-center justify-between w-full mt-2 text-xs font-medium text-neutral lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsx("span",{children:r("predict.event.timelineAndPayout")}),jsx(ChevronDownIcon,{className:cn$1("h-4 w-4 transition-transform",i&&"rotate-180")})]}),i&&jsxs(Fragment,{children:[jsx("div",{className:"flex flex-col",children:(()=>{let u=d.status,f=[];return d.created_at&&f.push({label:r("predict.event.timeline.created"),value:Ur(d.created_at),isActive:true}),f.push({label:r("predict.event.timeline.open"),value:Ur(d.start_at),isActive:u!=="pending"}),u==="voided"?f.push({label:r("predict.event.timeline.voided"),value:Ur(d.closed_at??d.end_at),isActive:true}):u==="closed"?f.push({label:r("predict.event.timeline.closed"),value:Ur(d.closed_at??d.end_at),isActive:true}):f.push({label:r("predict.event.timeline.close"),value:Ur(d.end_at),isActive:false}),f})().map((u,f,h)=>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 ${u.isActive?"border-primary bg-primary":"border-border bg-transparent"}`}),f<h.length-1&&jsx("div",{className:"w-px flex-1 bg-border"})]}),jsxs("div",{className:`flex flex-col ${f<h.length-1?"pb-4":""}`,children:[jsx("span",{className:"text-xs font-medium text-foreground lg:text-sm",children:u.label}),jsx("span",{className:"text-xs text-neutral lg:text-sm",children:u.value})]})]},u.label))}),jsxs("div",{className:"flex flex-wrap items-center gap-x-3 text-xxs text-neutral mt-2 lg:text-xs",children:[jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.event"),":"]})," ",jsx("span",{className:"text-foreground",children:t.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.market"),":"]})," ",jsx("span",{className:"text-foreground",children:d.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.source"),":"]})," ",jsx("span",{className:"text-foreground",children:xm(d.source)})]})]})]})]})}function Sm({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 Js({eventSlug:e,source:t,onTradeAction:r}){let{data:n,isLoading:o,error:i}=useEvent({slug:e,source:t});return o?jsx(zr,{}):i||!n?jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:i?.message||"Event not found"}):jsx(Xs,{event:n,onTradeAction:r})}var Mm={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}},Em={label:"Unknown",color:"rgb(156, 163, 175)",bgColor:"rgba(156, 163, 175, 0.12)",icon:null};function kt(e){return Mm[e]??Em}function Xb({source:e,className:t}){let r=kt(e);return jsxs("span",{className:cn$1("inline-flex items-center gap-x-1 rounded-md px-1.5 py-0.5 text-xs font-medium",t),style:{backgroundColor:r.bgColor,color:r.color},children:[r.icon,r.label]})}var ea="rgba(39,39,42,0.6)",Dm="rgba(63,63,70,0.8)";function Am(e){return e==null?"-":formatAmountInUsd(e)}function ra({eventSlug:e,source:t,limit:r=4,onEventClick:n,onEventHover:o}){let{t:i}=useTranslation(),{data:s,isLoading:a}=useSimilarEvents({slug:e,source:t,limit:r});return a||!s||s.length===0?null:jsxs("div",{className:"flex flex-col gap-y-3 mt-6 px-1 lg:px-0",children:[jsx("span",{style:{color:"#f4f4f5",fontSize:14,fontWeight:600},children:i("predict.similar.title")}),jsx("div",{className:"grid grid-cols-1 gap-2",children:s.map(l=>jsx(Fm,{event:l,onClick:n,onHover:o},`${l.source}-${l.slug}`))})]})}function Fm({event:e,onClick:t,onHover:r}){let{t:n}=useTranslation(),o=kt(e.source),i=useMemo(()=>Am(e.volume),[e.volume]),s=e.tags?.[0];return jsxs("button",{type:"button",onClick:()=>t?.(e),onMouseEnter:a=>{a.currentTarget.style.borderColor=Dm,r?.(e);},onMouseLeave:a=>{a.currentTarget.style.borderColor=ea;},style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",borderRadius:14,border:`1px solid ${ea}`,background:"rgba(24,24,27,0.4)",cursor:"pointer",textAlign:"left",width:"100%",transition:"border-color 0.2s"},className:"group",children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title?.[0]||"?",radius:"full",className:"size-9 shrink-0 bg-transparent",imgProps:{className:"object-cover"}}),jsxs("div",{style:{display:"flex",flexDirection:"column",minWidth:0,flex:1,gap:2},children:[jsx("span",{style:{fontSize:13,fontWeight:500,color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.title}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,color:o.color,flexShrink:0},children:[o.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase"},children:o.label})]}),jsx("span",{style:{color:"#52525b"},children:"\xB7"}),jsxs("span",{style:{color:"#a1a1aa"},children:[i," ",n("predict.event.volume")]}),s&&jsxs(Fragment,{children:[jsx("span",{style:{color:"#52525b"},children:"\xB7"}),jsx("span",{style:{color:"#71717a"},children:s.label})]})]})]}),jsx(ChevronRightIcon,{width:14,height:14,className:"shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",style:{color:"#71717a"}})]})}function An(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Sy({eventSlug:e,source:t,chain:r,walletAddress:n,onSimilarEventClick:o,onSimilarEventHover:i,onBack:s,renderActivitySection:a,onInsufficientBalance:l,slippageBps:c}){let{t:d}=useTranslation(),{isDesktop:p}=useScreen(),{onOpen:m}=useAsyncModal(_r),{onOpen:u}=useAsyncModal(go),{data:f,isLoading:h}=useEvent({slug:e,source:t}),g=useMemo(()=>{let k=[...f?.markets||[]],L=k.filter(D=>D.status==="open").sort((D,A)=>An(A)-An(D)),H=k.filter(D=>D.status!=="open").sort((D,A)=>An(A)-An(D));return [...L,...H]},[f?.markets]),[v,S]=useState(null),w=useCallback((k,L,H)=>{S(D=>({market:k,outcome:L,side:H,version:(D?.version??0)+1})),!p&&f&&(H==="sell"?u({params:{event:f,market:k,initialOutcome:L,chain:r,slippageBps:c}}):m({params:{event:f,market:k,initialOutcome:L,chain:r,slippageBps:c,onInsufficientBalance:l}}));},[p,f,r,c,m,u,l]),N=v?.market??g[0];if(h){let k=!!s;return p?jsxs("div",{className:"flex w-full max-w-6xl mx-auto gap-x-4 lg:gap-x-6",children:[jsx("div",{className:"min-w-0 flex-1 max-w-3xl",children:jsx(zr,{showBack:k})}),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(Cs,{})})})]}):jsx(zr,{showBack:k})}let x=v?`${v.market.slug}-${v.version}`:N?.slug??"default",T=v?.side==="sell";return jsxs("div",{className:"flex w-full flex-col gap-y-4 pb-12 lg:max-w-7xl lg:gap-y-8 lg:pb-16 mx-auto",children:[jsxs("div",{className:"flex w-full justify-center gap-4 pt-4 lg:gap-6",children:[jsxs("div",{className:"flex-auto min-w-0 flex flex-col gap-y-4 px-4 lg:gap-y-6 lg:px-0",children:[s&&jsx("div",{className:"flex items-center justify-between",children:jsx(Button,{as:"a",onPress:s,startContent:jsx(ChevronLeftIcon,{className:"h-4 w-4"}),className:"text-neutral bg-transparent h-5 min-h-5 gap-x-2 p-0 text-base w-auto min-w-auto",children:d("common.back")})}),jsx(Js,{eventSlug:e,source:t,onTradeAction:w})]}),jsxs("div",{className:"hidden flex-none w-md flex-col gap-y-4 lg:sticky lg:top-4 lg:flex lg:self-start",children:[N&&(T?jsx(Cn,{event:f,market:N,initialOutcome:v?.outcome,chain:r,slippageBps:c},x):jsx(xn,{event:f,market:N,initialOutcome:v?.outcome,chain:r,slippageBps:c,onInsufficientBalance:l},x)),f&&jsx(ra,{eventSlug:e,source:f.source,onEventClick:o,onEventHover:i})]})]}),f&&jsx("div",{className:"flex w-full flex-col",children:a?a({event:f,walletAddress:n}):jsx(ws,{event:f,walletAddress:n})}),jsx(bn,{}),jsx(ys,{}),jsx(os,{})]})}function oa(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Xm(e){switch(e){case ie.ONE_DAY:return {interval:"15m",limit:96};case ie.ONE_WEEK:return {interval:"1h",limit:168};case ie.ONE_MONTH:return {interval:"4h",limit:180};case ie.ALL:return {interval:"1d",limit:300};default:return {interval:"1h",limit:100}}}var Ty=e=>{let{candlestickMarketSlugs:t,chartRange:r=dn,source:n}=e,o=usePredictClient(),i=useMemo(()=>Xm(r),[r]),{data:s,isLoading:a,error:l}=useEvent({slug:e.eventSlug,source:n}),c=useMemo(()=>{if(!s?.markets)return [];let f=new Set,h=s.markets.filter(v=>f.has(v.slug)?false:(f.add(v.slug),true));return (t&&t.length>0?t.slice(0,4).map(v=>h.find(S=>S.slug===v)).filter(v=>v!==void 0):[...h].sort((v,S)=>oa(S)-oa(v)).slice(0,4)).map(v=>v.slug)},[t,s?.markets]),d=useQueries({queries:c.map(f=>({queryKey:candlesticksQueryKey(f,i),queryFn:()=>o.listCandlesticks(f,i),enabled:c.length>0}))}),p=d.some(f=>f.isLoading),m=useMemo(()=>{let f=new Map;return c.forEach((h,g)=>{let v=d[g]?.error;v&&f.set(h,v);}),f},[c,d]),u=useMemo(()=>{let f=new Map;return c.forEach((h,g)=>{let v=d[g]?.data;v&&f.set(h,v);}),f},[c,d]);return {event:s,isEventLoading:a,eventError:l,candlestickParams:i,candlesticks:u,isCandlesticksLoading:p,candlestickErrors:m}};var ef=10,tf=atomWithStorage("liberfi:predict_search_histories",[],void 0,{getOnInit:true});function Bn(){let[e,t]=useAtom(tf),r=useCallback(o=>{let i=o.trim();i&&t(s=>{let a=s.filter(l=>l!==i);return [i,...a].slice(0,ef)});},[t]),n=useCallback(()=>{t([]);},[t]);return {histories:e,addHistory:r,clearHistories:n}}function la({histories:e,onSelect:t,onClear:r,className:n}){let{t:o}=useTranslation();return e.length===0?null:jsxs("div",{className:cn$1("px-4 pb-4",n),children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-medium",children:o("predict.search.history")}),jsx(Button,{isIconOnly:true,size:"sm",className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsx(TrashIcon,{width:20,height:20})})]}),jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:e.map(i=>jsx(Chip,{size:"sm",variant:"bordered",className:cn$1("text-neutral","border-border border-1","cursor-pointer","hover:opacity-hover"),onClick:()=>t?.(i),children:i},i))})]})}function ca({onSelect:e,className:t}){let{histories:r,clearHistories:n}=Bn();return jsx(la,{className:cn$1(t),histories:r,onSelect:e,onClear:n})}function da({value:e,onValueChange:t,onClear:r,onEscape:n,className:o}){let{t:i}=useTranslation();return jsx("div",{className:o,children:jsx(StyledInput,{autoFocus:true,variant:"bordered",radius:"lg",value:e,onValueChange:t,placeholder:i("predict.search.placeholder"),classNames:{inputWrapper:["!bg-[rgba(39,39,42,0.6)]","!border-[rgba(63,63,70,0.5)]","data-[hover=true]:!bg-[rgba(39,39,42,1)]","group-data-[focus=true]:!bg-[rgba(39,39,42,1)]","group-data-[focus=true]:!border-[rgba(63,63,70,0.8)]"].join(" ")},startContent:jsx(SearchIcon,{width:20,height:20,className:"text-neutral"}),endContent:e?jsx(Button,{isIconOnly:true,className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsx(XCloseIcon,{width:20,height:20})}):jsx(Kbd,{className:"min-w-8 justify-center text-xs text-neutral bg-transparent border border-[rgba(63,63,70,0.5)] rounded-lg cursor-pointer select-none",onMouseDown:s=>{s.preventDefault(),n?.();},children:"Esc"})})})}function Sf(e){return e==null?"-":formatAmountInUsd(e)}function ua({event:e,href:t,LinkComponent:r,onSelect:n,onHover:o,className:i}){let{t:s}=useTranslation(),a=e.tags?.[0],l=kt(e.source),c=useMemo(()=>Sf(e.volume),[e.volume]);return jsxs(Linkable,{href:t,LinkComponent:r,className:cn$1("group w-full h-full px-3 flex items-center gap-3","hover:cursor-pointer hover:bg-content2 rounded-lg","transition-colors duration-150",i),onClick:d=>{t&&n&&d.preventDefault(),n?.(e);},onMouseEnter:()=>o?.(e),children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"full",className:"h-10 w-10 flex-shrink-0"}),jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-center gap-y-0.5",children:[jsx("span",{className:"min-w-0 text-sm font-medium line-clamp-2 group-hover:text-primary transition-colors",children:e.title}),jsxs("div",{className:"flex items-center gap-x-2 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[jsxs("span",{className:"inline-flex items-center gap-x-1 shrink-0",style:{color:l.color},children:[l.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase"},children:l.label})]}),jsx("span",{className:"text-neutral-600",children:"\xB7"}),jsxs("span",{className:"text-neutral-400",children:[c," ",s("predict.event.volume")]}),a&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral-600",children:"\xB7"}),jsx("span",{className:"text-neutral-500",children:a.label})]})]})]}),jsx(ChevronRightIcon,{width:16,height:16,className:"shrink-0 text-neutral-500 opacity-0 group-hover:opacity-100 transition-opacity"})]})}function pa({keyword:e="",limit:t,source:r}){let{data:n,isLoading:o,isFetchingNextPage:i,hasNextPage:s,fetchNextPage:a}=useSearchEvents({keyword:e,limit:t,source:r,sort_by:e?void 0:"volume",sort_asc:e?void 0:false},{enabled:true});return {events:useMemo(()=>n?.pages.flatMap(c=>c.items).filter(c=>c!=null)??[],[n]),isLoading:o,isFetchingNextPage:i,hasNextPage:s??false,fetchNextPage:a}}var _f=64;function ha({onSelect:e,getEventHref:t,LinkComponent:r,onHover:n,className:o,...i}){let{events:s,isLoading:a,isFetchingNextPage:l,hasNextPage:c,fetchNextPage:d}=pa(i),p=useRef(null),{height:m}=useResizeObserver({ref:p}),u=useCallback(v=>v<s.length,[s]),f=useCallback(async()=>{c&&!l&&await d();},[c,l,d]),h=useMemo(()=>c?s.length+1:s.length,[s,c]),g=useInfiniteLoader({isRowLoaded:u,loadMoreRows:f,rowCount:h,threshold:5});return a?jsx(Of,{className:o}):s.length===0?jsx(Df,{className:o}):jsx("div",{className:cn$1("w-full h-full flex flex-col",o),children:jsx("div",{className:"flex-auto min-h-0",ref:p,children:jsx(List,{className:"no-scrollbar",style:{height:m},onRowsRendered:g,rowComponent:If,rowCount:h,rowHeight:_f,rowProps:{events:s,onSelect:e,getEventHref:t,LinkComponent:r,onHover:n},overscanCount:5})})})}function If({index:e,style:t,events:r,onSelect:n,getEventHref:o,LinkComponent:i,onHover:s}){let a=r[e];return a?jsx("div",{style:t,children:jsx(ua,{event:a,href:o?.(a),LinkComponent:i,onSelect:n,onHover:s})}):jsx("div",{style:t,className:"flex items-center justify-center",children:jsx(Spinner,{size:"sm"})})}function Of({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 Df({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 ya({onKeywordChange:e}){let[t,r]=useState(""),[n,o]=useState(""),{addHistory:i}=Bn(),s=useCallbackRef(e),a=useCallbackRef(i),l=useMemo(()=>debounce(m=>{o(m),s(m),m&&a(m);},500),[s,a]),c=useCallback(m=>{r(m),l(m);},[l]),d=useCallback(m=>{l.cancel(),r(m),o(m),s(m),m&&a(m);},[l,s,a]),p=useCallback(()=>d(""),[d]);return {text:t,keyword:n,setText:c,setKeyword:d,clearKeyword:p}}function ka({onKeywordChange:e,onSelectEvent:t,getEventHref:r,LinkComponent:n,onHover:o,onEscape:i,source:s}){let{text:a,keyword:l,setText:c,setKeyword:d,clearKeyword:p}=ya({onKeywordChange:e});return jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsx(da,{value:a,onValueChange:c,onClear:p,onEscape:i}),!l&&jsx(ca,{onSelect:d}),jsx(ha,{className:"flex-auto min-h-0",keyword:l,onSelect:t,getEventHref:r,LinkComponent:n,onHover:o,source:s})]})}var _o="predict-search";function o2({id:e=_o}){return jsx(AsyncModal,{id:e,children:t=>jsx(qf,{...t})})}function qf({params:e,isOpen:t,onOpenChange:r,onResult:n}){let{t:o}=useTranslation(),{isMobile:i}=useScreen(),s=useCallback(l=>{n(l);},[n]),a=useCallback(()=>{r(false);},[r]);return jsx(StyledModal,{isOpen:t,onOpenChange:r,size:i?"full":"lg",hideCloseButton:true,backdrop:"blur",radius:"lg",children:jsxs(ModalContent,{className:"w-full h-full",style:{borderRadius:i?void 0:14,border:i?void 0:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:i?void 0:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"},children:[jsxs(ModalHeader,{className:"sm:hidden flex items-center justify-between pt-4 pb-2",children:[jsx("span",{className:"text-base font-semibold",children:o("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(ka,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectEvent:s,onEscape:a})})]})})}function m2({onSelectEvent:e,modalParams:t,className:r}){let{t:n}=useTranslation(),{isDesktop:o}=useScreen(),{onOpen:i,onClose:s}=useAsyncModal(_o),a=useCallbackRef(e),l=useCallbackRef(async()=>{let d=await i({params:t});d&&a(d);}),c=useCallbackRef(()=>{s();});return useEffect(()=>{let d=p=>{let m=document.activeElement,u=!!m&&(m.tagName==="INPUT"||m.tagName==="TEXTAREA"||m.getAttribute("contenteditable")==="true");p.key==="/"&&!u&&(p.preventDefault(),l()),p.key==="Escape"&&(p.preventDefault(),c());};return window.addEventListener("keydown",d),()=>{window.removeEventListener("keydown",d);}},[l,c]),o?jsx(Button,{size:"sm",radius:"full",onPress:l,variant:"bordered",startContent:jsx(SearchIcon,{width:16,height:16,className:"text-foreground"}),endContent:jsx(Kbd,{className:"min-w-6 justify-center text-xs text-foreground bg-content3 rounded-lg",children:"/"}),className:cn$1("w-56 min-w-0 h-8 min-h-0 border-transparent hover:border-border bg-content2 pl-3 pr-1.5 text-neutral",r),children:n("predict.search.placeholder")}):jsx(Button,{size:"sm",radius:"full",isIconOnly:true,onPress:l,variant:"bordered",className:cn$1("w-8 min-w-0 h-8 min-h-0 border-1 border-border bg-content2",r),children:jsx(SearchIcon,{width:16,height:16,className:"text-foreground"})})}var Oo=[{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"}],_a=[{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}],Ta={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"},La={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 rg(e,t){if(!e)return "$5K+";let r=_a.find(n=>n.value===e);return r?r.labelKey?t(r.labelKey):r.label:`$${e}`}function Ia({sortBy:e,onSortChange:t,sortAsc:r,onSortAscChange:n,minVolume:o,onMinVolumeChange:i,onRefresh:s}){let{t:a}=useTranslation(),[l,c]=useState(false),[d,p]=useState(false),[m,u]=useState(false),[f,h]=useState(false),g=useRef(null),v=useRef(null),S=Oo.find(x=>x.value===e)??Oo[0],w=useCallback(x=>{g.current&&!g.current.contains(x.target)&&c(false),v.current&&!v.current.contains(x.target)&&p(false);},[]);useEffect(()=>(document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)),[w]);let N=useCallback(()=>{s?.(),h(true),setTimeout(()=>h(false),700);},[s]);return jsxs(Fragment,{children:[jsx("style",{children:`
78
+ `):d.description??"";if(!p)return null;let m=p.length>200&&!n?p.slice(0,200)+"...":p;return jsxs("div",{className:"flex flex-col gap-y-3",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-semibold text-foreground lg:text-base",children:r("predict.event.rules")}),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:Bn(d)})}),jsx(DropdownMenu,{"aria-label":"Select market rules",selectionMode:"single",selectedKeys:[String(a)],onAction:u=>{l(Number(u)),o(false);},classNames:{list:"gap-1"},itemClasses:{base:"rounded-md px-3 h-8"},children:c.map((u,f)=>jsx(DropdownItem,{className:cn(f===a?"bg-content2 text-foreground":"text-neutral","data-[hover=true]:bg-content2 data-[hover=true]:text-foreground"),children:Bn(u)},String(f)))})]})]}),jsx("div",{className:"text-xs text-foreground/80 lg:text-sm whitespace-pre-wrap",children:m}),p.length>200&&jsx("button",{type:"button",onClick:()=>o(u=>!u),className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors self-start",children:r(n?"predict.event.rules.collapse":"predict.event.showMore")}),jsxs("button",{type:"button",onClick:()=>s(u=>!u),className:"flex items-center justify-between w-full mt-2 text-xs font-medium text-neutral lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsx("span",{children:r("predict.event.timelineAndPayout")}),jsx(ChevronDownIcon,{className:cn("h-4 w-4 transition-transform",i&&"rotate-180")})]}),i&&jsxs(Fragment,{children:[jsx("div",{className:"flex flex-col",children:(()=>{let u=d.status,f=[];return d.created_at&&f.push({label:r("predict.event.timeline.created"),value:jr(d.created_at),isActive:true}),f.push({label:r("predict.event.timeline.open"),value:jr(d.start_at),isActive:u!=="pending"}),u==="voided"?f.push({label:r("predict.event.timeline.voided"),value:jr(d.closed_at??d.end_at),isActive:true}):u==="closed"?f.push({label:r("predict.event.timeline.closed"),value:jr(d.closed_at??d.end_at),isActive:true}):f.push({label:r("predict.event.timeline.close"),value:jr(d.end_at),isActive:false}),f})().map((u,f,h)=>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 ${u.isActive?"border-primary bg-primary":"border-border bg-transparent"}`}),f<h.length-1&&jsx("div",{className:"w-px flex-1 bg-border"})]}),jsxs("div",{className:`flex flex-col ${f<h.length-1?"pb-4":""}`,children:[jsx("span",{className:"text-xs font-medium text-foreground lg:text-sm",children:u.label}),jsx("span",{className:"text-xs text-neutral lg:text-sm",children:u.value})]})]},u.label))}),jsxs("div",{className:"flex flex-wrap items-center gap-x-3 text-xxs text-neutral mt-2 lg:text-xs",children:[jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.event"),":"]})," ",jsx("span",{className:"text-foreground",children:t.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.market"),":"]})," ",jsx("span",{className:"text-foreground",children:d.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.source"),":"]})," ",jsx("span",{className:"text-foreground",children:Im(d.source)})]})]})]})]})}function Fm({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 la({eventSlug:e,source:t,onTradeAction:r}){let{data:n,isLoading:o,error:i}=useEvent({slug:e,source:t});return o?jsx($r,{}):i||!n?jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:i?.message||"Event not found"}):jsx(aa,{event:n,onTradeAction:r})}var Um={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}},$m={label:"Unknown",color:"rgb(156, 163, 175)",bgColor:"rgba(156, 163, 175, 0.12)",icon:null};function St(e){return Um[e]??$m}function Ay({source:e,className:t}){let r=St(e);return jsxs("span",{className:cn("inline-flex items-center gap-x-1 rounded-md px-1.5 py-0.5 text-xs font-medium",t),style:{backgroundColor:r.bgColor,color:r.color},children:[r.icon,r.label]})}var da="rgba(39,39,42,0.6)",Qm="rgba(63,63,70,0.8)";function Xm(e){return e==null?"-":formatAmountInUsd(e)}function pa({eventSlug:e,source:t,limit:r=4,onEventClick:n,onEventHover:o}){let{t:i}=useTranslation(),{data:s,isLoading:a}=useSimilarEvents({slug:e,source:t,limit:r});return a||!s||s.length===0?null:jsxs("div",{className:"flex flex-col gap-y-3 mt-6 px-1 lg:px-0",children:[jsx("span",{style:{color:"#f4f4f5",fontSize:14,fontWeight:600},children:i("predict.similar.title")}),jsx("div",{className:"grid grid-cols-1 gap-2",children:s.map(l=>jsx(Jm,{event:l,onClick:n,onHover:o},`${l.source}-${l.slug}`))})]})}function Jm({event:e,onClick:t,onHover:r}){let{t:n}=useTranslation(),o=St(e.source),i=useMemo(()=>Xm(e.volume),[e.volume]),s=e.tags?.[0];return jsxs("button",{type:"button",onClick:()=>t?.(e),onMouseEnter:a=>{a.currentTarget.style.borderColor=Qm,r?.(e);},onMouseLeave:a=>{a.currentTarget.style.borderColor=da;},style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",borderRadius:14,border:`1px solid ${da}`,background:"rgba(24,24,27,0.4)",cursor:"pointer",textAlign:"left",width:"100%",transition:"border-color 0.2s"},className:"group",children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title?.[0]||"?",radius:"full",className:"size-9 shrink-0 bg-transparent",imgProps:{className:"object-cover"}}),jsxs("div",{style:{display:"flex",flexDirection:"column",minWidth:0,flex:1,gap:2},children:[jsx("span",{style:{fontSize:13,fontWeight:500,color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.title}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,color:o.color,flexShrink:0},children:[o.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase"},children:o.label})]}),jsx("span",{style:{color:"#52525b"},children:"\xB7"}),jsxs("span",{style:{color:"#a1a1aa"},children:[i," ",n("predict.event.volume")]}),s&&jsxs(Fragment,{children:[jsx("span",{style:{color:"#52525b"},children:"\xB7"}),jsx("span",{style:{color:"#71717a"},children:s.label})]})]})]}),jsx(ChevronRightIcon,{width:14,height:14,className:"shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",style:{color:"#71717a"}})]})}function zn(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function a1({eventSlug:e,source:t,chain:r,walletAddress:n,onSimilarEventClick:o,onSimilarEventHover:i,onBack:s,renderActivitySection:a,onInsufficientBalance:l,slippageBps:c}){let{t:d}=useTranslation(),{isDesktop:p}=useScreen(),{onOpen:m}=useAsyncModal(Dr),{onOpen:u}=useAsyncModal(So),{data:f,isLoading:h}=useEvent({slug:e,source:t}),g=useMemo(()=>{let k=[...f?.markets||[]],T=k.filter(R=>R.status==="open").sort((R,A)=>zn(A)-zn(R)),B=k.filter(R=>R.status!=="open").sort((R,A)=>zn(A)-zn(R));return [...T,...B]},[f?.markets]),[v,S]=useState(null),w=useCallback((k,T,B)=>{S(R=>({market:k,outcome:T,side:B,version:(R?.version??0)+1})),!p&&f&&(B==="sell"?u({params:{event:f,market:k,initialOutcome:T,chain:r,slippageBps:c}}):m({params:{event:f,market:k,initialOutcome:T,chain:r,slippageBps:c,onInsufficientBalance:l}}));},[p,f,r,c,m,u,l]),P=v?.market??g[0];if(h){let k=!!s;return p?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($r,{showBack:k})}),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(Ds,{})})})]}):jsx($r,{showBack:k})}let x=v?`${v.market.slug}-${v.version}`:P?.slug??"default",E=v?.side==="sell";return jsxs("div",{className:"flex w-full flex-col gap-y-4 pb-12 lg:max-w-7xl lg:gap-y-8 lg:pb-16 mx-auto",children:[jsxs("div",{className:"flex w-full justify-center gap-4 pt-4 lg:gap-6",children:[jsxs("div",{className:"flex-auto min-w-0 flex flex-col gap-y-4 px-4 lg:gap-y-6 lg:px-0",children:[s&&jsx("div",{className:"flex items-center justify-between",children:jsx(Button,{as:"a",onPress:s,startContent:jsx(ChevronLeftIcon,{className:"h-4 w-4"}),className:"text-neutral bg-transparent h-5 min-h-5 gap-x-2 p-0 text-base w-auto min-w-auto",children:d("common.back")})}),jsx(la,{eventSlug:e,source:t,onTradeAction:w})]}),jsxs("div",{className:"hidden flex-none w-md flex-col gap-y-4 lg:sticky lg:top-4 lg:flex lg:self-start",children:[P&&(E?jsx(Rn,{event:f,market:P,initialOutcome:v?.outcome,chain:r,slippageBps:c},x):jsx(wn,{event:f,market:P,initialOutcome:v?.outcome,chain:r,slippageBps:c,onInsufficientBalance:l},x)),f&&jsx(pa,{eventSlug:e,source:f.source,onEventClick:o,onEventHover:i})]})]}),f&&jsx("div",{className:"flex w-full flex-col",children:a?a({event:f,walletAddress:n}):jsx(_s,{event:f,walletAddress:n})}),jsx(Nn,{}),jsx(Ts,{}),jsx(ms,{})]})}function fa(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function mf(e){switch(e){case se.ONE_DAY:return {interval:"15m",limit:96};case se.ONE_WEEK:return {interval:"1h",limit:168};case se.ONE_MONTH:return {interval:"4h",limit:180};case se.ALL:return {interval:"1d",limit:300};default:return {interval:"1h",limit:100}}}var f1=e=>{let{candlestickMarketSlugs:t,chartRange:r=gn,source:n}=e,o=usePredictClient(),i=useMemo(()=>mf(r),[r]),{data:s,isLoading:a,error:l}=useEvent({slug:e.eventSlug,source:n}),c=useMemo(()=>{if(!s?.markets)return [];let f=new Set,h=s.markets.filter(v=>f.has(v.slug)?false:(f.add(v.slug),true));return (t&&t.length>0?t.slice(0,4).map(v=>h.find(S=>S.slug===v)).filter(v=>v!==void 0):[...h].sort((v,S)=>fa(S)-fa(v)).slice(0,4)).map(v=>v.slug)},[t,s?.markets]),d=useQueries({queries:c.map(f=>({queryKey:candlesticksQueryKey(f,i),queryFn:()=>o.listCandlesticks(f,i),enabled:c.length>0}))}),p=d.some(f=>f.isLoading),m=useMemo(()=>{let f=new Map;return c.forEach((h,g)=>{let v=d[g]?.error;v&&f.set(h,v);}),f},[c,d]),u=useMemo(()=>{let f=new Map;return c.forEach((h,g)=>{let v=d[g]?.data;v&&f.set(h,v);}),f},[c,d]);return {event:s,isEventLoading:a,eventError:l,candlestickParams:i,candlesticks:u,isCandlesticksLoading:p,candlestickErrors:m}};function Ao({comment:e,anonymousLabel:t,isReply:r=false}){let{profile:n}=e,o=n.name||n.pseudonym||t,i=useMemo(()=>vf(e.created_at),[e.created_at]);return jsxs("div",{className:cn("flex gap-x-2.5 px-1 py-3 border-b border-border/40 lg:px-2",r&&"pl-8 lg:pl-9"),children:[jsx(ff,{src:n.profile_image,name:o,className:cn("shrink-0",r?"size-6":"size-8 lg:size-7")}),jsxs("div",{className:"min-w-0 flex-1",children:[jsxs("div",{className:"flex items-baseline gap-x-2",children:[jsx("span",{className:"truncate text-sm font-medium text-foreground",children:o}),jsx("span",{className:"ml-auto shrink-0 text-xs text-neutral",children:i})]}),jsx("p",{className:"mt-1 whitespace-pre-wrap break-words text-sm leading-relaxed text-foreground/90",children:e.body}),jsxs("div",{className:"mt-2 flex items-center gap-x-1 text-neutral",children:[jsx(gf,{className:"size-3.5"}),jsx("span",{className:"text-xs tabular-nums",children:e.reaction_count})]})]})]})}function ff({src:e,name:t,className:r}){let n=t.trim().charAt(0).toUpperCase()||"?",o=useMemo(()=>hf(t),[t]);return e?jsx("img",{src:e,alt:t,loading:"lazy",className:cn("rounded-full object-cover",r)}):jsx("span",{className:cn("flex items-center justify-center rounded-full text-xs font-semibold text-white",r),style:{backgroundColor:o},"aria-hidden":true,children:n})}function gf({className:e}){return jsx("svg",{viewBox:"0 0 24 24",className:e,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":true,children:jsx("path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z"})})}function hf(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t);return `hsl(${Math.abs(t)%360}, 55%, 45%)`}function vf(e){let t=new Date(e).getTime();if(Number.isNaN(t))return "";let r=Math.max(0,Math.floor((Date.now()-t)/1e3));if(r<60)return "now";let n=Math.floor(r/60);if(n<60)return `${n}m`;let o=Math.floor(n/60);if(o<24)return `${o}h`;let i=Math.floor(o/24);if(i<7)return `${i}d`;let s=Math.floor(i/7);return s<5?`${s}w`:new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}var Mf={latest:{order:"createdAt",ascending:false},oldest:{order:"createdAt",ascending:true},mostLiked:{order:"reactionCount",ascending:false}},va={latest:"predict.comments.sortLatest",oldest:"predict.comments.sortOldest",mostLiked:"predict.comments.sortMostLiked"},Ef=["latest","oldest","mostLiked"],Tf=600,Lf=112;function Rf({slug:e,source:t,limit:r=20,height:n,className:o}){let{t:i}=useTranslation(),[s,a]=useState("latest"),[l,c]=useState(false),d=Mf[s],{data:p,isLoading:m,isFetchingNextPage:u,hasNextPage:f,fetchNextPage:h}=useInfiniteComments({slug:e,source:t,limit:r,order:d.order,ascending:d.ascending,holders_only:l}),g=useMemo(()=>p?.pages?.flatMap(R=>R.items)??[],[p?.pages]),v=useRef(null),{height:S}=useResizeObserver({ref:v}),w=n??(S||Tf),P=useDynamicRowHeight({defaultRowHeight:Lf,key:`${e}:${t}:${s}:${l}`}),x=g.length,E=x+(f?1:0),k=useCallback(R=>R<x,[x]),T=useCallback(async()=>{f&&!u&&await h();},[f,u,h]),B=useInfiniteLoader({isRowLoaded:k,loadMoreRows:T,rowCount:E,threshold:5});return jsxs("div",{className:cn("flex h-full w-full flex-col",o),children:[jsx(If,{sort:s,onSortChange:a,holdersOnly:l,onHoldersOnlyChange:c}),jsx("div",{className:"min-h-0 flex-auto overflow-hidden",ref:v,children:m?jsx(Of,{}):g.length===0?jsx(Df,{message:i("predict.comments.empty")}):jsx(List,{className:"no-scrollbar",style:{height:w},onRowsRendered:B,rowComponent:_f,rowCount:E,rowHeight:P,rowProps:{comments:g,itemCount:x,anonymousLabel:i("predict.comments.anonymous")},overscanCount:4})})]})}function _f({index:e,style:t,comments:r,itemCount:n,anonymousLabel:o}){if(e>=n)return jsx("div",{style:t,className:"flex items-center justify-center py-4",children:jsx(Spinner,{size:"sm"})});let i=r[e];return i?jsx("div",{style:t,children:jsx(Ao,{comment:i,anonymousLabel:o,isReply:!!i.parent_comment_id})}):null}function If({sort:e,onSortChange:t,holdersOnly:r,onHoldersOnlyChange:n}){let{t:o}=useTranslation(),[i,s]=useState(false),a=useRef(null);return useEffect(()=>{if(!i)return;let l=d=>{a.current&&!a.current.contains(d.target)&&s(false);},c=d=>{d.key==="Escape"&&s(false);};return document.addEventListener("mousedown",l),document.addEventListener("keydown",c),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",c);}},[i]),jsxs("div",{className:"flex items-center justify-between gap-2 px-1 py-2 lg:px-2",children:[jsxs("div",{ref:a,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>s(l=>!l),className:"inline-flex items-center gap-x-1.5 rounded-lg border border-border bg-content2/40 px-3 py-1.5 text-sm text-foreground transition-colors hover:bg-content2 cursor-pointer",children:[jsx(Af,{className:"size-3.5 text-neutral"}),jsx("span",{children:o(va[e])}),jsx(Ff,{className:cn("size-3.5 text-neutral transition-transform",i&&"rotate-180")})]}),i&&jsx("div",{className:"absolute left-0 top-full z-20 mt-1.5 min-w-40 overflow-hidden rounded-xl border border-border bg-content1 p-1 shadow-xl",children:Ef.map(l=>{let c=l===e;return jsxs("button",{type:"button",onClick:()=>{t(l),s(false);},className:cn("flex w-full items-center gap-x-2 rounded-lg px-3 py-2 text-left text-sm transition-colors cursor-pointer",c?"bg-primary/10 text-primary":"text-neutral hover:bg-content2 hover:text-foreground"),children:[jsx("span",{className:"flex-1 font-medium",children:o(va[l])}),c&&jsx(xa,{className:"size-4 text-primary"})]},l)})})]}),jsxs("button",{type:"button",role:"switch","aria-checked":r,onClick:()=>n(!r),className:cn("inline-flex items-center gap-x-1.5 rounded-lg border px-3 py-1.5 text-sm transition-colors cursor-pointer",r?"border-primary/40 bg-primary/10 text-primary":"border-border bg-content2/40 text-neutral hover:text-foreground"),children:[jsx("span",{className:cn("flex size-4 items-center justify-center rounded border",r?"border-primary bg-primary":"border-neutral"),children:r&&jsx(xa,{className:"size-3 text-background"})}),o("predict.comments.holdersOnly")]})]})}function Of(){return jsx("div",{className:"flex flex-col gap-y-4 px-1 py-3 lg:px-2",children:Array.from({length:6}).map((e,t)=>jsxs("div",{className:"flex gap-x-2.5",children:[jsx(Skeleton,{className:"size-8 shrink-0 rounded-full"}),jsxs("div",{className:"flex-1 space-y-2",children:[jsx(Skeleton,{className:"h-3 w-24 rounded"}),jsx(Skeleton,{className:"h-3 w-full rounded"}),jsx(Skeleton,{className:"h-3 w-2/3 rounded"})]})]},t))})}function Df({message:e}){return jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[jsx(EmptyIcon,{width:28,height:28,className:"text-neutral"}),jsx("p",{className:"mt-2 text-sm text-neutral",children:e})]})}function Af({className:e}){return jsxs("svg",{viewBox:"0 0 24 24",className:e,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":true,children:[jsx("path",{d:"m21 16-4 4-4-4"}),jsx("path",{d:"M17 20V4"}),jsx("path",{d:"m3 8 4-4 4 4"}),jsx("path",{d:"M7 4v16"})]})}function Ff({className:e}){return jsx("svg",{viewBox:"0 0 24 24",className:e,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":true,children:jsx("path",{d:"m6 9 6 6 6-6"})})}function xa({className:e}){return jsx("svg",{viewBox:"0 0 24 24",className:e,fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":true,children:jsx("path",{d:"M20 6 9 17l-5-5"})})}var zf=10,Wf=atomWithStorage("liberfi:predict_search_histories",[],void 0,{getOnInit:true});function Vn(){let[e,t]=useAtom(Wf),r=useCallback(o=>{let i=o.trim();i&&t(s=>{let a=s.filter(l=>l!==i);return [i,...a].slice(0,zf)});},[t]),n=useCallback(()=>{t([]);},[t]);return {histories:e,addHistory:r,clearHistories:n}}function Na({histories:e,onSelect:t,onClear:r,className:n}){let{t:o}=useTranslation();return e.length===0?null:jsxs("div",{className:cn("px-4 pb-4",n),children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-medium",children:o("predict.search.history")}),jsx(Button,{isIconOnly:true,size:"sm",className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsx(TrashIcon,{width:20,height:20})})]}),jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:e.map(i=>jsx(Chip,{size:"sm",variant:"bordered",className:cn("text-neutral","border-border border-1","cursor-pointer","hover:opacity-hover"),onClick:()=>t?.(i),children:i},i))})]})}function Pa({onSelect:e,className:t}){let{histories:r,clearHistories:n}=Vn();return jsx(Na,{className:cn(t),histories:r,onSelect:e,onClear:n})}function Ca({value:e,onValueChange:t,onClear:r,onEscape:n,className:o}){let{t:i}=useTranslation();return jsx("div",{className:o,children:jsx(StyledInput,{autoFocus:true,variant:"bordered",radius:"lg",value:e,onValueChange:t,placeholder:i("predict.search.placeholder"),classNames:{inputWrapper:["!bg-[rgba(39,39,42,0.6)]","!border-[rgba(63,63,70,0.5)]","data-[hover=true]:!bg-[rgba(39,39,42,1)]","group-data-[focus=true]:!bg-[rgba(39,39,42,1)]","group-data-[focus=true]:!border-[rgba(63,63,70,0.8)]"].join(" ")},startContent:jsx(SearchIcon,{width:20,height:20,className:"text-neutral"}),endContent:e?jsx(Button,{isIconOnly:true,className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsx(XCloseIcon,{width:20,height:20})}):jsx(Kbd,{className:"min-w-8 justify-center text-xs text-neutral bg-transparent border border-[rgba(63,63,70,0.5)] rounded-lg cursor-pointer select-none",onMouseDown:s=>{s.preventDefault(),n?.();},children:"Esc"})})})}function ag(e){return e==null?"-":formatAmountInUsd(e)}function Ma({event:e,href:t,LinkComponent:r,onSelect:n,onHover:o,className:i}){let{t:s}=useTranslation(),a=e.tags?.[0],l=St(e.source),c=useMemo(()=>ag(e.volume),[e.volume]);return jsxs(Linkable,{href:t,LinkComponent:r,className:cn("group w-full h-full px-3 flex items-center gap-3","hover:cursor-pointer hover:bg-content2 rounded-lg","transition-colors duration-150",i),onClick:d=>{t&&n&&d.preventDefault(),n?.(e);},onMouseEnter:()=>o?.(e),children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"full",className:"h-10 w-10 flex-shrink-0"}),jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-center gap-y-0.5",children:[jsx("span",{className:"min-w-0 text-sm font-medium line-clamp-2 group-hover:text-primary transition-colors",children:e.title}),jsxs("div",{className:"flex items-center gap-x-2 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[jsxs("span",{className:"inline-flex items-center gap-x-1 shrink-0",style:{color:l.color},children:[l.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase"},children:l.label})]}),jsx("span",{className:"text-neutral-600",children:"\xB7"}),jsxs("span",{className:"text-neutral-400",children:[c," ",s("predict.event.volume")]}),a&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral-600",children:"\xB7"}),jsx("span",{className:"text-neutral-500",children:a.label})]})]})]}),jsx(ChevronRightIcon,{width:16,height:16,className:"shrink-0 text-neutral-500 opacity-0 group-hover:opacity-100 transition-opacity"})]})}function Ea({keyword:e="",limit:t,source:r}){let{data:n,isLoading:o,isFetchingNextPage:i,hasNextPage:s,fetchNextPage:a}=useSearchEvents({keyword:e,limit:t,source:r,sort_by:e?void 0:"volume",sort_asc:e?void 0:false},{enabled:true});return {events:useMemo(()=>n?.pages.flatMap(c=>c.items).filter(c=>c!=null)??[],[n]),isLoading:o,isFetchingNextPage:i,hasNextPage:s??false,fetchNextPage:a}}var vg=64;function _a({onSelect:e,getEventHref:t,LinkComponent:r,onHover:n,className:o,...i}){let{events:s,isLoading:a,isFetchingNextPage:l,hasNextPage:c,fetchNextPage:d}=Ea(i),p=useRef(null),{height:m}=useResizeObserver({ref:p}),u=useCallback(v=>v<s.length,[s]),f=useCallback(async()=>{c&&!l&&await d();},[c,l,d]),h=useMemo(()=>c?s.length+1:s.length,[s,c]),g=useInfiniteLoader({isRowLoaded:u,loadMoreRows:f,rowCount:h,threshold:5});return a?jsx(bg,{className:o}):s.length===0?jsx(yg,{className:o}):jsx("div",{className:cn("w-full h-full flex flex-col",o),children:jsx("div",{className:"flex-auto min-h-0",ref:p,children:jsx(List,{className:"no-scrollbar",style:{height:m},onRowsRendered:g,rowComponent:xg,rowCount:h,rowHeight:vg,rowProps:{events:s,onSelect:e,getEventHref:t,LinkComponent:r,onHover:n},overscanCount:5})})})}function xg({index:e,style:t,events:r,onSelect:n,getEventHref:o,LinkComponent:i,onHover:s}){let a=r[e];return a?jsx("div",{style:t,children:jsx(Ma,{event:a,href:o?.(a),LinkComponent:i,onSelect:n,onHover:s})}):jsx("div",{style:t,className:"flex items-center justify-center",children:jsx(Spinner,{size:"sm"})})}function bg({className:e}){let{t}=useTranslation();return jsxs("div",{className:cn("flex items-center justify-center gap-2 py-16",e),children:[jsx(Spinner,{size:"sm"}),jsx("span",{className:"text-sm text-neutral",children:t("predict.search.loading")})]})}function yg({className:e}){let{t}=useTranslation();return jsxs("div",{className:cn("flex flex-col items-center justify-center py-16",e),children:[jsx(EmptyIcon,{width:28,height:28,className:"text-neutral"}),jsx("p",{className:"mt-2 text-sm text-neutral",children:t("predict.search.noResults")})]})}function Aa({onKeywordChange:e}){let[t,r]=useState(""),[n,o]=useState(""),{addHistory:i}=Vn(),s=useCallbackRef(e),a=useCallbackRef(i),l=useMemo(()=>debounce(m=>{o(m),s(m),m&&a(m);},500),[s,a]),c=useCallback(m=>{r(m),l(m);},[l]),d=useCallback(m=>{l.cancel(),r(m),o(m),s(m),m&&a(m);},[l,s,a]),p=useCallback(()=>d(""),[d]);return {text:t,keyword:n,setText:c,setKeyword:d,clearKeyword:p}}function Fa({onKeywordChange:e,onSelectEvent:t,getEventHref:r,LinkComponent:n,onHover:o,onEscape:i,source:s}){let{text:a,keyword:l,setText:c,setKeyword:d,clearKeyword:p}=Aa({onKeywordChange:e});return jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsx(Ca,{value:a,onValueChange:c,onClear:p,onEscape:i}),!l&&jsx(Pa,{onSelect:d}),jsx(_a,{className:"flex-auto min-h-0",keyword:l,onSelect:t,getEventHref:r,LinkComponent:n,onHover:o,source:s})]})}var Wo="predict-search";function sk({id:e=Wo}){return jsx(AsyncModal,{id:e,children:t=>jsx(Ig,{...t})})}function Ig({params:e,isOpen:t,onOpenChange:r,onResult:n}){let{t:o}=useTranslation(),{isMobile:i}=useScreen(),s=useCallback(l=>{n(l);},[n]),a=useCallback(()=>{r(false);},[r]);return jsx(StyledModal,{isOpen:t,onOpenChange:r,size:i?"full":"lg",hideCloseButton:true,backdrop:"blur",radius:"lg",children:jsxs(ModalContent,{className:"w-full h-full",style:{borderRadius:i?void 0:14,border:i?void 0:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:i?void 0:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"},children:[jsxs(ModalHeader,{className:"sm:hidden flex items-center justify-between pt-4 pb-2",children:[jsx("span",{className:"text-base font-semibold",children:o("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(Fa,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectEvent:s,onEscape:a})})]})})}function gk({onSelectEvent:e,modalParams:t,className:r}){let{t:n}=useTranslation(),{isDesktop:o}=useScreen(),{onOpen:i,onClose:s}=useAsyncModal(Wo),a=useCallbackRef(e),l=useCallbackRef(async()=>{let d=await i({params:t});d&&a(d);}),c=useCallbackRef(()=>{s();});return useEffect(()=>{let d=p=>{let m=document.activeElement,u=!!m&&(m.tagName==="INPUT"||m.tagName==="TEXTAREA"||m.getAttribute("contenteditable")==="true");p.key==="/"&&!u&&(p.preventDefault(),l()),p.key==="Escape"&&(p.preventDefault(),c());};return window.addEventListener("keydown",d),()=>{window.removeEventListener("keydown",d);}},[l,c]),o?jsx(Button,{size:"sm",radius:"full",onPress:l,variant:"bordered",startContent:jsx(SearchIcon,{width:16,height:16,className:"text-foreground"}),endContent:jsx(Kbd,{className:"min-w-6 justify-center text-xs text-foreground bg-content3 rounded-lg",children:"/"}),className:cn("w-56 min-w-0 h-8 min-h-0 border-transparent hover:border-border bg-content2 pl-3 pr-1.5 text-neutral",r),children:n("predict.search.placeholder")}):jsx(Button,{size:"sm",radius:"full",isIconOnly:true,onPress:l,variant:"bordered",className:cn("w-8 min-w-0 h-8 min-h-0 border-1 border-border bg-content2",r),children:jsx(SearchIcon,{width:16,height:16,className:"text-foreground"})})}var $o=[{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"}],qa=[{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}],Va={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"},ja={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 Wg(e,t){if(!e)return "$5K+";let r=qa.find(n=>n.value===e);return r?r.labelKey?t(r.labelKey):r.label:`$${e}`}function Ya({sortBy:e,onSortChange:t,sortAsc:r,onSortAscChange:n,minVolume:o,onMinVolumeChange:i,onRefresh:s}){let{t:a}=useTranslation(),[l,c]=useState(false),[d,p]=useState(false),[m,u]=useState(false),[f,h]=useState(false),g=useRef(null),v=useRef(null),S=$o.find(x=>x.value===e)??$o[0],w=useCallback(x=>{g.current&&!g.current.contains(x.target)&&c(false),v.current&&!v.current.contains(x.target)&&p(false);},[]);useEffect(()=>(document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)),[w]);let P=useCallback(()=>{s?.(),h(true),setTimeout(()=>h(false),700);},[s]);return jsxs(Fragment,{children:[jsx("style",{children:`
79
79
  @keyframes matchRefreshSpin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}
80
80
  .match-refresh-spin{animation:matchRefreshSpin .6s ease-in-out}
81
81
  .match-btn:focus-visible{outline:2px solid #c7ff2e;outline-offset:2px;z-index:10}
82
- `}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxs("div",{ref:g,style:{position:"relative"},children:[jsxs("button",{type:"button",className:"match-btn",style:Ta,onMouseEnter:x=>{x.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:x=>{x.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>{c(x=>!x),p(false);},children:[jsx(ng,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:a(S.labelKey)}),jsx(Ra,{open:l})]}),l&&jsx("div",{style:{...La,width:224,padding:4},children:Oo.map(x=>{let T=e===x.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:T?"rgba(199,255,46,0.08)":"transparent",color:T?"#c7ff2e":"#a1a1aa",borderRadius:10},onMouseEnter:k=>{T||(k.currentTarget.style.background="rgba(39,39,42,0.5)",k.currentTarget.style.color="#fff");},onMouseLeave:k=>{T||(k.currentTarget.style.background="transparent",k.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===x.value?n(!r):t(x.value),c(false);},children:[jsx("div",{style:{color:T?"#c7ff2e":"#71717a"},children:jsx(og,{type:x.icon})}),jsxs("div",{style:{flex:1,textAlign:"left"},children:[jsx("div",{style:{fontWeight:500},children:a(x.labelKey)}),jsx("div",{style:{fontSize:11,color:"#71717a",marginTop:1},children:a(x.descKey)})]}),T&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 6 9 17l-5-5"})})]},x.value)})})]}),i&&jsxs("div",{ref:v,style:{position:"relative"},children:[jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxs("button",{type:"button",className:"match-btn",style:Ta,onMouseEnter:x=>{x.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:x=>{x.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>{p(x=>!x),c(false);},children:[jsx(ig,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:rg(o,a)}),jsx(sg,{onMouseEnter:()=>u(true),onMouseLeave:()=>u(false)}),jsx(Ra,{open:d})]}),m&&jsxs("div",{style:{position:"absolute",zIndex:100,top:"100%",marginTop:8,left:"50%",transform:"translateX(-50%)",width:256,padding:12,borderRadius:14,background:"rgba(24,24,27,1)",border:"1px solid rgba(63,63,70,0.5)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",pointerEvents:"none"},children:[jsx("div",{style:{position:"absolute",top:-6,left:"50%",transform:"translateX(-50%) rotate(45deg)",width:12,height:12,background:"rgba(24,24,27,1)",borderLeft:"1px solid rgba(63,63,70,0.5)",borderTop:"1px solid rgba(63,63,70,0.5)"}}),jsxs("div",{style:{position:"relative",fontSize:12,color:"#d4d4d8",lineHeight:1.625},children:[jsxs("div",{style:{fontWeight:600,color:"#fff",display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"})}),a("predict.matches.filter.liquidityFilter")]}),jsx("p",{style:{color:"#a1a1aa",margin:"0 0 4px"},children:a("predict.matches.filter.tooltipDesc")}),jsx("p",{style:{color:"#71717a",fontSize:11,margin:0},children:a("predict.matches.filter.tooltipNote")})]})]})]}),d&&jsxs("div",{style:{...La,right:0,width:176},children:[jsx("div",{style:{padding:"8px 12px",borderBottom:"1px solid rgba(39,39,42,1)"},children:jsx("span",{style:{fontSize:11,fontWeight:500,color:"#71717a",textTransform:"uppercase",letterSpacing:"0.05em"},children:a("predict.matches.filter.minVolumeEach")})}),jsx("div",{style:{padding:4},children:_a.map(x=>{let T=x.value===0?!o:o===x.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:T?"rgba(199,255,46,0.08)":"transparent",color:T?"#c7ff2e":"#a1a1aa",borderRadius:10,transition:"all 0.15s"},onMouseEnter:k=>{T||(k.currentTarget.style.background="rgba(39,39,42,0.5)",k.currentTarget.style.color="#fff");},onMouseLeave:k=>{T||(k.currentTarget.style.background="transparent",k.currentTarget.style.color="#a1a1aa");},onClick:()=>{i?.(x.value===0?void 0:x.value),p(false);},children:[jsx("span",{children:x.labelKey?a(x.labelKey):x.label}),T&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 6 9 17l-5-5"})})]},x.value)})})]})]}),s&&jsx("button",{type:"button",className:"match-btn",style:{borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",width:36,height:36,color:"#a1a1aa",cursor:"pointer",transition:"all 0.15s",display:"inline-flex",alignItems:"center",justifyContent:"center"},onMouseEnter:x=>{x.currentTarget.style.background="rgba(39,39,42,1)",x.currentTarget.style.color="#fff";},onMouseLeave:x=>{x.currentTarget.style.background="rgba(39,39,42,0.6)",x.currentTarget.style.color="#a1a1aa";},onClick:N,children:jsxs("svg",{className:f?"match-refresh-spin":void 0,viewBox:"0 0 24 24",style:{width:16,height:16},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),jsx("path",{d:"M21 3v5h-5"}),jsx("path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}),jsx("path",{d:"M8 16H3v5"})]})})]})]})}function ng(){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 og({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 ig(){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 sg({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 Ra({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 dg(e){return formatAmountInUsd(e)}var ug=[{key:"activePairs",labelKey:"predict.matches.stats.activePairs",format:e=>formatAmount(e),valueColor:"#c7ff2e",gradientFrom:"rgba(199,255,46,0.18)",gradientTo:"rgba(199,255,46,0.04)",borderColor:"rgba(199,255,46,0.18)"},{key:"maxSpread",labelKey:"predict.matches.stats.maxSpread",format:e=>`${(e*100).toFixed(1)}%`,valueColor:"#f76816",gradientFrom:"rgba(247,104,22,0.18)",gradientTo:"rgba(247,104,22,0.04)",borderColor:"rgba(247,104,22,0.18)"},{key:"highSpreadCount",labelKey:"predict.matches.stats.highSpreadCount",format:e=>formatAmount(e),valueColor:"#17c964",gradientFrom:"rgba(23,201,100,0.18)",gradientTo:"rgba(23,201,100,0.04)",borderColor:"rgba(23,201,100,0.18)"},{key:"totalVolume",labelKey:"predict.matches.stats.totalVolume",format:dg,valueColor:"#f5a524",gradientFrom:"rgba(245,165,36,0.18)",gradientTo:"rgba(245,165,36,0.04)",borderColor:"rgba(245,165,36,0.18)"}];function Da({stats:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsx("style",{children:`
82
+ `}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxs("div",{ref:g,style:{position:"relative"},children:[jsxs("button",{type:"button",className:"match-btn",style:Va,onMouseEnter:x=>{x.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:x=>{x.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>{c(x=>!x),p(false);},children:[jsx(Ug,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:a(S.labelKey)}),jsx(Ga,{open:l})]}),l&&jsx("div",{style:{...ja,width:224,padding:4},children:$o.map(x=>{let E=e===x.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:E?"rgba(199,255,46,0.08)":"transparent",color:E?"#c7ff2e":"#a1a1aa",borderRadius:10},onMouseEnter:k=>{E||(k.currentTarget.style.background="rgba(39,39,42,0.5)",k.currentTarget.style.color="#fff");},onMouseLeave:k=>{E||(k.currentTarget.style.background="transparent",k.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===x.value?n(!r):t(x.value),c(false);},children:[jsx("div",{style:{color:E?"#c7ff2e":"#71717a"},children:jsx($g,{type:x.icon})}),jsxs("div",{style:{flex:1,textAlign:"left"},children:[jsx("div",{style:{fontWeight:500},children:a(x.labelKey)}),jsx("div",{style:{fontSize:11,color:"#71717a",marginTop:1},children:a(x.descKey)})]}),E&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 6 9 17l-5-5"})})]},x.value)})})]}),i&&jsxs("div",{ref:v,style:{position:"relative"},children:[jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxs("button",{type:"button",className:"match-btn",style:Va,onMouseEnter:x=>{x.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:x=>{x.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>{p(x=>!x),c(false);},children:[jsx(Kg,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:Wg(o,a)}),jsx(Vg,{onMouseEnter:()=>u(true),onMouseLeave:()=>u(false)}),jsx(Ga,{open:d})]}),m&&jsxs("div",{style:{position:"absolute",zIndex:100,top:"100%",marginTop:8,left:"50%",transform:"translateX(-50%)",width:256,padding:12,borderRadius:14,background:"rgba(24,24,27,1)",border:"1px solid rgba(63,63,70,0.5)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",pointerEvents:"none"},children:[jsx("div",{style:{position:"absolute",top:-6,left:"50%",transform:"translateX(-50%) rotate(45deg)",width:12,height:12,background:"rgba(24,24,27,1)",borderLeft:"1px solid rgba(63,63,70,0.5)",borderTop:"1px solid rgba(63,63,70,0.5)"}}),jsxs("div",{style:{position:"relative",fontSize:12,color:"#d4d4d8",lineHeight:1.625},children:[jsxs("div",{style:{fontWeight:600,color:"#fff",display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"})}),a("predict.matches.filter.liquidityFilter")]}),jsx("p",{style:{color:"#a1a1aa",margin:"0 0 4px"},children:a("predict.matches.filter.tooltipDesc")}),jsx("p",{style:{color:"#71717a",fontSize:11,margin:0},children:a("predict.matches.filter.tooltipNote")})]})]})]}),d&&jsxs("div",{style:{...ja,right:0,width:176},children:[jsx("div",{style:{padding:"8px 12px",borderBottom:"1px solid rgba(39,39,42,1)"},children:jsx("span",{style:{fontSize:11,fontWeight:500,color:"#71717a",textTransform:"uppercase",letterSpacing:"0.05em"},children:a("predict.matches.filter.minVolumeEach")})}),jsx("div",{style:{padding:4},children:qa.map(x=>{let E=x.value===0?!o:o===x.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:E?"rgba(199,255,46,0.08)":"transparent",color:E?"#c7ff2e":"#a1a1aa",borderRadius:10,transition:"all 0.15s"},onMouseEnter:k=>{E||(k.currentTarget.style.background="rgba(39,39,42,0.5)",k.currentTarget.style.color="#fff");},onMouseLeave:k=>{E||(k.currentTarget.style.background="transparent",k.currentTarget.style.color="#a1a1aa");},onClick:()=>{i?.(x.value===0?void 0:x.value),p(false);},children:[jsx("span",{children:x.labelKey?a(x.labelKey):x.label}),E&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 6 9 17l-5-5"})})]},x.value)})})]})]}),s&&jsx("button",{type:"button",className:"match-btn",style:{borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",width:36,height:36,color:"#a1a1aa",cursor:"pointer",transition:"all 0.15s",display:"inline-flex",alignItems:"center",justifyContent:"center"},onMouseEnter:x=>{x.currentTarget.style.background="rgba(39,39,42,1)",x.currentTarget.style.color="#fff";},onMouseLeave:x=>{x.currentTarget.style.background="rgba(39,39,42,0.6)",x.currentTarget.style.color="#a1a1aa";},onClick:P,children:jsxs("svg",{className:f?"match-refresh-spin":void 0,viewBox:"0 0 24 24",style:{width:16,height:16},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),jsx("path",{d:"M21 3v5h-5"}),jsx("path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}),jsx("path",{d:"M8 16H3v5"})]})})]})]})}function Ug(){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 $g({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 Kg(){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 Vg({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 Ga({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 Yg(e){return formatAmountInUsd(e)}var Qg=[{key:"activePairs",labelKey:"predict.matches.stats.activePairs",format:e=>formatAmount(e),valueColor:"#c7ff2e",gradientFrom:"rgba(199,255,46,0.18)",gradientTo:"rgba(199,255,46,0.04)",borderColor:"rgba(199,255,46,0.18)"},{key:"maxSpread",labelKey:"predict.matches.stats.maxSpread",format:e=>`${(e*100).toFixed(1)}%`,valueColor:"#f76816",gradientFrom:"rgba(247,104,22,0.18)",gradientTo:"rgba(247,104,22,0.04)",borderColor:"rgba(247,104,22,0.18)"},{key:"highSpreadCount",labelKey:"predict.matches.stats.highSpreadCount",format:e=>formatAmount(e),valueColor:"#17c964",gradientFrom:"rgba(23,201,100,0.18)",gradientTo:"rgba(23,201,100,0.04)",borderColor:"rgba(23,201,100,0.18)"},{key:"totalVolume",labelKey:"predict.matches.stats.totalVolume",format:Yg,valueColor:"#f5a524",gradientFrom:"rgba(245,165,36,0.18)",gradientTo:"rgba(245,165,36,0.04)",borderColor:"rgba(245,165,36,0.18)"}];function Xa({stats:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsx("style",{children:`
83
83
  @keyframes match-live-ping{75%,100%{transform:scale(2.2);opacity:0}}
84
84
  @keyframes match-live-breathe{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.55;transform:scale(.85)}}
85
85
  @keyframes matchStatsEnter{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}
@@ -117,21 +117,21 @@ import {createContext,memo,useRef,forwardRef,useState,useImperativeHandle,useMem
117
117
  .matches-stat-label{font-size:11px;line-height:16px;min-height:16px}
118
118
  @media(min-width:640px){.matches-stat-label{font-size:12px;line-height:18px;min-height:18px}}
119
119
  `}),jsxs("div",{className:"matches-hero-outer",style:{display:"flex",marginBottom:0},children:[jsxs("div",{className:"matches-hero-left",style:{display:"flex",flexDirection:"column",minWidth:0,flex:1,animation:"matchHeroTitleEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both"},children:[jsx("div",{className:"matches-hero-live",style:{display:"flex",marginBottom:16},children:jsxs("div",{className:"inline-flex items-center",style:{gap:8,borderRadius:9999,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"6px 12px",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)"},children:[jsxs("span",{style:{position:"relative",display:"flex",width:8,height:8},children:[jsx("span",{style:{position:"absolute",display:"inline-flex",width:"100%",height:"100%",borderRadius:9999,background:"#00d492",opacity:.75,animation:"match-live-ping 1.2s cubic-bezier(0,0,0.2,1) infinite"}}),jsx("span",{style:{position:"relative",display:"inline-flex",width:8,height:8,borderRadius:9999,background:"#00bc7d",animation:"match-live-breathe 2.4s ease-in-out infinite"}})]}),jsx("span",{style:{fontSize:12,fontWeight:500,color:"#d4d4d8",letterSpacing:"0.025em"},children:t("predict.matches.liveBadge")}),jsx("span",{style:{borderRadius:4,background:"rgba(199,255,46,0.12)",padding:"2px 6px",fontSize:10,fontWeight:600,color:"#c7ff2e",textTransform:"uppercase",border:"1px solid rgba(199,255,46,0.22)"},children:t("predict.matches.betaTag")})]})}),jsxs("h1",{className:"matches-hero-title",style:{fontFamily:"var(--font-dm-sans, 'DM Sans', sans-serif)",fontSize:46,fontWeight:700,letterSpacing:"-1.2px",lineHeight:1.2,color:"#fff",margin:"0 0 14px"},children:[jsxs("span",{style:{color:"#fff"},children:[t("predict.matches.titlePrefix")," "]}),jsx("span",{style:{backgroundImage:"linear-gradient(to right, #c7ff2e, #a0e515, #17c964)",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",backgroundClip:"text"},children:t("predict.matches.titleHighlight")})]}),jsx("p",{className:"matches-hero-subtitle matches-hero-subtitle-text",style:{lineHeight:1.6,color:"#71717a",maxWidth:460},children:String(t("predict.matches.heroSubtitle")).split(`
120
- `).map((r,n)=>jsxs("span",{children:[n>0&&jsx("br",{className:"hidden sm:block"}),r,n===0?" ":""]},n))})]}),jsx("div",{className:"matches-stat-grid",style:{display:"grid",borderRadius:16,border:"1px solid rgba(39,39,42,0.5)",overflow:"hidden",flexShrink:0,backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",...e?{animation:"matchStatsEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:"0.1s"}:{}},children:ug.map((r,n)=>jsxs("div",{style:{padding:"16px 20px",background:e?`linear-gradient(to bottom, ${r.gradientFrom}, ${r.gradientTo})`:"rgba(255,255,255,0.02)",borderRight:n%2===0?"1px solid rgba(39,39,42,0.4)":"none",borderBottom:n<2?"1px solid rgba(39,39,42,0.4)":"none",...e?{animation:"matchStatCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:`${150+n*60}ms`}:{}},children:[jsx("div",{className:"matches-stat-val",style:{fontWeight:700,fontVariantNumeric:"tabular-nums",color:e?r.valueColor:"transparent",display:"flex",alignItems:"center"},children:e?r.format(e[r.key]??0):jsx("div",{style:{height:16,width:56,borderRadius:4,background:"rgba(255,255,255,0.06)",animation:"matchStatCardEnter 0.6s ease-out both",animationDelay:`${n*80}ms`}})}),jsx("div",{className:"matches-stat-label",style:{fontWeight:500,color:e?"#71717a":"transparent",marginTop:2,display:"flex",alignItems:"center"},children:e?t(r.labelKey):jsx("div",{style:{height:10,width:64,borderRadius:4,background:"rgba(255,255,255,0.04)",animation:"matchStatCardEnter 0.6s ease-out both",animationDelay:`${50+n*80}ms`}})})]},r.key))})]})]})}function Do(e){return e==null?"-":formatAmountInUsd(e)}function fg(e){return e==null?"narrow":e>=5?"wide":e>=3?"moderate":"narrow"}var Ha={wide:{color:"#f76816",bandFrom:"rgba(247,104,22,0.14)",bandTo:"rgba(247,104,22,0.03)",gaugeActive:"#f76816",gaugeInactive:"rgba(247,104,22,0.15)"},moderate:{color:"#c7ff2e",bandFrom:"rgba(199,255,46,0.12)",bandTo:"rgba(199,255,46,0.02)",gaugeActive:"#c7ff2e",gaugeInactive:"rgba(199,255,46,0.15)"},narrow:{color:"#71717a",bandFrom:"rgba(113,113,122,0.08)",bandTo:"transparent",gaugeActive:"#71717a",gaugeInactive:"rgba(113,113,122,0.12)"}},gg={wide:{border:"rgba(247,104,22,0.4)",shadow:"0 2px 18px rgba(247,104,22,0.35)"},moderate:{border:"rgba(199,255,46,0.5)",shadow:"0 2px 20px rgba(199,255,46,0.45)"},narrow:{border:"rgba(113,113,122,0.5)",shadow:"0 2px 20px rgba(113,113,122,0.35)"}},Aa={liquid_gap:{dot:"#17c964",label:"predict.matches.signalLiquidGap"},active_gap:{dot:"#c7ff2e",label:"predict.matches.signalActiveGap"},stale_gap:{dot:"#f5a524",label:"predict.matches.signalStaleGap"},stale_data:{dot:"#71717a",label:"predict.matches.signalStaleData"}};function hg(e){return e==null?null:e<120?"fresh":e<300?"aging":"stale"}var vg={fresh:"#17c964",aging:"#f5a524",stale:"#71717a"},xg={polymarket:{text:"#50a2ff",icon:"#50a2ff"},kalshi:{text:"#00d492",icon:"#00d492"}},bg={text:"#9ca3af",icon:"#9ca3af"};function yg(e){return xg[e]??bg}var kg=`
120
+ `).map((r,n)=>jsxs("span",{children:[n>0&&jsx("br",{className:"hidden sm:block"}),r,n===0?" ":""]},n))})]}),jsx("div",{className:"matches-stat-grid",style:{display:"grid",borderRadius:16,border:"1px solid rgba(39,39,42,0.5)",overflow:"hidden",flexShrink:0,backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",...e?{animation:"matchStatsEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:"0.1s"}:{}},children:Qg.map((r,n)=>jsxs("div",{style:{padding:"16px 20px",background:e?`linear-gradient(to bottom, ${r.gradientFrom}, ${r.gradientTo})`:"rgba(255,255,255,0.02)",borderRight:n%2===0?"1px solid rgba(39,39,42,0.4)":"none",borderBottom:n<2?"1px solid rgba(39,39,42,0.4)":"none",...e?{animation:"matchStatCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:`${150+n*60}ms`}:{}},children:[jsx("div",{className:"matches-stat-val",style:{fontWeight:700,fontVariantNumeric:"tabular-nums",color:e?r.valueColor:"transparent",display:"flex",alignItems:"center"},children:e?r.format(e[r.key]??0):jsx("div",{style:{height:16,width:56,borderRadius:4,background:"rgba(255,255,255,0.06)",animation:"matchStatCardEnter 0.6s ease-out both",animationDelay:`${n*80}ms`}})}),jsx("div",{className:"matches-stat-label",style:{fontWeight:500,color:e?"#71717a":"transparent",marginTop:2,display:"flex",alignItems:"center"},children:e?t(r.labelKey):jsx("div",{style:{height:10,width:64,borderRadius:4,background:"rgba(255,255,255,0.04)",animation:"matchStatCardEnter 0.6s ease-out both",animationDelay:`${50+n*80}ms`}})})]},r.key))})]})]})}function Ko(e){return e==null?"-":formatAmountInUsd(e)}function Zg(e){return e==null?"narrow":e>=5?"wide":e>=3?"moderate":"narrow"}var tl={wide:{color:"#f76816",bandFrom:"rgba(247,104,22,0.14)",bandTo:"rgba(247,104,22,0.03)",gaugeActive:"#f76816",gaugeInactive:"rgba(247,104,22,0.15)"},moderate:{color:"#c7ff2e",bandFrom:"rgba(199,255,46,0.12)",bandTo:"rgba(199,255,46,0.02)",gaugeActive:"#c7ff2e",gaugeInactive:"rgba(199,255,46,0.15)"},narrow:{color:"#71717a",bandFrom:"rgba(113,113,122,0.08)",bandTo:"transparent",gaugeActive:"#71717a",gaugeInactive:"rgba(113,113,122,0.12)"}},e0={wide:{border:"rgba(247,104,22,0.4)",shadow:"0 2px 18px rgba(247,104,22,0.35)"},moderate:{border:"rgba(199,255,46,0.5)",shadow:"0 2px 20px rgba(199,255,46,0.45)"},narrow:{border:"rgba(113,113,122,0.5)",shadow:"0 2px 20px rgba(113,113,122,0.35)"}},Ja={liquid_gap:{dot:"#17c964",label:"predict.matches.signalLiquidGap"},active_gap:{dot:"#c7ff2e",label:"predict.matches.signalActiveGap"},stale_gap:{dot:"#f5a524",label:"predict.matches.signalStaleGap"},stale_data:{dot:"#71717a",label:"predict.matches.signalStaleData"}};function t0(e){return e==null?null:e<120?"fresh":e<300?"aging":"stale"}var r0={fresh:"#17c964",aging:"#f5a524",stale:"#71717a"},n0={polymarket:{text:"#50a2ff",icon:"#50a2ff"},kalshi:{text:"#00d492",icon:"#00d492"}},o0={text:"#9ca3af",icon:"#9ca3af"};function i0(e){return n0[e]??o0}var s0=`
121
121
  .match-card button:focus-visible,
122
122
  .match-card a:focus-visible,
123
123
  .match-card [role="button"]:focus-visible {
124
124
  outline: 2px solid hsl(var(--heroui-primary) / 0.4);
125
125
  outline-offset: 2px;
126
126
  }
127
- `;function Sg({tier:e}){let t=Ha[e],r=e==="wide"?5:e==="moderate"?3:1;return jsx("div",{style:{display:"flex",gap:2,alignItems:"center"},children:Array.from({length:5},(n,o)=>jsx("div",{style:{width:6,height:10,borderRadius:1.5,background:o<r?t.gaugeActive:t.gaugeInactive,transition:"background 0.2s"}},o))})}function wg(e){if(Array.isArray(e.legs)&&e.legs.length===2)return [e.legs[0],e.legs[1]];let t=(r,n,o)=>({source:r,event_title:n,event_slug:o?.event_slug??"",market_id:o?.id??0,market_slug:o?.slug??"",question:o?.question??"",status:o?.status??"open",outcomes:o?.outcomes,best_price:o?.outcomes?.[0]?.best_ask??o?.outcomes?.[0]?.price??void 0,vol_24h_usd:o?.volume_24h??void 0});return !e.market_a||!e.market_b?null:[t(e.source_a,e.event_a_title??"",e.market_a),t(e.source_b,e.event_b_title??"",e.market_b)]}function za({match:e,onSelectMatch:t,getMatchHref:r,onSelectLeg:n,getLegHref:o,onHover:i,getMarketHref:s,LinkComponent:a}){let{t:l}=useTranslation(),c=wg(e);if(!c)return null;let[d,p]=c,m=e.spread_percent!=null?e.spread_percent:e.spread!=null?e.spread*100:null,u=fg(m),f=Ha[u],h=d.best_price!=null&&p.best_price!=null?d.best_price<=p.best_price?d.source:p.source:null,g=d.event_title||p.event_title,v=e.signal_tag??"stale_data",S=Aa[v]??Aa.stale_data,w=r?.(e),N=jsxs(Fragment,{children:[jsx("style",{children:kg}),m!=null&&jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",background:`linear-gradient(90deg, ${f.bandFrom}, ${f.bandTo})`,borderBottom:"1px solid rgba(39,39,42,0.3)"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,flexShrink:0,color:f.color},fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),jsxs("span",{style:{fontSize:15,fontWeight:700,fontVariantNumeric:"tabular-nums",color:f.color},children:[m.toFixed(1),"%"]}),jsx("span",{style:{fontSize:10,fontWeight:500,color:"rgba(161,161,170,0.7)",textTransform:"uppercase",letterSpacing:"0.06em"},children:l("predict.matches.gap")})]}),jsx(Sg,{tier:u})]}),jsxs("div",{style:{padding:"14px 14px 12px"},children:[jsx("h3",{style:{fontSize:13,fontWeight:600,lineHeight:1.4,letterSpacing:"-0.2px",color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",margin:"0 0 12px"},children:g}),jsxs("div",{style:{borderRadius:10,border:"1px solid rgba(39,39,42,0.4)",overflow:"hidden"},children:[jsx(Fa,{leg:d,isCheaper:h===d.source,externalUrlFallback:s?.(e,d.source),internalHref:o?.(e,d),onSelect:n?()=>n(e,d):void 0,LinkComponent:a}),jsx("div",{style:{height:1,background:"rgba(39,39,42,0.3)"}}),jsx(Fa,{leg:p,isCheaper:h===p.source,externalUrlFallback:s?.(e,p.source),internalHref:o?.(e,p),onSelect:n?()=>n(e,p):void 0,LinkComponent:a})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.15)",padding:"8px 14px"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,fontSize:10,color:"#71717a"},children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}),Do(e.combined_volume)]}),e.combined_volume_24h!=null&&e.combined_volume_24h>0&&jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z"})}),Do(e.combined_volume_24h)," ",l("predict.matches.vol24h")]}),e.age_seconds!=null&&jsxs("span",{title:l("predict.matches.updatedAgo",{seconds:e.age_seconds}),style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("polyline",{points:"12 6 12 12 16 14"})]}),Pg(l,e.age_seconds)]})]}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,color:"#52525b"},children:[jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:S.dot,flexShrink:0}}),l(S.label)]})]})]}),x={display:"block",color:"inherit",textDecoration:"none",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",cursor:w||t?"pointer":void 0},T=L=>{let H=L.currentTarget,D=gg[u];H.style.borderColor=D.border,H.style.boxShadow=D.shadow,i?.(e);},k=L=>{let H=L.currentTarget;H.style.borderColor="rgba(39,39,42,0.6)",H.style.boxShadow="none";};return w&&a?jsx(a,{href:w,className:"group match-card",children:jsx("div",{style:x,onMouseEnter:T,onMouseLeave:k,onClick:()=>t?.(e),children:N})}):jsx("div",{className:"group match-card",role:t?"button":void 0,tabIndex:t?0:void 0,style:x,onMouseEnter:T,onMouseLeave:k,onClick:()=>t?.(e),onKeyDown:L=>{t&&(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),t(e));},children:N})}function Pg(e,t){if(t<60)return e("predict.matches.ageJustNow");if(t<3600){let n=Math.floor(t/60);return e("predict.matches.ageMinutes",{count:n})}let r=Math.floor(t/3600);return e("predict.matches.ageHours",{count:r})}function Fa({leg:e,isCheaper:t,externalUrlFallback:r,internalHref:n,onSelect:o,LinkComponent:i}){let{t:s}=useTranslation(),a=kt(e.source),l=yg(e.source),c=e.best_price,d=e.outcomes?.[0]?.label??null,p=e.external_url??r,m=hg(e.age_seconds),u=v=>{v.stopPropagation();},f=!!(n||o),h={display:"flex",alignItems:"center",gap:8,padding:"10px 12px",background:t?"rgba(199,255,46,0.03)":"transparent",cursor:f?"pointer":void 0,color:"inherit",textDecoration:"none"},g=jsxs(Fragment,{children:[t?jsx("span",{style:{fontSize:10,color:"#c7ff2e",flexShrink:0},children:"\u2605"}):jsx("span",{style:{width:10,flexShrink:0}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,width:100,flexShrink:0},children:[a.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",color:l.text,textTransform:"uppercase"},children:a.label}),m&&jsx("span",{title:e.age_seconds!=null?s("predict.matches.updatedAgo",{seconds:e.age_seconds}):void 0,style:{width:6,height:6,borderRadius:"50%",background:vg[m],flexShrink:0}})]}),jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:1},children:[d&&jsx("span",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d}),jsxs("span",{style:{fontSize:9,color:"#52525b"},children:[Do(e.vol_24h_usd)," ",s("predict.matches.vol24h")]})]}),jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:3,flexShrink:0},children:[jsx("span",{style:{fontSize:18,fontWeight:700,fontVariantNumeric:"tabular-nums",color:t?"#c7ff2e":"#f4f4f5"},children:c!=null?(c*100).toFixed(1):"-"}),jsx("span",{style:{fontSize:9,color:"#71717a"},children:s("predict.matches.centsYes")})]}),p?jsx("a",{href:p,target:"_blank",rel:"noopener noreferrer","aria-label":s("predict.matches.viewOn",{platform:a.label}),title:s("predict.matches.viewOn",{platform:a.label}),onClick:v=>v.stopPropagation(),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,borderRadius:4,color:"#71717a",flexShrink:0},onMouseEnter:v=>{v.currentTarget.style.color="#d4d4d8",v.currentTarget.style.background="rgba(255,255,255,0.05)";},onMouseLeave:v=>{v.currentTarget.style.color="#71717a",v.currentTarget.style.background="transparent";},children:jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M7 7h10v10"}),jsx("path",{d:"M7 17 17 7"})]})}):jsx("span",{style:{width:18,flexShrink:0}})]});return n&&i?jsx(i,{href:n,className:"match-card-leg-link",onClick:v=>{u(v),o?.();},children:jsx("div",{style:h,children:g})}):f?jsx("div",{role:"link",tabIndex:0,style:h,onClick:v=>{u(v),o?.();},onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),u(v),o?.());},children:g}):jsx("div",{style:h,children:g})}var Va=forwardRef(function({sortBy:t,sortAsc:r,minVolume:n,signal:o,onSelectMatch:i,getMatchHref:s,onSelectLeg:a,getLegHref:l,onSelect:c,onHover:d,getMarketHref:p,LinkComponent:m,onStatsChange:u},f){let{t:h}=useTranslation(),{data:g,hasNextPage:v,fetchNextPage:S,isFetchingNextPage:w,isLoading:N,isPlaceholderData:x,refetch:T}=useInfiniteMatchMarkets({sort_by:t,sort_asc:r,min_volume:n,signal:o,status:"active",limit:20},{placeholderData:keepPreviousData}),[k,L]=useState(0),[H,D]=useState(false);H&&!x?(D(false),L(Y=>Y+1)):x&&!H&&D(true),useImperativeHandle(f,()=>({refetch:()=>{T();}}),[T]);let A=useMemo(()=>g?.pages.flatMap(Y=>Y.items??[])??[],[g]),P=g?.pages[0]?.total,W=useMemo(()=>{let Y=0,b=0,y=0;for(let V of A){let G=V.spread??0;G>Y&&(Y=G),G>=.03&&y++,V.combined_volume!=null&&(b+=V.combined_volume);}return {activePairs:P??A.length,maxSpread:Y,highSpreadCount:y,totalVolume:b}},[A,P]);useEffect(()=>{W.activePairs>0&&u?.(W);},[W,u]);let O=useRef(null),ae=useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]);if(useEffect(()=>{let Y=O.current;if(!Y)return;let b=new IntersectionObserver(y=>{y[0]?.isIntersecting&&v&&!w&&S();},{rootMargin:"200px"});return b.observe(Y),()=>b.disconnect()},[v,w,S]),useEffect(()=>{if(v)return document.documentElement.style.overscrollBehaviorY="none",()=>{document.documentElement.style.overscrollBehaviorY="";}},[v]),N)return jsx(_g,{});if(A.length===0)return jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"80px 0",color:"rgba(255,255,255,0.35)"},children:jsx("p",{style:{fontSize:18},children:h("predict.matches.empty")})});let X=!v&&A.length>0;return jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[jsx("style",{children:`
127
+ `;function a0({tier:e}){let t=tl[e],r=e==="wide"?5:e==="moderate"?3:1;return jsx("div",{style:{display:"flex",gap:2,alignItems:"center"},children:Array.from({length:5},(n,o)=>jsx("div",{style:{width:6,height:10,borderRadius:1.5,background:o<r?t.gaugeActive:t.gaugeInactive,transition:"background 0.2s"}},o))})}function l0(e){if(Array.isArray(e.legs)&&e.legs.length===2)return [e.legs[0],e.legs[1]];let t=(r,n,o)=>({source:r,event_title:n,event_slug:o?.event_slug??"",market_id:o?.id??0,market_slug:o?.slug??"",question:o?.question??"",status:o?.status??"open",outcomes:o?.outcomes,best_price:o?.outcomes?.[0]?.best_ask??o?.outcomes?.[0]?.price??void 0,vol_24h_usd:o?.volume_24h??void 0});return !e.market_a||!e.market_b?null:[t(e.source_a,e.event_a_title??"",e.market_a),t(e.source_b,e.event_b_title??"",e.market_b)]}function rl({match:e,onSelectMatch:t,getMatchHref:r,onSelectLeg:n,getLegHref:o,onHover:i,getMarketHref:s,LinkComponent:a}){let{t:l}=useTranslation(),c=l0(e);if(!c)return null;let[d,p]=c,m=e.spread_percent!=null?e.spread_percent:e.spread!=null?e.spread*100:null,u=Zg(m),f=tl[u],h=d.best_price!=null&&p.best_price!=null?d.best_price<=p.best_price?d.source:p.source:null,g=d.event_title||p.event_title,v=e.signal_tag??"stale_data",S=Ja[v]??Ja.stale_data,w=r?.(e),P=jsxs(Fragment,{children:[jsx("style",{children:s0}),m!=null&&jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",background:`linear-gradient(90deg, ${f.bandFrom}, ${f.bandTo})`,borderBottom:"1px solid rgba(39,39,42,0.3)"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,flexShrink:0,color:f.color},fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),jsxs("span",{style:{fontSize:15,fontWeight:700,fontVariantNumeric:"tabular-nums",color:f.color},children:[m.toFixed(1),"%"]}),jsx("span",{style:{fontSize:10,fontWeight:500,color:"rgba(161,161,170,0.7)",textTransform:"uppercase",letterSpacing:"0.06em"},children:l("predict.matches.gap")})]}),jsx(a0,{tier:u})]}),jsxs("div",{style:{padding:"14px 14px 12px"},children:[jsx("h3",{style:{fontSize:13,fontWeight:600,lineHeight:1.4,letterSpacing:"-0.2px",color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",margin:"0 0 12px"},children:g}),jsxs("div",{style:{borderRadius:10,border:"1px solid rgba(39,39,42,0.4)",overflow:"hidden"},children:[jsx(Za,{leg:d,isCheaper:h===d.source,externalUrlFallback:s?.(e,d.source),internalHref:o?.(e,d),onSelect:n?()=>n(e,d):void 0,LinkComponent:a}),jsx("div",{style:{height:1,background:"rgba(39,39,42,0.3)"}}),jsx(Za,{leg:p,isCheaper:h===p.source,externalUrlFallback:s?.(e,p.source),internalHref:o?.(e,p),onSelect:n?()=>n(e,p):void 0,LinkComponent:a})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.15)",padding:"8px 14px"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,fontSize:10,color:"#71717a"},children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}),Ko(e.combined_volume)]}),e.combined_volume_24h!=null&&e.combined_volume_24h>0&&jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z"})}),Ko(e.combined_volume_24h)," ",l("predict.matches.vol24h")]}),e.age_seconds!=null&&jsxs("span",{title:l("predict.matches.updatedAgo",{seconds:e.age_seconds}),style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("polyline",{points:"12 6 12 12 16 14"})]}),c0(l,e.age_seconds)]})]}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,color:"#52525b"},children:[jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:S.dot,flexShrink:0}}),l(S.label)]})]})]}),x={display:"block",color:"inherit",textDecoration:"none",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",cursor:w||t?"pointer":void 0},E=T=>{let B=T.currentTarget,R=e0[u];B.style.borderColor=R.border,B.style.boxShadow=R.shadow,i?.(e);},k=T=>{let B=T.currentTarget;B.style.borderColor="rgba(39,39,42,0.6)",B.style.boxShadow="none";};return w&&a?jsx(a,{href:w,className:"group match-card",children:jsx("div",{style:x,onMouseEnter:E,onMouseLeave:k,onClick:()=>t?.(e),children:P})}):jsx("div",{className:"group match-card",role:t?"button":void 0,tabIndex:t?0:void 0,style:x,onMouseEnter:E,onMouseLeave:k,onClick:()=>t?.(e),onKeyDown:T=>{t&&(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),t(e));},children:P})}function c0(e,t){if(t<60)return e("predict.matches.ageJustNow");if(t<3600){let n=Math.floor(t/60);return e("predict.matches.ageMinutes",{count:n})}let r=Math.floor(t/3600);return e("predict.matches.ageHours",{count:r})}function Za({leg:e,isCheaper:t,externalUrlFallback:r,internalHref:n,onSelect:o,LinkComponent:i}){let{t:s}=useTranslation(),a=St(e.source),l=i0(e.source),c=e.best_price,d=e.outcomes?.[0]?.label??null,p=e.external_url??r,m=t0(e.age_seconds),u=v=>{v.stopPropagation();},f=!!(n||o),h={display:"flex",alignItems:"center",gap:8,padding:"10px 12px",background:t?"rgba(199,255,46,0.03)":"transparent",cursor:f?"pointer":void 0,color:"inherit",textDecoration:"none"},g=jsxs(Fragment,{children:[t?jsx("span",{style:{fontSize:10,color:"#c7ff2e",flexShrink:0},children:"\u2605"}):jsx("span",{style:{width:10,flexShrink:0}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,width:100,flexShrink:0},children:[a.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",color:l.text,textTransform:"uppercase"},children:a.label}),m&&jsx("span",{title:e.age_seconds!=null?s("predict.matches.updatedAgo",{seconds:e.age_seconds}):void 0,style:{width:6,height:6,borderRadius:"50%",background:r0[m],flexShrink:0}})]}),jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:1},children:[d&&jsx("span",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d}),jsxs("span",{style:{fontSize:9,color:"#52525b"},children:[Ko(e.vol_24h_usd)," ",s("predict.matches.vol24h")]})]}),jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:3,flexShrink:0},children:[jsx("span",{style:{fontSize:18,fontWeight:700,fontVariantNumeric:"tabular-nums",color:t?"#c7ff2e":"#f4f4f5"},children:c!=null?(c*100).toFixed(1):"-"}),jsx("span",{style:{fontSize:9,color:"#71717a"},children:s("predict.matches.centsYes")})]}),p?jsx("a",{href:p,target:"_blank",rel:"noopener noreferrer","aria-label":s("predict.matches.viewOn",{platform:a.label}),title:s("predict.matches.viewOn",{platform:a.label}),onClick:v=>v.stopPropagation(),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,borderRadius:4,color:"#71717a",flexShrink:0},onMouseEnter:v=>{v.currentTarget.style.color="#d4d4d8",v.currentTarget.style.background="rgba(255,255,255,0.05)";},onMouseLeave:v=>{v.currentTarget.style.color="#71717a",v.currentTarget.style.background="transparent";},children:jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M7 7h10v10"}),jsx("path",{d:"M7 17 17 7"})]})}):jsx("span",{style:{width:18,flexShrink:0}})]});return n&&i?jsx(i,{href:n,className:"match-card-leg-link",onClick:v=>{u(v),o?.();},children:jsx("div",{style:h,children:g})}):f?jsx("div",{role:"link",tabIndex:0,style:h,onClick:v=>{u(v),o?.();},onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),u(v),o?.());},children:g}):jsx("div",{style:h,children:g})}var al=forwardRef(function({sortBy:t,sortAsc:r,minVolume:n,signal:o,onSelectMatch:i,getMatchHref:s,onSelectLeg:a,getLegHref:l,onSelect:c,onHover:d,getMarketHref:p,LinkComponent:m,onStatsChange:u},f){let{t:h}=useTranslation(),{data:g,hasNextPage:v,fetchNextPage:S,isFetchingNextPage:w,isLoading:P,isPlaceholderData:x,refetch:E}=useInfiniteMatchMarkets({sort_by:t,sort_asc:r,min_volume:n,signal:o,status:"active",limit:20},{placeholderData:keepPreviousData}),[k,T]=useState(0),[B,R]=useState(false);B&&!x?(R(false),T(Y=>Y+1)):x&&!B&&R(true),useImperativeHandle(f,()=>({refetch:()=>{E();}}),[E]);let A=useMemo(()=>g?.pages.flatMap(Y=>Y.items??[])??[],[g]),N=g?.pages[0]?.total,W=useMemo(()=>{let Y=0,b=0,y=0;for(let $ of A){let j=$.spread??0;j>Y&&(Y=j),j>=.03&&y++,$.combined_volume!=null&&(b+=$.combined_volume);}return {activePairs:N??A.length,maxSpread:Y,highSpreadCount:y,totalVolume:b}},[A,N]);useEffect(()=>{W.activePairs>0&&u?.(W);},[W,u]);let D=useRef(null),le=useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]);if(useEffect(()=>{let Y=D.current;if(!Y)return;let b=new IntersectionObserver(y=>{y[0]?.isIntersecting&&v&&!w&&S();},{rootMargin:"200px"});return b.observe(Y),()=>b.disconnect()},[v,w,S]),useEffect(()=>{if(v)return document.documentElement.style.overscrollBehaviorY="none",()=>{document.documentElement.style.overscrollBehaviorY="";}},[v]),P)return jsx(v0,{});if(A.length===0)return jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"80px 0",color:"rgba(255,255,255,0.35)"},children:jsx("p",{style:{fontSize:18},children:h("predict.matches.empty")})});let X=!v&&A.length>0;return jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[jsx("style",{children:`
128
128
  @media(max-width:1023px){.matches-card-grid{grid-template-columns:1fr!important}}
129
129
  @keyframes matchCardEnter{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}
130
- `}),jsx("div",{className:"matches-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:16},children:g?.pages.map(Y=>Y.items?.map((b,y)=>jsx("div",{style:{animation:`matchCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${y*35}ms both`},children:jsx(za,{match:b,onSelectMatch:i,getMatchHref:s,onSelectLeg:a,getLegHref:l,onHover:d,onSelect:c,getMarketHref:p,LinkComponent:m})},`${k}-${b.match_id}-${b.source_a}-${b.market_a?.slug??y}`)))}),jsxs("div",{ref:O,style:{display:"flex",flexDirection:"column",alignItems:"center",gap:8,padding:"16px 0",minHeight:1},children:[jsx("style",{children:"@keyframes match-load-spin{to{transform:rotate(360deg)}}"}),w&&jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#71717a",fontSize:13},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:"match-load-spin 1s linear infinite"},children:jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),h("predict.matches.loadMore")]})]}),X&&jsx(Rg,{onScrollToTop:ae})]})});function Rg({onScrollToTop:e}){let{t}=useTranslation();return jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:16,padding:"24px 0"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:16,width:"100%"},children:[jsx("div",{style:{height:1,width:64,background:"rgba(82,82,91,0.5)"}}),jsx("span",{style:{fontSize:12,fontWeight:500,color:"#71717a"},children:t("predict.matches.endOfList")}),jsx("div",{style:{height:1,width:64,background:"rgba(82,82,91,0.5)"}})]}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:4,fontSize:12,fontWeight:500,color:"#a1a1aa",background:"none",border:"none",cursor:"pointer",padding:0},onClick:e,children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12 19V5"}),jsx("path",{d:"m5 12 7-7 7 7"})]}),jsx("span",{children:t("predict.matches.backToTop")})]})]})}function _g(){return jsxs(Fragment,{children:[jsx("style",{children:"@keyframes shimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}@media(max-width:1023px){.matches-skeleton-grid{grid-template-columns:1fr!important}}"}),jsx("div",{className:"matches-skeleton-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:16},children:Array.from({length:6}).map((e,t)=>jsx(Ig,{index:t},t))})]})}function Ig({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(n=>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}})]},n))}),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 Hg={spread:"predict.matches.topOpportunities",volume:"predict.matches.highestVolume",confidence:"predict.matches.trendingToday"};function zg(){let[e,t]=useState("");return useEffect(()=>{let r=()=>{let o=new Date;return `${String(o.getHours()).padStart(2,"0")}:${String(o.getMinutes()).padStart(2,"0")}`};t(r());let n=setInterval(()=>t(r()),1e4);return ()=>clearInterval(n)},[]),jsx("span",{children:e})}function Wg({stats:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsx("style",{children:"@media(max-width:768px){.matches-status-bar{display:none!important}}"}),jsxs("div",{className:"matches-status-bar",style:{position:"fixed",bottom:0,left:0,right:0,height:28,display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 12px",background:"rgba(12,12,13,0.8)",borderTop:"1px solid rgba(39,39,42,0.6)",fontSize:11,color:"rgba(255,255,255,0.4)",zIndex:50,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",flexShrink:0},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,color:"#00bc7d"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12 20h.01"}),jsx("path",{d:"M2 8.82a15 15 0 0 1 20 0"}),jsx("path",{d:"M5 12.859a10 10 0 0 1 14 0"}),jsx("path",{d:"M8.5 16.429a5 5 0 0 1 7 0"})]}),jsx("span",{style:{color:"#00bc7d",fontWeight:500},children:t("predict.matches.status.live")})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)"}}),e&&jsxs("div",{className:"hidden sm:flex",style:{alignItems:"center",gap:12},children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"})}),jsx("span",{style:{color:"#52525b"},children:t("predict.matches.status.markets")}),jsx("span",{style:{color:"#d4d4d8",fontWeight:500,fontVariantNumeric:"tabular-nums"},children:formatAmount(e.activePairs)})]}),jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}),jsx("span",{style:{color:"#52525b"},children:t("predict.matches.status.vol24h")}),jsx("span",{style:{color:"#d4d4d8",fontWeight:500,fontVariantNumeric:"tabular-nums"},children:e.totalVolume>=1e6?`$${(e.totalVolume/1e6).toFixed(1)}M`:e.totalVolume>=1e3?`$${Math.round(e.totalVolume/1e3)}K`:`$${e.totalVolume}`})]})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("a",{href:"#",target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",textDecoration:"none",transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),jsx("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),jsx("path",{d:"M10 9H8"}),jsx("path",{d:"M16 13H8"}),jsx("path",{d:"M16 17H8"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.docs")})]}),jsxs("a",{href:"#",target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",textDecoration:"none",transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"currentColor",children:jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),jsx("span",{className:"hidden lg:inline",children:"X"})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)",margin:"0 4px"}}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.watchlist")})]}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2.5"}),jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.portfolio")})]}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),jsx("path",{d:"M12 17h.01"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.help")})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)",margin:"0 4px"}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("polyline",{points:"12 6 12 12 16 14"})]}),jsx(zg,{})]})]})]})]})}function ek({onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:n,onHover:o,onSelect:i,getMarketHref:s,LinkComponent:a,bgImageSrc:l}){let{t:c}=useTranslation(),[d,p]=useState("spread"),[m,u]=useState(false),[f,h]=useState(void 0),[g,v]=useState(),S=useRef(null),w=useCallback(k=>{p(k);},[]),N=useCallback(k=>{u(k);},[]),x=useCallback(k=>{startTransition(()=>{v(k);});},[]),T=useCallback(()=>{S.current?.refetch();},[]);return jsxs("div",{style:{minHeight:"100vh",position:"relative"},children:[jsx("style",{children:`
130
+ `}),jsx("div",{className:"matches-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:16},children:g?.pages.map(Y=>Y.items?.map((b,y)=>jsx("div",{style:{animation:`matchCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${y*35}ms both`},children:jsx(rl,{match:b,onSelectMatch:i,getMatchHref:s,onSelectLeg:a,getLegHref:l,onHover:d,onSelect:c,getMarketHref:p,LinkComponent:m})},`${k}-${b.match_id}-${b.source_a}-${b.market_a?.slug??y}`)))}),jsxs("div",{ref:D,style:{display:"flex",flexDirection:"column",alignItems:"center",gap:8,padding:"16px 0",minHeight:1},children:[jsx("style",{children:"@keyframes match-load-spin{to{transform:rotate(360deg)}}"}),w&&jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#71717a",fontSize:13},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:"match-load-spin 1s linear infinite"},children:jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),h("predict.matches.loadMore")]})]}),X&&jsx(h0,{onScrollToTop:le})]})});function h0({onScrollToTop:e}){let{t}=useTranslation();return jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:16,padding:"24px 0"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:16,width:"100%"},children:[jsx("div",{style:{height:1,width:64,background:"rgba(82,82,91,0.5)"}}),jsx("span",{style:{fontSize:12,fontWeight:500,color:"#71717a"},children:t("predict.matches.endOfList")}),jsx("div",{style:{height:1,width:64,background:"rgba(82,82,91,0.5)"}})]}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:4,fontSize:12,fontWeight:500,color:"#a1a1aa",background:"none",border:"none",cursor:"pointer",padding:0},onClick:e,children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12 19V5"}),jsx("path",{d:"m5 12 7-7 7 7"})]}),jsx("span",{children:t("predict.matches.backToTop")})]})]})}function v0(){return jsxs(Fragment,{children:[jsx("style",{children:"@keyframes shimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}@media(max-width:1023px){.matches-skeleton-grid{grid-template-columns:1fr!important}}"}),jsx("div",{className:"matches-skeleton-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:16},children:Array.from({length:6}).map((e,t)=>jsx(x0,{index:t},t))})]})}function x0({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(n=>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}})]},n))}),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 N0={spread:"predict.matches.topOpportunities",volume:"predict.matches.highestVolume",confidence:"predict.matches.trendingToday"};function P0(){let[e,t]=useState("");return useEffect(()=>{let r=()=>{let o=new Date;return `${String(o.getHours()).padStart(2,"0")}:${String(o.getMinutes()).padStart(2,"0")}`};t(r());let n=setInterval(()=>t(r()),1e4);return ()=>clearInterval(n)},[]),jsx("span",{children:e})}function C0({stats:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsx("style",{children:"@media(max-width:768px){.matches-status-bar{display:none!important}}"}),jsxs("div",{className:"matches-status-bar",style:{position:"fixed",bottom:0,left:0,right:0,height:28,display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 12px",background:"rgba(12,12,13,0.8)",borderTop:"1px solid rgba(39,39,42,0.6)",fontSize:11,color:"rgba(255,255,255,0.4)",zIndex:50,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",flexShrink:0},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,color:"#00bc7d"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12 20h.01"}),jsx("path",{d:"M2 8.82a15 15 0 0 1 20 0"}),jsx("path",{d:"M5 12.859a10 10 0 0 1 14 0"}),jsx("path",{d:"M8.5 16.429a5 5 0 0 1 7 0"})]}),jsx("span",{style:{color:"#00bc7d",fontWeight:500},children:t("predict.matches.status.live")})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)"}}),e&&jsxs("div",{className:"hidden sm:flex",style:{alignItems:"center",gap:12},children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"})}),jsx("span",{style:{color:"#52525b"},children:t("predict.matches.status.markets")}),jsx("span",{style:{color:"#d4d4d8",fontWeight:500,fontVariantNumeric:"tabular-nums"},children:formatAmount(e.activePairs)})]}),jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}),jsx("span",{style:{color:"#52525b"},children:t("predict.matches.status.vol24h")}),jsx("span",{style:{color:"#d4d4d8",fontWeight:500,fontVariantNumeric:"tabular-nums"},children:e.totalVolume>=1e6?`$${(e.totalVolume/1e6).toFixed(1)}M`:e.totalVolume>=1e3?`$${Math.round(e.totalVolume/1e3)}K`:`$${e.totalVolume}`})]})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("a",{href:"#",target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",textDecoration:"none",transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),jsx("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),jsx("path",{d:"M10 9H8"}),jsx("path",{d:"M16 13H8"}),jsx("path",{d:"M16 17H8"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.docs")})]}),jsxs("a",{href:"#",target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",textDecoration:"none",transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"currentColor",children:jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),jsx("span",{className:"hidden lg:inline",children:"X"})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)",margin:"0 4px"}}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.watchlist")})]}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2.5"}),jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.portfolio")})]}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),jsx("path",{d:"M12 17h.01"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.help")})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)",margin:"0 4px"}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("polyline",{points:"12 6 12 12 16 14"})]}),jsx(P0,{})]})]})]})]})}function rS({onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:n,onHover:o,onSelect:i,getMarketHref:s,LinkComponent:a,bgImageSrc:l}){let{t:c}=useTranslation(),[d,p]=useState("spread"),[m,u]=useState(false),[f,h]=useState(void 0),[g,v]=useState(),S=useRef(null),w=useCallback(k=>{p(k);},[]),P=useCallback(k=>{u(k);},[]),x=useCallback(k=>{startTransition(()=>{v(k);});},[]),E=useCallback(()=>{S.current?.refetch();},[]);return jsxs("div",{style:{minHeight:"100vh",position:"relative"},children:[jsx("style",{children:`
131
131
  @keyframes matchFadeIn{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}
132
132
  .match-fade-in{animation:matchFadeIn .5s ease-out both}
133
133
  .match-fade-in-d1{animation:matchFadeIn .5s ease-out .1s both}
134
134
  .match-fade-in-d2{animation:matchFadeIn .5s ease-out .2s both}
135
- `}),jsxs("div",{style:{position:"relative",overflow:"hidden",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:0,overflow:"hidden"},children:[l&&jsx("img",{src:l,alt:"","aria-hidden":"true",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",objectPosition:"center center",opacity:.3,mixBlendMode:"lighten",maskImage:"linear-gradient(to bottom, black 50%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 50%, transparent 100%)"}}),jsx("div",{style:{position:"absolute",inset:0,opacity:.025,backgroundImage:"radial-gradient(circle at 1px 1px, rgb(255 255 255) 1px, transparent 0)",backgroundSize:"20px 20px"}})]}),jsx("style",{children:".matches-hero-wrap{padding:40px 16px 32px}@media(min-width:640px){.matches-hero-wrap{padding:48px 24px 40px}}@media(min-width:1024px){.matches-hero-wrap{padding:52px 32px 44px}}"}),jsx("div",{className:"match-fade-in matches-hero-wrap",style:{position:"relative",zIndex:2,maxWidth:1152,margin:"0 auto"},children:jsx(Da,{stats:g})})]}),jsxs("div",{style:{position:"sticky",top:0,zIndex:40,background:"rgba(10,10,11,0.8)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsx("style",{children:".matches-toolbar-inner{padding:12px 16px}@media(min-width:640px){.matches-toolbar-inner{padding:12px 24px}}@media(min-width:1024px){.matches-toolbar-inner{padding:12px 32px}}"}),jsxs("div",{className:"matches-toolbar-inner",style:{maxWidth:1152,margin:"0 auto",display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,minWidth:0},children:[jsx("div",{className:"hidden sm:flex",style:{alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:10,background:"linear-gradient(to bottom right, rgba(199,255,46,0.15), rgba(23,201,100,0.15))",border:"1px solid rgba(199,255,46,0.15)",flexShrink:0},children:jsxs("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"}),jsx("path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"}),jsx("path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"})]})}),jsxs("div",{style:{minWidth:0},children:[jsx("h2",{style:{fontSize:14,fontWeight:600,color:"#fff",margin:0,letterSpacing:"-0.28px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c(Hg[d])}),g&&g.activePairs>0&&jsx("p",{className:"hidden sm:block",style:{fontSize:11,color:"#71717a",margin:0},children:c("predict.matches.pairsFound",{count:g.activePairs})})]})]}),jsx(Ia,{sortBy:d,onSortChange:w,sortAsc:m,onSortAscChange:N,minVolume:f,onMinVolumeChange:h,onRefresh:T})]})]}),jsx("style",{children:".matches-content-wrap{padding:24px 16px 80px}@media(min-width:640px){.matches-content-wrap{padding:32px 24px 80px}}@media(min-width:1024px){.matches-content-wrap{padding:24px 32px 80px}}"}),jsxs("div",{className:"match-fade-in-d2 matches-content-wrap",style:{position:"relative",maxWidth:1152,margin:"0 auto"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:16,padding:"8px 12px",borderRadius:8,border:"1px solid rgba(39,39,42,0.4)",background:"rgba(24,24,27,0.25)"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#52525b",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"})}),jsxs("p",{style:{fontSize:11,color:"#52525b",lineHeight:1.5,margin:0},children:[jsx("span",{style:{color:"#71717a",fontWeight:500},children:c("predict.matches.experimentalFeature")})," \u2014 ",c("predict.matches.disclaimer")]})]}),jsx(Va,{ref:S,sortBy:d,sortAsc:m,minVolume:f,onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:n,onHover:o,onSelect:i,getMarketHref:s,LinkComponent:a,onStatsChange:x})]}),jsx(Wg,{stats:g})]})}function Fo(e){return e==null?"-":formatAmountInUsd(e)}var Kg={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"}},Vg={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 jg(e){return Kg[e]??Vg}function Gg(e){if(!e.matched_markets?.length)return null;let t=null,r=-1;for(let n of e.matched_markets){let o=n.spread??0;o>r&&(r=o,t=n);}return t}function qg(e,t){let r=e.entries.find(a=>a.source===(t?.source_a??e.entries[0]?.source)),n=e.entries.find(a=>a.source===(t?.source_b??e.entries[1]?.source)),o=a=>{if(!a?.outcomes?.[0])return {name:null,price:null};let l=a.outcomes[0];return {name:l.label||null,price:l.best_ask??l.price??null}},i=o(t?.market_a),s=o(t?.market_b);return [{source:t?.source_a??r?.source??"unknown",outcomeName:i.name,yesPrice:i.price,volume:r?.event?.volume??null,event:r?.event},{source:t?.source_b??n?.source??"unknown",outcomeName:s.name,yesPrice:s.price,volume:n?.event?.volume??null,event:n?.event}]}function ak({group:e,onSelectEntry:t,getEventHref:r,LinkComponent:n}){let {t:o}=useTranslation(),i=useMemo(()=>Gg(e),[e]),s=e.max_spread!=null?e.max_spread*100:null,[a,l]=useMemo(()=>qg(e,i),[e,i]),c=s!=null&&s>=3;a.yesPrice!=null&&l.yesPrice!=null?a.source==="kalshi"?a.yesPrice>l.yesPrice:l.yesPrice>a.yesPrice:false;let p=a.yesPrice!=null&&l.yesPrice!=null?a.yesPrice<=l.yesPrice?a:l:null,m=p?kt(p.source):null,u=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:f=>{let h=f.currentTarget;h.style.borderColor="rgba(63,63,70,0.6)",h.style.boxShadow="0 10px 15px -3px rgba(0,0,0,0.2)";},onMouseLeave:f=>{let h=f.currentTarget;h.style.borderColor="rgba(39,39,42,0.6)",h.style.boxShadow="none";},children:[s!=null&&jsxs("span",{style:{position:"absolute",top:12,right:12,zIndex:10,display:"inline-flex",alignItems:"center",gap:4,borderRadius:10,padding:"4px 10px",fontSize:12,fontWeight:600,border:`1px solid ${c?"rgba(255,185,0,0.3)":s>=2?"rgba(166,132,255,0.3)":"rgba(156,163,175,0.3)"}`,background:c?"rgba(255,185,0,0.15)":s>=2?"rgba(166,132,255,0.15)":"rgba(156,163,175,0.12)",color:c?"#ffb900":s>=2?"#a684ff":"#9ca3af"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),s.toFixed(1),"%"]}),jsxs("div",{style:{padding:16},children:[jsx("h3",{style:{fontSize:14,fontWeight:600,lineHeight:1.375,letterSpacing:"-0.28px",color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",paddingRight:80,margin:"0 0 16px"},children:e.title}),jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[jsx(qa,{data:a,isCheaper:p===a,onSelect:t,getEventHref:r,LinkComponent:n}),jsx(qa,{data:l,isCheaper:p===l,onSelect:t,getEventHref:r,LinkComponent:n})]}),p&&m&&s!=null&&jsxs("div",{style:{marginTop:12,padding:"8px 12px",borderRadius:10,display:"flex",alignItems:"center",gap:8,cursor:"pointer",transition:"all 0.15s",border:`1px solid ${u==="amber"?"rgba(255,185,0,0.15)":"rgba(166,132,255,0.15)"}`,background:u==="amber"?"rgba(255,185,0,0.05)":"rgba(166,132,255,0.05)"},onClick:()=>p.event&&t?.(p.event),children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,flexShrink:0,color:u==="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:u==="amber"?"rgba(255,185,0,0.9)":"rgba(166,132,255,0.9)"},children:o("predict.matches.buyEdge",{platform:p.source.charAt(0).toUpperCase()+p.source.slice(1),spread:s.toFixed(1)})}),jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,marginLeft:"auto",color:u==="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"})]}),Fo(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"})}),Fo(e.combined_volume_24h)," ",o("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),"%"," ",o("predict.matches.match")]})]})]})}function qa({data:e,isCheaper:t,onSelect:r,getEventHref:n,LinkComponent:o}){let{t:i}=useTranslation(),s=kt(e.source),a=jg(e.source),l=e.event?n?.(e.event):void 0,c=jsxs("div",{style:{borderRadius:14,border:`1px solid ${a.border}`,background:a.bg,padding:12,cursor:l||r?"pointer":void 0,transition:"border-color 0.15s"},onMouseEnter:d=>{d.currentTarget.style.borderColor=a.hoverBorder;},onMouseLeave:d=>{d.currentTarget.style.borderColor=a.border;},onClick:()=>e.event&&r?.(e.event),children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[s.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.05em",color:a.text,textTransform:"uppercase"},children:s.label}),jsxs("svg",{viewBox:"0 0 24 24",className:"opacity-0 group-hover:opacity-100 transition-opacity",style:{width:10,height:10,color:"#52525b",marginLeft:"auto"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M7 7h10v10"}),jsx("path",{d:"M7 17 17 7"})]})]}),e.outcomeName&&jsx("div",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginBottom:8},children:e.outcomeName}),jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[jsx("span",{style:{fontSize:20,fontWeight:700,fontVariantNumeric:"tabular-nums",color:t?a.priceActiveColor:a.priceColor},children:e.yesPrice!=null?(e.yesPrice*100).toFixed(1):"-"}),jsx("span",{style:{fontSize:10,color:"#71717a"},children:i("predict.matches.centsYes")})]}),jsxs("div",{style:{fontSize:10,color:"#52525b",marginTop:6},children:[Fo(e.volume)," ",i("predict.matches.volume")]})]});return l&&o?jsx(o,{href:l,className:"block",children:c}):c}function Jg(e){return formatAmountInUsd(e)}function mk({matches:e,total:t}){let{t:r}=useTranslation(),n=useMemo(()=>{let o=0,i=0,s=new Set;for(let a of e){a.max_spread!=null&&a.max_spread>o&&(o=a.max_spread),a.combined_volume!=null&&(i+=a.combined_volume);for(let l of a.entries)s.add(typeof l.source=="string"?l.source:"");}return {count:t??e.length,maxSpread:o,totalVolume:i,platformCount:s.size}},[e,t]);return jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 rounded-xl border border-border/60 bg-background/50 px-4 py-3 text-sm",children:[jsx(Wn,{label:r("predict.matches.stats.matchedMarkets"),value:n.count.toLocaleString()}),jsx(Bo,{}),jsx(Wn,{label:r("predict.matches.stats.totalVolume"),value:Jg(n.totalVolume)}),jsx(Bo,{}),jsx(Wn,{label:r("predict.matches.stats.highestSpread"),value:`${(n.maxSpread*100).toFixed(1)}\xA2`,valueClassName:"text-green-400"}),jsx(Bo,{}),jsx(Wn,{label:r("predict.matches.stats.platforms"),value:String(n.platformCount)})]})}function Wn({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 Bo(){return jsx("span",{className:"hidden text-neutral-700 sm:inline",children:"|"})}function Xa(e){return `${(e*100).toFixed(1)}\xA2`}function Zg(e){return e>=.05?"text-green-400":e>=.02?"text-yellow-400":"text-neutral-400"}function vk({spread:e,arbProfit:t,className:r}){if(e==null)return null;let n=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",Zg(e)),children:Xa(e)}),n&&jsxs("span",{className:"text-xs text-green-500/80",children:["+",Xa(t)]})]})}var Gr=10,i0=64,tl=40,Un=48;function rl({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:n}=useTranslation(),[o,i]=useState(1),{data:s,isLoading:a,fetchNextPage:l,hasNextPage:c,isFetchingNextPage:d}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:50}),{data:p,isLoading:m,fetchNextPage:u,hasNextPage:f,isFetchingNextPage:h}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:50}),g=a||m,v=d||h,S=c||f,w=useMemo(()=>{let P=[];return s?.pages&&P.push(...s.pages.flatMap(W=>W.items)),p?.pages&&P.push(...p.pages.flatMap(W=>W.items)),P.sort((W,O)=>(O.timestamp??0)-(W.timestamp??0)),P},[s,p]),N=Math.max(1,Math.ceil(w.length/Gr)+(S?1:0)),x=(o-1)*Gr,T=w.slice(x,x+Gr),k=useCallback(()=>{i(P=>Math.max(1,P-1));},[]),L=useCallback(async()=>{o*Gr>=w.length&&S&&(c&&await l(),f&&await u()),i(W=>W+1);},[o,w.length,S,c,f,l,u]),H=o>1,D=o*Gr<w.length||S;if(g)return jsx(u0,{height:r});if(w.length===0&&!S)return jsx(d0,{message:n("predict.profile.noHistory"),height:r});let A=r-tl-Un;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:tl},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:n("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.profile.action")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.profile.status")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.profile.price")}),jsx("div",{className:"flex-[1.5] pr-2 text-right",children:n("predict.profile.depositWithdraw")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.profile.pnl")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.profile.fee")}),jsx("div",{className:"w-10 shrink-0"})]}),jsxs("div",{className:"hidden lg:block overflow-y-auto",style:{height:A},children:[T.map((P,W)=>jsx(s0,{trade:P},P.id??`${x+W}`)),v&&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:Un},children:[jsxs("button",{type:"button",disabled:!H,onClick:k,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",H?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",n("predict.profile.previous")]}),Array.from({length:Math.min(N,5)},(P,W)=>{let O=W+1;return jsx("button",{type:"button",onClick:()=>i(O),className:cn$1("w-8 h-8 rounded text-sm transition-colors cursor-pointer",O===o?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:O},O)}),jsxs("button",{type:"button",disabled:!D,onClick:L,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",D?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[n("predict.profile.next")," \u2192"]})]}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-Un},children:T.map((P,W)=>jsx(a0,{trade:P},P.id??`m-${x+W}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:Un},children:[jsx("button",{type:"button",disabled:!H,onClick:k,className:cn$1("text-sm cursor-pointer",H?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:o}),jsx("button",{type:"button",disabled:!D,onClick:L,className:cn$1("text-sm cursor-pointer",D?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function s0({trade:e}){let{t}=useTranslation(),r=e.type==="REDEEM",n=e.side?.toUpperCase()==="BUY",o=e.price??0,i=e.usd_size??0,s=nl(e.type,t),a=r||n,l=a?"+":"-",c=a?"text-success":"text-foreground",d=e.event?.title??e.market?.question??"\u2014",p=e.event?.image_url,m=e.outcome??"",u=al(e.timestamp),f=ol(e),h=l0(e),g=c0(e);return jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:i0},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[p&&jsx("img",{src:p,alt:"",className:"w-8 h-8 rounded-full object-cover shrink-0"}),jsxs("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:[jsx("span",{className:"text-foreground truncate font-medium text-sm",children:d}),jsxs("span",{className:"text-[11px] text-neutral",children:[m&&jsx("span",{className:"mr-1",children:m}),jsx("span",{children:u})]})]})]})}),jsx("div",{className:"flex-1 pr-2",children:jsx("span",{className:cn$1("text-sm font-medium",r?"text-primary":n?"text-success":"text-danger"),children:t(r?"predict.profile.redeem":n?"predict.profile.buy":"predict.profile.sell")})}),jsx("div",{className:"flex-1 pr-2 text-sm text-foreground",children:s}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:sl(o)}),jsx("div",{className:cn$1("flex-[1.5] pr-2 text-right font-mono",c),children:i>0?jsxs(Fragment,{children:[l,"$",i.toFixed(2)]}):"\u2014"}),jsx("div",{className:cn$1("flex-1 pr-2 text-right font-mono",h!==null?h>=0?"text-success":"text-danger":"text-neutral"),children:h!==null?`${h>=0?"+":"-"}$${Math.abs(h).toFixed(2)}`:"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-neutral",children:g!==null?`$${g.toFixed(2)}`:"\u2014"}),jsx("div",{className:"w-10 shrink-0 text-right",children:f&&jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"text-neutral hover:text-foreground transition-colors","aria-label":"View transaction",children:jsx(il,{})})})]})}function a0({trade:e}){let{t}=useTranslation(),r=e.type==="REDEEM",n=e.side?.toUpperCase()==="BUY",o=e.price??0,i=e.usd_size??0,s=nl(e.type,t),a=e.event?.title??e.market?.question??"\u2014",l=al(e.timestamp),c=ol(e);return jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.event?.image_url&&jsx("img",{src:e.event.image_url,alt:"",className:"w-6 h-6 rounded-full object-cover shrink-0"}),jsx("span",{className:"text-sm font-medium text-foreground line-clamp-2",children:a})]}),jsx("span",{className:"text-[11px] text-neutral whitespace-nowrap",children:l})]}),jsxs("div",{className:"flex items-center gap-4 text-xs flex-wrap",children:[jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.action")}),jsx("span",{className:cn$1("font-medium",r?"text-primary":n?"text-success":"text-danger"),children:t(r?"predict.profile.redeem":n?"predict.profile.buy":"predict.profile.sell")})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.status")}),jsx("span",{className:"text-foreground",children:s})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.price")}),jsx("span",{className:"font-mono text-foreground",children:sl(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:i>0?`$${i.toFixed(2)}`:"\u2014"})]}),c&&jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"ml-auto text-neutral hover:text-foreground transition-colors",children:jsx(il,{})})]})]})}function nl(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 ol(e){if(e.tx_hash)return e.source==="polymarket"?`https://polygonscan.com/tx/${e.tx_hash}`:`https://solscan.io/tx/${e.tx_hash}`}function l0(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 n=parseFloat(r);if(!Number.isNaN(n))return n}}return e.type==="REDEEM"&&e.usd_size!=null?e.usd_size:null}function c0(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 n=parseFloat(r);if(!Number.isNaN(n))return n}}return null}function il(){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 d0({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function u0({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 sl(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function al(e){let t=new Date(e*1e3),r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getFullYear(),a=t.getTimezoneOffset(),l=a<=0?"+":"-",c=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${s} (${l}${c})`}var qr=10,x0=64,cl=40,$n=48;function ul({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:n}=useTranslation(),o=useCancelOrder(),[i,s]=useState(1),{data:a,isLoading:l,fetchNextPage:c,hasNextPage:d,isFetchingNextPage:p}=useInfiniteOrders({source:"kalshi",wallet_address:e??""}),{data:m,isLoading:u,fetchNextPage:f,hasNextPage:h,isFetchingNextPage:g}=useInfiniteOrders({source:"polymarket",wallet_address:t??""}),v=l||u,S=p||g,w=d||h,N=useMemo(()=>{let O=[],ae=new Set(["live","open","submitted","pending"]);return a?.pages&&O.push(...a.pages.flatMap(X=>X.items).filter(X=>ae.has(X.status))),m?.pages&&O.push(...m.pages.flatMap(X=>X.items).filter(X=>ae.has(X.status))),O},[a,m]),x=useCallback(O=>{o.mutate({source:O.source,id:O.id});},[o]),T=Math.max(1,Math.ceil(N.length/qr)+(w?1:0)),k=(i-1)*qr,L=N.slice(k,k+qr),H=useCallback(()=>{s(O=>Math.max(1,O-1));},[]),D=useCallback(async()=>{i*qr>=N.length&&w&&(d&&await c(),h&&await f()),s(ae=>ae+1);},[i,N.length,w,d,h,c,f]),A=i>1,P=i*qr<N.length||w;if(v)return jsx(S0,{height:r});if(N.length===0&&!w)return jsx(k0,{message:n("predict.profile.noOrders"),height:r});let W=r-cl-$n;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:cl},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:n("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.profile.action")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.profile.type")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.profile.fillPrice")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.profile.cost")})]}),jsxs("div",{className:"hidden lg:block overflow-y-auto",style:{height:W},children:[L.map(O=>jsx(b0,{order:O,onCancel:x},O.id)),S&&jsx("div",{className:"flex justify-center items-center py-4",children:jsx(Spinner,{size:"sm"})})]}),jsx(dl,{className:"hidden lg:flex",currentPage:i,totalPages:T,canGoPrev:A,canGoNext:P,onPrev:H,onNext:D,onPage:s,t:n}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-$n},children:L.map(O=>jsx(y0,{order:O,onCancel:x},O.id))}),jsx(dl,{className:"lg:hidden",currentPage:i,totalPages:T,canGoPrev:A,canGoNext:P,onPrev:H,onNext:D,onPage:s,t:n,compact:true})]})}function b0({order:e,onCancel:t}){let{t:r}=useTranslation(),n=e.side==="BUY",o=e.price?parseFloat(e.price):0,i=e.in_amount?parseFloat(e.in_amount):o*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:x0},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",n?"text-success":"text-danger"),children:r(n?"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:o>0?pl(o):"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:i>0?`$${i.toFixed(2)}`:"\u2014"})]})}function y0({order:e,onCancel:t}){let{t:r}=useTranslation(),n=e.side==="BUY",o=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",n?"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:o>0?pl(o):"\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 dl({className:e,currentPage:t,totalPages:r,canGoPrev:n,canGoNext:o,onPrev:i,onNext:s,onPage:a,t:l,compact:c}){return c?jsxs("div",{className:cn$1("flex items-center justify-center gap-3 shrink-0",e),style:{height:$n},children:[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:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:t}),jsx("button",{type:"button",disabled:!o,onClick:s,className:cn$1("text-sm cursor-pointer",o?"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:$n},children:[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:["\u2190 ",l("predict.profile.previous")]}),Array.from({length:Math.min(r,5)},(d,p)=>{let m=p+1;return jsx("button",{type:"button",onClick:()=>a(m),className:cn$1("w-8 h-8 rounded text-sm transition-colors cursor-pointer",m===t?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:m},m)}),jsxs("button",{type:"button",disabled:!o,onClick:s,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:[l("predict.profile.next")," \u2192"]})]})}function k0({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function S0({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 pl(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}var $o=10,C0=64,ml=40,Kn=48;function fl({positions:e,isLoading:t,listHeight:r,onClosePosition:n,onEventClick:o}){let{t:i}=useTranslation(),[s,a]=useState(1),l=useCallback(()=>{for(let h of e)n?.(h);},[e,n]);if(t)return jsx(L0,{height:r});if(e.length===0)return jsx(T0,{message:i("predict.profile.noPositions"),height:r});let c=Math.max(1,Math.ceil(e.length/$o)),d=(s-1)*$o,p=e.slice(d,d+$o),m=s>1,u=s<c,f=r-ml-Kn;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:ml},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:i("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.totalSize")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.value")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.avgPrice")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.markPrice")}),jsxs("div",{className:"flex-[1.5] pr-2 text-right",children:[jsx("span",{children:i("predict.profile.pnl")}),jsxs("span",{className:"text-[10px] ml-1 opacity-60",children:["(",i("predict.profile.pnlExcludeFees"),")"]})]}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.payoutIfRight")}),jsx("div",{className:"flex-[1.5] pr-2 text-right",children:i("predict.profile.estSettlement")}),jsx("div",{className:"w-20 shrink-0 text-right",children:n&&e.length>0&&jsx("button",{type:"button",onClick:l,className:"text-xs text-primary hover:text-primary/80 cursor-pointer transition-colors",children:i("predict.profile.closeAll")})})]}),jsx("div",{className:"hidden lg:block overflow-y-auto",style:{height:f},children:p.map((h,g)=>jsx(M0,{position:h,onClosePosition:n,onEventClick:o},`${h.source}-${h.market?.slug??d+g}`))}),jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:Kn},children:[jsxs("button",{type:"button",disabled:!m,onClick:()=>a(h=>Math.max(1,h-1)),className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",m?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",i("predict.profile.previous")]}),Array.from({length:Math.min(c,5)},(h,g)=>{let v=g+1;return jsx("button",{type:"button",onClick:()=>a(v),className:cn$1("w-8 h-8 rounded text-sm transition-colors cursor-pointer",v===s?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:v},v)}),jsxs("button",{type:"button",disabled:!u,onClick:()=>a(h=>h+1),className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",u?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[i("predict.profile.next")," \u2192"]})]}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-Kn},children:p.map((h,g)=>jsx(E0,{position:h,onClose:n,onEventClick:o},`${h.source}-${h.market?.slug??`m-${d+g}`}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:Kn},children:[jsx("button",{type:"button",disabled:!m,onClick:()=>a(h=>Math.max(1,h-1)),className:cn$1("text-sm cursor-pointer",m?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:s}),jsx("button",{type:"button",disabled:!u,onClick:()=>a(h=>h+1),className:cn$1("text-sm cursor-pointer",u?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function M0({position:e,onClosePosition:t,onEventClick:r}){let{t:n}=useTranslation(),o=e.pnl??0,i=e.pnl_percent??0,s=e.avg_price??0,a=e.current_price??0,l=e.current_value??e.size*a,c=e.size,d=o>0?"text-success":o<0?"text-danger":"text-foreground",p=o>0?"+":"",m=e.event?.title??e.market?.question??"\u2014",u=e.event?.image_url,f=e.side,h=e.market?.outcomes?.[0]?.label??"",g=e.market?.end_at?R0(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:C0},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:[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:m}),jsxs("span",{className:"text-[11px] text-neutral",children:[jsx("span",{className:cn$1("font-medium",f.toLowerCase()==="yes"?"text-success":"text-danger"),children:f}),h&&jsxs(Fragment,{children:[jsx("span",{className:"mx-1",children:"\xB7"}),jsx("span",{children:h})]})]})]})]})}),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:n("predict.profile.contracts",{count:Rr(e.size)})})]})}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",(e.size*s).toFixed(2)]}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Ko(s)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Ko(a)}),jsxs("div",{className:cn$1("flex-[1.5] pr-2 text-right font-mono",d),children:[jsxs("span",{children:[p,"$",Math.abs(o).toFixed(2)]}),jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",p,i.toFixed(2),"%)"]})]}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",c.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap text-xs",children:g}),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"}),n("predict.profile.close")]})})]})}function E0({position:e,onClose:t,onEventClick:r}){let{t:n}=useTranslation(),o=e.pnl??0,i=e.pnl_percent??0,s=e.current_price??0,a=o>0?"text-success":o<0?"text-danger":"text-foreground",l=o>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(Vn,{label:n("predict.profile.totalSize"),value:Rr(e.size)}),jsx(Vn,{label:n("predict.profile.markPrice"),value:Ko(s)}),jsx(Vn,{label:n("predict.profile.pnl"),value:`${l}$${Math.abs(o).toFixed(2)} (${l}${i.toFixed(1)}%)`,className:a}),jsx(Vn,{label:n("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:n("predict.profile.close")})})]})}function Vn({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 T0({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function L0({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 Ko(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function R0(e){try{let t=new Date(e),r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getFullYear(),a=t.getTimezoneOffset(),l=a<=0?"+":"-",c=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${s} (${l}${c})`}catch{return "\u2014"}}function hl({positions:e,trades:t,isLoading:r}){let{t:n}=useTranslation(),o=useMemo(()=>{let a=0,l=0;for(let u of e)a+=u.realized_pnl??0,l+=u.current_value??u.size*(u.current_price??0);let c=0,d=0,p=0;for(let u of t)c+=u.usd_size??0,u.type==="REDEEM"&&(p++,(u.usd_size??0)>0&&d++);let m=p>0?`${d} / ${p}`:"0 / 0";return {realizedPnl:a,positionsValue:l,volume:c,winRateStr:m}},[e,t]),i=o.realizedPnl>0?"text-success":o.realizedPnl<0?"text-danger":"text-foreground",s=o.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:n("predict.profile.realizedPnl")}),r?jsx(Skeleton,{className:"h-14 w-48 rounded-md"}):jsxs("span",{className:cn$1("text-5xl font-bold tabular-nums",i),children:[s,"$",Math.abs(o.realizedPnl).toFixed(2)]})]}),jsxs("div",{className:"flex items-end gap-8 sm:gap-10",children:[jsx(jo,{label:n("predict.profile.winRate"),value:o.winRateStr,isLoading:r}),jsx(jo,{label:n("predict.profile.positions"),value:`$${o.positionsValue.toFixed(2)}`,isLoading:r}),jsx(jo,{label:n("predict.profile.volume"),value:`$${o.volume.toFixed(2)}`,isLoading:r})]})]})}function jo({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 Go=600;function H0({solanaAddress:e,evmAddress:t,onClosePosition:r,onEventClick:n}){let{t:o}=useTranslation(),[i,s]=useState("positions"),a=!!(e||t),{data:l,isLoading:c}=usePositions({source:"kalshi",user:e??""}),{data:d,isLoading:p}=usePositions({source:"polymarket",user:t??""}),m=useMemo(()=>{let k=[];return l?.positions&&k.push(...l.positions),d?.positions&&k.push(...d.positions),k},[l,d]),u=c||p,{data:f,isLoading:h}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:100}),{data:g,isLoading:v}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:100}),S=useMemo(()=>[...f?.pages?.flatMap(L=>L.items)??[],...g?.pages?.flatMap(L=>L.items)??[]],[f,g]),w=u||h||v,N=m.length,T=[{key:"positions",label:N>0?`${o("predict.profile.positionsTab")} (${N})`:o("predict.profile.positionsTab")},{key:"orders",label:o("predict.profile.openOrdersTab")},{key:"history",label:o("predict.profile.historyTab")}];return a?jsxs("div",{className:"flex flex-col max-w-[1280px] mx-auto w-full px-4 max-sm:px-2",children:[jsx(hl,{positions:m,trades:S,isLoading:w}),jsx("div",{className:"flex items-center gap-1 border-b border-border",children:T.map(k=>jsx("button",{type:"button",onClick:()=>s(k.key),className:cn$1("px-3 py-3 text-base font-normal transition-colors cursor-pointer whitespace-nowrap",i===k.key?"text-foreground border-b-2 border-foreground":"text-neutral hover:text-foreground"),children:k.label},k.key))}),jsxs("div",{className:"py-2",children:[i==="positions"&&jsx(fl,{positions:m,isLoading:u,listHeight:Go,onClosePosition:r,onEventClick:n}),i==="orders"&&jsx(ul,{solanaAddress:e,evmAddress:t,listHeight:Go}),i==="history"&&jsx(rl,{solanaAddress:e,evmAddress:t,listHeight:Go})]})]}):jsx("div",{className:"flex items-center justify-center text-sm text-neutral py-24 px-4",children:o("predict.profile.connectWallet")})}function fS({isOpen:e,onClose:t,safeDeployed:r,tokenApproved:n,onDeployAndApprove:o}){let{t:i}=useTranslation(),[s,a]=useState(false),[l,c]=useState(null),[d,p]=useState(false),m=r||d,u=n||d,f=m?"done":s?"running":"pending",h=u?"done":m&&s?"running":"pending",g=m&&u,v=useCallback(async()=>{c(null),p(false),a(true);try{await o(),p(!0);}catch(x){c(x instanceof Error?x.message:String(x));}finally{a(false);}},[o]),S=[{key:"step1",label:i("predict.setup.step1"),desc:i("predict.setup.step1Desc"),status:f},{key:"step2",label:i("predict.setup.step2"),desc:i("predict.setup.step2Desc"),status:h}],w=()=>{g?t():v();},N=i(g?"predict.setup.done":"predict.setup.setupButton");return jsx(StyledModal,{isOpen:e,onOpenChange:x=>{x||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:i("predict.setup.modalTitle")}),jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxs("div",{className:"px-5 pb-5 space-y-4",children:[jsx("p",{className:"text-[13px] text-zinc-400 text-left",children:i("predict.setup.modalDescription")}),jsx("div",{className:"space-y-2.5",children:S.map((x,T)=>jsxs("div",{className:"flex gap-3 rounded-[10px] border border-zinc-700/50 bg-zinc-800/50 px-3 py-3",children:[jsx(K0,{index:T+1,status:x.status}),jsxs("div",{className:"flex-1 min-w-0 pt-0.5",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("p",{className:"text-sm font-medium text-zinc-200",children:x.label}),jsx("span",{className:`text-[11px] leading-none ${x.status==="done"?"text-[#c7ff2e]":x.status==="running"?"text-[#c7ff2e]/70":"text-zinc-500"}`,children:x.status==="done"?i("predict.setup.stepComplete"):x.status==="running"?i("predict.setup.stepRunning"):i("predict.setup.stepPending")})]}),jsx("p",{className:"text-xs text-zinc-500 mt-1",children:x.desc})]})]},x.key))}),l&&jsx("div",{className:"rounded-[10px] bg-red-500/10 border border-red-500/20 px-3 py-2",children:jsx("p",{className:"text-xs text-red-400",children:l})}),jsx("button",{type:"button",onClick:w,disabled:s,className:g?"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus":"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:s?jsxs("span",{className:"inline-flex items-center gap-2",children:[jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",children:[jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",className:"opacity-25"}),jsx("path",{d:"M4 12a8 8 0 018-8",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",className:"opacity-75"})]}),i("predict.setup.stepRunning")]}):N}),!g&&jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] text-sm text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:i("common.cancel")})]})]})})})}function K0({index:e,status:t}){return t==="done"?jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-[#c7ff2e]/15 shrink-0",children:jsx("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#c7ff2e]",children:jsx("polyline",{points:"20 6 9 17 4 12"})})}):t==="running"?jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-[#c7ff2e]/10 shrink-0",children:jsxs("svg",{className:"animate-spin h-4 w-4 text-[#c7ff2e]",viewBox:"0 0 24 24",fill:"none",children:[jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",className:"opacity-25"}),jsx("path",{d:"M4 12a8 8 0 018-8",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",className:"opacity-75"})]})}):jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-zinc-700/50 text-xs font-bold text-zinc-400 shrink-0",children:e})}
136
- export{sh as CHART_RANGE_DURATION,oh as CHART_RANGE_PERIOD,ih as CHART_RANGE_SAMPLE_INTERVAL,cn as CandlestickPeriod,Y0 as CategoriesSkeleton,ei as CategoriesUI,ni as CategoriesWidget,ie as ChartRange,dn as DEFAULT_CHART_RANGE,oo as DEFAULT_FILTER_STATE,Lr as DEFAULT_PAGE_SIZE,dh as DEFAULT_PRICE_HISTORY_INTERVAL,Sy as EventDetailPage,zr as EventDetailSkeleton,Xs as EventDetailUI,Js as EventDetailWidget,zi as EventItem,Is as EventMarketDepthChartUI,Hs as EventMarketDetailWidget,Us as EventPriceChart,yi as EventsFilterUI,Zv as EventsHero,qv as EventsPage,yv as EventsPageSkeleton,so as EventsSkeleton,Ci as EventsToolbarUI,Vi as EventsUI,Gi as EventsWidget,hn as KycModal,Zn as MAX_PRICE_HISTORY_MARKETS,ak as MatchGroupCard,za as MatchMarketCard,Ia as MatchesFilterBar,Da as MatchesHero,ek as MatchesPage,mk as MatchesStatsBar,Va as MatchesWidget,ch as ORDER_MAX_PRICE,lh as ORDER_MIN_PRICE,un as ORDER_MIN_QUANTITY,pn as ORDER_MIN_USDC,ah as ORDER_PRICE_STEP,uu as PREDICT_REDEEM_MODAL_ID,_o as PREDICT_SEARCH_MODAL_ID,go as PREDICT_SELL_MODAL_ID,_r as PREDICT_TRADE_MODAL_ID,uh as PRICE_HISTORY_SAMPLE_INTERVAL,os as PredictRedeemModal,o2 as PredictSearchModal,ys as PredictSellModal,bn as PredictTradeModal,$l as PredictWalletProvider,fr as PriceHistoryInterval,H0 as ProfilePage,rs as RedeemFormWidget,Ni as SORT_PRESETS,Jn as STATIC_CATEGORIES,m2 as SearchEventsButton,la as SearchHistoryUI,ca as SearchHistoryWidget,da as SearchInputUI,ua as SearchResultItemUI,ha as SearchResultListWidget,ka as SearchWidget,xs as SellFormUI,Cn as SellFormWidget,fS as SetupModal,Fm as SimilarEventCard,ra as SimilarEventsSection,Xb as SourceBadge,vk as SpreadIndicator,Cs as TradeFormSkeleton,xi as TradeFormUI,xn as TradeFormWidget,ws as UserActivitySection,io as countActiveFilters,tr as fireCelebration,xe as floorToDecimals,Wr as formatKMB,Rr as formatShares,kt as getSourceMeta,gn as parsePolymarketError,mn as resolveExpiration,fn as roundToTickSize,Ty as useEventDetail,Ti as useEventsInfinite,Bn as usePredictSearchHistory,er as usePredictWallet,pa as useSearchResultListScript,ya as useSearchScript,cs as useSellForm,di as useTradeForm};//# sourceMappingURL=index.mjs.map
135
+ `}),jsxs("div",{style:{position:"relative",overflow:"hidden",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:0,overflow:"hidden"},children:[l&&jsx("img",{src:l,alt:"","aria-hidden":"true",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",objectPosition:"center center",opacity:.3,mixBlendMode:"lighten",maskImage:"linear-gradient(to bottom, black 50%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 50%, transparent 100%)"}}),jsx("div",{style:{position:"absolute",inset:0,opacity:.025,backgroundImage:"radial-gradient(circle at 1px 1px, rgb(255 255 255) 1px, transparent 0)",backgroundSize:"20px 20px"}})]}),jsx("style",{children:".matches-hero-wrap{padding:40px 16px 32px}@media(min-width:640px){.matches-hero-wrap{padding:48px 24px 40px}}@media(min-width:1024px){.matches-hero-wrap{padding:52px 32px 44px}}"}),jsx("div",{className:"match-fade-in matches-hero-wrap",style:{position:"relative",zIndex:2,maxWidth:1152,margin:"0 auto"},children:jsx(Xa,{stats:g})})]}),jsxs("div",{style:{position:"sticky",top:0,zIndex:40,background:"rgba(10,10,11,0.8)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsx("style",{children:".matches-toolbar-inner{padding:12px 16px}@media(min-width:640px){.matches-toolbar-inner{padding:12px 24px}}@media(min-width:1024px){.matches-toolbar-inner{padding:12px 32px}}"}),jsxs("div",{className:"matches-toolbar-inner",style:{maxWidth:1152,margin:"0 auto",display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,minWidth:0},children:[jsx("div",{className:"hidden sm:flex",style:{alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:10,background:"linear-gradient(to bottom right, rgba(199,255,46,0.15), rgba(23,201,100,0.15))",border:"1px solid rgba(199,255,46,0.15)",flexShrink:0},children:jsxs("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"}),jsx("path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"}),jsx("path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"})]})}),jsxs("div",{style:{minWidth:0},children:[jsx("h2",{style:{fontSize:14,fontWeight:600,color:"#fff",margin:0,letterSpacing:"-0.28px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c(N0[d])}),g&&g.activePairs>0&&jsx("p",{className:"hidden sm:block",style:{fontSize:11,color:"#71717a",margin:0},children:c("predict.matches.pairsFound",{count:g.activePairs})})]})]}),jsx(Ya,{sortBy:d,onSortChange:w,sortAsc:m,onSortAscChange:P,minVolume:f,onMinVolumeChange:h,onRefresh:E})]})]}),jsx("style",{children:".matches-content-wrap{padding:24px 16px 80px}@media(min-width:640px){.matches-content-wrap{padding:32px 24px 80px}}@media(min-width:1024px){.matches-content-wrap{padding:24px 32px 80px}}"}),jsxs("div",{className:"match-fade-in-d2 matches-content-wrap",style:{position:"relative",maxWidth:1152,margin:"0 auto"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:16,padding:"8px 12px",borderRadius:8,border:"1px solid rgba(39,39,42,0.4)",background:"rgba(24,24,27,0.25)"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#52525b",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"})}),jsxs("p",{style:{fontSize:11,color:"#52525b",lineHeight:1.5,margin:0},children:[jsx("span",{style:{color:"#71717a",fontWeight:500},children:c("predict.matches.experimentalFeature")})," \u2014 ",c("predict.matches.disclaimer")]})]}),jsx(al,{ref:S,sortBy:d,sortAsc:m,minVolume:f,onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:n,onHover:o,onSelect:i,getMarketHref:s,LinkComponent:a,onStatsChange:x})]}),jsx(C0,{stats:g})]})}function jo(e){return e==null?"-":formatAmountInUsd(e)}var T0={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"}},L0={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 R0(e){return T0[e]??L0}function _0(e){if(!e.matched_markets?.length)return null;let t=null,r=-1;for(let n of e.matched_markets){let o=n.spread??0;o>r&&(r=o,t=n);}return t}function I0(e,t){let r=e.entries.find(a=>a.source===(t?.source_a??e.entries[0]?.source)),n=e.entries.find(a=>a.source===(t?.source_b??e.entries[1]?.source)),o=a=>{if(!a?.outcomes?.[0])return {name:null,price:null};let l=a.outcomes[0];return {name:l.label||null,price:l.best_ask??l.price??null}},i=o(t?.market_a),s=o(t?.market_b);return [{source:t?.source_a??r?.source??"unknown",outcomeName:i.name,yesPrice:i.price,volume:r?.event?.volume??null,event:r?.event},{source:t?.source_b??n?.source??"unknown",outcomeName:s.name,yesPrice:s.price,volume:n?.event?.volume??null,event:n?.event}]}function cS({group:e,onSelectEntry:t,getEventHref:r,LinkComponent:n}){let {t:o}=useTranslation(),i=useMemo(()=>_0(e),[e]),s=e.max_spread!=null?e.max_spread*100:null,[a,l]=useMemo(()=>I0(e,i),[e,i]),c=s!=null&&s>=3;a.yesPrice!=null&&l.yesPrice!=null?a.source==="kalshi"?a.yesPrice>l.yesPrice:l.yesPrice>a.yesPrice:false;let p=a.yesPrice!=null&&l.yesPrice!=null?a.yesPrice<=l.yesPrice?a:l:null,m=p?St(p.source):null,u=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:f=>{let h=f.currentTarget;h.style.borderColor="rgba(63,63,70,0.6)",h.style.boxShadow="0 10px 15px -3px rgba(0,0,0,0.2)";},onMouseLeave:f=>{let h=f.currentTarget;h.style.borderColor="rgba(39,39,42,0.6)",h.style.boxShadow="none";},children:[s!=null&&jsxs("span",{style:{position:"absolute",top:12,right:12,zIndex:10,display:"inline-flex",alignItems:"center",gap:4,borderRadius:10,padding:"4px 10px",fontSize:12,fontWeight:600,border:`1px solid ${c?"rgba(255,185,0,0.3)":s>=2?"rgba(166,132,255,0.3)":"rgba(156,163,175,0.3)"}`,background:c?"rgba(255,185,0,0.15)":s>=2?"rgba(166,132,255,0.15)":"rgba(156,163,175,0.12)",color:c?"#ffb900":s>=2?"#a684ff":"#9ca3af"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),s.toFixed(1),"%"]}),jsxs("div",{style:{padding:16},children:[jsx("h3",{style:{fontSize:14,fontWeight:600,lineHeight:1.375,letterSpacing:"-0.28px",color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",paddingRight:80,margin:"0 0 16px"},children:e.title}),jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[jsx(dl,{data:a,isCheaper:p===a,onSelect:t,getEventHref:r,LinkComponent:n}),jsx(dl,{data:l,isCheaper:p===l,onSelect:t,getEventHref:r,LinkComponent:n})]}),p&&m&&s!=null&&jsxs("div",{style:{marginTop:12,padding:"8px 12px",borderRadius:10,display:"flex",alignItems:"center",gap:8,cursor:"pointer",transition:"all 0.15s",border:`1px solid ${u==="amber"?"rgba(255,185,0,0.15)":"rgba(166,132,255,0.15)"}`,background:u==="amber"?"rgba(255,185,0,0.05)":"rgba(166,132,255,0.05)"},onClick:()=>p.event&&t?.(p.event),children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,flexShrink:0,color:u==="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:u==="amber"?"rgba(255,185,0,0.9)":"rgba(166,132,255,0.9)"},children:o("predict.matches.buyEdge",{platform:p.source.charAt(0).toUpperCase()+p.source.slice(1),spread:s.toFixed(1)})}),jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,marginLeft:"auto",color:u==="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"})]}),jo(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"})}),jo(e.combined_volume_24h)," ",o("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),"%"," ",o("predict.matches.match")]})]})]})}function dl({data:e,isCheaper:t,onSelect:r,getEventHref:n,LinkComponent:o}){let{t:i}=useTranslation(),s=St(e.source),a=R0(e.source),l=e.event?n?.(e.event):void 0,c=jsxs("div",{style:{borderRadius:14,border:`1px solid ${a.border}`,background:a.bg,padding:12,cursor:l||r?"pointer":void 0,transition:"border-color 0.15s"},onMouseEnter:d=>{d.currentTarget.style.borderColor=a.hoverBorder;},onMouseLeave:d=>{d.currentTarget.style.borderColor=a.border;},onClick:()=>e.event&&r?.(e.event),children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[s.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.05em",color:a.text,textTransform:"uppercase"},children:s.label}),jsxs("svg",{viewBox:"0 0 24 24",className:"opacity-0 group-hover:opacity-100 transition-opacity",style:{width:10,height:10,color:"#52525b",marginLeft:"auto"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M7 7h10v10"}),jsx("path",{d:"M7 17 17 7"})]})]}),e.outcomeName&&jsx("div",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginBottom:8},children:e.outcomeName}),jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[jsx("span",{style:{fontSize:20,fontWeight:700,fontVariantNumeric:"tabular-nums",color:t?a.priceActiveColor:a.priceColor},children:e.yesPrice!=null?(e.yesPrice*100).toFixed(1):"-"}),jsx("span",{style:{fontSize:10,color:"#71717a"},children:i("predict.matches.centsYes")})]}),jsxs("div",{style:{fontSize:10,color:"#52525b",marginTop:6},children:[jo(e.volume)," ",i("predict.matches.volume")]})]});return l&&o?jsx(o,{href:l,className:"block",children:c}):c}function F0(e){return formatAmountInUsd(e)}function gS({matches:e,total:t}){let{t:r}=useTranslation(),n=useMemo(()=>{let o=0,i=0,s=new Set;for(let a of e){a.max_spread!=null&&a.max_spread>o&&(o=a.max_spread),a.combined_volume!=null&&(i+=a.combined_volume);for(let l of a.entries)s.add(typeof l.source=="string"?l.source:"");}return {count:t??e.length,maxSpread:o,totalVolume:i,platformCount:s.size}},[e,t]);return jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 rounded-xl border border-border/60 bg-background/50 px-4 py-3 text-sm",children:[jsx(qn,{label:r("predict.matches.stats.matchedMarkets"),value:n.count.toLocaleString()}),jsx(Go,{}),jsx(qn,{label:r("predict.matches.stats.totalVolume"),value:F0(n.totalVolume)}),jsx(Go,{}),jsx(qn,{label:r("predict.matches.stats.highestSpread"),value:`${(n.maxSpread*100).toFixed(1)}\xA2`,valueClassName:"text-green-400"}),jsx(Go,{}),jsx(qn,{label:r("predict.matches.stats.platforms"),value:String(n.platformCount)})]})}function qn({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 Go(){return jsx("span",{className:"hidden text-neutral-700 sm:inline",children:"|"})}function ml(e){return `${(e*100).toFixed(1)}\xA2`}function B0(e){return e>=.05?"text-green-400":e>=.02?"text-yellow-400":"text-neutral-400"}function bS({spread:e,arbProfit:t,className:r}){if(e==null)return null;let n=t!=null&&t>0;return jsxs("div",{className:cn("flex items-center gap-x-2",r),children:[jsx("span",{className:cn("text-sm font-semibold",B0(e)),children:ml(e)}),n&&jsxs("span",{className:"text-xs text-green-500/80",children:["+",ml(t)]})]})}var Jr=10,K0=64,vl=40,Yn=48;function xl({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:n}=useTranslation(),[o,i]=useState(1),{data:s,isLoading:a,fetchNextPage:l,hasNextPage:c,isFetchingNextPage:d}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:50}),{data:p,isLoading:m,fetchNextPage:u,hasNextPage:f,isFetchingNextPage:h}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:50}),g=a||m,v=d||h,S=c||f,w=useMemo(()=>{let N=[];return s?.pages&&N.push(...s.pages.flatMap(W=>W.items)),p?.pages&&N.push(...p.pages.flatMap(W=>W.items)),N.sort((W,D)=>(D.timestamp??0)-(W.timestamp??0)),N},[s,p]),P=Math.max(1,Math.ceil(w.length/Jr)+(S?1:0)),x=(o-1)*Jr,E=w.slice(x,x+Jr),k=useCallback(()=>{i(N=>Math.max(1,N-1));},[]),T=useCallback(async()=>{o*Jr>=w.length&&S&&(c&&await l(),f&&await u()),i(W=>W+1);},[o,w.length,S,c,f,l,u]),B=o>1,R=o*Jr<w.length||S;if(g)return jsx(Q0,{height:r});if(w.length===0&&!S)return jsx(Y0,{message:n("predict.profile.noHistory"),height:r});let A=r-vl-Yn;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:vl},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:n("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.profile.action")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.profile.status")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.profile.price")}),jsx("div",{className:"flex-[1.5] pr-2 text-right",children:n("predict.profile.depositWithdraw")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.profile.pnl")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.profile.fee")}),jsx("div",{className:"w-10 shrink-0"})]}),jsxs("div",{className:"hidden lg:block overflow-y-auto",style:{height:A},children:[E.map((N,W)=>jsx(V0,{trade:N},N.id??`${x+W}`)),v&&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:Yn},children:[jsxs("button",{type:"button",disabled:!B,onClick:k,className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",B?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",n("predict.profile.previous")]}),Array.from({length:Math.min(P,5)},(N,W)=>{let D=W+1;return jsx("button",{type:"button",onClick:()=>i(D),className:cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",D===o?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:D},D)}),jsxs("button",{type:"button",disabled:!R,onClick:T,className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",R?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[n("predict.profile.next")," \u2192"]})]}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-Yn},children:E.map((N,W)=>jsx(j0,{trade:N},N.id??`m-${x+W}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:Yn},children:[jsx("button",{type:"button",disabled:!B,onClick:k,className:cn("text-sm cursor-pointer",B?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:o}),jsx("button",{type:"button",disabled:!R,onClick:T,className:cn("text-sm cursor-pointer",R?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function V0({trade:e}){let{t}=useTranslation(),r=e.type==="REDEEM",n=e.side?.toUpperCase()==="BUY",o=e.price??0,i=e.usd_size??0,s=bl(e.type,t),a=r||n,l=a?"+":"-",c=a?"text-success":"text-foreground",d=e.event?.title??e.market?.question??"\u2014",p=e.event?.image_url,m=e.outcome??"",u=wl(e.timestamp),f=yl(e),h=G0(e),g=q0(e);return jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:K0},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[p&&jsx("img",{src:p,alt:"",className:"w-8 h-8 rounded-full object-cover shrink-0"}),jsxs("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:[jsx("span",{className:"text-foreground truncate font-medium text-sm",children:d}),jsxs("span",{className:"text-[11px] text-neutral",children:[m&&jsx("span",{className:"mr-1",children:m}),jsx("span",{children:u})]})]})]})}),jsx("div",{className:"flex-1 pr-2",children:jsx("span",{className:cn("text-sm font-medium",r?"text-primary":n?"text-success":"text-danger"),children:t(r?"predict.profile.redeem":n?"predict.profile.buy":"predict.profile.sell")})}),jsx("div",{className:"flex-1 pr-2 text-sm text-foreground",children:s}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Sl(o)}),jsx("div",{className:cn("flex-[1.5] pr-2 text-right font-mono",c),children:i>0?jsxs(Fragment,{children:[l,"$",i.toFixed(2)]}):"\u2014"}),jsx("div",{className:cn("flex-1 pr-2 text-right font-mono",h!==null?h>=0?"text-success":"text-danger":"text-neutral"),children:h!==null?`${h>=0?"+":"-"}$${Math.abs(h).toFixed(2)}`:"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-neutral",children:g!==null?`$${g.toFixed(2)}`:"\u2014"}),jsx("div",{className:"w-10 shrink-0 text-right",children:f&&jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"text-neutral hover:text-foreground transition-colors","aria-label":"View transaction",children:jsx(kl,{})})})]})}function j0({trade:e}){let{t}=useTranslation(),r=e.type==="REDEEM",n=e.side?.toUpperCase()==="BUY",o=e.price??0,i=e.usd_size??0,s=bl(e.type,t),a=e.event?.title??e.market?.question??"\u2014",l=wl(e.timestamp),c=yl(e);return jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.event?.image_url&&jsx("img",{src:e.event.image_url,alt:"",className:"w-6 h-6 rounded-full object-cover shrink-0"}),jsx("span",{className:"text-sm font-medium text-foreground line-clamp-2",children:a})]}),jsx("span",{className:"text-[11px] text-neutral whitespace-nowrap",children:l})]}),jsxs("div",{className:"flex items-center gap-4 text-xs flex-wrap",children:[jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.action")}),jsx("span",{className:cn("font-medium",r?"text-primary":n?"text-success":"text-danger"),children:t(r?"predict.profile.redeem":n?"predict.profile.buy":"predict.profile.sell")})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.status")}),jsx("span",{className:"text-foreground",children:s})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.price")}),jsx("span",{className:"font-mono text-foreground",children:Sl(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:i>0?`$${i.toFixed(2)}`:"\u2014"})]}),c&&jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"ml-auto text-neutral hover:text-foreground transition-colors",children:jsx(kl,{})})]})]})}function bl(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 yl(e){if(e.tx_hash)return e.source==="polymarket"?`https://polygonscan.com/tx/${e.tx_hash}`:`https://solscan.io/tx/${e.tx_hash}`}function G0(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 n=parseFloat(r);if(!Number.isNaN(n))return n}}return e.type==="REDEEM"&&e.usd_size!=null?e.usd_size:null}function q0(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 n=parseFloat(r);if(!Number.isNaN(n))return n}}return null}function kl(){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 Y0({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function Q0({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 Sl(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function wl(e){let t=new Date(e*1e3),r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getFullYear(),a=t.getTimezoneOffset(),l=a<=0?"+":"-",c=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${s} (${l}${c})`}var Zr=10,nh=64,Pl=40,Qn=48;function Ml({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:n}=useTranslation(),o=useCancelOrder(),[i,s]=useState(1),{data:a,isLoading:l,fetchNextPage:c,hasNextPage:d,isFetchingNextPage:p}=useInfiniteOrders({source:"kalshi",wallet_address:e??""}),{data:m,isLoading:u,fetchNextPage:f,hasNextPage:h,isFetchingNextPage:g}=useInfiniteOrders({source:"polymarket",wallet_address:t??""}),v=l||u,S=p||g,w=d||h,P=useMemo(()=>{let D=[],le=new Set(["live","open","submitted","pending"]);return a?.pages&&D.push(...a.pages.flatMap(X=>X.items).filter(X=>le.has(X.status))),m?.pages&&D.push(...m.pages.flatMap(X=>X.items).filter(X=>le.has(X.status))),D},[a,m]),x=useCallback(D=>{o.mutate({source:D.source,id:D.id});},[o]),E=Math.max(1,Math.ceil(P.length/Zr)+(w?1:0)),k=(i-1)*Zr,T=P.slice(k,k+Zr),B=useCallback(()=>{s(D=>Math.max(1,D-1));},[]),R=useCallback(async()=>{i*Zr>=P.length&&w&&(d&&await c(),h&&await f()),s(le=>le+1);},[i,P.length,w,d,h,c,f]),A=i>1,N=i*Zr<P.length||w;if(v)return jsx(ah,{height:r});if(P.length===0&&!w)return jsx(sh,{message:n("predict.profile.noOrders"),height:r});let W=r-Pl-Qn;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:Pl},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:n("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.profile.action")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.profile.type")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.profile.fillPrice")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.profile.cost")})]}),jsxs("div",{className:"hidden lg:block overflow-y-auto",style:{height:W},children:[T.map(D=>jsx(oh,{order:D,onCancel:x},D.id)),S&&jsx("div",{className:"flex justify-center items-center py-4",children:jsx(Spinner,{size:"sm"})})]}),jsx(Cl,{className:"hidden lg:flex",currentPage:i,totalPages:E,canGoPrev:A,canGoNext:N,onPrev:B,onNext:R,onPage:s,t:n}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-Qn},children:T.map(D=>jsx(ih,{order:D,onCancel:x},D.id))}),jsx(Cl,{className:"lg:hidden",currentPage:i,totalPages:E,canGoPrev:A,canGoNext:N,onPrev:B,onNext:R,onPage:s,t:n,compact:true})]})}function oh({order:e,onCancel:t}){let{t:r}=useTranslation(),n=e.side==="BUY",o=e.price?parseFloat(e.price):0,i=e.in_amount?parseFloat(e.in_amount):o*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:nh},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsx("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:jsx("span",{className:"text-foreground truncate font-medium",children:e.outcome??e.market_id??"\u2014"})})}),jsx("div",{className:"flex-1 pr-2",children:jsx("span",{className:cn("text-sm font-medium",n?"text-success":"text-danger"),children:r(n?"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:o>0?El(o):"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:i>0?`$${i.toFixed(2)}`:"\u2014"})]})}function ih({order:e,onCancel:t}){let{t:r}=useTranslation(),n=e.side==="BUY",o=e.price?parseFloat(e.price):0;return jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:cn("text-xs font-medium px-1.5 py-0.5 rounded",n?"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:o>0?El(o):"\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 Cl({className:e,currentPage:t,totalPages:r,canGoPrev:n,canGoNext:o,onPrev:i,onNext:s,onPage:a,t:l,compact:c}){return c?jsxs("div",{className:cn("flex items-center justify-center gap-3 shrink-0",e),style:{height:Qn},children:[jsx("button",{type:"button",disabled:!n,onClick:i,className:cn("text-sm cursor-pointer",n?"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:!o,onClick:s,className:cn("text-sm cursor-pointer",o?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]}):jsxs("div",{className:cn("flex items-center justify-center gap-2 shrink-0",e),style:{height:Qn},children:[jsxs("button",{type:"button",disabled:!n,onClick:i,className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",n?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",l("predict.profile.previous")]}),Array.from({length:Math.min(r,5)},(d,p)=>{let m=p+1;return jsx("button",{type:"button",onClick:()=>a(m),className:cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",m===t?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:m},m)}),jsxs("button",{type:"button",disabled:!o,onClick:s,className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",o?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[l("predict.profile.next")," \u2192"]})]})}function sh({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function ah({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 El(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}var Jo=10,uh=64,Tl=40,Xn=48;function Ll({positions:e,isLoading:t,listHeight:r,onClosePosition:n,onEventClick:o}){let{t:i}=useTranslation(),[s,a]=useState(1),l=useCallback(()=>{for(let h of e)n?.(h);},[e,n]);if(t)return jsx(gh,{height:r});if(e.length===0)return jsx(fh,{message:i("predict.profile.noPositions"),height:r});let c=Math.max(1,Math.ceil(e.length/Jo)),d=(s-1)*Jo,p=e.slice(d,d+Jo),m=s>1,u=s<c,f=r-Tl-Xn;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:Tl},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:i("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.totalSize")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.value")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.avgPrice")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.markPrice")}),jsxs("div",{className:"flex-[1.5] pr-2 text-right",children:[jsx("span",{children:i("predict.profile.pnl")}),jsxs("span",{className:"text-[10px] ml-1 opacity-60",children:["(",i("predict.profile.pnlExcludeFees"),")"]})]}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.payoutIfRight")}),jsx("div",{className:"flex-[1.5] pr-2 text-right",children:i("predict.profile.estSettlement")}),jsx("div",{className:"w-20 shrink-0 text-right",children:n&&e.length>0&&jsx("button",{type:"button",onClick:l,className:"text-xs text-primary hover:text-primary/80 cursor-pointer transition-colors",children:i("predict.profile.closeAll")})})]}),jsx("div",{className:"hidden lg:block overflow-y-auto",style:{height:f},children:p.map((h,g)=>jsx(ph,{position:h,onClosePosition:n,onEventClick:o},`${h.source}-${h.market?.slug??d+g}`))}),jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:Xn},children:[jsxs("button",{type:"button",disabled:!m,onClick:()=>a(h=>Math.max(1,h-1)),className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",m?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",i("predict.profile.previous")]}),Array.from({length:Math.min(c,5)},(h,g)=>{let v=g+1;return jsx("button",{type:"button",onClick:()=>a(v),className:cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",v===s?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:v},v)}),jsxs("button",{type:"button",disabled:!u,onClick:()=>a(h=>h+1),className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",u?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[i("predict.profile.next")," \u2192"]})]}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-Xn},children:p.map((h,g)=>jsx(mh,{position:h,onClose:n,onEventClick:o},`${h.source}-${h.market?.slug??`m-${d+g}`}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:Xn},children:[jsx("button",{type:"button",disabled:!m,onClick:()=>a(h=>Math.max(1,h-1)),className:cn("text-sm cursor-pointer",m?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:s}),jsx("button",{type:"button",disabled:!u,onClick:()=>a(h=>h+1),className:cn("text-sm cursor-pointer",u?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function ph({position:e,onClosePosition:t,onEventClick:r}){let{t:n}=useTranslation(),o=e.pnl??0,i=e.pnl_percent??0,s=e.avg_price??0,a=e.current_price??0,l=e.current_value??e.size*a,c=e.size,d=o>0?"text-success":o<0?"text-danger":"text-foreground",p=o>0?"+":"",m=e.event?.title??e.market?.question??"\u2014",u=e.event?.image_url,f=e.side,h=e.market?.outcomes?.[0]?.label??"",g=e.market?.end_at?hh(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:uh},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:[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:m}),jsxs("span",{className:"text-[11px] text-neutral",children:[jsx("span",{className:cn("font-medium",f.toLowerCase()==="yes"?"text-success":"text-danger"),children:f}),h&&jsxs(Fragment,{children:[jsx("span",{className:"mx-1",children:"\xB7"}),jsx("span",{children:h})]})]})]})]})}),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:n("predict.profile.contracts",{count:Or(e.size)})})]})}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",(e.size*s).toFixed(2)]}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Zo(s)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Zo(a)}),jsxs("div",{className:cn("flex-[1.5] pr-2 text-right font-mono",d),children:[jsxs("span",{children:[p,"$",Math.abs(o).toFixed(2)]}),jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",p,i.toFixed(2),"%)"]})]}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",c.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap text-xs",children:g}),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"}),n("predict.profile.close")]})})]})}function mh({position:e,onClose:t,onEventClick:r}){let{t:n}=useTranslation(),o=e.pnl??0,i=e.pnl_percent??0,s=e.current_price??0,a=o>0?"text-success":o<0?"text-danger":"text-foreground",l=o>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("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(Jn,{label:n("predict.profile.totalSize"),value:Or(e.size)}),jsx(Jn,{label:n("predict.profile.markPrice"),value:Zo(s)}),jsx(Jn,{label:n("predict.profile.pnl"),value:`${l}$${Math.abs(o).toFixed(2)} (${l}${i.toFixed(1)}%)`,className:a}),jsx(Jn,{label:n("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:n("predict.profile.close")})})]})}function Jn({label:e,value:t,className:r}){return jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:e}),jsx("span",{className:cn("font-mono text-foreground",r),children:t})]})}function fh({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function gh({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 Zo(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function hh(e){try{let t=new Date(e),r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getFullYear(),a=t.getTimezoneOffset(),l=a<=0?"+":"-",c=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${s} (${l}${c})`}catch{return "\u2014"}}function _l({positions:e,trades:t,isLoading:r}){let{t:n}=useTranslation(),o=useMemo(()=>{let a=0,l=0;for(let u of e)a+=u.realized_pnl??0,l+=u.current_value??u.size*(u.current_price??0);let c=0,d=0,p=0;for(let u of t)c+=u.usd_size??0,u.type==="REDEEM"&&(p++,(u.usd_size??0)>0&&d++);let m=p>0?`${d} / ${p}`:"0 / 0";return {realizedPnl:a,positionsValue:l,volume:c,winRateStr:m}},[e,t]),i=o.realizedPnl>0?"text-success":o.realizedPnl<0?"text-danger":"text-foreground",s=o.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:n("predict.profile.realizedPnl")}),r?jsx(Skeleton,{className:"h-14 w-48 rounded-md"}):jsxs("span",{className:cn("text-5xl font-bold tabular-nums",i),children:[s,"$",Math.abs(o.realizedPnl).toFixed(2)]})]}),jsxs("div",{className:"flex items-end gap-8 sm:gap-10",children:[jsx(ti,{label:n("predict.profile.winRate"),value:o.winRateStr,isLoading:r}),jsx(ti,{label:n("predict.profile.positions"),value:`$${o.positionsValue.toFixed(2)}`,isLoading:r}),jsx(ti,{label:n("predict.profile.volume"),value:`$${o.volume.toFixed(2)}`,isLoading:r})]})]})}function ti({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 ri=600;function Nh({solanaAddress:e,evmAddress:t,onClosePosition:r,onEventClick:n}){let{t:o}=useTranslation(),[i,s]=useState("positions"),a=!!(e||t),{data:l,isLoading:c}=usePositions({source:"kalshi",user:e??""}),{data:d,isLoading:p}=usePositions({source:"polymarket",user:t??""}),m=useMemo(()=>{let k=[];return l?.positions&&k.push(...l.positions),d?.positions&&k.push(...d.positions),k},[l,d]),u=c||p,{data:f,isLoading:h}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:100}),{data:g,isLoading:v}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:100}),S=useMemo(()=>[...f?.pages?.flatMap(T=>T.items)??[],...g?.pages?.flatMap(T=>T.items)??[]],[f,g]),w=u||h||v,P=m.length,E=[{key:"positions",label:P>0?`${o("predict.profile.positionsTab")} (${P})`:o("predict.profile.positionsTab")},{key:"orders",label:o("predict.profile.openOrdersTab")},{key:"history",label:o("predict.profile.historyTab")}];return a?jsxs("div",{className:"flex flex-col max-w-[1280px] mx-auto w-full px-4 max-sm:px-2",children:[jsx(_l,{positions:m,trades:S,isLoading:w}),jsx("div",{className:"flex items-center gap-1 border-b border-border",children:E.map(k=>jsx("button",{type:"button",onClick:()=>s(k.key),className:cn("px-3 py-3 text-base font-normal transition-colors cursor-pointer whitespace-nowrap",i===k.key?"text-foreground border-b-2 border-foreground":"text-neutral hover:text-foreground"),children:k.label},k.key))}),jsxs("div",{className:"py-2",children:[i==="positions"&&jsx(Ll,{positions:m,isLoading:u,listHeight:ri,onClosePosition:r,onEventClick:n}),i==="orders"&&jsx(Ml,{solanaAddress:e,evmAddress:t,listHeight:ri}),i==="history"&&jsx(xl,{solanaAddress:e,evmAddress:t,listHeight:ri})]})]}):jsx("div",{className:"flex items-center justify-center text-sm text-neutral py-24 px-4",children:o("predict.profile.connectWallet")})}function hw({isOpen:e,onClose:t,safeDeployed:r,tokenApproved:n,onDeployAndApprove:o}){let{t:i}=useTranslation(),[s,a]=useState(false),[l,c]=useState(null),[d,p]=useState(false),m=r||d,u=n||d,f=m?"done":s?"running":"pending",h=u?"done":m&&s?"running":"pending",g=m&&u,v=useCallback(async()=>{c(null),p(false),a(true);try{await o(),p(!0);}catch(x){c(x instanceof Error?x.message:String(x));}finally{a(false);}},[o]),S=[{key:"step1",label:i("predict.setup.step1"),desc:i("predict.setup.step1Desc"),status:f},{key:"step2",label:i("predict.setup.step2"),desc:i("predict.setup.step2Desc"),status:h}],w=()=>{g?t():v();},P=i(g?"predict.setup.done":"predict.setup.setupButton");return jsx(StyledModal,{isOpen:e,onOpenChange:x=>{x||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:i("predict.setup.modalTitle")}),jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxs("div",{className:"px-5 pb-5 space-y-4",children:[jsx("p",{className:"text-[13px] text-zinc-400 text-left",children:i("predict.setup.modalDescription")}),jsx("div",{className:"space-y-2.5",children:S.map((x,E)=>jsxs("div",{className:"flex gap-3 rounded-[10px] border border-zinc-700/50 bg-zinc-800/50 px-3 py-3",children:[jsx(Th,{index:E+1,status:x.status}),jsxs("div",{className:"flex-1 min-w-0 pt-0.5",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("p",{className:"text-sm font-medium text-zinc-200",children:x.label}),jsx("span",{className:`text-[11px] leading-none ${x.status==="done"?"text-[#c7ff2e]":x.status==="running"?"text-[#c7ff2e]/70":"text-zinc-500"}`,children:x.status==="done"?i("predict.setup.stepComplete"):x.status==="running"?i("predict.setup.stepRunning"):i("predict.setup.stepPending")})]}),jsx("p",{className:"text-xs text-zinc-500 mt-1",children:x.desc})]})]},x.key))}),l&&jsx("div",{className:"rounded-[10px] bg-red-500/10 border border-red-500/20 px-3 py-2",children:jsx("p",{className:"text-xs text-red-400",children:l})}),jsx("button",{type:"button",onClick:w,disabled:s,className:g?"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus":"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:s?jsxs("span",{className:"inline-flex items-center gap-2",children:[jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",children:[jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",className:"opacity-25"}),jsx("path",{d:"M4 12a8 8 0 018-8",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",className:"opacity-75"})]}),i("predict.setup.stepRunning")]}):P}),!g&&jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] text-sm text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:i("common.cancel")})]})]})})})}function Th({index:e,status:t}){return t==="done"?jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-[#c7ff2e]/15 shrink-0",children:jsx("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#c7ff2e]",children:jsx("polyline",{points:"20 6 9 17 4 12"})})}):t==="running"?jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-[#c7ff2e]/10 shrink-0",children:jsxs("svg",{className:"animate-spin h-4 w-4 text-[#c7ff2e]",viewBox:"0 0 24 24",fill:"none",children:[jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",className:"opacity-25"}),jsx("path",{d:"M4 12a8 8 0 018-8",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",className:"opacity-75"})]})}):jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-zinc-700/50 text-xs font-bold text-zinc-400 shrink-0",children:e})}
136
+ export{Vh as CHART_RANGE_DURATION,$h as CHART_RANGE_PERIOD,Kh as CHART_RANGE_SAMPLE_INTERVAL,fn as CandlestickPeriod,Oh as CategoriesSkeleton,ci as CategoriesUI,pi as CategoriesWidget,se as ChartRange,Ao as CommentItemUI,gn as DEFAULT_CHART_RANGE,po as DEFAULT_FILTER_STATE,Ir as DEFAULT_PAGE_SIZE,Yh as DEFAULT_PRICE_HISTORY_INTERVAL,Rf as EventCommentsWidget,a1 as EventDetailPage,$r as EventDetailSkeleton,aa as EventDetailUI,la as EventDetailWidget,Yi as EventItem,Us as EventMarketDepthChartUI,qs as EventMarketDetailWidget,Js as EventPriceChart,Ti as EventsFilterUI,Bx as EventsHero,Ix as EventsPage,ix as EventsPageSkeleton,fo as EventsSkeleton,Di as EventsToolbarUI,es as EventsUI,rs as EventsWidget,kn as KycModal,so as MAX_PRICE_HISTORY_MARKETS,cS as MatchGroupCard,rl as MatchMarketCard,Ya as MatchesFilterBar,Xa as MatchesHero,rS as MatchesPage,gS as MatchesStatsBar,al as MatchesWidget,qh as ORDER_MAX_PRICE,Gh as ORDER_MIN_PRICE,hn as ORDER_MIN_QUANTITY,vn as ORDER_MIN_USDC,jh as ORDER_PRICE_STEP,Mu as PREDICT_REDEEM_MODAL_ID,Wo as PREDICT_SEARCH_MODAL_ID,So as PREDICT_SELL_MODAL_ID,Dr as PREDICT_TRADE_MODAL_ID,Qh as PRICE_HISTORY_SAMPLE_INTERVAL,ms as PredictRedeemModal,sk as PredictSearchModal,Ts as PredictSellModal,Nn as PredictTradeModal,ic as PredictWalletProvider,vr as PriceHistoryInterval,Nh as ProfilePage,us as RedeemFormWidget,Oi as SORT_PRESETS,io as STATIC_CATEGORIES,gk as SearchEventsButton,Na as SearchHistoryUI,Pa as SearchHistoryWidget,Ca as SearchInputUI,Ma as SearchResultItemUI,_a as SearchResultListWidget,Fa as SearchWidget,Ms as SellFormUI,Rn as SellFormWidget,hw as SetupModal,Jm as SimilarEventCard,pa as SimilarEventsSection,Ay as SourceBadge,bS as SpreadIndicator,Ds as TradeFormSkeleton,Mi as TradeFormUI,wn as TradeFormWidget,_s as UserActivitySection,mo as countActiveFilters,or as fireCelebration,be as floorToDecimals,Kr as formatKMB,Or as formatShares,St as getSourceMeta,yn as parsePolymarketError,xn as resolveExpiration,bn as roundToTickSize,f1 as useEventDetail,Bi as useEventsInfinite,Vn as usePredictSearchHistory,nr as usePredictWallet,Ea as useSearchResultListScript,Aa as useSearchScript,xs as useSellForm,bi as useTradeForm};//# sourceMappingURL=index.mjs.map
137
137
  //# sourceMappingURL=index.mjs.map