@liberfi.io/ui-predict 4.0.38 → 4.0.39

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,Skeleton,toast,StyledModal,ModalContent,useDisclosure,Tabs,Tab,StyledInput,StyledSwitch,Select,SelectItem,StyledNumberInput,ChevronDownIcon,Button,Spinner,useScreen,TimerIcon,DropletIcon,ChartLineIcon,CalendarIcon,Linkable,Avatar,ChevronUpIcon,OrderbookTableIcon,OrderbookDepthIcon,RefreshIcon,Dropdown,DropdownTrigger,DropdownMenu,DropdownItem,ChevronRightIcon,ChevronLeftIcon,EmptyIcon,TrashIcon,Chip,XCloseIcon,Kbd,SearchIcon,ModalHeader,ModalBody}from'@liberfi.io/ui';import {AsyncModal,useAsyncModal}from'@liberfi.io/ui-scaffold';import {useTranslation}from'@liberfi.io/i18n';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useWallets,useAuth,useAuthCallback}from'@liberfi.io/wallet-connector';import {keepPreviousData,useQueryClient,useQueries}from'@tanstack/react-query';import {useInfiniteMatchMarkets,useBalance,useDFlowKYC,usePolymarketSetup,usePredictClient,PolymarketContext,useTickSize,useFeeRate,useRebateConfig,useRealtimeOrderbook,pickBestAsk,walkOrderbook,usePositions,useDFlowQuote,useDFlowSubmit,useOrder,buildSignedV2OrderPayload,buildCtfExchangeDomain,buildOrderMessage,CTF_ORDER_TYPES,buildSignedOrder,buildClobPayload,buildPolymarketL2Headers,resolveEventsParams,useInfiniteEvents,useRedeemPosition,pickBestBid,useAvailableShares,getPolymarketSharesPrecision,useInfiniteOrders,useCancelOrder,useInfiniteTrades,useMarketHistory,useOrderbook,useEvent,useSimilarEvents,candlesticksQueryKey,useInfiniteComments,useSearchEvents}from'@liberfi.io/react-predict';export{PredictClient,PredictContext,PredictProvider,PredictWsClient,createPredictClient,createPredictWsClient,eventStatsQueryKey,fetchMatchMarketsPage,fetchMatchesPage,matchMarketsQueryKey,matchQueryKey,matchesQueryKey,useBalance,useCancelOrder,useCandlesticks,useDFlowKYC,useDFlowQuote,useDFlowSubmit,useEvent,useEventStats,useEvents,useInfiniteEvents,useInfiniteMatchMarkets,useInfiniteMatches,useInfiniteOrders,useInfiniteTrades,useMarket,useMarketHistory,useMarketTrades,useMatch,useOrder,useOrderbook,useOrders,usePositions,usePredictClient,usePriceHistory,useRedeemPosition,useSearchEvents,useSimilarEvents,useTrades}from'@liberfi.io/react-predict';import {ChainNamespace,Chain}from'@liberfi.io/types';import {SOLANA_TOKENS,formatAmountInUsd,formatAmount,debounce}from'@liberfi.io/utils';import xo 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 Gl={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},mi=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],go=(()=>{let e=t=>{let r=mi.indexOf(t);return r===-1?mi.length:r};return Object.entries(Gl).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 hi({categories:e,selectedCategory:t,selectedTag:r,activeTags:n,onCategorySelect:o,onTagSelect:i,trailing:s,pulsingTab:a="Trending",className:l}){let{t:c}=useTranslation(),u=useCallback(()=>{o(null);},[o]),m=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(fi,{label:m,isSelected:t===null,onPress:u,showPulse:m===a}),jsx(Xl,{}),e.map(p=>jsx(fi,{label:p.category,isSelected:t===p.category,onPress:()=>o(p.category),badge:p.badge,showPulse:p.category===a},p.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(gi,{label:c("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>i(null)}),n.map(p=>jsx(gi,{label:p.label,icon:p.icon,isSelected:r===p.label,onPress:()=>i(p.label)},p.label))]})})]})}function fi({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 Xl(){return jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function gi({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 Kh({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 Jl(e){return e.map(t=>({category:t.label,tags:t.tags.map(r=>r.label)}))}function Zl(e){return e?e.tags.map(t=>({label:t.label,icon:t.icon})):[]}function bi({onSelect:e,trailing:t,className:r}){let[n,o]=useState(null),[i,s]=useState(null),a=useCallback(p=>{o(p),s(null),e?.({categorySlug:p,tagSlug:null});},[e]),l=useCallback(p=>{s(p),e?.({categorySlug:n,tagSlug:p});},[n,e]),c=Jl(go),u=go.find(p=>p.slug===n),m=Zl(u);return jsx(hi,{categories:c,selectedCategory:n,selectedTag:i,activeTags:m,onCategorySelect:a,onTagSelect:l,trailing:t,className:r})}function vn(e){return {title:e.title,imageUrl:e.image_url}}function xn(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 Hr=24,ho=4,bn={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},ie={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},yn=ie.ALL,Zh={[ie.ONE_DAY]:bn.ONE_MINUTE,[ie.ONE_WEEK]:bn.ONE_HOUR,[ie.ONE_MONTH]:bn.ONE_HOUR,[ie.ALL]:bn.ONE_DAY},ev={[ie.ONE_DAY]:300,[ie.ONE_WEEK]:3600,[ie.ONE_MONTH]:10800,[ie.ALL]:1440*60},tv={[ie.ONE_DAY]:1440*60,[ie.ONE_WEEK]:10080*60,[ie.ONE_MONTH]:720*60*60,[ie.ALL]:null},kn=1,Sn=1,rv=1,nv=1,ov=99,wr={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},iv=wr.ONE_WEEK,sv={[wr.ONE_HOUR]:60,[wr.SIX_HOURS]:60,[wr.ONE_DAY]:300,[wr.ONE_WEEK]:1800,[wr.MAX]:1800};var Si=createContext(null);function sr(){let e=useContext(Si);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var sc=1e4;function ac({pollingInterval:e=sc,enabled:t=true,children:r}){let n=useWallets(),o=useMemo(()=>n.find(T=>T.chainNamespace===ChainNamespace.SOLANA&&T.isConnected)?.address,[n]),i=useMemo(()=>n.find(T=>T.chainNamespace===ChainNamespace.EVM&&T.isConnected)?.address,[n]),{data:s,isLoading:a,isFetching:l,error:c}=useBalance({source:"kalshi",user:o??""},{enabled:t&&!!o,refetchInterval:e}),{data:u,isLoading:m}=useDFlowKYC(o,{enabled:t&&!!o,refetchInterval:3e4}),{data:p,isLoading:d}=usePolymarketSetup(i,{enabled:t&&!!i,refetchInterval:3e4}),f=p?.safe_address,v=p?.verified??false,g=p?.wallet_kind??"deposit",x=p?.deposit_wallet_address,b=g==="safe"?p?.safe_address:x,P=g==="safe"?p?.safe_deployed??false:p?.deposit_wallet_deployed??false,{data:S,isLoading:h,isFetching:N,error:w}=useBalance({source:"polymarket",user:i??""},{enabled:t&&v&&!!i,refetchInterval:e}),E=useMemo(()=>({solanaAddress:o,evmAddress:i,polymarketWalletKind:g,polymarketWalletAddress:b,polymarketDepositWalletAddress:x,polymarketWalletDeployed:P,polymarketSafeAddress:f,kalshiUsdcBalance:s?Number(s.balance):null,polymarketUsdcBalance:v&&S?Number(S.balance):null,kalshiKycVerified:u?.verified??false,kalshiKycUrl:u?.kyc_url??null,kalshiKycLoading:m,polymarketSetupVerified:v,polymarketSafeDeployed:p?.safe_deployed??false,polymarketTokenApproved:p?.token_approved??false,polymarketSetupLoading:d,isLoading:a||h,isFetching:l||N,error:c??w??null}),[o,i,g,b,x,P,f,s,S,v,u,m,p,d,a,h,l,N,c,w]);return jsx(Si.Provider,{value:E,children:r})}var cc={minutes:60,hours:3600,days:86400};function wn(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*cc[r]}}function Pn(e,t){let r=parseFloat(t);return !r||r<=0?e:Math.round(e/r)*r}function ye(e,t){let r=Math.pow(10,t);return Math.floor(e*r)/r}function Nn(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:ye(s,2).toFixed(2),active:ye(a,2).toFixed(2),available:ye(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 zr(e,t=2){return parseFloat(ye(e,t).toFixed(t)).toString()}function ar(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};xo({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{xo({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{xo({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function Ci({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(),u=e.source,m=u==="polymarket",p=s.find(R=>R.chainNamespace===ChainNamespace.SOLANA&&R.isConnected),d=s.find(R=>R.chainNamespace===ChainNamespace.EVM&&R.isConnected&&"switchChain"in R),f=i==="authenticated",v=p?.address,g=d?.address,[x,b]=useState(t),[P,S]=useState("market"),[h,N]=useState(NaN),[w,E]=useState(NaN),[T,_]=useState(false),[G,D]=useState(null),[K,W]=useState(false),[oe,le]=useState(false),[J,y]=useState("1h"),[k,H]=useState(30),[V,Q]=useState("minutes"),se=useMemo(()=>{if(u!=="polymarket")return;let R=e.provider_meta?.["polymarket.clobTokenIds"];return R?(typeof R=="string"?JSON.parse(R):R)[x==="yes"?0:1]:void 0},[u,e.provider_meta,x]),{data:ve,isLoading:je}=useTickSize(se),Ce=ve?.minimum_tick_size?String(ve.minimum_tick_size):"0.01",{data:Be,isLoading:pt}=useFeeRate(se),mt=String(Be?.base_fee??0),{data:wt}=useRebateConfig(),Ge=wt?.builder_enabled&&wt.builder_code?wt.builder_code:void 0,He=null,vt=false,A=null,xe,qe,et;try{let R=sr();He={kalshiUsdcBalance:R.kalshiUsdcBalance,polymarketUsdcBalance:R.polymarketUsdcBalance,isLoading:R.isLoading},vt=R.kalshiKycVerified,A=R.kalshiKycUrl,xe=R.polymarketSafeAddress,qe=R.polymarketWalletKind,et=R.polymarketWalletAddress;}catch{}let{data:$e}=useRealtimeOrderbook({slug:e.slug,source:u,outcome:x},{enabled:e.status==="open"}),ke=useMemo(()=>{let R=pickBestAsk($e,x);if(R!=null&&R>0)return R;let Oe=x==="yes"?0:1,Ye=e.outcomes[Oe];return Ye?.best_ask??Ye?.price??.5},[$e,e.outcomes,x]),O=useCallback(R=>{S(R);},[]),Me=useCallback(R=>{b(R),E(NaN);},[]);useEffect(()=>{P==="limit"&&isNaN(w)&&E(Math.round(ke*100)/100);},[P,w,ke]);let Pe=useMemo(()=>isNaN(h)||h<=0?0:ke>0?h/ke:0,[h,ke]),Ke=useMemo(()=>walkOrderbook({orderbook:$e,outcome:x,side:"buy",sharesNeeded:Pe,slippageBps:r}),[$e,x,Pe,r]),xr=useMemo(()=>Ke.status==="ok"&&Ke.worstPrice!=null&&Ke.worstPrice>0?Ke.worstPrice:ke,[Ke,ke]),br=useMemo(()=>isNaN(h)||h<=0?"0":String(Math.round(h*1e6)),[h]),oo=e.provider_meta?.["dflow.yesMint"]??"",Jt=e.provider_meta?.["dflow.noMint"]??"",io=SOLANA_TOKENS.stablecoins.USDC.address,Ir=x==="yes"?oo:Jt,_t=io,ft=Ir,Ve=u==="kalshi"?v??"":g??"",{data:Or,isLoading:so}=usePositions({source:u,user:Ve},{enabled:!!Ve}),ao=u==="kalshi"&&!!_t&&!!ft&&!!v&&br!=="0",{refetch:It}=useDFlowQuote({inputMint:_t,outputMint:ft,amount:br,userPublicKey:v??"",slippageBps:100},{enabled:ao}),Ot=useMemo(()=>He?u==="kalshi"?He.kalshiUsdcBalance:He.polymarketUsdcBalance:Or&&Or.positions.reduce((Oe,Ye)=>Ye.side==="USDC"||Ye.side==="collateral"?Oe+(Ye.current_value??0):Oe,0)||null,[He,Or,u]),lo=He?He.isLoading:so,ln=useMemo(()=>P==="limit"&&m&&!isNaN(w)?w:ke,[P,m,w,ke]),Dr=useMemo(()=>isNaN(h)||h<=0?0:h,[h]),cn=useMemo(()=>isNaN(h)||h<=0?0:ln>0?h/ln*1:0,[h,ln]),Zt=cn-Dr,er=useCallback(R=>{if(isNaN(R)){N(NaN);return}N(Math.round(Math.max(0,R)*100)/100);},[]),tr=useCallback(R=>{if(isNaN(R)){E(NaN);return}let Oe=Math.max(.01,Math.min(.99,R));E(Math.round(Oe*100)/100);},[]),Dt=useCallback(()=>{N(NaN),E(NaN),S("market"),le(false),y("1h"),H(30),Q("minutes");},[]),Ar=useMemo(()=>{let R=[];return isNaN(h)||h<=0?R.push(o("predict.trade.minAmountUsd",{amount:Sn})):h<Sn&&R.push(o("predict.trade.minAmountUsd",{amount:Sn})),e.status!=="open"&&R.push(o("predict.trade.marketNotActive")),Ot!=null&&!isNaN(h)&&h>0&&h>ye(Ot,2)&&R.push(o("predict.trade.insufficientBalance")),P==="limit"&&m&&(isNaN(w)||w<.01||w>.99)&&R.push(o("predict.trade.limitPriceRange")),P==="limit"&&m&&oe&&J==="custom"&&(isNaN(k)||k<=0)&&R.push(o("predict.trade.expiration.invalidDate")),u==="polymarket"&&P==="market"&&!isNaN(h)&&h>0&&Pe>0&&(Ke.status==="insufficient_liquidity"?R.push(o("predict.trade.insufficientLiquidity",{available:ye(Ke.totalAvailable,2)})):Ke.status==="exceeds_slippage"&&R.push(o("predict.trade.priceImpactTooHigh",{impact:(Ke.priceImpactBps/100).toFixed(2),slippage:(r/100).toFixed(2)}))),{isValid:R.length===0,errors:R}},[h,e.status,Ot,P,m,w,oe,J,k,u,Pe,Ke,r,o]),dn=useMemo(()=>Ot==null||isNaN(h)||h<=0?false:h>ye(Ot,2),[Ot,h]),Fr=useCallback(()=>{n?.(u);},[n,u]),{mutateAsync:tt}=useDFlowSubmit(),{data:yr}=useOrder({id:G??"",source:u},{enabled:!!G});useEffect(()=>{if(!yr||!G)return;let{status:R}=yr;R==="closed"?(D(null),_(false),toast.success(o("predict.trade.submitSuccess")),ar(),Dt(),c.invalidateQueries({queryKey:["predict","positions"]})):(R==="failed"||R==="expired")&&(_(false),D(null),toast.error(o("predict.trade.submitError")));},[yr,G,c,Dt,o]);let un=useCallback(async()=>{if(!v||!p)return;if(!_t||!ft){toast.error("Missing token mint addresses"),_(false);return}if(!vt){W(true),_(false);return}let rt=(await It()).data?.transaction;if(!rt){toast.error(o("predict.trade.submitError")),_(false);return}let rr=Uint8Array.from(atob(rt),bt=>bt.charCodeAt(0)),Pt=await p.signTransaction(rr),xt=await tt({signedTransaction:btoa(String.fromCharCode(...Pt)),orderContext:{user_public_key:v,input_mint:_t,output_mint:ft,amount:br,price:String(ke),side:"BUY",outcome:x==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});D(xt.signature);},[v,p,It,tt,_t,ft,br,ke,x,e.slug,o,vt]),pn=useCallback(async()=>{if(!d||!l)return;let R=d.chain,Oe=R!==Chain.POLYGON;Oe&&await d.switchChain(Chain.POLYGON);try{let Ye=await d.getEip1193Provider();if(!Ye){toast.error(o("predict.trade.submitError")),_(!1);return}let rt=qe==="deposit"&&!!et,rr=!rt&&!!xe,Pt=rt?et:xe,xt={address:d.address,signatureType:rt?3:rr?2:0,signTypedData:async(Re,At,jt,kr)=>{let Gt=[];"name"in Re&&Gt.push({name:"name",type:"string"}),"version"in Re&&Gt.push({name:"version",type:"string"}),"chainId"in Re&&Gt.push({name:"chainId",type:"uint256"}),"verifyingContract"in Re&&Gt.push({name:"verifyingContract",type:"address"}),"salt"in Re&&Gt.push({name:"salt",type:"bytes32"});let uo={EIP712Domain:Gt,...At};return await Ye.request({method:"eth_signTypedData_v4",params:[d.address,JSON.stringify({domain:Re,types:uo,primaryType:jt,message:kr})]})}},bt=l.credentials??await l.authenticate(xt),nr=x==="yes"?0:1,Br="",or=e.provider_meta?.["polymarket.clobTokenIds"];or&&(Br=(typeof or=="string"?JSON.parse(or):or)[nr]??"");let mn=e.provider_meta?.["polymarket.negRisk"]??!1,C=P==="limit"&&!isNaN(w)?w:xr,be=Pn(C,Ce),ze=P==="limit"?oe?"GTD":"GTC":"FOK",Qe=P==="market"?h:be>0?h/be:0,We={tokenId:Br,price:be,size:Qe,side:"BUY",orderType:ze,tickSize:Ce,negRisk:mn,...Pt&&{funderAddress:Pt},...Ge&&{builderCode:Ge},...P==="limit"&&oe&&{expiration:wn(J,k,V)}},Xe;if(rt)Xe=await buildSignedV2OrderPayload({signer:xt,depositWalletAddress:Pt,input:We,owner:bt.apiKey});else {let Re=buildCtfExchangeDomain(mn),At=buildOrderMessage({...We,signerAddress:xt.address,signatureType:xt.signatureType,feeRateBps:mt}),jt=await xt.signTypedData(Re,CTF_ORDER_TYPES,"Order",At),kr=buildSignedOrder(At,jt,We.orderType);Xe=buildClobPayload(kr,bt.apiKey);}let gt=JSON.stringify(Xe),De=await buildPolymarketL2Headers(bt.address,{apiKey:bt.apiKey,secret:bt.secret,passphrase:bt.passphrase,method:"POST",requestPath:"/order",body:gt});await a.createPolymarketOrder(Xe,De),c.invalidateQueries({queryKey:["predict","orders"]}),c.invalidateQueries({queryKey:["predict","positions"]}),toast.success(o("predict.trade.submitSuccess")),ar(),Dt(),_(!1);}finally{Oe&&R&&d.switchChain(R).catch(()=>{});}},[d,l,x,e.provider_meta,P,w,xr,h,a,c,oe,J,k,V,Dt,o,Ce,mt,xe,qe,et,Ge]),co=useCallback(async()=>{if(!(!Ar.isValid||!f)){_(true),D(null),W(false);try{u==="kalshi"?await un():await pn();}catch(R){let Oe=R instanceof Error?R.message:"",Ye=u==="polymarket"&&Oe?Nn(Oe,o,"buy"):Oe||void 0;toast.error(Ye||o("predict.trade.submitError")),_(false);}}},[Ar.isValid,f,u,un,pn,o]);return {outcome:x,orderType:P,quantity:h,limitPrice:w,shares:Pe,estimatedCost:Dr,potentialPayout:cn,potentialProfit:Zt,pricePerShare:ke,usdcBalance:Ot,isBalanceLoading:lo,isMarketDataLoading:u==="polymarket"&&(pt||je),isSubmitting:T,validation:Ar,isInsufficientBalance:dn,source:u,supportsLimitOrder:m,kycRequired:K,kycUrl:A,expirationEnabled:oe,expirationPreset:J,customDuration:k,customDurationUnit:V,setOutcome:Me,setOrderType:O,setQuantity:er,setLimitPrice:tr,setExpirationEnabled:le,setExpirationPreset:y,setCustomDuration:H,setCustomDurationUnit:Q,submit:co,notifyInsufficientBalance:Fr}}function Cn({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 qc=`https://s1.chainstream.io/chains/sol/tokens/${SOLANA_TOKENS.stablecoins.USDC.address}/image.png`,Yc=["5m","1h","12h","24h","eod","custom"],Qc={"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"},Xc=["minutes","hours","days"],Jc={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},Zc={maximumFractionDigits:0};function Oi({event:e,market:t,variant:r="bordered",outcome:n,orderType:o,quantity:i,limitPrice:s,shares:a,potentialProfit:l,potentialPayout:c,estimatedCost:u,usdcBalance:m,isBalanceLoading:p,isMarketDataLoading:d,isSubmitting:f,isValid:v,validationErrors:g,isInsufficientBalance:x,onInsufficientBalance:b,supportsLimitOrder:P,kycRequired:S,kycUrl:h,expirationEnabled:N,expirationPreset:w,customDuration:E,customDurationUnit:T,onOutcomeChange:_,onOrderTypeChange:G,onQuantityChange:D,onLimitPriceChange:K,onExpirationEnabledChange:W,onExpirationPresetChange:oe,onCustomDurationChange:le,onCustomDurationUnitChange:J,onSubmit:y}){let{t:k}=useTranslation(),[H,V]=useState(false),Q=useDisclosure(),[se,ve]=useState(""),je=useRef(false);useEffect(()=>{je.current||ve(isNaN(i)?"":String(i));},[i]);let[Ce,Be]=useState(""),pt=useRef(false);useEffect(()=>{pt.current||(isNaN(s)?Be(""):Be(String(parseFloat((s*100).toFixed(2)))));},[s]);let mt=useCallback(O=>{if(O!==""&&!/^\d*\.?\d{0,2}$/.test(O))return;if(Be(O),O===""||O==="."){K(NaN);return}let Pe=parseFloat(O);isNaN(Pe)||K(Pe/100);},[K]),wt=useCallback(O=>{if(O!==""&&!/^\d*\.?\d{0,2}$/.test(O))return;if(ve(O),$e(false),O===""||O==="."){D(NaN);return}let Pe=parseFloat(O);isNaN(Pe)||D(Pe);},[D]);useEffect(()=>{S&&!Q.isOpen&&Q.onOpen();},[S]);let Ge=useMemo(()=>{let O=n==="yes"?t.yesAsk:t.noAsk;return O!=null?parseFloat((Number(O)*100).toFixed(2)):null},[n,t]),He=!isNaN(i)&&i>0,vt=useMemo(()=>{if(p)return k("predict.trade.loadingBalance");if(d)return k("predict.trade.loadingMarketData");if(f)return k("predict.trade.submitting");if(S)return k("predict.trade.kycRequired");if(!He)return k("predict.trade.enterAmount");let O=k(n==="yes"?"predict.trade.yes":"predict.trade.no"),Me=l>0?` \u2192 Win $${l.toFixed(2)}`:"";return `${k("predict.trade.buy")} ${O}${Me}`},[p,d,f,S,He,n,l,k]),A=useMemo(()=>n==="yes"?"primary":"secondary",[n]),xe=()=>{D(Math.floor((m??0)/2*100)/100);},qe=()=>{D(ye(m??0,2));},[et,$e]=useState(false),ke=()=>{if(S){Q.onOpen();return}if(x&&b){$e(false),b();return}if(!v){$e(true);return}$e(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:O=>{r==="bordered"&&(O.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:O=>{r==="bordered"&&(O.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:[k("predict.trade.buy")," ",k(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:[P?jsxs(Tabs,{variant:"underlined",selectedKey:o,onSelectionChange:O=>G(O),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsx(Tab,{title:k("predict.trade.market")},"market"),jsx(Tab,{title:k("predict.trade.limit")},"limit")]}):jsx("span",{className:"text-sm font-medium text-foreground",children:k("predict.trade.market")}),o==="limit"&&P?jsx(StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:Ce,onChange:O=>mt(O.target.value),onFocus:()=>{pt.current=true;},onBlur:()=>{pt.current=false,isNaN(s)?Be(""):Be(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"}}):Ge!=null&&jsxs("span",{className:"text-xl font-bold tabular-nums",children:[Ge," \xA2"]})]}),jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(O=>{let Me=O==="yes"?t.yesAsk:t.noAsk;return jsx("div",{className:"flex flex-1 flex-col gap-y-1",children:jsxs("button",{type:"button",onClick:()=>_(O),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${n===O?O==="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:k(O==="yes"?"predict.trade.yes":"predict.trade.no")}),Me!=null&&jsxs("span",{className:"ml-1 opacity-70",children:[parseFloat((Number(Me)*100).toFixed(2)),"\xA2"]})]})},O)})}),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:k("predict.trade.youArePaying")}),jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("img",{src:qc,alt:"USDC",className:"h-3.5 w-3.5 rounded-full object-cover"}),jsx("span",{className:"font-medium text-foreground tabular-nums",children:m!=null?`${ye(m,2).toFixed(2)} USDC`:"\u2013"}),jsx("button",{type:"button",onClick:xe,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:k("predict.trade.half")}),jsx("button",{type:"button",onClick:qe,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:k("predict.trade.max")})]})]}),jsx(StyledInput,{"aria-label":"Trade amount",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:se,onChange:O=>wt(O.target.value),onFocus:()=>{je.current=true;},onBlur:()=>{je.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"}}),et&&g.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:g.map(O=>jsx("span",{className:"text-xs text-danger",children:O},O))})]}),o==="limit"&&P&&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:k("predict.trade.setExpiration")}),jsx(StyledSwitch,{size:"sm",color:"primary",isSelected:N,onValueChange:W,"aria-label":k("predict.trade.setExpiration")})]}),N&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":k("predict.trade.setExpiration"),selectedKeys:[w],onSelectionChange:O=>{let Me=Array.from(O)[0];Me&&oe(Me);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Yc.map(O=>jsx(SelectItem,{children:k(Qc[O])},O))}),w==="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:Zc,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:[T],onSelectionChange:O=>{let Me=Array.from(O)[0];Me&&J(Me);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Xc.map(O=>jsx(SelectItem,{children:k(Jc[O])},O))})]})]})]}),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:()=>V(O=>!O),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{children:k("predict.trade.odds")}),jsx(ChevronDownIcon,{className:cn("h-3.5 w-3.5 transition-transform",H&&"rotate-180")})]}),Ge!=null&&jsx("span",{className:"text-foreground font-medium tabular-nums",children:k("predict.trade.chance",{percent:Ge})})]}),H&&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:k("predict.trade.totalSize")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${u.toFixed(2)}`:"\u2013"})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:k("predict.trade.numContracts")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(a)&&a>0?zr(a):"\u2013"})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:k("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:k("predict.trade.estProfit")}),jsx("span",{className:"tabular-nums text-bullish",children:!isNaN(i)&&i>0&&l>0?`+$${l.toFixed(2)}`:"\u2013"})]})]})]}),jsx(Button,{color:A,fullWidth:true,radius:"lg",size:"lg",isDisabled:p||d||!He||f,isLoading:f||p||d,spinner:jsx(Spinner,{size:"sm",color:"current"}),onPress:ke,children:vt})]}),jsx(Cn,{isOpen:Q.isOpen,onClose:Q.onClose,kycUrl:h})]})}function En({event:e,market:t,variant:r,initialOutcome:n,chain:o,slippageBps:i,onInsufficientBalance:s,onOutcomeChange:a}){let{outcome:l,orderType:c,quantity:u,limitPrice:m,shares:p,estimatedCost:d,potentialPayout:f,potentialProfit:v,pricePerShare:g,usdcBalance:x,isBalanceLoading:b,isMarketDataLoading:P,isSubmitting:S,validation:h,isInsufficientBalance:N,supportsLimitOrder:w,kycRequired:E,kycUrl:T,expirationEnabled:_,expirationPreset:G,customDuration:D,customDurationUnit:K,setOutcome:W,setOrderType:oe,setQuantity:le,setLimitPrice:J,setExpirationEnabled:y,setExpirationPreset:k,setCustomDuration:H,setCustomDurationUnit:V,submit:Q,notifyInsufficientBalance:se}=Ci({market:t,initialOutcome:n,slippageBps:i,onInsufficientBalance:s}),ve=useAuthCallback(Q),je=useCallback(pt=>{W(pt),a?.(pt);},[W,a]),Ce=useMemo(()=>e?vn(e):void 0,[e]),Be=useMemo(()=>xn(t,{yesAsk:l==="yes"?g:void 0,noAsk:l==="no"?g:void 0}),[t,l,g]);return jsx(Oi,{event:Ce,market:Be,variant:r,outcome:l,orderType:c,quantity:u,limitPrice:m,shares:p,estimatedCost:d,potentialPayout:f,potentialProfit:v,usdcBalance:x,isBalanceLoading:b,isMarketDataLoading:P,isSubmitting:S,isValid:h.isValid,validationErrors:h.errors,isInsufficientBalance:N,onInsufficientBalance:s?se:void 0,supportsLimitOrder:w,kycRequired:E,kycUrl:T,expirationEnabled:_,expirationPreset:G,customDuration:D,customDurationUnit:K,onOutcomeChange:je,onOrderTypeChange:oe,onQuantityChange:le,onLimitPriceChange:J,onExpirationEnabledChange:y,onExpirationPresetChange:k,onCustomDurationChange:H,onCustomDurationUnitChange:V,onSubmit:ve})}var Wr="predict-trade";function Tn({id:e=Wr}){return jsx(AsyncModal,{id:e,children:t=>jsx(ld,{...t})})}function ld({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(En,{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 Ur={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function ko(e,t=true){let r=0;return t&&e.source&&r++,e.timeRemaining&&r++,e.minVolume&&r++,e.minLiquidity&&r++,r}function Ai({isOpen:e,onClose:t,value:r,onChange:n,enableKalshi:o=true}){let{t:i}=useTranslation(),[s,a]=useState(r),l=useMemo(()=>o?Ur:{...Ur,source:"polymarket"},[o]),c=useCallback(b=>{b?a(r):t();},[r,t]),u=useCallback(()=>{a(l);},[l]),m=useCallback(()=>{n(s),t();},[s,n,t]),p=useCallback((b,P)=>{a(S=>({...S,[b]:P}));},[]),d=useMemo(()=>ko(s,o),[s,o]),f=useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"polymarket",label:i("predict.platform.polymarket")},{value:"kalshi",label:i("predict.platform.kalshi")}],[i]),v=useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1d",label:i("predict.filter.lessThanDay")},{value:"7d",label:i("predict.filter.lessThanWeek")},{value:"30d",label:i("predict.filter.lessThanMonth")}],[i]),g=useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[i]),x=useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[i]);return jsx(StyledModal,{isOpen:e,onOpenChange:c,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:i("predict.filter.title")}),jsx(fd,{onClick:()=>c(false)})]}),jsxs("div",{style:{padding:"0 20px 16px",display:"flex",flexDirection:"column",gap:20},children:[o&&jsx(Rn,{label:i("predict.filter.platform"),children:jsx(_n,{options:f,selected:s.source,onSelect:b=>p("source",b)})}),jsx(Rn,{label:i("predict.filter.timeRemaining"),children:jsx(_n,{options:v,selected:s.timeRemaining,onSelect:b=>p("timeRemaining",b)})}),jsx(Rn,{label:i("predict.filter.minVolume"),children:jsx(_n,{options:g,selected:s.minVolume,onSelect:b=>p("minVolume",b)})}),jsx(Rn,{label:i("predict.filter.minLiquidity"),children:jsx(_n,{options:x,selected:s.minLiquidity,onSelect:b=>p("minLiquidity",b)})})]}),jsxs("div",{className:"flex items-center gap-3 px-5 py-4",style:{borderTop:"1px solid rgba(39,39,42,0.5)"},children:[jsx("button",{type:"button",className:"inline-flex items-center justify-center py-2.5 px-5 rounded-[10px] text-zinc-400 text-sm font-medium hover:text-white transition-colors cursor-pointer",onClick:u,children:i("predict.filter.reset")}),jsxs("button",{type:"button",className:"flex-1 inline-flex items-center justify-center gap-2 py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer",onClick:m,children:[i("predict.filter.showResults"),d>0&&jsxs("span",{style:{opacity:.7},children:["(",d,")"]})]})]})]})})})}function Rn({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 fd({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 _n({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 Wi={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},Bi={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},wd=["start_time","volume","liquidity","ending_soon"],Hi={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"},Pd={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 Ui({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:n,onFilterPress:o,filterCount:i=0,className:s}){let{t:a}=useTranslation(),[l,c]=useState(false),u=useRef(null),m=useCallback(d=>{u.current&&!u.current.contains(d.target)&&c(false);},[]);useEffect(()=>(document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)),[m]),useEffect(()=>{if(!l)return;let d=f=>{f.key==="Escape"&&c(false);};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[l]);let p=zi[e];return jsxs("div",{className:s,style:{display:"flex",alignItems:"center",gap:8},children:[jsxs("div",{ref:u,style:{position:"relative"},children:[jsxs("button",{type:"button",style:Hi,onMouseEnter:d=>{d.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:d=>{d.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>c(d=>!d),children:[jsx(Nd,{}),jsx(p,{className:"size-4 shrink-0",style:{color:"#a1a1aa"}}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:a(Bi[e])}),jsx(Md,{open:l})]}),l&&jsx("div",{style:{...Pd,width:224,padding:4},children:wd.map(d=>{let f=zi[d],v=e===d;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:v?"rgba(199,255,46,0.08)":"transparent",color:v?"#c7ff2e":"#a1a1aa",borderRadius:10},onMouseEnter:g=>{v||(g.currentTarget.style.background="rgba(39,39,42,0.5)",g.currentTarget.style.color="#fff");},onMouseLeave:g=>{v||(g.currentTarget.style.background="transparent",g.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===d?n(!r):t(d),c(false);},children:[jsx(f,{className:"size-4 shrink-0",style:{color:v?"#c7ff2e":"#71717a"}}),jsx("span",{style:{flex:1,fontWeight:500},children:a(Bi[d])}),v&&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"})})]},d)})})]}),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:d=>{d.currentTarget.style.background="rgba(39,39,42,1)",d.currentTarget.style.color="#fff";},onMouseLeave:d=>{d.currentTarget.style.background="rgba(39,39,42,0.6)",d.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:Hi,onMouseEnter:d=>{d.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:d=>{d.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:o,children:[jsx(Cd,{}),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 zi={start_time:CalendarIcon,volume:ChartLineIcon,liquidity:DropletIcon,ending_soon:TimerIcon};function Nd(){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 Cd(){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 Md({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 Vi(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:u}=useInfiniteEvents(t),m=useMemo(()=>r?.pages.flatMap(f=>f.items).filter(f=>f!=null)??[],[r]),p=useCallback(()=>{c();},[c]),d=useCallback(()=>{u();},[u]);return {data:m,isLoading:n,isFetching:o&&!i,isFetchingMore:i,isError:s,error:a??null,hasMore:l??false,fetchMore:p,refetch:d}}var ji=`
1
+ import {createContext,memo,useRef,forwardRef,useState,useImperativeHandle,useMemo,useEffect,useCallback,useContext,Fragment as Fragment$1,startTransition,Component}from'react';import {PolymarketIcon,KalshiIcon,cn as cn$1,Skeleton,toast,StyledModal,ModalContent,useDisclosure,Tabs,Tab,StyledInput,StyledSwitch,Select,SelectItem,StyledNumberInput,ChevronDownIcon,Button,Spinner,useScreen,TimerIcon,DropletIcon,ChartLineIcon,CalendarIcon,Linkable,Avatar,ChevronUpIcon,OrderbookTableIcon,OrderbookDepthIcon,RefreshIcon,Dropdown,DropdownTrigger,DropdownMenu,DropdownItem,ChevronRightIcon,ChevronLeftIcon,EmptyIcon,TrashIcon,Chip,XCloseIcon,Kbd,SearchIcon,ModalHeader,ModalBody}from'@liberfi.io/ui';import {AsyncModal,useAsyncModal}from'@liberfi.io/ui-scaffold';import {useTranslation}from'@liberfi.io/i18n';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useWallets,useAuth,useAuthCallback}from'@liberfi.io/wallet-connector';import {keepPreviousData,useQueryClient,useQueries}from'@tanstack/react-query';import {useInfiniteMatchMarkets,useBalance,useDFlowKYC,usePolymarketSetup,usePredictClient,PolymarketContext,useTickSize,useFeeRate,useRebateConfig,useRealtimeOrderbook,pickBestAsk,walkOrderbook,usePositions,useDFlowQuote,useDFlowSubmit,useOrder,buildSignedV2OrderPayload,buildCtfExchangeDomain,buildOrderMessage,CTF_ORDER_TYPES,buildSignedOrder,buildClobPayload,buildPolymarketL2Headers,resolveEventsParams,useInfiniteEvents,useRedeemPosition,pickBestBid,useAvailableShares,getPolymarketSharesPrecision,useInfiniteOrders,useCancelOrder,useInfiniteTrades,useMarketHistory,useOrderbook,useEvent,useSimilarEvents,candlesticksQueryKey,useInfiniteComments,useSearchEvents}from'@liberfi.io/react-predict';export{PredictClient,PredictContext,PredictProvider,PredictWsClient,createPredictClient,createPredictWsClient,eventStatsQueryKey,fetchMatchMarketsPage,fetchMatchesPage,matchMarketsQueryKey,matchQueryKey,matchesQueryKey,useBalance,useCancelOrder,useCandlesticks,useDFlowKYC,useDFlowQuote,useDFlowSubmit,useEvent,useEventStats,useEvents,useInfiniteEvents,useInfiniteMatchMarkets,useInfiniteMatches,useInfiniteOrders,useInfiniteTrades,useMarket,useMarketHistory,useMarketTrades,useMatch,useOrder,useOrderbook,useOrders,usePositions,usePredictClient,usePriceHistory,useRedeemPosition,useSearchEvents,useSimilarEvents,useTrades}from'@liberfi.io/react-predict';import {ChainNamespace,Chain}from'@liberfi.io/types';import {formatAmountInUsd,SOLANA_TOKENS,formatAmount,debounce}from'@liberfi.io/utils';import ko 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 Jl={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},vi=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],xo=(()=>{let e=t=>{let r=vi.indexOf(t);return r===-1?vi.length:r};return Object.entries(Jl).map(([t,r])=>({slug:t,label:t,tags:(r??[]).map(o=>({slug:o,label:o}))})).sort((t,r)=>e(t.slug)-e(r.slug))})();function yi({categories:e,selectedCategory:t,selectedTag:r,activeTags:o,onCategorySelect:n,onTagSelect:i,trailing:s,pulsingTab:a="Trending",className:l}){let{t:d}=useTranslation(),u=useCallback(()=>{n(null);},[n]),p=d("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(xi,{label:p,isSelected:t===null,onPress:u,showPulse:p===a}),jsx(rc,{}),e.map(m=>jsx(xi,{label:m.category,isSelected:t===m.category,onPress:()=>n(m.category),badge:m.badge,showPulse:m.category===a},m.category))]})}),s&&jsx("div",{className:"flex-shrink-0",children:s})]}),t&&o.length>0&&jsx("div",{className:"hideScrollbar overflow-x-auto overflow-y-hidden flex items-center",children:jsxs("div",{className:"flex gap-x-1.5 pl-1 lg:w-full lg:gap-x-2",children:[jsx(bi,{label:d("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>i(null)}),o.map(m=>jsx(bi,{label:m.label,icon:m.icon,isSelected:r===m.label,onPress:()=>i(m.label)},m.label))]})})]})}function xi({label:e,isSelected:t,onPress:r,badge:o,showPulse:n}){return jsxs("button",{type:"button",onClick:r,className:cn$1("relative shrink-0 cursor-pointer whitespace-nowrap border-b px-2.5 py-1.5 text-sm font-medium capitalize transition-colors",t?"border-primary/50 text-primary":"border-transparent text-neutral-500 hover:text-neutral-300"),children:[n?jsxs("span",{className:"flex items-center gap-x-1.5",children:[jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-[rgb(240,68,56)]"}),jsx("span",{children:e})]}):e,o&&jsx("span",{className:"absolute -right-1 top-0 rounded bg-primary px-0.5 py-px text-[0.625rem] font-semibold leading-none text-neutral-950",children:o})]})}function rc(){return jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function bi({label:e,icon:t,isSelected:r,onPress:o}){return jsxs("button",{type:"button",onClick:o,className:cn$1("flex shrink-0 items-center justify-center gap-x-1 min-w-14 rounded-2xl border px-3 py-1.5 text-sm font-medium uppercase transition-colors cursor-pointer",r?"border-primary/40 bg-primary/15 text-primary":"border-border/80 text-neutral-500 hover:bg-primary/10 hover:text-primary"),children:[t&&jsx("span",{className:cn$1("iconify size-4",t)}),e]})}function qh({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 nc(e){return e.map(t=>({category:t.label,tags:t.tags.map(r=>r.label)}))}function oc(e){return e?e.tags.map(t=>({label:t.label,icon:t.icon})):[]}function wi({onSelect:e,trailing:t,className:r}){let[o,n]=useState(null),[i,s]=useState(null),a=useCallback(m=>{n(m),s(null),e?.({categorySlug:m,tagSlug:null});},[e]),l=useCallback(m=>{s(m),e?.({categorySlug:o,tagSlug:m});},[o,e]),d=nc(xo),u=xo.find(m=>m.slug===o),p=oc(u);return jsx(yi,{categories:d,selectedCategory:o,selectedTag:i,activeTags:p,onCategorySelect:a,onTagSelect:l,trailing:t,className:r})}function yn(e){return {title:e.title,imageUrl:e.image_url}}function kn(e,t){let r=e.outcomes[0],o=e.outcomes[1];return {question:e.question,yesAsk:t?.yesAsk??r?.best_ask??r?.price,noAsk:t?.noAsk??o?.best_ask??o?.price,yesBid:t?.yesBid??r?.best_bid,noBid:t?.noBid??o?.best_bid,yesSubTitle:r?.label??"Yes",noSubTitle:o?.label??"No"}}var $r=24,bo=4,Sn={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},ae={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},wn=ae.ALL,rv={[ae.ONE_DAY]:Sn.ONE_MINUTE,[ae.ONE_WEEK]:Sn.ONE_HOUR,[ae.ONE_MONTH]:Sn.ONE_HOUR,[ae.ALL]:Sn.ONE_DAY},nv={[ae.ONE_DAY]:300,[ae.ONE_WEEK]:3600,[ae.ONE_MONTH]:10800,[ae.ALL]:1440*60},ov={[ae.ONE_DAY]:1440*60,[ae.ONE_WEEK]:10080*60,[ae.ONE_MONTH]:720*60*60,[ae.ALL]:null},Pn=1,Nn=1,iv=1,sv=1,av=99,Pr={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},lv=Pr.ONE_WEEK,cv={[Pr.ONE_HOUR]:60,[Pr.SIX_HOURS]:60,[Pr.ONE_DAY]:300,[Pr.ONE_WEEK]:1800,[Pr.MAX]:1800};var Ci=createContext(null);function cr(){let e=useContext(Ci);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var uc=1e4;function pc({pollingInterval:e=uc,enabled:t=true,enableKalshi:r=true,children:o}){let n=useWallets(),i=useMemo(()=>n.find(D=>D.chainNamespace===ChainNamespace.SOLANA&&D.isConnected)?.address,[n]),s=useMemo(()=>n.find(D=>D.chainNamespace===ChainNamespace.EVM&&D.isConnected)?.address,[n]),{data:a,isLoading:l,isFetching:d,error:u}=useBalance({source:"kalshi",user:i??""},{enabled:t&&r&&!!i,refetchInterval:e}),{data:p,isLoading:m}=useDFlowKYC(i,{enabled:t&&r&&!!i,refetchInterval:3e4}),{data:c,isLoading:f}=usePolymarketSetup(s,{enabled:t&&!!s,refetchInterval:3e4}),g=c?.safe_address,v=c?.verified??false,x=c?.wallet_kind??"deposit",b=c?.deposit_wallet_address,w=x==="safe"?c?.safe_address:b,P=x==="safe"?c?.safe_deployed??false:c?.deposit_wallet_deployed??false,{data:h,isLoading:y,isFetching:S,error:N}=useBalance({source:"polymarket",user:s??""},{enabled:t&&v&&!!s,refetchInterval:e}),A=useMemo(()=>({solanaAddress:i,evmAddress:s,polymarketWalletKind:x,polymarketWalletAddress:w,polymarketDepositWalletAddress:b,polymarketWalletDeployed:P,polymarketSafeAddress:g,kalshiUsdcBalance:a?Number(a.balance):null,polymarketUsdcBalance:v&&h?Number(h.balance):null,kalshiKycVerified:p?.verified??false,kalshiKycUrl:p?.kyc_url??null,kalshiKycLoading:m,polymarketSetupVerified:v,polymarketSafeDeployed:c?.safe_deployed??false,polymarketTokenApproved:c?.token_approved??false,polymarketSetupLoading:f,isLoading:l||y,isFetching:d||S,error:u??N??null}),[i,s,x,w,b,P,g,a,h,v,p,m,c,f,l,y,d,S,u,N]);return jsx(Ci.Provider,{value:A,children:o})}var fc={minutes:60,hours:3600,days:86400};function Cn(e,t,r){let o=Math.floor(Date.now()/1e3);switch(e){case "5m":return o+300;case "1h":return o+3600;case "12h":return o+720*60;case "24h":return o+1440*60;case "eod":{let n=new Date;return n.setUTCHours(23,59,59,0),Math.floor(n.getTime()/1e3)}case "custom":return o+t*fc[r]}}function Mn(e,t){let r=parseFloat(t);return !r||r<=0?e:Math.round(e/r)*r}function we(e,t){let r=Math.pow(10,t);return Math.floor(e*r)/r}function En(e,t,r){let o=e.match(/Size\s*\(([\d.]+)\)\s*lower than the minimum:\s*([\d.]+)/i);if(o)return t("predict.trade.polymarket.minOrderSize",{current:o[1],min:o[2]});let n=e.match(/balance:\s*(\d+),\s*sum of active orders:\s*(\d+)/i);if(n){let s=parseInt(n[1],10)/1e6,a=parseInt(n[2],10)/1e6,l=Math.max(0,s-a);return t("predict.trade.polymarket.insufficientBalance",{total:we(s,2).toFixed(2),active:we(a,2).toFixed(2),available:we(l,2).toFixed(2)})}return /not enough balance/i.test(e)?t(r==="sell"?"predict.trade.insufficientShares":"predict.trade.insufficientBalance"):/max accuracy of/i.test(e)?t("predict.trade.polymarket.decimalAccuracy"):/tick size/i.test(e)?t("predict.trade.polymarket.tickSizeError"):/couldn.*fully filled|FOK.*filled or killed/i.test(e)?t("predict.trade.polymarket.fokNotFilled"):e.replace(/order\s+0x[a-f0-9]+\s+is invalid\.\s*/i,"")||e}function Kr(e,t=2){return parseFloat(we(e,t).toFixed(t)).toString()}function dr(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};ko({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{ko({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{ko({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function Ti({market:e,initialOutcome:t="yes",slippageBps:r=100,onInsufficientBalance:o}){let{t:n}=useTranslation(),{status:i}=useAuth(),s=useWallets(),a=usePredictClient(),l=useContext(PolymarketContext),d=useQueryClient(),u=e.source,p=u==="polymarket",m=s.find(_=>_.chainNamespace===ChainNamespace.SOLANA&&_.isConnected),c=s.find(_=>_.chainNamespace===ChainNamespace.EVM&&_.isConnected&&"switchChain"in _),f=i==="authenticated",g=m?.address,v=c?.address,[x,b]=useState(t),[w,P]=useState("market"),[h,y]=useState(NaN),[S,N]=useState(NaN),[A,D]=useState(false),[z,F]=useState(null),[q,$]=useState(false),[Q,re]=useState(false),[Z,C]=useState("1h"),[M,U]=useState(30),[G,k]=useState("minutes"),ce=useMemo(()=>{if(u!=="polymarket")return;let _=e.provider_meta?.["polymarket.clobTokenIds"];return _?(typeof _=="string"?JSON.parse(_):_)[x==="yes"?0:1]:void 0},[u,e.provider_meta,x]),{data:pe,isLoading:ke}=useTickSize(ce),Ve=pe?.minimum_tick_size?String(pe.minimum_tick_size):"0.01",{data:Ue,isLoading:$e}=useFeeRate(ce),Ze=String(Ue?.base_fee??0),{data:Pe}=useRebateConfig(),xe=Pe?.builder_enabled&&Pe.builder_code?Pe.builder_code:void 0,et=null,Mt=false,tt=null,qe=false,Se,Oe,rt;try{let _=cr();et={kalshiUsdcBalance:_.kalshiUsdcBalance,polymarketUsdcBalance:_.polymarketUsdcBalance,isLoading:_.isLoading},Mt=_.kalshiKycVerified,tt=_.kalshiKycUrl,qe=_.polymarketSetupVerified,Se=_.polymarketSafeAddress,Oe=_.polymarketWalletKind,rt=_.polymarketWalletAddress;}catch{}let Xt=u==="kalshi"&&!Mt,mt=u==="polymarket"&&!qe,{data:R}=useRealtimeOrderbook({slug:e.slug,source:u,outcome:x},{enabled:e.status==="open"}),X=useMemo(()=>{let _=pickBestAsk(R,x);if(_!=null&&_>0)return _;let Be=x==="yes"?0:1,Ye=e.outcomes[Be];return Ye?.best_ask??Ye?.price??.5},[R,e.outcomes,x]),bt=useCallback(_=>{P(_);},[]),ft=useCallback(_=>{b(_),N(NaN);},[]);useEffect(()=>{ft(t);},[t,ft]),useEffect(()=>{w==="limit"&&isNaN(S)&&N(Math.round(X*100)/100);},[w,S,X]);let gt=useMemo(()=>isNaN(h)||h<=0?0:X>0?h/X:0,[h,X]),L=useMemo(()=>walkOrderbook({orderbook:R,outcome:x,side:"buy",sharesNeeded:gt,slippageBps:r}),[R,x,gt,r]),ve=useMemo(()=>L.status==="ok"&&L.worstPrice!=null&&L.worstPrice>0?L.worstPrice:X,[L,X]),je=useMemo(()=>isNaN(h)||h<=0?"0":String(Math.round(h*1e6)),[h]),Or=e.provider_meta?.["dflow.yesMint"]??"",ao=e.provider_meta?.["dflow.noMint"]??"",lo=SOLANA_TOKENS.stablecoins.USDC.address,or=x==="yes"?Or:ao,ir=lo,Bt=or,kr=u==="kalshi"?g??"":v??"",{data:Et,isLoading:Ge}=usePositions({source:u,user:kr},{enabled:!!kr}),co=u==="kalshi"&&!!ir&&!!Bt&&!!g&&je!=="0",{refetch:pn}=useDFlowQuote({inputMint:ir,outputMint:Bt,amount:je,userPublicKey:g??"",slippageBps:100},{enabled:co}),Ht=useMemo(()=>et?u==="kalshi"?et.kalshiUsdcBalance:et.polymarketUsdcBalance:Et&&Et.positions.reduce((Be,Ye)=>Ye.side==="USDC"||Ye.side==="collateral"?Be+(Ye.current_value??0):Be,0)||null,[et,Et,u]),Jt=et?et.isLoading:Ge,Dr=useMemo(()=>w==="limit"&&p&&!isNaN(S)?S:X,[w,p,S,X]),mn=useMemo(()=>isNaN(h)||h<=0?0:h,[h]),uo=useMemo(()=>isNaN(h)||h<=0?0:Dr>0?h/Dr*1:0,[h,Dr]),fn=uo-mn,po=useCallback(_=>{if(isNaN(_)){y(NaN);return}y(Math.round(Math.max(0,_)*100)/100);},[]),sr=useCallback(_=>{if(isNaN(_)){N(NaN);return}let Be=Math.max(.01,Math.min(.99,_));N(Math.round(Be*100)/100);},[]),Tt=useCallback(()=>{y(NaN),N(NaN),P("market"),re(false),C("1h"),U(30),k("minutes");},[]),zt=useMemo(()=>{let _=[];return isNaN(h)||h<=0?_.push(n("predict.trade.minAmountUsd",{amount:Nn})):h<Nn&&_.push(n("predict.trade.minAmountUsd",{amount:Nn})),e.status!=="open"&&_.push(n("predict.trade.marketNotActive")),Ht!=null&&!isNaN(h)&&h>0&&h>we(Ht,2)&&_.push(n("predict.trade.insufficientBalance")),w==="limit"&&p&&(isNaN(S)||S<.01||S>.99)&&_.push(n("predict.trade.limitPriceRange")),w==="limit"&&p&&Q&&Z==="custom"&&(isNaN(M)||M<=0)&&_.push(n("predict.trade.expiration.invalidDate")),u==="polymarket"&&w==="market"&&!isNaN(h)&&h>0&&gt>0&&(L.status==="insufficient_liquidity"?_.push(n("predict.trade.insufficientLiquidity",{available:we(L.totalAvailable,2)})):L.status==="exceeds_slippage"&&_.push(n("predict.trade.priceImpactTooHigh",{impact:(L.priceImpactBps/100).toFixed(2),slippage:(r/100).toFixed(2)}))),{isValid:_.length===0,errors:_}},[h,e.status,Ht,w,p,S,Q,Z,M,u,gt,L,r,n]),Sr=useMemo(()=>Ht==null||isNaN(h)||h<=0?false:h>we(Ht,2),[Ht,h]),mo=useCallback(()=>{o?.(u);},[o,u]),{mutateAsync:Ar}=useDFlowSubmit(),{data:ar}=useOrder({id:z??"",source:u},{enabled:!!z});useEffect(()=>{if(!ar||!z)return;let{status:_}=ar;_==="closed"?(F(null),D(false),toast.success(n("predict.trade.submitSuccess")),dr(),Tt(),d.invalidateQueries({queryKey:["predict","positions"]})):(_==="failed"||_==="expired")&&(D(false),F(null),toast.error(n("predict.trade.submitError")));},[ar,z,d,Tt,n]);let nt=useCallback(async()=>{if(!g||!m)return;if(!ir||!Bt){toast.error("Missing token mint addresses"),D(false);return}if(!Mt){$(true),D(false);return}let Wt=(await pn()).data?.transaction;if(!Wt){toast.error(n("predict.trade.submitError")),D(false);return}let Br=Uint8Array.from(atob(Wt),ot=>ot.charCodeAt(0)),yt=await m.signTransaction(Br),kt=await Ar({signedTransaction:btoa(String.fromCharCode(...yt)),orderContext:{user_public_key:g,input_mint:ir,output_mint:Bt,amount:je,price:String(X),side:"BUY",outcome:x==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});F(kt.signature);},[g,m,pn,Ar,ir,Bt,je,X,x,e.slug,n,Mt]),Fr=useCallback(async()=>{if(!c||!l)return;let _=c.chain,Be=_!==Chain.POLYGON;Be&&await c.switchChain(Chain.POLYGON);try{let Ye=await c.getEip1193Provider();if(!Ye){toast.error(n("predict.trade.submitError")),D(!1);return}let Wt=Oe==="deposit"&&!!rt,Br=!Wt&&!!Se,yt=Wt?rt:Se,kt={address:c.address,signatureType:Wt?3:Br?2:0,signTypedData:async(Ee,Te,ht,Zt)=>{let wt=[];"name"in Ee&&wt.push({name:"name",type:"string"}),"version"in Ee&&wt.push({name:"version",type:"string"}),"chainId"in Ee&&wt.push({name:"chainId",type:"uint256"}),"verifyingContract"in Ee&&wt.push({name:"verifyingContract",type:"address"}),"salt"in Ee&&wt.push({name:"salt",type:"bytes32"});let hn={EIP712Domain:wt,...Te};return await Ye.request({method:"eth_signTypedData_v4",params:[c.address,JSON.stringify({domain:Ee,types:hn,primaryType:ht,message:Zt})]})}},ot=l.credentials??await l.authenticate(kt),Hr=x==="yes"?0:1,zr="",Lt=e.provider_meta?.["polymarket.clobTokenIds"];Lt&&(zr=(typeof Lt=="string"?JSON.parse(Lt):Lt)[Hr]??"");let Wr=e.provider_meta?.["polymarket.negRisk"]??!1,gn=w==="limit"&&!isNaN(S)?S:ve,Ur=Mn(gn,Ve),E=w==="limit"?Q?"GTD":"GTC":"FOK",Me=w==="market"?h:Ur>0?h/Ur:0,De={tokenId:zr,price:Ur,size:Me,side:"BUY",orderType:E,tickSize:Ve,negRisk:Wr,...yt&&{funderAddress:yt},...xe&&{builderCode:xe},...w==="limit"&&Q&&{expiration:Cn(Z,M,G)}},He;if(Wt)He=await buildSignedV2OrderPayload({signer:kt,depositWalletAddress:yt,input:De,owner:ot.apiKey});else {let Ee=buildCtfExchangeDomain(Wr),Te=buildOrderMessage({...De,signerAddress:kt.address,signatureType:kt.signatureType,feeRateBps:Ze}),ht=await kt.signTypedData(Ee,CTF_ORDER_TYPES,"Order",Te),Zt=buildSignedOrder(Te,ht,De.orderType);He=buildClobPayload(Zt,ot.apiKey);}let Qe=JSON.stringify(He),St=await buildPolymarketL2Headers(ot.address,{apiKey:ot.apiKey,secret:ot.secret,passphrase:ot.passphrase,method:"POST",requestPath:"/order",body:Qe});await a.createPolymarketOrder(He,St),d.invalidateQueries({queryKey:["predict","orders"]}),d.invalidateQueries({queryKey:["predict","positions"]}),toast.success(n("predict.trade.submitSuccess")),dr(),Tt(),D(!1);}finally{Be&&_&&c.switchChain(_).catch(()=>{});}},[c,l,x,e.provider_meta,w,S,ve,h,a,d,Q,Z,M,G,Tt,n,Ve,Ze,Se,Oe,rt,xe]),fo=useCallback(async()=>{if(!(!zt.isValid||!f)){D(true),F(null),$(false);try{u==="kalshi"?await nt():await Fr();}catch(_){let Be=_ instanceof Error?_.message:"",Ye=u==="polymarket"&&Be?En(Be,n,"buy"):Be||void 0;toast.error(Ye||n("predict.trade.submitError")),D(false);}}},[zt.isValid,f,u,nt,Fr,n]);return {outcome:x,orderType:w,quantity:h,limitPrice:S,shares:gt,estimatedCost:mn,potentialPayout:uo,potentialProfit:fn,pricePerShare:X,usdcBalance:Ht,isBalanceLoading:Jt,isMarketDataLoading:u==="polymarket"&&($e||ke),isSubmitting:A,authStatus:i,validation:zt,isInsufficientBalance:Sr,source:u,supportsLimitOrder:p,kycRequired:q,needsKyc:Xt,needsSetup:mt,kycUrl:tt,expirationEnabled:Q,expirationPreset:Z,customDuration:M,customDurationUnit:G,setOutcome:ft,setOrderType:bt,setQuantity:po,setLimitPrice:sr,setExpirationEnabled:re,setExpirationPreset:C,setCustomDuration:U,setCustomDurationUnit:k,submit:fo,notifyInsufficientBalance:mo}}function Tn({isOpen:e,onClose:t,kycUrl:r}){let{t:o}=useTranslation();return jsx(StyledModal,{isOpen:e,onOpenChange:n=>{n||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:o("predict.trade.kycModalTitle")}),jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxs("div",{className:"px-5 pb-5",children:[jsx("p",{className:"text-[13px] text-zinc-400 mb-4 text-left",children:o("predict.trade.kycModalDescription")}),jsx("div",{className:"flex flex-col gap-2 mb-4",children:["predict.trade.kycModalBullet1","predict.trade.kycModalBullet2","predict.trade.kycModalBullet3"].map(n=>jsxs("div",{className:"flex items-center gap-2.5 text-[13px] text-zinc-300",children:[jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#c7ff2e] shrink-0",children:jsx("polyline",{points:"20 6 9 17 4 12"})}),jsx("span",{children:o(n)})]},n))}),r&&jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[13px] text-[#c7ff2e]/70 hover:text-[#c7ff2e] transition-colors mb-3",children:[o("predict.trade.goToKYC")," \u2192"]}),jsx("p",{className:"text-[11px] text-zinc-500 mb-5",children:o("predict.trade.kycModalNote")}),jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:o("common.ok")})]})]})})})}var Jc=["5m","1h","12h","24h","eod","custom"],Zc={"5m":"predict.trade.expiration.5m","1h":"predict.trade.expiration.1h","12h":"predict.trade.expiration.12h","24h":"predict.trade.expiration.24h",eod:"predict.trade.expiration.eod",custom:"predict.trade.expiration.custom"},ed=["minutes","hours","days"],td={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},rd={maximumFractionDigits:0};function Bi({event:e,market:t,variant:r="bordered",outcome:o,orderType:n,quantity:i,limitPrice:s,shares:a,potentialProfit:l,potentialPayout:d,estimatedCost:u,usdcBalance:p,isBalanceLoading:m,isMarketDataLoading:c,isSubmitting:f,authStatus:g,isValid:v,validationErrors:x,isInsufficientBalance:b,onInsufficientBalance:w,supportsLimitOrder:P,kycRequired:h,needsKyc:y,needsSetup:S,kycUrl:N,expirationEnabled:A,expirationPreset:D,customDuration:z,customDurationUnit:F,onOutcomeChange:q,onOrderTypeChange:$,onQuantityChange:Q,onLimitPriceChange:re,onExpirationEnabledChange:Z,onExpirationPresetChange:C,onCustomDurationChange:M,onCustomDurationUnitChange:U,onSubmit:G}){let{t:k}=useTranslation(),[ce,pe]=useState(false),ke=useDisclosure(),[Ve,Ue]=useState(""),$e=useRef(false);useEffect(()=>{$e.current||Ue(isNaN(i)?"":String(i));},[i]);let[Ze,Pe]=useState(""),xe=useRef(false);useEffect(()=>{xe.current||(isNaN(s)?Pe(""):Pe(String(parseFloat((s*100).toFixed(2)))));},[s]);let et=useCallback(L=>{if(L!==""&&!/^\d*\.?\d{0,2}$/.test(L))return;if(Pe(L),L===""||L==="."){re(NaN);return}let je=parseFloat(L);isNaN(je)||re(je/100);},[re]),Mt=useCallback(L=>{if(L!==""&&!/^\d*\.?\d{0,2}$/.test(L))return;if(Ue(L),ft(false),L===""||L==="."){Q(NaN);return}let je=parseFloat(L);isNaN(je)||Q(je);},[Q]);useEffect(()=>{h&&!ke.isOpen&&ke.onOpen();},[h]);let tt=useMemo(()=>{let L=o==="yes"?t.yesAsk:t.noAsk;return L!=null?parseFloat((Number(L)*100).toFixed(2)):null},[o,t]),qe=!isNaN(i)&&i>0,Se=g==="authenticated",Oe=g==="authenticating"||g==="deauthenticating",rt=Se&&(y||S),Xt=useMemo(()=>{if(Oe)return k("predict.trade.checkingLogin");if(!Se)return k("predict.trade.loginToTrade");if(y)return k("predict.trade.kycRequired");if(S)return k("predict.trade.setupRequired");if(m)return k("predict.trade.loadingBalance");if(c)return k("predict.trade.loadingMarketData");if(f)return k("predict.trade.submitting");if(h)return k("predict.trade.kycRequired");if(!qe)return k("predict.trade.enterAmount");let L=k(o==="yes"?"predict.trade.yes":"predict.trade.no"),ve=l>0?` \u2192 Win $${l.toFixed(2)}`:"";return `${k("predict.trade.buy")} ${L}${ve}`},[Oe,Se,y,S,m,c,f,h,qe,o,l,k]),mt="primary",R=()=>{Q(Math.floor((p??0)/2*100)/100);},X=()=>{Q(we(p??0,2));},[bt,ft]=useState(false),gt=()=>{if(!Se){ft(false),G();return}if(y){ke.onOpen();return}if(S&&w){ft(false),w();return}if(h){ke.onOpen();return}if(b&&w){ft(false),w();return}if(!v){ft(true);return}ft(false),G();};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:L=>{r==="bordered"&&(L.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:L=>{r==="bordered"&&(L.currentTarget.style.borderColor="rgba(39,39,42,0.6)");},children:[e&&jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxs("span",{className:"text-bullish",children:[k("predict.trade.buy")," ",k(o==="yes"?"predict.trade.yes":"predict.trade.no")]}),jsxs("span",{className:"text-foreground",children:[" \xB7 ",t.yesSubTitle]})]})]})]}),jsxs("div",{className:"flex items-center justify-between",children:[P?jsxs(Tabs,{variant:"underlined",selectedKey:n,onSelectionChange:L=>$(L),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsx(Tab,{title:k("predict.trade.market")},"market"),jsx(Tab,{title:k("predict.trade.limit")},"limit")]}):jsx("span",{className:"text-sm font-medium text-foreground",children:k("predict.trade.market")}),n==="limit"&&P?jsx(StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:Ze,onChange:L=>et(L.target.value),onFocus:()=>{xe.current=true;},onBlur:()=>{xe.current=false,isNaN(s)?Pe(""):Pe(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"}}):tt!=null&&jsxs("span",{className:"text-xl font-bold tabular-nums",children:[tt," \xA2"]})]}),jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(L=>{let ve=L==="yes"?t.yesAsk:t.noAsk;return jsx("div",{className:"flex flex-1 flex-col gap-y-1",children:jsxs("button",{type:"button",onClick:()=>q(L),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${o===L?"border-bullish bg-bullish/10 text-bullish":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsx("span",{children:k(L==="yes"?"predict.trade.yes":"predict.trade.no")}),ve!=null&&jsxs("span",{className:"ml-1 opacity-70",children:[parseFloat((Number(ve)*100).toFixed(2)),"\xA2"]})]})},L)})}),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:k("predict.trade.youArePaying")}),jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("button",{type:"button",onClick:R,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:k("predict.trade.half")}),jsx("button",{type:"button",onClick:X,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:k("predict.trade.max")})]})]}),jsx(StyledInput,{"aria-label":"Trade amount",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:Ve,onChange:L=>Mt(L.target.value),onFocus:()=>{$e.current=true;},onBlur:()=>{$e.current=false,Ue(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"}}),bt&&x.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:x.map(L=>jsx("span",{className:"text-xs text-danger",children:L},L))})]}),jsxs("div",{className:"flex items-center justify-end gap-x-1.5 text-sm",children:[jsx("span",{className:"text-neutral-500",children:k("predict.trade.balance")}),jsx("span",{className:"font-medium text-foreground tabular-nums",children:p!=null?`$${we(p,2).toFixed(2)}`:"$0"})]}),n==="limit"&&P&&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:k("predict.trade.setExpiration")}),jsx(StyledSwitch,{size:"sm",color:"primary",isSelected:A,onValueChange:Z,"aria-label":k("predict.trade.setExpiration")})]}),A&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":k("predict.trade.setExpiration"),selectedKeys:[D],onSelectionChange:L=>{let ve=Array.from(L)[0];ve&&C(ve);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Jc.map(L=>jsx(SelectItem,{children:k(Zc[L])},L))}),D==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(z)?void 0:z,onValueChange:M,minValue:1,step:1,formatOptions:rd,classNames:{base:"flex-1",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 min-h-10",input:"text-sm"}}),jsx(Select,{"aria-label":"Duration unit",selectedKeys:[F],onSelectionChange:L=>{let ve=Array.from(L)[0];ve&&U(ve);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:ed.map(L=>jsx(SelectItem,{children:k(td[L])},L))})]})]})]}),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:()=>pe(L=>!L),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{children:k("predict.trade.odds")}),jsx(ChevronDownIcon,{className:cn$1("h-3.5 w-3.5 transition-transform",ce&&"rotate-180")})]}),tt!=null&&jsx("span",{className:"text-foreground font-medium tabular-nums",children:k("predict.trade.chance",{percent:tt})})]}),ce&&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:k("predict.trade.totalSize")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${u.toFixed(2)}`:"\u2013"})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:k("predict.trade.numContracts")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(a)&&a>0?Kr(a):"\u2013"})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:k("predict.trade.payout")}),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:k("predict.trade.estProfit")}),jsx("span",{className:"tabular-nums text-bullish",children:!isNaN(i)&&i>0&&l>0?`+$${l.toFixed(2)}`:"\u2013"})]})]})]}),jsx(Button,{color:mt,fullWidth:true,radius:"lg",size:"lg",isDisabled:Oe||Se&&!rt&&(m||c||!qe||f),isLoading:Oe||Se&&!rt&&(f||m||c),spinner:jsx(Spinner,{size:"sm",color:"current"}),onPress:gt,children:Xt})]}),jsx(Tn,{isOpen:ke.isOpen,onClose:ke.onClose,kycUrl:N})]})}function Rn({event:e,market:t,variant:r,initialOutcome:o,chain:n,slippageBps:i,onInsufficientBalance:s,onOutcomeChange:a}){let{outcome:l,orderType:d,quantity:u,limitPrice:p,shares:m,estimatedCost:c,potentialPayout:f,potentialProfit:g,pricePerShare:v,usdcBalance:x,isBalanceLoading:b,isMarketDataLoading:w,isSubmitting:P,authStatus:h,validation:y,isInsufficientBalance:S,supportsLimitOrder:N,kycRequired:A,needsKyc:D,needsSetup:z,kycUrl:F,expirationEnabled:q,expirationPreset:$,customDuration:Q,customDurationUnit:re,setOutcome:Z,setOrderType:C,setQuantity:M,setLimitPrice:U,setExpirationEnabled:G,setExpirationPreset:k,setCustomDuration:ce,setCustomDurationUnit:pe,submit:ke,notifyInsufficientBalance:Ve}=Ti({market:t,initialOutcome:o,slippageBps:i,onInsufficientBalance:s}),Ue=useAuthCallback(ke),$e=useCallback(xe=>{Z(xe),a?.(xe);},[Z,a]),Ze=useMemo(()=>e?yn(e):void 0,[e]),Pe=useMemo(()=>kn(t,{yesAsk:l==="yes"?v:void 0,noAsk:l==="no"?v:void 0}),[t,l,v]);return jsx(Bi,{event:Ze,market:Pe,variant:r,outcome:l,orderType:d,quantity:u,limitPrice:p,shares:m,estimatedCost:c,potentialPayout:f,potentialProfit:g,usdcBalance:x,isBalanceLoading:b,isMarketDataLoading:w,isSubmitting:P,authStatus:h,isValid:y.isValid,validationErrors:y.errors,isInsufficientBalance:S,onInsufficientBalance:s?Ve:void 0,supportsLimitOrder:N,kycRequired:A,needsKyc:D,needsSetup:z,kycUrl:F,expirationEnabled:q,expirationPreset:$,customDuration:Q,customDurationUnit:re,onOutcomeChange:$e,onOrderTypeChange:C,onQuantityChange:M,onLimitPriceChange:U,onExpirationEnabledChange:G,onExpirationPresetChange:k,onCustomDurationChange:ce,onCustomDurationUnitChange:pe,onSubmit:Ue})}var Vr="predict-trade";function _n({id:e=Vr}){return jsx(AsyncModal,{id:e,children:t=>jsx(ud,{...t})})}function ud({params:e,isOpen:t,onOpenChange:r}){let{t:o}=useTranslation(),{isMobile:n}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:n?"lg":"md",backdrop:"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:n?"":"p-2",children:[jsx(Rn,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,chain:e.chain,slippageBps:e.slippageBps,variant:"flat",onInsufficientBalance:e.onInsufficientBalance}),jsx("div",{className:"px-4 pb-4",children:jsx("button",{type:"button",onClick:()=>r(false),className:"w-full h-12 rounded-xl text-sm font-medium text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:o("common.cancel")})})]})})}):null}var jr={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function Po(e,t=true){let r=0;return t&&e.source&&r++,e.timeRemaining&&r++,e.minVolume&&r++,e.minLiquidity&&r++,r}function zi({isOpen:e,onClose:t,value:r,onChange:o,enableKalshi:n=true}){let{t:i}=useTranslation(),[s,a]=useState(r),l=useMemo(()=>n?jr:{...jr,source:"polymarket"},[n]),d=useCallback(b=>{b?a(r):t();},[r,t]),u=useCallback(()=>{a(l);},[l]),p=useCallback(()=>{o(s),t();},[s,o,t]),m=useCallback((b,w)=>{a(P=>({...P,[b]:w}));},[]),c=useMemo(()=>Po(s,n),[s,n]),f=useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"polymarket",label:i("predict.platform.polymarket")},{value:"kalshi",label:i("predict.platform.kalshi")}],[i]),g=useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1d",label:i("predict.filter.lessThanDay")},{value:"7d",label:i("predict.filter.lessThanWeek")},{value:"30d",label:i("predict.filter.lessThanMonth")}],[i]),v=useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[i]),x=useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[i]);return jsx(StyledModal,{isOpen:e,onOpenChange:d,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:i("predict.filter.title")}),jsx(vd,{onClick:()=>d(false)})]}),jsxs("div",{style:{padding:"0 20px 16px",display:"flex",flexDirection:"column",gap:20},children:[n&&jsx(On,{label:i("predict.filter.platform"),children:jsx(Dn,{options:f,selected:s.source,onSelect:b=>m("source",b)})}),jsx(On,{label:i("predict.filter.timeRemaining"),children:jsx(Dn,{options:g,selected:s.timeRemaining,onSelect:b=>m("timeRemaining",b)})}),jsx(On,{label:i("predict.filter.minVolume"),children:jsx(Dn,{options:v,selected:s.minVolume,onSelect:b=>m("minVolume",b)})}),jsx(On,{label:i("predict.filter.minLiquidity"),children:jsx(Dn,{options:x,selected:s.minLiquidity,onSelect:b=>m("minLiquidity",b)})})]}),jsxs("div",{className:"flex items-center gap-3 px-5 py-4",style:{borderTop:"1px solid rgba(39,39,42,0.5)"},children:[jsx("button",{type:"button",className:"inline-flex items-center justify-center py-2.5 px-5 rounded-[10px] text-zinc-400 text-sm font-medium hover:text-white transition-colors cursor-pointer",onClick:u,children:i("predict.filter.reset")}),jsxs("button",{type:"button",className:"flex-1 inline-flex items-center justify-center gap-2 py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer",onClick:p,children:[i("predict.filter.showResults"),c>0&&jsxs("span",{style:{opacity:.7},children:["(",c,")"]})]})]})]})})})}function On({label:e,children:t}){return jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[jsx("span",{style:{fontSize:11,fontWeight:500,color:"#71717a",textTransform:"uppercase",letterSpacing:"0.05em"},children:e}),t]})}function vd({onClick:e}){return jsx("button",{type:"button",onClick:e,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}function Dn({options:e,selected:t,onSelect:r,allowDeselect:o=true}){return jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:e.map(n=>{let i=t===n.value;return jsx("button",{type:"button",onClick:()=>{r(i&&o?void 0:n.value);},style:{flexShrink:0,borderRadius:10,padding:"6px 14px",fontSize:13,fontWeight:500,cursor:"pointer",transition:"all 0.15s",border:i?"1px solid rgba(199,255,46,0.3)":"1px solid rgba(63,63,70,0.5)",background:i?"rgba(199,255,46,0.08)":"rgba(39,39,42,0.4)",color:i?"#c7ff2e":"#a1a1aa"},onMouseEnter:s=>{i||(s.currentTarget.style.background="rgba(39,39,42,0.8)",s.currentTarget.style.color="#fff");},onMouseLeave:s=>{i||(s.currentTarget.style.background="rgba(39,39,42,0.4)",s.currentTarget.style.color="#a1a1aa");},children:n.label},n.value??"__all")})})}var Vi={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},Ui={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},Cd=["start_time","volume","liquidity","ending_soon"],$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"},Md={position:"absolute",left:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function ji({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:o,onFilterPress:n,filterCount:i=0,className:s}){let{t:a}=useTranslation(),[l,d]=useState(false),u=useRef(null),p=useCallback(c=>{u.current&&!u.current.contains(c.target)&&d(false);},[]);useEffect(()=>(document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)),[p]),useEffect(()=>{if(!l)return;let c=f=>{f.key==="Escape"&&d(false);};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[l]);let m=Ki[e];return jsxs("div",{className:s,style:{display:"flex",alignItems:"center",gap:8},children:[jsxs("div",{ref:u,style:{position:"relative"},children:[jsxs("button",{type:"button",style:$i,onMouseEnter:c=>{c.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:c=>{c.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>d(c=>!c),children:[jsx(Ed,{}),jsx(m,{className:"size-4 shrink-0",style:{color:"#a1a1aa"}}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:a(Ui[e])}),jsx(Ld,{open:l})]}),l&&jsx("div",{style:{...Md,width:224,padding:4},children:Cd.map(c=>{let f=Ki[c],g=e===c;return jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",gap:12,padding:"10px 12px",textAlign:"left",fontSize:14,border:"none",cursor:"pointer",transition:"all 0.15s",background:g?"rgba(199,255,46,0.08)":"transparent",color:g?"#c7ff2e":"#a1a1aa",borderRadius:10},onMouseEnter:v=>{g||(v.currentTarget.style.background="rgba(39,39,42,0.5)",v.currentTarget.style.color="#fff");},onMouseLeave:v=>{g||(v.currentTarget.style.background="transparent",v.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===c?o(!r):t(c),d(false);},children:[jsx(f,{className:"size-4 shrink-0",style:{color:g?"#c7ff2e":"#71717a"}}),jsx("span",{style:{flex:1,fontWeight:500},children:a(Ui[c])}),g&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 6 9 17l-5-5"})})]},c)})})]}),jsx("button",{type:"button",style:{borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",width:36,height:36,color:"#a1a1aa",cursor:"pointer",transition:"all 0.15s",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:14},onMouseEnter:c=>{c.currentTarget.style.background="rgba(39,39,42,1)",c.currentTarget.style.color="#fff";},onMouseLeave:c=>{c.currentTarget.style.background="rgba(39,39,42,0.6)",c.currentTarget.style.color="#a1a1aa";},onClick:()=>o(!r),children:r?"\u2191":"\u2193"}),jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxs("button",{type:"button",style:$i,onMouseEnter:c=>{c.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:c=>{c.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:n,children:[jsx(Td,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:a("predict.filter.title")})]}),i>0&&jsx("span",{style:{position:"absolute",top:-4,right:-4,minWidth:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,background:"#c7ff2e",color:"#000",fontSize:10,fontWeight:600,padding:"0 4px"},children:i})]})]})}var Ki={start_time:CalendarIcon,volume:ChartLineIcon,liquidity:DropletIcon,ending_soon:TimerIcon};function Ed(){return jsxs("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#a1a1aa"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"m21 16-4 4-4-4"}),jsx("path",{d:"M17 20V4"}),jsx("path",{d:"m3 8 4-4 4 4"}),jsx("path",{d:"M7 4v16"})]})}function Td(){return jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#a1a1aa"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"})})}function Ld({open:e}){return jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#71717a",transition:"transform 0.15s",transform:e?"rotate(180deg)":void 0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"m6 9 6 6 6-6"})})}function Yi(e={}){let t=useMemo(()=>resolveEventsParams(e),[e.tagSlugSelection,e.limit,e.status,e.sort_by,e.sort_asc,e.source,e.with_markets,e.minVolume,e.minLiquidity,e.timeRemaining,e.markets_limit]),{data:r,isLoading:o,isFetching:n,isFetchingNextPage:i,isError:s,error:a,hasNextPage:l,fetchNextPage:d,refetch:u}=useInfiniteEvents(t),p=useMemo(()=>r?.pages.flatMap(f=>f.items).filter(f=>f!=null)??[],[r]),m=useCallback(()=>{d();},[d]),c=useCallback(()=>{u();},[u]);return {data:p,isLoading:o,isFetching:n&&!i,isFetchingMore:i,isError:s,error:a??null,hasMore:l??false,fetchMore:m,refetch:c}}var Qi=`
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
- `,Gi={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 In(e){return {...Gi,animationDelay:`${e}ms`}}function So({count:e=6}){return jsxs(Fragment,{children:[jsx("style",{children:ji}),jsx("div",{className:"evt-skel-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",width:"100%"},children:Array.from({length:e}).map((t,r)=>jsx(Ld,{index:r},r))})]})}function Ld({index:e}){let t=e*120,r={...Gi,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 Rd(){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:{...In(t*50),height:28,width:e,borderRadius:6}},t))}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[jsx("div",{style:{...In(0),height:36,width:120,borderRadius:10}}),jsx("div",{style:{...In(50),height:36,width:36,borderRadius:10}}),jsx("div",{style:{...In(100),height:36,width:80,borderRadius:10}})]})]})}function gx({count:e=24}){return jsxs("div",{style:{minHeight:"100vh",position:"relative",width:"100%",maxWidth:1680,margin:"0 auto"},children:[jsx("style",{children:ji}),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(Rd,{})}),jsx("div",{style:{padding:"12px 8px 80px"},children:jsx(So,{count:e})})]})}var qi=3,Wd={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)"}},Ud={border:"hsl(var(--heroui-primary) / 0.4)",shadow:"0 2px 18px hsl(var(--heroui-primary) / 0.45)"},Po={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},Zi={bg:"hsl(var(--heroui-secondary) / 0.14)",text:"hsl(var(--heroui-secondary))",shadow:"hsl(var(--heroui-secondary) / 0.18)"},$d={bg:"rgba(239, 68, 68, 0.14)",text:"rgb(239, 68, 68)",shadow:"rgba(239, 68, 68, 0.18)"},$r=[{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 Yi(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 Kd(e){let t=e.outcomes?.map(s=>s.label?.toLowerCase().trim()??"")??[];if(t.some(s=>s==="up")&&t.some(s=>s==="down"))return [Po,$d];if(t.some(s=>s==="yes")&&t.some(s=>s==="no"))return [Po,Zi];let r=t[0]??"",n=t[1]??"",o=Yi(r)%$r.length,i=Yi(n)%$r.length;return i===o&&(i=(i+1)%$r.length),[$r[o],$r[i]]}function Vd(e){let t=e.outcomes?.[0];return t?t.best_ask??t.price??null:null}function es(e){let t=Vd(e);return t!=null?parseFloat((t*100).toFixed(2)):0}function ts(e){return e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function Qi(e){let t=e.outcomes?.[0],r=t?.best_ask??t?.price??0;return parseFloat((r*100).toFixed(2)).toString()}function Xi(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 jd(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 Gd=`
6
+ `,Xi={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 An(e){return {...Xi,animationDelay:`${e}ms`}}function No({count:e=6}){return jsxs(Fragment,{children:[jsx("style",{children:Qi}),jsx("div",{className:"evt-skel-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",width:"100%"},children:Array.from({length:e}).map((t,r)=>jsx(Id,{index:r},r))})]})}function Id({index:e}){let t=e*120,r={...Xi,animationDelay:`${t}ms`},o=e%3===0?"85%":e%3===1?"70%":"60%";return jsx("div",{style:{padding:8},children:jsxs("div",{className:"evt-skel-card",style:{display:"flex",flexDirection:"column",minHeight:248,borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 14px 8px"},children:[jsx("div",{style:{...r,width:36,height:36,borderRadius:10,flexShrink:0}}),jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6},children:[jsx("div",{style:{...r,height:12,width:o}}),jsx("div",{style:{...r,height:10,width:"40%"}})]})]}),jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,padding:"4px 14px 14px",flex:1},children:[0,1,2].map(n=>jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[jsx("div",{style:{...r,height:11,width:n===0?"55%":n===1?"45%":"35%"}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsx("div",{style:{...r,height:11,width:32}}),jsx("div",{style:{...r,height:28,width:80,borderRadius:8}})]})]},n))}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.15)",padding:"8px 14px"},children:[jsx("div",{style:{...r,height:10,width:56}}),jsx("div",{style:{...r,height:10,width:72}})]})]})})}function Od(){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:{...An(t*50),height:28,width:e,borderRadius:6}},t))}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[jsx("div",{style:{...An(0),height:36,width:120,borderRadius:10}}),jsx("div",{style:{...An(50),height:36,width:36,borderRadius:10}}),jsx("div",{style:{...An(100),height:36,width:80,borderRadius:10}})]})]})}function vx({count:e=24}){return jsxs("div",{style:{minHeight:"100vh",position:"relative",width:"100%",maxWidth:1680,margin:"0 auto"},children:[jsx("style",{children:Qi}),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(Od,{})}),jsx("div",{style:{padding:"12px 8px 80px"},children:jsx(No,{count:e})})]})}var Ji=3,Kd={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)"}},Vd={border:"hsl(var(--heroui-primary) / 0.4)",shadow:"0 2px 18px hsl(var(--heroui-primary) / 0.45)"},Mo={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},ns={bg:"hsl(var(--heroui-secondary) / 0.14)",text:"hsl(var(--heroui-secondary))",shadow:"hsl(var(--heroui-secondary) / 0.18)"},jd={bg:"rgba(239, 68, 68, 0.14)",text:"rgb(239, 68, 68)",shadow:"rgba(239, 68, 68, 0.18)"},qr=[{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 Zi(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 qd(e){let t=e.outcomes?.map(s=>s.label?.toLowerCase().trim()??"")??[];if(t.some(s=>s==="up")&&t.some(s=>s==="down"))return [Mo,jd];if(t.some(s=>s==="yes")&&t.some(s=>s==="no"))return [Mo,ns];let r=t[0]??"",o=t[1]??"",n=Zi(r)%qr.length,i=Zi(o)%qr.length;return i===n&&(i=(i+1)%qr.length),[qr[n],qr[i]]}function Gd(e){let t=e.outcomes?.[0];return t?t.best_ask??t.price??null:null}function os(e){let t=Gd(e);return t!=null?parseFloat((t*100).toFixed(2)):0}function is(e){return e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function es(e){let t=e.outcomes?.[0],r=t?.best_ask??t?.price??0;return parseFloat((r*100).toFixed(2)).toString()}function ts(e){let t=e.outcomes?.[1];if(t){let n=t.best_ask??t.price??0;return parseFloat((n*100).toFixed(2)).toString()}let r=e.outcomes?.[0],o=r?.best_ask??r?.price??0;return parseFloat(((1-o)*100).toFixed(2)).toString()}function Yd(e){let t=new Date(e).getTime()-Date.now();if(t<=0)return null;let r=Math.floor(t/864e5),o=Math.floor(t%864e5/36e5),n=Math.floor(t%36e5/6e4),i=[];return r>0&&i.push(`${r}d`),o>0&&i.push(`${o}h`),i.push(`${n}m`),i.join(" ")}var Qd=`
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 rs({event:e,href:t,LinkComponent:r,onSelect:n,onSelectOutcome:o,onHover:i}){let[s,a]=useState(null),l=e.markets??[],u=useMemo(()=>l.length>2?[...l].sort((h,N)=>(N.outcomes?.[0]?.price??0)-(h.outcomes?.[0]?.price??0)):l,[l]).filter(h=>h.status==="open"),m=u.length===1,p=u.slice(0,qi),d=u.length-qi,f=useMemo(()=>formatAmountInUsd(e.volume??0),[e.volume]),v=s?u.find(h=>h.slug===s)??null:null,g=!!v||m,x=()=>{g||n?.(e);},b=h=>{h.stopPropagation(),v&&(h.preventDefault(),a(null));},P=h=>{h.stopPropagation(),t||(h.preventDefault(),n?.(e));},S=m?jsx(iu,{event:e,formattedVolume:f,href:t,LinkComponent:r,onSelect:n}):v?jsx(au,{onCollapse:()=>a(null)}):jsx(tu,{moreCount:d,formattedVolume:f,source:e.source,href:t,LinkComponent:r,onShowMore:P});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:h=>{let N=h.currentTarget,w=Wd[e.source]??Ud;N.style.borderColor=w.border,N.style.boxShadow=w.shadow,i?.(e);},onMouseLeave:h=>{let N=h.currentTarget;N.style.borderColor="rgba(39,39,42,0.6)",N.style.boxShadow="none";},onClick:x,children:[jsx("style",{children:Gd}),jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,padding:"14px 14px 12px",gap:8},children:[jsx(qd,{event:e,href:t,LinkComponent:r,onClick:b,isExpanded:g}),jsx("div",{style:{display:"flex",flexDirection:"column",flex:1},children:m?jsx(ou,{market:u[0],event:e,onSelectOutcome:o}):v?jsx(su,{market:v,event:e,onCollapse:()=>a(null),onSelectOutcome:o}):jsx(eu,{displayedMarkets:p,onMarketClick:h=>a(h.slug)})})]}),jsx(ru,{children:S})]})}function qd({event:e,href:t,LinkComponent:r,onClick:n,isExpanded:o}){let i=e.start_at?jd(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(Qd,{event:e})]})}function Yd(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 Qd({event:e}){let t=useMemo(()=>Yd(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(Xd,{},n);case "crypto-short":return jsx(Jd,{label:r.label,color:r.color},n);case "closed":return jsx(Zd,{},n)}})})}function Xd(){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 Jd({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 Zd(){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 eu({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=es(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:ts(n)}),jsx(nu,{})]})]},r.id??`${r.source}-${r.slug}`)})}):null}function tu({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(os,{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(is,{source:r})]})]})}function ru({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 Ji({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 ns({market:e,event:t,onSelectOutcome:r,dynamicColors:n=false,labelFormat:o="action"}){let{t:i}=useTranslation(),[s,a]=n?Kd(e):[Po,Zi],l=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",c=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",u=o==="label"&&l===c?"action":o,m=u==="label"?`${e.outcomes?.[0]?.label??"Yes"} ${Qi(e)}\xA2`:i("predict.market.action.yes",{price:Qi(e)}),p=u==="label"?`${e.outcomes?.[1]?.label??"No"} ${Xi(e)}\xA2`:i("predict.market.action.no",{price:Xi(e)});return jsxs("div",{className:"flex gap-2",children:[jsx(Ji,{bgColor:s.bg,textColor:s.text,shadowColor:s.shadow,onClick:d=>{d.stopPropagation(),r?.(t,e,"yes");},children:m}),jsx(Ji,{bgColor:a.bg,textColor:a.text,shadowColor:a.shadow,onClick:d=>{d.stopPropagation(),r?.(t,e,"no");},children:p})]})}function nu(){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 ou({market:e,event:t,onSelectOutcome:r}){return jsx("div",{style:{flex:1},children:jsx(ns,{market:e,event:t,onSelectOutcome:r,dynamicColors:true,labelFormat:"label"})})}function iu({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(os,{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(is,{source:e.source})]})]})}function su({market:e,event:t,onCollapse:r,onSelectOutcome:n}){let o=es(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:ts(o)}),jsx(ChevronUpIcon,{className:"h-4 w-4 text-neutral-400"})]})]}),jsx("div",{style:{marginTop:12},children:jsx(ns,{market:e,event:t,onSelectOutcome:n,labelFormat:"action"})})]})}function au({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(lu,{className:"h-3 w-3"}),t("predict.event.back")]}),jsx("div",{})]})}function os({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 lu({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 is({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 pu=8;function as({events:e,hasMore:t=false,isFetchingMore:r=false,onFetchMore:n,onSelect:o,onSelectOutcome:i,getEventHref:s,LinkComponent:a,onHover:l}){let{t:c}=useTranslation(),u=useRef(null);useEffect(()=>{let d=u.current;if(!d)return;let f=new IntersectionObserver(v=>{v[0]?.isIntersecting&&t&&!r&&n?.();},{rootMargin:"300px"});return f.observe(d),()=>f.disconnect()},[t,r,n]);let m=useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]),p=!t&&e.length>0;return jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[jsx("style",{children:`
30
+ `;function ss({event:e,href:t,LinkComponent:r,onSelect:o,onSelectOutcome:n,onHover:i}){let[s,a]=useState(null),l=e.markets??[],u=useMemo(()=>l.length>2?[...l].sort((h,y)=>(y.outcomes?.[0]?.price??0)-(h.outcomes?.[0]?.price??0)):l,[l]).filter(h=>h.status==="open"),p=u.length===1,m=u.slice(0,Ji),c=u.length-Ji,f=useMemo(()=>formatAmountInUsd(e.volume??0),[e.volume]),g=s?u.find(h=>h.slug===s)??null:null,v=!!g||p,x=()=>{v||o?.(e);},b=h=>{h.stopPropagation(),g&&(h.preventDefault(),a(null));},w=h=>{h.stopPropagation(),t||(h.preventDefault(),o?.(e));},P=p?jsx(lu,{event:e,formattedVolume:f,href:t,LinkComponent:r,onSelect:o}):g?jsx(du,{onCollapse:()=>a(null)}):jsx(ou,{moreCount:c,formattedVolume:f,source:e.source,href:t,LinkComponent:r,onShowMore:w});return jsxs("div",{className:"group evt-card",style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",cursor:v?void 0:"pointer"},onMouseEnter:h=>{let y=h.currentTarget,S=Kd[e.source]??Vd;y.style.borderColor=S.border,y.style.boxShadow=S.shadow,i?.(e);},onMouseLeave:h=>{let y=h.currentTarget;y.style.borderColor="rgba(39,39,42,0.6)",y.style.boxShadow="none";},onClick:x,children:[jsx("style",{children:Qd}),jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,padding:"14px 14px 12px",gap:8},children:[jsx(Xd,{event:e,href:t,LinkComponent:r,onClick:b,isExpanded:v}),jsx("div",{style:{display:"flex",flexDirection:"column",flex:1},children:p?jsx(au,{market:u[0],event:e,onSelectOutcome:n}):g?jsx(cu,{market:g,event:e,onCollapse:()=>a(null),onSelectOutcome:n}):jsx(nu,{displayedMarkets:m,onMarketClick:h=>a(h.slug)})})]}),jsx(iu,{children:P})]})}function Xd({event:e,href:t,LinkComponent:r,onClick:o,isExpanded:n}){let i=e.start_at?Yd(e.start_at):null;return jsxs(Linkable,{href:t,LinkComponent:r,as:"button",className:"group/header flex items-center gap-x-2 lg:gap-x-4 w-full text-left cursor-pointer",onClick:o,children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",className:"h-8 w-8 flex-shrink-0 transition-transform duration-300 group-hover/header:scale-110 lg:h-12 lg:w-12",classNames:{base:"bg-transparent"}}),jsxs("div",{className:"flex min-w-0 flex-1 flex-col justify-center gap-y-0.5",children:[jsx("p",{className:cn$1("min-w-0 text-sm font-semibold leading-snug text-slate-200 line-clamp-2 lg:text-base",n&&"group-hover/header:text-neutral-400"),children:e.title}),i&&jsxs("span",{className:"text-[10px] leading-4 text-neutral-500",children:["Live in ",i]})]}),jsx(Zd,{event:e})]})}function Jd(e){let t=[];if(e.status==="closed")return t.push({kind:"closed"}),t.slice(0,2);let r=e.tags?.some(n=>n.label?.toLowerCase()==="crypto"),o=e.tags?.some(n=>n.label?.toLowerCase()==="live");if(r&&e.end_at){let n=new Date(e.end_at).getTime()-Date.now(),i=300*1e3,s=900*1e3;if(n>0&&n<=s){let a=n<=i?"#ef4444":"#f59e0b";t.push({kind:"crypto-short",label:n<=i?"5m":"15m",color:a});}}return o&&t.push({kind:"live"}),t.slice(0,2)}function Zd({event:e}){let t=useMemo(()=>Jd(e),[e]);return t.length===0?null:jsx("div",{className:"flex flex-shrink-0 flex-col items-end gap-1",children:t.map((r,o)=>{switch(r.kind){case "live":return jsx(eu,{},o);case "crypto-short":return jsx(tu,{label:r.label,color:r.color},o);case "closed":return jsx(ru,{},o)}})})}function eu(){let{t:e}=useTranslation();return jsxs("span",{className:"badge-shine relative inline-flex items-center gap-1 overflow-hidden rounded-md bg-[rgb(240,68,56)]/10 px-1.5 py-0.5 text-xs font-semibold text-[rgb(240,68,56)]",children:[jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-current"}),e("predict.event.status.live")]})}function tu({label:e,color:t}){return jsxs("span",{className:"badge-shine relative inline-flex items-center gap-1 overflow-hidden rounded-md px-1.5 py-0.5 text-xs font-semibold",style:{backgroundColor:`${t}26`,color:t},children:[jsx(TimerIcon,{className:"size-3 shrink-0"}),e]})}function ru(){let{t:e}=useTranslation();return jsx("span",{className:"inline-flex items-center rounded-md bg-neutral-800/80 px-1.5 py-0.5 text-xs font-semibold text-neutral-400",children:e("predict.event.status.closed")})}function nu({displayedMarkets:e,onMarketClick:t}){return e.length>0?jsx("div",{className:"flex w-full flex-1 flex-col gap-y-0.5 lg:gap-y-2",children:e.map(r=>{let o=os(r);return jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between gap-x-2 transition-opacity hover:cursor-pointer hover:opacity-80",onClick:n=>{n.stopPropagation(),t(r);},children:[jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 line-clamp-1 lg:text-sm",children:r.outcomes?.[0]?.label??r.question}),jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:is(o)}),jsx(su,{})]})]},r.id??`${r.source}-${r.slug}`)})}):null}function ou({moreCount:e,formattedVolume:t,source:r,href:o,LinkComponent:n,onShowMore:i}){let{t:s}=useTranslation();return jsxs(Fragment,{children:[e>0?jsxs(Linkable,{href:o,LinkComponent:n,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-zinc-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:i,children:[s("predict.event.showMore"),jsx(ls,{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(cs,{source:r})]})]})}function iu({children:e}){return jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.15)",padding:"8px 14px",marginTop:"auto"},children:e})}function rs({bgColor:e,textColor:t,shadowColor:r,onClick:o,children:n}){return jsx("button",{type:"button",className:"flex h-12 flex-1 w-full items-center justify-center gap-x-1 overflow-hidden rounded-lg p-3 text-base font-normal hover:cursor-pointer will-change-transform [-webkit-tap-highlight-color:transparent]",style:{backgroundColor:e,color:t,"--shadow-color":r,"--shadow-offset":"4px",boxShadow:"inset 0 -1px 0 rgba(255,255,255,0.08), 0 var(--shadow-offset, 4px) 0 var(--shadow-color, rgba(0,0,0,0.22))",transition:"transform .12s, box-shadow .12s, opacity .14s"},onMouseEnter:a=>{let l=a.currentTarget;l.style.setProperty("--shadow-offset","2px"),l.style.transform="translateY(2px)";},onMouseLeave:a=>{let l=a.currentTarget;l.style.setProperty("--shadow-offset","4px"),l.style.transform="translateY(0px)";},onClick:o,children:n})}function as({market:e,event:t,onSelectOutcome:r,dynamicColors:o=false,labelFormat:n="action"}){let{t:i}=useTranslation(),[s,a]=o?qd(e):[Mo,ns],l=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",d=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",u=n==="label"&&l===d?"action":n,p=u==="label"?`${e.outcomes?.[0]?.label??"Yes"} ${es(e)}\xA2`:i("predict.market.action.yes",{price:es(e)}),m=u==="label"?`${e.outcomes?.[1]?.label??"No"} ${ts(e)}\xA2`:i("predict.market.action.no",{price:ts(e)});return jsxs("div",{className:"flex gap-2",children:[jsx(rs,{bgColor:s.bg,textColor:s.text,shadowColor:s.shadow,onClick:c=>{c.stopPropagation(),r?.(t,e,"yes");},children:p}),jsx(rs,{bgColor:a.bg,textColor:a.text,shadowColor:a.shadow,onClick:c=>{c.stopPropagation(),r?.(t,e,"no");},children:m})]})}function su(){let{t:e}=useTranslation();return jsxs("span",{className:"inline-flex h-7 w-[85px] items-center justify-center gap-x-3 rounded-lg p-1.5 text-xs font-semibold flex-shrink-0 bg-gradient-to-r from-primary/15 to-secondary/15 lg:h-9 lg:w-24 lg:gap-x-4 lg:p-2 lg:text-sm",children:[jsx("span",{className:"text-primary",children:e("predict.market.yes")}),jsx("span",{className:"text-neutral-400",children:"/"}),jsx("span",{className:"text-secondary",children:e("predict.market.no")})]})}function au({market:e,event:t,onSelectOutcome:r}){return jsx("div",{style:{flex:1},children:jsx(as,{market:e,event:t,onSelectOutcome:r,dynamicColors:true,labelFormat:"label"})})}function lu({event:e,formattedVolume:t,href:r,LinkComponent:o,onSelect:n}){let{t:i}=useTranslation();return jsxs(Fragment,{children:[jsxs(Linkable,{href:r,LinkComponent:o,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-zinc-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:a=>{a.stopPropagation(),r||(a.preventDefault(),n?.(e));},children:[i("predict.event.viewEvent"),jsx(ls,{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(cs,{source:e.source})]})]})}function cu({market:e,event:t,onCollapse:r,onSelectOutcome:o}){let n=os(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:is(n)}),jsx(ChevronUpIcon,{className:"h-4 w-4 text-neutral-400"})]})]}),jsx("div",{style:{marginTop:12},children:jsx(as,{market:e,event:t,onSelectOutcome:o,labelFormat:"action"})})]})}function du({onCollapse:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsxs("button",{type:"button",className:"flex items-center gap-x-1 text-[10px] font-normal transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",style:{color:"#71717a"},onClick:r=>{r.stopPropagation(),e();},children:[jsx(uu,{className:"h-3 w-3"}),t("predict.event.back")]}),jsx("div",{})]})}function ls({className:e}){return jsx("svg",{viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:jsx("path",{d:"M4.5 2.5L8 6l-3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function uu({className:e}){return jsx("svg",{viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:jsx("path",{d:"M7.5 2.5L4 6l3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function cs({source:e}){return jsxs("span",{className:"inline-flex items-center gap-x-1 text-neutral-400",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsx("span",{className:"text-neutral-600",children:"\xB7"}),e==="polymarket"?jsx(PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsx(KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}var gu=8;function us({events:e,hasMore:t=false,isFetchingMore:r=false,onFetchMore:o,onSelect:n,onSelectOutcome:i,getEventHref:s,LinkComponent:a,onHover:l}){let{t:d}=useTranslation(),u=useRef(null);useEffect(()=>{let c=u.current;if(!c)return;let f=new IntersectionObserver(g=>{g[0]?.isIntersecting&&t&&!r&&o?.();},{rootMargin:"300px"});return f.observe(c),()=>f.disconnect()},[t,r,o]);let p=useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]),m=!t&&e.length>0;return jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[jsx("style",{children:`
31
31
  @keyframes eventCardEnter{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}
32
32
  @keyframes evt-load-spin{to{transform:rotate(360deg)}}
33
33
  @media(max-width:767px){.evt-card-grid{grid-template-columns:1fr!important}}
34
34
  @media(min-width:768px) and (max-width:1023px){.evt-card-grid{grid-template-columns:repeat(2,1fr)!important}}
35
35
  @media(min-width:1024px) and (max-width:1279px){.evt-card-grid{grid-template-columns:repeat(3,1fr)!important}}
36
- `}),jsx("div",{className:"evt-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)"},children:e.map((d,f)=>d==null?null:jsx("div",{style:{padding:pu,animation:`eventCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${f%4*35}ms both`},children:jsx(rs,{event:d,href:s?.(d),LinkComponent:a,onSelect:o,onSelectOutcome:i,onHover:l})},`${d.source}-${d.slug}`))}),jsx("div",{ref:u,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")]})}),p&&jsx(mu,{onScrollToTop:m})]})}function mu({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 cs({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:u,onSelect:m,onSelectOutcome:p,getEventHref:d,LinkComponent:f,onHover:v}){let{data:g,hasMore:x,fetchMore:b,isFetching:P,isFetchingMore:S}=Vi({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:u});return P?jsx(So,{count:24}):jsx(as,{events:g,hasMore:x,isFetchingMore:S,onFetchMore:b,onSelect:m,onSelectOutcome:p,getEventHref:d,LinkComponent:f,onHover:v})}function $x({onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:n,onHover:o,bgImageSrc:i,onInsufficientBalance:s,enableKalshi:a=true}){let[l,c]=useState({categorySlug:null,tagSlug:null}),[u,m]=useState(()=>a?Ur:{...Ur,source:"polymarket"}),{isOpen:p,onOpen:d,onClose:f}=useDisclosure(),{onOpen:v}=useAsyncModal(Wr),g=useCallback((E,T,_)=>{t?.(E,T,_),v({params:{event:E,market:T,initialOutcome:_,onInsufficientBalance:s}});},[t,v,s]),x=useCallback(E=>{c(E);},[]),b=useCallback(E=>{m(T=>({...T,sortPreset:E}));},[]),P=useCallback(E=>{m(T=>({...T,sortAsc:E}));},[]),S=useCallback(E=>{m(E);},[]),h=useMemo(()=>Wi[u.sortPreset].sort_by,[u.sortPreset]),N=useMemo(()=>ko(u,a),[u,a]),w=useMemo(()=>jsx(Ui,{sortPreset:u.sortPreset,onSortChange:b,sortAsc:u.sortAsc,onSortAscChange:P,onFilterPress:d,filterCount:N}),[u.sortPreset,u.sortAsc,N,b,P,d]);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(bi,{onSelect:x,trailing:w})}),jsxs("div",{style:{padding:"12px 8px 80px"},children:[jsx(Ai,{isOpen:p,onClose:f,value:u,onChange:S,enableKalshi:a}),jsx(cs,{tagSlugSelection:l,sort_by:h,sort_asc:u.sortAsc,source:u.source,timeRemaining:u.timeRemaining,minVolume:u.minVolume,minLiquidity:u.minLiquidity,onSelect:e,onSelectOutcome:g,getEventHref:r,LinkComponent:n,onHover:o})]}),jsx(Tn,{})]})}function ms(e){return formatAmountInUsd(e)}var xu=[{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:ms,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:ms,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 qx({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((c,f)=>c==null?null:jsx("div",{style:{padding:gu,animation:`eventCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${f%4*35}ms both`},children:jsx(ss,{event:c,href:s?.(c),LinkComponent:a,onSelect:n,onSelectOutcome:i,onHover:l})},`${c.source}-${c.slug}`))}),jsx("div",{ref:u,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"})}),d("predict.events.loadMore")]})}),m&&jsx(hu,{onScrollToTop:p})]})}function hu({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 ms({tagSlugSelection:e,limit:t=24,status:r,sort_by:o,sort_asc:n,source:i,with_markets:s,timeRemaining:a,minVolume:l,minLiquidity:d,markets_limit:u,onSelect:p,onSelectOutcome:m,getEventHref:c,LinkComponent:f,onHover:g}){let{data:v,hasMore:x,fetchMore:b,isFetching:w,isFetchingMore:P}=Yi({tagSlugSelection:e,limit:t,status:r,sort_by:o,sort_asc:n,source:i,with_markets:s,timeRemaining:a,minVolume:l,minLiquidity:d,markets_limit:u});return w?jsx(No,{count:24}):jsx(us,{events:v,hasMore:x,isFetchingMore:P,onFetchMore:b,onSelect:p,onSelectOutcome:m,getEventHref:c,LinkComponent:f,onHover:g})}function Vx({onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:o,onHover:n,bgImageSrc:i,onInsufficientBalance:s,enableKalshi:a=true}){let[l,d]=useState({categorySlug:null,tagSlug:null}),[u,p]=useState(()=>a?jr:{...jr,source:"polymarket"}),{isOpen:m,onOpen:c,onClose:f}=useDisclosure(),{onOpen:g}=useAsyncModal(Vr),v=useCallback((N,A,D)=>{t?.(N,A,D),g({params:{event:N,market:A,initialOutcome:D,onInsufficientBalance:s}});},[t,g,s]),x=useCallback(N=>{d(N);},[]),b=useCallback(N=>{p(A=>({...A,sortPreset:N}));},[]),w=useCallback(N=>{p(A=>({...A,sortAsc:N}));},[]),P=useCallback(N=>{p(N);},[]),h=useMemo(()=>Vi[u.sortPreset].sort_by,[u.sortPreset]),y=useMemo(()=>Po(u,a),[u,a]),S=useMemo(()=>jsx(ji,{sortPreset:u.sortPreset,onSortChange:b,sortAsc:u.sortAsc,onSortAscChange:w,onFilterPress:c,filterCount:y}),[u.sortPreset,u.sortAsc,y,b,w,c]);return jsxs("div",{style:{minHeight:"100vh",position:"relative",width:"100%",maxWidth:1680,margin:"0 auto"},children:[jsx("div",{style:{position:"sticky",top:0,zIndex:40,background:"rgba(10,10,11,0.8)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:jsx(wi,{onSelect:x,trailing:S})}),jsxs("div",{style:{padding:"12px 8px 80px"},children:[jsx(zi,{isOpen:m,onClose:f,value:u,onChange:P,enableKalshi:a}),jsx(ms,{tagSlugSelection:l,sort_by:h,sort_asc:u.sortAsc,source:u.source,timeRemaining:u.timeRemaining,minVolume:u.minVolume,minLiquidity:u.minLiquidity,onSelect:e,onSelectOutcome:v,getEventHref:r,LinkComponent:o,onHover:n})]}),jsx(_n,{})]})}function vs(e){return formatAmountInUsd(e)}var ku=[{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:vs,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:vs,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 Qx({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:xu.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 xs({event:e,market:t,position:r,onSuccess:n,onCancel:o}){let{t:i}=useTranslation(),{mutateAsync:s}=useRedeemPosition(),{evmAddress:a}=sr(),l=useWallets(),[c,u]=useState("idle"),[m,p]=useState(null),d=t.provider_meta?.["polymarket.conditionId"],f=t.provider_meta?.["polymarket.negRisk"]??false,v=a??"",g=useMemo(()=>l.find(D=>D.chainNamespace===ChainNamespace.EVM&&D.isConnected),[l]),x=vs(r.side,t.outcomes),P=t.outcomes?.[x]?.label??r.side,S=t.result!=null?vs(t.result,t.outcomes):-1,N=(S>=0?t.outcomes?.[S]:void 0)?.label??t.result??"",w=t.result!=null?x===S:true,E=useMemo(()=>w?r.size:0,[w,r.size]),T=useCallback(async()=>{if(!(!d||!v||!g)){u("pending"),p(null);try{let D=await g.getEip1193Provider();if(!D)throw new Error("EIP-1193 provider unavailable");await s({wallet_address:v,condition_id:d,neg_risk:f,signMessage:async K=>await D.request({method:"personal_sign",params:[K,v]})}),u("success"),n?.();}catch(D){u("error"),p(D instanceof Error?D.message:i("predict.redeem.error"));}}},[d,v,f,g,s,n,i]),_=useAuthCallback(T),G=c==="idle"&&!!d&&!!v&&!!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(On,{label:i("predict.positions.side"),value:P,valueClassName:w?"text-green-400":"text-red-400"}),t.result!=null&&jsx(On,{label:i("predict.redeem.result"),value:N,valueClassName:"text-green-400"}),jsx(On,{label:i("predict.positions.size"),value:r.size.toFixed(2)}),jsx(On,{label:i("predict.redeem.expectedPayout"),value:`$${E.toFixed(2)}`,valueClassName:E>0?"text-green-400":"text-zinc-400"})]}),!w&&E===0&&jsx("p",{className:"text-sm text-zinc-500",children:i("predict.redeem.noWinnings")}),c==="error"&&m&&jsx("p",{className:"text-sm text-red-400",children:m}),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:!G,isLoading:c==="pending",onPress:_,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 On({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 vs(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 _u="predict-redeem";function ys({id:e=_u}){return jsx(AsyncModal,{id:e,children:t=>jsx(Iu,{...t})})}function Iu({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(xs,{event:e.event,market:e.market,position:e.position,onSuccess:()=>{setTimeout(()=>r(false),1500);},onCancel:()=>r(false)})]})})}):null}function Ns({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,u=c==="polymarket",m=i.find(C=>C.chainNamespace===ChainNamespace.SOLANA&&C.isConnected),p=i.find(C=>C.chainNamespace===ChainNamespace.EVM&&C.isConnected&&"switchChain"in C),d=o==="authenticated",f=m?.address,v=p?.address,[g,x]=useState(t),[b,P]=useState("market"),[S,h]=useState(NaN),[N,w]=useState(NaN),[E,T]=useState(false),[_,G]=useState(false),[D,K]=useState(null),[W,oe]=useState(null),[le,J]=useState(false),[y,k]=useState(false),[H,V]=useState("1h"),[Q,se]=useState(30),[ve,je]=useState("minutes"),Ce=useMemo(()=>{if(c!=="polymarket")return;let C=e.provider_meta?.["polymarket.clobTokenIds"];return C?(typeof C=="string"?JSON.parse(C):C)[g==="yes"?0:1]:void 0},[c,e.provider_meta,g]),{data:Be,isLoading:pt}=useTickSize(Ce),mt=Be?.minimum_tick_size?String(Be.minimum_tick_size):"0.01",{data:wt,isLoading:Ge}=useFeeRate(Ce),He=String(wt?.base_fee??0),{data:vt}=useRebateConfig(),A=vt?.builder_enabled&&vt.builder_code?vt.builder_code:void 0,xe=false,qe=null,et,$e,ke;try{let C=sr();xe=C.kalshiKycVerified,qe=C.kalshiKycUrl,et=C.polymarketSafeAddress,$e=C.polymarketWalletKind,ke=C.polymarketWalletAddress;}catch{}let O=useCallback(async()=>{if(!p||!a)return null;let C=await p.getEip1193Provider();if(!C)return null;let be=$e==="deposit"&&!!ke,ze=!be&&!!et,Qe={address:p.address,signatureType:be?3:ze?2:0,signTypedData:async(We,Xe,gt,De)=>{let Re=[];"name"in We&&Re.push({name:"name",type:"string"}),"version"in We&&Re.push({name:"version",type:"string"}),"chainId"in We&&Re.push({name:"chainId",type:"uint256"}),"verifyingContract"in We&&Re.push({name:"verifyingContract",type:"address"}),"salt"in We&&Re.push({name:"salt",type:"bytes32"});let At={EIP712Domain:Re,...Xe};return await C.request({method:"eth_signTypedData_v4",params:[p.address,JSON.stringify({domain:We,types:At,primaryType:gt,message:De})]})}};return a.credentials??await a.authenticate(Qe)},[et,$e,ke,p,a]),{data:Me}=useRealtimeOrderbook({slug:e.slug,source:c,outcome:g},{enabled:e.status==="open"}),Pe=useMemo(()=>{let C=pickBestBid(Me,g);if(C!=null&&C>0)return C;let be=g==="yes"?0:1,ze=e.outcomes[be];return ze?.best_bid??ze?.price??.5},[Me,e.outcomes,g]),Ke=c==="kalshi"?f??"":v??"",{data:xr,isLoading:br}=usePositions({source:c,user:Ke},{enabled:!!Ke,refetchInterval:3e4}),oo=useCallback(async()=>{let C=await O();return C?await buildPolymarketL2Headers(C.address,{apiKey:C.apiKey,secret:C.secret,passphrase:C.passphrase,method:"GET",requestPath:"/data/orders",body:""}):{}},[O]),{data:Jt,isLoading:io}=useAvailableShares({source:c,user:Ke,market:e.slug,side:g},c==="polymarket"?{getHeaders:oo}:void 0,{enabled:!!Ke&&!!e.slug,refetchOnMount:"always"}),Ir=Jt?.total_shares??0,_t=Jt?.active_order_shares??0,ft=Jt?.available_shares??0,Ve=useMemo(()=>c==="polymarket"?getPolymarketSharesPrecision(mt):Jt?.precision??0,[c,mt,Jt?.precision]),Or=io||br,so=e.provider_meta?.["dflow.yesMint"]??"",ao=e.provider_meta?.["dflow.noMint"]??"",It=SOLANA_TOKENS.stablecoins.USDC.address,Ot=e.provider_meta?.["dflow.collateralMint"]||"",lo=g==="yes"?so:ao,Dr=useMemo(()=>xr?xr.positions.find(C=>C.side?.toLowerCase()===g&&C.market?.slug===e.slug)??null:null,[xr,e.slug,g])?.market?.provider_meta,cn=Dr?.["dflow.outcomeMint"]||lo,Zt=Dr?.["dflow.collateralMint"]||Ot,er=cn,tr=Zt||It,Dt=useMemo(()=>isNaN(S)||S<=0?"0":String(Math.round(S*1e6)),[S]),Ar=c==="kalshi"&&!!er&&!!tr&&!!f&&Dt!=="0",{refetch:dn}=useDFlowQuote({inputMint:er,outputMint:tr,amount:Dt,userPublicKey:f??"",slippageBps:100},{enabled:Ar}),Fr=useMemo(()=>isNaN(S)||S<=0?0:S,[S]),tt=useMemo(()=>walkOrderbook({orderbook:Me,outcome:g,side:"sell",sharesNeeded:Fr,slippageBps:r}),[Me,g,Fr,r]),yr=useMemo(()=>tt.status==="ok"&&tt.worstPrice!=null&&tt.worstPrice>0?tt.worstPrice:Pe,[tt,Pe]),un=useMemo(()=>{if(isNaN(S)||S<=0)return 0;let C=b==="limit"&&u&&!isNaN(N)?N:Pe;return S*C},[S,b,u,N,Pe]),pn=useCallback(C=>{x(C),w(NaN),h(NaN),G(false);},[]),co=useCallback(C=>{P(C);},[]);useEffect(()=>{b==="limit"&&w(Math.round(Pe*100)/100);},[b,g]);let R=useCallback(C=>{if(G(false),isNaN(C)){h(NaN);return}h(ye(Math.max(0,C),Ve));},[Ve]),Oe=useCallback(()=>{G(true),h(ye(ft,Ve));},[ft,Ve]),Ye=useCallback(C=>{if(isNaN(C)){w(NaN);return}let be=Math.max(.01,Math.min(.99,C));w(Math.round(be*100)/100);},[]),rt=useCallback(()=>{h(NaN),w(NaN),P("market"),G(false),k(false),V("1h"),se(30),je("minutes");},[]),rr=useMemo(()=>{let C=[];return isNaN(S)||S<=0?C.push(n("predict.trade.minQuantity",{amount:kn})):S<kn&&C.push(n("predict.trade.minQuantity",{amount:kn})),e.status!=="open"&&C.push(n("predict.trade.marketNotActive")),!isNaN(S)&&S>0&&!_&&S>ft&&C.push(n("predict.trade.insufficientSharesDetail",{total:ye(Ir,Ve).toFixed(Ve),active:ye(_t,Ve).toFixed(Ve),available:ye(ft,Ve).toFixed(Ve)})),b==="limit"&&u&&(isNaN(N)||N<.01||N>.99)&&C.push(n("predict.trade.limitPriceRange")),b==="limit"&&u&&y&&H==="custom"&&(isNaN(Q)||Q<=0)&&C.push(n("predict.trade.expiration.invalidDate")),c==="polymarket"&&b==="market"&&!isNaN(S)&&S>0&&(tt.status==="insufficient_liquidity"?C.push(n("predict.trade.insufficientLiquidity",{available:ye(tt.totalAvailable,2)})):tt.status==="exceeds_slippage"&&C.push(n("predict.trade.priceImpactTooHigh",{impact:(tt.priceImpactBps/100).toFixed(2),slippage:(r/100).toFixed(2)}))),{isValid:C.length===0,errors:C}},[S,e.status,ft,Ir,_t,_,b,u,N,y,H,Q,Ve,c,tt,r,n]),{mutateAsync:Pt}=useDFlowSubmit(),{data:xt}=useOrder({id:D??"",source:c},{enabled:!!D}),bt=useCallback(async()=>{if(!W||!f||!m)return;let{cashAmount:C,collateral:be}=W;oe(null);try{let Qe=(await s.createDFlowQuote({inputMint:be,outputMint:It,amount:C,userPublicKey:f,slippageBps:100}))?.transaction;if(!Qe)return;let We=Uint8Array.from(atob(Qe),gt=>gt.charCodeAt(0)),Xe=await m.signTransaction(We);await Pt({signedTransaction:btoa(String.fromCharCode(...Xe)),orderContext:{user_public_key:f,input_mint:be,output_mint:It,amount:C,price:"1",side:"SELL",outcome:"",market_slug:"",slippage_bps:100}});}catch{}},[W,f,m,s,Pt,It]),nr=useCallback(()=>{l.invalidateQueries({queryKey:["predict","positions"]}),l.invalidateQueries({queryKey:["predict","orders"]}),l.invalidateQueries({queryKey:["predict","available-shares"]});},[l]);useEffect(()=>{if(!xt||!D)return;let{status:C}=xt;C==="closed"?(K(null),W?bt().finally(()=>{T(false),toast.success(n("predict.trade.submitSuccess")),ar(),nr(),rt();}):(T(false),toast.success(n("predict.trade.submitSuccess")),ar(),nr(),rt())):(C==="failed"||C==="expired")&&(T(false),K(null),oe(null),toast.error(n("predict.trade.submitError")));},[xt,D,W,bt,nr,rt,n]);let Br=useCallback(async()=>{if(!f||!m)return;if(!er||!tr){toast.error("Missing token mint addresses"),T(false);return}if(!xe){J(true),T(false);return}let ze=(await dn()).data,Qe=ze?.transaction;if(!Qe){toast.error(n("predict.trade.submitError")),T(false);return}if(Zt&&Zt!==It){let De=String(ze?.outAmount??"");De&&De!=="0"&&oe({cashAmount:De,collateral:Zt});}let We=Uint8Array.from(atob(Qe),De=>De.charCodeAt(0)),Xe=await m.signTransaction(We),gt=await Pt({signedTransaction:btoa(String.fromCharCode(...Xe)),orderContext:{user_public_key:f,input_mint:er,output_mint:tr,amount:Dt,price:String(Pe),side:"SELL",outcome:g==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});K(gt.signature);},[f,m,dn,Pt,er,tr,Dt,Pe,g,e.slug,Zt,It,n,xe]),or=useCallback(async()=>{if(!p||!a)return;let C=p.chain,be=C!==Chain.POLYGON;be&&await p.switchChain(Chain.POLYGON);try{let ze=await p.getEip1193Provider();if(!ze){toast.error(n("predict.trade.submitError")),T(!1);return}let Qe=$e==="deposit"&&!!ke,We=!Qe&&!!et,Xe=Qe?ke:et,gt={address:p.address,signatureType:Qe?3:We?2:0,signTypedData:async(Ft,gn,mo,fo)=>{let Sr=[];"name"in Ft&&Sr.push({name:"name",type:"string"}),"version"in Ft&&Sr.push({name:"version",type:"string"}),"chainId"in Ft&&Sr.push({name:"chainId",type:"uint256"}),"verifyingContract"in Ft&&Sr.push({name:"verifyingContract",type:"address"}),"salt"in Ft&&Sr.push({name:"salt",type:"bytes32"});let jl={EIP712Domain:Sr,...gn};return await ze.request({method:"eth_signTypedData_v4",params:[p.address,JSON.stringify({domain:Ft,types:jl,primaryType:mo,message:fo})]})}},De=await O();if(!De){toast.error(n("predict.trade.submitError")),T(!1);return}let Re=g==="yes"?0:1,At="",jt=e.provider_meta?.["polymarket.clobTokenIds"];jt&&(At=(typeof jt=="string"?JSON.parse(jt):jt)[Re]??"");let kr=e.provider_meta?.["polymarket.negRisk"]??!1,Gt=b==="limit"&&!isNaN(N)?N:yr,uo=Pn(Gt,mt),po={tokenId:At,price:uo,size:S,side:"SELL",orderType:b==="limit"?y?"GTD":"GTC":"FOK",tickSize:mt,negRisk:kr,...Xe&&{funderAddress:Xe},...A&&{builderCode:A},...b==="limit"&&y&&{expiration:wn(H,Q,ve)}},fn;if(Qe)fn=await buildSignedV2OrderPayload({signer:gt,depositWalletAddress:Xe,input:po,owner:De.apiKey});else {let Ft=buildCtfExchangeDomain(kr),gn=buildOrderMessage({...po,signerAddress:gt.address,signatureType:gt.signatureType,feeRateBps:He}),mo=await gt.signTypedData(Ft,CTF_ORDER_TYPES,"Order",gn),fo=buildSignedOrder(gn,mo,po.orderType);fn=buildClobPayload(fo,De.apiKey);}let Kl=JSON.stringify(fn),Vl=await buildPolymarketL2Headers(De.address,{apiKey:De.apiKey,secret:De.secret,passphrase:De.passphrase,method:"POST",requestPath:"/order",body:Kl});await s.createPolymarketOrder(fn,Vl),nr(),toast.success(n("predict.trade.submitSuccess")),ar(),rt(),T(!1);}finally{be&&C&&p.switchChain(C).catch(()=>{});}},[p,a,O,g,e.provider_meta,b,N,yr,S,s,nr,y,H,Q,ve,rt,n,mt,He,e.slug,et,$e,ke,A]),mn=useCallback(async()=>{if(!(!rr.isValid||!d)){T(true),K(null),J(false);try{c==="kalshi"?await Br():await or();}catch(C){let be=C instanceof Error?C.message:"",ze=c==="polymarket"&&be?Nn(be,n,"sell"):be||void 0;toast.error(ze||n("predict.trade.submitError")),T(false);}}},[rr.isValid,d,c,Br,or,n]);return {outcome:g,orderType:b,quantity:S,limitPrice:N,shares:Fr,estimatedReturn:un,pricePerShare:Pe,isMarketDataLoading:c==="polymarket"&&(Ge||pt),isSubmitting:E,validation:rr,supportsLimitOrder:u,kycRequired:le,kycUrl:qe,totalShares:Ir,activeOrderShares:_t,availableShares:ft,isAvailableLoading:Or,isSellAll:_,precision:Ve,expirationEnabled:y,expirationPreset:H,customDuration:Q,customDurationUnit:ve,setOutcome:pn,setOrderType:co,setQuantity:R,setLimitPrice:Ye,setSellAll:Oe,setExpirationEnabled:k,setExpirationPreset:V,setCustomDuration:se,setCustomDurationUnit:je,submit:mn}}var mp=["5m","1h","12h","24h","eod","custom"],fp={"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"},gp=["minutes","hours","days"],hp={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},vp={maximumFractionDigits:0};function Os({event:e,market:t,variant:r="bordered",outcome:n,orderType:o,quantity:i,limitPrice:s,estimatedReturn:a,isMarketDataLoading:l,isSubmitting:c,isValid:u,validationErrors:m,supportsLimitOrder:p,kycRequired:d,kycUrl:f,totalShares:v,activeOrderShares:g,availableShares:x,isAvailableLoading:b,precision:P,expirationEnabled:S,expirationPreset:h,customDuration:N,customDurationUnit:w,onOutcomeChange:E,onOrderTypeChange:T,onQuantityChange:_,onLimitPriceChange:G,onSellAll:D,onExpirationEnabledChange:K,onExpirationPresetChange:W,onCustomDurationChange:oe,onCustomDurationUnitChange:le,onSubmit:J}){let{t:y}=useTranslation(),[k,H]=useState(false),V=useDisclosure(),[Q,se]=useState(""),ve=useRef(false);useEffect(()=>{ve.current||se(isNaN(i)?"":String(i));},[i]);let[je,Ce]=useState(""),Be=useRef(false);useEffect(()=>{Be.current||(isNaN(s)?Ce(""):Ce(String(parseFloat((s*100).toFixed(2)))));},[s]);let pt=useCallback(A=>{if(A!==""&&!/^\d*\.?\d{0,2}$/.test(A))return;if(Ce(A),A===""||A==="."){G(NaN);return}let qe=parseFloat(A);isNaN(qe)||G(qe/100);},[G]),mt=useCallback(A=>{let xe=new RegExp(`^\\d*\\.?\\d{0,${P}}$`);if(A!==""&&!xe.test(A))return;if(se(A),H(false),A===""||A==="."){_(NaN);return}let qe=parseFloat(A);isNaN(qe)||_(qe);},[_,P]);useEffect(()=>{d&&!V.isOpen&&V.onOpen();},[d]);let wt=useMemo(()=>{let A=n==="yes"?t.yesBid:t.noBid;return A!=null?parseFloat((Number(A)*100).toFixed(2)):null},[n,t]),Ge=!isNaN(i)&&i>0,He=useMemo(()=>{if(b)return y("predict.trade.loadingBalance");if(l)return y("predict.trade.loadingMarketData");if(c)return y("predict.trade.submitting");if(d)return y("predict.trade.kycRequired");if(!Ge)return y("predict.trade.enterAmount");let A=y(n==="yes"?"predict.trade.yes":"predict.trade.no");return `${y("predict.trade.sell")} ${A}`},[b,l,c,d,Ge,n,y]),vt=()=>{if(d){V.onOpen();return}if(!u){H(true);return}H(false),J();};return jsxs(Fragment,{children:[jsxs("div",{className:"flex w-full flex-col gap-y-4 p-4",style:r==="bordered"?{borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",transition:"border-color 0.2s"}:void 0,onMouseEnter:A=>{r==="bordered"&&(A.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:A=>{r==="bordered"&&(A.currentTarget.style.borderColor="rgba(39,39,42,0.6)");},children:[e&&jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxs("span",{className:"text-bearish",children:[y("predict.trade.sell")," ",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:[p?jsxs(Tabs,{variant:"underlined",selectedKey:o,onSelectionChange:A=>T(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"&&p?jsx(StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:je,onChange:A=>pt(A.target.value),onFocus:()=>{Be.current=true;},onBlur:()=>{Be.current=false,isNaN(s)?Ce(""):Ce(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"}}):wt!=null&&jsxs("span",{className:"text-xl font-bold tabular-nums",children:[wt," \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.sellContracts")}),jsxs("div",{className:"flex items-center gap-x-2",children:[[25,50].map(A=>{let xe=Math.pow(10,P);return jsxs("button",{type:"button",onClick:()=>{_(Math.floor(x*A/100*xe)/xe);},className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:[A,"%"]},A)}),jsx("button",{type:"button",onClick:D,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:y("common.all")})]})]}),jsx(StyledInput,{"aria-label":"Sell quantity",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:Q,onChange:A=>mt(A.target.value),onFocus:()=>{ve.current=true;},onBlur:()=>{ve.current=false,se(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"}}),k&&m.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:m.map(A=>jsx("span",{className:"text-xs text-danger",children:A},A))})]}),jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-neutral-500",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:y("predict.trade.totalShares")}),jsx("span",{className:"tabular-nums text-foreground",children:b?"\u2013":`${ye(v,P).toFixed(P)}${y("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:y("predict.trade.activeOrders")}),jsx("span",{className:"tabular-nums text-warning",children:b?"\u2013":g>0?`-${ye(g,P).toFixed(P)}${y("predict.trade.sharesUnit")}`:`0${y("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:y("predict.trade.availableShares")}),jsx("span",{className:"tabular-nums text-success font-medium",children:b?"\u2013":`${ye(x,P).toFixed(P)}${y("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:y("predict.trade.estReturn")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${a.toFixed(2)}`:"\u2013"})]})]}),o==="limit"&&p&&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:S,onValueChange:K,"aria-label":y("predict.trade.setExpiration")})]}),S&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":y("predict.trade.setExpiration"),selectedKeys:[h],onSelectionChange:A=>{let xe=Array.from(A)[0];xe&&W(xe);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:mp.map(A=>jsx(SelectItem,{children:y(fp[A])},A))}),h==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(N)?void 0:N,onValueChange:oe,minValue:1,step:1,formatOptions:vp,classNames:{base:"flex-1",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 min-h-10",input:"text-sm"}}),jsx(Select,{"aria-label":"Duration unit",selectedKeys:[w],onSelectionChange:A=>{let xe=Array.from(A)[0];xe&&le(xe);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:gp.map(A=>jsx(SelectItem,{children:y(hp[A])},A))})]})]})]}),jsx(Button,{color:"secondary",fullWidth:true,radius:"lg",size:"lg",isDisabled:b||l||!Ge||c,isLoading:c||b||l,spinner:jsx(Spinner,{size:"sm",color:"current"}),onPress:vt,children:He})]}),jsx(Cn,{isOpen:V.isOpen,onClose:V.onClose,kycUrl:f})]})}function An({event:e,market:t,variant:r,initialOutcome:n,chain:o,slippageBps:i,onOutcomeChange:s}){let{outcome:a,orderType:l,quantity:c,limitPrice:u,estimatedReturn:m,pricePerShare:p,isMarketDataLoading:d,isSubmitting:f,validation:v,supportsLimitOrder:g,kycRequired:x,kycUrl:b,totalShares:P,activeOrderShares:S,availableShares:h,isAvailableLoading:N,precision:w,expirationEnabled:E,expirationPreset:T,customDuration:_,customDurationUnit:G,setOutcome:D,setOrderType:K,setQuantity:W,setLimitPrice:oe,setSellAll:le,setExpirationEnabled:J,setExpirationPreset:y,setCustomDuration:k,setCustomDurationUnit:H,submit:V}=Ns({market:t,initialOutcome:n,slippageBps:i}),Q=useAuthCallback(V),se=useCallback(Ce=>{D(Ce),s?.(Ce);},[D,s]),ve=useMemo(()=>e?vn(e):void 0,[e]),je=useMemo(()=>xn(t,{yesBid:a==="yes"?p:void 0,noBid:a==="no"?p:void 0}),[t,a,p]);return jsx(Os,{event:ve,market:je,variant:r,outcome:a,orderType:l,quantity:c,limitPrice:u,estimatedReturn:m,isMarketDataLoading:d,isSubmitting:f,isValid:v.isValid,validationErrors:v.errors,supportsLimitOrder:g,kycRequired:x,kycUrl:b,totalShares:P,activeOrderShares:S,availableShares:h,isAvailableLoading:N,precision:w,expirationEnabled:E,expirationPreset:T,customDuration:_,customDurationUnit:G,onOutcomeChange:se,onOrderTypeChange:K,onQuantityChange:W,onLimitPriceChange:oe,onSellAll:le,onExpirationEnabledChange:J,onExpirationPresetChange:y,onCustomDurationChange:k,onCustomDurationUnitChange:H,onSubmit:Q})}var Lo="predict-sell";function As({id:e=Lo}){return jsx(AsyncModal,{id:e,children:t=>jsx(Cp,{...t})})}function Cp({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(An,{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 Io=40,Hn=36,qr=480,Oo=qr-Hn;function Hs({event:e,walletAddress:t,onCancelOrder:r}){let{t:n}=useTranslation(),[o,i]=useState("positions"),s=useMemo(()=>e.markets?.map(m=>m.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(m=>m.market&&s.includes(m.market.slug)).length,[a?.positions,s,t]),u=[{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:u.map(m=>jsx("button",{type:"button",onClick:()=>i(m.key),className:cn("px-3 py-2 text-sm font-medium transition-colors cursor-pointer",o===m.key?"text-foreground border-b-2 border-primary":"text-neutral hover:text-foreground"),children:m.label},m.key))}),t?jsxs("div",{style:{height:qr},children:[o==="positions"&&jsx(Ip,{source:e.source,walletAddress:t,marketSlugs:s}),o==="orders"&&jsx(Dp,{source:e.source,walletAddress:t,marketSlugs:s,onCancelOrder:r}),o==="trades"&&jsx(Bp,{source:e.source,walletAddress:t})]}):jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:qr},children:n("predict.trade.connectWallet")})]})}function Ip({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(Ao,{}):s.length===0?jsx(Do,{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:Hn},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:Oo},rowComponent:Op,rowCount:s.length,rowHeight:Io,rowProps:{positions:s,closeLabel:n("predict.positions.close")}})]})}function Op({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",u=i>0?"+":"",m=o.market?.outcomes?.[0]?.label??o.market?.question??"\u2014",p=o.side,d=o.size,f=o.size*l,v=o.market?.end_at?Wp(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:m}),jsx("span",{className:cn("text-[10px] font-medium",p.toLowerCase()==="yes"?"text-primary":"text-secondary"),children:p})]})}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children: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:Fn(a)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:Fn(l)}),jsxs("div",{className:cn("flex-[1.5] pr-2 text-right font-mono whitespace-nowrap",c),children:[u,"$",Math.abs(i).toFixed(2),jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",u,s.toFixed(1),"%)"]})]}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",d.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:v}),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 Dp({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(),u=useMemo(()=>{let x=i?.pages?.flatMap(S=>S.items)??[],b=new Set(["live","open","submitted","pending"]),P=x.filter(S=>b.has(S.status));return r.length>0&&(P=P.filter(S=>S.market_id&&r.includes(S.market_id))),P},[i?.pages,r]),m=useCallback(x=>{n?n(x.id):c.mutate({source:x.source,id:x.id});},[n,c]),p=u.length,d=p+(l?1:0),f=useCallback(x=>x<p,[p]),v=useCallback(async()=>{await a();},[a]),g=useInfiniteLoader({isRowLoaded:f,loadMoreRows:v,rowCount:d,threshold:5});return s?jsx(Ao,{}):u.length===0&&!l?jsx(Do,{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:Hn},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:Oo},onRowsRendered:g,rowComponent:Ap,rowCount:d,rowHeight:Io,rowProps:{orders:u,itemCount:p,onCancel:m,isCancelling:c.isPending,cancelLabel:o("predict.openOrders.cancel")}})]})}function Ap({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?Fn(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(Fp,{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 Fp({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 Bp({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(d=>d.items)??[],[n?.pages]),l=a.length,c=l+(s?1:0),u=useCallback(d=>d<l,[l]),m=useCallback(async()=>{await i();},[i]),p=useInfiniteLoader({isRowLoaded:u,loadMoreRows:m,rowCount:c,threshold:5});return o?jsx(Ao,{}):a.length===0&&!s?jsx(Do,{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:Hn},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:Oo},onRowsRendered:p,rowComponent:Hp,rowCount:c,rowHeight:Io,rowProps:{trades:a,itemCount:l}})]})}function Hp({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=zp(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:Fn(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 Do({message:e}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:qr},children:e})}function Ao(){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:qr},children:Array.from({length:6}).map((e,t)=>jsx(Skeleton,{className:"h-8 w-full rounded-md"},t))})}function Fn(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(1)}\xA2`}function zp(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 Wp(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return "\u2014"}}var zs=`
74
+ `).map((r,o)=>jsxs("span",{children:[o>0&&jsx("br",{className:"hidden sm:block"}),r,o===0?" ":""]},o))})]}),jsx("div",{className:"evt-stat-grid",style:e?{animation:"evtStatsEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:"0.1s"}:{},children:ku.map((r,o)=>jsxs("div",{style:{padding:"14px 16px",background:e?`linear-gradient(to bottom, ${r.gradientFrom}, ${r.gradientTo})`:"rgba(255,255,255,0.02)",borderRight:o%2===0?"1px solid rgba(39,39,42,0.4)":"none",borderBottom:o<2?"1px solid rgba(39,39,42,0.4)":"none",...e?{animation:"evtStatCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:`${150+o*60}ms`}:{}},children:[jsx("div",{className:"evt-stat-val",style:{fontWeight:700,fontVariantNumeric:"tabular-nums",color:e?r.valueColor:"transparent",display:"flex",alignItems:"center"},children:e?r.format(e[r.key]):jsx("div",{style:{height:16,width:56,borderRadius:4,background:"rgba(255,255,255,0.06)",animation:"evtStatCardEnter 0.6s ease-out both",animationDelay:`${o*80}ms`}})}),jsx("div",{className:"evt-stat-label",style:{fontWeight:500,color:e?"#71717a":"transparent",marginTop:2,display:"flex",alignItems:"center"},children:e?t(r.labelKey):jsx("div",{style:{height:10,width:64,borderRadius:4,background:"rgba(255,255,255,0.04)",animation:"evtStatCardEnter 0.6s ease-out both",animationDelay:`${50+o*80}ms`}})})]},r.key))})]})]})}function Ss({event:e,market:t,position:r,onSuccess:o,onCancel:n}){let{t:i}=useTranslation(),{mutateAsync:s}=useRedeemPosition(),{evmAddress:a}=cr(),l=useWallets(),[d,u]=useState("idle"),[p,m]=useState(null),c=t.provider_meta?.["polymarket.conditionId"],f=t.provider_meta?.["polymarket.negRisk"]??false,g=a??"",v=useMemo(()=>l.find(F=>F.chainNamespace===ChainNamespace.EVM&&F.isConnected),[l]),x=ks(r.side,t.outcomes),w=t.outcomes?.[x]?.label??r.side,P=t.result!=null?ks(t.result,t.outcomes):-1,y=(P>=0?t.outcomes?.[P]:void 0)?.label??t.result??"",S=t.result!=null?x===P:true,N=useMemo(()=>S?r.size:0,[S,r.size]),A=useCallback(async()=>{if(!(!c||!g||!v)){u("pending"),m(null);try{let F=await v.getEip1193Provider();if(!F)throw new Error("EIP-1193 provider unavailable");await s({wallet_address:g,condition_id:c,neg_risk:f,signMessage:async q=>await F.request({method:"personal_sign",params:[q,g]})}),u("success"),o?.();}catch(F){u("error"),m(F instanceof Error?F.message:i("predict.redeem.error"));}}},[c,g,f,v,s,o,i]),D=useAuthCallback(A),z=d==="idle"&&!!c&&!!g&&!!v&&r.redeemable;return jsxs("div",{className:"flex flex-col gap-4 p-4",children:[jsx("div",{className:"text-base font-medium text-white",children:e?.title??t.question}),jsxs("div",{className:"flex flex-col gap-2 rounded-xl bg-[rgba(39,39,42,0.4)] p-3",children:[jsx(Fn,{label:i("predict.positions.side"),value:w,valueClassName:S?"text-green-400":"text-red-400"}),t.result!=null&&jsx(Fn,{label:i("predict.redeem.result"),value:y,valueClassName:"text-green-400"}),jsx(Fn,{label:i("predict.positions.size"),value:r.size.toFixed(2)}),jsx(Fn,{label:i("predict.redeem.expectedPayout"),value:`$${N.toFixed(2)}`,valueClassName:N>0?"text-green-400":"text-zinc-400"})]}),!S&&N===0&&jsx("p",{className:"text-sm text-zinc-500",children:i("predict.redeem.noWinnings")}),d==="error"&&p&&jsx("p",{className:"text-sm text-red-400",children:p}),d==="success"&&jsx("p",{className:"text-sm text-green-400",children:i("predict.redeem.success")}),jsxs("div",{className:"flex flex-col gap-2",children:[d!=="success"&&jsx(Button,{color:"success",className:"w-full h-12 rounded-xl text-sm font-semibold",isDisabled:!z,isLoading:d==="pending",onPress:D,spinner:jsx(Spinner,{size:"sm",color:"current"}),children:i("predict.redeem.confirm")}),n&&d!=="success"&&jsx("button",{type:"button",onClick:n,className:"w-full h-12 rounded-xl text-sm font-medium text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:i("common.cancel")}),d==="success"&&n&&jsx(Button,{className:"w-full h-12 rounded-xl text-sm font-medium",onPress:n,children:i("common.ok")})]})]})}function Fn({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 ks(e,t){let r=e.toLowerCase();if(r==="yes")return 0;if(r==="no"||!t)return 1;let o=t.findIndex(n=>n.label.toLowerCase()===r);return o>=0?o:1}var Du="predict-redeem";function Ps({id:e=Du}){return jsx(AsyncModal,{id:e,children:t=>jsx(Au,{...t})})}function Au({params:e,isOpen:t,onOpenChange:r}){let{t:o}=useTranslation(),{isMobile:n}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:n?"lg":"md",backdrop:"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:n?"":"p-2",children:[jsxs("div",{className:"px-4 pt-4 pb-1",children:[jsx("h3",{className:"text-lg font-semibold text-white",children:o("predict.redeem.title")}),jsx("p",{className:"text-sm text-zinc-400 mt-1",children:o("predict.redeem.description")})]}),jsx(Ss,{event:e.event,market:e.market,position:e.position,onSuccess:()=>{setTimeout(()=>r(false),1500);},onCancel:()=>r(false)})]})})}):null}function Es({market:e,initialOutcome:t="yes",slippageBps:r=100,onSuccess:o}){let{t:n}=useTranslation(),i=useRef(o);i.current=o;let{status:s}=useAuth(),a=useWallets(),l=usePredictClient(),d=useContext(PolymarketContext),u=useQueryClient(),p=e.source,m=p==="polymarket",c=a.find(E=>E.chainNamespace===ChainNamespace.SOLANA&&E.isConnected),f=a.find(E=>E.chainNamespace===ChainNamespace.EVM&&E.isConnected&&"switchChain"in E),g=s==="authenticated",v=c?.address,x=f?.address,[b,w]=useState(t),[P,h]=useState("market"),[y,S]=useState(NaN),[N,A]=useState(NaN),[D,z]=useState(false),[F,q]=useState(false),[$,Q]=useState(null),[re,Z]=useState(null),[C,M]=useState(false),[U,G]=useState(false),[k,ce]=useState("1h"),[pe,ke]=useState(30),[Ve,Ue]=useState("minutes"),$e=useMemo(()=>{if(p!=="polymarket")return;let E=e.provider_meta?.["polymarket.clobTokenIds"];return E?(typeof E=="string"?JSON.parse(E):E)[b==="yes"?0:1]:void 0},[p,e.provider_meta,b]),{data:Ze,isLoading:Pe}=useTickSize($e),xe=Ze?.minimum_tick_size?String(Ze.minimum_tick_size):"0.01",{data:et,isLoading:Mt}=useFeeRate($e),tt=String(et?.base_fee??0),{data:qe}=useRebateConfig(),Se=qe?.builder_enabled&&qe.builder_code?qe.builder_code:void 0,Oe=false,rt=null,Xt=false,mt,R,X;try{let E=cr();Oe=E.kalshiKycVerified,rt=E.kalshiKycUrl,Xt=E.polymarketSetupVerified,mt=E.polymarketSafeAddress,R=E.polymarketWalletKind,X=E.polymarketWalletAddress;}catch{}let bt=p==="kalshi"&&!Oe,ft=p==="polymarket"&&!Xt,gt=useCallback(async()=>{if(!f||!d)return null;let E=await f.getEip1193Provider();if(!E)return null;let Me=R==="deposit"&&!!X,De=!Me&&!!mt,He={address:f.address,signatureType:Me?3:De?2:0,signTypedData:async(Qe,St,Ee,Te)=>{let ht=[];"name"in Qe&&ht.push({name:"name",type:"string"}),"version"in Qe&&ht.push({name:"version",type:"string"}),"chainId"in Qe&&ht.push({name:"chainId",type:"uint256"}),"verifyingContract"in Qe&&ht.push({name:"verifyingContract",type:"address"}),"salt"in Qe&&ht.push({name:"salt",type:"bytes32"});let Zt={EIP712Domain:ht,...St};return await E.request({method:"eth_signTypedData_v4",params:[f.address,JSON.stringify({domain:Qe,types:Zt,primaryType:Ee,message:Te})]})}};return d.credentials??await d.authenticate(He)},[mt,R,X,f,d]),{data:L}=useRealtimeOrderbook({slug:e.slug,source:p,outcome:b},{enabled:e.status==="open"}),ve=useMemo(()=>{let E=pickBestBid(L,b);if(E!=null&&E>0)return E;let Me=b==="yes"?0:1,De=e.outcomes[Me];return De?.best_bid??De?.price??.5},[L,e.outcomes,b]),je=p==="kalshi"?v??"":x??"",{data:Or,isLoading:ao}=usePositions({source:p,user:je},{enabled:!!je,refetchInterval:3e4}),lo=useCallback(async()=>{let E=await gt();return E?await buildPolymarketL2Headers(E.address,{apiKey:E.apiKey,secret:E.secret,passphrase:E.passphrase,method:"GET",requestPath:"/data/orders",body:""}):{}},[gt]),{data:or,isLoading:ir}=useAvailableShares({source:p,user:je,market:e.slug,side:b},p==="polymarket"?{getHeaders:lo}:void 0,{enabled:!!je&&!!e.slug,refetchOnMount:"always"}),Bt=or?.total_shares??0,kr=or?.active_order_shares??0,Et=or?.available_shares??0,Ge=useMemo(()=>p==="polymarket"?getPolymarketSharesPrecision(xe):or?.precision??0,[p,xe,or?.precision]),co=ir||ao,pn=e.provider_meta?.["dflow.yesMint"]??"",Ht=e.provider_meta?.["dflow.noMint"]??"",Jt=SOLANA_TOKENS.stablecoins.USDC.address,Dr=e.provider_meta?.["dflow.collateralMint"]||"",mn=b==="yes"?pn:Ht,fn=useMemo(()=>Or?Or.positions.find(E=>E.side?.toLowerCase()===b&&E.market?.slug===e.slug)??null:null,[Or,e.slug,b])?.market?.provider_meta,po=fn?.["dflow.outcomeMint"]||mn,sr=fn?.["dflow.collateralMint"]||Dr,Tt=po,zt=sr||Jt,Sr=useMemo(()=>isNaN(y)||y<=0?"0":String(Math.round(y*1e6)),[y]),mo=p==="kalshi"&&!!Tt&&!!zt&&!!v&&Sr!=="0",{refetch:Ar}=useDFlowQuote({inputMint:Tt,outputMint:zt,amount:Sr,userPublicKey:v??"",slippageBps:100},{enabled:mo}),ar=useMemo(()=>isNaN(y)||y<=0?0:y,[y]),nt=useMemo(()=>walkOrderbook({orderbook:L,outcome:b,side:"sell",sharesNeeded:ar,slippageBps:r}),[L,b,ar,r]),Fr=useMemo(()=>nt.status==="ok"&&nt.worstPrice!=null&&nt.worstPrice>0?nt.worstPrice:ve,[nt,ve]),fo=useMemo(()=>{if(isNaN(y)||y<=0)return 0;let E=P==="limit"&&m&&!isNaN(N)?N:ve;return y*E},[y,P,m,N,ve]),_=useCallback(E=>{w(E),A(NaN),S(NaN),q(false);},[]);useEffect(()=>{_(t);},[t,_]);let Be=useCallback(E=>{h(E);},[]);useEffect(()=>{P==="limit"&&A(Math.round(ve*100)/100);},[P,b]);let Ye=useCallback(E=>{if(q(false),isNaN(E)){S(NaN);return}S(we(Math.max(0,E),Ge));},[Ge]),Wt=useCallback(()=>{q(true),S(we(Et,Ge));},[Et,Ge]),Br=useCallback(E=>{if(isNaN(E)){A(NaN);return}let Me=Math.max(.01,Math.min(.99,E));A(Math.round(Me*100)/100);},[]),yt=useCallback(()=>{S(NaN),A(NaN),h("market"),q(false),G(false),ce("1h"),ke(30),Ue("minutes");},[]),kt=useMemo(()=>{let E=[];return isNaN(y)||y<=0?E.push(n("predict.trade.minQuantity",{amount:Pn})):y<Pn&&E.push(n("predict.trade.minQuantity",{amount:Pn})),e.status!=="open"&&E.push(n("predict.trade.marketNotActive")),!isNaN(y)&&y>0&&!F&&y>Et&&E.push(n("predict.trade.insufficientSharesDetail",{total:we(Bt,Ge).toFixed(Ge),active:we(kr,Ge).toFixed(Ge),available:we(Et,Ge).toFixed(Ge)})),P==="limit"&&m&&(isNaN(N)||N<.01||N>.99)&&E.push(n("predict.trade.limitPriceRange")),P==="limit"&&m&&U&&k==="custom"&&(isNaN(pe)||pe<=0)&&E.push(n("predict.trade.expiration.invalidDate")),p==="polymarket"&&P==="market"&&!isNaN(y)&&y>0&&(nt.status==="insufficient_liquidity"?E.push(n("predict.trade.insufficientLiquidity",{available:we(nt.totalAvailable,2)})):nt.status==="exceeds_slippage"&&E.push(n("predict.trade.priceImpactTooHigh",{impact:(nt.priceImpactBps/100).toFixed(2),slippage:(r/100).toFixed(2)}))),{isValid:E.length===0,errors:E}},[y,e.status,Et,Bt,kr,F,P,m,N,U,k,pe,Ge,p,nt,r,n]),{mutateAsync:ot}=useDFlowSubmit(),{data:Hr}=useOrder({id:$??"",source:p},{enabled:!!$}),zr=useCallback(async()=>{if(!re||!v||!c)return;let{cashAmount:E,collateral:Me}=re;Z(null);try{let He=(await l.createDFlowQuote({inputMint:Me,outputMint:Jt,amount:E,userPublicKey:v,slippageBps:100}))?.transaction;if(!He)return;let Qe=Uint8Array.from(atob(He),Ee=>Ee.charCodeAt(0)),St=await c.signTransaction(Qe);await ot({signedTransaction:btoa(String.fromCharCode(...St)),orderContext:{user_public_key:v,input_mint:Me,output_mint:Jt,amount:E,price:"1",side:"SELL",outcome:"",market_slug:"",slippage_bps:100}});}catch{}},[re,v,c,l,ot,Jt]),Lt=useCallback(()=>{u.invalidateQueries({queryKey:["predict","positions"]}),u.invalidateQueries({queryKey:["predict","orders"]}),u.invalidateQueries({queryKey:["predict","available-shares"]});},[u]);useEffect(()=>{if(!Hr||!$)return;let{status:E}=Hr;E==="closed"?(Q(null),re?zr().finally(()=>{z(false),toast.success(n("predict.trade.submitSuccess")),dr(),Lt(),yt(),i.current?.();}):(z(false),toast.success(n("predict.trade.submitSuccess")),dr(),Lt(),yt(),i.current?.())):(E==="failed"||E==="expired")&&(z(false),Q(null),Z(null),toast.error(n("predict.trade.submitError")));},[Hr,$,re,zr,Lt,yt,n]);let Wr=useCallback(async()=>{if(!v||!c)return;if(!Tt||!zt){toast.error("Missing token mint addresses"),z(false);return}if(!Oe){M(true),z(false);return}let De=(await Ar()).data,He=De?.transaction;if(!He){toast.error(n("predict.trade.submitError")),z(false);return}if(sr&&sr!==Jt){let Te=String(De?.outAmount??"");Te&&Te!=="0"&&Z({cashAmount:Te,collateral:sr});}let Qe=Uint8Array.from(atob(He),Te=>Te.charCodeAt(0)),St=await c.signTransaction(Qe),Ee=await ot({signedTransaction:btoa(String.fromCharCode(...St)),orderContext:{user_public_key:v,input_mint:Tt,output_mint:zt,amount:Sr,price:String(ve),side:"SELL",outcome:b==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});Q(Ee.signature);},[v,c,Ar,ot,Tt,zt,Sr,ve,b,e.slug,sr,Jt,n,Oe]),gn=useCallback(async()=>{if(!f||!d)return;let E=f.chain,Me=E!==Chain.POLYGON;Me&&await f.switchChain(Chain.POLYGON);try{let De=await f.getEip1193Provider();if(!De){toast.error(n("predict.trade.submitError")),z(!1);return}let He=R==="deposit"&&!!X,Qe=!He&&!!mt,St=He?X:mt,Ee={address:f.address,signatureType:He?3:Qe?2:0,signTypedData:async(Ut,xn,ho,vo)=>{let wr=[];"name"in Ut&&wr.push({name:"name",type:"string"}),"version"in Ut&&wr.push({name:"version",type:"string"}),"chainId"in Ut&&wr.push({name:"chainId",type:"uint256"}),"verifyingContract"in Ut&&wr.push({name:"verifyingContract",type:"address"}),"salt"in Ut&&wr.push({name:"salt",type:"bytes32"});let Xl={EIP712Domain:wr,...xn};return await De.request({method:"eth_signTypedData_v4",params:[f.address,JSON.stringify({domain:Ut,types:Xl,primaryType:ho,message:vo})]})}},Te=await gt();if(!Te){toast.error(n("predict.trade.submitError")),z(!1);return}let ht=b==="yes"?0:1,Zt="",wt=e.provider_meta?.["polymarket.clobTokenIds"];wt&&(Zt=(typeof wt=="string"?JSON.parse(wt):wt)[ht]??"");let hn=e.provider_meta?.["polymarket.negRisk"]??!1,ql=P==="limit"&&!isNaN(N)?N:Fr,Gl=Mn(ql,xe),go={tokenId:Zt,price:Gl,size:y,side:"SELL",orderType:P==="limit"?U?"GTD":"GTC":"FOK",tickSize:xe,negRisk:hn,...St&&{funderAddress:St},...Se&&{builderCode:Se},...P==="limit"&&U&&{expiration:Cn(k,pe,Ve)}},vn;if(He)vn=await buildSignedV2OrderPayload({signer:Ee,depositWalletAddress:St,input:go,owner:Te.apiKey});else {let Ut=buildCtfExchangeDomain(hn),xn=buildOrderMessage({...go,signerAddress:Ee.address,signatureType:Ee.signatureType,feeRateBps:tt}),ho=await Ee.signTypedData(Ut,CTF_ORDER_TYPES,"Order",xn),vo=buildSignedOrder(xn,ho,go.orderType);vn=buildClobPayload(vo,Te.apiKey);}let Yl=JSON.stringify(vn),Ql=await buildPolymarketL2Headers(Te.address,{apiKey:Te.apiKey,secret:Te.secret,passphrase:Te.passphrase,method:"POST",requestPath:"/order",body:Yl});await l.createPolymarketOrder(vn,Ql),Lt(),toast.success(n("predict.trade.submitSuccess")),dr(),yt(),z(!1),i.current?.();}finally{Me&&E&&f.switchChain(E).catch(()=>{});}},[f,d,gt,b,e.provider_meta,P,N,Fr,y,l,Lt,U,k,pe,Ve,yt,n,xe,tt,e.slug,mt,R,X,Se]),Ur=useCallback(async()=>{if(!(!kt.isValid||!g)){z(true),Q(null),M(false);try{p==="kalshi"?await Wr():await gn();}catch(E){let Me=E instanceof Error?E.message:"",De=p==="polymarket"&&Me?En(Me,n,"sell"):Me||void 0;toast.error(De||n("predict.trade.submitError")),z(false);}}},[kt.isValid,g,p,Wr,gn,n]);return {outcome:b,orderType:P,quantity:y,limitPrice:N,shares:ar,estimatedReturn:fo,pricePerShare:ve,isMarketDataLoading:p==="polymarket"&&(Mt||Pe),isSubmitting:D,authStatus:s,validation:kt,supportsLimitOrder:m,kycRequired:C,needsKyc:bt,needsSetup:ft,kycUrl:rt,totalShares:Bt,activeOrderShares:kr,availableShares:Et,isAvailableLoading:co,isSellAll:F,precision:Ge,expirationEnabled:U,expirationPreset:k,customDuration:pe,customDurationUnit:Ve,setOutcome:_,setOrderType:Be,setQuantity:Ye,setLimitPrice:Br,setSellAll:Wt,setExpirationEnabled:G,setExpirationPreset:ce,setCustomDuration:ke,setCustomDurationUnit:Ue,submit:Ur}}var vp=["5m","1h","12h","24h","eod","custom"],xp={"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"},bp=["minutes","hours","days"],yp={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},kp={maximumFractionDigits:0};function Fs({event:e,market:t,variant:r="bordered",outcome:o,orderType:n,quantity:i,limitPrice:s,estimatedReturn:a,isMarketDataLoading:l,isSubmitting:d,authStatus:u,isValid:p,validationErrors:m,supportsLimitOrder:c,kycRequired:f,needsKyc:g,needsSetup:v,onSetupRequired:x,kycUrl:b,totalShares:w,activeOrderShares:P,availableShares:h,isAvailableLoading:y,precision:S,expirationEnabled:N,expirationPreset:A,customDuration:D,customDurationUnit:z,onOutcomeChange:F,onOrderTypeChange:q,onQuantityChange:$,onLimitPriceChange:Q,onSellAll:re,onExpirationEnabledChange:Z,onExpirationPresetChange:C,onCustomDurationChange:M,onCustomDurationUnitChange:U,onSubmit:G}){let{t:k}=useTranslation(),[ce,pe]=useState(false),ke=useDisclosure(),[Ve,Ue]=useState(""),$e=useRef(false);useEffect(()=>{$e.current||Ue(isNaN(i)?"":String(i));},[i]);let[Ze,Pe]=useState(""),xe=useRef(false);useEffect(()=>{xe.current||(isNaN(s)?Pe(""):Pe(String(parseFloat((s*100).toFixed(2)))));},[s]);let et=useCallback(R=>{if(R!==""&&!/^\d*\.?\d{0,2}$/.test(R))return;if(Pe(R),R===""||R==="."){Q(NaN);return}let bt=parseFloat(R);isNaN(bt)||Q(bt/100);},[Q]),Mt=useCallback(R=>{let X=new RegExp(`^\\d*\\.?\\d{0,${S}}$`);if(R!==""&&!X.test(R))return;if(Ue(R),pe(false),R===""||R==="."){$(NaN);return}let bt=parseFloat(R);isNaN(bt)||$(bt);},[$,S]);useEffect(()=>{f&&!ke.isOpen&&ke.onOpen();},[f]);let tt=useMemo(()=>{let R=o==="yes"?t.yesBid:t.noBid;return R!=null?parseFloat((Number(R)*100).toFixed(2)):null},[o,t]),qe=!isNaN(i)&&i>0,Se=u==="authenticated",Oe=u==="authenticating"||u==="deauthenticating",rt=Se&&(g||v),Xt=useMemo(()=>{if(Oe)return k("predict.trade.checkingLogin");if(!Se)return k("predict.trade.loginToTrade");if(g)return k("predict.trade.kycRequired");if(v)return k("predict.trade.setupRequired");if(y)return k("predict.trade.loadingBalance");if(l)return k("predict.trade.loadingMarketData");if(d)return k("predict.trade.submitting");if(f)return k("predict.trade.kycRequired");if(!qe)return k("predict.trade.enterAmount");let R=k(o==="yes"?"predict.trade.yes":"predict.trade.no");return `${k("predict.trade.sell")} ${R}`},[Oe,Se,g,v,y,l,d,f,qe,o,k]),mt=()=>{if(!Se){pe(false),G();return}if(g){ke.onOpen();return}if(v&&x){pe(false),x();return}if(f){ke.onOpen();return}if(!p){pe(true);return}pe(false),G();};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=>{r==="bordered"&&(R.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:R=>{r==="bordered"&&(R.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:[k("predict.trade.sell")," ",k(o==="yes"?"predict.trade.yes":"predict.trade.no")]}),jsxs("span",{className:"text-foreground",children:[" \xB7 ",t.yesSubTitle]})]})]})]}),jsxs("div",{className:"flex items-center justify-between",children:[c?jsxs(Tabs,{variant:"underlined",selectedKey:n,onSelectionChange:R=>q(R),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsx(Tab,{title:k("predict.trade.market")},"market"),jsx(Tab,{title:k("predict.trade.limit")},"limit")]}):jsx("span",{className:"text-sm font-medium text-foreground",children:k("predict.trade.market")}),n==="limit"&&c?jsx(StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:Ze,onChange:R=>et(R.target.value),onFocus:()=>{xe.current=true;},onBlur:()=>{xe.current=false,isNaN(s)?Pe(""):Pe(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"}}):tt!=null&&jsxs("span",{className:"text-xl font-bold tabular-nums",children:[tt," \xA2"]})]}),jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(R=>{let X=R==="yes"?t.yesBid:t.noBid;return jsx("div",{className:"flex flex-1 flex-col gap-y-1",children:jsxs("button",{type:"button",onClick:()=>F(R),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${o===R?"border-bearish bg-bearish/10 text-bearish":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsx("span",{children:k(R==="yes"?"predict.trade.yes":"predict.trade.no")}),X!=null&&jsxs("span",{className:"ml-1 opacity-70",children:[parseFloat((Number(X)*100).toFixed(2)),"\xA2"]})]})},R)})}),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:k("predict.trade.sellContracts")}),jsxs("div",{className:"flex items-center gap-x-2",children:[[25,50].map(R=>{let X=Math.pow(10,S);return jsxs("button",{type:"button",onClick:()=>{$(Math.floor(h*R/100*X)/X);},className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:[R,"%"]},R)}),jsx("button",{type:"button",onClick:re,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:k("common.all")})]})]}),jsx(StyledInput,{"aria-label":"Sell quantity",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:Ve,onChange:R=>Mt(R.target.value),onFocus:()=>{$e.current=true;},onBlur:()=>{$e.current=false,Ue(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"}}),ce&&m.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:m.map(R=>jsx("span",{className:"text-xs text-danger",children:R},R))})]}),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:k("predict.trade.totalShares")}),jsx("span",{className:"tabular-nums text-foreground",children:y?"\u2013":`${we(w,S).toFixed(S)}${k("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:k("predict.trade.activeOrders")}),jsx("span",{className:"tabular-nums text-warning",children:y?"\u2013":P>0?`-${we(P,S).toFixed(S)}${k("predict.trade.sharesUnit")}`:`0${k("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:k("predict.trade.availableShares")}),jsx("span",{className:"tabular-nums text-success font-medium",children:y?"\u2013":`${we(h,S).toFixed(S)}${k("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:k("predict.trade.estReturn")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${a.toFixed(2)}`:"\u2013"})]})]}),n==="limit"&&c&&jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-medium text-primary",children:k("predict.trade.setExpiration")}),jsx(StyledSwitch,{size:"sm",color:"primary",isSelected:N,onValueChange:Z,"aria-label":k("predict.trade.setExpiration")})]}),N&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":k("predict.trade.setExpiration"),selectedKeys:[A],onSelectionChange:R=>{let X=Array.from(R)[0];X&&C(X);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:vp.map(R=>jsx(SelectItem,{children:k(xp[R])},R))}),A==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(D)?void 0:D,onValueChange:M,minValue:1,step:1,formatOptions:kp,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:[z],onSelectionChange:R=>{let X=Array.from(R)[0];X&&U(X);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:bp.map(R=>jsx(SelectItem,{children:k(yp[R])},R))})]})]})]}),jsx(Button,{color:"secondary",fullWidth:true,radius:"lg",size:"lg",isDisabled:Oe||Se&&!rt&&(y||l||!qe||d),isLoading:Oe||Se&&!rt&&(d||y||l),spinner:jsx(Spinner,{size:"sm",color:"current"}),onPress:mt,children:Xt})]}),jsx(Tn,{isOpen:ke.isOpen,onClose:ke.onClose,kycUrl:b})]})}function Hn({event:e,market:t,variant:r,initialOutcome:o,chain:n,slippageBps:i,onOutcomeChange:s,onSetupRequired:a,onSuccess:l}){let{outcome:d,orderType:u,quantity:p,limitPrice:m,estimatedReturn:c,pricePerShare:f,isMarketDataLoading:g,isSubmitting:v,authStatus:x,validation:b,supportsLimitOrder:w,kycRequired:P,needsKyc:h,needsSetup:y,kycUrl:S,totalShares:N,activeOrderShares:A,availableShares:D,isAvailableLoading:z,precision:F,expirationEnabled:q,expirationPreset:$,customDuration:Q,customDurationUnit:re,setOutcome:Z,setOrderType:C,setQuantity:M,setLimitPrice:U,setSellAll:G,setExpirationEnabled:k,setExpirationPreset:ce,setCustomDuration:pe,setCustomDurationUnit:ke,submit:Ve}=Es({market:t,initialOutcome:o,slippageBps:i,onSuccess:l}),Ue=useAuthCallback(Ve),$e=useCallback(xe=>{Z(xe),s?.(xe);},[Z,s]),Ze=useMemo(()=>e?yn(e):void 0,[e]),Pe=useMemo(()=>kn(t,{yesBid:d==="yes"?f:void 0,noBid:d==="no"?f:void 0}),[t,d,f]);return jsx(Fs,{event:Ze,market:Pe,variant:r,outcome:d,orderType:u,quantity:p,limitPrice:m,estimatedReturn:c,isMarketDataLoading:g,isSubmitting:v,authStatus:x,isValid:b.isValid,validationErrors:b.errors,supportsLimitOrder:w,kycRequired:P,needsKyc:h,needsSetup:y,onSetupRequired:a,kycUrl:S,totalShares:N,activeOrderShares:A,availableShares:D,isAvailableLoading:z,precision:F,expirationEnabled:q,expirationPreset:$,customDuration:Q,customDurationUnit:re,onOutcomeChange:$e,onOrderTypeChange:C,onQuantityChange:M,onLimitPriceChange:U,onSellAll:G,onExpirationEnabledChange:k,onExpirationPresetChange:ce,onCustomDurationChange:pe,onCustomDurationUnitChange:ke,onSubmit:Ue})}var Oo="predict-sell";function Hs({id:e=Oo}){return jsx(AsyncModal,{id:e,children:t=>jsx(Lp,{...t})})}function Lp({params:e,isOpen:t,onOpenChange:r}){let{t:o}=useTranslation(),{isMobile:n}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:n?"lg":"md",backdrop:"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:n?"":"p-2",children:[jsx(Hn,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,chain:e.chain,slippageBps:e.slippageBps,onSetupRequired:e.onSetupRequired,onSuccess:()=>r(false),variant:"flat"}),jsx("div",{className:"px-4 pb-4",children:jsx("button",{type:"button",onClick:()=>r(false),className:"w-full h-12 rounded-xl text-sm font-medium text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:o("common.cancel")})})]})})}):null}var Fo=40,Un=36,Jr=480,Bo=Jr-Un;function Us({event:e,walletAddress:t,onCancelOrder:r}){let{t:o}=useTranslation(),[n,i]=useState("positions"),s=useMemo(()=>e.markets?.map(p=>p.slug)??[],[e.markets]),{data:a}=usePositions({source:e.source,user:t??""}),l=useMemo(()=>!a?.positions||!t?0:s.length===0?a.positions.length:a.positions.filter(p=>p.market&&s.includes(p.market.slug)).length,[a?.positions,s,t]),u=[{key:"positions",label:l>0?`${o("predict.positions.title")} (${l})`:o("predict.positions.title")},{key:"orders",label:o("predict.openOrders.title")},{key:"trades",label:o("predict.tradeHistory.title")}];return jsxs("div",{className:"flex flex-col gap-y-2 mt-6 px-1 lg:px-4",children:[jsx("div",{className:"flex items-center gap-x-1 border-b border-border",children:u.map(p=>jsx("button",{type:"button",onClick:()=>i(p.key),className:cn$1("px-3 py-2 text-sm font-medium transition-colors cursor-pointer",n===p.key?"text-foreground border-b-2 border-primary":"text-neutral hover:text-foreground"),children:p.label},p.key))}),t?jsxs("div",{style:{height:Jr},children:[n==="positions"&&jsx(Fp,{source:e.source,walletAddress:t,marketSlugs:s}),n==="orders"&&jsx(Hp,{source:e.source,walletAddress:t,marketSlugs:s,onCancelOrder:r}),n==="trades"&&jsx(Up,{source:e.source,walletAddress:t})]}):jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:Jr},children:o("predict.trade.connectWallet")})]})}function Fp({source:e,walletAddress:t,marketSlugs:r}){let{t:o}=useTranslation(),{data:n,isLoading:i}=usePositions({source:e,user:t}),s=useMemo(()=>n?.positions?r.length===0?n.positions:n.positions.filter(a=>a.market&&r.includes(a.market.slug)):[],[n?.positions,r]);return i?jsx(zo,{}):s.length===0?jsx(Ho,{message:o("predict.positions.empty")}):jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:Un},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2 whitespace-nowrap",children:o("predict.positions.event")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.totalSize")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.value")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.avgPrice")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.markPrice")}),jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:o("predict.positions.pnl")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.payoutIfRight")}),jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:o("predict.positions.estSettlement")}),jsx("div",{className:"w-16 shrink-0"})]}),jsx(List,{style:{height:Bo},rowComponent:Bp,rowCount:s.length,rowHeight:Fo,rowProps:{positions:s,closeLabel:o("predict.positions.close")}})]})}function Bp({index:e,style:t,positions:r,closeLabel:o}){let n=r[e];if(!n)return null;let i=n.pnl??0,s=n.pnl_percent??0,a=n.avg_price??0,l=n.current_price??0,d=i>0?"text-success":i<0?"text-danger":"text-foreground",u=i>0?"+":"",p=n.market?.outcomes?.[0]?.label??n.market?.question??"\u2014",m=n.side,c=n.size,f=n.size*l,g=n.market?.end_at?Vp(n.market.end_at):"\u2014";return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-xs lg:text-sm",children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxs("div",{className:"flex flex-col gap-y-0.5",children:[jsx("span",{className:"text-foreground truncate font-medium",children:p}),jsx("span",{className:cn$1("text-[10px] font-medium",m.toLowerCase()==="yes"?"text-primary":"text-secondary"),children:m})]})}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:n.size}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",f.toFixed(2)]}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:zn(a)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:zn(l)}),jsxs("div",{className:cn$1("flex-[1.5] pr-2 text-right font-mono whitespace-nowrap",d),children:[u,"$",Math.abs(i).toFixed(2),jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",u,s.toFixed(1),"%)"]})]}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",c.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:g}),jsx("div",{className:"w-16 shrink-0 text-right",children:jsx("button",{type:"button",className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors rounded px-2 py-0.5 border border-border hover:border-foreground/40",children:o})})]})}function Hp({source:e,walletAddress:t,marketSlugs:r,onCancelOrder:o}){let{t:n}=useTranslation(),{data:i,isLoading:s,fetchNextPage:a,hasNextPage:l}=useInfiniteOrders({source:e,wallet_address:t}),d=useCancelOrder(),u=useMemo(()=>{let x=i?.pages?.flatMap(P=>P.items)??[],b=new Set(["live","open","submitted","pending"]),w=x.filter(P=>b.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(x=>{o?o(x.id):d.mutate({source:x.source,id:x.id});},[o,d]),m=u.length,c=m+(l?1:0),f=useCallback(x=>x<m,[m]),g=useCallback(async()=>{await a();},[a]),v=useInfiniteLoader({isRowLoaded:f,loadMoreRows:g,rowCount:c,threshold:5});return s?jsx(zo,{}):u.length===0&&!l?jsx(Ho,{message:n("predict.openOrders.empty")}):jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:Un},children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:n("predict.openOrders.side")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.openOrders.outcome")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.openOrders.type")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.openOrders.price")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.openOrders.filled")}),jsx("div",{className:"w-20 shrink-0 pr-2",children:n("predict.openOrders.status")}),jsx("div",{className:"w-16 shrink-0"})]}),jsx(List,{style:{height:Bo},onRowsRendered:v,rowComponent:zp,rowCount:c,rowHeight:Fo,rowProps:{orders:u,itemCount:m,onCancel:p,isCancelling:d.isPending,cancelLabel:n("predict.openOrders.cancel")}})]})}function zp({index:e,style:t,orders:r,itemCount:o,onCancel:n,isCancelling:i,cancelLabel:s}){if(e>=o)return jsx("div",{style:t,className:"flex justify-center items-center",children:jsx(Spinner,{size:"sm"})});let a=r[e];if(!a)return null;let l=a.side==="BUY";return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:jsx("span",{className:cn$1("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",l?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:a.side})}),jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:a.outcome??"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-neutral capitalize",children:a.order_type??"limit"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:a.price?zn(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(Wp,{status:a.status})}),jsx("div",{className:"w-16 shrink-0 text-right",children:jsx("button",{type:"button",onClick:()=>n(a),disabled:i,className:"text-[10px] text-danger hover:text-danger/80 cursor-pointer disabled:opacity-50 transition-colors",children:i?jsx(Spinner,{size:"sm"}):s})})]})}function Wp({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 Up({source:e,walletAddress:t}){let{t:r}=useTranslation(),{data:o,isLoading:n,fetchNextPage:i,hasNextPage:s}=useInfiniteTrades({source:e,wallet:t,limit:50}),a=useMemo(()=>o?.pages?.flatMap(c=>c.items)??[],[o?.pages]),l=a.length,d=l+(s?1:0),u=useCallback(c=>c<l,[l]),p=useCallback(async()=>{await i();},[i]),m=useInfiniteLoader({isRowLoaded:u,loadMoreRows:p,rowCount:d,threshold:5});return n?jsx(zo,{}):a.length===0&&!s?jsx(Ho,{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:Un},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:$p,rowCount:d,rowHeight:Fo,rowProps:{trades:a,itemCount:l}})]})}function $p({index:e,style:t,trades:r,itemCount:o}){if(e>=o)return jsx("div",{style:t,className:"flex justify-center items-center",children:jsx(Spinner,{size:"sm"})});let n=r[e];if(!n)return null;let i=n.side?.toUpperCase()==="BUY",s=Kp(n.timestamp),a=n.price??0,l=n.usd_size??0;return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:jsx("span",{className:cn$1("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",i?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:n.side})}),jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:n.outcome??"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:zn(a)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:n.size}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",l.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:s})]})}function Ho({message:e}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:Jr},children:e})}function zo(){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:Jr},children:Array.from({length:6}).map((e,t)=>jsx(Skeleton,{className:"h-8 w-full rounded-md"},t))})}function zn(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(1)}\xA2`}function Kp(e){let t=new Date(e*1e3),r=(t.getMonth()+1).toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),n=t.getHours().toString().padStart(2,"0"),i=t.getMinutes().toString().padStart(2,"0");return `${r}/${o} ${n}:${i}`}function Vp(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return "\u2014"}}var $s=`
75
75
  @keyframes detailShimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}
76
- `,Ws={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 {...Ws,animationDelay:`${e}ms`}}function Yr({marketCount:e=4,showBack:t}){return jsxs(Fragment,{children:[jsx("style",{children:zs}),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:{...Ws,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 Us(){return jsxs(Fragment,{children:[jsx("style",{children:zs}),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 Gs="var(--color-bullish)",qs="var(--color-bearish)";function Qr(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 Kp(e,t){return e<=0||t<=0?0:Math.pow(e/t,.3)}function Vp(e,t){let r=new Float64Array(101),n=new Float64Array(101);for(let d of e){let f=Math.round(d.price*100);f>=0&&f<=100&&(r[f]+=d.quantity);}for(let d of t){let f=Math.round(d.price*100);f>=0&&f<=100&&(n[f]+=d.quantity);}let o=0,i=0,s=new Float64Array(101),a=new Float64Array(101);for(let d=100;d>=0;d--)o+=r[d],i+=r[d]*d/100,s[d]=o,a[d]=i;let l=0,c=0,u=new Float64Array(101),m=new Float64Array(101);for(let d=0;d<=100;d++)l+=n[d],c+=n[d]*d/100,u[d]=l,m[d]=c;let p=Math.max(s[0]??0,u[100]??0);return Array.from({length:101},(d,f)=>{let v=s[f]>0,g=u[f]>0,x=s[f]||u[f],b=r[f]>0||n[f]>0;return {priceCents:f,displayHeight:Kp(x,p),opacity:x>0?b?1:.5:0,isBid:v,isAsk:g,bidCumTotal:s[f],askCumTotal:u[f],bidCumCost:a[f],askCumCost:m[f]}})}function jp({info:e}){let{t}=useTranslation(),r=e.isBid?Gs:qs,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:Qr(Math.round(e.cumTotal))})}),jsxs("div",{style:{color:r},children:["$",Qr(Math.round(e.cumCost))]})]})}var Gp=memo(function({slot:t,onEnter:r,onLeave:n}){let o=useRef(null),i=t.isBid||t.isAsk,s=t.isBid?Gs:t.isAsk?qs: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}})})}),qp=[0,10,20,30,40,50,60,70,80,90,100];function Yp(){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:qp.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 Ys({bids:e,asks:t}){let{t:r}=useTranslation(),n=useMemo(()=>Vp(e,t),[e,t]),o=useMemo(()=>{let m=e.length>0?Math.max(...e.map(d=>d.price)):0,p=t.length>0?Math.min(...t.map(d=>d.price)):1;return Math.round((m+p)/2*100)},[e,t]),i=useMemo(()=>n.some(m=>m.isBid||m.isAsk),[n]),[s,a]=useState(null),l=useRef(null),c=useCallback((m,p)=>{l.current&&(l.current.style.filter=""),p?(p.style.filter="brightness(1.5)",l.current=p):l.current=null,m.isBid||m.isAsk?a({priceCents:m.priceCents,isBid:m.isBid,cumTotal:m.isBid?m.bidCumTotal:m.askCumTotal,cumCost:m.isBid?m.bidCumCost:m.askCumCost,leftPct:m.priceCents}):a(null);},[]),u=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(jp,{info:s}),n.map(m=>jsx(Gp,{slot:m,onEnter:c,onLeave:u},m.priceCents))]}),jsx(Yp,{})]}):jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:r("predict.orderBook.noData")})}function Ho(e){let t=e*100,r=Math.round(t*10)/10;return Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`}function Xs(){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 ta({market:e,outcome:t="yes",onTradeAction:r,initialViewMode:n="depth",className:o}){let{t:i}=useTranslation(),[s,a]=useState(n),l=e.source,{data:c,isLoading:u,isFetching:m,refetch:p}=useRealtimeOrderbook({slug:e.slug,source:l,outcome:t}),d=useMemo(()=>(c?.bids??[]).map(b=>({price:b.price,quantity:b.size})),[c?.bids]),f=useMemo(()=>(c?.asks??[]).map(b=>({price:b.price,quantity:b.size})),[c?.asks]),v=useMemo(()=>d.length>0?Math.max(...d.map(b=>b.price)):null,[d]),g=useMemo(()=>f.length>0?Math.min(...f.map(b=>b.price)):null,[f]),x=useMemo(()=>{if(v==null||g==null)return null;let b=(g-v)*100;return Math.round(b*10)/10},[v,g]);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:x!=null?`${i("predict.orderBook.spread")}: ${Number.isInteger(x)?`${x}\xA2`:`${x.toFixed(1)}\xA2`}`:null}),jsxs("span",{className:"flex flex-1 items-center justify-center gap-x-1 whitespace-nowrap",children:[v!=null&&jsxs("span",{style:{color:"var(--color-bullish)"},children:[i("predict.trade.bestBid"),": ",Ho(v)]}),v!=null&&g!=null&&jsx("span",{className:"text-neutral",children:"|"}),g!=null&&jsxs("span",{style:{color:"var(--color-bearish)"},children:[i("predict.trade.bestAsk"),": ",Ho(g)]})]}),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(b=>b==="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:()=>p(),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:u?jsx(Xs,{}):jsx(Ys,{bids:d,asks:f})}),s==="table"&&jsx(Fragment,{children:u?jsx(Xs,{}):jsx(rm,{bids:d,asks:f,bestBid:v??void 0,bestAsk:g??void 0,spread:x??void 0})})]})]})}var Bo=4,tm=8;function rm({bids:e,asks:t,spread:r}){let{t:n}=useTranslation(),[o,i]=useState(false),s=o?tm:Bo,a=t.length>Bo||e.length>Bo,l=useMemo(()=>[...t].sort((p,d)=>p.price-d.price).slice(0,s).reverse(),[t,s]),c=useMemo(()=>[...e].sort((p,d)=>d.price-p.price).slice(0,s),[e,s]),u=useMemo(()=>{let p=[...l,...c].map(d=>d.quantity);return Math.max(...p,1)},[l,c]);return l.length===0&&c.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:[l.map(p=>jsx(Js,{price:p.price,quantity:p.quantity,side:"ask",maxQty:u},`ask-${p.price}`)),jsxs("div",{className:"relative flex items-center justify-center gap-x-2 py-1 border-y border-border text-neutral text-[10px]",children:[r!=null&&jsxs("span",{children:[n("predict.orderBook.spread"),":"," ",Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`]}),a&&jsx("button",{type:"button",onClick:()=>i(p=>!p),className:"absolute right-2 text-[10px] text-neutral transition-colors cursor-pointer hover:text-foreground",children:n(o?"predict.orderBook.collapse":"predict.orderBook.expand")})]}),c.map(p=>jsx(Js,{price:p.price,quantity:p.quantity,side:"bid",maxQty:u},`bid-${p.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=Qr(Math.round(t)),c=Math.round(t*e),u=`$${Qr(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:Ho(e)}),jsx("span",{className:"relative z-10 text-foreground text-center",children:l}),jsx("span",{className:"relative z-10 text-foreground text-right",children:u})]})}var Uo=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}},Xr=4,ra=["#22d3ee","#a3e635","#f97316","#f472b6","#a78bfa"];function fm(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 gm(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 oa(e){return `${(e*100).toFixed(2)}%`}var hm=[{range:ie.ONE_DAY,label:"1D"},{range:ie.ONE_WEEK,label:"1W"},{range:ie.ONE_MONTH,label:"1M"},{range:ie.ALL,label:"ALL"}];function vm({value:e,onChange:t}){return jsx("div",{style:{display:"flex",alignItems:"center",gap:2},children:hm.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 xm(){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 bm({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"?gm(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?oa(l.value):"--"})]},l.dataKey))]})}function ym({markets:e,selectedSlugs:t,colorMap:r,onToggle:n}){let[o,i]=useState(false),s=useRef(null);useEffect(()=>{if(!o)return;function c(u){s.current&&!s.current.contains(u.target)&&i(false);}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[o]);let a=t.length>=Xr,l=jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},children:[jsx("div",{style:{display:"flex",gap:3,flexShrink:0},children:t.map(c=>jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:r.get(c)??"#6b7280",display:"inline-block"}},c))}),jsx("span",{style:{color:"#e5e7eb",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.length===1?(()=>{let c=e.find(u=>u.slug===t[0]);return c?.outcomes?.[0]?.label??c?.question??"1 market"})():`${t.length} / ${e.length} markets`})]});return jsxs("div",{ref: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 ",Xr," markets"]}),e.map((c,u)=>{let m=t.includes(c.slug),p=!m&&a,d=m&&t.length===1,f=r.get(c.slug)??"#6b7280",v=c.outcomes.find(x=>x.label.toLowerCase()==="yes")??c.outcomes[0],g=v?.price!=null?`${Math.round(v.price*100)}%`:null;return jsxs("button",{onClick:()=>{d||p||n(c.slug);},style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"7px 12px",border:"none",background:m?"rgba(255,255,255,0.05)":"transparent",cursor:p||d?"not-allowed":"pointer",opacity:p?.35:1,textAlign:"left",transition:"background 0.1s"},onMouseEnter:x=>{!p&&!d&&(x.currentTarget.style.background="rgba(255,255,255,0.07)");},onMouseLeave:x=>{x.currentTarget.style.background=m?"rgba(255,255,255,0.05)":"transparent";},children:[jsx("span",{style:{width:16,height:16,borderRadius:4,border:m?`2px solid ${f}`:"2px solid rgba(255,255,255,0.2)",background:m?`${f}30`:"transparent",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:m&&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:m?"#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??`${u}-${c.slug}`)})]})]})}function km({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?oa(i):"--"})]})]},n.marketSlug)})})}function Sm(e){let t=Math.floor(e.length/2);return e.length%2===1?e[t]:(e[t-1]+e[t])/2}function wm(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,u)=>c-u);r.push({timestamp:a[a.length-1].timestamp,price:Sm(l)});}return r}function Pm(e,t=200){if(e.length===0)return [];let r=e.map(a=>({...a,data:wm(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:u})=>{let m=u.get(a);if(m!==void 0)s.set(c,m),l[c]=m;else {let p=s.get(c);p!==void 0&&(l[c]=p);}}),l})}function ia(e){return jsx(Uo,{children:jsx(Nm,{...e})})}function Nm({event:e,isLoading:t,className:r,volume:n,fillHeight:o=false}){let i=useMemo(()=>{let y=new Set;return (e.markets??[]).filter(k=>k.status!=="open"||y.has(k.slug)?false:(y.add(k.slug),true))},[e.markets]),s=useMemo(()=>[...i].sort((y,k)=>{let H=V=>(V.outcomes.find(Q=>Q.label.toLowerCase()==="yes")??V.outcomes[0])?.price??0;return H(k)-H(y)}),[i]),[a,l]=useState(()=>s.slice(0,Xr).map(y=>y.slug));useEffect(()=>{let y=new Set(i.map(k=>k.slug));l(k=>{let H=k.filter(V=>y.has(V));return H.length===k.length?k:H.length>0?H:s.slice(0,Xr).map(V=>V.slug)});},[i,s]);let[c,u]=useState(yn),m=useMemo(()=>{let y=new Map;return a.forEach((k,H)=>{y.set(k,ra[H%ra.length]);}),y},[a]),p=useMemo(()=>i.filter(y=>a.includes(y.slug)),[i,a]),{series:d,isLoading:f}=useMarketHistory(p,c),v=t||f,g=useMemo(()=>{if(d.length>0&&d.some(H=>H.data.length>0))return d;let y=Date.now(),k=864e5;return p.map(H=>{let Q=(H.outcomes?.find(se=>se.label.toLowerCase()==="yes")??H.outcomes?.[0])?.price??.5;return {marketSlug:H.slug,label:H.outcomes?.[0]?.label??H.question,data:[{timestamp:y-7*k,price:Q},{timestamp:y,price:Q}]}})},[d,p]),x=useMemo(()=>c===ie.ONE_DAY?96:c===ie.ONE_WEEK?168:c===ie.ONE_MONTH?180:300,[c]),b=useMemo(()=>Pm(g,x),[g,x]),P=useMemo(()=>{if(b.length===0)return [0,1];let y=1/0,k=-1/0;if(a.forEach(V=>{b.forEach(Q=>{let se=Q[V];se!=null&&(se<y&&(y=se),se>k&&(k=se));});}),!isFinite(y))return [0,1];let H=Math.max((k-y)*.15,.05);return [Math.max(0,y-H),Math.min(1,k+H)]},[b,a]),S=useMemo(()=>{let y=new Map;return g.forEach(k=>{k.data.length>0&&y.set(k.marketSlug,k.data[k.data.length-1].price);}),y},[g]),h=useMemo(()=>{let y=new Map;return g.forEach(k=>y.set(k.marketSlug,k.label)),y},[g]),N=useMemo(()=>g.map(y=>({slug:y.marketSlug,color:m.get(y.marketSlug)??"#6b7280"})),[g,m]),{wrapperRef:w,overlayRef:E,onMouseMove:T,onMouseLeave:_}=xm(),G=useCallback(y=>{l(k=>k.includes(y)?k.length<=1?k:k.filter(H=>H!==y):k.length>=Xr?k:[...k,y]);},[]),[D,K]=useState(null),W=useRef(null),oe=useRef(""),le=useRef(0),J=!v&&b.length>0;return jsxs("div",{className:r,style:{display:"flex",flexDirection:"column",gap:12,...o?{height:"100%",minHeight:0}:null},children:[jsx(km,{series:g,colorMap:m,displayValues:D??S}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,...o?{flex:1,minHeight:0}:null},children:[jsx("div",{ref:w,style:{width:"100%",userSelect:"none",position:"relative",...o?{flex:1,minHeight:240}:{height:300}},onMouseMove:J?y=>{T(y),cancelAnimationFrame(le.current),le.current=requestAnimationFrame(()=>{K(W.current);});}:void 0,onMouseLeave:J?()=>{_(),cancelAnimationFrame(le.current),oe.current="",W.current=null,K(null);}:void 0,children:v?jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:jsx("div",{style:{width:28,height:28,borderRadius:"50%",border:"2.5px solid #22d3ee",borderTopColor:"transparent",animation:"spin 0.7s linear infinite"}})}):b.length===0?jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:"No price history data"}):jsxs(Fragment,{children:[jsx("div",{ref:E,style:{position:"absolute",inset:0,opacity:0,pointerEvents:"none",zIndex:1}}),jsx(ResponsiveContainer,{width:"100%",height:"100%",children:jsxs(LineChart,{data:b,margin:{top:8,right:16,left:0,bottom:0},children:[jsx(CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"#374151",opacity:.5}),jsx(XAxis,{dataKey:"timestamp",type:"number",scale:"time",domain:["dataMin","dataMax"],tickFormatter:y=>fm(y,c),axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},minTickGap:70}),jsx(YAxis,{domain:P,tickFormatter:y=>`${Math.round(y*100)}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},width:40,tickCount:6}),jsx(Tooltip,{content:y=>{let k=y;if(k.active&&k.payload?.length){let H=k.payload.map(V=>`${V.dataKey}:${V.value}`).join(",");if(H!==oe.current){oe.current=H;let V=new Map;k.payload.forEach(Q=>{Q.value!=null&&V.set(Q.dataKey,Q.value);}),W.current=V;}}return jsx(bm,{...k,labelMap:h,allSeries:N,range:c})},cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},wrapperStyle:{zIndex:2},isAnimationActive:false}),g.map(y=>{let k=m.get(y.marketSlug)??"#6b7280";return jsx(Line,{type:"linear",dataKey:y.marketSlug,stroke:k,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:k},connectNulls:true,isAnimationActive:false},y.marketSlug)}),D==null&&b.length>0&&g.map(y=>{let k=b[b.length-1],H=k[y.marketSlug];if(H==null)return null;let V=m.get(y.marketSlug)??"#6b7280";return jsx(ReferenceDot,{x:k.timestamp,y:H,ifOverflow:"extendDomain",shape:Q=>{let{cx:se,cy:ve}=Q;return se==null||ve==null?jsx("g",{}):jsxs("g",{children:[jsxs("circle",{cx:se,cy:ve,r:6,fill:V,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:se,cy:ve,r:3.5,fill:V})]})}},`pulse-${y.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(vm,{value:c,onChange:u}),s.length>1&&jsx("div",{style:{width:"100%",display:"flex",alignItems:"center"},children:jsx(ym,{markets:s,selectedSlugs:a,colorMap:m,onToggle:G})})]})]})]})}function Un(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function aa(e,t){let r=e.outcomes[t==="yes"?0:1];return r?.best_ask??r?.price}function Wm(e){return `${parseFloat((e*100).toFixed(2))}%`}function la(e){let t=e*100;return t<1&&t>0?"< 1":parseFloat(t.toFixed(2)).toString()}function $n(e){return e.outcomes?.[0]?.label??e.question}function Um(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 ca(e){let[t,r]=useState(0);if(useEffect(()=>{if(!e)return;r(Date.now());let u=setInterval(()=>r(Date.now()),1e3);return ()=>clearInterval(u)},[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 da(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 fa({event:e,onTradeAction:t}){let{t:r}=useTranslation(),{ref:n,isCollapsed:o}=useScrollCollapse(),i=useMemo(()=>{let m=[...e.markets||[]],p=m.filter(f=>f.status==="open").sort((f,v)=>Un(v)-Un(f)),d=m.filter(f=>f.status!=="open").sort((f,v)=>Un(v)-Un(f));return [...p,...d]},[e.markets]),s=e.status==="closed"||e.status==="voided",a=ca(s?void 0:e.start_at),l=ca(s?void 0:e.end_at),c=da(e.start_at),u=da(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((m,p)=>jsxs(Fragment$1,{children:[p>0&&jsx("span",{className:"text-sm text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-sm text-neutral truncate",children:m.label})]},m.slug)),jsx(jm,{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?u&&jsx("span",{className:"text-neutral",children:r("predict.event.endedAt",{time:u})}):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})}),u&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-neutral",children:u})]})]}):null}),jsx(ia,{event:e,volume:e.volume??void 0}),jsx($m,{markets:i,onTradeAction:t}),jsx(Vm,{markets:i,event:e})]})}var ua=5;function $m({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(x=>g.has(x.slug)?false:(g.add(x.slug),true))},[e]),c=l.find(g=>g.status==="open")?.slug,[u,m]=useState(c?`${c}:yes`:null);if(l.length===0)return null;let p=l.length>ua,d=o?l:l.slice(0,ua),f=g=>{a(x=>x===g?null:g);},v=(g,x,b)=>{m(`${g.slug}:${x}`),n&&a(g.slug),t?.(g,x,b);};return jsxs("div",{className:"flex flex-col",children:[jsxs("table",{className:"w-full border-collapse",children:[jsx("thead",{children:jsxs("tr",{children:[jsx("th",{}),jsx("th",{className:"py-2 text-left text-xs text-neutral font-normal lg:text-center lg:text-sm",children:r("predict.market.table.chance")}),jsx("th",{})]})}),jsx("tbody",{children:d.map((g,x)=>{let b=s===g.slug;return jsx(Km,{market:g,activeYes:u===`${g.slug}:yes`,activeNo:u===`${g.slug}:no`,isExpanded:b,onToggleExpand:()=>f(g.slug),onTradeAction:v},g.id??`${x}-${g.slug}`)})})]}),p&&jsxs("button",{type:"button",onClick:()=>i(g=>!g),className:"flex w-full items-center justify-start gap-x-2 py-2 pl-1 text-xs text-neutral lg:pl-2 lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsx("span",{children:r(o?"predict.event.rules.collapse":"predict.event.moreMarketsLabel")}),jsx(ChevronDownIcon,{className:cn("h-4 w-4 transition-transform",o&&"rotate-180")})]})]})}function Km({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,outcome:"yes"},{enabled:a}),{data:u}=useOrderbook({slug:e.slug,source:e.source,outcome:"no"},{enabled:false,refetchInterval:false}),m=pickBestAsk(c,"yes")??aa(e,"yes")??0,p=pickBestAsk(u,"no")??aa(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:d=>{(d.key==="Enter"||d.key===" ")&&(d.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:$n(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:$n(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:Wm(m)}),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:d=>{d.stopPropagation(),i?.(e,"yes","buy");},children:s("predict.market.action.yes",{price:la(m)})}),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:d=>{d.stopPropagation(),i?.(e,"no","buy");},children:p!=null?s("predict.market.action.no",{price:la(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(ta,{market:e,outcome:r?"no":"yes",onTradeAction:i})})})})]})}function Vm({markets:e,event:t}){let{t:r}=useTranslation(),[n,o]=useState(false),[i,s]=useState(false),[a,l]=useState(0),c=e.filter(d=>d.rules&&d.rules.length>0||d.description);if(c.length===0)return null;let u=c[a]??c[0],m=u.rules&&u.rules.length>0?u.rules.join(`
76
+ `,Ks={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 fe(e){return {...Ks,animationDelay:`${e}ms`}}function Zr({marketCount:e=4,showBack:t}){return jsxs(Fragment,{children:[jsx("style",{children:$s}),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:{...Ks,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:{...fe(0),height:14,width:48}}),jsx("div",{style:{...fe(30),height:14,width:40}}),jsx("div",{style:{...fe(60),height:14,width:40}})]}),jsx("div",{style:{...fe(80),height:20,width:"80%",maxWidth:384,borderRadius:4}})]})]}),jsx("div",{style:{...fe(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:{...fe(120),height:16,width:96}}),jsx("div",{style:{...fe(140),height:16,width:80}})]}),jsx("div",{style:{...fe(160),height:300,width:"100%",borderRadius:12}}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[jsx("div",{style:{...fe(180),height:16,width:80}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsx("div",{style:{...fe(200),height:28,width:200,borderRadius:8}}),jsx("div",{style:{...fe(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:{...fe(240),height:14,width:56}})}),Array.from({length:e}).map((r,o)=>jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 0",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsx("div",{style:{...fe(260+o*40),width:28,height:28,borderRadius:8,flexShrink:0}}),jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:4},children:[jsx("div",{style:{...fe(280+o*40),height:14,width:o%2===0?192:160}}),jsx("div",{style:{...fe(300+o*40),height:10,width:64}})]}),jsx("div",{style:{...fe(320+o*40),height:16,width:40}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsx("div",{style:{...fe(340+o*40),height:32,width:80,borderRadius:8}}),jsx("div",{style:{...fe(360+o*40),height:32,width:80,borderRadius:8}})]})]},o))]}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[jsx("div",{style:{...fe(400),height:16,width:64}}),jsx("div",{style:{...fe(420),height:14,width:"100%"}}),jsx("div",{style:{...fe(440),height:14,width:"80%"}}),jsx("div",{style:{...fe(460),height:14,width:"60%"}})]})]})]})}function Vs(){return jsxs(Fragment,{children:[jsx("style",{children:$s}),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:{...fe(0),height:40,width:"100%",borderRadius:8}}),jsx("div",{style:{...fe(60),height:96,width:"100%",borderRadius:8}}),jsx("div",{style:{...fe(120),height:40,width:"100%",borderRadius:8}})]})]})}var Qs="var(--color-bullish)",Xs="var(--color-bearish)";function en(e){let t=Math.abs(e);return t>=1e9?`${parseFloat((e/1e9).toFixed(2))}B`:t>=1e6?`${parseFloat((e/1e6).toFixed(2))}M`:t>=1e3?`${parseFloat((e/1e3).toFixed(2))}K`:e.toLocaleString()}function Gp(e,t){return e<=0||t<=0?0:Math.pow(e/t,.3)}function Yp(e,t){let r=new Float64Array(101),o=new Float64Array(101);for(let c of e){let f=Math.round(c.price*100);f>=0&&f<=100&&(r[f]+=c.quantity);}for(let c of t){let f=Math.round(c.price*100);f>=0&&f<=100&&(o[f]+=c.quantity);}let n=0,i=0,s=new Float64Array(101),a=new Float64Array(101);for(let c=100;c>=0;c--)n+=r[c],i+=r[c]*c/100,s[c]=n,a[c]=i;let l=0,d=0,u=new Float64Array(101),p=new Float64Array(101);for(let c=0;c<=100;c++)l+=o[c],d+=o[c]*c/100,u[c]=l,p[c]=d;let m=Math.max(s[0]??0,u[100]??0);return Array.from({length:101},(c,f)=>{let g=s[f]>0,v=u[f]>0,x=s[f]||u[f],b=r[f]>0||o[f]>0;return {priceCents:f,displayHeight:Gp(x,m),opacity:x>0?b?1:.5:0,isBid:g,isAsk:v,bidCumTotal:s[f],askCumTotal:u[f],bidCumCost:a[f],askCumCost:p[f]}})}function Qp({info:e}){let{t}=useTranslation(),r=e.isBid?Qs:Xs,o=e.leftPct>65?void 0:`${e.leftPct}%`,n=e.leftPct>65?`${100-e.leftPct}%`:void 0;return jsxs("div",{style:{position:"absolute",top:8,left:o,right:n,zIndex:10,background:"rgba(17,24,39,0.95)",border:"1px solid rgba(255,255,255,0.08)",borderRadius:8,padding:"8px 12px",fontSize:12,color:"#f9fafb",minWidth:140,pointerEvents:"none"},children:[jsx("div",{style:{marginBottom:4,fontWeight:600},children:t("predict.orderBook.depthToPrice",{price:e.priceCents})}),jsx("div",{style:{color:r},children:t("predict.orderBook.depthContracts",{amount:en(Math.round(e.cumTotal))})}),jsxs("div",{style:{color:r},children:["$",en(Math.round(e.cumCost))]})]})}var Xp=memo(function({slot:t,onEnter:r,onLeave:o}){let n=useRef(null),i=t.isBid||t.isAsk,s=t.isBid?Qs:t.isAsk?Xs:void 0;return jsx("div",{style:{position:"absolute",left:`${t.priceCents}%`,width:"1%",height:"100%",boxSizing:"border-box",borderRight:t.priceCents<100?"1px solid transparent":"none",cursor:i?"crosshair":"default"},onMouseEnter:()=>r(t,n.current),onMouseLeave:o,children:i&&jsx("div",{ref:n,style:{position:"absolute",bottom:0,left:0,width:"100%",height:`${t.displayHeight*100}%`,backgroundColor:s,opacity:t.opacity}})})}),Jp=[0,10,20,30,40,50,60,70,80,90,100];function Zp(){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:Jp.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 Js({bids:e,asks:t}){let{t:r}=useTranslation(),o=useMemo(()=>Yp(e,t),[e,t]),n=useMemo(()=>{let p=e.length>0?Math.max(...e.map(c=>c.price)):0,m=t.length>0?Math.min(...t.map(c=>c.price)):1;return Math.round((p+m)/2*100)},[e,t]),i=useMemo(()=>o.some(p=>p.isBid||p.isAsk),[o]),[s,a]=useState(null),l=useRef(null),d=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);},[]),u=useCallback(()=>{l.current&&(l.current.style.filter="",l.current=null),a(null);},[]);return i?jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",userSelect:"none",overflow:"hidden"},children:[jsxs("div",{style:{flex:1,position:"relative",width:"100%",overflow:"hidden"},children:[n>0&&jsx("div",{style:{position:"absolute",left:`${n}%`,top:0,bottom:0,width:1,backgroundImage:"repeating-linear-gradient(to bottom, #6b7280 0, #6b7280 4px, transparent 4px, transparent 8px)",zIndex:1,pointerEvents:"none"}}),s&&jsx(Qp,{info:s}),o.map(p=>jsx(Xp,{slot:p,onEnter:d,onLeave:u},p.priceCents))]}),jsx(Zp,{})]}):jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:r("predict.orderBook.noData")})}function $o(e){let t=e*100,r=Math.round(t*10)/10;return Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`}function ea(){let{t:e}=useTranslation();return jsx("div",{className:"absolute inset-0 flex items-center justify-center text-neutral text-xs",children:jsx("span",{children:e("predict.orderBook.loading")})})}function oa({market:e,outcome:t="yes",onTradeAction:r,initialViewMode:o="depth",className:n}){let{t:i}=useTranslation(),[s,a]=useState(o),l=e.source,{data:d,isLoading:u,isFetching:p,refetch:m}=useRealtimeOrderbook({slug:e.slug,source:l,outcome:t}),c=useMemo(()=>(d?.bids??[]).map(b=>({price:b.price,quantity:b.size})),[d?.bids]),f=useMemo(()=>(d?.asks??[]).map(b=>({price:b.price,quantity:b.size})),[d?.asks]),g=useMemo(()=>c.length>0?Math.max(...c.map(b=>b.price)):null,[c]),v=useMemo(()=>f.length>0?Math.min(...f.map(b=>b.price)):null,[f]),x=useMemo(()=>{if(g==null||v==null)return null;let b=(v-g)*100;return Math.round(b*10)/10},[g,v]);return jsxs("div",{className:cn$1("flex flex-col",n??"h-[262px]"),children:[jsxs("div",{className:"flex h-9 items-center border-b border-border px-1 text-xs",children:[jsx("span",{className:"flex-1 text-left text-neutral",children:x!=null?`${i("predict.orderBook.spread")}: ${Number.isInteger(x)?`${x}\xA2`:`${x.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"),": ",$o(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"),": ",$o(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(b=>b==="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:()=>m(),disabled:p,className:cn$1("flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground disabled:cursor-default disabled:opacity-50",p&&"animate-spin"),children:jsx(RefreshIcon,{className:"h-4 w-4"})})]})]}),jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[s==="depth"&&jsx(Fragment,{children:u?jsx(ea,{}):jsx(Js,{bids:c,asks:f})}),s==="table"&&jsx(Fragment,{children:u?jsx(ea,{}):jsx(im,{bids:c,asks:f,bestBid:g??void 0,bestAsk:v??void 0,spread:x??void 0})})]})]})}var Uo=4,om=8;function im({bids:e,asks:t,spread:r}){let{t:o}=useTranslation(),[n,i]=useState(false),s=n?om:Uo,a=t.length>Uo||e.length>Uo,l=useMemo(()=>[...t].sort((m,c)=>m.price-c.price).slice(0,s).reverse(),[t,s]),d=useMemo(()=>[...e].sort((m,c)=>c.price-m.price).slice(0,s),[e,s]),u=useMemo(()=>{let m=[...l,...d].map(c=>c.quantity);return Math.max(...m,1)},[l,d]);return l.length===0&&d.length===0?jsx("div",{className:"flex items-center justify-center h-full text-xs text-neutral",children:o("predict.orderBook.empty")}):jsxs("div",{className:"flex flex-col h-full overflow-y-auto text-xs font-mono select-none",children:[l.map(m=>jsx(ta,{price:m.price,quantity:m.quantity,side:"ask",maxQty:u},`ask-${m.price}`)),jsxs("div",{className:"relative flex items-center justify-center gap-x-2 py-1 border-y border-border text-neutral text-[10px]",children:[r!=null&&jsxs("span",{children:[o("predict.orderBook.spread"),":"," ",Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`]}),a&&jsx("button",{type:"button",onClick:()=>i(m=>!m),className:"absolute right-2 text-[10px] text-neutral transition-colors cursor-pointer hover:text-foreground",children:o(n?"predict.orderBook.collapse":"predict.orderBook.expand")})]}),d.map(m=>jsx(ta,{price:m.price,quantity:m.quantity,side:"bid",maxQty:u},`bid-${m.price}`)),jsxs("div",{className:"grid grid-cols-3 px-2 pt-2 pb-0.5 text-[10px] text-neutral border-t border-border",children:[jsx("span",{children:o("predict.orderBook.price")}),jsx("span",{className:"text-center",children:o("predict.orderBook.contracts")}),jsx("span",{className:"text-right",children:o("predict.orderBook.total")})]})]})}function ta({price:e,quantity:t,side:r,maxQty:o}){let n=r==="ask",i=Math.min(t/o*100,100),s=n?"bg-bearish/10":"bg-bullish/10",a=n?"text-bearish":"text-bullish",l=en(Math.round(t)),d=Math.round(t*e),u=`$${en(d)}`;return jsxs("div",{className:"relative grid grid-cols-3 px-2 py-1 hover:bg-content2 transition-colors cursor-default",children:[jsx("div",{className:`absolute inset-y-0 left-0 ${s} transition-[width] duration-200`,style:{width:`${i}%`}}),jsx("span",{className:`relative z-10 ${a}`,children:$o(e)}),jsx("span",{className:"relative z-10 text-foreground text-center",children:l}),jsx("span",{className:"relative z-10 text-foreground text-right",children:u})]})}var jo=class extends Component{state={error:null};static getDerivedStateFromError(t){return {error:t}}componentDidCatch(t,r){}render(){return this.state.error?jsxs("div",{style:{height:this.props.fallbackHeight??320,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,color:"#6b7280",fontSize:13},children:[jsx("span",{children:"Chart unavailable"}),jsx("span",{style:{fontSize:11,opacity:.7},children:this.state.error.message})]}):this.props.children}},tn=4,ia=["#22d3ee","#a3e635","#f97316","#f472b6","#a78bfa"];function vm(e,t){let r=new Date(e);return t===ae.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function xm(e,t){let r=new Date(e);return t===ae.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):t===ae.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 aa(e){return `${(e*100).toFixed(2)}%`}var bm=[{range:ae.ONE_DAY,label:"1D"},{range:ae.ONE_WEEK,label:"1W"},{range:ae.ONE_MONTH,label:"1M"},{range:ae.ALL,label:"ALL"}];function ym({value:e,onChange:t}){return jsx("div",{style:{display:"flex",alignItems:"center",gap:2},children:bm.map(({range:r,label:o})=>{let n=r===e;return jsx("button",{onClick:()=>t(r),style:{padding:"2px 8px",border:"none",background:"transparent",color:n?"#f9fafb":"#6b7280",fontWeight:n?700:400,fontSize:12,cursor:"pointer",borderRadius:4,letterSpacing:"0.02em",transition:"color 0.15s",userSelect:"none"},children:o},r)})})}function km(){let e=useRef(null),t=useRef(null),r=useCallback(n=>{let i=e.current,s=t.current;if(!i||!s)return;let a=i.getBoundingClientRect(),l=(n.clientX-a.left)/a.width*100;s.style.background=`linear-gradient(to right, transparent ${l}%, rgba(0,0,0,0.55) ${l}%)`,s.style.opacity="1";},[]),o=useCallback(()=>{t.current&&(t.current.style.opacity="0");},[]);return {wrapperRef:e,overlayRef:t,onMouseMove:r,onMouseLeave:o}}function Sm({active:e,payload:t,label:r,labelMap:o,allSeries:n,range:i}){if(!e||!n?.length)return null;let s=new Map;t?.forEach(l=>s.set(l.dataKey,l));let a=n.map(l=>s.get(l.slug)??{dataKey:l.slug,value:void 0,stroke:l.color,color:l.color});return jsxs("div",{style:{background:"rgba(10,10,10,0.92)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:8,padding:"8px 12px",minWidth:180,backdropFilter:"blur(8px)",fontSize:12},children:[jsx("div",{style:{color:"#9ca3af",marginBottom:6,fontWeight:500},children:typeof r=="number"?xm(r,i):r}),a.map(l=>jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[jsx("span",{style:{display:"inline-block",width:3,height:14,borderRadius:2,background:l.stroke??l.color,flexShrink:0}}),jsx("span",{style:{color:"#9ca3af",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:120},children:o.get(l.dataKey)??l.dataKey}),jsx("span",{style:{color:"#f9fafb",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:l.value!=null?aa(l.value):"--"})]},l.dataKey))]})}function wm({markets:e,selectedSlugs:t,colorMap:r,onToggle:o}){let[n,i]=useState(false),s=useRef(null);useEffect(()=>{if(!n)return;function d(u){s.current&&!s.current.contains(u.target)&&i(false);}return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[n]);let a=t.length>=tn,l=jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},children:[jsx("div",{style:{display:"flex",gap:3,flexShrink:0},children:t.map(d=>jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:r.get(d)??"#6b7280",display:"inline-block"}},d))}),jsx("span",{style:{color:"#e5e7eb",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.length===1?(()=>{let d=e.find(u=>u.slug===t[0]);return d?.outcomes?.[0]?.label??d?.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(d=>!d),style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:8,border:"1px solid rgba(255,255,255,0.12)",background:"rgba(255,255,255,0.05)",cursor:"pointer",width:"100%",userSelect:"none"},children:[l,jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{flexShrink:0,transform:n?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.15s",color:"#6b7280"},children:jsx("path",{d:"M2 4l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),n&&jsxs("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,zIndex:50,background:"#111827",border:"1px solid rgba(255,255,255,0.1)",borderRadius:10,boxShadow:"0 8px 24px rgba(0,0,0,0.5)",minWidth:260,maxWidth:360,maxHeight:320,overflowY:"auto",padding:"6px 0"},children:[jsxs("div",{style:{padding:"4px 12px 8px",fontSize:11,color:"#6b7280",borderBottom:"1px solid rgba(255,255,255,0.06)",marginBottom:4},children:["Select up to ",tn," markets"]}),e.map((d,u)=>{let p=t.includes(d.slug),m=!p&&a,c=p&&t.length===1,f=r.get(d.slug)??"#6b7280",g=d.outcomes.find(x=>x.label.toLowerCase()==="yes")??d.outcomes[0],v=g?.price!=null?`${Math.round(g.price*100)}%`:null;return jsxs("button",{onClick:()=>{c||m||o(d.slug);},style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"7px 12px",border:"none",background:p?"rgba(255,255,255,0.05)":"transparent",cursor:m||c?"not-allowed":"pointer",opacity:m?.35:1,textAlign:"left",transition:"background 0.1s"},onMouseEnter:x=>{!m&&!c&&(x.currentTarget.style.background="rgba(255,255,255,0.07)");},onMouseLeave:x=>{x.currentTarget.style.background=p?"rgba(255,255,255,0.05)":"transparent";},children:[jsx("span",{style:{width:16,height:16,borderRadius:4,border:p?`2px solid ${f}`:"2px solid rgba(255,255,255,0.2)",background:p?`${f}30`:"transparent",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:p&&jsx("svg",{width:"9",height:"7",viewBox:"0 0 9 7",fill:"none",children:jsx("path",{d:"M1 3.5L3.5 6L8 1",stroke:f,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:f,flexShrink:0}}),jsx("span",{style:{color:p?"#f9fafb":"#9ca3af",fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d.outcomes?.[0]?.label??d.question}),v&&jsx("span",{style:{color:f,fontWeight:700,fontSize:12,flexShrink:0},children:v})]},d.id??`${u}-${d.slug}`)})]})]})}function Pm({series:e,colorMap:t,displayValues:r}){return jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px 24px",padding:"0 2px"},children:e.map(o=>{let n=t.get(o.marketSlug)??"#6b7280",i=r.get(o.marketSlug);return jsxs("div",{style:{display:"inline-flex",alignItems:"flex-start",gap:6},children:[jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:n,flexShrink:0,marginTop:3}}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:1},children:[jsx("span",{style:{color:"#9ca3af",fontSize:12,lineHeight:"17px",whiteSpace:"nowrap"},children:o.label}),jsx("span",{style:{color:"#f9fafb",fontSize:14,fontWeight:700,lineHeight:"20px",fontVariantNumeric:"tabular-nums"},children:i!=null?aa(i):"--"})]})]},o.marketSlug)})})}function Nm(e){let t=Math.floor(e.length/2);return e.length%2===1?e[t]:(e[t-1]+e[t])/2}function Cm(e,t){if(e.length<=t)return e;let r=[],o=e.length/t;for(let n=0;n<t;n++){let i=Math.floor(n*o),s=Math.min(Math.floor((n+1)*o),e.length),a=e.slice(i,s),l=a.map(d=>d.price).sort((d,u)=>d-u);r.push({timestamp:a[a.length-1].timestamp,price:Nm(l)});}return r}function Mm(e,t=200){if(e.length===0)return [];let r=e.map(a=>({...a,data:Cm(a.data,t)})),o=new Set;r.forEach(a=>a.data.forEach(l=>o.add(l.timestamp)));let n=Array.from(o).sort((a,l)=>a-l),i=r.map(a=>{let l=new Map;return a.data.forEach(d=>l.set(d.timestamp,d.price)),{slug:a.marketSlug,map:l}}),s=new Map;return n.map(a=>{let l={timestamp:a};return i.forEach(({slug:d,map:u})=>{let p=u.get(a);if(p!==void 0)s.set(d,p),l[d]=p;else {let m=s.get(d);m!==void 0&&(l[d]=m);}}),l})}function la(e){return jsx(jo,{children:jsx(Em,{...e})})}function Em({event:e,isLoading:t,className:r,volume:o,fillHeight:n=false}){let i=useMemo(()=>{let C=new Set;return (e.markets??[]).filter(M=>M.status!=="open"||C.has(M.slug)?false:(C.add(M.slug),true))},[e.markets]),s=useMemo(()=>[...i].sort((C,M)=>{let U=G=>(G.outcomes.find(k=>k.label.toLowerCase()==="yes")??G.outcomes[0])?.price??0;return U(M)-U(C)}),[i]),[a,l]=useState(()=>s.slice(0,tn).map(C=>C.slug));useEffect(()=>{let C=new Set(i.map(M=>M.slug));l(M=>{let U=M.filter(G=>C.has(G));return U.length===M.length?M:U.length>0?U:s.slice(0,tn).map(G=>G.slug)});},[i,s]);let[d,u]=useState(wn),p=useMemo(()=>{let C=new Map;return a.forEach((M,U)=>{C.set(M,ia[U%ia.length]);}),C},[a]),m=useMemo(()=>i.filter(C=>a.includes(C.slug)),[i,a]),{series:c,isLoading:f}=useMarketHistory(m,d),g=t||f,v=useMemo(()=>{if(c.length>0&&c.some(U=>U.data.length>0))return c;let C=Date.now(),M=864e5;return m.map(U=>{let k=(U.outcomes?.find(ce=>ce.label.toLowerCase()==="yes")??U.outcomes?.[0])?.price??.5;return {marketSlug:U.slug,label:U.outcomes?.[0]?.label??U.question,data:[{timestamp:C-7*M,price:k},{timestamp:C,price:k}]}})},[c,m]),x=useMemo(()=>d===ae.ONE_DAY?96:d===ae.ONE_WEEK?168:d===ae.ONE_MONTH?180:300,[d]),b=useMemo(()=>Mm(v,x),[v,x]),w=useMemo(()=>{if(b.length===0)return [0,1];let C=1/0,M=-1/0;if(a.forEach(G=>{b.forEach(k=>{let ce=k[G];ce!=null&&(ce<C&&(C=ce),ce>M&&(M=ce));});}),!isFinite(C))return [0,1];let U=Math.max((M-C)*.15,.05);return [Math.max(0,C-U),Math.min(1,M+U)]},[b,a]),P=useMemo(()=>{let C=new Map;return v.forEach(M=>{M.data.length>0&&C.set(M.marketSlug,M.data[M.data.length-1].price);}),C},[v]),h=useMemo(()=>{let C=new Map;return v.forEach(M=>C.set(M.marketSlug,M.label)),C},[v]),y=useMemo(()=>v.map(C=>({slug:C.marketSlug,color:p.get(C.marketSlug)??"#6b7280"})),[v,p]),{wrapperRef:S,overlayRef:N,onMouseMove:A,onMouseLeave:D}=km(),z=useCallback(C=>{l(M=>M.includes(C)?M.length<=1?M:M.filter(U=>U!==C):M.length>=tn?M:[...M,C]);},[]),[F,q]=useState(null),$=useRef(null),Q=useRef(""),re=useRef(0),Z=!g&&b.length>0;return jsxs("div",{className:r,style:{display:"flex",flexDirection:"column",gap:12,...n?{height:"100%",minHeight:0}:null},children:[jsx(Pm,{series:v,colorMap:p,displayValues:F??P}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,...n?{flex:1,minHeight:0}:null},children:[jsx("div",{ref:S,style:{width:"100%",userSelect:"none",position:"relative",...n?{flex:1,minHeight:240}:{height:300}},onMouseMove:Z?C=>{A(C),cancelAnimationFrame(re.current),re.current=requestAnimationFrame(()=>{q($.current);});}:void 0,onMouseLeave:Z?()=>{D(),cancelAnimationFrame(re.current),Q.current="",$.current=null,q(null);}:void 0,children:g?jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:jsx("div",{style:{width:28,height:28,borderRadius:"50%",border:"2.5px solid #22d3ee",borderTopColor:"transparent",animation:"spin 0.7s linear infinite"}})}):b.length===0?jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:"No price history data"}):jsxs(Fragment,{children:[jsx("div",{ref:N,style:{position:"absolute",inset:0,opacity:0,pointerEvents:"none",zIndex:1}}),jsx(ResponsiveContainer,{width:"100%",height:"100%",children:jsxs(LineChart,{data:b,margin:{top:8,right:16,left:0,bottom:0},children:[jsx(CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"#374151",opacity:.5}),jsx(XAxis,{dataKey:"timestamp",type:"number",scale:"time",domain:["dataMin","dataMax"],tickFormatter:C=>vm(C,d),axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},minTickGap:70}),jsx(YAxis,{domain:w,tickFormatter:C=>`${Math.round(C*100)}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},width:40,tickCount:6}),jsx(Tooltip,{content:C=>{let M=C;if(M.active&&M.payload?.length){let U=M.payload.map(G=>`${G.dataKey}:${G.value}`).join(",");if(U!==Q.current){Q.current=U;let G=new Map;M.payload.forEach(k=>{k.value!=null&&G.set(k.dataKey,k.value);}),$.current=G;}}return jsx(Sm,{...M,labelMap:h,allSeries:y,range:d})},cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},wrapperStyle:{zIndex:2},isAnimationActive:false}),v.map(C=>{let M=p.get(C.marketSlug)??"#6b7280";return jsx(Line,{type:"linear",dataKey:C.marketSlug,stroke:M,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:M},connectNulls:true,isAnimationActive:false},C.marketSlug)}),F==null&&b.length>0&&v.map(C=>{let M=b[b.length-1],U=M[C.marketSlug];if(U==null)return null;let G=p.get(C.marketSlug)??"#6b7280";return jsx(ReferenceDot,{x:M.timestamp,y:U,ifOverflow:"extendDomain",shape:k=>{let{cx:ce,cy:pe}=k;return ce==null||pe==null?jsx("g",{}):jsxs("g",{children:[jsxs("circle",{cx:ce,cy:pe,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:ce,cy:pe,r:3.5,fill:G})]})}},`pulse-${C.marketSlug}`)})]})})]})}),jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"6px 8px",marginTop:6},children:[o!=null&&o>0&&jsxs("span",{style:{color:"#6b7280",fontSize:12},children:[formatAmountInUsd(o)," vol"]}),jsx("div",{style:{flex:1,minWidth:0}}),jsx(ym,{value:d,onChange:u}),s.length>1&&jsx("div",{style:{width:"100%",display:"flex",alignItems:"center"},children:jsx(wm,{markets:s,selectedSlugs:a,colorMap:p,onToggle:z})})]})]})]})}function Vn(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function da(e,t){let r=e.outcomes[t==="yes"?0:1];return r?.best_ask??r?.price}function Km(e){return `${parseFloat((e*100).toFixed(2))}%`}function ua(e){let t=e*100;return t<1&&t>0?"< 1":parseFloat(t.toFixed(2)).toString()}function jn(e){return e.outcomes?.[0]?.label??e.question}function Vm(e){switch(e){case "polymarket":return "Polymarket";case "kalshi":return "Kalshi";default:return e}}function rn(e){if(!e)return "\u2014";let t=new Date(e);if(isNaN(t.getTime()))return "\u2014";let r=t.toLocaleString("default",{month:"short"}),o=t.getDate(),n=t.getFullYear(),i=t.getHours().toString().padStart(2,"0"),s=t.getMinutes().toString().padStart(2,"0");return `${r} ${o}, ${n} ${i}:${s}`}function pa(e){let[t,r]=useState(0);if(useEffect(()=>{if(!e)return;r(Date.now());let u=setInterval(()=>r(Date.now()),1e3);return ()=>clearInterval(u)},[e]),!e||t===0)return null;let o=new Date(e).getTime();if(isNaN(o))return null;let n=o-t;if(n<=0)return null;let i=Math.floor(n/864e5),s=Math.floor(n%864e5/36e5),a=Math.floor(n%36e5/6e4),l=Math.floor(n%6e4/1e3),d=[];return i>0&&d.push(`${i}d`),d.push(`${String(s).padStart(2,"0")}h`),d.push(`${String(a).padStart(2,"0")}m`),d.push(`${String(l).padStart(2,"0")}s`),d.join(" ")}function ma(e){if(!e)return null;let t=new Date(e);if(isNaN(t.getTime()))return null;let r=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0"),n=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getDate().toString().padStart(2,"0"),s=t.getFullYear(),a=-t.getTimezoneOffset(),l=a>=0?"+":"-",d=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${o} ${n}/${i}/${s} (${l}${d})`}function va({event:e,onTradeAction:t}){let{t:r}=useTranslation(),{ref:o,isCollapsed:n}=useScrollCollapse(),i=useMemo(()=>{let p=[...e.markets||[]],m=p.filter(f=>f.status==="open").sort((f,g)=>Vn(g)-Vn(f)),c=p.filter(f=>f.status!=="open").sort((f,g)=>Vn(g)-Vn(f));return [...m,...c]},[e.markets]),s=e.status==="closed"||e.status==="voided",a=pa(s?void 0:e.start_at),l=pa(s?void 0:e.end_at),d=ma(e.start_at),u=ma(e.end_at);return jsxs("div",{className:"w-full flex flex-col gap-y-4 lg:gap-y-6",children:[jsxs("div",{ref:o,className:`sticky top-0 z-30 flex items-center backdrop-blur-md transition-all duration-300 ${n?"h-14 lg:h-16 gap-x-2 py-2 px-1 lg:px-4 -mx-1 lg:-mx-4 shadow-sm":"h-16 lg:h-20 gap-x-2 lg:gap-x-4"}`,children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",classNames:{base:"bg-transparent"},className:`flex-shrink-0 transition-all duration-300 ${n?"!h-10 !w-10 lg:!h-12 lg:!w-12":"!h-16 !w-16 lg:!h-20 lg:!w-20"}`}),jsxs("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[!n&&jsxs("div",{className:"flex items-center gap-1.5",children:[e.tags?.slice(0,3).map((p,m)=>jsxs(Fragment$1,{children:[m>0&&jsx("span",{className:"text-sm text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-sm text-neutral truncate",children:p.label})]},p.slug)),jsx(Ym,{source:e.source})]}),jsx("span",{className:`font-semibold truncate transition-all duration-300 ${n?"text-sm lg:text-base":"text-lg lg:text-xl"}`,children:e.title})]})]}),(a||l||s)&&jsx("div",{className:"flex items-center gap-x-2 text-xs lg:text-sm font-mono",children:s?u&&jsx("span",{className:"text-neutral",children:r("predict.event.endedAt",{time:u})}):a?jsxs(Fragment,{children:[jsx("span",{className:"text-foreground",children:r("predict.event.beginsIn",{time:a})}),d&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-neutral",children:d})]})]}):l?jsxs(Fragment,{children:[jsx("span",{className:"text-foreground",children:r("predict.event.endsIn",{time:l})}),u&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-neutral",children:u})]})]}):null}),jsx(la,{event:e,volume:e.volume??void 0}),jsx(jm,{markets:i,onTradeAction:t}),jsx(Gm,{markets:i,event:e})]})}var fa=5;function jm({markets:e,onTradeAction:t}){let{t:r}=useTranslation(),{isDesktop:o}=useScreen(),[n,i]=useState(false),[s,a]=useState(null),l=useMemo(()=>{let v=new Set;return e.filter(x=>v.has(x.slug)?false:(v.add(x.slug),true))},[e]),d=l.find(v=>v.status==="open")?.slug,[u,p]=useState(d?`${d}:yes`:null);if(l.length===0)return null;let m=l.length>fa,c=n?l:l.slice(0,fa),f=v=>{a(x=>x===v?null:v);},g=(v,x,b)=>{p(`${v.slug}:${x}`),o&&a(v.slug),t?.(v,x,b);};return jsxs("div",{className:"flex flex-col",children:[jsxs("table",{className:"w-full border-collapse",children:[jsx("thead",{children:jsxs("tr",{children:[jsx("th",{}),jsx("th",{className:"py-2 text-left text-xs text-neutral font-normal lg:text-center lg:text-sm",children:r("predict.market.table.chance")}),jsx("th",{})]})}),jsx("tbody",{children:c.map((v,x)=>{let b=s===v.slug;return jsx(qm,{market:v,activeYes:u===`${v.slug}:yes`,activeNo:u===`${v.slug}:no`,isExpanded:b,onToggleExpand:()=>f(v.slug),onTradeAction:g},v.id??`${x}-${v.slug}`)})})]}),m&&jsxs("button",{type:"button",onClick:()=>i(v=>!v),className:"flex w-full items-center justify-start gap-x-2 py-2 pl-1 text-xs text-neutral lg:pl-2 lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsx("span",{children:r(n?"predict.event.rules.collapse":"predict.event.moreMarketsLabel")}),jsx(ChevronDownIcon,{className:cn$1("h-4 w-4 transition-transform",n&&"rotate-180")})]})]})}function qm({market:e,activeYes:t,activeNo:r,isExpanded:o,onToggleExpand:n,onTradeAction:i}){let{t:s}=useTranslation(),a=e.status==="open",l=e.volume?`${formatAmountInUsd(e.volume)} vol`:void 0,{data:d}=useRealtimeOrderbook({slug:e.slug,source:e.source,outcome:"yes"},{enabled:a}),{data:u}=useOrderbook({slug:e.slug,source:e.source,outcome:"no"},{enabled:false,refetchInterval:false}),p=pickBestAsk(d,"yes")??da(e,"yes")??0,m=pickBestAsk(u,"no")??da(e,"no");return jsxs(Fragment,{children:[jsxs("tr",{className:"cursor-pointer border-b border-border text-xs hover:bg-content2 lg:text-base",onClick:n,role:"button",tabIndex:0,onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),n());},children:[jsx("td",{className:"py-2 pl-1 lg:pl-2",children:jsxs("div",{className:"flex items-center gap-x-1 lg:gap-x-2",children:[e.image_url&&jsx(Avatar,{src:e.image_url,name:jn(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:jn(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:Km(p)}),jsx("td",{className:"py-2 pr-1 lg:pr-2",children:a?jsxs("div",{className:"flex items-center justify-end gap-x-2",children:[jsx("button",{type:"button",className:cn$1("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all focus-visible:outline-2 focus-visible:outline-primary/40 focus-visible:outline-offset-2",t?"bg-primary text-primary-foreground":"bg-primary/10 text-primary"),onClick:c=>{c.stopPropagation(),i?.(e,"yes","buy");},children:s("predict.market.action.yes",{price:ua(p)})}),jsx("button",{type:"button",className:cn$1("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all focus-visible:outline-2 focus-visible:outline-primary/40 focus-visible:outline-offset-2",r?"bg-secondary text-secondary-foreground":"bg-secondary/10 text-secondary"),onClick:c=>{c.stopPropagation(),i?.(e,"no","buy");},children:m!=null?s("predict.market.action.no",{price:ua(m)}):s("predict.market.no")})]}):jsx("div",{className:"flex items-center justify-end",children:jsx("span",{className:cn$1("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",e.status==="closed"?"bg-neutral/10 text-neutral":e.status==="voided"?"bg-warning/10 text-warning":"bg-primary/10 text-primary"),children:e.status==="closed"?s("predict.event.status.closed"):e.status==="voided"?s("predict.event.status.voided"):s("predict.event.status.pending")})})})]}),o&&jsx("tr",{children:jsx("td",{colSpan:3,className:"pb-3",children:jsx("div",{className:"max-h-100 overflow-y-auto",children:jsx(oa,{market:e,outcome:r?"no":"yes",onTradeAction:i})})})})]})}function Gm({markets:e,event:t}){let{t:r}=useTranslation(),[o,n]=useState(false),[i,s]=useState(false),[a,l]=useState(0),d=e.filter(c=>c.rules&&c.rules.length>0||c.description);if(d.length===0)return null;let u=d[a]??d[0],p=u.rules&&u.rules.length>0?u.rules.join(`
77
77
 
78
- `):u.description??"";if(!m)return null;let p=m.length>200&&!n?m.slice(0,200)+"...":m;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:$n(u)})}),jsx(DropdownMenu,{"aria-label":"Select market rules",selectionMode:"single",selectedKeys:[String(a)],onAction:d=>{l(Number(d)),o(false);},classNames:{list:"gap-1"},itemClasses:{base:"rounded-md px-3 h-8"},children:c.map((d,f)=>jsx(DropdownItem,{className:cn(f===a?"bg-content2 text-foreground":"text-neutral","data-[hover=true]:bg-content2 data-[hover=true]:text-foreground"),children:$n(d)},String(f)))})]})]}),jsx("div",{className:"text-xs text-foreground/80 lg:text-sm whitespace-pre-wrap",children:p}),m.length>200&&jsx("button",{type:"button",onClick:()=>o(d=>!d),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(d=>!d),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 d=u.status,f=[];return u.created_at&&f.push({label:r("predict.event.timeline.created"),value:Jr(u.created_at),isActive:true}),f.push({label:r("predict.event.timeline.open"),value:Jr(u.start_at),isActive:d!=="pending"}),d==="voided"?f.push({label:r("predict.event.timeline.voided"),value:Jr(u.closed_at??u.end_at),isActive:true}):d==="closed"?f.push({label:r("predict.event.timeline.closed"),value:Jr(u.closed_at??u.end_at),isActive:true}):f.push({label:r("predict.event.timeline.close"),value:Jr(u.end_at),isActive:false}),f})().map((d,f,v)=>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 ${d.isActive?"border-primary bg-primary":"border-border bg-transparent"}`}),f<v.length-1&&jsx("div",{className:"w-px flex-1 bg-border"})]}),jsxs("div",{className:`flex flex-col ${f<v.length-1?"pb-4":""}`,children:[jsx("span",{className:"text-xs font-medium text-foreground lg:text-sm",children:d.label}),jsx("span",{className:"text-xs text-neutral lg:text-sm",children:d.value})]})]},d.label))}),jsxs("div",{className:"flex flex-wrap items-center gap-x-3 text-xxs text-neutral mt-2 lg:text-xs",children:[jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.event"),":"]})," ",jsx("span",{className:"text-foreground",children:t.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.market"),":"]})," ",jsx("span",{className:"text-foreground",children:u.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.source"),":"]})," ",jsx("span",{className:"text-foreground",children:Um(u.source)})]})]})]})]})}function jm({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 ga({eventSlug:e,source:t,onTradeAction:r}){let{data:n,isLoading:o,error:i}=useEvent({slug:e,source:t});return o?jsx(Yr,{}):i||!n?jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:i?.message||"Event not found"}):jsx(fa,{event:n,onTradeAction:r})}var Xm={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}},Jm={label:"Unknown",color:"rgb(156, 163, 175)",bgColor:"rgba(156, 163, 175, 0.12)",icon:null};function Mt(e){return Xm[e]??Jm}function jy({source:e,className:t}){let r=Mt(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 va="rgba(39,39,42,0.6)",sf="rgba(63,63,70,0.8)";function af(e){return e==null?"-":formatAmountInUsd(e)}function ba({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(lf,{event:l,onClick:n,onHover:o},`${l.source}-${l.slug}`))})]})}function lf({event:e,onClick:t,onHover:r}){let{t:n}=useTranslation(),o=Mt(e.source),i=useMemo(()=>af(e.volume),[e.volume]),s=e.tags?.[0];return jsxs("button",{type:"button",onClick:()=>t?.(e),onMouseEnter:a=>{a.currentTarget.style.borderColor=sf,r?.(e);},onMouseLeave:a=>{a.currentTarget.style.borderColor=va;},style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",borderRadius:14,border:`1px solid ${va}`,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 Vn(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function v1({eventSlug:e,source:t,chain:r,walletAddress:n,onSimilarEventClick:o,onSimilarEventHover:i,onBack:s,renderActivitySection:a,onInsufficientBalance:l,slippageBps:c}){let{t:u}=useTranslation(),{isDesktop:m}=useScreen(),{onOpen:p}=useAsyncModal(Wr),{onOpen:d}=useAsyncModal(Lo),{data:f,isLoading:v}=useEvent({slug:e,source:t}),g=useMemo(()=>{let w=[...f?.markets||[]],E=w.filter(_=>_.status==="open").sort((_,G)=>Vn(G)-Vn(_)),T=w.filter(_=>_.status!=="open").sort((_,G)=>Vn(G)-Vn(_));return [...E,...T]},[f?.markets]),[x,b]=useState(null),P=useCallback((w,E,T)=>{b(_=>({market:w,outcome:E,side:T,version:(_?.version??0)+1})),!m&&f&&(T==="sell"?d({params:{event:f,market:w,initialOutcome:E,chain:r,slippageBps:c}}):p({params:{event:f,market:w,initialOutcome:E,chain:r,slippageBps:c,onInsufficientBalance:l}}));},[m,f,r,c,p,d,l]),S=x?.market??g[0];if(v){let w=!!s;return m?jsxs("div",{className:"flex w-full max-w-6xl mx-auto gap-x-4 lg:gap-x-6",children:[jsx("div",{className:"min-w-0 flex-1 max-w-3xl",children:jsx(Yr,{showBack:w})}),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(Us,{})})})]}):jsx(Yr,{showBack:w})}let h=x?`${x.market.slug}-${x.version}`:S?.slug??"default",N=x?.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:u("common.back")})}),jsx(ga,{eventSlug:e,source:t,onTradeAction:P})]}),jsxs("div",{className:"hidden flex-none w-md flex-col gap-y-4 lg:sticky lg:top-4 lg:flex lg:self-start",children:[S&&(N?jsx(An,{event:f,market:S,initialOutcome:x?.outcome,chain:r,slippageBps:c},h):jsx(En,{event:f,market:S,initialOutcome:x?.outcome,chain:r,slippageBps:c,onInsufficientBalance:l},h)),f&&jsx(ba,{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(Hs,{event:f,walletAddress:n})}),jsx(Tn,{}),jsx(As,{}),jsx(ys,{})]})}function ka(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Sf(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 P1=e=>{let{candlestickMarketSlugs:t,chartRange:r=yn,source:n}=e,o=usePredictClient(),i=useMemo(()=>Sf(r),[r]),{data:s,isLoading:a,error:l}=useEvent({slug:e.eventSlug,source:n}),c=useMemo(()=>{if(!s?.markets)return [];let f=new Set,v=s.markets.filter(x=>f.has(x.slug)?false:(f.add(x.slug),true));return (t&&t.length>0?t.slice(0,4).map(x=>v.find(b=>b.slug===x)).filter(x=>x!==void 0):[...v].sort((x,b)=>ka(b)-ka(x)).slice(0,4)).map(x=>x.slug)},[t,s?.markets]),u=useQueries({queries:c.map(f=>({queryKey:candlesticksQueryKey(f,i),queryFn:()=>o.listCandlesticks(f,i),enabled:c.length>0}))}),m=u.some(f=>f.isLoading),p=useMemo(()=>{let f=new Map;return c.forEach((v,g)=>{let x=u[g]?.error;x&&f.set(v,x);}),f},[c,u]),d=useMemo(()=>{let f=new Map;return c.forEach((v,g)=>{let x=u[g]?.data;x&&f.set(v,x);}),f},[c,u]);return {event:s,isEventLoading:a,eventError:l,candlestickParams:i,candlesticks:d,isCandlesticksLoading:m,candlestickErrors:p}};function Vo({comment:e,anonymousLabel:t,isReply:r=false}){let{profile:n}=e,o=n.name||n.pseudonym||t,i=useMemo(()=>Cf(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(wf,{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(Pf,{className:"size-3.5"}),jsx("span",{className:"text-xs tabular-nums",children:e.reaction_count})]})]})]})}function wf({src:e,name:t,className:r}){let n=t.trim().charAt(0).toUpperCase()||"?",o=useMemo(()=>Nf(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 Pf({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 Nf(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 Cf(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 Af={latest:{order:"createdAt",ascending:false},oldest:{order:"createdAt",ascending:true},mostLiked:{order:"reactionCount",ascending:false}},Pa={latest:"predict.comments.sortLatest",oldest:"predict.comments.sortOldest",mostLiked:"predict.comments.sortMostLiked"},Ff=["latest","oldest","mostLiked"],Bf=600,Hf=112;function zf({slug:e,source:t,limit:r=20,height:n,className:o}){let{t:i}=useTranslation(),[s,a]=useState("latest"),[l,c]=useState(false),u=Af[s],{data:m,isLoading:p,isFetchingNextPage:d,hasNextPage:f,fetchNextPage:v}=useInfiniteComments({slug:e,source:t,limit:r,order:u.order,ascending:u.ascending,holders_only:l}),g=useMemo(()=>m?.pages?.flatMap(_=>_.items)??[],[m?.pages]),x=useRef(null),{height:b}=useResizeObserver({ref:x}),P=n??(b||Bf),S=useDynamicRowHeight({defaultRowHeight:Hf,key:`${e}:${t}:${s}:${l}`}),h=g.length,N=h+(f?1:0),w=useCallback(_=>_<h,[h]),E=useCallback(async()=>{f&&!d&&await v();},[f,d,v]),T=useInfiniteLoader({isRowLoaded:w,loadMoreRows:E,rowCount:N,threshold:5});return jsxs("div",{className:cn("flex h-full w-full flex-col",o),children:[jsx(Uf,{sort:s,onSortChange:a,holdersOnly:l,onHoldersOnlyChange:c}),jsx("div",{className:"min-h-0 flex-auto overflow-hidden",ref:x,children:p?jsx($f,{}):g.length===0?jsx(Kf,{message:i("predict.comments.empty")}):jsx(List,{className:"no-scrollbar",style:{height:P},onRowsRendered:T,rowComponent:Wf,rowCount:N,rowHeight:S,rowProps:{comments:g,itemCount:h,anonymousLabel:i("predict.comments.anonymous")},overscanCount:4})})]})}function Wf({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(Vo,{comment:i,anonymousLabel:o,isReply:!!i.parent_comment_id})}):null}function Uf({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=u=>{a.current&&!a.current.contains(u.target)&&s(false);},c=u=>{u.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(Vf,{className:"size-3.5 text-neutral"}),jsx("span",{children:o(Pa[e])}),jsx(jf,{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:Ff.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(Pa[l])}),c&&jsx(Na,{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(Na,{className:"size-3 text-background"})}),o("predict.comments.holdersOnly")]})]})}function $f(){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 Kf({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 Vf({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 jf({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 Na({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 Yf=10,Qf=atomWithStorage("liberfi:predict_search_histories",[],void 0,{getOnInit:true});function Qn(){let[e,t]=useAtom(Qf),r=useCallback(o=>{let i=o.trim();i&&t(s=>{let a=s.filter(l=>l!==i);return [i,...a].slice(0,Yf)});},[t]),n=useCallback(()=>{t([]);},[t]);return {histories:e,addHistory:r,clearHistories:n}}function Ra({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 _a({onSelect:e,className:t}){let{histories:r,clearHistories:n}=Qn();return jsx(Ra,{className:cn(t),histories:r,onSelect:e,onClear:n})}function Ia({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 hg(e){return e==null?"-":formatAmountInUsd(e)}function Oa({event:e,href:t,LinkComponent:r,onSelect:n,onHover:o,className:i}){let{t:s}=useTranslation(),a=e.tags?.[0],l=Mt(e.source),c=useMemo(()=>hg(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:u=>{t&&n&&u.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 Da({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 Cg=64;function Ha({onSelect:e,getEventHref:t,LinkComponent:r,onHover:n,className:o,...i}){let{events:s,isLoading:a,isFetchingNextPage:l,hasNextPage:c,fetchNextPage:u}=Da(i),m=useRef(null),{height:p}=useResizeObserver({ref:m}),d=useCallback(x=>x<s.length,[s]),f=useCallback(async()=>{c&&!l&&await u();},[c,l,u]),v=useMemo(()=>c?s.length+1:s.length,[s,c]),g=useInfiniteLoader({isRowLoaded:d,loadMoreRows:f,rowCount:v,threshold:5});return a?jsx(Eg,{className:o}):s.length===0?jsx(Tg,{className:o}):jsx("div",{className:cn("w-full h-full flex flex-col",o),children:jsx("div",{className:"flex-auto min-h-0",ref:m,children:jsx(List,{className:"no-scrollbar",style:{height:p},onRowsRendered:g,rowComponent:Mg,rowCount:v,rowHeight:Cg,rowProps:{events:s,onSelect:e,getEventHref:t,LinkComponent:r,onHover:n},overscanCount:5})})})}function Mg({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(Oa,{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 Eg({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 Tg({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 $a({onKeywordChange:e}){let[t,r]=useState(""),[n,o]=useState(""),{addHistory:i}=Qn(),s=useCallbackRef(e),a=useCallbackRef(i),l=useMemo(()=>debounce(p=>{o(p),s(p),p&&a(p);},500),[s,a]),c=useCallback(p=>{r(p),l(p);},[l]),u=useCallback(p=>{l.cancel(),r(p),o(p),s(p),p&&a(p);},[l,s,a]),m=useCallback(()=>u(""),[u]);return {text:t,keyword:n,setText:c,setKeyword:u,clearKeyword:m}}function Ka({onKeywordChange:e,onSelectEvent:t,getEventHref:r,LinkComponent:n,onHover:o,onEscape:i,source:s}){let{text:a,keyword:l,setText:c,setKeyword:u,clearKeyword:m}=$a({onKeywordChange:e});return jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsx(Ia,{value:a,onValueChange:c,onClear:m,onEscape:i}),!l&&jsx(_a,{onSelect:u}),jsx(Ha,{className:"flex-auto min-h-0",keyword:l,onSelect:t,getEventHref:r,LinkComponent:n,onHover:o,source:s})]})}var Qo="predict-search";function hk({id:e=Qo}){return jsx(AsyncModal,{id:e,children:t=>jsx(Ug,{...t})})}function Ug({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 Nk({onSelectEvent:e,modalParams:t,className:r}){let{t:n}=useTranslation(),{isDesktop:o}=useScreen(),{onOpen:i,onClose:s}=useAsyncModal(Qo),a=useCallbackRef(e),l=useCallbackRef(async()=>{let u=await i({params:t});u&&a(u);}),c=useCallbackRef(()=>{s();});return useEffect(()=>{let u=m=>{let p=document.activeElement,d=!!p&&(p.tagName==="INPUT"||p.tagName==="TEXTAREA"||p.getAttribute("contenteditable")==="true");m.key==="/"&&!d&&(m.preventDefault(),l()),m.key==="Escape"&&(m.preventDefault(),c());};return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u);}},[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 Jo=[{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"}],tl=[{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}],Ja={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"},Za={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 Qg(e,t){if(!e)return "$5K+";let r=tl.find(n=>n.value===e);return r?r.labelKey?t(r.labelKey):r.label:`$${e}`}function rl({sortBy:e,onSortChange:t,sortAsc:r,onSortAscChange:n,minVolume:o,onMinVolumeChange:i,onRefresh:s}){let{t:a}=useTranslation(),[l,c]=useState(false),[u,m]=useState(false),[p,d]=useState(false),[f,v]=useState(false),g=useRef(null),x=useRef(null),b=Jo.find(h=>h.value===e)??Jo[0],P=useCallback(h=>{g.current&&!g.current.contains(h.target)&&c(false),x.current&&!x.current.contains(h.target)&&m(false);},[]);useEffect(()=>(document.addEventListener("mousedown",P),()=>document.removeEventListener("mousedown",P)),[P]);let S=useCallback(()=>{s?.(),v(true),setTimeout(()=>v(false),700);},[s]);return jsxs(Fragment,{children:[jsx("style",{children:`
78
+ `):u.description??"";if(!p)return null;let m=p.length>200&&!o?p.slice(0,200)+"...":p;return jsxs("div",{className:"flex flex-col gap-y-3",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-semibold text-foreground lg:text-base",children:r("predict.event.rules")}),d.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:jn(u)})}),jsx(DropdownMenu,{"aria-label":"Select market rules",selectionMode:"single",selectedKeys:[String(a)],onAction:c=>{l(Number(c)),n(false);},classNames:{list:"gap-1"},itemClasses:{base:"rounded-md px-3 h-8"},children:d.map((c,f)=>jsx(DropdownItem,{className:cn$1(f===a?"bg-content2 text-foreground":"text-neutral","data-[hover=true]:bg-content2 data-[hover=true]:text-foreground"),children:jn(c)},String(f)))})]})]}),jsx("div",{className:"text-xs text-foreground/80 lg:text-sm whitespace-pre-wrap",children:m}),p.length>200&&jsx("button",{type:"button",onClick:()=>n(c=>!c),className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors self-start",children:r(o?"predict.event.rules.collapse":"predict.event.showMore")}),jsxs("button",{type:"button",onClick:()=>s(c=>!c),className:"flex items-center justify-between w-full mt-2 text-xs font-medium text-neutral lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsx("span",{children:r("predict.event.timelineAndPayout")}),jsx(ChevronDownIcon,{className:cn$1("h-4 w-4 transition-transform",i&&"rotate-180")})]}),i&&jsxs(Fragment,{children:[jsx("div",{className:"flex flex-col",children:(()=>{let c=u.status,f=[];return u.created_at&&f.push({label:r("predict.event.timeline.created"),value:rn(u.created_at),isActive:true}),f.push({label:r("predict.event.timeline.open"),value:rn(u.start_at),isActive:c!=="pending"}),c==="voided"?f.push({label:r("predict.event.timeline.voided"),value:rn(u.closed_at??u.end_at),isActive:true}):c==="closed"?f.push({label:r("predict.event.timeline.closed"),value:rn(u.closed_at??u.end_at),isActive:true}):f.push({label:r("predict.event.timeline.close"),value:rn(u.end_at),isActive:false}),f})().map((c,f,g)=>jsxs("div",{className:"flex items-stretch gap-x-3",children:[jsxs("div",{className:"flex flex-col items-center w-3",children:[jsx("div",{className:`h-3 w-3 shrink-0 rounded-full border-2 mt-0.5 ${c.isActive?"border-primary bg-primary":"border-border bg-transparent"}`}),f<g.length-1&&jsx("div",{className:"w-px flex-1 bg-border"})]}),jsxs("div",{className:`flex flex-col ${f<g.length-1?"pb-4":""}`,children:[jsx("span",{className:"text-xs font-medium text-foreground lg:text-sm",children:c.label}),jsx("span",{className:"text-xs text-neutral lg:text-sm",children:c.value})]})]},c.label))}),jsxs("div",{className:"flex flex-wrap items-center gap-x-3 text-xxs text-neutral mt-2 lg:text-xs",children:[jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.event"),":"]})," ",jsx("span",{className:"text-foreground",children:t.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.market"),":"]})," ",jsx("span",{className:"text-foreground",children:u.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.source"),":"]})," ",jsx("span",{className:"text-foreground",children:Vm(u.source)})]})]})]})]})}function Ym({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 xa({eventSlug:e,source:t,onTradeAction:r}){let{data:o,isLoading:n,error:i}=useEvent({slug:e,source:t});return n?jsx(Zr,{}):i||!o?jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:i?.message||"Event not found"}):jsx(va,{event:o,onTradeAction:r})}var ef={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}},tf={label:"Unknown",color:"rgb(156, 163, 175)",bgColor:"rgba(156, 163, 175, 0.12)",icon:null};function It(e){return ef[e]??tf}function Gy({source:e,className:t}){let r=It(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 ya="rgba(39,39,42,0.6)",cf="rgba(63,63,70,0.8)";function df(e){return e==null?"-":formatAmountInUsd(e)}function Sa({eventSlug:e,source:t,limit:r=4,onEventClick:o,onEventHover:n}){let{t:i}=useTranslation(),{data:s,isLoading:a}=useSimilarEvents({slug:e,source:t,limit:r});return a||!s||s.length===0?null:jsxs("div",{className:"flex flex-col gap-y-3 mt-6 px-1 lg:px-0",children:[jsx("span",{style:{color:"#f4f4f5",fontSize:14,fontWeight:600},children:i("predict.similar.title")}),jsx("div",{className:"grid grid-cols-1 gap-2",children:s.map(l=>jsx(uf,{event:l,onClick:o,onHover:n},`${l.source}-${l.slug}`))})]})}function uf({event:e,onClick:t,onHover:r}){let{t:o}=useTranslation(),n=It(e.source),i=useMemo(()=>df(e.volume),[e.volume]),s=e.tags?.[0];return jsxs("button",{type:"button",onClick:()=>t?.(e),onMouseEnter:a=>{a.currentTarget.style.borderColor=cf,r?.(e);},onMouseLeave:a=>{a.currentTarget.style.borderColor=ya;},style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",borderRadius:14,border:`1px solid ${ya}`,background:"rgba(24,24,27,0.4)",cursor:"pointer",textAlign:"left",width:"100%",transition:"border-color 0.2s"},className:"group",children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title?.[0]||"?",radius:"full",className:"size-9 shrink-0 bg-transparent",imgProps:{className:"object-cover"}}),jsxs("div",{style:{display:"flex",flexDirection:"column",minWidth:0,flex:1,gap:2},children:[jsx("span",{style:{fontSize:13,fontWeight:500,color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.title}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,color:n.color,flexShrink:0},children:[n.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase"},children:n.label})]}),jsx("span",{style:{color:"#52525b"},children:"\xB7"}),jsxs("span",{style:{color:"#a1a1aa"},children:[i," ",o("predict.event.volume")]}),s&&jsxs(Fragment,{children:[jsx("span",{style:{color:"#52525b"},children:"\xB7"}),jsx("span",{style:{color:"#71717a"},children:s.label})]})]})]}),jsx(ChevronRightIcon,{width:14,height:14,className:"shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",style:{color:"#71717a"}})]})}function Gn(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function b1({eventSlug:e,source:t,chain:r,walletAddress:o,onSimilarEventClick:n,onSimilarEventHover:i,onBack:s,renderActivitySection:a,onInsufficientBalance:l,onSetupRequired:d,slippageBps:u}){let{t:p}=useTranslation(),{isDesktop:m}=useScreen(),{onOpen:c}=useAsyncModal(Vr),{onOpen:f}=useAsyncModal(Oo),{data:g,isLoading:v}=useEvent({slug:e,source:t}),x=useMemo(()=>{let N=[...g?.markets||[]],A=N.filter(z=>z.status==="open").sort((z,F)=>Gn(F)-Gn(z)),D=N.filter(z=>z.status!=="open").sort((z,F)=>Gn(F)-Gn(z));return [...A,...D]},[g?.markets]),[b,w]=useState(null),P=useCallback((N,A,D)=>{w(z=>({market:N,outcome:A,side:D,version:(z?.version??0)+1})),!m&&g&&(D==="sell"?f({params:{event:g,market:N,initialOutcome:A,chain:r,slippageBps:u,onSetupRequired:d}}):c({params:{event:g,market:N,initialOutcome:A,chain:r,slippageBps:u,onInsufficientBalance:l}}));},[m,g,r,u,c,f,l,d]),h=b?.market??x[0];if(v){let N=!!s;return m?jsxs("div",{className:"flex w-full max-w-6xl mx-auto gap-x-4 lg:gap-x-6",children:[jsx("div",{className:"min-w-0 flex-1 max-w-3xl",children:jsx(Zr,{showBack:N})}),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(Vs,{})})})]}):jsx(Zr,{showBack:N})}let y=b?`${b.market.slug}-${b.version}`:h?.slug??"default",S=b?.side==="sell";return jsxs("div",{className:"flex w-full flex-col gap-y-4 pb-12 lg:max-w-7xl lg:gap-y-8 lg:pb-16 mx-auto",children:[jsxs("div",{className:"flex w-full justify-center gap-4 pt-4 lg:gap-6",children:[jsxs("div",{className:"flex-auto min-w-0 flex flex-col gap-y-4 px-4 lg:gap-y-6 lg:px-0",children:[s&&jsx("div",{className:"flex items-center justify-between",children:jsx(Button,{as:"a",onPress:s,startContent:jsx(ChevronLeftIcon,{className:"h-4 w-4"}),className:"text-neutral bg-transparent h-5 min-h-5 gap-x-2 p-0 text-base w-auto min-w-auto",children:p("common.back")})}),jsx(xa,{eventSlug:e,source:t,onTradeAction:P})]}),jsxs("div",{className:"hidden flex-none w-md flex-col gap-y-4 lg:sticky lg:top-4 lg:flex lg:self-start",children:[h&&(S?jsx(Hn,{event:g,market:h,initialOutcome:b?.outcome,chain:r,slippageBps:u,onSetupRequired:d},y):jsx(Rn,{event:g,market:h,initialOutcome:b?.outcome,chain:r,slippageBps:u,onInsufficientBalance:l},y)),g&&jsx(Sa,{eventSlug:e,source:g.source,onEventClick:n,onEventHover:i})]})]}),g&&jsx("div",{className:"flex w-full flex-col",children:a?a({event:g,walletAddress:o}):jsx(Us,{event:g,walletAddress:o})}),jsx(_n,{}),jsx(Hs,{}),jsx(Ps,{})]})}function Pa(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Nf(e){switch(e){case ae.ONE_DAY:return {interval:"15m",limit:96};case ae.ONE_WEEK:return {interval:"1h",limit:168};case ae.ONE_MONTH:return {interval:"4h",limit:180};case ae.ALL:return {interval:"1d",limit:300};default:return {interval:"1h",limit:100}}}var C1=e=>{let{candlestickMarketSlugs:t,chartRange:r=wn,source:o}=e,n=usePredictClient(),i=useMemo(()=>Nf(r),[r]),{data:s,isLoading:a,error:l}=useEvent({slug:e.eventSlug,source:o}),d=useMemo(()=>{if(!s?.markets)return [];let f=new Set,g=s.markets.filter(x=>f.has(x.slug)?false:(f.add(x.slug),true));return (t&&t.length>0?t.slice(0,4).map(x=>g.find(b=>b.slug===x)).filter(x=>x!==void 0):[...g].sort((x,b)=>Pa(b)-Pa(x)).slice(0,4)).map(x=>x.slug)},[t,s?.markets]),u=useQueries({queries:d.map(f=>({queryKey:candlesticksQueryKey(f,i),queryFn:()=>n.listCandlesticks(f,i),enabled:d.length>0}))}),p=u.some(f=>f.isLoading),m=useMemo(()=>{let f=new Map;return d.forEach((g,v)=>{let x=u[v]?.error;x&&f.set(g,x);}),f},[d,u]),c=useMemo(()=>{let f=new Map;return d.forEach((g,v)=>{let x=u[v]?.data;x&&f.set(g,x);}),f},[d,u]);return {event:s,isEventLoading:a,eventError:l,candlestickParams:i,candlesticks:c,isCandlesticksLoading:p,candlestickErrors:m}};function Yo({comment:e,anonymousLabel:t,isReply:r=false}){let{profile:o}=e,n=o.name||o.pseudonym||t,i=useMemo(()=>Tf(e.created_at),[e.created_at]);return jsxs("div",{className:cn$1("flex gap-x-2.5 px-1 py-3 border-b border-border/40 lg:px-2",r&&"pl-8 lg:pl-9"),children:[jsx(Cf,{src:o.profile_image,name:n,className:cn$1("shrink-0",r?"size-6":"size-8 lg:size-7")}),jsxs("div",{className:"min-w-0 flex-1",children:[jsxs("div",{className:"flex items-baseline gap-x-2",children:[jsx("span",{className:"truncate text-sm font-medium text-foreground",children:n}),jsx("span",{className:"ml-auto shrink-0 text-xs text-neutral",children:i})]}),jsx("p",{className:"mt-1 whitespace-pre-wrap break-words text-sm leading-relaxed text-foreground/90",children:e.body}),jsxs("div",{className:"mt-2 flex items-center gap-x-1 text-neutral",children:[jsx(Mf,{className:"size-3.5"}),jsx("span",{className:"text-xs tabular-nums",children:e.reaction_count})]})]})]})}function Cf({src:e,name:t,className:r}){let o=t.trim().charAt(0).toUpperCase()||"?",n=useMemo(()=>Ef(t),[t]);return e?jsx("img",{src:e,alt:t,loading:"lazy",className:cn$1("rounded-full object-cover",r)}):jsx("span",{className:cn$1("flex items-center justify-center rounded-full text-xs font-semibold text-white",r),style:{backgroundColor:n},"aria-hidden":true,children:o})}function Mf({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 Ef(e){let t=0;for(let o=0;o<e.length;o++)t=e.charCodeAt(o)+((t<<5)-t);return `hsl(${Math.abs(t)%360}, 55%, 45%)`}function Tf(e){let t=new Date(e).getTime();if(Number.isNaN(t))return "";let r=Math.max(0,Math.floor((Date.now()-t)/1e3));if(r<60)return "now";let o=Math.floor(r/60);if(o<60)return `${o}m`;let n=Math.floor(o/60);if(n<24)return `${n}h`;let i=Math.floor(n/24);if(i<7)return `${i}d`;let s=Math.floor(i/7);return s<5?`${s}w`:new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}var Hf={latest:{order:"createdAt",ascending:false},oldest:{order:"createdAt",ascending:true},mostLiked:{order:"reactionCount",ascending:false}},Ma={latest:"predict.comments.sortLatest",oldest:"predict.comments.sortOldest",mostLiked:"predict.comments.sortMostLiked"},zf=["latest","oldest","mostLiked"],Wf=600,Uf=112;function $f({slug:e,source:t,limit:r=20,height:o,className:n}){let{t:i}=useTranslation(),[s,a]=useState("latest"),[l,d]=useState(false),u=Hf[s],{data:p,isLoading:m,isFetchingNextPage:c,hasNextPage:f,fetchNextPage:g}=useInfiniteComments({slug:e,source:t,limit:r,order:u.order,ascending:u.ascending,holders_only:l}),v=useMemo(()=>p?.pages?.flatMap(D=>D.items)??[],[p?.pages]),x=useRef(null),{height:b}=useResizeObserver({ref:x}),w=o??(b||Wf),P=useDynamicRowHeight({defaultRowHeight:Uf,key:`${e}:${t}:${s}:${l}`}),h=v.length,y=h+(f?1:0),S=useCallback(D=>D<h,[h]),N=useCallback(async()=>{f&&!c&&await g();},[f,c,g]),A=useInfiniteLoader({isRowLoaded:S,loadMoreRows:N,rowCount:y,threshold:5});return jsxs("div",{className:cn$1("flex h-full w-full flex-col",n),children:[jsx(Vf,{sort:s,onSortChange:a,holdersOnly:l,onHoldersOnlyChange:d}),jsx("div",{className:"min-h-0 flex-auto overflow-hidden",ref:x,children:m?jsx(jf,{}):v.length===0?jsx(qf,{message:i("predict.comments.empty")}):jsx(List,{className:"no-scrollbar",style:{height:w},onRowsRendered:A,rowComponent:Kf,rowCount:y,rowHeight:P,rowProps:{comments:v,itemCount:h,anonymousLabel:i("predict.comments.anonymous")},overscanCount:4})})]})}function Kf({index:e,style:t,comments:r,itemCount:o,anonymousLabel:n}){if(e>=o)return jsx("div",{style:t,className:"flex items-center justify-center py-4",children:jsx(Spinner,{size:"sm"})});let i=r[e];return i?jsx("div",{style:t,children:jsx(Yo,{comment:i,anonymousLabel:n,isReply:!!i.parent_comment_id})}):null}function Vf({sort:e,onSortChange:t,holdersOnly:r,onHoldersOnlyChange:o}){let{t:n}=useTranslation(),[i,s]=useState(false),a=useRef(null);return useEffect(()=>{if(!i)return;let l=u=>{a.current&&!a.current.contains(u.target)&&s(false);},d=u=>{u.key==="Escape"&&s(false);};return document.addEventListener("mousedown",l),document.addEventListener("keydown",d),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",d);}},[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(Gf,{className:"size-3.5 text-neutral"}),jsx("span",{children:n(Ma[e])}),jsx(Yf,{className:cn$1("size-3.5 text-neutral transition-transform",i&&"rotate-180")})]}),i&&jsx("div",{className:"absolute left-0 top-full z-20 mt-1.5 min-w-40 overflow-hidden rounded-xl border border-border bg-content1 p-1 shadow-xl",children:zf.map(l=>{let d=l===e;return jsxs("button",{type:"button",onClick:()=>{t(l),s(false);},className:cn$1("flex w-full items-center gap-x-2 rounded-lg px-3 py-2 text-left text-sm transition-colors cursor-pointer",d?"bg-primary/10 text-primary":"text-neutral hover:bg-content2 hover:text-foreground"),children:[jsx("span",{className:"flex-1 font-medium",children:n(Ma[l])}),d&&jsx(Ea,{className:"size-4 text-primary"})]},l)})})]}),jsxs("button",{type:"button",role:"switch","aria-checked":r,onClick:()=>o(!r),className:cn$1("inline-flex items-center gap-x-1.5 rounded-lg border px-3 py-1.5 text-sm transition-colors cursor-pointer",r?"border-primary/40 bg-primary/10 text-primary":"border-border bg-content2/40 text-neutral hover:text-foreground"),children:[jsx("span",{className:cn$1("flex size-4 items-center justify-center rounded border",r?"border-primary bg-primary":"border-neutral"),children:r&&jsx(Ea,{className:"size-3 text-background"})}),n("predict.comments.holdersOnly")]})]})}function jf(){return jsx("div",{className:"flex flex-col gap-y-4 px-1 py-3 lg:px-2",children:Array.from({length:6}).map((e,t)=>jsxs("div",{className:"flex gap-x-2.5",children:[jsx(Skeleton,{className:"size-8 shrink-0 rounded-full"}),jsxs("div",{className:"flex-1 space-y-2",children:[jsx(Skeleton,{className:"h-3 w-24 rounded"}),jsx(Skeleton,{className:"h-3 w-full rounded"}),jsx(Skeleton,{className:"h-3 w-2/3 rounded"})]})]},t))})}function qf({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 Gf({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 Yf({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 Ea({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 Jf=10,Zf=atomWithStorage("liberfi:predict_search_histories",[],void 0,{getOnInit:true});function Zn(){let[e,t]=useAtom(Zf),r=useCallback(n=>{let i=n.trim();i&&t(s=>{let a=s.filter(l=>l!==i);return [i,...a].slice(0,Jf)});},[t]),o=useCallback(()=>{t([]);},[t]);return {histories:e,addHistory:r,clearHistories:o}}function Oa({histories:e,onSelect:t,onClear:r,className:o}){let{t:n}=useTranslation();return e.length===0?null:jsxs("div",{className:cn$1("px-4 pb-4",o),children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-medium",children:n("predict.search.history")}),jsx(Button,{isIconOnly:true,size:"sm",className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsx(TrashIcon,{width:20,height:20})})]}),jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:e.map(i=>jsx(Chip,{size:"sm",variant:"bordered",className:cn$1("text-neutral","border-border border-1","cursor-pointer","hover:opacity-hover"),onClick:()=>t?.(i),children:i},i))})]})}function Da({onSelect:e,className:t}){let{histories:r,clearHistories:o}=Zn();return jsx(Oa,{className:cn$1(t),histories:r,onSelect:e,onClear:o})}function Aa({value:e,onValueChange:t,onClear:r,onEscape:o,className:n}){let{t:i}=useTranslation();return jsx("div",{className:n,children:jsx(StyledInput,{autoFocus:true,variant:"bordered",radius:"lg",value:e,onValueChange:t,placeholder:i("predict.search.placeholder"),classNames:{inputWrapper:["!bg-[rgba(39,39,42,0.6)]","!border-[rgba(63,63,70,0.5)]","data-[hover=true]:!bg-[rgba(39,39,42,1)]","group-data-[focus=true]:!bg-[rgba(39,39,42,1)]","group-data-[focus=true]:!border-[rgba(63,63,70,0.8)]"].join(" ")},startContent:jsx(SearchIcon,{width:20,height:20,className:"text-neutral"}),endContent:e?jsx(Button,{isIconOnly:true,className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsx(XCloseIcon,{width:20,height:20})}):jsx(Kbd,{className:"min-w-8 justify-center text-xs text-neutral bg-transparent border border-[rgba(63,63,70,0.5)] rounded-lg cursor-pointer select-none",onMouseDown:s=>{s.preventDefault(),o?.();},children:"Esc"})})})}function bg(e){return e==null?"-":formatAmountInUsd(e)}function Fa({event:e,href:t,LinkComponent:r,onSelect:o,onHover:n,className:i}){let{t:s}=useTranslation(),a=e.tags?.[0],l=It(e.source),d=useMemo(()=>bg(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:u=>{t&&o&&u.preventDefault(),o?.(e);},onMouseEnter:()=>n?.(e),children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"full",className:"h-10 w-10 flex-shrink-0"}),jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-center gap-y-0.5",children:[jsx("span",{className:"min-w-0 text-sm font-medium line-clamp-2 group-hover:text-primary transition-colors",children:e.title}),jsxs("div",{className:"flex items-center gap-x-2 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[jsxs("span",{className:"inline-flex items-center gap-x-1 shrink-0",style:{color:l.color},children:[l.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase"},children:l.label})]}),jsx("span",{className:"text-neutral-600",children:"\xB7"}),jsxs("span",{className:"text-neutral-400",children:[d," ",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 Ba({keyword:e="",limit:t,source:r}){let{data:o,isLoading:n,isFetchingNextPage:i,hasNextPage:s,fetchNextPage:a}=useSearchEvents({keyword:e,limit:t,source:r,sort_by:e?void 0:"volume",sort_asc:e?void 0:false},{enabled:true});return {events:useMemo(()=>o?.pages.flatMap(d=>d.items).filter(d=>d!=null)??[],[o]),isLoading:n,isFetchingNextPage:i,hasNextPage:s??false,fetchNextPage:a}}var Tg=64;function Ua({onSelect:e,getEventHref:t,LinkComponent:r,onHover:o,className:n,...i}){let{events:s,isLoading:a,isFetchingNextPage:l,hasNextPage:d,fetchNextPage:u}=Ba(i),p=useRef(null),{height:m}=useResizeObserver({ref:p}),c=useCallback(x=>x<s.length,[s]),f=useCallback(async()=>{d&&!l&&await u();},[d,l,u]),g=useMemo(()=>d?s.length+1:s.length,[s,d]),v=useInfiniteLoader({isRowLoaded:c,loadMoreRows:f,rowCount:g,threshold:5});return a?jsx(Rg,{className:n}):s.length===0?jsx(_g,{className:n}):jsx("div",{className:cn$1("w-full h-full flex flex-col",n),children:jsx("div",{className:"flex-auto min-h-0",ref:p,children:jsx(List,{className:"no-scrollbar",style:{height:m},onRowsRendered:v,rowComponent:Lg,rowCount:g,rowHeight:Tg,rowProps:{events:s,onSelect:e,getEventHref:t,LinkComponent:r,onHover:o},overscanCount:5})})})}function Lg({index:e,style:t,events:r,onSelect:o,getEventHref:n,LinkComponent:i,onHover:s}){let a=r[e];return a?jsx("div",{style:t,children:jsx(Fa,{event:a,href:n?.(a),LinkComponent:i,onSelect:o,onHover:s})}):jsx("div",{style:t,className:"flex items-center justify-center",children:jsx(Spinner,{size:"sm"})})}function Rg({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 _g({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 ja({onKeywordChange:e}){let[t,r]=useState(""),[o,n]=useState(""),{addHistory:i}=Zn(),s=useCallbackRef(e),a=useCallbackRef(i),l=useMemo(()=>debounce(m=>{n(m),s(m),m&&a(m);},500),[s,a]),d=useCallback(m=>{r(m),l(m);},[l]),u=useCallback(m=>{l.cancel(),r(m),n(m),s(m),m&&a(m);},[l,s,a]),p=useCallback(()=>u(""),[u]);return {text:t,keyword:o,setText:d,setKeyword:u,clearKeyword:p}}function qa({onKeywordChange:e,onSelectEvent:t,getEventHref:r,LinkComponent:o,onHover:n,onEscape:i,source:s}){let{text:a,keyword:l,setText:d,setKeyword:u,clearKeyword:p}=ja({onKeywordChange:e});return jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsx(Aa,{value:a,onValueChange:d,onClear:p,onEscape:i}),!l&&jsx(Da,{onSelect:u}),jsx(Ua,{className:"flex-auto min-h-0",keyword:l,onSelect:t,getEventHref:r,LinkComponent:o,onHover:n,source:s})]})}var ei="predict-search";function xk({id:e=ei}){return jsx(AsyncModal,{id:e,children:t=>jsx(Vg,{...t})})}function Vg({params:e,isOpen:t,onOpenChange:r,onResult:o}){let{t:n}=useTranslation(),{isMobile:i}=useScreen(),s=useCallback(l=>{o(l);},[o]),a=useCallback(()=>{r(false);},[r]);return jsx(StyledModal,{isOpen:t,onOpenChange:r,size:i?"full":"lg",hideCloseButton:true,backdrop:"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:n("predict.search.title")}),jsx(Button,{isIconOnly:true,onPress:()=>r(false),size:"sm",className:"bg-transparent min-w-6 w-6 h-6",children:jsx(XCloseIcon,{width:20,height:20})})]}),jsx(ModalBody,{className:"p-4",children:jsx(qa,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectEvent:s,onEscape:a})})]})})}function Mk({onSelectEvent:e,modalParams:t,className:r}){let{t:o}=useTranslation(),{isDesktop:n}=useScreen(),{onOpen:i,onClose:s}=useAsyncModal(ei),a=useCallbackRef(e),l=useCallbackRef(async()=>{let u=await i({params:t});u&&a(u);}),d=useCallbackRef(()=>{s();});return useEffect(()=>{let u=p=>{let m=document.activeElement,c=!!m&&(m.tagName==="INPUT"||m.tagName==="TEXTAREA"||m.getAttribute("contenteditable")==="true");p.key==="/"&&!c&&(p.preventDefault(),l()),p.key==="Escape"&&(p.preventDefault(),d());};return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u);}},[l,d]),n?jsx(Button,{size:"sm",radius:"full",onPress:l,variant:"bordered",startContent:jsx(SearchIcon,{width:16,height:16,className:"text-foreground"}),endContent:jsx(Kbd,{className:"min-w-6 justify-center text-xs text-foreground bg-content3 rounded-lg",children:"/"}),className:cn$1("w-56 min-w-0 h-8 min-h-0 border-transparent hover:border-border bg-content2 pl-3 pr-1.5 text-neutral",r),children:o("predict.search.placeholder")}):jsx(Button,{size:"sm",radius:"full",isIconOnly:true,onPress:l,variant:"bordered",className:cn$1("w-8 min-w-0 h-8 min-h-0 border-1 border-border bg-content2",r),children:jsx(SearchIcon,{width:16,height:16,className:"text-foreground"})})}var ri=[{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"}],ol=[{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}],tl={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"},rl={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 Zg(e,t){if(!e)return "$5K+";let r=ol.find(o=>o.value===e);return r?r.labelKey?t(r.labelKey):r.label:`$${e}`}function il({sortBy:e,onSortChange:t,sortAsc:r,onSortAscChange:o,minVolume:n,onMinVolumeChange:i,onRefresh:s}){let{t:a}=useTranslation(),[l,d]=useState(false),[u,p]=useState(false),[m,c]=useState(false),[f,g]=useState(false),v=useRef(null),x=useRef(null),b=ri.find(h=>h.value===e)??ri[0],w=useCallback(h=>{v.current&&!v.current.contains(h.target)&&d(false),x.current&&!x.current.contains(h.target)&&p(false);},[]);useEffect(()=>(document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)),[w]);let P=useCallback(()=>{s?.(),g(true),setTimeout(()=>g(false),700);},[s]);return jsxs(Fragment,{children:[jsx("style",{children:`
79
79
  @keyframes matchRefreshSpin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}
80
80
  .match-refresh-spin{animation:matchRefreshSpin .6s ease-in-out}
81
81
  .match-btn:focus-visible{outline:2px solid #c7ff2e;outline-offset:2px;z-index:10}
82
- `}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxs("div",{ref:g,style:{position:"relative"},children:[jsxs("button",{type:"button",className:"match-btn",style:Ja,onMouseEnter:h=>{h.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:h=>{h.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>{c(h=>!h),m(false);},children:[jsx(Xg,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:a(b.labelKey)}),jsx(el,{open:l})]}),l&&jsx("div",{style:{...Za,width:224,padding:4},children:Jo.map(h=>{let N=e===h.value;return jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",gap:12,padding:"10px 12px",textAlign:"left",fontSize:14,border:"none",cursor:"pointer",transition:"all 0.15s",background:N?"rgba(199,255,46,0.08)":"transparent",color:N?"#c7ff2e":"#a1a1aa",borderRadius:10},onMouseEnter:w=>{N||(w.currentTarget.style.background="rgba(39,39,42,0.5)",w.currentTarget.style.color="#fff");},onMouseLeave:w=>{N||(w.currentTarget.style.background="transparent",w.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===h.value?n(!r):t(h.value),c(false);},children:[jsx("div",{style:{color:N?"#c7ff2e":"#71717a"},children:jsx(Jg,{type:h.icon})}),jsxs("div",{style:{flex:1,textAlign:"left"},children:[jsx("div",{style:{fontWeight:500},children:a(h.labelKey)}),jsx("div",{style:{fontSize:11,color:"#71717a",marginTop:1},children:a(h.descKey)})]}),N&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 6 9 17l-5-5"})})]},h.value)})})]}),i&&jsxs("div",{ref:x,style:{position:"relative"},children:[jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxs("button",{type:"button",className:"match-btn",style:Ja,onMouseEnter:h=>{h.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:h=>{h.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>{m(h=>!h),c(false);},children:[jsx(Zg,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:Qg(o,a)}),jsx(e0,{onMouseEnter:()=>d(true),onMouseLeave:()=>d(false)}),jsx(el,{open:u})]}),p&&jsxs("div",{style:{position:"absolute",zIndex:100,top:"100%",marginTop:8,left:"50%",transform:"translateX(-50%)",width:256,padding:12,borderRadius:14,background:"rgba(24,24,27,1)",border:"1px solid rgba(63,63,70,0.5)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",pointerEvents:"none"},children:[jsx("div",{style:{position:"absolute",top:-6,left:"50%",transform:"translateX(-50%) rotate(45deg)",width:12,height:12,background:"rgba(24,24,27,1)",borderLeft:"1px solid rgba(63,63,70,0.5)",borderTop:"1px solid rgba(63,63,70,0.5)"}}),jsxs("div",{style:{position:"relative",fontSize:12,color:"#d4d4d8",lineHeight:1.625},children:[jsxs("div",{style:{fontWeight:600,color:"#fff",display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#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")})]})]})]}),u&&jsxs("div",{style:{...Za,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:tl.map(h=>{let N=h.value===0?!o:o===h.value;return jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",textAlign:"left",fontSize:14,border:"none",cursor:"pointer",background:N?"rgba(199,255,46,0.08)":"transparent",color:N?"#c7ff2e":"#a1a1aa",borderRadius:10,transition:"all 0.15s"},onMouseEnter:w=>{N||(w.currentTarget.style.background="rgba(39,39,42,0.5)",w.currentTarget.style.color="#fff");},onMouseLeave:w=>{N||(w.currentTarget.style.background="transparent",w.currentTarget.style.color="#a1a1aa");},onClick:()=>{i?.(h.value===0?void 0:h.value),m(false);},children:[jsx("span",{children:h.labelKey?a(h.labelKey):h.label}),N&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 6 9 17l-5-5"})})]},h.value)})})]})]}),s&&jsx("button",{type:"button",className:"match-btn",style:{borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",width:36,height:36,color:"#a1a1aa",cursor:"pointer",transition:"all 0.15s",display:"inline-flex",alignItems:"center",justifyContent:"center"},onMouseEnter:h=>{h.currentTarget.style.background="rgba(39,39,42,1)",h.currentTarget.style.color="#fff";},onMouseLeave:h=>{h.currentTarget.style.background="rgba(39,39,42,0.6)",h.currentTarget.style.color="#a1a1aa";},onClick:S,children:jsxs("svg",{className:f?"match-refresh-spin":void 0,viewBox:"0 0 24 24",style:{width:16,height:16},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),jsx("path",{d:"M21 3v5h-5"}),jsx("path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}),jsx("path",{d:"M8 16H3v5"})]})})]})]})}function Xg(){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 Jg({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 Zg(){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 e0({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 el({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 o0(e){return formatAmountInUsd(e)}var i0=[{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:o0,valueColor:"#f5a524",gradientFrom:"rgba(245,165,36,0.18)",gradientTo:"rgba(245,165,36,0.04)",borderColor:"rgba(245,165,36,0.18)"}];function ol({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:v,style:{position:"relative"},children:[jsxs("button",{type:"button",className:"match-btn",style:tl,onMouseEnter:h=>{h.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:h=>{h.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>{d(h=>!h),p(false);},children:[jsx(e0,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:a(b.labelKey)}),jsx(nl,{open:l})]}),l&&jsx("div",{style:{...rl,width:224,padding:4},children:ri.map(h=>{let y=e===h.value;return jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",gap:12,padding:"10px 12px",textAlign:"left",fontSize:14,border:"none",cursor:"pointer",transition:"all 0.15s",background:y?"rgba(199,255,46,0.08)":"transparent",color:y?"#c7ff2e":"#a1a1aa",borderRadius:10},onMouseEnter:S=>{y||(S.currentTarget.style.background="rgba(39,39,42,0.5)",S.currentTarget.style.color="#fff");},onMouseLeave:S=>{y||(S.currentTarget.style.background="transparent",S.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===h.value?o(!r):t(h.value),d(false);},children:[jsx("div",{style:{color:y?"#c7ff2e":"#71717a"},children:jsx(t0,{type:h.icon})}),jsxs("div",{style:{flex:1,textAlign:"left"},children:[jsx("div",{style:{fontWeight:500},children:a(h.labelKey)}),jsx("div",{style:{fontSize:11,color:"#71717a",marginTop:1},children:a(h.descKey)})]}),y&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 6 9 17l-5-5"})})]},h.value)})})]}),i&&jsxs("div",{ref:x,style:{position:"relative"},children:[jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxs("button",{type:"button",className:"match-btn",style:tl,onMouseEnter:h=>{h.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:h=>{h.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>{p(h=>!h),d(false);},children:[jsx(r0,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:Zg(n,a)}),jsx(n0,{onMouseEnter:()=>c(true),onMouseLeave:()=>c(false)}),jsx(nl,{open:u})]}),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")})]})]})]}),u&&jsxs("div",{style:{...rl,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:ol.map(h=>{let y=h.value===0?!n:n===h.value;return jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",textAlign:"left",fontSize:14,border:"none",cursor:"pointer",background:y?"rgba(199,255,46,0.08)":"transparent",color:y?"#c7ff2e":"#a1a1aa",borderRadius:10,transition:"all 0.15s"},onMouseEnter:S=>{y||(S.currentTarget.style.background="rgba(39,39,42,0.5)",S.currentTarget.style.color="#fff");},onMouseLeave:S=>{y||(S.currentTarget.style.background="transparent",S.currentTarget.style.color="#a1a1aa");},onClick:()=>{i?.(h.value===0?void 0:h.value),p(false);},children:[jsx("span",{children:h.labelKey?a(h.labelKey):h.label}),y&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 6 9 17l-5-5"})})]},h.value)})})]})]}),s&&jsx("button",{type:"button",className:"match-btn",style:{borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",width:36,height:36,color:"#a1a1aa",cursor:"pointer",transition:"all 0.15s",display:"inline-flex",alignItems:"center",justifyContent:"center"},onMouseEnter:h=>{h.currentTarget.style.background="rgba(39,39,42,1)",h.currentTarget.style.color="#fff";},onMouseLeave:h=>{h.currentTarget.style.background="rgba(39,39,42,0.6)",h.currentTarget.style.color="#a1a1aa";},onClick: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 e0(){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 t0({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 r0(){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 n0({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 nl({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 a0(e){return formatAmountInUsd(e)}var l0=[{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:a0,valueColor:"#f5a524",gradientFrom:"rgba(245,165,36,0.18)",gradientTo:"rgba(245,165,36,0.04)",borderColor:"rgba(245,165,36,0.18)"}];function al({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:i0.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 Zo(e){return e==null?"-":formatAmountInUsd(e)}function l0(e){return e==null?"narrow":e>=5?"wide":e>=3?"moderate":"narrow"}var ll={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)"}},c0={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)"}},il={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 d0(e){return e==null?null:e<120?"fresh":e<300?"aging":"stale"}var u0={fresh:"#17c964",aging:"#f5a524",stale:"#71717a"},p0={polymarket:{text:"#50a2ff",icon:"#50a2ff"},kalshi:{text:"#00d492",icon:"#00d492"}},m0={text:"#9ca3af",icon:"#9ca3af"};function f0(e){return p0[e]??m0}var g0=`
120
+ `).map((r,o)=>jsxs("span",{children:[o>0&&jsx("br",{className:"hidden sm:block"}),r,o===0?" ":""]},o))})]}),jsx("div",{className:"matches-stat-grid",style:{display:"grid",borderRadius:16,border:"1px solid rgba(39,39,42,0.5)",overflow:"hidden",flexShrink:0,backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",...e?{animation:"matchStatsEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:"0.1s"}:{}},children:l0.map((r,o)=>jsxs("div",{style:{padding:"16px 20px",background:e?`linear-gradient(to bottom, ${r.gradientFrom}, ${r.gradientTo})`:"rgba(255,255,255,0.02)",borderRight:o%2===0?"1px solid rgba(39,39,42,0.4)":"none",borderBottom:o<2?"1px solid rgba(39,39,42,0.4)":"none",...e?{animation:"matchStatCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:`${150+o*60}ms`}:{}},children:[jsx("div",{className:"matches-stat-val",style:{fontWeight:700,fontVariantNumeric:"tabular-nums",color:e?r.valueColor:"transparent",display:"flex",alignItems:"center"},children:e?r.format(e[r.key]??0):jsx("div",{style:{height:16,width:56,borderRadius:4,background:"rgba(255,255,255,0.06)",animation:"matchStatCardEnter 0.6s ease-out both",animationDelay:`${o*80}ms`}})}),jsx("div",{className:"matches-stat-label",style:{fontWeight:500,color:e?"#71717a":"transparent",marginTop:2,display:"flex",alignItems:"center"},children:e?t(r.labelKey):jsx("div",{style:{height:10,width:64,borderRadius:4,background:"rgba(255,255,255,0.04)",animation:"matchStatCardEnter 0.6s ease-out both",animationDelay:`${50+o*80}ms`}})})]},r.key))})]})]})}function ni(e){return e==null?"-":formatAmountInUsd(e)}function u0(e){return e==null?"narrow":e>=5?"wide":e>=3?"moderate":"narrow"}var ul={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)"}},p0={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)"}},ll={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 m0(e){return e==null?null:e<120?"fresh":e<300?"aging":"stale"}var f0={fresh:"#17c964",aging:"#f5a524",stale:"#71717a"},g0={polymarket:{text:"#50a2ff",icon:"#50a2ff"},kalshi:{text:"#00d492",icon:"#00d492"}},h0={text:"#9ca3af",icon:"#9ca3af"};function v0(e){return g0[e]??h0}var x0=`
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 h0({tier:e}){let t=ll[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 v0(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 cl({match:e,onSelectMatch:t,getMatchHref:r,onSelectLeg:n,getLegHref:o,onHover:i,getMarketHref:s,LinkComponent:a}){let{t:l}=useTranslation(),c=v0(e);if(!c)return null;let[u,m]=c,p=e.spread_percent!=null?e.spread_percent:e.spread!=null?e.spread*100:null,d=l0(p),f=ll[d],v=u.best_price!=null&&m.best_price!=null?u.best_price<=m.best_price?u.source:m.source:null,g=u.event_title||m.event_title,x=e.signal_tag??"stale_data",b=il[x]??il.stale_data,P=r?.(e),S=jsxs(Fragment,{children:[jsx("style",{children:g0}),p!=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:[p.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(h0,{tier:d})]}),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(sl,{leg:u,isCheaper:v===u.source,externalUrlFallback:s?.(e,u.source),internalHref:o?.(e,u),onSelect:n?()=>n(e,u):void 0,LinkComponent:a}),jsx("div",{style:{height:1,background:"rgba(39,39,42,0.3)"}}),jsx(sl,{leg:m,isCheaper:v===m.source,externalUrlFallback:s?.(e,m.source),internalHref:o?.(e,m),onSelect:n?()=>n(e,m):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"})]}),Zo(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"})}),Zo(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"})]}),x0(l,e.age_seconds)]})]}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,color:"#52525b"},children:[jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:b.dot,flexShrink:0}}),l(b.label)]})]})]}),h={display:"block",color:"inherit",textDecoration:"none",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",cursor:P||t?"pointer":void 0},N=E=>{let T=E.currentTarget,_=c0[d];T.style.borderColor=_.border,T.style.boxShadow=_.shadow,i?.(e);},w=E=>{let T=E.currentTarget;T.style.borderColor="rgba(39,39,42,0.6)",T.style.boxShadow="none";};return P&&a?jsx(a,{href:P,className:"group match-card",children:jsx("div",{style:h,onMouseEnter:N,onMouseLeave:w,onClick:()=>t?.(e),children:S})}):jsx("div",{className:"group match-card",role:t?"button":void 0,tabIndex:t?0:void 0,style:h,onMouseEnter:N,onMouseLeave:w,onClick:()=>t?.(e),onKeyDown:E=>{t&&(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),t(e));},children:S})}function x0(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 sl({leg:e,isCheaper:t,externalUrlFallback:r,internalHref:n,onSelect:o,LinkComponent:i}){let{t:s}=useTranslation(),a=Mt(e.source),l=f0(e.source),c=e.best_price,u=e.outcomes?.[0]?.label??null,m=e.external_url??r,p=d0(e.age_seconds),d=x=>{x.stopPropagation();},f=!!(n||o),v={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}),p&&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:u0[p],flexShrink:0}})]}),jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:1},children:[u&&jsx("span",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u}),jsxs("span",{style:{fontSize:9,color:"#52525b"},children:[Zo(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")})]}),m?jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer","aria-label":s("predict.matches.viewOn",{platform:a.label}),title:s("predict.matches.viewOn",{platform:a.label}),onClick:x=>x.stopPropagation(),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,borderRadius:4,color:"#71717a",flexShrink:0},onMouseEnter:x=>{x.currentTarget.style.color="#d4d4d8",x.currentTarget.style.background="rgba(255,255,255,0.05)";},onMouseLeave:x=>{x.currentTarget.style.color="#71717a",x.currentTarget.style.background="transparent";},children:jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M7 7h10v10"}),jsx("path",{d:"M7 17 17 7"})]})}):jsx("span",{style:{width:18,flexShrink:0}})]});return n&&i?jsx(i,{href:n,className:"match-card-leg-link",onClick:x=>{d(x),o?.();},children:jsx("div",{style:v,children:g})}):f?jsx("div",{role:"link",tabIndex:0,style:v,onClick:x=>{d(x),o?.();},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),d(x),o?.());},children:g}):jsx("div",{style:v,children:g})}var fl=forwardRef(function({sortBy:t,sortAsc:r,minVolume:n,signal:o,onSelectMatch:i,getMatchHref:s,onSelectLeg:a,getLegHref:l,onSelect:c,onHover:u,getMarketHref:m,LinkComponent:p,onStatsChange:d},f){let{t:v}=useTranslation(),{data:g,hasNextPage:x,fetchNextPage:b,isFetchingNextPage:P,isLoading:S,isPlaceholderData:h,refetch:N}=useInfiniteMatchMarkets({sort_by:t,sort_asc:r,min_volume:n,signal:o,status:"active",limit:20},{placeholderData:keepPreviousData}),[w,E]=useState(0),[T,_]=useState(false);T&&!h?(_(false),E(J=>J+1)):h&&!T&&_(true),useImperativeHandle(f,()=>({refetch:()=>{N();}}),[N]);let G=useMemo(()=>g?.pages.flatMap(J=>J.items??[])??[],[g]),D=g?.pages[0]?.total,K=useMemo(()=>{let J=0,y=0,k=0;for(let H of G){let V=H.spread??0;V>J&&(J=V),V>=.03&&k++,H.combined_volume!=null&&(y+=H.combined_volume);}return {activePairs:D??G.length,maxSpread:J,highSpreadCount:k,totalVolume:y}},[G,D]);useEffect(()=>{K.activePairs>0&&d?.(K);},[K,d]);let W=useRef(null),oe=useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]);if(useEffect(()=>{let J=W.current;if(!J)return;let y=new IntersectionObserver(k=>{k[0]?.isIntersecting&&x&&!P&&b();},{rootMargin:"200px"});return y.observe(J),()=>y.disconnect()},[x,P,b]),useEffect(()=>{if(x)return document.documentElement.style.overscrollBehaviorY="none",()=>{document.documentElement.style.overscrollBehaviorY="";}},[x]),S)return jsx(C0,{});if(G.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:v("predict.matches.empty")})});let le=!x&&G.length>0;return jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[jsx("style",{children:`
127
+ `;function b0({tier:e}){let t=ul[e],r=e==="wide"?5:e==="moderate"?3:1;return jsx("div",{style:{display:"flex",gap:2,alignItems:"center"},children:Array.from({length:5},(o,n)=>jsx("div",{style:{width:6,height:10,borderRadius:1.5,background:n<r?t.gaugeActive:t.gaugeInactive,transition:"background 0.2s"}},n))})}function y0(e){if(Array.isArray(e.legs)&&e.legs.length===2)return [e.legs[0],e.legs[1]];let t=(r,o,n)=>({source:r,event_title:o,event_slug:n?.event_slug??"",market_id:n?.id??0,market_slug:n?.slug??"",question:n?.question??"",status:n?.status??"open",outcomes:n?.outcomes,best_price:n?.outcomes?.[0]?.best_ask??n?.outcomes?.[0]?.price??void 0,vol_24h_usd:n?.volume_24h??void 0});return !e.market_a||!e.market_b?null:[t(e.source_a,e.event_a_title??"",e.market_a),t(e.source_b,e.event_b_title??"",e.market_b)]}function pl({match:e,onSelectMatch:t,getMatchHref:r,onSelectLeg:o,getLegHref:n,onHover:i,getMarketHref:s,LinkComponent:a}){let{t:l}=useTranslation(),d=y0(e);if(!d)return null;let[u,p]=d,m=e.spread_percent!=null?e.spread_percent:e.spread!=null?e.spread*100:null,c=u0(m),f=ul[c],g=u.best_price!=null&&p.best_price!=null?u.best_price<=p.best_price?u.source:p.source:null,v=u.event_title||p.event_title,x=e.signal_tag??"stale_data",b=ll[x]??ll.stale_data,w=r?.(e),P=jsxs(Fragment,{children:[jsx("style",{children:x0}),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(b0,{tier:c})]}),jsxs("div",{style:{padding:"14px 14px 12px"},children:[jsx("h3",{style:{fontSize:13,fontWeight:600,lineHeight:1.4,letterSpacing:"-0.2px",color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",margin:"0 0 12px"},children:v}),jsxs("div",{style:{borderRadius:10,border:"1px solid rgba(39,39,42,0.4)",overflow:"hidden"},children:[jsx(cl,{leg:u,isCheaper:g===u.source,externalUrlFallback:s?.(e,u.source),internalHref:n?.(e,u),onSelect:o?()=>o(e,u):void 0,LinkComponent:a}),jsx("div",{style:{height:1,background:"rgba(39,39,42,0.3)"}}),jsx(cl,{leg:p,isCheaper:g===p.source,externalUrlFallback:s?.(e,p.source),internalHref:n?.(e,p),onSelect:o?()=>o(e,p):void 0,LinkComponent:a})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.15)",padding:"8px 14px"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,fontSize:10,color:"#71717a"},children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}),ni(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"})}),ni(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"})]}),k0(l,e.age_seconds)]})]}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,color:"#52525b"},children:[jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:b.dot,flexShrink:0}}),l(b.label)]})]})]}),h={display:"block",color:"inherit",textDecoration:"none",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",cursor:w||t?"pointer":void 0},y=N=>{let A=N.currentTarget,D=p0[c];A.style.borderColor=D.border,A.style.boxShadow=D.shadow,i?.(e);},S=N=>{let A=N.currentTarget;A.style.borderColor="rgba(39,39,42,0.6)",A.style.boxShadow="none";};return w&&a?jsx(a,{href:w,className:"group match-card",children:jsx("div",{style:h,onMouseEnter:y,onMouseLeave:S,onClick:()=>t?.(e),children:P})}):jsx("div",{className:"group match-card",role:t?"button":void 0,tabIndex:t?0:void 0,style:h,onMouseEnter:y,onMouseLeave:S,onClick:()=>t?.(e),onKeyDown:N=>{t&&(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),t(e));},children:P})}function k0(e,t){if(t<60)return e("predict.matches.ageJustNow");if(t<3600){let o=Math.floor(t/60);return e("predict.matches.ageMinutes",{count:o})}let r=Math.floor(t/3600);return e("predict.matches.ageHours",{count:r})}function cl({leg:e,isCheaper:t,externalUrlFallback:r,internalHref:o,onSelect:n,LinkComponent:i}){let{t:s}=useTranslation(),a=It(e.source),l=v0(e.source),d=e.best_price,u=e.outcomes?.[0]?.label??null,p=e.external_url??r,m=m0(e.age_seconds),c=x=>{x.stopPropagation();},f=!!(o||n),g={display:"flex",alignItems:"center",gap:8,padding:"10px 12px",background:t?"rgba(199,255,46,0.03)":"transparent",cursor:f?"pointer":void 0,color:"inherit",textDecoration:"none"},v=jsxs(Fragment,{children:[t?jsx("span",{style:{fontSize:10,color:"#c7ff2e",flexShrink:0},children:"\u2605"}):jsx("span",{style:{width:10,flexShrink:0}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,width:100,flexShrink:0},children:[a.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",color:l.text,textTransform:"uppercase"},children:a.label}),m&&jsx("span",{title:e.age_seconds!=null?s("predict.matches.updatedAgo",{seconds:e.age_seconds}):void 0,style:{width:6,height:6,borderRadius:"50%",background:f0[m],flexShrink:0}})]}),jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:1},children:[u&&jsx("span",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u}),jsxs("span",{style:{fontSize:9,color:"#52525b"},children:[ni(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:d!=null?(d*100).toFixed(1):"-"}),jsx("span",{style:{fontSize:9,color:"#71717a"},children:s("predict.matches.centsYes")})]}),p?jsx("a",{href:p,target:"_blank",rel:"noopener noreferrer","aria-label":s("predict.matches.viewOn",{platform:a.label}),title:s("predict.matches.viewOn",{platform:a.label}),onClick:x=>x.stopPropagation(),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,borderRadius:4,color:"#71717a",flexShrink:0},onMouseEnter:x=>{x.currentTarget.style.color="#d4d4d8",x.currentTarget.style.background="rgba(255,255,255,0.05)";},onMouseLeave:x=>{x.currentTarget.style.color="#71717a",x.currentTarget.style.background="transparent";},children:jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M7 7h10v10"}),jsx("path",{d:"M7 17 17 7"})]})}):jsx("span",{style:{width:18,flexShrink:0}})]});return o&&i?jsx(i,{href:o,className:"match-card-leg-link",onClick:x=>{c(x),n?.();},children:jsx("div",{style:g,children:v})}):f?jsx("div",{role:"link",tabIndex:0,style:g,onClick:x=>{c(x),n?.();},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),c(x),n?.());},children:v}):jsx("div",{style:g,children:v})}var vl=forwardRef(function({sortBy:t,sortAsc:r,minVolume:o,signal:n,onSelectMatch:i,getMatchHref:s,onSelectLeg:a,getLegHref:l,onSelect:d,onHover:u,getMarketHref:p,LinkComponent:m,onStatsChange:c},f){let{t:g}=useTranslation(),{data:v,hasNextPage:x,fetchNextPage:b,isFetchingNextPage:w,isLoading:P,isPlaceholderData:h,refetch:y}=useInfiniteMatchMarkets({sort_by:t,sort_asc:r,min_volume:o,signal:n,status:"active",limit:20},{placeholderData:keepPreviousData}),[S,N]=useState(0),[A,D]=useState(false);A&&!h?(D(false),N(Z=>Z+1)):h&&!A&&D(true),useImperativeHandle(f,()=>({refetch:()=>{y();}}),[y]);let z=useMemo(()=>v?.pages.flatMap(Z=>Z.items??[])??[],[v]),F=v?.pages[0]?.total,q=useMemo(()=>{let Z=0,C=0,M=0;for(let U of z){let G=U.spread??0;G>Z&&(Z=G),G>=.03&&M++,U.combined_volume!=null&&(C+=U.combined_volume);}return {activePairs:F??z.length,maxSpread:Z,highSpreadCount:M,totalVolume:C}},[z,F]);useEffect(()=>{q.activePairs>0&&c?.(q);},[q,c]);let $=useRef(null),Q=useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]);if(useEffect(()=>{let Z=$.current;if(!Z)return;let C=new IntersectionObserver(M=>{M[0]?.isIntersecting&&x&&!w&&b();},{rootMargin:"200px"});return C.observe(Z),()=>C.disconnect()},[x,w,b]),useEffect(()=>{if(x)return document.documentElement.style.overscrollBehaviorY="none",()=>{document.documentElement.style.overscrollBehaviorY="";}},[x]),P)return jsx(T0,{});if(z.length===0)return jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"80px 0",color:"rgba(255,255,255,0.35)"},children:jsx("p",{style:{fontSize:18},children:g("predict.matches.empty")})});let re=!x&&z.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(J=>J.items?.map((y,k)=>jsx("div",{style:{animation:`matchCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${k*35}ms both`},children:jsx(cl,{match:y,onSelectMatch:i,getMatchHref:s,onSelectLeg:a,getLegHref:l,onHover:u,onSelect:c,getMarketHref:m,LinkComponent:p})},`${w}-${y.match_id}-${y.source_a}-${y.market_a?.slug??k}`)))}),jsxs("div",{ref:W,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)}}"}),P&&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"})}),v("predict.matches.loadMore")]})]}),le&&jsx(N0,{onScrollToTop:oe})]})});function N0({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 C0(){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(M0,{index:t},t))})]})}function M0({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 I0={spread:"predict.matches.topOpportunities",volume:"predict.matches.highestVolume",confidence:"predict.matches.trendingToday"};function O0(){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 D0({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(O0,{})]})]})]})]})}function pS({onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:n,onHover:o,onSelect:i,getMarketHref:s,LinkComponent:a,bgImageSrc:l}){let{t:c}=useTranslation(),[u,m]=useState("spread"),[p,d]=useState(false),[f,v]=useState(void 0),[g,x]=useState(),b=useRef(null),P=useCallback(w=>{m(w);},[]),S=useCallback(w=>{d(w);},[]),h=useCallback(w=>{startTransition(()=>{x(w);});},[]),N=useCallback(()=>{b.current?.refetch();},[]);return jsxs("div",{style:{minHeight:"100vh",position:"relative"},children:[jsx("style",{children:`
130
+ `}),jsx("div",{className:"matches-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:16},children:v?.pages.map(Z=>Z.items?.map((C,M)=>jsx("div",{style:{animation:`matchCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${M*35}ms both`},children:jsx(pl,{match:C,onSelectMatch:i,getMatchHref:s,onSelectLeg:a,getLegHref:l,onHover:u,onSelect:d,getMarketHref:p,LinkComponent:m})},`${S}-${C.match_id}-${C.source_a}-${C.market_a?.slug??M}`)))}),jsxs("div",{ref:$,style:{display:"flex",flexDirection:"column",alignItems:"center",gap:8,padding:"16px 0",minHeight:1},children:[jsx("style",{children:"@keyframes match-load-spin{to{transform:rotate(360deg)}}"}),w&&jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#71717a",fontSize:13},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:"match-load-spin 1s linear infinite"},children:jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),g("predict.matches.loadMore")]})]}),re&&jsx(E0,{onScrollToTop:Q})]})});function E0({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 T0(){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(L0,{index:t},t))})]})}function L0({index:e}){let r={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:`shimmer 1.8s ease-in-out infinite ${e*150}ms`,borderRadius:6};return jsxs("div",{style:{borderRadius:16,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden"},children:[jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",padding:"16px 16px 12px"},children:[jsx("div",{style:{...r,height:14,width:e%2===0?"75%":"60%"}}),jsx("div",{style:{...r,height:24,width:64,borderRadius:10,flexShrink:0,marginLeft:12}})]}),jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,padding:"0 16px"},children:[0,1].map(o=>jsxs("div",{style:{borderRadius:12,border:"1px solid rgba(255,255,255,0.04)",background:"rgba(255,255,255,0.02)",padding:12,display:"flex",flexDirection:"column",gap:8},children:[jsx("div",{style:{...r,height:10,width:72}}),jsx("div",{style:{...r,height:10,width:48}}),jsx("div",{style:{...r,height:20,width:56}}),jsx("div",{style:{...r,height:10,width:60,marginTop:4}})]},o))}),jsx("div",{style:{padding:"12px 16px"},children:jsx("div",{style:{...r,height:36,borderRadius:10,width:"100%"}})}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",padding:"10px 16px"},children:[jsxs("div",{style:{display:"flex",gap:12},children:[jsx("div",{style:{...r,height:10,width:40}}),jsx("div",{style:{...r,height:10,width:50}})]}),jsx("div",{style:{...r,height:10,width:56}})]})]})}var A0={spread:"predict.matches.topOpportunities",volume:"predict.matches.highestVolume",confidence:"predict.matches.trendingToday"};function F0(){let[e,t]=useState("");return useEffect(()=>{let r=()=>{let n=new Date;return `${String(n.getHours()).padStart(2,"0")}:${String(n.getMinutes()).padStart(2,"0")}`};t(r());let o=setInterval(()=>t(r()),1e4);return ()=>clearInterval(o)},[]),jsx("span",{children:e})}function B0({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(F0,{})]})]})]})]})}function fS({onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:o,onHover:n,onSelect:i,getMarketHref:s,LinkComponent:a,bgImageSrc:l}){let{t:d}=useTranslation(),[u,p]=useState("spread"),[m,c]=useState(false),[f,g]=useState(void 0),[v,x]=useState(),b=useRef(null),w=useCallback(S=>{p(S);},[]),P=useCallback(S=>{c(S);},[]),h=useCallback(S=>{startTransition(()=>{x(S);});},[]),y=useCallback(()=>{b.current?.refetch();},[]);return jsxs("div",{style:{minHeight:"100vh",position:"relative"},children:[jsx("style",{children:`
131
131
  @keyframes matchFadeIn{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}
132
132
  .match-fade-in{animation:matchFadeIn .5s ease-out both}
133
133
  .match-fade-in-d1{animation:matchFadeIn .5s ease-out .1s both}
134
134
  .match-fade-in-d2{animation:matchFadeIn .5s ease-out .2s both}
135
- `}),jsxs("div",{style:{position:"relative",overflow:"hidden",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:0,overflow:"hidden"},children:[l&&jsx("img",{src:l,alt:"","aria-hidden":"true",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",objectPosition:"center center",opacity:.3,mixBlendMode:"lighten",maskImage:"linear-gradient(to bottom, black 50%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 50%, transparent 100%)"}}),jsx("div",{style:{position:"absolute",inset:0,opacity:.025,backgroundImage:"radial-gradient(circle at 1px 1px, rgb(255 255 255) 1px, transparent 0)",backgroundSize:"20px 20px"}})]}),jsx("style",{children:".matches-hero-wrap{padding:40px 16px 32px}@media(min-width:640px){.matches-hero-wrap{padding:48px 24px 40px}}@media(min-width:1024px){.matches-hero-wrap{padding:52px 32px 44px}}"}),jsx("div",{className:"match-fade-in matches-hero-wrap",style:{position:"relative",zIndex:2,maxWidth:1152,margin:"0 auto"},children:jsx(ol,{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(I0[u])}),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(rl,{sortBy:u,onSortChange:P,sortAsc:p,onSortAscChange:S,minVolume:f,onMinVolumeChange:v,onRefresh:N})]})]}),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(fl,{ref:b,sortBy:u,sortAsc:p,minVolume:f,onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:n,onHover:o,onSelect:i,getMarketHref:s,LinkComponent:a,onStatsChange:h})]}),jsx(D0,{stats:g})]})}function ti(e){return e==null?"-":formatAmountInUsd(e)}var B0={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"}},H0={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 z0(e){return B0[e]??H0}function W0(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 U0(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 bS({group:e,onSelectEntry:t,getEventHref:r,LinkComponent:n}){let {t:o}=useTranslation(),i=useMemo(()=>W0(e),[e]),s=e.max_spread!=null?e.max_spread*100:null,[a,l]=useMemo(()=>U0(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 m=a.yesPrice!=null&&l.yesPrice!=null?a.yesPrice<=l.yesPrice?a:l:null,p=m?Mt(m.source):null,d=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 v=f.currentTarget;v.style.borderColor="rgba(63,63,70,0.6)",v.style.boxShadow="0 10px 15px -3px rgba(0,0,0,0.2)";},onMouseLeave:f=>{let v=f.currentTarget;v.style.borderColor="rgba(39,39,42,0.6)",v.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(vl,{data:a,isCheaper:m===a,onSelect:t,getEventHref:r,LinkComponent:n}),jsx(vl,{data:l,isCheaper:m===l,onSelect:t,getEventHref:r,LinkComponent:n})]}),m&&p&&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 ${d==="amber"?"rgba(255,185,0,0.15)":"rgba(166,132,255,0.15)"}`,background:d==="amber"?"rgba(255,185,0,0.05)":"rgba(166,132,255,0.05)"},onClick:()=>m.event&&t?.(m.event),children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,flexShrink:0,color:d==="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:d==="amber"?"rgba(255,185,0,0.9)":"rgba(166,132,255,0.9)"},children:o("predict.matches.buyEdge",{platform:m.source.charAt(0).toUpperCase()+m.source.slice(1),spread:s.toFixed(1)})}),jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,marginLeft:"auto",color:d==="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"})]}),ti(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"})}),ti(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 vl({data:e,isCheaper:t,onSelect:r,getEventHref:n,LinkComponent:o}){let{t:i}=useTranslation(),s=Mt(e.source),a=z0(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:u=>{u.currentTarget.style.borderColor=a.hoverBorder;},onMouseLeave:u=>{u.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:[ti(e.volume)," ",i("predict.matches.volume")]})]});return l&&o?jsx(o,{href:l,className:"block",children:c}):c}function j0(e){return formatAmountInUsd(e)}function NS({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(Zn,{label:r("predict.matches.stats.matchedMarkets"),value:n.count.toLocaleString()}),jsx(ri,{}),jsx(Zn,{label:r("predict.matches.stats.totalVolume"),value:j0(n.totalVolume)}),jsx(ri,{}),jsx(Zn,{label:r("predict.matches.stats.highestSpread"),value:`${(n.maxSpread*100).toFixed(1)}\xA2`,valueClassName:"text-green-400"}),jsx(ri,{}),jsx(Zn,{label:r("predict.matches.stats.platforms"),value:String(n.platformCount)})]})}function Zn({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 ri(){return jsx("span",{className:"hidden text-neutral-700 sm:inline",children:"|"})}function yl(e){return `${(e*100).toFixed(1)}\xA2`}function G0(e){return e>=.05?"text-green-400":e>=.02?"text-yellow-400":"text-neutral-400"}function TS({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",G0(e)),children:yl(e)}),n&&jsxs("span",{className:"text-xs text-green-500/80",children:["+",yl(t)]})]})}var on=10,Z0=64,Pl=40,eo=48;function Nl({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:n}=useTranslation(),[o,i]=useState(1),{data:s,isLoading:a,fetchNextPage:l,hasNextPage:c,isFetchingNextPage:u}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:50}),{data:m,isLoading:p,fetchNextPage:d,hasNextPage:f,isFetchingNextPage:v}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:50}),g=a||p,x=u||v,b=c||f,P=useMemo(()=>{let D=[];return s?.pages&&D.push(...s.pages.flatMap(K=>K.items)),m?.pages&&D.push(...m.pages.flatMap(K=>K.items)),D.sort((K,W)=>(W.timestamp??0)-(K.timestamp??0)),D},[s,m]),S=Math.max(1,Math.ceil(P.length/on)+(b?1:0)),h=(o-1)*on,N=P.slice(h,h+on),w=useCallback(()=>{i(D=>Math.max(1,D-1));},[]),E=useCallback(async()=>{o*on>=P.length&&b&&(c&&await l(),f&&await d()),i(K=>K+1);},[o,P.length,b,c,f,l,d]),T=o>1,_=o*on<P.length||b;if(g)return jsx(ih,{height:r});if(P.length===0&&!b)return jsx(oh,{message:n("predict.profile.noHistory"),height:r});let G=r-Pl-eo;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.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:G},children:[N.map((D,K)=>jsx(eh,{trade:D},D.id??`${h+K}`)),x&&jsx("div",{className:"flex justify-center items-center py-4",children:jsx(Spinner,{size:"sm"})})]}),jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:eo},children:[jsxs("button",{type:"button",disabled:!T,onClick:w,className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",T?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",n("predict.profile.previous")]}),Array.from({length:Math.min(S,5)},(D,K)=>{let W=K+1;return jsx("button",{type:"button",onClick:()=>i(W),className:cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",W===o?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:W},W)}),jsxs("button",{type:"button",disabled:!_,onClick:E,className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",_?"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-eo},children:N.map((D,K)=>jsx(th,{trade:D},D.id??`m-${h+K}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:eo},children:[jsx("button",{type:"button",disabled:!T,onClick:w,className:cn("text-sm cursor-pointer",T?"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:!_,onClick:E,className:cn("text-sm cursor-pointer",_?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function eh({trade:e}){let{t}=useTranslation(),r=e.type==="REDEEM",n=e.side?.toUpperCase()==="BUY",o=e.price??0,i=e.usd_size??0,s=Cl(e.type,t),a=r||n,l=a?"+":"-",c=a?"text-success":"text-foreground",u=e.event?.title??e.market?.question??"\u2014",m=e.event?.image_url,p=e.outcome??"",d=Ll(e.timestamp),f=Ml(e),v=rh(e),g=nh(e);return jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:Z0},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:[m&&jsx("img",{src:m,alt:"",className:"w-8 h-8 rounded-full object-cover shrink-0"}),jsxs("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:[jsx("span",{className:"text-foreground truncate font-medium text-sm",children:u}),jsxs("span",{className:"text-[11px] text-neutral",children:[p&&jsx("span",{className:"mr-1",children:p}),jsx("span",{children:d})]})]})]})}),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:Tl(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",v!==null?v>=0?"text-success":"text-danger":"text-neutral"),children:v!==null?`${v>=0?"+":"-"}$${Math.abs(v).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(El,{})})})]})}function th({trade:e}){let{t}=useTranslation(),r=e.type==="REDEEM",n=e.side?.toUpperCase()==="BUY",o=e.price??0,i=e.usd_size??0,s=Cl(e.type,t),a=e.event?.title??e.market?.question??"\u2014",l=Ll(e.timestamp),c=Ml(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:Tl(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(El,{})})]})]})}function Cl(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 Ml(e){if(e.tx_hash)return e.source==="polymarket"?`https://polygonscan.com/tx/${e.tx_hash}`:`https://solscan.io/tx/${e.tx_hash}`}function rh(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 nh(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 El(){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 oh({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function ih({height:e}){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:e},children:Array.from({length:6}).map((t,r)=>jsx(Skeleton,{className:"h-12 w-full rounded-md"},r))})}function Tl(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function Ll(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 sn=10,ph=64,_l=40,to=48;function Ol({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:n}=useTranslation(),o=useCancelOrder(),[i,s]=useState(1),{data:a,isLoading:l,fetchNextPage:c,hasNextPage:u,isFetchingNextPage:m}=useInfiniteOrders({source:"kalshi",wallet_address:e??""}),{data:p,isLoading:d,fetchNextPage:f,hasNextPage:v,isFetchingNextPage:g}=useInfiniteOrders({source:"polymarket",wallet_address:t??""}),x=l||d,b=m||g,P=u||v,S=useMemo(()=>{let W=[],oe=new Set(["live","open","submitted","pending"]);return a?.pages&&W.push(...a.pages.flatMap(le=>le.items).filter(le=>oe.has(le.status))),p?.pages&&W.push(...p.pages.flatMap(le=>le.items).filter(le=>oe.has(le.status))),W},[a,p]),h=useCallback(W=>{o.mutate({source:W.source,id:W.id});},[o]),N=Math.max(1,Math.ceil(S.length/sn)+(P?1:0)),w=(i-1)*sn,E=S.slice(w,w+sn),T=useCallback(()=>{s(W=>Math.max(1,W-1));},[]),_=useCallback(async()=>{i*sn>=S.length&&P&&(u&&await c(),v&&await f()),s(oe=>oe+1);},[i,S.length,P,u,v,c,f]),G=i>1,D=i*sn<S.length||P;if(x)return jsx(hh,{height:r});if(S.length===0&&!P)return jsx(gh,{message:n("predict.profile.noOrders"),height:r});let K=r-_l-to;return jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxs("div",{className:"hidden lg:flex items-center text-neutral text-xs font-normal shrink-0 border-b border-border/50",style:{height:_l},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children: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:K},children:[E.map(W=>jsx(mh,{order:W,onCancel:h},W.id)),b&&jsx("div",{className:"flex justify-center items-center py-4",children:jsx(Spinner,{size:"sm"})})]}),jsx(Il,{className:"hidden lg:flex",currentPage:i,totalPages:N,canGoPrev:G,canGoNext:D,onPrev:T,onNext:_,onPage:s,t:n}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-to},children:E.map(W=>jsx(fh,{order:W,onCancel:h},W.id))}),jsx(Il,{className:"lg:hidden",currentPage:i,totalPages:N,canGoPrev:G,canGoNext:D,onPrev:T,onNext:_,onPage:s,t:n,compact:true})]})}function mh({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:ph},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?Dl(o):"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:i>0?`$${i.toFixed(2)}`:"\u2014"})]})}function fh({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?Dl(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 Il({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:to},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:to},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)},(u,m)=>{let p=m+1;return jsx("button",{type:"button",onClick:()=>a(p),className:cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",p===t?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:p},p)}),jsxs("button",{type:"button",disabled:!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 gh({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function hh({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 Dl(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}var ai=10,yh=64,Al=40,ro=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 v of e)n?.(v);},[e,n]);if(t)return jsx(Ph,{height:r});if(e.length===0)return jsx(wh,{message:i("predict.profile.noPositions"),height:r});let c=Math.max(1,Math.ceil(e.length/ai)),u=(s-1)*ai,m=e.slice(u,u+ai),p=s>1,d=s<c,f=r-Al-ro;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:Al},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:m.map((v,g)=>jsx(kh,{position:v,onClosePosition:n,onEventClick:o},`${v.source}-${v.market?.slug??u+g}`))}),jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:ro},children:[jsxs("button",{type:"button",disabled:!p,onClick:()=>a(v=>Math.max(1,v-1)),className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",p?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",i("predict.profile.previous")]}),Array.from({length:Math.min(c,5)},(v,g)=>{let x=g+1;return jsx("button",{type:"button",onClick:()=>a(x),className:cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",x===s?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:x},x)}),jsxs("button",{type:"button",disabled:!d,onClick:()=>a(v=>v+1),className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",d?"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-ro},children:m.map((v,g)=>jsx(Sh,{position:v,onClose:n,onEventClick:o},`${v.source}-${v.market?.slug??`m-${u+g}`}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:ro},children:[jsx("button",{type:"button",disabled:!p,onClick:()=>a(v=>Math.max(1,v-1)),className:cn("text-sm cursor-pointer",p?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:s}),jsx("button",{type:"button",disabled:!d,onClick:()=>a(v=>v+1),className:cn("text-sm cursor-pointer",d?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function kh({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,u=o>0?"text-success":o<0?"text-danger":"text-foreground",m=o>0?"+":"",p=e.event?.title??e.market?.question??"\u2014",d=e.event?.image_url,f=e.side,v=e.market?.outcomes?.[0]?.label??"",g=e.market?.end_at?Nh(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:yh},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:[d&&jsx("img",{src:d,alt:"",className:"w-8 h-8 rounded-full object-cover shrink-0"}),jsxs("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:[jsx("span",{className:"text-foreground truncate font-medium text-sm",children:p}),jsxs("span",{className:"text-[11px] text-neutral",children:[jsx("span",{className:cn("font-medium",f.toLowerCase()==="yes"?"text-success":"text-danger"),children:f}),v&&jsxs(Fragment,{children:[jsx("span",{className:"mx-1",children:"\xB7"}),jsx("span",{children:v})]})]})]})]})}),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:zr(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:li(s)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:li(a)}),jsxs("div",{className:cn("flex-[1.5] pr-2 text-right font-mono",u),children:[jsxs("span",{children:[m,"$",Math.abs(o).toFixed(2)]}),jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",m,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 Sh({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(no,{label:n("predict.profile.totalSize"),value:zr(e.size)}),jsx(no,{label:n("predict.profile.markPrice"),value:li(s)}),jsx(no,{label:n("predict.profile.pnl"),value:`${l}$${Math.abs(o).toFixed(2)} (${l}${i.toFixed(1)}%)`,className:a}),jsx(no,{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 no({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 wh({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function Ph({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 li(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function Nh(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 d of e)a+=d.realized_pnl??0,l+=d.current_value??d.size*(d.current_price??0);let c=0,u=0,m=0;for(let d of t)c+=d.usd_size??0,d.type==="REDEEM"&&(m++,(d.usd_size??0)>0&&u++);let p=m>0?`${u} / ${m}`:"0 / 0";return {realizedPnl:a,positionsValue:l,volume:c,winRateStr:p}},[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(di,{label:n("predict.profile.winRate"),value:o.winRateStr,isLoading:r}),jsx(di,{label:n("predict.profile.positions"),value:`$${o.positionsValue.toFixed(2)}`,isLoading:r}),jsx(di,{label:n("predict.profile.volume"),value:`$${o.volume.toFixed(2)}`,isLoading:r})]})]})}function di({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 ui=600;function Ih({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:u,isLoading:m}=usePositions({source:"polymarket",user:t??""}),p=useMemo(()=>{let w=[];return l?.positions&&w.push(...l.positions),u?.positions&&w.push(...u.positions),w},[l,u]),d=c||m,{data:f,isLoading:v}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:100}),{data:g,isLoading:x}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:100}),b=useMemo(()=>[...f?.pages?.flatMap(E=>E.items)??[],...g?.pages?.flatMap(E=>E.items)??[]],[f,g]),P=d||v||x,S=p.length,N=[{key:"positions",label:S>0?`${o("predict.profile.positionsTab")} (${S})`: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:p,trades:b,isLoading:P}),jsx("div",{className:"flex items-center gap-1 border-b border-border",children:N.map(w=>jsx("button",{type:"button",onClick:()=>s(w.key),className:cn("px-3 py-3 text-base font-normal transition-colors cursor-pointer whitespace-nowrap",i===w.key?"text-foreground border-b-2 border-foreground":"text-neutral hover:text-foreground"),children:w.label},w.key))}),jsxs("div",{className:"py-2",children:[i==="positions"&&jsx(Fl,{positions:p,isLoading:d,listHeight:ui,onClosePosition:r,onEventClick:n}),i==="orders"&&jsx(Ol,{solanaAddress:e,evmAddress:t,listHeight:ui}),i==="history"&&jsx(Nl,{solanaAddress:e,evmAddress:t,listHeight:ui})]})]}):jsx("div",{className:"flex items-center justify-center text-sm text-neutral py-24 px-4",children:o("predict.profile.connectWallet")})}function Cw({isOpen:e,onClose:t,safeDeployed:r,tokenApproved:n,onDeployAndApprove:o}){let{t:i}=useTranslation(),[s,a]=useState(false),[l,c]=useState(null),[u,m]=useState(false),p=r||u,d=n||u,f=p?"done":s?"running":"pending",v=d?"done":p&&s?"running":"pending",g=p&&d,x=useCallback(async()=>{c(null),m(false),a(true);try{await o(),m(!0);}catch(h){c(h instanceof Error?h.message:String(h));}finally{a(false);}},[o]),b=[{key:"step1",label:i("predict.setup.step1"),desc:i("predict.setup.step1Desc"),status:f},{key:"step2",label:i("predict.setup.step2"),desc:i("predict.setup.step2Desc"),status:v}],P=()=>{g?t():x();},S=i(g?"predict.setup.done":"predict.setup.setupButton");return jsx(StyledModal,{isOpen:e,onOpenChange:h=>{h||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:i("predict.setup.modalTitle")}),jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxs("div",{className:"px-5 pb-5 space-y-4",children:[jsx("p",{className:"text-[13px] text-zinc-400 text-left",children:i("predict.setup.modalDescription")}),jsx("div",{className:"space-y-2.5",children:b.map((h,N)=>jsxs("div",{className:"flex gap-3 rounded-[10px] border border-zinc-700/50 bg-zinc-800/50 px-3 py-3",children:[jsx(Bh,{index:N+1,status:h.status}),jsxs("div",{className:"flex-1 min-w-0 pt-0.5",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("p",{className:"text-sm font-medium text-zinc-200",children:h.label}),jsx("span",{className:`text-[11px] leading-none ${h.status==="done"?"text-[#c7ff2e]":h.status==="running"?"text-[#c7ff2e]/70":"text-zinc-500"}`,children:h.status==="done"?i("predict.setup.stepComplete"):h.status==="running"?i("predict.setup.stepRunning"):i("predict.setup.stepPending")})]}),jsx("p",{className:"text-xs text-zinc-500 mt-1",children:h.desc})]})]},h.key))}),l&&jsx("div",{className:"rounded-[10px] bg-red-500/10 border border-red-500/20 px-3 py-2",children:jsx("p",{className:"text-xs text-red-400",children:l})}),jsx("button",{type:"button",onClick:P,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")]}):S}),!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 Bh({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{tv as CHART_RANGE_DURATION,Zh as CHART_RANGE_PERIOD,ev as CHART_RANGE_SAMPLE_INTERVAL,bn as CandlestickPeriod,Kh as CategoriesSkeleton,hi as CategoriesUI,bi as CategoriesWidget,ie as ChartRange,Vo as CommentItemUI,yn as DEFAULT_CHART_RANGE,Ur as DEFAULT_FILTER_STATE,Hr as DEFAULT_PAGE_SIZE,iv as DEFAULT_PRICE_HISTORY_INTERVAL,zf as EventCommentsWidget,v1 as EventDetailPage,Yr as EventDetailSkeleton,fa as EventDetailUI,ga as EventDetailWidget,rs as EventItem,Ys as EventMarketDepthChartUI,ta as EventMarketDetailWidget,ia as EventPriceChart,Ai as EventsFilterUI,qx as EventsHero,$x as EventsPage,gx as EventsPageSkeleton,So as EventsSkeleton,Ui as EventsToolbarUI,as as EventsUI,cs as EventsWidget,Cn as KycModal,ho as MAX_PRICE_HISTORY_MARKETS,bS as MatchGroupCard,cl as MatchMarketCard,rl as MatchesFilterBar,ol as MatchesHero,pS as MatchesPage,NS as MatchesStatsBar,fl as MatchesWidget,ov as ORDER_MAX_PRICE,nv as ORDER_MIN_PRICE,kn as ORDER_MIN_QUANTITY,Sn as ORDER_MIN_USDC,rv as ORDER_PRICE_STEP,_u as PREDICT_REDEEM_MODAL_ID,Qo as PREDICT_SEARCH_MODAL_ID,Lo as PREDICT_SELL_MODAL_ID,Wr as PREDICT_TRADE_MODAL_ID,sv as PRICE_HISTORY_SAMPLE_INTERVAL,ys as PredictRedeemModal,hk as PredictSearchModal,As as PredictSellModal,Tn as PredictTradeModal,ac as PredictWalletProvider,wr as PriceHistoryInterval,Ih as ProfilePage,xs as RedeemFormWidget,Wi as SORT_PRESETS,go as STATIC_CATEGORIES,Nk as SearchEventsButton,Ra as SearchHistoryUI,_a as SearchHistoryWidget,Ia as SearchInputUI,Oa as SearchResultItemUI,Ha as SearchResultListWidget,Ka as SearchWidget,Os as SellFormUI,An as SellFormWidget,Cw as SetupModal,lf as SimilarEventCard,ba as SimilarEventsSection,jy as SourceBadge,TS as SpreadIndicator,Us as TradeFormSkeleton,Oi as TradeFormUI,En as TradeFormWidget,Hs as UserActivitySection,ko as countActiveFilters,ar as fireCelebration,ye as floorToDecimals,Qr as formatKMB,zr as formatShares,Mt as getSourceMeta,Nn as parsePolymarketError,wn as resolveExpiration,Pn as roundToTickSize,P1 as useEventDetail,Vi as useEventsInfinite,Qn as usePredictSearchHistory,sr as usePredictWallet,Da as useSearchResultListScript,$a as useSearchScript,Ns as useSellForm,Ci 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(al,{stats:v})})]}),jsxs("div",{style:{position:"sticky",top:0,zIndex:40,background:"rgba(10,10,11,0.8)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsx("style",{children:".matches-toolbar-inner{padding:12px 16px}@media(min-width:640px){.matches-toolbar-inner{padding:12px 24px}}@media(min-width:1024px){.matches-toolbar-inner{padding:12px 32px}}"}),jsxs("div",{className:"matches-toolbar-inner",style:{maxWidth:1152,margin:"0 auto",display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,minWidth:0},children:[jsx("div",{className:"hidden sm:flex",style:{alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:10,background:"linear-gradient(to bottom right, rgba(199,255,46,0.15), rgba(23,201,100,0.15))",border:"1px solid rgba(199,255,46,0.15)",flexShrink:0},children:jsxs("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"}),jsx("path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"}),jsx("path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"})]})}),jsxs("div",{style:{minWidth:0},children:[jsx("h2",{style:{fontSize:14,fontWeight:600,color:"#fff",margin:0,letterSpacing:"-0.28px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d(A0[u])}),v&&v.activePairs>0&&jsx("p",{className:"hidden sm:block",style:{fontSize:11,color:"#71717a",margin:0},children:d("predict.matches.pairsFound",{count:v.activePairs})})]})]}),jsx(il,{sortBy:u,onSortChange:w,sortAsc:m,onSortAscChange:P,minVolume:f,onMinVolumeChange:g,onRefresh:y})]})]}),jsx("style",{children:".matches-content-wrap{padding:24px 16px 80px}@media(min-width:640px){.matches-content-wrap{padding:32px 24px 80px}}@media(min-width:1024px){.matches-content-wrap{padding:24px 32px 80px}}"}),jsxs("div",{className:"match-fade-in-d2 matches-content-wrap",style:{position:"relative",maxWidth:1152,margin:"0 auto"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:16,padding:"8px 12px",borderRadius:8,border:"1px solid rgba(39,39,42,0.4)",background:"rgba(24,24,27,0.25)"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#52525b",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"})}),jsxs("p",{style:{fontSize:11,color:"#52525b",lineHeight:1.5,margin:0},children:[jsx("span",{style:{color:"#71717a",fontWeight:500},children:d("predict.matches.experimentalFeature")})," \u2014 ",d("predict.matches.disclaimer")]})]}),jsx(vl,{ref:b,sortBy:u,sortAsc:m,minVolume:f,onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:o,onHover:n,onSelect:i,getMarketHref:s,LinkComponent:a,onStatsChange:h})]}),jsx(B0,{stats:v})]})}function ii(e){return e==null?"-":formatAmountInUsd(e)}var W0={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"}},U0={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 $0(e){return W0[e]??U0}function K0(e){if(!e.matched_markets?.length)return null;let t=null,r=-1;for(let o of e.matched_markets){let n=o.spread??0;n>r&&(r=n,t=o);}return t}function V0(e,t){let r=e.entries.find(a=>a.source===(t?.source_a??e.entries[0]?.source)),o=e.entries.find(a=>a.source===(t?.source_b??e.entries[1]?.source)),n=a=>{if(!a?.outcomes?.[0])return {name:null,price:null};let l=a.outcomes[0];return {name:l.label||null,price:l.best_ask??l.price??null}},i=n(t?.market_a),s=n(t?.market_b);return [{source:t?.source_a??r?.source??"unknown",outcomeName:i.name,yesPrice:i.price,volume:r?.event?.volume??null,event:r?.event},{source:t?.source_b??o?.source??"unknown",outcomeName:s.name,yesPrice:s.price,volume:o?.event?.volume??null,event:o?.event}]}function kS({group:e,onSelectEntry:t,getEventHref:r,LinkComponent:o}){let {t:n}=useTranslation(),i=useMemo(()=>K0(e),[e]),s=e.max_spread!=null?e.max_spread*100:null,[a,l]=useMemo(()=>V0(e,i),[e,i]),d=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?It(p.source):null,c=d?"amber":"violet";return jsxs("div",{className:"group",style:{borderRadius:16,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",position:"relative"},onMouseEnter:f=>{let g=f.currentTarget;g.style.borderColor="rgba(63,63,70,0.6)",g.style.boxShadow="0 10px 15px -3px rgba(0,0,0,0.2)";},onMouseLeave:f=>{let g=f.currentTarget;g.style.borderColor="rgba(39,39,42,0.6)",g.style.boxShadow="none";},children:[s!=null&&jsxs("span",{style:{position:"absolute",top:12,right:12,zIndex:10,display:"inline-flex",alignItems:"center",gap:4,borderRadius:10,padding:"4px 10px",fontSize:12,fontWeight:600,border:`1px solid ${d?"rgba(255,185,0,0.3)":s>=2?"rgba(166,132,255,0.3)":"rgba(156,163,175,0.3)"}`,background:d?"rgba(255,185,0,0.15)":s>=2?"rgba(166,132,255,0.15)":"rgba(156,163,175,0.12)",color:d?"#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(yl,{data:a,isCheaper:p===a,onSelect:t,getEventHref:r,LinkComponent:o}),jsx(yl,{data:l,isCheaper:p===l,onSelect:t,getEventHref:r,LinkComponent:o})]}),p&&m&&s!=null&&jsxs("div",{style:{marginTop:12,padding:"8px 12px",borderRadius:10,display:"flex",alignItems:"center",gap:8,cursor:"pointer",transition:"all 0.15s",border:`1px solid ${c==="amber"?"rgba(255,185,0,0.15)":"rgba(166,132,255,0.15)"}`,background:c==="amber"?"rgba(255,185,0,0.05)":"rgba(166,132,255,0.05)"},onClick:()=>p.event&&t?.(p.event),children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,flexShrink:0,color:c==="amber"?"#ffb900":"#a684ff"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),jsx("span",{style:{fontSize:11,fontWeight:500,color:c==="amber"?"rgba(255,185,0,0.9)":"rgba(166,132,255,0.9)"},children:n("predict.matches.buyEdge",{platform:p.source.charAt(0).toUpperCase()+p.source.slice(1),spread:s.toFixed(1)})}),jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,marginLeft:"auto",color:c==="amber"?"rgba(255,185,0,0.5)":"rgba(166,132,255,0.5)"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M5 12h14"}),jsx("path",{d:"m12 5 7 7-7 7"})]})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.2)",padding:"10px 16px"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,fontSize:10,color:"#71717a"},children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}),ii(e.combined_volume)]}),e.combined_volume_24h!=null&&e.combined_volume_24h>0&&jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width: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"})}),ii(e.combined_volume_24h)," ",n("predict.matches.vol24h")]})]}),e.confidence!=null&&jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,fontSize:10,color:"#52525b"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"})}),Math.round(e.confidence*100),"%"," ",n("predict.matches.match")]})]})]})}function yl({data:e,isCheaper:t,onSelect:r,getEventHref:o,LinkComponent:n}){let{t:i}=useTranslation(),s=It(e.source),a=$0(e.source),l=e.event?o?.(e.event):void 0,d=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:u=>{u.currentTarget.style.borderColor=a.hoverBorder;},onMouseLeave:u=>{u.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:[ii(e.volume)," ",i("predict.matches.volume")]})]});return l&&n?jsx(n,{href:l,className:"block",children:d}):d}function Y0(e){return formatAmountInUsd(e)}function MS({matches:e,total:t}){let{t:r}=useTranslation(),o=useMemo(()=>{let n=0,i=0,s=new Set;for(let a of e){a.max_spread!=null&&a.max_spread>n&&(n=a.max_spread),a.combined_volume!=null&&(i+=a.combined_volume);for(let l of a.entries)s.add(typeof l.source=="string"?l.source:"");}return {count:t??e.length,maxSpread:n,totalVolume:i,platformCount:s.size}},[e,t]);return jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 rounded-xl border border-border/60 bg-background/50 px-4 py-3 text-sm",children:[jsx(ro,{label:r("predict.matches.stats.matchedMarkets"),value:o.count.toLocaleString()}),jsx(si,{}),jsx(ro,{label:r("predict.matches.stats.totalVolume"),value:Y0(o.totalVolume)}),jsx(si,{}),jsx(ro,{label:r("predict.matches.stats.highestSpread"),value:`${(o.maxSpread*100).toFixed(1)}\xA2`,valueClassName:"text-green-400"}),jsx(si,{}),jsx(ro,{label:r("predict.matches.stats.platforms"),value:String(o.platformCount)})]})}function ro({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 si(){return jsx("span",{className:"hidden text-neutral-700 sm:inline",children:"|"})}function wl(e){return `${(e*100).toFixed(1)}\xA2`}function Q0(e){return e>=.05?"text-green-400":e>=.02?"text-yellow-400":"text-neutral-400"}function RS({spread:e,arbProfit:t,className:r}){if(e==null)return null;let o=t!=null&&t>0;return jsxs("div",{className:cn$1("flex items-center gap-x-2",r),children:[jsx("span",{className:cn$1("text-sm font-semibold",Q0(e)),children:wl(e)}),o&&jsxs("span",{className:"text-xs text-green-500/80",children:["+",wl(t)]})]})}var cn=10,rh=64,Ml=40,no=48;function El({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:o}=useTranslation(),[n,i]=useState(1),{data:s,isLoading:a,fetchNextPage:l,hasNextPage:d,isFetchingNextPage:u}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:50}),{data:p,isLoading:m,fetchNextPage:c,hasNextPage:f,isFetchingNextPage:g}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:50}),v=a||m,x=u||g,b=d||f,w=useMemo(()=>{let F=[];return s?.pages&&F.push(...s.pages.flatMap(q=>q.items)),p?.pages&&F.push(...p.pages.flatMap(q=>q.items)),F.sort((q,$)=>($.timestamp??0)-(q.timestamp??0)),F},[s,p]),P=Math.max(1,Math.ceil(w.length/cn)+(b?1:0)),h=(n-1)*cn,y=w.slice(h,h+cn),S=useCallback(()=>{i(F=>Math.max(1,F-1));},[]),N=useCallback(async()=>{n*cn>=w.length&&b&&(d&&await l(),f&&await c()),i(q=>q+1);},[n,w.length,b,d,f,l,c]),A=n>1,D=n*cn<w.length||b;if(v)return jsx(lh,{height:r});if(w.length===0&&!b)return jsx(ah,{message:o("predict.profile.noHistory"),height:r});let z=r-Ml-no;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:o("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.profile.action")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.profile.status")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.price")}),jsx("div",{className:"flex-[1.5] pr-2 text-right",children:o("predict.profile.depositWithdraw")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.pnl")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.fee")}),jsx("div",{className:"w-10 shrink-0"})]}),jsxs("div",{className:"hidden lg:block overflow-y-auto",style:{height:z},children:[y.map((F,q)=>jsx(nh,{trade:F},F.id??`${h+q}`)),x&&jsx("div",{className:"flex justify-center items-center py-4",children:jsx(Spinner,{size:"sm"})})]}),jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:no},children:[jsxs("button",{type:"button",disabled:!A,onClick:S,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",A?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",o("predict.profile.previous")]}),Array.from({length:Math.min(P,5)},(F,q)=>{let $=q+1;return jsx("button",{type:"button",onClick:()=>i($),className:cn$1("w-8 h-8 rounded text-sm transition-colors cursor-pointer",$===n?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:$},$)}),jsxs("button",{type:"button",disabled:!D,onClick:N,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",D?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[o("predict.profile.next")," \u2192"]})]}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-no},children:y.map((F,q)=>jsx(oh,{trade:F},F.id??`m-${h+q}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:no},children:[jsx("button",{type:"button",disabled:!A,onClick:S,className:cn$1("text-sm cursor-pointer",A?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:n}),jsx("button",{type:"button",disabled:!D,onClick:N,className:cn$1("text-sm cursor-pointer",D?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function nh({trade:e}){let{t}=useTranslation(),r=e.type==="REDEEM",o=e.side?.toUpperCase()==="BUY",n=e.price??0,i=e.usd_size??0,s=Tl(e.type,t),a=r||o,l=a?"+":"-",d=a?"text-success":"text-foreground",u=e.event?.title??e.market?.question??"\u2014",p=e.event?.image_url,m=e.outcome??"",c=Il(e.timestamp),f=Ll(e),g=ih(e),v=sh(e);return jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:rh},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:u}),jsxs("span",{className:"text-[11px] text-neutral",children:[m&&jsx("span",{className:"mr-1",children:m}),jsx("span",{children:c})]})]})]})}),jsx("div",{className:"flex-1 pr-2",children:jsx("span",{className:cn$1("text-sm font-medium",r?"text-primary":o?"text-success":"text-danger"),children:t(r?"predict.profile.redeem":o?"predict.profile.buy":"predict.profile.sell")})}),jsx("div",{className:"flex-1 pr-2 text-sm text-foreground",children:s}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:_l(n)}),jsx("div",{className:cn$1("flex-[1.5] pr-2 text-right font-mono",d),children:i>0?jsxs(Fragment,{children:[l,"$",i.toFixed(2)]}):"\u2014"}),jsx("div",{className:cn$1("flex-1 pr-2 text-right font-mono",g!==null?g>=0?"text-success":"text-danger":"text-neutral"),children:g!==null?`${g>=0?"+":"-"}$${Math.abs(g).toFixed(2)}`:"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-neutral",children:v!==null?`$${v.toFixed(2)}`:"\u2014"}),jsx("div",{className:"w-10 shrink-0 text-right",children:f&&jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"text-neutral hover:text-foreground transition-colors","aria-label":"View transaction",children:jsx(Rl,{})})})]})}function oh({trade:e}){let{t}=useTranslation(),r=e.type==="REDEEM",o=e.side?.toUpperCase()==="BUY",n=e.price??0,i=e.usd_size??0,s=Tl(e.type,t),a=e.event?.title??e.market?.question??"\u2014",l=Il(e.timestamp),d=Ll(e);return jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.event?.image_url&&jsx("img",{src:e.event.image_url,alt:"",className:"w-6 h-6 rounded-full object-cover shrink-0"}),jsx("span",{className:"text-sm font-medium text-foreground line-clamp-2",children:a})]}),jsx("span",{className:"text-[11px] text-neutral whitespace-nowrap",children:l})]}),jsxs("div",{className:"flex items-center gap-4 text-xs flex-wrap",children:[jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.action")}),jsx("span",{className:cn$1("font-medium",r?"text-primary":o?"text-success":"text-danger"),children:t(r?"predict.profile.redeem":o?"predict.profile.buy":"predict.profile.sell")})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.status")}),jsx("span",{className:"text-foreground",children:s})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.price")}),jsx("span",{className:"font-mono text-foreground",children:_l(n)})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.depositWithdraw")}),jsx("span",{className:"font-mono text-foreground",children:i>0?`$${i.toFixed(2)}`:"\u2014"})]}),d&&jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"ml-auto text-neutral hover:text-foreground transition-colors",children:jsx(Rl,{})})]})]})}function Tl(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 Ll(e){if(e.tx_hash)return e.source==="polymarket"?`https://polygonscan.com/tx/${e.tx_hash}`:`https://solscan.io/tx/${e.tx_hash}`}function ih(e){let t=e.provider_meta;if(t){let r=t.pnl??t.profit??t.realized_pnl??t["dflow.pnl"];if(typeof r=="number")return r;if(typeof r=="string"&&r!==""){let o=parseFloat(r);if(!Number.isNaN(o))return o}}return e.type==="REDEEM"&&e.usd_size!=null?e.usd_size:null}function sh(e){let t=e.provider_meta;if(t){let r=t.fee??t.fees??t.trading_fee??t["dflow.fee"];if(typeof r=="number")return r;if(typeof r=="string"&&r!==""){let o=parseFloat(r);if(!Number.isNaN(o))return o}}return null}function Rl(){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 ah({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function lh({height:e}){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:e},children:Array.from({length:6}).map((t,r)=>jsx(Skeleton,{className:"h-12 w-full rounded-md"},r))})}function _l(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function Il(e){let t=new Date(e*1e3),r=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0"),n=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getFullYear(),a=t.getTimezoneOffset(),l=a<=0?"+":"-",d=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${o} ${n}/${i}/${s} (${l}${d})`}var dn=10,gh=64,Dl=40,oo=48;function Fl({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:o}=useTranslation(),n=useCancelOrder(),[i,s]=useState(1),{data:a,isLoading:l,fetchNextPage:d,hasNextPage:u,isFetchingNextPage:p}=useInfiniteOrders({source:"kalshi",wallet_address:e??""}),{data:m,isLoading:c,fetchNextPage:f,hasNextPage:g,isFetchingNextPage:v}=useInfiniteOrders({source:"polymarket",wallet_address:t??""}),x=l||c,b=p||v,w=u||g,P=useMemo(()=>{let $=[],Q=new Set(["live","open","submitted","pending"]);return a?.pages&&$.push(...a.pages.flatMap(re=>re.items).filter(re=>Q.has(re.status))),m?.pages&&$.push(...m.pages.flatMap(re=>re.items).filter(re=>Q.has(re.status))),$},[a,m]),h=useCallback($=>{n.mutate({source:$.source,id:$.id});},[n]),y=Math.max(1,Math.ceil(P.length/dn)+(w?1:0)),S=(i-1)*dn,N=P.slice(S,S+dn),A=useCallback(()=>{s($=>Math.max(1,$-1));},[]),D=useCallback(async()=>{i*dn>=P.length&&w&&(u&&await d(),g&&await f()),s(Q=>Q+1);},[i,P.length,w,u,g,d,f]),z=i>1,F=i*dn<P.length||w;if(x)return jsx(bh,{height:r});if(P.length===0&&!w)return jsx(xh,{message:o("predict.profile.noOrders"),height:r});let q=r-Dl-oo;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:Dl},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:o("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.profile.action")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.profile.type")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.fillPrice")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.cost")})]}),jsxs("div",{className:"hidden lg:block overflow-y-auto",style:{height:q},children:[N.map($=>jsx(hh,{order:$,onCancel:h},$.id)),b&&jsx("div",{className:"flex justify-center items-center py-4",children:jsx(Spinner,{size:"sm"})})]}),jsx(Al,{className:"hidden lg:flex",currentPage:i,totalPages:y,canGoPrev:z,canGoNext:F,onPrev:A,onNext:D,onPage:s,t:o}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-oo},children:N.map($=>jsx(vh,{order:$,onCancel:h},$.id))}),jsx(Al,{className:"lg:hidden",currentPage:i,totalPages:y,canGoPrev:z,canGoNext:F,onPrev:A,onNext:D,onPage:s,t:o,compact:true})]})}function hh({order:e,onCancel:t}){let{t:r}=useTranslation(),o=e.side==="BUY",n=e.price?parseFloat(e.price):0,i=e.in_amount?parseFloat(e.in_amount):n*parseFloat(e.original_size??"0");return jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:gh},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsx("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:jsx("span",{className:"text-foreground truncate font-medium",children:e.outcome??e.market_id??"\u2014"})})}),jsx("div",{className:"flex-1 pr-2",children:jsx("span",{className:cn$1("text-sm font-medium",o?"text-success":"text-danger"),children:r(o?"predict.profile.buy":"predict.profile.sell")})}),jsx("div",{className:"flex-1 pr-2 text-neutral capitalize text-sm",children:e.order_type??"limit"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:n>0?Bl(n):"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:i>0?`$${i.toFixed(2)}`:"\u2014"})]})}function vh({order:e,onCancel:t}){let{t:r}=useTranslation(),o=e.side==="BUY",n=e.price?parseFloat(e.price):0;return jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:cn$1("text-xs font-medium px-1.5 py-0.5 rounded",o?"bg-success/10 text-success":"bg-danger/10 text-danger"),children:e.side}),jsx("span",{className:"text-sm text-foreground capitalize",children:e.outcome??"\u2014"})]}),jsx("span",{className:"text-xs text-neutral capitalize",children:e.order_type??"limit"})]}),jsxs("div",{className:"flex items-center gap-4 text-xs",children:[jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:r("predict.profile.fillPrice")}),jsx("span",{className:"font-mono text-foreground",children:n>0?Bl(n):"\u2014"})]}),jsx("div",{className:"flex-1"}),jsx("button",{type:"button",onClick:()=>t(e),className:"text-xs text-danger hover:text-danger/80 cursor-pointer border border-border rounded px-2 py-1",children:r("predict.orders.cancel")})]})]})}function Al({className:e,currentPage:t,totalPages:r,canGoPrev:o,canGoNext:n,onPrev:i,onNext:s,onPage:a,t:l,compact:d}){return d?jsxs("div",{className:cn$1("flex items-center justify-center gap-3 shrink-0",e),style:{height:oo},children:[jsx("button",{type:"button",disabled:!o,onClick:i,className:cn$1("text-sm cursor-pointer",o?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:t}),jsx("button",{type:"button",disabled:!n,onClick:s,className:cn$1("text-sm cursor-pointer",n?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]}):jsxs("div",{className:cn$1("flex items-center justify-center gap-2 shrink-0",e),style:{height:oo},children:[jsxs("button",{type:"button",disabled:!o,onClick:i,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",o?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",l("predict.profile.previous")]}),Array.from({length:Math.min(r,5)},(u,p)=>{let m=p+1;return jsx("button",{type:"button",onClick:()=>a(m),className:cn$1("w-8 h-8 rounded text-sm transition-colors cursor-pointer",m===t?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:m},m)}),jsxs("button",{type:"button",disabled:!n,onClick:s,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",n?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[l("predict.profile.next")," \u2192"]})]})}function xh({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function bh({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 Bl(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}var ui=10,wh=64,Hl=40,io=48;function zl({positions:e,isLoading:t,listHeight:r,onClosePosition:o,onEventClick:n}){let{t:i}=useTranslation(),[s,a]=useState(1),l=useCallback(()=>{for(let g of e)o?.(g);},[e,o]);if(t)return jsx(Mh,{height:r});if(e.length===0)return jsx(Ch,{message:i("predict.profile.noPositions"),height:r});let d=Math.max(1,Math.ceil(e.length/ui)),u=(s-1)*ui,p=e.slice(u,u+ui),m=s>1,c=s<d,f=r-Hl-io;return jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxs("div",{className:"hidden lg:flex items-center text-neutral text-xs font-normal shrink-0 border-b border-border/50",style:{height:Hl},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:i("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.totalSize")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.value")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.avgPrice")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.markPrice")}),jsxs("div",{className:"flex-[1.5] pr-2 text-right",children:[jsx("span",{children:i("predict.profile.pnl")}),jsxs("span",{className:"text-[10px] ml-1 opacity-60",children:["(",i("predict.profile.pnlExcludeFees"),")"]})]}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.payoutIfRight")}),jsx("div",{className:"flex-[1.5] pr-2 text-right",children:i("predict.profile.estSettlement")}),jsx("div",{className:"w-20 shrink-0 text-right",children:o&&e.length>0&&jsx("button",{type:"button",onClick:l,className:"text-xs text-primary hover:text-primary/80 cursor-pointer transition-colors",children:i("predict.profile.closeAll")})})]}),jsx("div",{className:"hidden lg:block overflow-y-auto",style:{height:f},children:p.map((g,v)=>jsx(Ph,{position:g,onClosePosition:o,onEventClick:n},`${g.source}-${g.market?.slug??u+v}`))}),jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:io},children:[jsxs("button",{type:"button",disabled:!m,onClick:()=>a(g=>Math.max(1,g-1)),className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",m?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",i("predict.profile.previous")]}),Array.from({length:Math.min(d,5)},(g,v)=>{let x=v+1;return jsx("button",{type:"button",onClick:()=>a(x),className:cn$1("w-8 h-8 rounded text-sm transition-colors cursor-pointer",x===s?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:x},x)}),jsxs("button",{type:"button",disabled:!c,onClick:()=>a(g=>g+1),className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",c?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[i("predict.profile.next")," \u2192"]})]}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-io},children:p.map((g,v)=>jsx(Nh,{position:g,onClose:o,onEventClick:n},`${g.source}-${g.market?.slug??`m-${u+v}`}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:io},children:[jsx("button",{type:"button",disabled:!m,onClick:()=>a(g=>Math.max(1,g-1)),className:cn$1("text-sm cursor-pointer",m?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:s}),jsx("button",{type:"button",disabled:!c,onClick:()=>a(g=>g+1),className:cn$1("text-sm cursor-pointer",c?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function Ph({position:e,onClosePosition:t,onEventClick:r}){let{t:o}=useTranslation(),n=e.pnl??0,i=e.pnl_percent??0,s=e.avg_price??0,a=e.current_price??0,l=e.current_value??e.size*a,d=e.size,u=n>0?"text-success":n<0?"text-danger":"text-foreground",p=n>0?"+":"",m=e.event?.title??e.market?.question??"\u2014",c=e.event?.image_url,f=e.side,g=e.market?.outcomes?.[0]?.label??"",v=e.market?.end_at?Eh(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:wh},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxs("button",{type:"button",className:"flex items-center gap-2.5 min-w-0 cursor-pointer text-left",onClick:()=>e.event&&r?.(e.event),children:[c&&jsx("img",{src:c,alt:"",className:"w-8 h-8 rounded-full object-cover shrink-0"}),jsxs("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:[jsx("span",{className:"text-foreground truncate font-medium text-sm",children:m}),jsxs("span",{className:"text-[11px] text-neutral",children:[jsx("span",{className:cn$1("font-medium",f.toLowerCase()==="yes"?"text-success":"text-danger"),children:f}),g&&jsxs(Fragment,{children:[jsx("span",{className:"mx-1",children:"\xB7"}),jsx("span",{children:g})]})]})]})]})}),jsx("div",{className:"flex-1 pr-2 text-right",children:jsxs("div",{className:"flex flex-col items-end",children:[jsxs("span",{className:"font-mono text-foreground",children:["$",l.toFixed(2)]}),jsx("span",{className:"text-[10px] text-neutral",children:o("predict.profile.contracts",{count:Kr(e.size)})})]})}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",(e.size*s).toFixed(2)]}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:pi(s)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:pi(a)}),jsxs("div",{className:cn$1("flex-[1.5] pr-2 text-right font-mono",u),children:[jsxs("span",{children:[p,"$",Math.abs(n).toFixed(2)]}),jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",p,i.toFixed(2),"%)"]})]}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",d.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap text-xs",children:v}),jsx("div",{className:"w-20 shrink-0 text-right",children:t&&jsxs("button",{type:"button",onClick:()=>t(e),className:"inline-flex items-center gap-1 text-xs text-neutral hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{className:"text-danger",children:"\u2715"}),o("predict.profile.close")]})})]})}function Nh({position:e,onClose:t,onEventClick:r}){let{t:o}=useTranslation(),n=e.pnl??0,i=e.pnl_percent??0,s=e.current_price??0,a=n>0?"text-success":n<0?"text-danger":"text-foreground",l=n>0?"+":"",d=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:d})]}),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(so,{label:o("predict.profile.totalSize"),value:Kr(e.size)}),jsx(so,{label:o("predict.profile.markPrice"),value:pi(s)}),jsx(so,{label:o("predict.profile.pnl"),value:`${l}$${Math.abs(n).toFixed(2)} (${l}${i.toFixed(1)}%)`,className:a}),jsx(so,{label:o("predict.profile.payoutIfRight"),value:`$${e.size.toFixed(2)}`})]}),t&&jsx("div",{className:"flex justify-end",children:jsx("button",{type:"button",onClick:()=>t(e),className:"text-xs text-danger hover:text-danger/80 cursor-pointer transition-colors border border-border rounded px-2 py-1",children:o("predict.profile.close")})})]})}function so({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 Ch({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function Mh({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 pi(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function Eh(e){try{let t=new Date(e),r=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0"),n=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getFullYear(),a=t.getTimezoneOffset(),l=a<=0?"+":"-",d=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${o} ${n}/${i}/${s} (${l}${d})`}catch{return "\u2014"}}function Ul({positions:e,trades:t,isLoading:r}){let{t:o}=useTranslation(),n=useMemo(()=>{let a=0,l=0;for(let c of e)a+=c.realized_pnl??0,l+=c.current_value??c.size*(c.current_price??0);let d=0,u=0,p=0;for(let c of t)d+=c.usd_size??0,c.type==="REDEEM"&&(p++,(c.usd_size??0)>0&&u++);let m=p>0?`${u} / ${p}`:"0 / 0";return {realizedPnl:a,positionsValue:l,volume:d,winRateStr:m}},[e,t]),i=n.realizedPnl>0?"text-success":n.realizedPnl<0?"text-danger":"text-foreground",s=n.realizedPnl>0?"+":"";return jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 py-8",children:[jsxs("div",{className:"flex flex-col gap-1",children:[jsx("span",{className:"text-xl text-neutral",children:o("predict.profile.realizedPnl")}),r?jsx(Skeleton,{className:"h-14 w-48 rounded-md"}):jsxs("span",{className:cn$1("text-5xl font-bold tabular-nums",i),children:[s,"$",Math.abs(n.realizedPnl).toFixed(2)]})]}),jsxs("div",{className:"flex items-end gap-8 sm:gap-10",children:[jsx(fi,{label:o("predict.profile.winRate"),value:n.winRateStr,isLoading:r}),jsx(fi,{label:o("predict.profile.positions"),value:`$${n.positionsValue.toFixed(2)}`,isLoading:r}),jsx(fi,{label:o("predict.profile.volume"),value:`$${n.volume.toFixed(2)}`,isLoading:r})]})]})}function fi({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 gi=600;function Ah({solanaAddress:e,evmAddress:t,onClosePosition:r,onEventClick:o}){let{t:n}=useTranslation(),[i,s]=useState("positions"),a=!!(e||t),{data:l,isLoading:d}=usePositions({source:"kalshi",user:e??""}),{data:u,isLoading:p}=usePositions({source:"polymarket",user:t??""}),m=useMemo(()=>{let S=[];return l?.positions&&S.push(...l.positions),u?.positions&&S.push(...u.positions),S},[l,u]),c=d||p,{data:f,isLoading:g}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:100}),{data:v,isLoading:x}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:100}),b=useMemo(()=>[...f?.pages?.flatMap(N=>N.items)??[],...v?.pages?.flatMap(N=>N.items)??[]],[f,v]),w=c||g||x,P=m.length,y=[{key:"positions",label:P>0?`${n("predict.profile.positionsTab")} (${P})`:n("predict.profile.positionsTab")},{key:"orders",label:n("predict.profile.openOrdersTab")},{key:"history",label:n("predict.profile.historyTab")}];return a?jsxs("div",{className:"flex flex-col max-w-[1280px] mx-auto w-full px-4 max-sm:px-2",children:[jsx(Ul,{positions:m,trades:b,isLoading:w}),jsx("div",{className:"flex items-center gap-1 border-b border-border",children:y.map(S=>jsx("button",{type:"button",onClick:()=>s(S.key),className:cn$1("px-3 py-3 text-base font-normal transition-colors cursor-pointer whitespace-nowrap",i===S.key?"text-foreground border-b-2 border-foreground":"text-neutral hover:text-foreground"),children:S.label},S.key))}),jsxs("div",{className:"py-2",children:[i==="positions"&&jsx(zl,{positions:m,isLoading:c,listHeight:gi,onClosePosition:r,onEventClick:o}),i==="orders"&&jsx(Fl,{solanaAddress:e,evmAddress:t,listHeight:gi}),i==="history"&&jsx(El,{solanaAddress:e,evmAddress:t,listHeight:gi})]})]}):jsx("div",{className:"flex items-center justify-center text-sm text-neutral py-24 px-4",children:n("predict.profile.connectWallet")})}function Ew({isOpen:e,onClose:t,safeDeployed:r,tokenApproved:o,onDeployAndApprove:n}){let{t:i}=useTranslation(),[s,a]=useState(false),[l,d]=useState(null),[u,p]=useState(false),m=r||u,c=o||u,f=m?"done":s?"running":"pending",g=c?"done":m&&s?"running":"pending",v=m&&c,x=useCallback(async()=>{d(null),p(false),a(true);try{await n(),p(!0);}catch(h){d(h instanceof Error?h.message:String(h));}finally{a(false);}},[n]),b=[{key:"step1",label:i("predict.setup.step1"),desc:i("predict.setup.step1Desc"),status:f},{key:"step2",label:i("predict.setup.step2"),desc:i("predict.setup.step2Desc"),status:g}],w=()=>{v?t():x();},P=i(v?"predict.setup.done":"predict.setup.setupButton");return jsx(StyledModal,{isOpen:e,onOpenChange:h=>{h||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:i("predict.setup.modalTitle")}),jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxs("div",{className:"px-5 pb-5 space-y-4",children:[jsx("p",{className:"text-[13px] text-zinc-400 text-left",children:i("predict.setup.modalDescription")}),jsx("div",{className:"space-y-2.5",children:b.map((h,y)=>jsxs("div",{className:"flex gap-3 rounded-[10px] border border-zinc-700/50 bg-zinc-800/50 px-3 py-3",children:[jsx(Wh,{index:y+1,status:h.status}),jsxs("div",{className:"flex-1 min-w-0 pt-0.5",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("p",{className:"text-sm font-medium text-zinc-200",children:h.label}),jsx("span",{className:`text-[11px] leading-none ${h.status==="done"?"text-[#c7ff2e]":h.status==="running"?"text-[#c7ff2e]/70":"text-zinc-500"}`,children:h.status==="done"?i("predict.setup.stepComplete"):h.status==="running"?i("predict.setup.stepRunning"):i("predict.setup.stepPending")})]}),jsx("p",{className:"text-xs text-zinc-500 mt-1",children:h.desc})]})]},h.key))}),l&&jsx("div",{className:"rounded-[10px] bg-red-500/10 border border-red-500/20 px-3 py-2",children:jsx("p",{className:"text-xs text-red-400",children:l})}),jsx("button",{type:"button",onClick:w,disabled:s,className:v?"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus":"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:s?jsxs("span",{className:"inline-flex items-center gap-2",children:[jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",children:[jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",className:"opacity-25"}),jsx("path",{d:"M4 12a8 8 0 018-8",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",className:"opacity-75"})]}),i("predict.setup.stepRunning")]}):P}),!v&&jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] text-sm text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:i("common.cancel")})]})]})})})}function Wh({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{ov as CHART_RANGE_DURATION,rv as CHART_RANGE_PERIOD,nv as CHART_RANGE_SAMPLE_INTERVAL,Sn as CandlestickPeriod,qh as CategoriesSkeleton,yi as CategoriesUI,wi as CategoriesWidget,ae as ChartRange,Yo as CommentItemUI,wn as DEFAULT_CHART_RANGE,jr as DEFAULT_FILTER_STATE,$r as DEFAULT_PAGE_SIZE,lv as DEFAULT_PRICE_HISTORY_INTERVAL,$f as EventCommentsWidget,b1 as EventDetailPage,Zr as EventDetailSkeleton,va as EventDetailUI,xa as EventDetailWidget,ss as EventItem,Js as EventMarketDepthChartUI,oa as EventMarketDetailWidget,la as EventPriceChart,zi as EventsFilterUI,Qx as EventsHero,Vx as EventsPage,vx as EventsPageSkeleton,No as EventsSkeleton,ji as EventsToolbarUI,us as EventsUI,ms as EventsWidget,Tn as KycModal,bo as MAX_PRICE_HISTORY_MARKETS,kS as MatchGroupCard,pl as MatchMarketCard,il as MatchesFilterBar,al as MatchesHero,fS as MatchesPage,MS as MatchesStatsBar,vl as MatchesWidget,av as ORDER_MAX_PRICE,sv as ORDER_MIN_PRICE,Pn as ORDER_MIN_QUANTITY,Nn as ORDER_MIN_USDC,iv as ORDER_PRICE_STEP,Du as PREDICT_REDEEM_MODAL_ID,ei as PREDICT_SEARCH_MODAL_ID,Oo as PREDICT_SELL_MODAL_ID,Vr as PREDICT_TRADE_MODAL_ID,cv as PRICE_HISTORY_SAMPLE_INTERVAL,Ps as PredictRedeemModal,xk as PredictSearchModal,Hs as PredictSellModal,_n as PredictTradeModal,pc as PredictWalletProvider,Pr as PriceHistoryInterval,Ah as ProfilePage,Ss as RedeemFormWidget,Vi as SORT_PRESETS,xo as STATIC_CATEGORIES,Mk as SearchEventsButton,Oa as SearchHistoryUI,Da as SearchHistoryWidget,Aa as SearchInputUI,Fa as SearchResultItemUI,Ua as SearchResultListWidget,qa as SearchWidget,Fs as SellFormUI,Hn as SellFormWidget,Ew as SetupModal,uf as SimilarEventCard,Sa as SimilarEventsSection,Gy as SourceBadge,RS as SpreadIndicator,Vs as TradeFormSkeleton,Bi as TradeFormUI,Rn as TradeFormWidget,Us as UserActivitySection,Po as countActiveFilters,dr as fireCelebration,we as floorToDecimals,en as formatKMB,Kr as formatShares,It as getSourceMeta,En as parsePolymarketError,Cn as resolveExpiration,Mn as roundToTickSize,C1 as useEventDetail,Yi as useEventsInfinite,Zn as usePredictSearchHistory,cr as usePredictWallet,Ba as useSearchResultListScript,ja as useSearchScript,Es as useSellForm,Ti as useTradeForm};//# sourceMappingURL=index.mjs.map
137
137
  //# sourceMappingURL=index.mjs.map