@liberfi.io/ui-predict 4.0.86 → 4.0.88
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.js +13 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {createContext,memo,useRef,forwardRef,useState,useImperativeHandle,useMemo,useEffect,useCallback,useContext,createElement,Fragment as Fragment$1,useSyncExternalStore,useLayoutEffect,startTransition,Component}from'react';import {themeSemanticColors,PolymarketIcon,KalshiIcon,cn as cn$1,Skeleton,toast,StyledModal,THEMED_MODAL_BASE_CLASS,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,useLocalizedTimeFormatter,Translation}from'@liberfi.io/i18n';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useWallets,useAuth,useAuthCallback}from'@liberfi.io/wallet-connector';import {useInfiniteMatchMarkets,useBalance,useDFlowKYC,usePolymarketSetup,usePredictClient,PolymarketContext,useTradeResultConfirmation,useTickSize,normalizePolymarketTickSize,useFeeRate,useRebateConfig,useRealtimeOrderbook,pickBestAsk,walkOrderbook,usePositionsMulti,useDFlowQuote,useDFlowSubmit,useOrder,buildSignedV2OrderPayload,buildCtfExchangeDomain,buildOrderMessage,CTF_ORDER_TYPES,buildSignedOrder,buildClobPayload,buildPolymarketL2Headers,resolveEventsParams,useInfiniteEvents,useRedeemPosition,pickBestBid,useAvailableShares,getPolymarketSharesPrecision,useInfiniteOrders,useCancelOrder,useInfiniteTrades,useMarketHistory,useSimilarEvents,useEvent,candlesticksQueryKey,useInfiniteComments,useInfinitePredictSearch,usePositions,usePositionValueMulti,usePredictWsClient,orderbookQueryKey}from'@liberfi.io/react-predict';export{PredictClient,PredictContext,PredictProvider,PredictWsClient,createPredictClient,createPredictWsClient,eventStatsQueryKey,fetchMatchMarketsPage,fetchMatchesPage,fetchPredictSearch,matchMarketsQueryKey,matchQueryKey,matchesQueryKey,predictSearchQueryKey,useBalance,useCancelOrder,useCandlesticks,useDFlowKYC,useDFlowQuote,useDFlowSubmit,useEvent,useEventStats,useEvents,useInfiniteEvents,useInfiniteMatchMarkets,useInfiniteMatches,useInfiniteOrders,useInfinitePredictSearch,useInfiniteTrades,useMarket,useMarketHistory,useMarketTrades,useMatch,useOrder,useOrderbook,useOrders,usePositionValue,usePositionValueMulti,usePositions,usePredictClient,usePredictSearch,usePriceHistory,useRedeemPosition,useSearchEvents,useSimilarEvents,useTrades}from'@liberfi.io/react-predict';import {ChainNamespace,Chain}from'@liberfi.io/types';import {formatAmountInUsd,SOLANA_TOKENS,formatAmount}from'@liberfi.io/utils';import yi from'canvas-confetti';import {keepPreviousData,useQueryClient,useQueries}from'@tanstack/react-query';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 {createBrowserSearchHistoryStorage,createMemorySearchHistoryStorage,useSearchKeyboardNavigation,useSearchController}from'@liberfi.io/ui/search';var yd={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},ra=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],an=(()=>{let e=t=>{let r=ra.indexOf(t);return r===-1?ra.length:r};return Object.entries(yd).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 mi({categories:e,selectedCategory:t,selectedTag:r,activeTags:o,onCategorySelect:n,onTagSelect:i,trailing:s,pulsingTab:a="Trending",className:l}){let{t:m}=useTranslation(),u=useCallback(()=>{n(null);},[n]),c=m("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(oa,{label:c,isSelected:t===null,onPress:u,showPulse:c===a}),jsx(Nd,{}),e.map(p=>{let d=p.slug??p.category,f=p.label??p.category;return jsx(oa,{label:f,isSelected:t===d,onPress:()=>n(d),badge:p.badge,showPulse:d===a||f===a},d)})]})}),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(na,{label:m("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>i(null)}),o.map(p=>{let d=p.slug??p.label;return jsx(na,{label:p.label,icon:p.icon,isSelected:r===d,onPress:()=>i(d)},d)})]})})]})}function oa({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-text-muted hover:text-text-secondary"),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-text-inverse",children:o})]})}function Nd(){return jsx("span",{className:"flex items-center text-text-muted","aria-hidden":"true",children:"|"})}function na({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-text-muted hover:bg-primary/10 hover:text-primary"),children:[t&&jsx("span",{className:cn$1("iconify size-4",t)}),e]})}function Md({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 sa(e){return e.trim().toLowerCase().replace(/&/g,"and").replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}function Ed(e){return `predict.categories.category.${sa(e)}`}function aa(e){return `predict.categories.tag.${sa(e)}`}function Cd(e,t){return e.map(r=>({category:r.slug,slug:r.slug,label:t(Ed(r.slug),r.label),tags:r.tags.map(o=>({slug:o.slug,label:t(aa(o.slug),o.label),icon:o.icon}))}))}function Td(e,t){return e?e.tags.map(r=>({slug:r.slug,label:t(aa(r.slug),r.label),icon:r.icon})):[]}function gi({onSelect:e,trailing:t,className:r}){let{t:o}=useTranslation(),n=useCallback((f,g)=>{let h=o(f);return typeof h=="string"&&h!==f?h:g},[o]),[i,s]=useState(null),[a,l]=useState(null),m=useCallback(f=>{s(f),l(null),e?.({categorySlug:f,tagSlug:null});},[e]),u=useCallback(f=>{l(f),e?.({categorySlug:i,tagSlug:f});},[i,e]),c=Cd(an,n),p=an.find(f=>f.slug===i),d=Td(p,n);return jsx(mi,{categories:c,selectedCategory:i,selectedTag:a,activeTags:d,onCategorySelect:m,onTagSelect:u,trailing:t,className:r})}function cn(e,t){return e?.trim()||t}function $r(e){return cn(e.title_trans,e.title)??e.title}function hi(e){return cn(e.question_trans,e.question)??e.question}function vi(e){return cn(e.description_trans,e.description)}function dn(e){return cn(e.label_trans,e.label)??e.label}function lr(e){let t=e.outcomes?.[0];return t?dn(t):hi(e)}function un(e){return {title:$r(e),imageUrl:e.image_url}}function pn(e,t){let r=e.outcomes[0],o=e.outcomes[1];return {question:hi(e),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?dn(r):lr(e),noSubTitle:o?dn(o):"No"}}var jr=24,mn=4,Vr={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},K={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_MONTH:"1m",ALL:"all"},yo=K.ALL,Ld={[K.ONE_HOUR]:Vr.ONE_MINUTE,[K.SIX_HOURS]:Vr.ONE_MINUTE,[K.ONE_DAY]:Vr.ONE_MINUTE,[K.ONE_MONTH]:Vr.ONE_MINUTE,[K.ALL]:Vr.ONE_MINUTE},Od={[K.ONE_HOUR]:60,[K.SIX_HOURS]:60,[K.ONE_DAY]:300,[K.ONE_MONTH]:900,[K.ALL]:900},xi={[K.ONE_HOUR]:3600,[K.SIX_HOURS]:360*60,[K.ONE_DAY]:1440*60,[K.ONE_MONTH]:720*60*60,[K.ALL]:null},_d={[K.ONE_HOUR]:1,[K.SIX_HOURS]:1,[K.ONE_DAY]:5,[K.ONE_MONTH]:15,[K.ALL]:15},ko=1,So=1,Id=1,Dd=1,Ad=99,Pr={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},Fd=Pr.ONE_WEEK,Bd={[Pr.ONE_HOUR]:60,[Pr.SIX_HOURS]:60,[Pr.ONE_DAY]:300,[Pr.ONE_WEEK]:1800,[Pr.MAX]:1800};var da=createContext(null);function cr(){let e=useContext(da);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var $d=1e4;function ua({pollingInterval:e=$d,enabled:t=true,enableKalshi:r=true,children:o}){let n=useWallets(),i=useMemo(()=>n.find(M=>M.chainNamespace===ChainNamespace.SOLANA&&M.isConnected)?.address,[n]),s=useMemo(()=>n.find(M=>M.chainNamespace===ChainNamespace.EVM&&M.isConnected)?.address,[n]),{data:a,isLoading:l,isFetching:m,error:u}=useBalance({source:"kalshi",user:i??""},{enabled:t&&r&&!!i,refetchInterval:e}),{data:c,isLoading:p}=useDFlowKYC(i,{enabled:t&&r&&!!i,refetchInterval:3e4}),{data:d,isLoading:f}=usePolymarketSetup(s,{enabled:t&&!!s,refetchInterval:3e4}),g=d?.safe_address,b=d?.verified??false,h=d?.wallet_kind??"deposit",S=d?.deposit_wallet_address,x=h==="safe"?d?.safe_address:S,y=h==="safe"?d?.safe_deployed??false:d?.deposit_wallet_deployed??false,{data:v,isLoading:k,isFetching:N,error:w}=useBalance({source:"polymarket",user:s??""},{enabled:t&&b&&!!s,refetchInterval:e}),P=useMemo(()=>({enableKalshi:r,solanaAddress:i,evmAddress:s,polymarketWalletKind:h,polymarketWalletAddress:x,polymarketDepositWalletAddress:S,polymarketWalletDeployed:y,polymarketSafeAddress:g,kalshiUsdcBalance:a?Number(a.balance):null,polymarketUsdcBalance:b&&v?Number(v.balance):null,kalshiKycVerified:c?.verified??false,kalshiKycUrl:c?.kyc_url??null,kalshiKycLoading:p,polymarketSetupVerified:b,polymarketSafeDeployed:d?.safe_deployed??false,polymarketTokenApproved:d?.token_approved??false,polymarketSetupLoading:f,isLoading:l||k,isFetching:m||N,error:u??w??null}),[r,i,s,h,x,S,y,g,a,v,b,c,p,d,f,l,k,m,N,u,w]);return jsx(da.Provider,{value:P,children:o})}var jd={minutes:60,hours:3600,days:86400};function Po(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*jd[r]}}function No(e,t){let r=parseFloat(t);return !r||r<=0?e:Math.round(e/r)*r}function be(e,t){let r=Math.pow(10,t);return Math.floor(e*r)/r}function pa(e){let t=e;return !Number.isFinite(t)||t<=0||t>=1?1:1-t}var ma=100,fa=300;function ki(e,t){return ma/1e4+Math.max(0,e)/1e4*pa(t)}function Gd(e,t){let r=e?.[t],o=typeof r=="number"?r:Number(r);return Number.isFinite(o)?o:void 0}function Yd(e,t){let r=e?.[t];return typeof r=="string"?r:void 0}function Si(e){let t=Gd(e,"polymarket.effectiveTakerFeeBps");if(t!==void 0&&t>=0)return t;let r=e?.["polymarket.feeDescriptor"],o=typeof r?.r=="number"?r.r:Number(r?.r);return Number.isFinite(o)&&o>=0?o*1e4:Yd(e,"polymarket.sportsMarketType")?fa:0}function Pi({source:e,usdcBalance:t,safetyBufferUsd:r=.01,feeRateBps:o=0,pricePerShare:n}){if(t==null||!Number.isFinite(t))return 0;let i=be(Math.max(0,t),2);if(e!=="polymarket")return i;let s=ki(o,n??NaN),a=i/(1+s)-r;return be(Math.max(0,a),2)}function Ni({usdcAmount:e,pricePerShare:t,feeRateBps:r}){if(!Number.isFinite(e)||e<=0)return 0;let o=ki(r,t);return e*o}function Mi({grossReturn:e,pricePerShare:t,feeRateBps:r}){if(!Number.isFinite(e)||e<=0)return 0;let o=ki(r,t);return e*o}function Mo(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:be(s,2).toFixed(2),active:be(a,2).toFixed(2),available:be(l,2).toFixed(2)})}return /not enough balance/i.test(e)?t(r==="sell"?"predict.trade.insufficientShares":"predict.trade.insufficientBalance"):/max accuracy of/i.test(e)?t("predict.trade.polymarket.decimalAccuracy"):/tick size/i.test(e)?t("predict.trade.polymarket.tickSizeError"):/couldn.*fully filled|FOK.*filled or killed/i.test(e)?t("predict.trade.polymarket.fokNotFilled"):e.replace(/order\s+0x[a-f0-9]+\s+is invalid\.\s*/i,"")||e}function Nr(e,t=2){return parseFloat(be(e,t).toFixed(t)).toString()}function wi(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};yi({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{yi({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{yi({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function Gr(e,t){return {submitted:e("predict.trade.resultSubmitted"),completed:e("predict.trade.resultCompleted"),delayed:e("predict.trade.resultDelayed")}}function Zd({deadlineAt:e}){let{formatUnit:t}=useLocalizedTimeFormatter(),[r,o]=useState(()=>Math.max(0,e-Date.now()));return useEffect(()=>{let n=setInterval(()=>{o(Math.max(0,e-Date.now()));},1e3);return ()=>clearInterval(n)},[e]),t(Math.max(0,Math.ceil(r/1e3)),"second")}function Mr({id:e=`predict-trade-result-${Date.now()}`,durationMs:t=3e4,celebrateOnCompleted:r=false,messages:o}){return {id:e,submitted:()=>{let n=Date.now()+t;toast.progress({id:e,message:o.submitted,duration:t,progress:true,action:createElement(Zd,{deadlineAt:n})});},completed:()=>{toast.update(e,{type:"success",message:o.completed,duration:5e3}),r&&wi();},delayed:()=>{toast.update(e,{type:"blank",message:o.delayed,duration:8e3});},failed:n=>{toast.update(e,{type:"error",message:n,duration:8e3});}}}function Ci({market:e,initialOutcome:t="yes",slippageBps:r=100,onInsufficientBalance:o}){let{t:n,i18n:i}=useTranslation(),{status:s}=useAuth(),a=useWallets(),l=usePredictClient(),m=useContext(PolymarketContext),{start:u}=useTradeResultConfirmation(),c=e.source,p=c==="polymarket",d=a.find(D=>D.chainNamespace===ChainNamespace.SOLANA&&D.isConnected),f=a.find(D=>D.chainNamespace===ChainNamespace.EVM&&D.isConnected&&"switchChain"in D),g=s==="authenticated",b=d?.address,h=f?.address,[S,x]=useState(t),[y,v]=useState("market"),[k,N]=useState(NaN),[w,P]=useState(NaN),[M,T]=useState(false),[A,X]=useState(null),[L,G]=useState(false),[U,oe]=useState(false),[W,te]=useState("1h"),[ne,se]=useState(30),[he,Pe]=useState("minutes"),pt=useMemo(()=>Gr(n),[i,n]),Ve=true,Be=useCallback(async(D,De)=>{let Te=Mr({celebrateOnCompleted:true,messages:pt});Te.submitted(),await u({source:c,user:c==="kalshi"?b:h,kalshiUser:Ve?b:void 0,polymarketUser:h,marketSlug:e.slug,eventSlug:e.event_slug,expectation:D,getOrdersHeaders:De})==="confirmed"?Te.completed():Te.delayed();},[u,Ve,h,e.event_slug,e.slug,c,pt,b]),E=useMemo(()=>{if(c!=="polymarket")return;let D=e.provider_meta?.["polymarket.clobTokenIds"];return D?(typeof D=="string"?JSON.parse(D):D)[S==="yes"?0:1]:void 0},[c,e.provider_meta,S]),{data:st,isLoading:He}=useTickSize(E),ve=normalizePolymarketTickSize(st?.minimum_tick_size),{data:at,isLoading:we}=useFeeRate(E),Ue=at?.base_fee??0,qe=String(Ue),C=useMemo(()=>Si(e.provider_meta),[e.provider_meta]),{data:O}=useRebateConfig(),z=O?.builder_enabled&&O.builder_code?O.builder_code:void 0,Z=null,me=false,Ne=null,lt=false,ct,kt,Qe;try{let D=cr();Ve=D.enableKalshi,Z={kalshiUsdcBalance:D.kalshiUsdcBalance,polymarketUsdcBalance:D.polymarketUsdcBalance,isLoading:D.isLoading},me=D.kalshiKycVerified,Ne=D.kalshiKycUrl,lt=D.polymarketSetupVerified,ct=D.polymarketSafeAddress,kt=D.polymarketWalletKind,Qe=D.polymarketWalletAddress;}catch{}let Yt=c==="kalshi"&&!me,We=c==="polymarket"&&!lt,{data:et}=useRealtimeOrderbook({slug:e.slug,source:c,outcome:S},{enabled:e.status==="open"}),xe=useMemo(()=>{let D=pickBestAsk(et,S);if(D!=null&&D>0)return D;let De=S==="yes"?0:1,Te=e.outcomes[De];return Te?.best_ask??Te?.price??.5},[et,e.outcomes,S]),mt=useCallback(D=>{v(D);},[]),St=useCallback(D=>{x(D),P(NaN);},[]);useEffect(()=>{St(t);},[t,St]),useEffect(()=>{y==="limit"&&isNaN(w)&&P(Math.round(xe*1e4)/1e4);},[y,w,xe]);let Me=useMemo(()=>y==="limit"&&p&&!isNaN(w)?w:xe,[y,p,w,xe]),tt=useMemo(()=>isNaN(k)||k<=0?0:Me>0?k/Me:0,[k,Me]),Ce=useMemo(()=>walkOrderbook({orderbook:et,outcome:S,side:"buy",sharesNeeded:tt,slippageBps:r}),[et,S,tt,r]),Lt=useMemo(()=>Ce.status==="ok"&&Ce.worstPrice!=null&&Ce.worstPrice>0?Ce.worstPrice:xe,[Ce,xe]),I=useMemo(()=>isNaN(k)||k<=0?"0":String(Math.round(k*1e6)),[k]),_e=e.provider_meta?.["dflow.yesMint"]??"",Xe=e.provider_meta?.["dflow.noMint"]??"",fo=SOLANA_TOKENS.stablecoins.USDC.address,B=S==="yes"?_e:Xe,Ie=fo,Pt=B,Ft=c==="kalshi"?b??"":h??"",{data:go,isLoading:ni}=usePositionsMulti({kalshi_user:c==="kalshi"?Ft:void 0,polymarket_user:c==="polymarket"?Ft:void 0},{enabled:!!Ft}),ii=c==="kalshi"&&!!Ie&&!!Pt&&!!b&&I!=="0",{refetch:qt}=useDFlowQuote({inputMint:Ie,outputMint:Pt,amount:I,userPublicKey:b??"",slippageBps:100},{enabled:ii}),Ir=useMemo(()=>Z?c==="kalshi"?Z.kalshiUsdcBalance:Z.polymarketUsdcBalance:go&&go.positions.reduce((De,Te)=>Te.side==="USDC"||Te.side==="collateral"?De+(Te.current_value??0):De,0)||null,[Z,go,c]),si=Z?Z.isLoading:ni,ft=useMemo(()=>Pi({source:c,usdcBalance:Ir,feeRateBps:C,pricePerShare:Me}),[c,Ir,C,Me]),Ot=Ir==null?null:ft,Dr=useMemo(()=>isNaN(k)||k<=0?0:k,[k]),ho=useMemo(()=>isNaN(k)||k<=0?0:Me>0?k/Me*1:0,[k,Me]),Ar=useMemo(()=>c!=="polymarket"||isNaN(k)||k<=0?0:Ni({usdcAmount:k,pricePerShare:Me,feeRateBps:C}),[c,k,Me,C]),sr=ho-Dr-Ar,ai=useCallback(D=>{if(isNaN(D)){N(NaN);return}N(Math.round(Math.max(0,D)*100)/100);},[]),en=useCallback(D=>{if(isNaN(D)){P(NaN);return}P(Math.round(D*1e4)/1e4);},[]),Fr=useCallback(()=>{N(NaN),P(NaN),v("market"),oe(false),te("1h"),se(30),Pe("minutes");},[]),Qt=useMemo(()=>{let D=[];return isNaN(k)||k<=0?D.push(n("predict.trade.minAmountUsd",{amount:So})):k<So&&D.push(n("predict.trade.minAmountUsd",{amount:So})),e.status!=="open"&&D.push(n("predict.trade.marketNotActive")),Ot!=null&&!isNaN(k)&&k>0&&k>Ot&&D.push(n("predict.trade.insufficientBalance")),y==="limit"&&p&&(isNaN(w)||w<.01||w>.99)&&D.push(n("predict.trade.limitPriceRange")),y==="limit"&&p&&U&&W==="custom"&&(isNaN(ne)||ne<=0)&&D.push(n("predict.trade.expiration.invalidDate")),c==="polymarket"&&y==="market"&&!isNaN(k)&&k>0&&tt>0&&(Ce.status==="insufficient_liquidity"?D.push(n("predict.trade.insufficientLiquidity",{available:be(Ce.totalAvailable,2)})):Ce.status==="exceeds_slippage"&&D.push(n("predict.trade.priceImpactTooHigh",{impact:(Ce.priceImpactBps/100).toFixed(2),slippage:(r/100).toFixed(2)}))),{isValid:D.length===0,errors:D}},[k,e.status,Ot,y,p,w,U,W,ne,c,tt,Ce,r,n]),vr=useMemo(()=>Ot==null||isNaN(k)||k<=0?false:k>Ot,[Ot,k]),xr=useCallback(()=>{o?.(c);},[o,c]),{mutateAsync:br}=useDFlowSubmit(),{data:vo}=useOrder({id:A??"",source:c},{enabled:!!A});useEffect(()=>{if(!vo||!A)return;let{status:D}=vo;D==="closed"?(X(null),T(false),Be("buy-market"),Fr()):(D==="failed"||D==="expired")&&(T(false),X(null),toast.error(n("predict.trade.submitError")));},[Be,vo,A,Fr,n]);let xo=useCallback(async()=>{if(!b||!d)return;if(!Ie||!Pt){toast.error("Missing token mint addresses"),T(false);return}if(!me){G(true),T(false);return}let It=(await qt()).data?.transaction;if(!It){toast.error(n("predict.trade.submitError")),T(false);return}let bo=Uint8Array.from(atob(It),gt=>gt.charCodeAt(0)),Xt=await d.signTransaction(bo),Jt=await br({signedTransaction:btoa(String.fromCharCode(...Xt)),orderContext:{user_public_key:b,input_mint:Ie,output_mint:Pt,amount:I,price:String(xe),side:"BUY",outcome:S==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});X(Jt.signature);},[b,d,qt,br,Ie,Pt,I,xe,S,e.slug,n,me]),Br=useCallback(async()=>{if(!f||!m)return;let D=f.chain,De=D!==Chain.POLYGON;De&&await f.switchChain(Chain.POLYGON);try{let Te=await f.getEip1193Provider();if(!Te){toast.error(n("predict.trade.submitError")),T(!1);return}let It=kt==="deposit"&&!!Qe,bo=!It&&!!ct,Xt=It?Qe:ct,Jt={address:f.address,signatureType:It?3:bo?2:0,signTypedData:async(Dt,R,Re,Le)=>{let ze=[];"name"in Dt&&ze.push({name:"name",type:"string"}),"version"in Dt&&ze.push({name:"version",type:"string"}),"chainId"in Dt&&ze.push({name:"chainId",type:"uint256"}),"verifyingContract"in Dt&&ze.push({name:"verifyingContract",type:"address"}),"salt"in Dt&&ze.push({name:"salt",type:"bytes32"});let vt={EIP712Domain:ze,...R};return await Te.request({method:"eth_signTypedData_v4",params:[f.address,JSON.stringify({domain:Dt,types:vt,primaryType:Re,message:Le})]})}},gt=m.credentials??await m.authenticate(Jt),li=S==="yes"?0:1,tn="",Ut=e.provider_meta?.["polymarket.clobTokenIds"];Ut&&(tn=(typeof Ut=="string"?JSON.parse(Ut):Ut)[li]??"");let Hr=e.provider_meta?.["polymarket.negRisk"]??!1,Ur=y==="limit"&&!isNaN(w)?w:Lt,yr=No(Ur,ve),rn=y==="limit"?U?"GTD":"GTC":"FOK",kr=y==="market"?k:yr>0?k/yr:0,Wr={tokenId:tn,price:yr,size:kr,side:"BUY",orderType:rn,tickSize:ve,negRisk:Hr,...Xt&&{funderAddress:Xt},...z&&{builderCode:z},...y==="limit"&&U&&{expiration:Po(W,ne,he)}},zr;if(It)zr=await buildSignedV2OrderPayload({signer:Jt,depositWalletAddress:Xt,input:Wr,owner:gt.apiKey});else {let Dt=buildCtfExchangeDomain(Hr),R=buildOrderMessage({...Wr,signerAddress:Jt.address,signatureType:Jt.signatureType,feeRateBps:qe}),Re=await Jt.signTypedData(Dt,CTF_ORDER_TYPES,"Order",R),Le=buildSignedOrder(R,Re,Wr.orderType);zr=buildClobPayload(Le,gt.apiKey);}await l.executePolymarketOrder({payload:zr,l2_api_key:gt.apiKey,l2_secret:gt.secret,l2_passphrase:gt.passphrase,signer_address:gt.address,owner:gt.apiKey}),Be(y==="limit"?"buy-limit":"buy-market",async()=>await buildPolymarketL2Headers(gt.address,{apiKey:gt.apiKey,secret:gt.secret,passphrase:gt.passphrase,method:"GET",requestPath:"/data/orders"})),Fr(),T(!1);}finally{De&&D&&f.switchChain(D).catch(()=>{});}},[f,m,S,e.provider_meta,y,Be,w,Lt,k,l,U,W,ne,he,Fr,n,ve,qe,ct,kt,Qe,z]),_t=useCallback(async()=>{if(!(!Qt.isValid||!g)){T(true),X(null),G(false);try{c==="kalshi"?await xo():await Br();}catch(D){let De=D instanceof Error?D.message:"",Te=c==="polymarket"&&De?Mo(De,n,"buy"):De||void 0;toast.error(Te||n("predict.trade.submitError")),T(false);}}},[Qt.isValid,g,c,xo,Br,n]);return {outcome:S,orderType:y,quantity:k,limitPrice:w,shares:tt,effectivePrice:Me,estimatedCost:Dr,estimatedFee:Ar,potentialPayout:ho,potentialProfit:sr,pricePerShare:xe,usdcBalance:Ir,maxBuyAmount:ft,spendableUsdcBalance:Ot,isBalanceLoading:si,isMarketDataLoading:c==="polymarket"&&(we||He),isSubmitting:M,authStatus:s,validation:Qt,isInsufficientBalance:vr,source:c,supportsLimitOrder:p,kycRequired:L,needsKyc:Yt,needsSetup:We,kycUrl:Ne,expirationEnabled:U,expirationPreset:W,customDuration:ne,customDurationUnit:he,setOutcome:St,setOrderType:mt,setQuantity:ai,setLimitPrice:en,setExpirationEnabled:oe,setExpirationPreset:te,setCustomDuration:se,setCustomDurationUnit:Pe,submit:_t,notifyInsufficientBalance:xr}}function Eo({isOpen:e,onClose:t,kycUrl:r}){let{t:o}=useTranslation();return jsx(StyledModal,{isOpen:e,onOpenChange:n=>{n||t();},size:"md",classNames:{base:THEMED_MODAL_BASE_CLASS,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-text-primary",children:o("predict.trade.kycModalTitle")}),jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-surface-strong/50 text-text-secondary hover:text-text-primary 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-text-secondary 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-text-secondary",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-brand-primary 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-brand-primary/70 hover:text-brand-primary transition-colors mb-3",children:[o("predict.trade.goToKYC")," \u2192"]}),jsx("p",{className:"text-[11px] text-text-muted mb-5",children:o("predict.trade.kycModalNote")}),jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] bg-action-primary text-text-inverse text-sm font-semibold hover:bg-action-primary-hover 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 Hu=["5m","1h","12h","24h","eod","custom"],Uu={"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"},Wu=["minutes","hours","days"],zu={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},Ku={maximumFractionDigits:0},dr="-";function Li({event:e,market:t,variant:r="bordered",outcome:o,orderType:n,quantity:i,limitPrice:s,shares:a,effectivePrice:l,potentialProfit:m,potentialPayout:u,estimatedCost:c,estimatedFee:p=0,usdcBalance:d,isBalanceLoading:f,isMarketDataLoading:g,isSubmitting:b,authStatus:h,isValid:S,validationErrors:x,isInsufficientBalance:y,onInsufficientBalance:v,supportsLimitOrder:k,maxBuyAmount:N,kycRequired:w,needsKyc:P,needsSetup:M,kycUrl:T,expirationEnabled:A,expirationPreset:X,customDuration:L,customDurationUnit:G,oddsFormatter:U,outcomeLabels:oe,onOutcomeChange:W,onOrderTypeChange:te,onQuantityChange:ne,onLimitPriceChange:se,onExpirationEnabledChange:he,onExpirationPresetChange:Pe,onCustomDurationChange:pt,onCustomDurationUnitChange:Ve,onSubmit:Be}){let{t:E}=useTranslation(),[st,He]=useState(true),ve=useDisclosure(),[at,we]=useState(""),Ue=useRef(false);useEffect(()=>{Ue.current||we(isNaN(i)?"":String(i));},[i]);let[qe,C]=useState(""),O=useRef(false);useEffect(()=>{O.current||(isNaN(s)?C(""):C(String(parseFloat((s*100).toFixed(2)))));},[s]);let z=useCallback(B=>{if(B!==""&&!/^\d*\.?\d{0,2}$/.test(B))return;if(C(B),B===""||B==="."){se(NaN);return}let Pt=parseFloat(B);isNaN(Pt)||se(Pt/100);},[se]),Z=useCallback(B=>{if(B!==""&&!/^\d*\.?\d{0,2}$/.test(B))return;if(we(B),Xe(false),B===""||B==="."){ne(NaN);return}let Pt=parseFloat(B);isNaN(Pt)||ne(Pt);},[ne]);useEffect(()=>{w&&!ve.isOpen&&ve.onOpen();},[w,ve]);let me=useMemo(()=>{let B=o==="yes"?t.yesAsk:t.noAsk;return B!=null?parseFloat((Number(B)*100).toFixed(2)):null},[o,t]),Ne=o==="yes"?t.yesAsk:t.noAsk,lt=Ne!=null&&U?U(Number(Ne)):me!=null?`${me} \xA2`:dr,ct=Number.isFinite(l)?parseFloat((l*100).toFixed(2)):null,kt=Number.isFinite(l)&&U?U(l):ct!=null?`${ct} \xA2`:dr,Qe=!isNaN(i)&&i>0,Yt=Qe?c+p:0,We=Qe&&a>0?Yt/a:0,et=We>0&&U?U(We):We>0?`${parseFloat((We*100).toFixed(2))}\xA2`:dr,xe=h==="authenticated",mt=h==="authenticating"||h==="deauthenticating",St=xe&&(P||M),Me=useCallback(B=>oe?.[B]??E(B==="yes"?"predict.trade.yes":"predict.trade.no"),[oe,E]),tt=useMemo(()=>{if(mt)return E("predict.trade.checkingLogin");if(!xe)return E("predict.trade.loginToTrade");if(P)return E("predict.trade.kycRequired");if(M)return E("predict.trade.setupRequired");if(f)return E("predict.trade.loadingBalance");if(g)return E("predict.trade.loadingMarketData");if(b)return E("predict.trade.submitting");if(w)return E("predict.trade.kycRequired");if(!Qe)return E("predict.trade.enterAmount");let B=Me(o),Ie=m>0?` \u2192 Win $${m.toFixed(2)}`:"";return `${E("predict.trade.buy")} ${B}${Ie}`},[mt,xe,P,M,f,g,b,w,Qe,o,Me,m,E]),Ce="primary",Lt=()=>{let B=N??be(d??0,2);ne(be(B/2,2));},I=()=>{ne(N??be(d??0,2));},[_e,Xe]=useState(false),fo=()=>{if(!xe){Xe(false),Be();return}if(P){ve.onOpen();return}if(M&&v){Xe(false),v();return}if(w){ve.onOpen();return}if(y&&v){Xe(false),v();return}if(!S){Xe(true);return}Xe(false),Be();};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 var(--color-border-subtle)",background:"hsl(var(--heroui-content2) / 0.4)",transition:"border-color 0.2s"}:void 0,onMouseEnter:B=>{r==="bordered"&&(B.currentTarget.style.borderColor="hsl(var(--heroui-content4) / 0.8)");},onMouseLeave:B=>{r==="bordered"&&(B.currentTarget.style.borderColor="hsl(var(--heroui-content3) / 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-text-muted leading-tight line-clamp-1",children:e.title}),jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsx("span",{className:"text-foreground",children:t.yesSubTitle}),jsx("span",{className:"text-foreground",children:" \xB7 "}),jsxs("span",{className:"text-positive",children:[E("predict.trade.buy")," ",Me(o)]})]})]})]}),jsxs("div",{className:"flex items-center justify-between",children:[k?jsxs(Tabs,{variant:"underlined",selectedKey:n,onSelectionChange:B=>te(B),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsx(Tab,{title:E("predict.trade.market")},"market"),jsx(Tab,{title:E("predict.trade.limit")},"limit")]}):jsx("span",{className:"text-sm font-medium text-foreground",children:E("predict.trade.market")}),n==="limit"&&k?jsx(StyledInput,{"aria-label":E("predict.trade.limitPrice"),placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:qe,onChange:B=>z(B.target.value),onFocus:()=>{O.current=true;},onBlur:()=>{O.current=false,isNaN(s)?C(""):C(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"}}):lt!=null&&jsx("span",{className:"text-xl font-bold tabular-nums",children:lt})]}),jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(B=>{let Ie=B==="yes"?t.yesAsk:t.noAsk;return jsx("div",{className:"flex flex-1 flex-col gap-y-1",children:jsxs("button",{type:"button",onClick:()=>W(B),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${o===B?"border-positive bg-positive/10 text-positive":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsx("span",{children:Me(B)}),Ie!=null&&jsx("span",{className:"ml-1 opacity-70",children:U?U(Number(Ie)):`${parseFloat((Number(Ie)*100).toFixed(2))}\xA2`})]})},B)})}),jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxs("div",{className:"flex items-center justify-between text-xs text-text-muted",children:[jsx("span",{className:"text-sm font-medium text-foreground",children:E("predict.trade.youArePaying")}),jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("button",{type:"button",onClick:Lt,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-text-muted hover:text-foreground font-medium",children:E("predict.trade.half")}),jsx("button",{type:"button",onClick:I,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-text-muted hover:text-foreground font-medium",children:E("predict.trade.max")})]})]}),jsx(StyledInput,{"aria-label":E("predict.trade.tradeAmount"),fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:at,onChange:B=>Z(B.target.value),onFocus:()=>{Ue.current=true;},onBlur:()=>{Ue.current=false,we(isNaN(i)?"":String(i));},startContent:jsx("span",{className:"text-text-muted 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"}}),_e&&x.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:x.map(B=>jsx("span",{className:"text-xs text-danger",children:B},B))})]}),jsxs("div",{className:"flex items-center justify-end gap-x-1.5 text-sm",children:[jsx("span",{className:"text-text-muted",children:E("predict.trade.balance")}),jsx("span",{className:"font-medium text-foreground tabular-nums",children:d!=null?`$${be(d,2).toFixed(2)}`:"$0"})]}),n==="limit"&&k&&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:E("predict.trade.setExpiration")}),jsx(StyledSwitch,{size:"sm",color:"primary",isSelected:A,onValueChange:he,"aria-label":E("predict.trade.setExpiration")})]}),A&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":E("predict.trade.setExpiration"),selectedKeys:[X],onSelectionChange:B=>{let Ie=Array.from(B)[0];Ie&&Pe(Ie);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Hu.map(B=>jsx(SelectItem,{children:E(Uu[B])},B))}),X==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":E("predict.trade.durationAmount"),size:"sm",radius:"lg",value:isNaN(L)?void 0:L,onValueChange:pt,minValue:1,step:1,formatOptions:Ku,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":E("predict.trade.durationUnit"),selectedKeys:[G],onSelectionChange:B=>{let Ie=Array.from(B)[0];Ie&&Ve(Ie);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Wu.map(B=>jsx(SelectItem,{children:E(zu[B])},B))})]})]})]}),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:()=>He(B=>!B),className:"flex items-center gap-x-1 text-text-muted hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{children:E("predict.trade.odds")}),jsx(ChevronDownIcon,{className:cn$1("h-3.5 w-3.5 transition-transform",st&&"rotate-180")})]}),jsx("span",{className:"text-foreground font-medium tabular-nums",children:U&&Number.isFinite(l)?kt:ct!=null?E("predict.trade.chance",{percent:ct}):dr})]}),st&&jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-text-muted",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:E("predict.trade.totalSize")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${c.toFixed(2)}`:dr})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:E("predict.trade.numContracts")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(a)&&a>0?Nr(a):dr})]}),p>0&&jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:E("predict.trade.estFee")}),jsx("span",{className:"tabular-nums text-foreground",children:`$${p.toFixed(2)}`})]}),p>0&&jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:E("predict.trade.totalPayment")}),jsx("span",{className:"tabular-nums text-foreground",children:`$${Yt.toFixed(2)}`})]}),p>0&&jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:E("predict.trade.effectiveOdds")}),jsx("span",{className:"tabular-nums text-foreground",children:et})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:E("predict.trade.payout")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${u.toFixed(2)}`:dr})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:E("predict.trade.estProfit")}),jsx("span",{className:"tabular-nums text-positive",children:!isNaN(i)&&i>0&&m>0?`+$${m.toFixed(2)}`:dr})]})]})]}),jsx(Button,{color:Ce,fullWidth:true,radius:"lg",size:"lg",isDisabled:mt||xe&&!St&&(f||g||!Qe||b),isLoading:mt||xe&&!St&&(b||f||g),spinner:jsx(Spinner,{size:"sm",color:"current"}),onPress:fo,children:tt})]}),jsx(Eo,{isOpen:ve.isOpen,onClose:ve.onClose,kycUrl:T})]})}function Co({event:e,market:t,variant:r,initialOutcome:o,chain:n,slippageBps:i,onInsufficientBalance:s,onOutcomeChange:a,oddsFormatter:l,outcomeLabels:m}){let{outcome:u,orderType:c,quantity:p,limitPrice:d,shares:f,effectivePrice:g,estimatedCost:b,estimatedFee:h,potentialPayout:S,potentialProfit:x,pricePerShare:y,usdcBalance:v,maxBuyAmount:k,isBalanceLoading:N,isMarketDataLoading:w,isSubmitting:P,authStatus:M,validation:T,isInsufficientBalance:A,supportsLimitOrder:X,kycRequired:L,needsKyc:G,needsSetup:U,kycUrl:oe,expirationEnabled:W,expirationPreset:te,customDuration:ne,customDurationUnit:se,setOutcome:he,setOrderType:Pe,setQuantity:pt,setLimitPrice:Ve,setExpirationEnabled:Be,setExpirationPreset:E,setCustomDuration:st,setCustomDurationUnit:He,submit:ve,notifyInsufficientBalance:at}=Ci({market:t,initialOutcome:o,slippageBps:i,onInsufficientBalance:s}),we=useAuthCallback(ve),Ue=useCallback(O=>{he(O),a?.(O);},[he,a]),qe=useMemo(()=>e?un(e):void 0,[e]),C=useMemo(()=>pn(t,{yesAsk:u==="yes"?y:void 0,noAsk:u==="no"?y:void 0}),[t,u,y]);return jsx(Li,{event:qe,market:C,variant:r,outcome:u,orderType:c,quantity:p,limitPrice:d,shares:f,effectivePrice:g,estimatedCost:b,estimatedFee:h,potentialPayout:S,potentialProfit:x,usdcBalance:v,maxBuyAmount:k,isBalanceLoading:N,isMarketDataLoading:w,isSubmitting:P,authStatus:M,isValid:T.isValid,validationErrors:T.errors,isInsufficientBalance:A,onInsufficientBalance:s?at:void 0,supportsLimitOrder:X,kycRequired:L,needsKyc:G,needsSetup:U,kycUrl:oe,expirationEnabled:W,expirationPreset:te,customDuration:ne,customDurationUnit:se,oddsFormatter:l,outcomeLabels:m,onOutcomeChange:Ue,onOrderTypeChange:Pe,onQuantityChange:pt,onLimitPriceChange:Ve,onExpirationEnabledChange:Be,onExpirationPresetChange:E,onCustomDurationChange:st,onCustomDurationUnitChange:He,onSubmit:we})}var qr="predict-trade";function To({id:e=qr}){return jsx(AsyncModal,{id:e,children:t=>jsx(Zu,{...t})})}function Zu({params:e,isOpen:t,onOpenChange:r}){let{t:o}=useTranslation(),{isMobile:n}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:n?"lg":"md",backdrop:"opaque",hideCloseButton:true,classNames:{base:THEMED_MODAL_BASE_CLASS,body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{className:n?"":"p-2",children:[jsx(Co,{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-text-secondary hover:text-text-primary hover:bg-surface-strong/50 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 Xr={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function bn(e,t=true){let r=0;return t&&e.source&&r++,e.timeRemaining&&r++,e.minVolume&&r++,e.minLiquidity&&r++,r}function Oi({isOpen:e,onClose:t,value:r,onChange:o,enableKalshi:n=true}){let{t:i}=useTranslation(),[s,a]=useState(r),l=useMemo(()=>n?Xr:{...Xr,source:"polymarket"},[n]),m=useCallback(S=>{S?a(r):t();},[r,t]),u=useCallback(()=>{a(l);},[l]),c=useCallback(()=>{o(s),t();},[s,o,t]),p=useCallback((S,x)=>{a(y=>({...y,[S]:x}));},[]),d=useMemo(()=>bn(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]),b=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]),h=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:m,size:"md",backdrop:"opaque",scrollBehavior:"inside",classNames:{base:THEMED_MODAL_BASE_CLASS,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-text-primary",children:i("predict.filter.title")}),jsx(sp,{onClick:()=>m(false)})]}),jsxs("div",{style:{padding:"0 20px 16px",display:"flex",flexDirection:"column",gap:20},children:[n&&jsx(vn,{label:i("predict.filter.platform"),children:jsx(xn,{options:f,selected:s.source,onSelect:S=>p("source",S)})}),jsx(vn,{label:i("predict.filter.timeRemaining"),children:jsx(xn,{options:g,selected:s.timeRemaining,onSelect:S=>p("timeRemaining",S)})}),jsx(vn,{label:i("predict.filter.minVolume"),children:jsx(xn,{options:b,selected:s.minVolume,onSelect:S=>p("minVolume",S)})}),jsx(vn,{label:i("predict.filter.minLiquidity"),children:jsx(xn,{options:h,selected:s.minLiquidity,onSelect:S=>p("minLiquidity",S)})})]}),jsxs("div",{className:"flex items-center gap-3 px-5 py-4",style:{borderTop:"1px solid var(--color-border-subtle)"},children:[jsx("button",{type:"button",className:"inline-flex items-center justify-center py-2.5 px-5 rounded-[10px] text-text-secondary text-sm font-medium hover:text-text-primary 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-action-primary text-text-inverse text-sm font-semibold hover:bg-action-primary-hover transition-colors cursor-pointer",onClick:c,children:[i("predict.filter.showResults"),d>0&&jsxs("span",{style:{opacity:.7},children:["(",d,")"]})]})]})]})})})}function vn({label:e,children:t}){return jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[jsx("span",{style:{fontSize:11,fontWeight:500,color:"var(--color-text-muted)",textTransform:"uppercase",letterSpacing:"0.05em"},children:e}),t]})}function sp({onClick:e}){return jsx("button",{type:"button",onClick:e,className:"p-1 rounded-[10px] hover:bg-surface-strong/50 text-text-secondary hover:text-text-primary 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 xn({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 color-mix(in srgb, var(--color-action-primary) 30%, transparent)":"1px solid var(--color-border-subtle)",background:i?"color-mix(in srgb, var(--color-action-primary) 8%, transparent)":"hsl(var(--heroui-content3) / 0.4)",color:i?"var(--color-action-primary)":"var(--color-text-secondary)"},onMouseEnter:s=>{i||(s.currentTarget.style.background="hsl(var(--heroui-content3) / 0.8)",s.currentTarget.style.color="var(--color-text-primary)");},onMouseLeave:s=>{i||(s.currentTarget.style.background="hsl(var(--heroui-content3) / 0.4)",s.currentTarget.style.color="var(--color-text-secondary)");},children:n.label},n.value??"__all")})})}var _i={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},wa={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},gp=["start_time","volume","liquidity","ending_soon"],Ea={display:"inline-flex",alignItems:"center",gap:8,borderRadius:10,border:"1px solid var(--color-border-subtle)",background:"hsl(var(--heroui-content3) / 0.6)",padding:"8px 12px",fontSize:14,color:"var(--color-text-primary)",cursor:"pointer",transition:"all 0.15s"},hp={position:"absolute",left:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid var(--color-border-control)",background:"var(--color-surface-interactive)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function Ii({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:o,onFilterPress:n,filterCount:i=0,className:s}){let{t:a}=useTranslation(),[l,m]=useState(false),u=useRef(null),c=useCallback(d=>{u.current&&!u.current.contains(d.target)&&m(false);},[]);useEffect(()=>(document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)),[c]),useEffect(()=>{if(!l)return;let d=f=>{f.key==="Escape"&&m(false);};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[l]);let p=Ca[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:Ea,onMouseEnter:d=>{d.currentTarget.style.background="var(--color-surface-strong)";},onMouseLeave:d=>{d.currentTarget.style.background="hsl(var(--heroui-content3) / 0.6)";},onClick:()=>m(d=>!d),children:[jsx(vp,{}),jsx(p,{className:"size-4 shrink-0",style:{color:"var(--color-text-secondary)"}}),jsx("span",{className:"hidden sm:block",style:{color:"var(--color-text-primary)"},children:a(wa[e])}),jsx(bp,{open:l})]}),l&&jsx("div",{style:{...hp,width:224,padding:4},children:gp.map(d=>{let f=Ca[d],g=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:g?"color-mix(in srgb, var(--color-action-primary) 8%, transparent)":"transparent",color:g?"var(--color-action-primary)":"var(--color-text-secondary)",borderRadius:10},onMouseEnter:b=>{g||(b.currentTarget.style.background="hsl(var(--heroui-content3) / 0.5)",b.currentTarget.style.color="var(--color-text-primary)");},onMouseLeave:b=>{g||(b.currentTarget.style.background="transparent",b.currentTarget.style.color="var(--color-text-secondary)");},onClick:()=>{e===d?o(!r):t(d),m(false);},children:[jsx(f,{className:"size-4 shrink-0",style:{color:g?"var(--color-action-primary)":"var(--color-text-muted)"}}),jsx("span",{style:{flex:1,fontWeight:500},children:a(wa[d])}),g&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"var(--color-action-primary)",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 var(--color-border-subtle)",background:"hsl(var(--heroui-content3) / 0.6)",width:36,height:36,color:"var(--color-text-secondary)",cursor:"pointer",transition:"all 0.15s",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:14},onMouseEnter:d=>{d.currentTarget.style.background="var(--color-surface-strong)",d.currentTarget.style.color="var(--color-text-primary)";},onMouseLeave:d=>{d.currentTarget.style.background="hsl(var(--heroui-content3) / 0.6)",d.currentTarget.style.color="var(--color-text-secondary)";},onClick:()=>o(!r),children:r?"\u2191":"\u2193"}),jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxs("button",{type:"button",style:Ea,onMouseEnter:d=>{d.currentTarget.style.background="var(--color-surface-strong)";},onMouseLeave:d=>{d.currentTarget.style.background="hsl(var(--heroui-content3) / 0.6)";},onClick:n,children:[jsx(xp,{}),jsx("span",{className:"hidden sm:block",style:{color:"var(--color-text-primary)"},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:"var(--color-action-primary)",color:"var(--color-text-inverse)",fontSize:10,fontWeight:600,padding:"0 4px"},children:i})]})]})}var Ca={start_time:CalendarIcon,volume:ChartLineIcon,liquidity:DropletIcon,ending_soon:TimerIcon};function vp(){return jsxs("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"var(--color-text-secondary)"},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 xp(){return jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"var(--color-text-secondary)"},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 bp({open:e}){return jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"var(--color-text-muted)",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 Di(e={}){let{i18n:t}=useTranslation(),{tagSlugSelection:r,limit:o,status:n,sort_by:i,sort_asc:s,source:a,with_markets:l,minVolume:m,minLiquidity:u,timeRemaining:c,markets_limit:p,lang:d}=e,f=d??t.resolvedLanguage??t.language,g=useMemo(()=>resolveEventsParams({tagSlugSelection:r,limit:o,status:n,sort_by:i,sort_asc:s,source:a,with_markets:l,minVolume:m,minLiquidity:u,timeRemaining:c,markets_limit:p,lang:f}),[f,o,p,u,m,s,i,a,n,r,c,l]),{data:b,isLoading:h,isFetching:S,isFetchingNextPage:x,isError:y,error:v,hasNextPage:k,fetchNextPage:N,refetch:w}=useInfiniteEvents(g),P=useMemo(()=>b?.pages.flatMap(A=>A.items).filter(A=>A!=null)??[],[b]),M=useCallback(()=>{N();},[N]),T=useCallback(()=>{w();},[w]);return {data:P,isLoading:h,isFetching:S&&!x,isFetchingMore:x,isError:y,error:v??null,hasMore:k??false,fetchMore:M,refetch:T}}var La=`
|
|
1
|
+
import {createContext,memo,useRef,forwardRef,useState,useImperativeHandle,useMemo,useEffect,useCallback,useContext,createElement,Fragment as Fragment$1,useSyncExternalStore,useLayoutEffect,startTransition,Component}from'react';import {themeSemanticColors,PolymarketIcon,KalshiIcon,cn,Skeleton,toast,StyledModal,THEMED_MODAL_BASE_CLASS,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,useLocalizedTimeFormatter,Translation}from'@liberfi.io/i18n';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useWallets,useAuth,useAuthCallback}from'@liberfi.io/wallet-connector';import {useInfiniteMatchMarkets,useBalance,useDFlowKYC,usePolymarketSetup,usePredictClient,PolymarketContext,useTradeResultConfirmation,useTickSize,normalizePolymarketTickSize,useFeeRate,useRebateConfig,useRealtimeOrderbook,pickBestAsk,walkOrderbook,usePositionsMulti,useDFlowQuote,useDFlowSubmit,useOrder,buildSignedV2OrderPayload,buildCtfExchangeDomain,buildOrderMessage,CTF_ORDER_TYPES,buildSignedOrder,buildClobPayload,buildPolymarketL2Headers,resolveEventsParams,useInfiniteEvents,useRedeemPosition,pickBestBid,useAvailableShares,getPolymarketSharesPrecision,useInfiniteOrders,useCancelOrder,useInfiniteTrades,useMarketHistory,useSimilarEvents,useEvent,candlesticksQueryKey,useInfiniteComments,useInfinitePredictSearch,usePositions,usePositionValueMulti,usePredictWsClient,orderbookQueryKey}from'@liberfi.io/react-predict';export{PredictClient,PredictContext,PredictProvider,PredictWsClient,createPredictClient,createPredictWsClient,eventStatsQueryKey,fetchMatchMarketsPage,fetchMatchesPage,fetchPredictSearch,matchMarketsQueryKey,matchQueryKey,matchesQueryKey,predictSearchQueryKey,useBalance,useCancelOrder,useCandlesticks,useDFlowKYC,useDFlowQuote,useDFlowSubmit,useEvent,useEventStats,useEvents,useInfiniteEvents,useInfiniteMatchMarkets,useInfiniteMatches,useInfiniteOrders,useInfinitePredictSearch,useInfiniteTrades,useMarket,useMarketHistory,useMarketTrades,useMatch,useOrder,useOrderbook,useOrders,usePositionValue,usePositionValueMulti,usePositions,usePredictClient,usePredictSearch,usePriceHistory,useRedeemPosition,useSearchEvents,useSimilarEvents,useTrades}from'@liberfi.io/react-predict';import {ChainNamespace,Chain}from'@liberfi.io/types';import {formatAmountInUsd,SOLANA_TOKENS,formatAmount}from'@liberfi.io/utils';import ki from'canvas-confetti';import {keepPreviousData,useQueryClient,useQueries}from'@tanstack/react-query';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 {createBrowserSearchHistoryStorage,createMemorySearchHistoryStorage,useSearchKeyboardNavigation,useSearchController}from'@liberfi.io/ui/search';var Sd={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},na=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],ln=(()=>{let e=t=>{let r=na.indexOf(t);return r===-1?na.length:r};return Object.entries(Sd).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 fi({categories:e,selectedCategory:t,selectedTag:r,activeTags:o,onCategorySelect:n,onTagSelect:i,trailing:s,pulsingTab:a="Trending",className:l}){let{t:m}=useTranslation(),u=useCallback(()=>{n(null);},[n]),c=m("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(ia,{label:c,isSelected:t===null,onPress:u,showPulse:c===a}),jsx(wd,{}),e.map(p=>{let d=p.slug??p.category,f=p.label??p.category;return jsx(ia,{label:f,isSelected:t===d,onPress:()=>n(d),badge:p.badge,showPulse:d===a||f===a},d)})]})}),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(sa,{label:m("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>i(null)}),o.map(p=>{let d=p.slug??p.label;return jsx(sa,{label:p.label,icon:p.icon,isSelected:r===d,onPress:()=>i(d)},d)})]})})]})}function ia({label:e,isSelected:t,onPress:r,badge:o,showPulse:n}){return jsxs("button",{type:"button",onClick:r,className:cn("relative shrink-0 cursor-pointer whitespace-nowrap border-b px-2.5 py-1.5 text-sm font-medium capitalize transition-colors",t?"border-primary/50 text-primary":"border-transparent text-text-muted hover:text-text-secondary"),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-text-inverse",children:o})]})}function wd(){return jsx("span",{className:"flex items-center text-text-muted","aria-hidden":"true",children:"|"})}function sa({label:e,icon:t,isSelected:r,onPress:o}){return jsxs("button",{type:"button",onClick:o,className:cn("flex shrink-0 items-center justify-center gap-x-1 min-w-14 rounded-2xl border px-3 py-1.5 text-sm font-medium uppercase transition-colors cursor-pointer",r?"border-primary/40 bg-primary/15 text-primary":"border-border/80 text-text-muted hover:bg-primary/10 hover:text-primary"),children:[t&&jsx("span",{className:cn("iconify size-4",t)}),e]})}function Ed({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 la(e){return e.trim().toLowerCase().replace(/&/g,"and").replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}function Td(e){return `predict.categories.category.${la(e)}`}function ca(e){return `predict.categories.tag.${la(e)}`}function Rd(e,t){return e.map(r=>({category:r.slug,slug:r.slug,label:t(Td(r.slug),r.label),tags:r.tags.map(o=>({slug:o.slug,label:t(ca(o.slug),o.label),icon:o.icon}))}))}function Ld(e,t){return e?e.tags.map(r=>({slug:r.slug,label:t(ca(r.slug),r.label),icon:r.icon})):[]}function vi({onSelect:e,trailing:t,className:r}){let{t:o}=useTranslation(),n=useCallback((f,g)=>{let v=o(f);return typeof v=="string"&&v!==f?v:g},[o]),[i,s]=useState(null),[a,l]=useState(null),m=useCallback(f=>{s(f),l(null),e?.({categorySlug:f,tagSlug:null});},[e]),u=useCallback(f=>{l(f),e?.({categorySlug:i,tagSlug:f});},[i,e]),c=Rd(ln,n),p=ln.find(f=>f.slug===i),d=Ld(p,n);return jsx(fi,{categories:c,selectedCategory:i,selectedTag:a,activeTags:d,onCategorySelect:m,onTagSelect:u,trailing:t,className:r})}function dn(e,t){return e?.trim()||t}function Vr(e){return dn(e.title_trans,e.title)??e.title}function hi(e){return dn(e.question_trans,e.question)??e.question}function xi(e){return dn(e.description_trans,e.description)}function un(e){return dn(e.label_trans,e.label)??e.label}function lr(e){let t=e.outcomes?.[0];return t?un(t):hi(e)}function pn(e){return {title:Vr(e),imageUrl:e.image_url}}function mn(e,t){let r=e.outcomes[0],o=e.outcomes[1];return {question:hi(e),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?un(r):lr(e),noSubTitle:o?un(o):"No"}}var Gr=24,fn=4,jr={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},K={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_MONTH:"1m",ALL:"all"},ko=K.ALL,_d={[K.ONE_HOUR]:jr.ONE_MINUTE,[K.SIX_HOURS]:jr.ONE_MINUTE,[K.ONE_DAY]:jr.ONE_MINUTE,[K.ONE_MONTH]:jr.ONE_MINUTE,[K.ALL]:jr.ONE_MINUTE},Id={[K.ONE_HOUR]:60,[K.SIX_HOURS]:60,[K.ONE_DAY]:300,[K.ONE_MONTH]:900,[K.ALL]:900},bi={[K.ONE_HOUR]:3600,[K.SIX_HOURS]:360*60,[K.ONE_DAY]:1440*60,[K.ONE_MONTH]:720*60*60,[K.ALL]:null},Dd={[K.ONE_HOUR]:1,[K.SIX_HOURS]:1,[K.ONE_DAY]:5,[K.ONE_MONTH]:15,[K.ALL]:15},So=1,Po=1,Ad=1,Fd=1,Bd=99,Nr={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},Hd=Nr.ONE_WEEK,Ud={[Nr.ONE_HOUR]:60,[Nr.SIX_HOURS]:60,[Nr.ONE_DAY]:300,[Nr.ONE_WEEK]:1800,[Nr.MAX]:1800};var pa=createContext(null);function cr(){let e=useContext(pa);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var jd=1e4;function ma({pollingInterval:e=jd,enabled:t=true,enableKalshi:r=true,children:o}){let n=useWallets(),i=useMemo(()=>n.find(M=>M.chainNamespace===ChainNamespace.SOLANA&&M.isConnected)?.address,[n]),s=useMemo(()=>n.find(M=>M.chainNamespace===ChainNamespace.EVM&&M.isConnected)?.address,[n]),{data:a,isLoading:l,isFetching:m,error:u}=useBalance({source:"kalshi",user:i??""},{enabled:t&&r&&!!i,refetchInterval:e}),{data:c,isLoading:p}=useDFlowKYC(i,{enabled:t&&r&&!!i,refetchInterval:3e4}),{data:d,isLoading:f}=usePolymarketSetup(s,{enabled:t&&!!s,refetchInterval:3e4}),g=d?.safe_address,b=d?.verified??false,v=d?.wallet_kind??"deposit",S=d?.deposit_wallet_address,x=v==="safe"?d?.safe_address:S,y=v==="safe"?d?.safe_deployed??false:d?.deposit_wallet_deployed??false,{data:h,isLoading:k,isFetching:N,error:w}=useBalance({source:"polymarket",user:s??""},{enabled:t&&b&&!!s,refetchInterval:e}),P=useMemo(()=>({enableKalshi:r,solanaAddress:i,evmAddress:s,polymarketWalletKind:v,polymarketWalletAddress:x,polymarketDepositWalletAddress:S,polymarketWalletDeployed:y,polymarketSafeAddress:g,kalshiUsdcBalance:a?Number(a.balance):null,polymarketUsdcBalance:b&&h?Number(h.balance):null,kalshiKycVerified:c?.verified??false,kalshiKycUrl:c?.kyc_url??null,kalshiKycLoading:p,polymarketSetupVerified:b,polymarketSafeDeployed:d?.safe_deployed??false,polymarketTokenApproved:d?.token_approved??false,polymarketSetupLoading:f,isLoading:l||k,isFetching:m||N,error:u??w??null}),[r,i,s,v,x,S,y,g,a,h,b,c,p,d,f,l,k,m,N,u,w]);return jsx(pa.Provider,{value:P,children:o})}var Yd={minutes:60,hours:3600,days:86400};function No(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*Yd[r]}}function Mo(e,t){let r=parseFloat(t);return !r||r<=0?e:Math.round(e/r)*r}function be(e,t){let r=Math.pow(10,t);return Math.floor(e*r)/r}function fa(e){let t=e;return !Number.isFinite(t)||t<=0||t>=1?1:1-t}var ga=100,va=300;function Si(e,t){return ga/1e4+Math.max(0,e)/1e4*fa(t)}function qd(e,t){let r=e?.[t],o=typeof r=="number"?r:Number(r);return Number.isFinite(o)?o:void 0}function Qd(e,t){let r=e?.[t];return typeof r=="string"?r:void 0}function Pi(e){let t=qd(e,"polymarket.effectiveTakerFeeBps");if(t!==void 0&&t>=0)return t;let r=e?.["polymarket.feeDescriptor"],o=typeof r?.r=="number"?r.r:Number(r?.r);return Number.isFinite(o)&&o>=0?o*1e4:Qd(e,"polymarket.sportsMarketType")?va:0}function Ni({source:e,usdcBalance:t,safetyBufferUsd:r=.01,feeRateBps:o=0,pricePerShare:n}){if(t==null||!Number.isFinite(t))return 0;let i=be(Math.max(0,t),2);if(e!=="polymarket")return i;let s=Si(o,n??NaN),a=i/(1+s)-r;return be(Math.max(0,a),2)}function Mi({usdcAmount:e,pricePerShare:t,feeRateBps:r}){if(!Number.isFinite(e)||e<=0)return 0;let o=Si(r,t);return e*o}function wi({grossReturn:e,pricePerShare:t,feeRateBps:r}){if(!Number.isFinite(e)||e<=0)return 0;let o=Si(r,t);return e*o}function wo(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:be(s,2).toFixed(2),active:be(a,2).toFixed(2),available:be(l,2).toFixed(2)})}return /not enough balance/i.test(e)?t(r==="sell"?"predict.trade.insufficientShares":"predict.trade.insufficientBalance"):/max accuracy of/i.test(e)?t("predict.trade.polymarket.decimalAccuracy"):/tick size/i.test(e)?t("predict.trade.polymarket.tickSizeError"):/couldn.*fully filled|FOK.*filled or killed/i.test(e)?t("predict.trade.polymarket.fokNotFilled"):e.replace(/order\s+0x[a-f0-9]+\s+is invalid\.\s*/i,"")||e}function Mr(e,t=2){return parseFloat(be(e,t).toFixed(t)).toString()}function Ei(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};ki({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{ki({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{ki({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function Yr(e,t){return {submitted:e("predict.trade.resultSubmitted"),completed:e("predict.trade.resultCompleted"),delayed:e("predict.trade.resultDelayed")}}function tu({deadlineAt:e}){let{formatUnit:t}=useLocalizedTimeFormatter(),[r,o]=useState(()=>Math.max(0,e-Date.now()));return useEffect(()=>{let n=setInterval(()=>{o(Math.max(0,e-Date.now()));},1e3);return ()=>clearInterval(n)},[e]),t(Math.max(0,Math.ceil(r/1e3)),"second")}function wr({id:e=`predict-trade-result-${Date.now()}`,durationMs:t=3e4,celebrateOnCompleted:r=false,messages:o}){return {id:e,submitted:()=>{let n=Date.now()+t;toast.progress({id:e,message:o.submitted,duration:t,progress:true,action:createElement(tu,{deadlineAt:n})});},completed:()=>{toast.update(e,{type:"success",message:o.completed,duration:5e3}),r&&Ei();},delayed:()=>{toast.update(e,{type:"blank",message:o.delayed,duration:8e3});},failed:n=>{toast.update(e,{type:"error",message:n,duration:8e3});}}}function Ti({market:e,initialOutcome:t="yes",slippageBps:r=100,onInsufficientBalance:o}){let{t:n,i18n:i}=useTranslation(),{status:s}=useAuth(),a=useWallets(),l=usePredictClient(),m=useContext(PolymarketContext),{start:u}=useTradeResultConfirmation(),c=e.source,p=c==="polymarket",d=a.find(D=>D.chainNamespace===ChainNamespace.SOLANA&&D.isConnected),f=a.find(D=>D.chainNamespace===ChainNamespace.EVM&&D.isConnected&&"switchChain"in D),g=s==="authenticated",b=d?.address,v=f?.address,[S,x]=useState(t),[y,h]=useState("market"),[k,N]=useState(NaN),[w,P]=useState(NaN),[M,T]=useState(false),[A,X]=useState(null),[L,G]=useState(false),[U,oe]=useState(false),[W,te]=useState("1h"),[ne,se]=useState(30),[ve,Pe]=useState("minutes"),pt=useMemo(()=>Yr(n),[i,n]),Ve=true,Be=useCallback(async(D,De)=>{let Te=wr({celebrateOnCompleted:true,messages:pt});Te.submitted(),await u({source:c,user:c==="kalshi"?b:v,kalshiUser:Ve?b:void 0,polymarketUser:v,marketSlug:e.slug,eventSlug:e.event_slug,expectation:D,getOrdersHeaders:De})==="confirmed"?Te.completed():Te.delayed();},[u,Ve,v,e.event_slug,e.slug,c,pt,b]),E=useMemo(()=>{if(c!=="polymarket")return;let D=e.provider_meta?.["polymarket.clobTokenIds"];return D?(typeof D=="string"?JSON.parse(D):D)[S==="yes"?0:1]:void 0},[c,e.provider_meta,S]),{data:st,isLoading:He}=useTickSize(E),he=normalizePolymarketTickSize(st?.minimum_tick_size),{data:at,isLoading:we}=useFeeRate(E),Ue=at?.base_fee??0,qe=String(Ue),C=useMemo(()=>Pi(e.provider_meta),[e.provider_meta]),{data:O}=useRebateConfig(),z=O?.builder_enabled&&O.builder_code?O.builder_code:void 0,Z=null,me=false,Ne=null,lt=false,ct,kt,Qe;try{let D=cr();Ve=D.enableKalshi,Z={kalshiUsdcBalance:D.kalshiUsdcBalance,polymarketUsdcBalance:D.polymarketUsdcBalance,isLoading:D.isLoading},me=D.kalshiKycVerified,Ne=D.kalshiKycUrl,lt=D.polymarketSetupVerified,ct=D.polymarketSafeAddress,kt=D.polymarketWalletKind,Qe=D.polymarketWalletAddress;}catch{}let Yt=c==="kalshi"&&!me,We=c==="polymarket"&&!lt,{data:et}=useRealtimeOrderbook({slug:e.slug,source:c,outcome:S},{enabled:e.status==="open"}),xe=useMemo(()=>{let D=pickBestAsk(et,S);if(D!=null&&D>0)return D;let De=S==="yes"?0:1,Te=e.outcomes[De];return Te?.best_ask??Te?.price??.5},[et,e.outcomes,S]),mt=useCallback(D=>{h(D);},[]),St=useCallback(D=>{x(D),P(NaN);},[]);useEffect(()=>{St(t);},[t,St]),useEffect(()=>{y==="limit"&&isNaN(w)&&P(Math.round(xe*1e4)/1e4);},[y,w,xe]);let Me=useMemo(()=>y==="limit"&&p&&!isNaN(w)?w:xe,[y,p,w,xe]),tt=useMemo(()=>isNaN(k)||k<=0?0:Me>0?k/Me:0,[k,Me]),Ce=useMemo(()=>walkOrderbook({orderbook:et,outcome:S,side:"buy",sharesNeeded:tt,slippageBps:r}),[et,S,tt,r]),Lt=useMemo(()=>Ce.status==="ok"&&Ce.worstPrice!=null&&Ce.worstPrice>0?Ce.worstPrice:xe,[Ce,xe]),I=useMemo(()=>isNaN(k)||k<=0?"0":String(Math.round(k*1e6)),[k]),_e=e.provider_meta?.["dflow.yesMint"]??"",Xe=e.provider_meta?.["dflow.noMint"]??"",go=SOLANA_TOKENS.stablecoins.USDC.address,B=S==="yes"?_e:Xe,Ie=go,Pt=B,Ft=c==="kalshi"?b??"":v??"",{data:vo,isLoading:ii}=usePositionsMulti({kalshi_user:c==="kalshi"?Ft:void 0,polymarket_user:c==="polymarket"?Ft:void 0},{enabled:!!Ft}),si=c==="kalshi"&&!!Ie&&!!Pt&&!!b&&I!=="0",{refetch:qt}=useDFlowQuote({inputMint:Ie,outputMint:Pt,amount:I,userPublicKey:b??"",slippageBps:100},{enabled:si}),Dr=useMemo(()=>Z?c==="kalshi"?Z.kalshiUsdcBalance:Z.polymarketUsdcBalance:vo&&vo.positions.reduce((De,Te)=>Te.side==="USDC"||Te.side==="collateral"?De+(Te.current_value??0):De,0)||null,[Z,vo,c]),ai=Z?Z.isLoading:ii,ft=useMemo(()=>Ni({source:c,usdcBalance:Dr,feeRateBps:C,pricePerShare:Me}),[c,Dr,C,Me]),Ot=Dr==null?null:ft,Ar=useMemo(()=>isNaN(k)||k<=0?0:k,[k]),ho=useMemo(()=>isNaN(k)||k<=0?0:Me>0?k/Me*1:0,[k,Me]),Fr=useMemo(()=>c!=="polymarket"||isNaN(k)||k<=0?0:Mi({usdcAmount:k,pricePerShare:Me,feeRateBps:C}),[c,k,Me,C]),sr=ho-Ar-Fr,li=useCallback(D=>{if(isNaN(D)){N(NaN);return}N(Math.round(Math.max(0,D)*100)/100);},[]),tn=useCallback(D=>{if(isNaN(D)){P(NaN);return}P(Math.round(D*1e4)/1e4);},[]),Br=useCallback(()=>{N(NaN),P(NaN),h("market"),oe(false),te("1h"),se(30),Pe("minutes");},[]),Qt=useMemo(()=>{let D=[];return isNaN(k)||k<=0?D.push(n("predict.trade.minAmountUsd",{amount:Po})):k<Po&&D.push(n("predict.trade.minAmountUsd",{amount:Po})),e.status!=="open"&&D.push(n("predict.trade.marketNotActive")),Ot!=null&&!isNaN(k)&&k>0&&k>Ot&&D.push(n("predict.trade.insufficientBalance")),y==="limit"&&p&&(isNaN(w)||w<.01||w>.99)&&D.push(n("predict.trade.limitPriceRange")),y==="limit"&&p&&U&&W==="custom"&&(isNaN(ne)||ne<=0)&&D.push(n("predict.trade.expiration.invalidDate")),c==="polymarket"&&y==="market"&&!isNaN(k)&&k>0&&tt>0&&(Ce.status==="insufficient_liquidity"?D.push(n("predict.trade.insufficientLiquidity",{available:be(Ce.totalAvailable,2)})):Ce.status==="exceeds_slippage"&&D.push(n("predict.trade.priceImpactTooHigh",{impact:(Ce.priceImpactBps/100).toFixed(2),slippage:(r/100).toFixed(2)}))),{isValid:D.length===0,errors:D}},[k,e.status,Ot,y,p,w,U,W,ne,c,tt,Ce,r,n]),xr=useMemo(()=>Ot==null||isNaN(k)||k<=0?false:k>Ot,[Ot,k]),br=useCallback(()=>{o?.(c);},[o,c]),{mutateAsync:yr}=useDFlowSubmit(),{data:xo}=useOrder({id:A??"",source:c},{enabled:!!A});useEffect(()=>{if(!xo||!A)return;let{status:D}=xo;D==="closed"?(X(null),T(false),Be("buy-market"),Br()):(D==="failed"||D==="expired")&&(T(false),X(null),toast.error(n("predict.trade.submitError")));},[Be,xo,A,Br,n]);let bo=useCallback(async()=>{if(!b||!d)return;if(!Ie||!Pt){toast.error("Missing token mint addresses"),T(false);return}if(!me){G(true),T(false);return}let It=(await qt()).data?.transaction;if(!It){toast.error(n("predict.trade.submitError")),T(false);return}let yo=Uint8Array.from(atob(It),gt=>gt.charCodeAt(0)),Xt=await d.signTransaction(yo),Jt=await yr({signedTransaction:btoa(String.fromCharCode(...Xt)),orderContext:{user_public_key:b,input_mint:Ie,output_mint:Pt,amount:I,price:String(xe),side:"BUY",outcome:S==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});X(Jt.signature);},[b,d,qt,yr,Ie,Pt,I,xe,S,e.slug,n,me]),Hr=useCallback(async()=>{if(!f||!m)return;let D=f.chain,De=D!==Chain.POLYGON;De&&await f.switchChain(Chain.POLYGON);try{let Te=await f.getEip1193Provider();if(!Te){toast.error(n("predict.trade.submitError")),T(!1);return}let It=kt==="deposit"&&!!Qe,yo=!It&&!!ct,Xt=It?Qe:ct,Jt={address:f.address,signatureType:It?3:yo?2:0,signTypedData:async(Dt,R,Re,Le)=>{let ze=[];"name"in Dt&&ze.push({name:"name",type:"string"}),"version"in Dt&&ze.push({name:"version",type:"string"}),"chainId"in Dt&&ze.push({name:"chainId",type:"uint256"}),"verifyingContract"in Dt&&ze.push({name:"verifyingContract",type:"address"}),"salt"in Dt&&ze.push({name:"salt",type:"bytes32"});let ht={EIP712Domain:ze,...R};return await Te.request({method:"eth_signTypedData_v4",params:[f.address,JSON.stringify({domain:Dt,types:ht,primaryType:Re,message:Le})]})}},gt=m.credentials??await m.authenticate(Jt),ci=S==="yes"?0:1,rn="",Ut=e.provider_meta?.["polymarket.clobTokenIds"];Ut&&(rn=(typeof Ut=="string"?JSON.parse(Ut):Ut)[ci]??"");let Ur=e.provider_meta?.["polymarket.negRisk"]??!1,Wr=y==="limit"&&!isNaN(w)?w:Lt,kr=Mo(Wr,he),on=y==="limit"?U?"GTD":"GTC":"FOK",Sr=y==="market"?k:kr>0?k/kr:0,zr={tokenId:rn,price:kr,size:Sr,side:"BUY",orderType:on,tickSize:he,negRisk:Ur,...Xt&&{funderAddress:Xt},...z&&{builderCode:z},...y==="limit"&&U&&{expiration:No(W,ne,ve)}},Kr;if(It)Kr=await buildSignedV2OrderPayload({signer:Jt,depositWalletAddress:Xt,input:zr,owner:gt.apiKey});else {let Dt=buildCtfExchangeDomain(Ur),R=buildOrderMessage({...zr,signerAddress:Jt.address,signatureType:Jt.signatureType,feeRateBps:qe}),Re=await Jt.signTypedData(Dt,CTF_ORDER_TYPES,"Order",R),Le=buildSignedOrder(R,Re,zr.orderType);Kr=buildClobPayload(Le,gt.apiKey);}await l.executePolymarketOrder({payload:Kr,l2_api_key:gt.apiKey,l2_secret:gt.secret,l2_passphrase:gt.passphrase,signer_address:gt.address,owner:gt.apiKey}),Be(y==="limit"?"buy-limit":"buy-market",async()=>await buildPolymarketL2Headers(gt.address,{apiKey:gt.apiKey,secret:gt.secret,passphrase:gt.passphrase,method:"GET",requestPath:"/data/orders"})),Br(),T(!1);}finally{De&&D&&f.switchChain(D).catch(()=>{});}},[f,m,S,e.provider_meta,y,Be,w,Lt,k,l,U,W,ne,ve,Br,n,he,qe,ct,kt,Qe,z]),_t=useCallback(async()=>{if(!(!Qt.isValid||!g)){T(true),X(null),G(false);try{c==="kalshi"?await bo():await Hr();}catch(D){let De=D instanceof Error?D.message:"",Te=c==="polymarket"&&De?wo(De,n,"buy"):De||void 0;toast.error(Te||n("predict.trade.submitError")),T(false);}}},[Qt.isValid,g,c,bo,Hr,n]);return {outcome:S,orderType:y,quantity:k,limitPrice:w,shares:tt,effectivePrice:Me,estimatedCost:Ar,estimatedFee:Fr,potentialPayout:ho,potentialProfit:sr,pricePerShare:xe,usdcBalance:Dr,maxBuyAmount:ft,spendableUsdcBalance:Ot,isBalanceLoading:ai,isMarketDataLoading:c==="polymarket"&&(we||He),isSubmitting:M,authStatus:s,validation:Qt,isInsufficientBalance:xr,source:c,supportsLimitOrder:p,kycRequired:L,needsKyc:Yt,needsSetup:We,kycUrl:Ne,expirationEnabled:U,expirationPreset:W,customDuration:ne,customDurationUnit:ve,setOutcome:St,setOrderType:mt,setQuantity:li,setLimitPrice:tn,setExpirationEnabled:oe,setExpirationPreset:te,setCustomDuration:se,setCustomDurationUnit:Pe,submit:_t,notifyInsufficientBalance:br}}function Co({isOpen:e,onClose:t,kycUrl:r}){let{t:o}=useTranslation();return jsx(StyledModal,{isOpen:e,onOpenChange:n=>{n||t();},size:"md",classNames:{base:THEMED_MODAL_BASE_CLASS,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-text-primary",children:o("predict.trade.kycModalTitle")}),jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-surface-strong/50 text-text-secondary hover:text-text-primary 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-text-secondary 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-text-secondary",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-brand-primary 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-brand-primary/70 hover:text-brand-primary transition-colors mb-3",children:[o("predict.trade.goToKYC")," \u2192"]}),jsx("p",{className:"text-[11px] text-text-muted mb-5",children:o("predict.trade.kycModalNote")}),jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] bg-action-primary text-text-inverse text-sm font-semibold hover:bg-action-primary-hover 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 Wu=["5m","1h","12h","24h","eod","custom"],zu={"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"},Ku=["minutes","hours","days"],$u={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},Vu={maximumFractionDigits:0},dr="-";function Oi({event:e,market:t,variant:r="bordered",outcome:o,orderType:n,quantity:i,limitPrice:s,shares:a,effectivePrice:l,potentialProfit:m,potentialPayout:u,estimatedCost:c,estimatedFee:p=0,usdcBalance:d,isBalanceLoading:f,isMarketDataLoading:g,isSubmitting:b,authStatus:v,isValid:S,validationErrors:x,isInsufficientBalance:y,onInsufficientBalance:h,supportsLimitOrder:k,maxBuyAmount:N,kycRequired:w,needsKyc:P,needsSetup:M,kycUrl:T,expirationEnabled:A,expirationPreset:X,customDuration:L,customDurationUnit:G,oddsFormatter:U,outcomeLabels:oe,onOutcomeChange:W,onOrderTypeChange:te,onQuantityChange:ne,onLimitPriceChange:se,onExpirationEnabledChange:ve,onExpirationPresetChange:Pe,onCustomDurationChange:pt,onCustomDurationUnitChange:Ve,onSubmit:Be}){let{t:E}=useTranslation(),[st,He]=useState(true),he=useDisclosure(),[at,we]=useState(""),Ue=useRef(false);useEffect(()=>{Ue.current||we(isNaN(i)?"":String(i));},[i]);let[qe,C]=useState(""),O=useRef(false);useEffect(()=>{O.current||(isNaN(s)?C(""):C(String(parseFloat((s*100).toFixed(2)))));},[s]);let z=useCallback(B=>{if(B!==""&&!/^\d*\.?\d{0,2}$/.test(B))return;if(C(B),B===""||B==="."){se(NaN);return}let Pt=parseFloat(B);isNaN(Pt)||se(Pt/100);},[se]),Z=useCallback(B=>{if(B!==""&&!/^\d*\.?\d{0,2}$/.test(B))return;if(we(B),Xe(false),B===""||B==="."){ne(NaN);return}let Pt=parseFloat(B);isNaN(Pt)||ne(Pt);},[ne]);useEffect(()=>{w&&!he.isOpen&&he.onOpen();},[w,he]);let me=useMemo(()=>{let B=o==="yes"?t.yesAsk:t.noAsk;return B!=null?parseFloat((Number(B)*100).toFixed(2)):null},[o,t]),Ne=o==="yes"?t.yesAsk:t.noAsk,lt=Ne!=null&&U?U(Number(Ne)):me!=null?`${me} \xA2`:dr,ct=Number.isFinite(l)?parseFloat((l*100).toFixed(2)):null,kt=Number.isFinite(l)&&U?U(l):ct!=null?`${ct} \xA2`:dr,Qe=!isNaN(i)&&i>0,Yt=Qe?c+p:0,We=Qe&&a>0?Yt/a:0,et=We>0&&U?U(We):We>0?`${parseFloat((We*100).toFixed(2))}\xA2`:dr,xe=v==="authenticated",mt=v==="authenticating"||v==="deauthenticating",St=xe&&(P||M),Me=useCallback(B=>oe?.[B]??E(B==="yes"?"predict.trade.yes":"predict.trade.no"),[oe,E]),tt=useMemo(()=>{if(mt)return E("predict.trade.checkingLogin");if(!xe)return E("predict.trade.loginToTrade");if(P)return E("predict.trade.kycRequired");if(M)return E("predict.trade.setupRequired");if(f)return E("predict.trade.loadingBalance");if(g)return E("predict.trade.loadingMarketData");if(b)return E("predict.trade.submitting");if(w)return E("predict.trade.kycRequired");if(!Qe)return E("predict.trade.enterAmount");let B=Me(o),Ie=m>0?` \u2192 Win $${m.toFixed(2)}`:"";return `${E("predict.trade.buy")} ${B}${Ie}`},[mt,xe,P,M,f,g,b,w,Qe,o,Me,m,E]),Ce="primary",Lt=()=>{let B=N??be(d??0,2);ne(be(B/2,2));},I=()=>{ne(N??be(d??0,2));},[_e,Xe]=useState(false),go=()=>{if(!xe){Xe(false),Be();return}if(P){he.onOpen();return}if(M&&h){Xe(false),h();return}if(w){he.onOpen();return}if(y&&h){Xe(false),h();return}if(!S){Xe(true);return}Xe(false),Be();};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 var(--color-border-subtle)",background:"hsl(var(--heroui-content2) / 0.4)",transition:"border-color 0.2s"}:void 0,onMouseEnter:B=>{r==="bordered"&&(B.currentTarget.style.borderColor="hsl(var(--heroui-content4) / 0.8)");},onMouseLeave:B=>{r==="bordered"&&(B.currentTarget.style.borderColor="hsl(var(--heroui-content3) / 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-text-muted leading-tight line-clamp-1",children:e.title}),jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsx("span",{className:"text-foreground",children:t.yesSubTitle}),jsx("span",{className:"text-foreground",children:" \xB7 "}),jsxs("span",{className:"text-positive",children:[E("predict.trade.buy")," ",Me(o)]})]})]})]}),jsxs("div",{className:"flex items-center justify-between",children:[k?jsxs(Tabs,{variant:"underlined",selectedKey:n,onSelectionChange:B=>te(B),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsx(Tab,{title:E("predict.trade.market")},"market"),jsx(Tab,{title:E("predict.trade.limit")},"limit")]}):jsx("span",{className:"text-sm font-medium text-foreground",children:E("predict.trade.market")}),n==="limit"&&k?jsx(StyledInput,{"aria-label":E("predict.trade.limitPrice"),placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:qe,onChange:B=>z(B.target.value),onFocus:()=>{O.current=true;},onBlur:()=>{O.current=false,isNaN(s)?C(""):C(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"}}):lt!=null&&jsx("span",{className:"text-xl font-bold tabular-nums",children:lt})]}),jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(B=>{let Ie=B==="yes"?t.yesAsk:t.noAsk;return jsx("div",{className:"flex flex-1 flex-col gap-y-1",children:jsxs("button",{type:"button",onClick:()=>W(B),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${o===B?"border-positive bg-positive/10 text-positive":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsx("span",{children:Me(B)}),Ie!=null&&jsx("span",{className:"ml-1 opacity-70",children:U?U(Number(Ie)):`${parseFloat((Number(Ie)*100).toFixed(2))}\xA2`})]})},B)})}),jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxs("div",{className:"flex items-center justify-between text-xs text-text-muted",children:[jsx("span",{className:"text-sm font-medium text-foreground",children:E("predict.trade.youArePaying")}),jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("button",{type:"button",onClick:Lt,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-text-muted hover:text-foreground font-medium",children:E("predict.trade.half")}),jsx("button",{type:"button",onClick:I,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-text-muted hover:text-foreground font-medium",children:E("predict.trade.max")})]})]}),jsx(StyledInput,{"aria-label":E("predict.trade.tradeAmount"),fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:at,onChange:B=>Z(B.target.value),onFocus:()=>{Ue.current=true;},onBlur:()=>{Ue.current=false,we(isNaN(i)?"":String(i));},startContent:jsx("span",{className:"text-text-muted 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"}}),_e&&x.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:x.map(B=>jsx("span",{className:"text-xs text-danger",children:B},B))})]}),jsxs("div",{className:"flex items-center justify-end gap-x-1.5 text-sm",children:[jsx("span",{className:"text-text-muted",children:E("predict.trade.balance")}),jsx("span",{className:"font-medium text-foreground tabular-nums",children:d!=null?`$${be(d,2).toFixed(2)}`:"$0"})]}),n==="limit"&&k&&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:E("predict.trade.setExpiration")}),jsx(StyledSwitch,{size:"sm",color:"primary",isSelected:A,onValueChange:ve,"aria-label":E("predict.trade.setExpiration")})]}),A&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":E("predict.trade.setExpiration"),selectedKeys:[X],onSelectionChange:B=>{let Ie=Array.from(B)[0];Ie&&Pe(Ie);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Wu.map(B=>jsx(SelectItem,{children:E(zu[B])},B))}),X==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":E("predict.trade.durationAmount"),size:"sm",radius:"lg",value:isNaN(L)?void 0:L,onValueChange:pt,minValue:1,step:1,formatOptions:Vu,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":E("predict.trade.durationUnit"),selectedKeys:[G],onSelectionChange:B=>{let Ie=Array.from(B)[0];Ie&&Ve(Ie);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Ku.map(B=>jsx(SelectItem,{children:E($u[B])},B))})]})]})]}),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:()=>He(B=>!B),className:"flex items-center gap-x-1 text-text-muted hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{children:E("predict.trade.odds")}),jsx(ChevronDownIcon,{className:cn("h-3.5 w-3.5 transition-transform",st&&"rotate-180")})]}),jsx("span",{className:"text-foreground font-medium tabular-nums",children:U&&Number.isFinite(l)?kt:ct!=null?E("predict.trade.chance",{percent:ct}):dr})]}),st&&jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-text-muted",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:E("predict.trade.totalSize")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${c.toFixed(2)}`:dr})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:E("predict.trade.numContracts")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(a)&&a>0?Mr(a):dr})]}),p>0&&jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:E("predict.trade.estFee")}),jsx("span",{className:"tabular-nums text-foreground",children:`$${p.toFixed(2)}`})]}),p>0&&jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:E("predict.trade.totalPayment")}),jsx("span",{className:"tabular-nums text-foreground",children:`$${Yt.toFixed(2)}`})]}),p>0&&jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:E("predict.trade.effectiveOdds")}),jsx("span",{className:"tabular-nums text-foreground",children:et})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:E("predict.trade.payout")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${u.toFixed(2)}`:dr})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:E("predict.trade.estProfit")}),jsx("span",{className:"tabular-nums text-positive",children:!isNaN(i)&&i>0&&m>0?`+$${m.toFixed(2)}`:dr})]})]})]}),jsx(Button,{color:Ce,fullWidth:true,radius:"lg",size:"lg",isDisabled:mt||xe&&!St&&(f||g||!Qe||b),isLoading:mt||xe&&!St&&(b||f||g),spinner:jsx(Spinner,{size:"sm",color:"current"}),onPress:go,children:tt})]}),jsx(Co,{isOpen:he.isOpen,onClose:he.onClose,kycUrl:T})]})}function To({event:e,market:t,variant:r,initialOutcome:o,chain:n,slippageBps:i,onInsufficientBalance:s,onOutcomeChange:a,oddsFormatter:l,outcomeLabels:m}){let{outcome:u,orderType:c,quantity:p,limitPrice:d,shares:f,effectivePrice:g,estimatedCost:b,estimatedFee:v,potentialPayout:S,potentialProfit:x,pricePerShare:y,usdcBalance:h,maxBuyAmount:k,isBalanceLoading:N,isMarketDataLoading:w,isSubmitting:P,authStatus:M,validation:T,isInsufficientBalance:A,supportsLimitOrder:X,kycRequired:L,needsKyc:G,needsSetup:U,kycUrl:oe,expirationEnabled:W,expirationPreset:te,customDuration:ne,customDurationUnit:se,setOutcome:ve,setOrderType:Pe,setQuantity:pt,setLimitPrice:Ve,setExpirationEnabled:Be,setExpirationPreset:E,setCustomDuration:st,setCustomDurationUnit:He,submit:he,notifyInsufficientBalance:at}=Ti({market:t,initialOutcome:o,slippageBps:i,onInsufficientBalance:s}),we=useAuthCallback(he),Ue=useCallback(O=>{ve(O),a?.(O);},[ve,a]),qe=useMemo(()=>e?pn(e):void 0,[e]),C=useMemo(()=>mn(t,{yesAsk:u==="yes"?y:void 0,noAsk:u==="no"?y:void 0}),[t,u,y]);return jsx(Oi,{event:qe,market:C,variant:r,outcome:u,orderType:c,quantity:p,limitPrice:d,shares:f,effectivePrice:g,estimatedCost:b,estimatedFee:v,potentialPayout:S,potentialProfit:x,usdcBalance:h,maxBuyAmount:k,isBalanceLoading:N,isMarketDataLoading:w,isSubmitting:P,authStatus:M,isValid:T.isValid,validationErrors:T.errors,isInsufficientBalance:A,onInsufficientBalance:s?at:void 0,supportsLimitOrder:X,kycRequired:L,needsKyc:G,needsSetup:U,kycUrl:oe,expirationEnabled:W,expirationPreset:te,customDuration:ne,customDurationUnit:se,oddsFormatter:l,outcomeLabels:m,onOutcomeChange:Ue,onOrderTypeChange:Pe,onQuantityChange:pt,onLimitPriceChange:Ve,onExpirationEnabledChange:Be,onExpirationPresetChange:E,onCustomDurationChange:st,onCustomDurationUnitChange:He,onSubmit:we})}var Qr="predict-trade";function Ro({id:e=Qr}){return jsx(AsyncModal,{id:e,children:t=>jsx(tp,{...t})})}function tp({params:e,isOpen:t,onOpenChange:r}){let{t:o}=useTranslation(),{isMobile:n}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:n?"lg":"md",backdrop:"opaque",hideCloseButton:true,classNames:{base:THEMED_MODAL_BASE_CLASS,body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{className:n?"":"p-2",children:[jsx(To,{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-text-secondary hover:text-text-primary hover:bg-surface-strong/50 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 yn(e,t=true){let r=0;return t&&e.source&&r++,e.timeRemaining&&r++,e.minVolume&&r++,e.minLiquidity&&r++,r}function _i({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]),m=useCallback(S=>{S?a(r):t();},[r,t]),u=useCallback(()=>{a(l);},[l]),c=useCallback(()=>{o(s),t();},[s,o,t]),p=useCallback((S,x)=>{a(y=>({...y,[S]:x}));},[]),d=useMemo(()=>yn(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]),b=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]),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]);return jsx(StyledModal,{isOpen:e,onOpenChange:m,size:"md",backdrop:"opaque",scrollBehavior:"inside",classNames:{base:THEMED_MODAL_BASE_CLASS,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-text-primary",children:i("predict.filter.title")}),jsx(lp,{onClick:()=>m(false)})]}),jsxs("div",{style:{padding:"0 20px 16px",display:"flex",flexDirection:"column",gap:20},children:[n&&jsx(xn,{label:i("predict.filter.platform"),children:jsx(bn,{options:f,selected:s.source,onSelect:S=>p("source",S)})}),jsx(xn,{label:i("predict.filter.timeRemaining"),children:jsx(bn,{options:g,selected:s.timeRemaining,onSelect:S=>p("timeRemaining",S)})}),jsx(xn,{label:i("predict.filter.minVolume"),children:jsx(bn,{options:b,selected:s.minVolume,onSelect:S=>p("minVolume",S)})}),jsx(xn,{label:i("predict.filter.minLiquidity"),children:jsx(bn,{options:v,selected:s.minLiquidity,onSelect:S=>p("minLiquidity",S)})})]}),jsxs("div",{className:"flex items-center gap-3 px-5 py-4",style:{borderTop:"1px solid var(--color-border-subtle)"},children:[jsx("button",{type:"button",className:"inline-flex items-center justify-center py-2.5 px-5 rounded-[10px] text-text-secondary text-sm font-medium hover:text-text-primary 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-action-primary text-text-inverse text-sm font-semibold hover:bg-action-primary-hover transition-colors cursor-pointer",onClick:c,children:[i("predict.filter.showResults"),d>0&&jsxs("span",{style:{opacity:.7},children:["(",d,")"]})]})]})]})})})}function xn({label:e,children:t}){return jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[jsx("span",{style:{fontSize:11,fontWeight:500,color:"var(--color-text-muted)",textTransform:"uppercase",letterSpacing:"0.05em"},children:e}),t]})}function lp({onClick:e}){return jsx("button",{type:"button",onClick:e,className:"p-1 rounded-[10px] hover:bg-surface-strong/50 text-text-secondary hover:text-text-primary 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 bn({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 color-mix(in srgb, var(--color-action-primary) 30%, transparent)":"1px solid var(--color-border-subtle)",background:i?"color-mix(in srgb, var(--color-action-primary) 8%, transparent)":"hsl(var(--heroui-content3) / 0.4)",color:i?"var(--color-action-primary)":"var(--color-text-secondary)"},onMouseEnter:s=>{i||(s.currentTarget.style.background="hsl(var(--heroui-content3) / 0.8)",s.currentTarget.style.color="var(--color-text-primary)");},onMouseLeave:s=>{i||(s.currentTarget.style.background="hsl(var(--heroui-content3) / 0.4)",s.currentTarget.style.color="var(--color-text-secondary)");},children:n.label},n.value??"__all")})})}var Ii={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},Ca={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},hp=["start_time","volume","liquidity","ending_soon"],Ta={display:"inline-flex",alignItems:"center",gap:8,borderRadius:10,border:"1px solid var(--color-border-subtle)",background:"hsl(var(--heroui-content3) / 0.6)",padding:"8px 12px",fontSize:14,color:"var(--color-text-primary)",cursor:"pointer",transition:"all 0.15s"},xp={position:"absolute",left:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid var(--color-border-control)",background:"var(--color-surface-interactive)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function Di({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:o,onFilterPress:n,filterCount:i=0,className:s}){let{t:a}=useTranslation(),[l,m]=useState(false),u=useRef(null),c=useCallback(d=>{u.current&&!u.current.contains(d.target)&&m(false);},[]);useEffect(()=>(document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)),[c]),useEffect(()=>{if(!l)return;let d=f=>{f.key==="Escape"&&m(false);};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[l]);let p=Ra[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:Ta,onMouseEnter:d=>{d.currentTarget.style.background="var(--color-surface-strong)";},onMouseLeave:d=>{d.currentTarget.style.background="hsl(var(--heroui-content3) / 0.6)";},onClick:()=>m(d=>!d),children:[jsx(bp,{}),jsx(p,{className:"size-4 shrink-0",style:{color:"var(--color-text-secondary)"}}),jsx("span",{className:"hidden sm:block",style:{color:"var(--color-text-primary)"},children:a(Ca[e])}),jsx(kp,{open:l})]}),l&&jsx("div",{style:{...xp,width:224,padding:4},children:hp.map(d=>{let f=Ra[d],g=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:g?"color-mix(in srgb, var(--color-action-primary) 8%, transparent)":"transparent",color:g?"var(--color-action-primary)":"var(--color-text-secondary)",borderRadius:10},onMouseEnter:b=>{g||(b.currentTarget.style.background="hsl(var(--heroui-content3) / 0.5)",b.currentTarget.style.color="var(--color-text-primary)");},onMouseLeave:b=>{g||(b.currentTarget.style.background="transparent",b.currentTarget.style.color="var(--color-text-secondary)");},onClick:()=>{e===d?o(!r):t(d),m(false);},children:[jsx(f,{className:"size-4 shrink-0",style:{color:g?"var(--color-action-primary)":"var(--color-text-muted)"}}),jsx("span",{style:{flex:1,fontWeight:500},children:a(Ca[d])}),g&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"var(--color-action-primary)",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 var(--color-border-subtle)",background:"hsl(var(--heroui-content3) / 0.6)",width:36,height:36,color:"var(--color-text-secondary)",cursor:"pointer",transition:"all 0.15s",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:14},onMouseEnter:d=>{d.currentTarget.style.background="var(--color-surface-strong)",d.currentTarget.style.color="var(--color-text-primary)";},onMouseLeave:d=>{d.currentTarget.style.background="hsl(var(--heroui-content3) / 0.6)",d.currentTarget.style.color="var(--color-text-secondary)";},onClick:()=>o(!r),children:r?"\u2191":"\u2193"}),jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxs("button",{type:"button",style:Ta,onMouseEnter:d=>{d.currentTarget.style.background="var(--color-surface-strong)";},onMouseLeave:d=>{d.currentTarget.style.background="hsl(var(--heroui-content3) / 0.6)";},onClick:n,children:[jsx(yp,{}),jsx("span",{className:"hidden sm:block",style:{color:"var(--color-text-primary)"},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:"var(--color-action-primary)",color:"var(--color-text-inverse)",fontSize:10,fontWeight:600,padding:"0 4px"},children:i})]})]})}var Ra={start_time:CalendarIcon,volume:ChartLineIcon,liquidity:DropletIcon,ending_soon:TimerIcon};function bp(){return jsxs("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"var(--color-text-secondary)"},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 yp(){return jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"var(--color-text-secondary)"},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 kp({open:e}){return jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"var(--color-text-muted)",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 Ai(e={}){let{i18n:t}=useTranslation(),{tagSlugSelection:r,limit:o,status:n,sort_by:i,sort_asc:s,source:a,with_markets:l,minVolume:m,minLiquidity:u,timeRemaining:c,markets_limit:p,lang:d}=e,f=d??t.resolvedLanguage??t.language,g=useMemo(()=>resolveEventsParams({tagSlugSelection:r,limit:o,status:n,sort_by:i,sort_asc:s,source:a,with_markets:l,minVolume:m,minLiquidity:u,timeRemaining:c,markets_limit:p,lang:f}),[f,o,p,u,m,s,i,a,n,r,c,l]),{data:b,isLoading:v,isFetching:S,isFetchingNextPage:x,isError:y,error:h,hasNextPage:k,fetchNextPage:N,refetch:w}=useInfiniteEvents(g),P=useMemo(()=>b?.pages.flatMap(A=>A.items).filter(A=>A!=null)??[],[b]),M=useCallback(()=>{N();},[N]),T=useCallback(()=>{w();},[w]);return {data:P,isLoading:v,isFetching:S&&!x,isFetchingMore:x,isError:y,error:h??null,hasMore:k??false,fetchMore:M,refetch:T}}var _a=`
|
|
2
2
|
@keyframes evtShimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}
|
|
3
3
|
@media(max-width:1279px){.evt-skel-grid{grid-template-columns:repeat(3,1fr)!important}}
|
|
4
4
|
@media(max-width:1023px){.evt-skel-grid{grid-template-columns:repeat(2,1fr)!important}.evt-skel-card{min-height:200px!important}}
|
|
5
5
|
@media(max-width:767px){.evt-skel-grid{grid-template-columns:1fr!important}}
|
|
6
|
-
`,
|
|
6
|
+
`,Ia={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 kn(e){return {...Ia,animationDelay:`${e}ms`}}function Sn({count:e=6}){return jsxs(Fragment,{children:[jsx("style",{children:_a}),jsx("div",{className:"evt-skel-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",width:"100%"},children:Array.from({length:e}).map((t,r)=>jsx(Mp,{index:r},r))})]})}function Mp({index:e}){let t=e*120,r={...Ia,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 var(--color-border-subtle)",background:"hsl(var(--heroui-content2) / 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 var(--color-border-subtle)",background:"hsl(var(--heroui-content3) / 0.15)",padding:"8px 14px"},children:[jsx("div",{style:{...r,height:10,width:56}}),jsx("div",{style:{...r,height:10,width:72}})]})]})})}function wp(){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:{...kn(t*50),height:28,width:e,borderRadius:6}},t))}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[jsx("div",{style:{...kn(0),height:36,width:120,borderRadius:10}}),jsx("div",{style:{...kn(50),height:36,width:36,borderRadius:10}}),jsx("div",{style:{...kn(100),height:36,width:80,borderRadius:10}})]})]})}function Ep({count:e=24}){return jsxs("div",{style:{minHeight:"100vh",position:"relative",width:"100%",maxWidth:1680,margin:"0 auto"},children:[jsx("style",{children:_a}),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 var(--color-border-subtle)"},children:jsx(wp,{})}),jsx("div",{style:{padding:"12px 8px 80px"},children:jsx(Sn,{count:e})})]})}function Tp(e,t){let r={...e};return delete r.price,t||(delete r.best_bid,delete r.best_ask),r}function Pn(e){if(!e.capability?.enabled)return e.legacyEvent;let t=e.marketDataEvent??e.legacyEvent;return {...t,markets:t.markets?.map(r=>({...r,outcomes:r.outcomes.map(o=>Tp(o,!!e.marketDataEvent))}))}}function Zr(e,t){if(e)return t?e.best_ask:e.best_ask??e.price}var Da=3,Bp={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)"}},Hp={border:"hsl(var(--heroui-primary) / 0.4)",shadow:"0 2px 18px hsl(var(--heroui-primary) / 0.45)"},Fi={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},za={bg:"hsl(var(--heroui-secondary) / 0.14)",text:"hsl(var(--heroui-secondary))",shadow:"hsl(var(--heroui-secondary) / 0.18)"},Up={bg:"rgba(239, 68, 68, 0.14)",text:"rgb(239, 68, 68)",shadow:"rgba(239, 68, 68, 0.18)"},Lo=[{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 Aa(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 Wp(e){let t=e.outcomes?.map(s=>s.label?.toLowerCase().trim()??"")??[];if(t.some(s=>s==="up")&&t.some(s=>s==="down"))return [Fi,Up];if(t.some(s=>s==="yes")&&t.some(s=>s==="no"))return [Fi,za];let r=t[0]??"",o=t[1]??"",n=Aa(r)%Lo.length,i=Aa(o)%Lo.length;return i===n&&(i=(i+1)%Lo.length),[Lo[n],Lo[i]]}function Fa(e){return e.title_trans||e.title}function zp(e){return e.question_trans||e.question}function Bi(e,t){return e?.label_trans||e?.label||t}function Ka(e){return Bi(e.outcomes?.[0],zp(e))}function Hi(e,t){let r=e.outcomes?.[0];return r?Zr(r,t)??null:null}function $a(e,t){let r=Hi(e,t);return r!=null?parseFloat((r*100).toFixed(2)):null}function Va(e){return e===null?"\u2014":e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function Ba(e,t){let r=e.outcomes?.[0],o=Zr(r,t);return o===void 0?"\u2014":parseFloat((o*100).toFixed(2)).toString()}function Ha(e,t){let r=e.outcomes?.[1];if(r){let i=Zr(r,t);return i===void 0?"\u2014":parseFloat((i*100).toFixed(2)).toString()}if(t)return "\u2014";let o=e.outcomes?.[0],n=o?.best_ask??o?.price??0;return parseFloat(((1-n)*100).toFixed(2)).toString()}function Kp(e,t){let r=new Date(e).getTime()-Date.now();if(r<=0)return null;let o=Math.floor(r/864e5),n=Math.floor(r%864e5/36e5),i=Math.floor(r%36e5/6e4),s=[];return o>0&&s.push(t(o,"day")),n>0&&s.push(t(n,"hour")),s.push(t(i,"minute")),s.join(" ")}var $p=`
|
|
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 Ui({event:e,href:t,LinkComponent:r,onSelect:o,onSelectOutcome:n,onHover:i,marketDataCapability:s,marketDataEvent:a}){let[l,m]=useState(null),u=s?.enabled??false,c=useMemo(()=>Sn({capability:s,legacyEvent:e,marketDataEvent:a}),[e,s,a]),d=useMemo(()=>{let w=c.markets??[];return w.length>2?[...w].sort((P,M)=>(Bi(M,u)??-1)-(Bi(P,u)??-1)):w},[c.markets,u]).filter(w=>w.status==="open"),f=d.length===1,g=d.slice(0,_a),b=d.length-_a,h=useMemo(()=>formatAmountInUsd(e.volume??0),[e.volume]),S=l?d.find(w=>w.slug===l)??null:null,x=!!S||f,y=()=>{x||o?.(c);},v=w=>{w.stopPropagation(),S&&(w.preventDefault(),m(null));},k=w=>{w.stopPropagation(),t||(w.preventDefault(),o?.(c));},N=f?jsx(em,{event:c,formattedVolume:h,href:t,LinkComponent:r,onSelect:o}):S?jsx(rm,{onCollapse:()=>m(null)}):jsx(Qp,{moreCount:b,formattedVolume:h,source:c.source,href:t,LinkComponent:r,onShowMore:k});return jsxs("div",{className:"group evt-card",style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",borderRadius:14,border:"1px solid var(--color-border-subtle)",background:"hsl(var(--heroui-content2) / 0.4)",overflow:"hidden",transition:"all 0.2s",cursor:x?void 0:"pointer"},onMouseEnter:w=>{let P=w.currentTarget,M=Ap[e.source]??Fp;P.style.borderColor=M.border,P.style.boxShadow=M.shadow,i?.(e);},onMouseLeave:w=>{let P=w.currentTarget;P.style.borderColor="hsl(var(--heroui-content3) / 0.6)",P.style.boxShadow="none";},onClick:y,children:[jsx("style",{children:zp}),jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,padding:"14px 14px 12px",gap:8},children:[jsx(Kp,{event:c,href:t,LinkComponent:r,onClick:v,isExpanded:x}),jsx("div",{style:{display:"flex",flexDirection:"column",flex:1},children:f?jsx(Zp,{market:d[0],event:c,onSelectOutcome:n,marketDataEnabled:u}):S?jsx(tm,{market:S,event:c,onCollapse:()=>m(null),onSelectOutcome:n,marketDataEnabled:u}):jsx(qp,{displayedMarkets:g,marketDataEnabled:u,onMarketClick:w=>m(w.slug)})})]}),jsx(Xp,{children:N})]})}function Kp({event:e,href:t,LinkComponent:r,onClick:o,isExpanded:n}){let{t:i}=useTranslation(),{formatUnit:s}=useLocalizedTimeFormatter(),a=e.start_at?Wp(e.start_at,s):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:Da(e)||i("predict.event.fallbackName"),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-text-primary line-clamp-2 lg:text-base",n&&"group-hover/header:text-text-secondary"),children:Da(e)}),a&&jsx("span",{className:"text-[10px] leading-4 text-text-muted",children:i("predict.event.liveIn",{countdown:a})})]}),jsx(Vp,{event:e})]})}function $p(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",minutes:n<=i?5:15,color:a});}}return o&&t.push({kind:"live"}),t.slice(0,2)}function Vp({event:e}){let{formatUnit:t}=useLocalizedTimeFormatter(),r=useMemo(()=>$p(e),[e]);return r.length===0?null:jsx("div",{className:"flex flex-shrink-0 flex-col items-end gap-1",children:r.map((o,n)=>{switch(o.kind){case "live":return jsx(jp,{},n);case "crypto-short":return jsx(Gp,{label:t(o.minutes,"minute"),color:o.color},n);case "closed":return jsx(Yp,{},n)}})})}function jp(){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 Gp({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 Yp(){let{t:e}=useTranslation();return jsx("span",{className:"inline-flex items-center rounded-md bg-surface-interactive/80 px-1.5 py-0.5 text-xs font-semibold text-text-secondary",children:e("predict.event.status.closed")})}function qp({displayedMarkets:e,onMarketClick:t,marketDataEnabled:r}){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(o=>{let n=za(o,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:i=>{i.stopPropagation(),t(o);},children:[jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-text-primary line-clamp-1 lg:text-sm",children:Wa(o)}),jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("span",{className:"text-sm font-semibold text-text-primary lg:text-lg",children:Ka(n)}),jsx(Jp,{})]})]},o.id??`${o.source}-${o.slug}`)})}):null}function Qp({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-text-muted transition-colors hover:text-text-primary cursor-pointer lg:text-xs",onClick:i,children:[s("predict.event.showMore"),jsx(Va,{className:"h-3 w-3"})]}):jsx("div",{}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:10,color:"var(--color-text-muted)"},children:[t," ",s("predict.event.volume"),jsx(ja,{source:r})]})]})}function Xp({children:e}){return jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid var(--color-border-subtle)",background:"hsl(var(--heroui-content3) / 0.15)",padding:"8px 14px",marginTop:"auto"},children:e})}function Ba({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 $a({market:e,event:t,onSelectOutcome:r,dynamicColors:o=false,labelFormat:n="action",marketDataEnabled:i}){let{t:s}=useTranslation(),[a,l]=o?Hp(e):[Ai,Ua],m=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",u=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",c=n==="label"&&m===u?"action":n,p=c==="label"?`${Fi(e.outcomes?.[0],"Yes")} ${Aa(e,i)}\xA2`:s("predict.market.action.yes",{price:Aa(e,i)}),d=c==="label"?`${Fi(e.outcomes?.[1],"No")} ${Fa(e,i)}\xA2`:s("predict.market.action.no",{price:Fa(e,i)});return jsxs("div",{className:"flex gap-2",children:[jsx(Ba,{bgColor:a.bg,textColor:a.text,shadowColor:a.shadow,onClick:f=>{f.stopPropagation(),r?.(t,e,"yes");},children:p}),jsx(Ba,{bgColor:l.bg,textColor:l.text,shadowColor:l.shadow,onClick:f=>{f.stopPropagation(),r?.(t,e,"no");},children:d})]})}function Jp(){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-text-secondary",children:"/"}),jsx("span",{className:"text-secondary",children:e("predict.market.no")})]})}function Zp({market:e,event:t,onSelectOutcome:r,marketDataEnabled:o}){return jsx("div",{style:{flex:1},children:jsx($a,{market:e,event:t,onSelectOutcome:r,dynamicColors:true,labelFormat:"label",marketDataEnabled:o})})}function em({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-text-muted transition-colors hover:text-text-primary cursor-pointer lg:text-xs",onClick:a=>{a.stopPropagation(),r||(a.preventDefault(),n?.(e));},children:[i("predict.event.viewEvent"),jsx(Va,{className:"h-3 w-3"})]}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:10,color:"var(--color-text-muted)"},children:[t," ",i("predict.event.volume"),jsx(ja,{source:e.source})]})]})}function tm({market:e,event:t,onCollapse:r,onSelectOutcome:o,marketDataEnabled:n}){let i=za(e,n);return jsxs("div",{style:{flex:1},children:[jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between cursor-pointer",onClick:s=>{s.stopPropagation(),r();},children:[jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-text-primary lg:text-sm",children:Wa(e)}),jsxs("div",{className:"flex items-center gap-x-1 flex-shrink-0",children:[jsx("span",{className:"text-sm font-semibold text-text-primary lg:text-lg",children:Ka(i)}),jsx(ChevronUpIcon,{className:"h-4 w-4 text-text-secondary"})]})]}),jsx("div",{style:{marginTop:12},children:jsx($a,{market:e,event:t,onSelectOutcome:o,labelFormat:"action",marketDataEnabled:n})})]})}function rm({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-text-primary cursor-pointer lg:text-xs",style:{color:"var(--color-text-muted)"},onClick:r=>{r.stopPropagation(),e();},children:[jsx(om,{className:"h-3 w-3"}),t("predict.event.back")]}),jsx("div",{})]})}function Va({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 om({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 ja({source:e}){return jsxs("span",{className:"inline-flex items-center gap-x-1 text-text-secondary",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsx("span",{className:"text-text-muted",children:"\xB7"}),e==="polymarket"?jsx(PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsx(KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}var am=8;function zi({events:e,hasMore:t=false,isFetchingMore:r=false,onFetchMore:o,onSelect:n,onSelectOutcome:i,getEventHref:s,LinkComponent:a,onHover:l,marketDataCapability:m,getMarketDataEvent:u}){let{t:c}=useTranslation(),p=useRef(null);useEffect(()=>{let g=p.current;if(!g)return;let b=new IntersectionObserver(h=>{h[0]?.isIntersecting&&t&&!r&&o?.();},{rootMargin:"300px"});return b.observe(g),()=>b.disconnect()},[t,r,o]);let d=useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]),f=!t&&e.length>0;return jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[jsx("style",{children:`
|
|
30
|
+
`;function Wi({event:e,href:t,LinkComponent:r,onSelect:o,onSelectOutcome:n,onHover:i,marketDataCapability:s,marketDataEvent:a}){let[l,m]=useState(null),u=s?.enabled??false,c=useMemo(()=>Pn({capability:s,legacyEvent:e,marketDataEvent:a}),[e,s,a]),d=useMemo(()=>{let w=c.markets??[];return w.length>2?[...w].sort((P,M)=>(Hi(M,u)??-1)-(Hi(P,u)??-1)):w},[c.markets,u]).filter(w=>w.status==="open"),f=d.length===1,g=d.slice(0,Da),b=d.length-Da,v=useMemo(()=>formatAmountInUsd(e.volume??0),[e.volume]),S=l?d.find(w=>w.slug===l)??null:null,x=!!S||f,y=()=>{x||o?.(c);},h=w=>{w.stopPropagation(),S&&(w.preventDefault(),m(null));},k=w=>{w.stopPropagation(),t||(w.preventDefault(),o?.(c));},N=f?jsx(rm,{event:c,formattedVolume:v,href:t,LinkComponent:r,onSelect:o}):S?jsx(nm,{onCollapse:()=>m(null)}):jsx(Jp,{moreCount:b,formattedVolume:v,source:c.source,href:t,LinkComponent:r,onShowMore:k});return jsxs("div",{className:"group evt-card",style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",borderRadius:14,border:"1px solid var(--color-border-subtle)",background:"hsl(var(--heroui-content2) / 0.4)",overflow:"hidden",transition:"all 0.2s",cursor:x?void 0:"pointer"},onMouseEnter:w=>{let P=w.currentTarget,M=Bp[e.source]??Hp;P.style.borderColor=M.border,P.style.boxShadow=M.shadow,i?.(e);},onMouseLeave:w=>{let P=w.currentTarget;P.style.borderColor="hsl(var(--heroui-content3) / 0.6)",P.style.boxShadow="none";},onClick:y,children:[jsx("style",{children:$p}),jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,padding:"14px 14px 12px",gap:8},children:[jsx(Vp,{event:c,href:t,LinkComponent:r,onClick:h,isExpanded:x}),jsx("div",{style:{display:"flex",flexDirection:"column",flex:1},children:f?jsx(tm,{market:d[0],event:c,onSelectOutcome:n,marketDataEnabled:u}):S?jsx(om,{market:S,event:c,onCollapse:()=>m(null),onSelectOutcome:n,marketDataEnabled:u}):jsx(Xp,{displayedMarkets:g,marketDataEnabled:u,onMarketClick:w=>m(w.slug)})})]}),jsx(Zp,{children:N})]})}function Vp({event:e,href:t,LinkComponent:r,onClick:o,isExpanded:n}){let{t:i}=useTranslation(),{formatUnit:s}=useLocalizedTimeFormatter(),a=e.start_at?Kp(e.start_at,s):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:Fa(e)||i("predict.event.fallbackName"),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-text-primary line-clamp-2 lg:text-base",n&&"group-hover/header:text-text-secondary"),children:Fa(e)}),a&&jsx("span",{className:"text-[10px] leading-4 text-text-muted",children:i("predict.event.liveIn",{countdown:a})})]}),jsx(Gp,{event:e})]})}function jp(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",minutes:n<=i?5:15,color:a});}}return o&&t.push({kind:"live"}),t.slice(0,2)}function Gp({event:e}){let{formatUnit:t}=useLocalizedTimeFormatter(),r=useMemo(()=>jp(e),[e]);return r.length===0?null:jsx("div",{className:"flex flex-shrink-0 flex-col items-end gap-1",children:r.map((o,n)=>{switch(o.kind){case "live":return jsx(Yp,{},n);case "crypto-short":return jsx(qp,{label:t(o.minutes,"minute"),color:o.color},n);case "closed":return jsx(Qp,{},n)}})})}function Yp(){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 qp({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 Qp(){let{t:e}=useTranslation();return jsx("span",{className:"inline-flex items-center rounded-md bg-surface-interactive/80 px-1.5 py-0.5 text-xs font-semibold text-text-secondary",children:e("predict.event.status.closed")})}function Xp({displayedMarkets:e,onMarketClick:t,marketDataEnabled:r}){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(o=>{let n=$a(o,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:i=>{i.stopPropagation(),t(o);},children:[jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-text-primary line-clamp-1 lg:text-sm",children:Ka(o)}),jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("span",{className:"text-sm font-semibold text-text-primary lg:text-lg",children:Va(n)}),jsx(em,{})]})]},o.id??`${o.source}-${o.slug}`)})}):null}function Jp({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-text-muted transition-colors hover:text-text-primary cursor-pointer lg:text-xs",onClick:i,children:[s("predict.event.showMore"),jsx(Ga,{className:"h-3 w-3"})]}):jsx("div",{}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:10,color:"var(--color-text-muted)"},children:[t," ",s("predict.event.volume"),jsx(Ya,{source:r})]})]})}function Zp({children:e}){return jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid var(--color-border-subtle)",background:"hsl(var(--heroui-content3) / 0.15)",padding:"8px 14px",marginTop:"auto"},children:e})}function Ua({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 ja({market:e,event:t,onSelectOutcome:r,dynamicColors:o=false,labelFormat:n="action",marketDataEnabled:i}){let{t:s}=useTranslation(),[a,l]=o?Wp(e):[Fi,za],m=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",u=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",c=n==="label"&&m===u?"action":n,p=c==="label"?`${Bi(e.outcomes?.[0],"Yes")} ${Ba(e,i)}\xA2`:s("predict.market.action.yes",{price:Ba(e,i)}),d=c==="label"?`${Bi(e.outcomes?.[1],"No")} ${Ha(e,i)}\xA2`:s("predict.market.action.no",{price:Ha(e,i)});return jsxs("div",{className:"flex gap-2",children:[jsx(Ua,{bgColor:a.bg,textColor:a.text,shadowColor:a.shadow,onClick:f=>{f.stopPropagation(),r?.(t,e,"yes");},children:p}),jsx(Ua,{bgColor:l.bg,textColor:l.text,shadowColor:l.shadow,onClick:f=>{f.stopPropagation(),r?.(t,e,"no");},children:d})]})}function em(){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-text-secondary",children:"/"}),jsx("span",{className:"text-secondary",children:e("predict.market.no")})]})}function tm({market:e,event:t,onSelectOutcome:r,marketDataEnabled:o}){return jsx("div",{style:{flex:1},children:jsx(ja,{market:e,event:t,onSelectOutcome:r,dynamicColors:true,labelFormat:"label",marketDataEnabled:o})})}function rm({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-text-muted transition-colors hover:text-text-primary cursor-pointer lg:text-xs",onClick:a=>{a.stopPropagation(),r||(a.preventDefault(),n?.(e));},children:[i("predict.event.viewEvent"),jsx(Ga,{className:"h-3 w-3"})]}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:10,color:"var(--color-text-muted)"},children:[t," ",i("predict.event.volume"),jsx(Ya,{source:e.source})]})]})}function om({market:e,event:t,onCollapse:r,onSelectOutcome:o,marketDataEnabled:n}){let i=$a(e,n);return jsxs("div",{style:{flex:1},children:[jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between cursor-pointer",onClick:s=>{s.stopPropagation(),r();},children:[jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-text-primary lg:text-sm",children:Ka(e)}),jsxs("div",{className:"flex items-center gap-x-1 flex-shrink-0",children:[jsx("span",{className:"text-sm font-semibold text-text-primary lg:text-lg",children:Va(i)}),jsx(ChevronUpIcon,{className:"h-4 w-4 text-text-secondary"})]})]}),jsx("div",{style:{marginTop:12},children:jsx(ja,{market:e,event:t,onSelectOutcome:o,labelFormat:"action",marketDataEnabled:n})})]})}function nm({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-text-primary cursor-pointer lg:text-xs",style:{color:"var(--color-text-muted)"},onClick:r=>{r.stopPropagation(),e();},children:[jsx(im,{className:"h-3 w-3"}),t("predict.event.back")]}),jsx("div",{})]})}function Ga({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 im({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 Ya({source:e}){return jsxs("span",{className:"inline-flex items-center gap-x-1 text-text-secondary",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsx("span",{className:"text-text-muted",children:"\xB7"}),e==="polymarket"?jsx(PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsx(KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}var cm=8;function Ki({events:e,hasMore:t=false,isFetchingMore:r=false,onFetchMore:o,onSelect:n,onSelectOutcome:i,getEventHref:s,LinkComponent:a,onHover:l,marketDataCapability:m,getMarketDataEvent:u}){let{t:c}=useTranslation(),p=useRef(null);useEffect(()=>{let g=p.current;if(!g)return;let b=new IntersectionObserver(v=>{v[0]?.isIntersecting&&t&&!r&&o?.();},{rootMargin:"300px"});return b.observe(g),()=>b.disconnect()},[t,r,o]);let d=useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]),f=!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((g,b)=>g==null?null:jsx("div",{style:{padding:
|
|
36
|
+
`}),jsx("div",{className:"evt-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)"},children:e.map((g,b)=>g==null?null:jsx("div",{style:{padding:cm,animation:`eventCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${b%4*35}ms both`},children:jsx(Wi,{event:g,href:s?.(g),LinkComponent:a,onSelect:n,onSelectOutcome:i,onHover:l,marketDataCapability:m,marketDataEvent:u?.(g)})},`${g.source}-${g.slug}`))}),jsx("div",{ref:p,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:"var(--color-text-muted)",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")]})}),f&&jsx(dm,{onScrollToTop:d})]})}function dm({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-surface-strong"}),jsx("span",{className:"text-xs font-medium text-text-muted",children:t("predict.event.endOfList")}),jsx("div",{className:"h-px w-16 bg-surface-strong"})]}),jsxs("button",{type:"button",className:"flex cursor-pointer items-center gap-x-1 text-xs font-medium text-text-secondary",onClick:e,children:[jsx("span",{className:"iconify size-4 ph--arrow-up-bold"}),jsx("span",{children:t("predict.event.backToTop")})]})]})}function Vi({tagSlugSelection:e,limit:t=24,status:r,sort_by:o,sort_asc:n,source:i,with_markets:s,timeRemaining:a,minVolume:l,minLiquidity:m,markets_limit:u,lang:c,onSelect:p,onSelectOutcome:d,getEventHref:f,LinkComponent:g,onHover:b,marketDataCapability:v,getMarketDataEvent:S}){let{data:x,hasMore:y,fetchMore:h,isFetching:k,isFetchingMore:N,isError:w,error:P,refetch:M}=Ai({tagSlugSelection:e,limit:t,status:r,sort_by:o,sort_asc:n,source:i,with_markets:s,timeRemaining:a,minVolume:l,minLiquidity:m,markets_limit:u,lang:c});return k&&x.length===0?jsx(Sn,{count:24}):w&&x.length===0?jsx($i,{error:P,onRetry:M}):x.length===0?jsx($i,{}):jsxs(Fragment,{children:[w&&jsx($i,{error:P,onRetry:M,compact:true}),jsx(Ki,{events:x,hasMore:y,isFetchingMore:N,onFetchMore:h,onSelect:p,onSelectOutcome:d,getEventHref:f,LinkComponent:g,onHover:b,marketDataCapability:v,getMarketDataEvent:S})]})}function $i({error:e,onRetry:t,compact:r=false}){let{t:o}=useTranslation();return jsxs("div",{role:e?"alert":"status","data-testid":e?"events-error-state":"events-empty-state",style:{minHeight:r?0:280,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:r?8:12,padding:r?"12px 16px":0,margin:r?"8px":0,border:r?"1px solid var(--color-border-default)":void 0,borderRadius:r?12:void 0,background:r?"var(--color-surface-raised)":void 0,color:"var(--color-text-muted)",textAlign:"center"},children:[jsx("span",{className:e?"iconify ph--warning-circle":"iconify ph--tray",style:{width:32,height:32},"aria-hidden":"true"}),jsx("p",{style:{margin:0,fontSize:14},children:o(e?"predict.events.loadFailed":"predict.events.empty")}),e&&t&&jsx("button",{type:"button",onClick:t,style:{minHeight:36,padding:"0 16px",borderRadius:18,border:"1px solid var(--color-border-default)",background:"var(--color-surface-raised)",color:"var(--color-text-primary)",cursor:"pointer"},children:o("predict.events.retry")})]})}function gm({onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:o,onHover:n,onInsufficientBalance:i,enableKalshi:s=true,lang:a,marketDataCapability:l,getMarketDataEvent:m}){let[u,c]=useState({categorySlug:null,tagSlug:null}),[p,d]=useState(()=>s?Jr:{...Jr,source:"polymarket"}),{isOpen:f,onOpen:g,onClose:b}=useDisclosure(),{onOpen:v}=useAsyncModal(Qr),S=useCallback((M,T,A)=>{t?.(M,T,A),v({params:{event:M,market:T,initialOutcome:A,onInsufficientBalance:i}});},[t,v,i]),x=useCallback(M=>{c(M);},[]),y=useCallback(M=>{d(T=>({...T,sortPreset:M}));},[]),h=useCallback(M=>{d(T=>({...T,sortAsc:M}));},[]),k=useCallback(M=>{d(M);},[]),N=useMemo(()=>Ii[p.sortPreset].sort_by,[p.sortPreset]),w=useMemo(()=>yn(p,s),[p,s]),P=useMemo(()=>jsx(Di,{sortPreset:p.sortPreset,onSortChange:y,sortAsc:p.sortAsc,onSortAscChange:h,onFilterPress:g,filterCount:w}),[p.sortPreset,p.sortAsc,w,y,h,g]);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 var(--color-border-subtle)"},children:jsx(vi,{onSelect:x,trailing:P})}),jsxs("div",{style:{padding:"12px 8px 80px"},children:[jsx(_i,{isOpen:f,onClose:b,value:p,onChange:k,enableKalshi:s}),jsx(Vi,{tagSlugSelection:u,lang:a,sort_by:N,sort_asc:p.sortAsc,source:p.source,timeRemaining:p.timeRemaining,minVolume:p.minVolume,minLiquidity:p.minLiquidity,onSelect:e,onSelectOutcome:S,getEventHref:r,LinkComponent:o,onHover:n,marketDataCapability:l,getMarketDataEvent:m})]}),jsx(Ro,{})]})}function el(e){return formatAmountInUsd(e)}var xm=[{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:el,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:el,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 bm({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:"hsl(var(--heroui-content3) / 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:"var(--color-text-primary)",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:"var(--color-text-muted)",maxWidth:460},children:String(t("predict.events.heroSubtitle")).split(`
|
|
74
|
-
`).map((r,o)=>jsxs("span",{children:[o>0&&jsx("br",{className:"hidden sm:block"}),r,o===0?" ":""]},o))})]}),jsx("div",{className:"evt-stat-grid",style:e?{animation:"evtStatsEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:"0.1s"}:{},children:fm.map((r,o)=>jsxs("div",{style:{padding:"14px 16px",background:e?`linear-gradient(to bottom, ${r.gradientFrom}, ${r.gradientTo})`:"hsl(var(--heroui-foreground) / 0.02)",borderRight:o%2===0?"1px solid var(--color-border-subtle)":"none",borderBottom:o<2?"1px solid var(--color-border-subtle)":"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:"hsl(var(--heroui-foreground) / 0.06)",animation:"evtStatCardEnter 0.6s ease-out both",animationDelay:`${o*80}ms`}})}),jsx("div",{className:"evt-stat-label",style:{fontWeight:500,color:e?"var(--color-text-muted)":"transparent",marginTop:2,display:"flex",alignItems:"center"},children:e?t(r.labelKey):jsx("div",{style:{height:10,width:64,borderRadius:4,background:"hsl(var(--heroui-foreground) / 0.04)",animation:"evtStatCardEnter 0.6s ease-out both",animationDelay:`${50+o*80}ms`}})})]},r.key))})]})]})}function ji({event:e,market:t,position:r,onSuccess:o,onCancel:n}){let{t:i,i18n:s}=useTranslation(),{mutateAsync:a}=useRedeemPosition(),{start:l}=useTradeResultConfirmation(),{evmAddress:m}=cr(),u=useWallets(),[c,p]=useState("idle"),[d,f]=useState(null),g=t.provider_meta?.["polymarket.conditionId"],b=t.provider_meta?.["polymarket.negRisk"]??false,h=m??"",S=useMemo(()=>Gr(i),[s,i]),x=useMemo(()=>u.find(G=>G.chainNamespace===ChainNamespace.EVM&&G.isConnected),[u]),y=tl(r.side,t.outcomes),k=t.outcomes?.[y]?.label??r.side,N=t.result!=null?tl(t.result,t.outcomes):-1,P=(N>=0?t.outcomes?.[N]:void 0)?.label??t.result??"",M=t.result!=null?y===N:true,T=useMemo(()=>M?r.size:0,[M,r.size]),A=useCallback(async()=>{if(!(!g||!h||!x)){p("pending"),f(null);try{let G=await x.getEip1193Provider();if(!G)throw new Error("EIP-1193 provider unavailable");await a({wallet_address:h,condition_id:g,neg_risk:b,signMessage:async W=>await G.request({method:"personal_sign",params:[W,h]}),signTypedData:async W=>await G.request({method:"eth_signTypedData_v4",params:[h,JSON.stringify(W)]})}),p("confirming");let U=Mr({messages:S});U.submitted(),await l({source:r.source,user:h,marketSlug:r.market?.slug??t.slug,eventSlug:r.event?.slug??e?.slug,expectation:"redeem",expectedPayout:T})==="confirmed"?(p("success"),U.completed()):(p("delayed"),U.delayed()),o?.();}catch(G){p("error"),f(G instanceof Error?G.message:i("predict.redeem.error"));}}},[g,h,b,x,a,S,l,r.source,r.market?.slug,r.event?.slug,t.slug,e?.slug,T,o,i]),X=useAuthCallback(A),L=c==="idle"&&!!g&&!!h&&!!x&&r.redeemable;return jsxs("div",{className:"flex flex-col gap-4 p-4",children:[jsx("div",{className:"text-base font-medium text-text-primary",children:e?.title??t.question}),jsxs("div",{className:"flex flex-col gap-2 rounded-xl bg-surface-strong/40 p-3",children:[jsx(Nn,{label:i("predict.positions.side"),value:k,valueClassName:M?"text-success":"text-danger"}),t.result!=null&&jsx(Nn,{label:i("predict.redeem.result"),value:P,valueClassName:"text-success"}),jsx(Nn,{label:i("predict.positions.size"),value:r.size.toFixed(2)}),jsx(Nn,{label:i("predict.redeem.expectedPayout"),value:`$${T.toFixed(2)}`,valueClassName:T>0?"text-success":"text-text-secondary"})]}),!M&&T===0&&jsx("p",{className:"text-sm text-text-muted",children:i("predict.redeem.noWinnings")}),c==="error"&&d&&jsx("p",{className:"text-sm text-danger",children:d}),c==="success"&&jsx("p",{className:"text-sm text-success",children:i("predict.redeem.success")}),c==="delayed"&&jsx("p",{className:"text-sm text-text-secondary",children:i("predict.trade.resultDelayed",{defaultValue:"Your trade was submitted successfully. Confirmation is taking a little longer."})}),jsxs("div",{className:"flex flex-col gap-2",children:[c!=="success"&&c!=="delayed"&&jsx(Button,{color:"success",className:"w-full h-12 rounded-xl text-sm font-semibold",isDisabled:!L,isLoading:c==="pending"||c==="confirming",onPress:X,spinner:jsx(Spinner,{size:"sm",color:"current"}),children:i("predict.redeem.confirm")}),n&&c!=="success"&&c!=="delayed"&&jsx("button",{type:"button",onClick:n,className:"w-full h-12 rounded-xl text-sm font-medium text-text-secondary hover:text-text-primary hover:bg-surface-strong/50 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"||c==="delayed")&&n&&jsx(Button,{className:"w-full h-12 rounded-xl text-sm font-medium",onPress:n,children:i("common.ok")})]})]})}function Nn({label:e,value:t,valueClassName:r="text-text-primary"}){return jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm text-text-secondary",children:e}),jsx("span",{className:`text-sm font-medium ${r}`,children:t})]})}function tl(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 ol="predict-redeem";function Gi({id:e=ol}){return jsx(AsyncModal,{id:e,children:t=>jsx(Lm,{...t})})}function Lm({params:e,isOpen:t,onOpenChange:r}){let{t:o}=useTranslation(),{isMobile:n}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:n?"lg":"md",backdrop:"opaque",hideCloseButton:true,classNames:{base:THEMED_MODAL_BASE_CLASS,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-text-primary",children:o("predict.redeem.title")}),jsx("p",{className:"text-sm text-text-secondary mt-1",children:o("predict.redeem.description")})]}),jsx(ji,{event:e.event,market:e.market,position:e.position,onSuccess:()=>{setTimeout(()=>r(false),1500);},onCancel:()=>r(false)})]})})}):null}function Qi(e){return e?.trim().toLowerCase()??""}function qi(e,t){let r=e.provider_meta?.[t];return typeof r=="string"?r:""}function al(e,t){return !!(e&&t&&e.trim().toLowerCase().includes(t))}function lf(e,t){let r=Qi(e.side);if(r==="yes"||r==="no")return r;if(r==="over"||r==="odd")return "yes";if(r==="under"||r==="even")return "no";let o=[t.outcomes?.[0]?.label,qi(t,"polymarket.groupItemTitle"),qi(t,"polymarket.groupItemTitleTrans"),qi(t,"polymarket.group_item_title_trans")],n=[t.outcomes?.[1]?.label];return o.some(i=>al(i,r))?"yes":n.some(i=>al(i,r))?"no":null}function Xi({market:e,initialOutcome:t="yes",initialPositionSide:r,slippageBps:o=100,onSuccess:n}){let{t:i,i18n:s}=useTranslation(),a=useRef(n);a.current=n;let{status:l}=useAuth(),m=useWallets(),u=usePredictClient(),c=useContext(PolymarketContext),p=useQueryClient(),{start:d}=useTradeResultConfirmation(),f=e.source,g=f==="polymarket",b=m.find(R=>R.chainNamespace===ChainNamespace.SOLANA&&R.isConnected),h=m.find(R=>R.chainNamespace===ChainNamespace.EVM&&R.isConnected&&"switchChain"in R),S=l==="authenticated",x=b?.address,y=h?.address,[v,k]=useState(t),[N,w]=useState("market"),[P,M]=useState(NaN),[T,A]=useState(NaN),[X,L]=useState(false),[G,U]=useState(false),[oe,W]=useState(null),[te,ne]=useState(null),[se,he]=useState(false),[Pe,pt]=useState(false),[Ve,Be]=useState("1h"),[E,st]=useState(30),[He,ve]=useState("minutes"),at=useMemo(()=>Gr(i),[s,i]),we=true,Ue=useCallback(async(R,Re)=>{let Le=Mr({messages:at});Le.submitted(),await d({source:f,user:f==="kalshi"?x:y,kalshiUser:we?x:void 0,polymarketUser:y,marketSlug:e.slug,eventSlug:e.event_slug,expectation:R,getOrdersHeaders:Re})==="confirmed"?Le.completed():Le.delayed();},[d,we,y,e.event_slug,e.slug,f,at,x]),qe=useMemo(()=>{if(f!=="polymarket")return;let R=e.provider_meta?.["polymarket.clobTokenIds"];return R?(typeof R=="string"?JSON.parse(R):R)[v==="yes"?0:1]:void 0},[f,e.provider_meta,v]),{data:C,isLoading:O}=useTickSize(qe),z=normalizePolymarketTickSize(C?.minimum_tick_size),{data:Z,isLoading:me}=useFeeRate(qe),Ne=String(Z?.base_fee??0),{data:lt}=useRebateConfig(),ct=lt?.builder_enabled&<.builder_code?lt.builder_code:void 0,kt=false,Qe=null,Yt=false,We,et,xe;try{let R=cr();we=R.enableKalshi,kt=R.kalshiKycVerified,Qe=R.kalshiKycUrl,Yt=R.polymarketSetupVerified,We=R.polymarketSafeAddress,et=R.polymarketWalletKind,xe=R.polymarketWalletAddress;}catch{}let mt=f==="kalshi"&&!kt,St=f==="polymarket"&&!Yt,Me=useCallback(async()=>{if(!h||!c)return null;let R=await h.getEip1193Provider();if(!R)return null;let Re=et==="deposit"&&!!xe,Le=!Re&&!!We,ze={address:h.address,signatureType:Re?3:Le?2:0,signTypedData:async(vt,Zt,Wt,Ke)=>{let ar=[];"name"in vt&&ar.push({name:"name",type:"string"}),"version"in vt&&ar.push({name:"version",type:"string"}),"chainId"in vt&&ar.push({name:"chainId",type:"uint256"}),"verifyingContract"in vt&&ar.push({name:"verifyingContract",type:"address"}),"salt"in vt&&ar.push({name:"salt",type:"bytes32"});let on={EIP712Domain:ar,...Zt};return await R.request({method:"eth_signTypedData_v4",params:[h.address,JSON.stringify({domain:vt,types:on,primaryType:Wt,message:Ke})]})}};return c.credentials??await c.authenticate(ze)},[We,et,xe,h,c]),{data:tt}=useRealtimeOrderbook({slug:e.slug,source:f,outcome:v},{enabled:e.status==="open"}),Ce=useMemo(()=>{let R=pickBestBid(tt,v);if(R!=null&&R>0)return R;let Re=v==="yes"?0:1,Le=e.outcomes[Re];return Le?.best_bid??Le?.price??.5},[tt,e.outcomes,v]),Lt=f==="kalshi"?x??"":y??"",{data:I,isLoading:_e}=usePositionsMulti({kalshi_user:f==="kalshi"?Lt:void 0,polymarket_user:f==="polymarket"?Lt:void 0},{enabled:!!Lt,refetchInterval:3e4}),Xe=Qi(r),fo=r?.trim(),B=useMemo(()=>I?I.positions.find(R=>R.market?.slug!==e.slug?false:Xe?Qi(R.side)===Xe:lf(R,e)===v)??null:null,[I,e,v,Xe]),Ie=fo||B?.side||v,Pt=useCallback(async()=>{let R=await Me();return R?await buildPolymarketL2Headers(R.address,{apiKey:R.apiKey,secret:R.secret,passphrase:R.passphrase,method:"GET",requestPath:"/data/orders",body:""}):{}},[Me]),{data:Ft,isLoading:go}=useAvailableShares({source:f,user:Lt,market:e.slug,side:Ie},f==="polymarket"?{getHeaders:Pt}:void 0,{enabled:!!Lt&&!!e.slug,refetchOnMount:"always"}),ni=e.provider_meta?.["dflow.yesMint"]??"",ii=e.provider_meta?.["dflow.noMint"]??"",qt=SOLANA_TOKENS.stablecoins.USDC.address,Ir=e.provider_meta?.["dflow.collateralMint"]||"",si=v==="yes"?ni:ii,ft=useMemo(()=>f==="polymarket"?getPolymarketSharesPrecision(z):Ft?.precision??0,[f,z,Ft?.precision]),Ot=Ft?.active_order_shares??0,Dr=f==="polymarket"&&!!B?.size&&(Ft?.total_shares??0)<=0&&(Ft?.available_shares??0)<=0,ho=Dr?B?.size??0:0,Ar=Dr?ho:Ft?.total_shares??0,sr=Dr?Math.max(0,ho-Ot):Ft?.available_shares??0,ai=go||_e,en=B?.market?.provider_meta,Fr=en?.["dflow.outcomeMint"]||si,Qt=en?.["dflow.collateralMint"]||Ir,vr=Fr,xr=Qt||qt,br=useMemo(()=>isNaN(P)||P<=0?"0":String(Math.round(P*1e6)),[P]),vo=f==="kalshi"&&!!vr&&!!xr&&!!x&&br!=="0",{refetch:xo}=useDFlowQuote({inputMint:vr,outputMint:xr,amount:br,userPublicKey:x??"",slippageBps:100},{enabled:vo}),Br=useMemo(()=>isNaN(P)||P<=0?0:P,[P]),_t=useMemo(()=>walkOrderbook({orderbook:tt,outcome:v,side:"sell",sharesNeeded:Br,slippageBps:o}),[tt,v,Br,o]),D=useMemo(()=>_t.status==="ok"&&_t.worstPrice!=null&&_t.worstPrice>0?_t.worstPrice:Ce,[_t,Ce]),De=useMemo(()=>N==="limit"&&g&&!isNaN(T)?T:D,[N,g,T,D]),Te=useMemo(()=>isNaN(P)||P<=0?0:P*De,[P,De]),It=useMemo(()=>f!=="polymarket"?0:Mi({grossReturn:Te,pricePerShare:De,feeRateBps:Number(Ne)}),[f,Te,De,Ne]),bo=useMemo(()=>Math.max(0,Te-It),[Te,It]),Xt=useCallback(R=>{k(R),A(NaN),M(NaN),U(false);},[]);useEffect(()=>{Xt(t);},[t,Xt]);let Jt=useCallback(R=>{w(R);},[]);useEffect(()=>{N==="limit"&&A(Math.round(Ce*1e4)/1e4);},[N,v,Ce]);let gt=useCallback(R=>{if(U(false),isNaN(R)){M(NaN);return}M(be(Math.max(0,R),ft));},[ft]),li=useCallback(()=>{U(true),M(be(sr,ft));},[sr,ft]),tn=useCallback(R=>{if(isNaN(R)){A(NaN);return}A(Math.round(R*1e4)/1e4);},[]),Ut=useCallback(()=>{M(NaN),A(NaN),w("market"),U(false),pt(false),Be("1h"),st(30),ve("minutes");},[]),Hr=useMemo(()=>{let R=[];return isNaN(P)||P<=0?R.push(i("predict.trade.minQuantity",{amount:ko})):P<ko&&R.push(i("predict.trade.minQuantity",{amount:ko})),e.status!=="open"&&R.push(i("predict.trade.marketNotActive")),!isNaN(P)&&P>0&&!G&&P>sr&&R.push(i("predict.trade.insufficientSharesDetail",{total:be(Ar,ft).toFixed(ft),active:be(Ot,ft).toFixed(ft),available:be(sr,ft).toFixed(ft)})),N==="limit"&&g&&(isNaN(T)||T<.01||T>.99)&&R.push(i("predict.trade.limitPriceRange")),N==="limit"&&g&&Pe&&Ve==="custom"&&(isNaN(E)||E<=0)&&R.push(i("predict.trade.expiration.invalidDate")),f==="polymarket"&&N==="market"&&!isNaN(P)&&P>0&&(_t.status==="insufficient_liquidity"?R.push(i("predict.trade.insufficientLiquidity",{available:be(_t.totalAvailable,2)})):_t.status==="exceeds_slippage"&&R.push(i("predict.trade.priceImpactTooHigh",{impact:(_t.priceImpactBps/100).toFixed(2),slippage:(o/100).toFixed(2)}))),{isValid:R.length===0,errors:R}},[P,e.status,sr,Ar,Ot,G,N,g,T,Pe,Ve,E,ft,f,_t,o,i]),{mutateAsync:Ur}=useDFlowSubmit(),{data:yr}=useOrder({id:oe??"",source:f},{enabled:!!oe}),rn=useCallback(async()=>{if(!te||!x||!b)return;let{cashAmount:R,collateral:Re}=te;ne(null);try{let ze=(await u.createDFlowQuote({inputMint:Re,outputMint:qt,amount:R,userPublicKey:x,slippageBps:100}))?.transaction;if(!ze)return;let vt=Uint8Array.from(atob(ze),Wt=>Wt.charCodeAt(0)),Zt=await b.signTransaction(vt);await Ur({signedTransaction:btoa(String.fromCharCode(...Zt)),orderContext:{user_public_key:x,input_mint:Re,output_mint:qt,amount:R,price:"1",side:"SELL",outcome:"",market_slug:"",slippage_bps:100}});}catch{}},[te,x,b,u,Ur,qt]),kr=useCallback(()=>{p.invalidateQueries({queryKey:["predict","available-shares"]});},[p]);useEffect(()=>{if(!yr||!oe)return;let{status:R}=yr;R==="closed"?(W(null),te?rn().finally(()=>{L(false),Ue("sell-market"),kr(),Ut(),a.current?.();}):(L(false),Ue("sell-market"),kr(),Ut(),a.current?.())):(R==="failed"||R==="expired")&&(L(false),W(null),ne(null),toast.error(i("predict.trade.submitError")));},[yr,oe,te,rn,Ue,kr,Ut,i]);let Wr=useCallback(async()=>{if(!x||!b)return;if(!vr||!xr){toast.error("Missing token mint addresses"),L(false);return}if(!kt){he(true),L(false);return}let Le=(await xo()).data,ze=Le?.transaction;if(!ze){toast.error(i("predict.trade.submitError")),L(false);return}if(Qt&&Qt!==qt){let Ke=String(Le?.outAmount??"");Ke&&Ke!=="0"&&ne({cashAmount:Ke,collateral:Qt});}let vt=Uint8Array.from(atob(ze),Ke=>Ke.charCodeAt(0)),Zt=await b.signTransaction(vt),Wt=await Ur({signedTransaction:btoa(String.fromCharCode(...Zt)),orderContext:{user_public_key:x,input_mint:vr,output_mint:xr,amount:br,price:String(Ce),side:"SELL",outcome:v==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});W(Wt.signature);},[x,b,xo,Ur,vr,xr,br,Ce,v,e.slug,Qt,qt,i,kt]),zr=useCallback(async()=>{if(!h||!c)return;let R=h.chain,Re=R!==Chain.POLYGON;Re&&await h.switchChain(Chain.POLYGON);try{let Le=await h.getEip1193Provider();if(!Le){toast.error(i("predict.trade.submitError")),L(!1);return}let ze=et==="deposit"&&!!xe,vt=!ze&&!!We,Zt=ze?xe:We,Wt={address:h.address,signatureType:ze?3:vt?2:0,signTypedData:async(zt,sn,ui,pi)=>{let Kr=[];"name"in zt&&Kr.push({name:"name",type:"string"}),"version"in zt&&Kr.push({name:"version",type:"string"}),"chainId"in zt&&Kr.push({name:"chainId",type:"uint256"}),"verifyingContract"in zt&&Kr.push({name:"verifyingContract",type:"address"}),"salt"in zt&&Kr.push({name:"salt",type:"bytes32"});let bd={EIP712Domain:Kr,...sn};return await Le.request({method:"eth_signTypedData_v4",params:[h.address,JSON.stringify({domain:zt,types:bd,primaryType:ui,message:pi})]})}},Ke=await Me();if(!Ke){toast.error(i("predict.trade.submitError")),L(!1);return}let ar=v==="yes"?0:1,on="",nn=e.provider_meta?.["polymarket.clobTokenIds"];nn&&(on=(typeof nn=="string"?JSON.parse(nn):nn)[ar]??"");let ta=e.provider_meta?.["polymarket.negRisk"]??!1,vd=N==="limit"&&!isNaN(T)?T:D,xd=No(vd,z),ci={tokenId:on,price:xd,size:P,side:"SELL",orderType:N==="limit"?Pe?"GTD":"GTC":"FOK",tickSize:z,negRisk:ta,...Zt&&{funderAddress:Zt},...ct&&{builderCode:ct},...N==="limit"&&Pe&&{expiration:Po(Ve,E,He)}},di;if(ze)di=await buildSignedV2OrderPayload({signer:Wt,depositWalletAddress:Zt,input:ci,owner:Ke.apiKey});else {let zt=buildCtfExchangeDomain(ta),sn=buildOrderMessage({...ci,signerAddress:Wt.address,signatureType:Wt.signatureType,feeRateBps:Ne}),ui=await Wt.signTypedData(zt,CTF_ORDER_TYPES,"Order",sn),pi=buildSignedOrder(sn,ui,ci.orderType);di=buildClobPayload(pi,Ke.apiKey);}await u.executePolymarketOrder({payload:di,l2_api_key:Ke.apiKey,l2_secret:Ke.secret,l2_passphrase:Ke.passphrase,signer_address:Ke.address,owner:Ke.apiKey}),kr(),Ue(N==="limit"?"sell-limit":"sell-market",async()=>await buildPolymarketL2Headers(Ke.address,{apiKey:Ke.apiKey,secret:Ke.secret,passphrase:Ke.passphrase,method:"GET",requestPath:"/data/orders"})),Ut(),L(!1),a.current?.();}finally{Re&&R&&h.switchChain(R).catch(()=>{});}},[h,c,Me,v,e,N,Ue,T,D,P,u,kr,Pe,Ve,E,He,Ut,i,z,Ne,We,et,xe,ct]),Dt=useCallback(async()=>{if(!(!Hr.isValid||!S)){L(true),W(null),he(false);try{f==="kalshi"?await Wr():await zr();}catch(R){let Re=R instanceof Error?R.message:"",Le=f==="polymarket"&&Re?Mo(Re,i,"sell"):Re||void 0;toast.error(Le||i("predict.trade.submitError")),L(false);}}},[Hr.isValid,S,f,Wr,zr,i]);return {outcome:v,orderType:N,quantity:P,limitPrice:T,shares:Br,effectivePrice:De,grossReturn:Te,estimatedFee:It,estimatedReturn:bo,pricePerShare:Ce,isMarketDataLoading:f==="polymarket"&&(me||O),isSubmitting:X,authStatus:l,validation:Hr,supportsLimitOrder:g,kycRequired:se,needsKyc:mt,needsSetup:St,kycUrl:Qe,totalShares:Ar,activeOrderShares:Ot,availableShares:sr,isAvailableLoading:ai,isSellAll:G,precision:ft,expirationEnabled:Pe,expirationPreset:Ve,customDuration:E,customDurationUnit:He,setOutcome:Xt,setOrderType:Jt,setQuantity:gt,setLimitPrice:tn,setSellAll:li,setExpirationEnabled:pt,setExpirationPreset:Be,setCustomDuration:st,setCustomDurationUnit:ve,submit:Dt}}var xf=["5m","1h","12h","24h","eod","custom"],bf={"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"},yf=["minutes","hours","days"],kf={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},Sf={maximumFractionDigits:0},_o="-";function es({event:e,market:t,variant:r="bordered",outcome:o,orderType:n,quantity:i,limitPrice:s,effectivePrice:a,grossReturn:l,estimatedFee:m,estimatedReturn:u,isMarketDataLoading:c,isSubmitting:p,authStatus:d,isValid:f,validationErrors:g,supportsLimitOrder:b,kycRequired:h,needsKyc:S,needsSetup:x,onSetupRequired:y,kycUrl:v,totalShares:k,activeOrderShares:N,availableShares:w,isAvailableLoading:P,precision:M,expirationEnabled:T,expirationPreset:A,customDuration:X,customDurationUnit:L,oddsFormatter:G,outcomeLabels:U,onOutcomeChange:oe,onOrderTypeChange:W,onQuantityChange:te,onLimitPriceChange:ne,onSellAll:se,onExpirationEnabledChange:he,onExpirationPresetChange:Pe,onCustomDurationChange:pt,onCustomDurationUnitChange:Ve,onSubmit:Be}){let{t:E}=useTranslation(),[st,He]=useState(false),[ve,at]=useState(true),we=useDisclosure(),[Ue,qe]=useState(""),C=useRef(false);useEffect(()=>{C.current||qe(isNaN(i)?"":String(i));},[i]);let[O,z]=useState(""),Z=useRef(false);useEffect(()=>{Z.current||(isNaN(s)?z(""):z(String(parseFloat((s*100).toFixed(2)))));},[s]);let me=useCallback(I=>{if(I!==""&&!/^\d*\.?\d{0,2}$/.test(I))return;if(z(I),I===""||I==="."){ne(NaN);return}let Xe=parseFloat(I);isNaN(Xe)||ne(Xe/100);},[ne]),Ne=useCallback(I=>{let _e=new RegExp(`^\\d*\\.?\\d{0,${M}}$`);if(I!==""&&!_e.test(I))return;if(qe(I),He(false),I===""||I==="."){te(NaN);return}let Xe=parseFloat(I);isNaN(Xe)||te(Xe);},[te,M]);useEffect(()=>{h&&!we.isOpen&&we.onOpen();},[h,we]);let lt=useMemo(()=>{let I=o==="yes"?t.yesBid:t.noBid;return I!=null?parseFloat((Number(I)*100).toFixed(2)):null},[o,t]),ct=o==="yes"?t.yesBid:t.noBid,kt=ct!=null&&G?G(Number(ct)):lt!=null?`${lt} \xA2`:null,Qe=Number.isFinite(a)?parseFloat((a*100).toFixed(2)):null,Yt=Number.isFinite(a)&&G?G(a):Qe!=null?`${Qe} \xA2`:null,We=!isNaN(i)&&i>0,et=We&&i>0?u/i:0,xe=et>0&&G?G(et):et>0?`${parseFloat((et*100).toFixed(2))} \xA2`:_o,mt=d==="authenticated",St=d==="authenticating"||d==="deauthenticating",Me=mt&&(S||x),tt=useCallback(I=>U?.[I]??E(I==="yes"?"predict.trade.yes":"predict.trade.no"),[U,E]),Ce=useMemo(()=>{if(St)return E("predict.trade.checkingLogin");if(!mt)return E("predict.trade.loginToTrade");if(S)return E("predict.trade.kycRequired");if(x)return E("predict.trade.setupRequired");if(P)return E("predict.trade.loadingBalance");if(c)return E("predict.trade.loadingMarketData");if(p)return E("predict.trade.submitting");if(h)return E("predict.trade.kycRequired");if(!We)return E("predict.trade.enterAmount");let I=tt(o);return `${E("predict.trade.sell")} ${I}`},[St,mt,S,x,P,c,p,h,We,o,tt,E]),Lt=()=>{if(!mt){He(false),Be();return}if(S){we.onOpen();return}if(x&&y){He(false),y();return}if(h){we.onOpen();return}if(!f){He(true);return}He(false),Be();};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 var(--color-border-subtle)",background:"hsl(var(--heroui-content2) / 0.4)",transition:"border-color 0.2s"}:void 0,onMouseEnter:I=>{r==="bordered"&&(I.currentTarget.style.borderColor="hsl(var(--heroui-content4) / 0.8)");},onMouseLeave:I=>{r==="bordered"&&(I.currentTarget.style.borderColor="hsl(var(--heroui-content3) / 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-text-muted leading-tight line-clamp-1",children:e.title}),jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsx("span",{className:"text-foreground",children:t.yesSubTitle}),jsx("span",{className:"text-foreground",children:" \xB7 "}),jsxs("span",{className:"text-negative",children:[E("predict.trade.sell")," ",tt(o)]})]})]})]}),jsxs("div",{className:"flex items-center justify-between",children:[b?jsxs(Tabs,{variant:"underlined",selectedKey:n,onSelectionChange:I=>W(I),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsx(Tab,{title:E("predict.trade.market")},"market"),jsx(Tab,{title:E("predict.trade.limit")},"limit")]}):jsx("span",{className:"text-sm font-medium text-foreground",children:E("predict.trade.market")}),n==="limit"&&b?jsx(StyledInput,{"aria-label":E("predict.trade.limitPrice"),placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:O,onChange:I=>me(I.target.value),onFocus:()=>{Z.current=true;},onBlur:()=>{Z.current=false,isNaN(s)?z(""):z(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"}}):kt!=null&&jsx("span",{className:"text-xl font-bold tabular-nums",children:kt})]}),jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(I=>{let _e=I==="yes"?t.yesBid:t.noBid;return jsx("div",{className:"flex flex-1 flex-col gap-y-1",children:jsxs("button",{type:"button",onClick:()=>oe(I),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${o===I?"border-negative bg-negative/10 text-negative":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsx("span",{children:tt(I)}),_e!=null&&jsx("span",{className:"ml-1 opacity-70",children:G?G(Number(_e)):`${parseFloat((Number(_e)*100).toFixed(2))}\xA2`})]})},I)})}),jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxs("div",{className:"flex items-center justify-between text-xs text-text-muted",children:[jsx("span",{className:"text-sm font-medium text-foreground",children:E("predict.trade.sellContracts")}),jsxs("div",{className:"flex items-center gap-x-2",children:[[25,50].map(I=>{let _e=Math.pow(10,M);return jsxs("button",{type:"button",onClick:()=>{te(Math.floor(w*I/100*_e)/_e);},className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-text-muted hover:text-foreground font-medium",children:[I,"%"]},I)}),jsx("button",{type:"button",onClick:se,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-text-muted hover:text-foreground font-medium",children:E("common.all")})]})]}),jsx(StyledInput,{"aria-label":E("predict.trade.sellQuantity"),fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:Ue,onChange:I=>Ne(I.target.value),onFocus:()=>{C.current=true;},onBlur:()=>{C.current=false,qe(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"}}),st&&g.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:g.map(I=>jsx("span",{className:"text-xs text-danger",children:I},I))})]}),jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-text-muted",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:E("predict.trade.totalShares")}),jsx("span",{className:"tabular-nums text-foreground",children:P?"\u2013":`${be(k,M).toFixed(M)}${E("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:E("predict.trade.activeOrders")}),jsx("span",{className:"tabular-nums text-warning",children:P?"\u2013":N>0?`-${be(N,M).toFixed(M)}${E("predict.trade.sharesUnit")}`:`0${E("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:E("predict.trade.availableShares")}),jsx("span",{className:"tabular-nums text-success font-medium",children:P?"\u2013":`${be(w,M).toFixed(M)}${E("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:E("predict.trade.estReturn")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${u.toFixed(2)}`:"\u2013"})]})]}),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:()=>at(I=>!I),className:"flex items-center gap-x-1 text-text-muted hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{children:E("predict.trade.odds")}),jsx(ChevronDownIcon,{className:cn$1("h-3.5 w-3.5 transition-transform",ve&&"rotate-180")})]}),jsx("span",{className:"text-foreground font-medium tabular-nums",children:G&&Number.isFinite(a)?Yt:Qe!=null?E("predict.trade.chance",{percent:Qe}):_o})]}),ve&&jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-text-muted",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:E("predict.trade.numContracts")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?Nr(i):_o})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:E("predict.trade.totalSize")}),jsx("span",{className:"tabular-nums text-foreground",children:We?`$${l.toFixed(2)}`:_o})]}),(m??0)>0&&jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:E("predict.trade.estFee")}),jsx("span",{className:"tabular-nums text-foreground",children:`$${(m??0).toFixed(2)}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:E("predict.trade.estReturnAfterFees")}),jsx("span",{className:"tabular-nums text-foreground",children:We?`$${u.toFixed(2)}`:_o})]}),(m??0)>0&&jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:E("predict.trade.effectiveOdds")}),jsx("span",{className:"tabular-nums text-foreground",children:xe})]})]})]}),n==="limit"&&b&&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:E("predict.trade.setExpiration")}),jsx(StyledSwitch,{size:"sm",color:"primary",isSelected:T,onValueChange:he,"aria-label":E("predict.trade.setExpiration")})]}),T&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":E("predict.trade.setExpiration"),selectedKeys:[A],onSelectionChange:I=>{let _e=Array.from(I)[0];_e&&Pe(_e);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:xf.map(I=>jsx(SelectItem,{children:E(bf[I])},I))}),A==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":E("predict.trade.durationAmount"),size:"sm",radius:"lg",value:isNaN(X)?void 0:X,onValueChange:pt,minValue:1,step:1,formatOptions:Sf,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":E("predict.trade.durationUnit"),selectedKeys:[L],onSelectionChange:I=>{let _e=Array.from(I)[0];_e&&Ve(_e);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:yf.map(I=>jsx(SelectItem,{children:E(kf[I])},I))})]})]})]}),jsx(Button,{color:"secondary",fullWidth:true,radius:"lg",size:"lg",isDisabled:St||mt&&!Me&&(P||c||!We||p),isLoading:St||mt&&!Me&&(p||P||c),spinner:jsx(Spinner,{size:"sm",color:"current"}),onPress:Lt,children:Ce})]}),jsx(Eo,{isOpen:we.isOpen,onClose:we.onClose,kycUrl:v})]})}function Io({event:e,market:t,variant:r,initialOutcome:o,initialPositionSide:n,chain:i,slippageBps:s,onOutcomeChange:a,onSetupRequired:l,onSuccess:m,oddsFormatter:u,outcomeLabels:c}){let{outcome:p,orderType:d,quantity:f,limitPrice:g,effectivePrice:b,grossReturn:h,estimatedFee:S,estimatedReturn:x,pricePerShare:y,isMarketDataLoading:v,isSubmitting:k,authStatus:N,validation:w,supportsLimitOrder:P,kycRequired:M,needsKyc:T,needsSetup:A,kycUrl:X,totalShares:L,activeOrderShares:G,availableShares:U,isAvailableLoading:oe,precision:W,expirationEnabled:te,expirationPreset:ne,customDuration:se,customDurationUnit:he,setOutcome:Pe,setOrderType:pt,setQuantity:Ve,setLimitPrice:Be,setSellAll:E,setExpirationEnabled:st,setExpirationPreset:He,setCustomDuration:ve,setCustomDurationUnit:at,submit:we}=Xi({market:t,initialOutcome:o,initialPositionSide:n,slippageBps:s,onSuccess:m}),Ue=useAuthCallback(we),qe=useCallback(z=>{Pe(z),a?.(z);},[Pe,a]),C=useMemo(()=>e?un(e):void 0,[e]),O=useMemo(()=>pn(t,{yesBid:p==="yes"?y:void 0,noBid:p==="no"?y:void 0}),[t,p,y]);return jsx(es,{event:C,market:O,variant:r,outcome:p,orderType:d,quantity:f,limitPrice:g,effectivePrice:b,grossReturn:h,estimatedFee:S,estimatedReturn:x,isMarketDataLoading:v,isSubmitting:k,authStatus:N,isValid:w.isValid,validationErrors:w.errors,supportsLimitOrder:P,kycRequired:M,needsKyc:T,needsSetup:A,onSetupRequired:l,kycUrl:X,totalShares:L,activeOrderShares:G,availableShares:U,isAvailableLoading:oe,precision:W,expirationEnabled:te,expirationPreset:ne,customDuration:se,customDurationUnit:he,oddsFormatter:u,outcomeLabels:c,onOutcomeChange:qe,onOrderTypeChange:pt,onQuantityChange:Ve,onLimitPriceChange:Be,onSellAll:E,onExpirationEnabledChange:st,onExpirationPresetChange:He,onCustomDurationChange:ve,onCustomDurationUnitChange:at,onSubmit:Ue})}var En="predict-sell";function ts({id:e=En}){return jsx(AsyncModal,{id:e,children:t=>jsx(Of,{...t})})}function Of({params:e,isOpen:t,onOpenChange:r}){let{t:o}=useTranslation(),{isMobile:n}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:n?"lg":"md",backdrop:"opaque",hideCloseButton:true,classNames:{base:THEMED_MODAL_BASE_CLASS,body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{className:n?"":"p-2",children:[jsx(Io,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,initialPositionSide:e.initialPositionSide,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-text-secondary hover:text-text-primary hover:bg-surface-strong/50 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 ns=40,Tn=36,Fo=480,is=Fo-Tn;function ss({event:e,walletAddress:t,onCancelOrder:r}){let{t:o}=useTranslation(),[n,i]=useState("positions"),s=useMemo(()=>e.markets?.map(c=>c.slug)??[],[e.markets]),{data:a}=usePositionsMulti({kalshi_user:e.source==="kalshi"?t:void 0,polymarket_user:e.source==="polymarket"?t:void 0}),l=useMemo(()=>!a?.positions||!t?0:s.length===0?a.positions.length:a.positions.filter(c=>c.market&&s.includes(c.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(c=>jsx("button",{type:"button",onClick:()=>i(c.key),className:cn$1("px-3 py-2 text-sm font-medium transition-colors cursor-pointer",n===c.key?"text-foreground border-b-2 border-primary":"text-text-muted hover:text-foreground"),children:c.label},c.key))}),t?jsxs("div",{style:{height:Fo},children:[n==="positions"&&jsx(Hf,{source:e.source,walletAddress:t,marketSlugs:s}),n==="orders"&&jsx(Wf,{source:e.source,walletAddress:t,marketSlugs:s,onCancelOrder:r}),n==="trades"&&jsx($f,{source:e.source,walletAddress:t})]}):jsx("div",{className:"flex items-center justify-center text-sm text-text-muted",style:{height:Fo},children:o("predict.trade.connectWallet")})]})}function Hf({source:e,walletAddress:t,marketSlugs:r}){let{t:o}=useTranslation(),{data:n,isLoading:i}=usePositionsMulti({kalshi_user:e==="kalshi"?t:void 0,polymarket_user:e==="polymarket"?t:void 0}),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(ls,{}):s.length===0?jsx(as,{message:o("predict.positions.empty")}):jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex items-center text-text-muted text-xs lg:text-sm font-normal shrink-0",style:{height:Tn},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2 whitespace-nowrap",children: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:is},rowComponent:Uf,rowCount:s.length,rowHeight:ns,rowProps:{positions:s,closeLabel:o("predict.positions.close")}})]})}function Uf({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,m=i>0?"text-success":i<0?"text-danger":"text-foreground",u=i>0?"+":"",c=n.market?.outcomes?.[0]?.label??n.market?.question??"\u2014",p=n.side,d=n.size,f=n.size*l,g=n.market?.end_at?Gf(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:c}),jsx("span",{className:cn$1("text-[10px] font-medium",p.toLowerCase()==="yes"?"text-primary":"text-secondary"),children:p})]})}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:n.size}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",f.toFixed(2)]}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:Cn(a)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:Cn(l)}),jsxs("div",{className:cn$1("flex-[1.5] pr-2 text-right font-mono whitespace-nowrap",m),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-text-muted whitespace-nowrap",children:g}),jsx("div",{className:"w-16 shrink-0 text-right",children:jsx("button",{type:"button",className:"text-xs text-text-muted hover:text-foreground cursor-pointer transition-colors rounded px-2 py-0.5 border border-border hover:border-foreground/40",children:o})})]})}function Wf({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}),m=useCancelOrder(),u=useMemo(()=>{let h=i?.pages?.flatMap(y=>y.items)??[],S=new Set(["live","open","submitted","pending"]),x=h.filter(y=>S.has(y.status));return r.length>0&&(x=x.filter(y=>y.market_id&&r.includes(y.market_id))),x},[i?.pages,r]),c=useCallback(h=>{o?o(h.id):m.mutate({source:h.source,id:h.id});},[o,m]),p=u.length,d=p+(l?1:0),f=useCallback(h=>h<p,[p]),g=useCallback(async()=>{await a();},[a]),b=useInfiniteLoader({isRowLoaded:f,loadMoreRows:g,rowCount:d,threshold:5});return s?jsx(ls,{}):u.length===0&&!l?jsx(as,{message:n("predict.openOrders.empty")}):jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex items-center text-text-muted text-xs lg:text-sm font-normal shrink-0",style:{height:Tn},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:is},onRowsRendered:b,rowComponent:zf,rowCount:d,rowHeight:ns,rowProps:{orders:u,itemCount:p,onCancel:c,isCancelling:m.isPending,cancelLabel:n("predict.openOrders.cancel")}})]})}function zf({index:e,style:t,orders:r,itemCount:o,onCancel:n,isCancelling:i,cancelLabel:s}){let{t:a}=useTranslation();if(e>=o)return jsx("div",{style:t,className:"flex justify-center items-center",children:jsx(Spinner,{size:"sm"})});let l=r[e];if(!l)return null;let m=l.side==="BUY";return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:jsx("span",{className:cn$1("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",m?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:l.side})}),jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:l.outcome??"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-text-muted capitalize",children:l.order_type?.toLowerCase()==="market"?a("predict.trade.market"):a("predict.trade.limit")}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:l.price?Cn(parseFloat(l.price)):"\u2014"}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:[l.size_matched??"0","/",l.original_size??"\u2014"]}),jsx("div",{className:"w-20 shrink-0 pr-2",children:jsx(Kf,{status:l.status})}),jsx("div",{className:"w-16 shrink-0 text-right",children:jsx("button",{type:"button",onClick:()=>n(l),disabled:i,className:"text-[10px] text-danger hover:text-danger/80 cursor-pointer disabled:opacity-50 transition-colors",children:i?jsx(Spinner,{size:"sm"}):s})})]})}function Kf({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-text-muted/10 text-text-muted",failed:"bg-danger/10 text-danger",expired:"bg-text-muted/10 text-text-muted"}[e]??"bg-text-muted/10 text-text-muted"),children:e})}function $f({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(d=>d.items)??[],[o?.pages]),l=a.length,m=l+(s?1:0),u=useCallback(d=>d<l,[l]),c=useCallback(async()=>{await i();},[i]),p=useInfiniteLoader({isRowLoaded:u,loadMoreRows:c,rowCount:m,threshold:5});return n?jsx(ls,{}):a.length===0&&!s?jsx(as,{message:r("predict.tradeHistory.empty")}):jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex items-center text-text-muted text-xs lg:text-sm font-normal shrink-0",style:{height:Tn},children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:r("predict.tradeHistory.side")}),jsx("div",{className:"flex-1 pr-2",children:r("predict.tradeHistory.outcome")}),jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.price")}),jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.qty")}),jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.total")}),jsx("div",{className:"flex-[1.5] pr-2 text-right",children:r("predict.tradeHistory.time")})]}),jsx(List,{style:{height:is},onRowsRendered:p,rowComponent:Vf,rowCount:m,rowHeight:ns,rowProps:{trades:a,itemCount:l}})]})}function Vf({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=jf(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:Cn(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-text-muted whitespace-nowrap",children:s})]})}function as({message:e}){return jsx("div",{className:"flex items-center justify-center text-sm text-text-muted",style:{height:Fo},children:e})}function ls(){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:Fo},children:Array.from({length:6}).map((e,t)=>jsx(Skeleton,{className:"h-8 w-full rounded-md"},t))})}function Cn(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(1)}\xA2`}function jf(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 Gf(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return "\u2014"}}var xl=`
|
|
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:xm.map((r,o)=>jsxs("div",{style:{padding:"14px 16px",background:e?`linear-gradient(to bottom, ${r.gradientFrom}, ${r.gradientTo})`:"hsl(var(--heroui-foreground) / 0.02)",borderRight:o%2===0?"1px solid var(--color-border-subtle)":"none",borderBottom:o<2?"1px solid var(--color-border-subtle)":"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:"hsl(var(--heroui-foreground) / 0.06)",animation:"evtStatCardEnter 0.6s ease-out both",animationDelay:`${o*80}ms`}})}),jsx("div",{className:"evt-stat-label",style:{fontWeight:500,color:e?"var(--color-text-muted)":"transparent",marginTop:2,display:"flex",alignItems:"center"},children:e?t(r.labelKey):jsx("div",{style:{height:10,width:64,borderRadius:4,background:"hsl(var(--heroui-foreground) / 0.04)",animation:"evtStatCardEnter 0.6s ease-out both",animationDelay:`${50+o*80}ms`}})})]},r.key))})]})]})}function Yi({event:e,market:t,position:r,onSuccess:o,onCancel:n}){let{t:i,i18n:s}=useTranslation(),{mutateAsync:a}=useRedeemPosition(),{start:l}=useTradeResultConfirmation(),{evmAddress:m}=cr(),u=useWallets(),[c,p]=useState("idle"),[d,f]=useState(null),g=t.provider_meta?.["polymarket.conditionId"],b=t.provider_meta?.["polymarket.negRisk"]??false,v=m??"",S=useMemo(()=>Yr(i),[s,i]),x=useMemo(()=>u.find(G=>G.chainNamespace===ChainNamespace.EVM&&G.isConnected),[u]),y=ol(r.side,t.outcomes),k=t.outcomes?.[y]?.label??r.side,N=t.result!=null?ol(t.result,t.outcomes):-1,P=(N>=0?t.outcomes?.[N]:void 0)?.label??t.result??"",M=t.result!=null?y===N:true,T=useMemo(()=>M?r.size:0,[M,r.size]),A=useCallback(async()=>{if(!(!g||!v||!x)){p("pending"),f(null);try{let G=await x.getEip1193Provider();if(!G)throw new Error("EIP-1193 provider unavailable");await a({wallet_address:v,condition_id:g,neg_risk:b,signMessage:async W=>await G.request({method:"personal_sign",params:[W,v]}),signTypedData:async W=>await G.request({method:"eth_signTypedData_v4",params:[v,JSON.stringify(W)]})}),p("confirming");let U=wr({messages:S});U.submitted(),await l({source:r.source,user:v,marketSlug:r.market?.slug??t.slug,eventSlug:r.event?.slug??e?.slug,expectation:"redeem",expectedPayout:T})==="confirmed"?(p("success"),U.completed()):(p("delayed"),U.delayed()),o?.();}catch(G){p("error"),f(G instanceof Error?G.message:i("predict.redeem.error"));}}},[g,v,b,x,a,S,l,r.source,r.market?.slug,r.event?.slug,t.slug,e?.slug,T,o,i]),X=useAuthCallback(A),L=c==="idle"&&!!g&&!!v&&!!x&&r.redeemable;return jsxs("div",{className:"flex flex-col gap-4 p-4",children:[jsx("div",{className:"text-base font-medium text-text-primary",children:e?.title??t.question}),jsxs("div",{className:"flex flex-col gap-2 rounded-xl bg-surface-strong/40 p-3",children:[jsx(Mn,{label:i("predict.positions.side"),value:k,valueClassName:M?"text-success":"text-danger"}),t.result!=null&&jsx(Mn,{label:i("predict.redeem.result"),value:P,valueClassName:"text-success"}),jsx(Mn,{label:i("predict.positions.size"),value:r.size.toFixed(2)}),jsx(Mn,{label:i("predict.redeem.expectedPayout"),value:`$${T.toFixed(2)}`,valueClassName:T>0?"text-success":"text-text-secondary"})]}),!M&&T===0&&jsx("p",{className:"text-sm text-text-muted",children:i("predict.redeem.noWinnings")}),c==="error"&&d&&jsx("p",{className:"text-sm text-danger",children:d}),c==="success"&&jsx("p",{className:"text-sm text-success",children:i("predict.redeem.success")}),c==="delayed"&&jsx("p",{className:"text-sm text-text-secondary",children:i("predict.trade.resultDelayed",{defaultValue:"Your trade was submitted successfully. Confirmation is taking a little longer."})}),jsxs("div",{className:"flex flex-col gap-2",children:[c!=="success"&&c!=="delayed"&&jsx(Button,{color:"success",className:"w-full h-12 rounded-xl text-sm font-semibold",isDisabled:!L,isLoading:c==="pending"||c==="confirming",onPress:X,spinner:jsx(Spinner,{size:"sm",color:"current"}),children:i("predict.redeem.confirm")}),n&&c!=="success"&&c!=="delayed"&&jsx("button",{type:"button",onClick:n,className:"w-full h-12 rounded-xl text-sm font-medium text-text-secondary hover:text-text-primary hover:bg-surface-strong/50 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"||c==="delayed")&&n&&jsx(Button,{className:"w-full h-12 rounded-xl text-sm font-medium",onPress:n,children:i("common.ok")})]})]})}function Mn({label:e,value:t,valueClassName:r="text-text-primary"}){return jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm text-text-secondary",children:e}),jsx("span",{className:`text-sm font-medium ${r}`,children:t})]})}function ol(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 il="predict-redeem";function qi({id:e=il}){return jsx(AsyncModal,{id:e,children:t=>jsx(Dm,{...t})})}function Dm({params:e,isOpen:t,onOpenChange:r}){let{t:o}=useTranslation(),{isMobile:n}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:n?"lg":"md",backdrop:"opaque",hideCloseButton:true,classNames:{base:THEMED_MODAL_BASE_CLASS,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-text-primary",children:o("predict.redeem.title")}),jsx("p",{className:"text-sm text-text-secondary mt-1",children:o("predict.redeem.description")})]}),jsx(Yi,{event:e.event,market:e.market,position:e.position,onSuccess:()=>{setTimeout(()=>r(false),1500);},onCancel:()=>r(false)})]})})}):null}function Ji(e){return e?.trim().toLowerCase()??""}function Xi(e,t){let r=e.provider_meta?.[t];return typeof r=="string"?r:""}function cl(e,t){return !!(e&&t&&e.trim().toLowerCase().includes(t))}function pf(e,t){let r=Ji(e.side);if(r==="yes"||r==="no")return r;if(r==="over"||r==="odd")return "yes";if(r==="under"||r==="even")return "no";let o=[t.outcomes?.[0]?.label,Xi(t,"polymarket.groupItemTitle"),Xi(t,"polymarket.groupItemTitleTrans"),Xi(t,"polymarket.group_item_title_trans")],n=[t.outcomes?.[1]?.label];return o.some(i=>cl(i,r))?"yes":n.some(i=>cl(i,r))?"no":null}function Zi({market:e,initialOutcome:t="yes",initialPositionSide:r,slippageBps:o=100,onSuccess:n}){let{t:i,i18n:s}=useTranslation(),a=useRef(n);a.current=n;let{status:l}=useAuth(),m=useWallets(),u=usePredictClient(),c=useContext(PolymarketContext),p=useQueryClient(),{start:d}=useTradeResultConfirmation(),f=e.source,g=f==="polymarket",b=m.find(R=>R.chainNamespace===ChainNamespace.SOLANA&&R.isConnected),v=m.find(R=>R.chainNamespace===ChainNamespace.EVM&&R.isConnected&&"switchChain"in R),S=l==="authenticated",x=b?.address,y=v?.address,[h,k]=useState(t),[N,w]=useState("market"),[P,M]=useState(NaN),[T,A]=useState(NaN),[X,L]=useState(false),[G,U]=useState(false),[oe,W]=useState(null),[te,ne]=useState(null),[se,ve]=useState(false),[Pe,pt]=useState(false),[Ve,Be]=useState("1h"),[E,st]=useState(30),[He,he]=useState("minutes"),at=useMemo(()=>Yr(i),[s,i]),we=true,Ue=useCallback(async(R,Re)=>{let Le=wr({messages:at});Le.submitted(),await d({source:f,user:f==="kalshi"?x:y,kalshiUser:we?x:void 0,polymarketUser:y,marketSlug:e.slug,eventSlug:e.event_slug,expectation:R,getOrdersHeaders:Re})==="confirmed"?Le.completed():Le.delayed();},[d,we,y,e.event_slug,e.slug,f,at,x]),qe=useMemo(()=>{if(f!=="polymarket")return;let R=e.provider_meta?.["polymarket.clobTokenIds"];return R?(typeof R=="string"?JSON.parse(R):R)[h==="yes"?0:1]:void 0},[f,e.provider_meta,h]),{data:C,isLoading:O}=useTickSize(qe),z=normalizePolymarketTickSize(C?.minimum_tick_size),{data:Z,isLoading:me}=useFeeRate(qe),Ne=String(Z?.base_fee??0),{data:lt}=useRebateConfig(),ct=lt?.builder_enabled&<.builder_code?lt.builder_code:void 0,kt=false,Qe=null,Yt=false,We,et,xe;try{let R=cr();we=R.enableKalshi,kt=R.kalshiKycVerified,Qe=R.kalshiKycUrl,Yt=R.polymarketSetupVerified,We=R.polymarketSafeAddress,et=R.polymarketWalletKind,xe=R.polymarketWalletAddress;}catch{}let mt=f==="kalshi"&&!kt,St=f==="polymarket"&&!Yt,Me=useCallback(async()=>{if(!v||!c)return null;let R=await v.getEip1193Provider();if(!R)return null;let Re=et==="deposit"&&!!xe,Le=!Re&&!!We,ze={address:v.address,signatureType:Re?3:Le?2:0,signTypedData:async(ht,Zt,Wt,Ke)=>{let ar=[];"name"in ht&&ar.push({name:"name",type:"string"}),"version"in ht&&ar.push({name:"version",type:"string"}),"chainId"in ht&&ar.push({name:"chainId",type:"uint256"}),"verifyingContract"in ht&&ar.push({name:"verifyingContract",type:"address"}),"salt"in ht&&ar.push({name:"salt",type:"bytes32"});let nn={EIP712Domain:ar,...Zt};return await R.request({method:"eth_signTypedData_v4",params:[v.address,JSON.stringify({domain:ht,types:nn,primaryType:Wt,message:Ke})]})}};return c.credentials??await c.authenticate(ze)},[We,et,xe,v,c]),{data:tt}=useRealtimeOrderbook({slug:e.slug,source:f,outcome:h},{enabled:e.status==="open"}),Ce=useMemo(()=>{let R=pickBestBid(tt,h);if(R!=null&&R>0)return R;let Re=h==="yes"?0:1,Le=e.outcomes[Re];return Le?.best_bid??Le?.price??.5},[tt,e.outcomes,h]),Lt=f==="kalshi"?x??"":y??"",{data:I,isLoading:_e}=usePositionsMulti({kalshi_user:f==="kalshi"?Lt:void 0,polymarket_user:f==="polymarket"?Lt:void 0},{enabled:!!Lt,refetchInterval:3e4}),Xe=Ji(r),go=r?.trim(),B=useMemo(()=>I?I.positions.find(R=>R.market?.slug!==e.slug?false:Xe?Ji(R.side)===Xe:pf(R,e)===h)??null:null,[I,e,h,Xe]),Ie=go||B?.side||h,Pt=useCallback(async()=>{let R=await Me();return R?await buildPolymarketL2Headers(R.address,{apiKey:R.apiKey,secret:R.secret,passphrase:R.passphrase,method:"GET",requestPath:"/data/orders",body:""}):{}},[Me]),{data:Ft,isLoading:vo}=useAvailableShares({source:f,user:Lt,market:e.slug,side:Ie},f==="polymarket"?{getHeaders:Pt}:void 0,{enabled:!!Lt&&!!e.slug,refetchOnMount:"always"}),ii=e.provider_meta?.["dflow.yesMint"]??"",si=e.provider_meta?.["dflow.noMint"]??"",qt=SOLANA_TOKENS.stablecoins.USDC.address,Dr=e.provider_meta?.["dflow.collateralMint"]||"",ai=h==="yes"?ii:si,ft=useMemo(()=>f==="polymarket"?getPolymarketSharesPrecision(z):Ft?.precision??0,[f,z,Ft?.precision]),Ot=Ft?.active_order_shares??0,Ar=f==="polymarket"&&!!B?.size&&(Ft?.total_shares??0)<=0&&(Ft?.available_shares??0)<=0,ho=Ar?B?.size??0:0,Fr=Ar?ho:Ft?.total_shares??0,sr=Ar?Math.max(0,ho-Ot):Ft?.available_shares??0,li=vo||_e,tn=B?.market?.provider_meta,Br=tn?.["dflow.outcomeMint"]||ai,Qt=tn?.["dflow.collateralMint"]||Dr,xr=Br,br=Qt||qt,yr=useMemo(()=>isNaN(P)||P<=0?"0":String(Math.round(P*1e6)),[P]),xo=f==="kalshi"&&!!xr&&!!br&&!!x&&yr!=="0",{refetch:bo}=useDFlowQuote({inputMint:xr,outputMint:br,amount:yr,userPublicKey:x??"",slippageBps:100},{enabled:xo}),Hr=useMemo(()=>isNaN(P)||P<=0?0:P,[P]),_t=useMemo(()=>walkOrderbook({orderbook:tt,outcome:h,side:"sell",sharesNeeded:Hr,slippageBps:o}),[tt,h,Hr,o]),D=useMemo(()=>_t.status==="ok"&&_t.worstPrice!=null&&_t.worstPrice>0?_t.worstPrice:Ce,[_t,Ce]),De=useMemo(()=>N==="limit"&&g&&!isNaN(T)?T:D,[N,g,T,D]),Te=useMemo(()=>isNaN(P)||P<=0?0:P*De,[P,De]),It=useMemo(()=>f!=="polymarket"?0:wi({grossReturn:Te,pricePerShare:De,feeRateBps:Number(Ne)}),[f,Te,De,Ne]),yo=useMemo(()=>Math.max(0,Te-It),[Te,It]),Xt=useCallback(R=>{k(R),A(NaN),M(NaN),U(false);},[]);useEffect(()=>{Xt(t);},[t,Xt]);let Jt=useCallback(R=>{w(R);},[]);useEffect(()=>{N==="limit"&&A(Math.round(Ce*1e4)/1e4);},[N,h,Ce]);let gt=useCallback(R=>{if(U(false),isNaN(R)){M(NaN);return}M(be(Math.max(0,R),ft));},[ft]),ci=useCallback(()=>{U(true),M(be(sr,ft));},[sr,ft]),rn=useCallback(R=>{if(isNaN(R)){A(NaN);return}A(Math.round(R*1e4)/1e4);},[]),Ut=useCallback(()=>{M(NaN),A(NaN),w("market"),U(false),pt(false),Be("1h"),st(30),he("minutes");},[]),Ur=useMemo(()=>{let R=[];return isNaN(P)||P<=0?R.push(i("predict.trade.minQuantity",{amount:So})):P<So&&R.push(i("predict.trade.minQuantity",{amount:So})),e.status!=="open"&&R.push(i("predict.trade.marketNotActive")),!isNaN(P)&&P>0&&!G&&P>sr&&R.push(i("predict.trade.insufficientSharesDetail",{total:be(Fr,ft).toFixed(ft),active:be(Ot,ft).toFixed(ft),available:be(sr,ft).toFixed(ft)})),N==="limit"&&g&&(isNaN(T)||T<.01||T>.99)&&R.push(i("predict.trade.limitPriceRange")),N==="limit"&&g&&Pe&&Ve==="custom"&&(isNaN(E)||E<=0)&&R.push(i("predict.trade.expiration.invalidDate")),f==="polymarket"&&N==="market"&&!isNaN(P)&&P>0&&(_t.status==="insufficient_liquidity"?R.push(i("predict.trade.insufficientLiquidity",{available:be(_t.totalAvailable,2)})):_t.status==="exceeds_slippage"&&R.push(i("predict.trade.priceImpactTooHigh",{impact:(_t.priceImpactBps/100).toFixed(2),slippage:(o/100).toFixed(2)}))),{isValid:R.length===0,errors:R}},[P,e.status,sr,Fr,Ot,G,N,g,T,Pe,Ve,E,ft,f,_t,o,i]),{mutateAsync:Wr}=useDFlowSubmit(),{data:kr}=useOrder({id:oe??"",source:f},{enabled:!!oe}),on=useCallback(async()=>{if(!te||!x||!b)return;let{cashAmount:R,collateral:Re}=te;ne(null);try{let ze=(await u.createDFlowQuote({inputMint:Re,outputMint:qt,amount:R,userPublicKey:x,slippageBps:100}))?.transaction;if(!ze)return;let ht=Uint8Array.from(atob(ze),Wt=>Wt.charCodeAt(0)),Zt=await b.signTransaction(ht);await Wr({signedTransaction:btoa(String.fromCharCode(...Zt)),orderContext:{user_public_key:x,input_mint:Re,output_mint:qt,amount:R,price:"1",side:"SELL",outcome:"",market_slug:"",slippage_bps:100}});}catch{}},[te,x,b,u,Wr,qt]),Sr=useCallback(()=>{p.invalidateQueries({queryKey:["predict","available-shares"]});},[p]);useEffect(()=>{if(!kr||!oe)return;let{status:R}=kr;R==="closed"?(W(null),te?on().finally(()=>{L(false),Ue("sell-market"),Sr(),Ut(),a.current?.();}):(L(false),Ue("sell-market"),Sr(),Ut(),a.current?.())):(R==="failed"||R==="expired")&&(L(false),W(null),ne(null),toast.error(i("predict.trade.submitError")));},[kr,oe,te,on,Ue,Sr,Ut,i]);let zr=useCallback(async()=>{if(!x||!b)return;if(!xr||!br){toast.error("Missing token mint addresses"),L(false);return}if(!kt){ve(true),L(false);return}let Le=(await bo()).data,ze=Le?.transaction;if(!ze){toast.error(i("predict.trade.submitError")),L(false);return}if(Qt&&Qt!==qt){let Ke=String(Le?.outAmount??"");Ke&&Ke!=="0"&&ne({cashAmount:Ke,collateral:Qt});}let ht=Uint8Array.from(atob(ze),Ke=>Ke.charCodeAt(0)),Zt=await b.signTransaction(ht),Wt=await Wr({signedTransaction:btoa(String.fromCharCode(...Zt)),orderContext:{user_public_key:x,input_mint:xr,output_mint:br,amount:yr,price:String(Ce),side:"SELL",outcome:h==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});W(Wt.signature);},[x,b,bo,Wr,xr,br,yr,Ce,h,e.slug,Qt,qt,i,kt]),Kr=useCallback(async()=>{if(!v||!c)return;let R=v.chain,Re=R!==Chain.POLYGON;Re&&await v.switchChain(Chain.POLYGON);try{let Le=await v.getEip1193Provider();if(!Le){toast.error(i("predict.trade.submitError")),L(!1);return}let ze=et==="deposit"&&!!xe,ht=!ze&&!!We,Zt=ze?xe:We,Wt={address:v.address,signatureType:ze?3:ht?2:0,signTypedData:async(zt,an,pi,mi)=>{let $r=[];"name"in zt&&$r.push({name:"name",type:"string"}),"version"in zt&&$r.push({name:"version",type:"string"}),"chainId"in zt&&$r.push({name:"chainId",type:"uint256"}),"verifyingContract"in zt&&$r.push({name:"verifyingContract",type:"address"}),"salt"in zt&&$r.push({name:"salt",type:"bytes32"});let kd={EIP712Domain:$r,...an};return await Le.request({method:"eth_signTypedData_v4",params:[v.address,JSON.stringify({domain:zt,types:kd,primaryType:pi,message:mi})]})}},Ke=await Me();if(!Ke){toast.error(i("predict.trade.submitError")),L(!1);return}let ar=h==="yes"?0:1,nn="",sn=e.provider_meta?.["polymarket.clobTokenIds"];sn&&(nn=(typeof sn=="string"?JSON.parse(sn):sn)[ar]??"");let oa=e.provider_meta?.["polymarket.negRisk"]??!1,bd=N==="limit"&&!isNaN(T)?T:D,yd=Mo(bd,z),di={tokenId:nn,price:yd,size:P,side:"SELL",orderType:N==="limit"?Pe?"GTD":"GTC":"FOK",tickSize:z,negRisk:oa,...Zt&&{funderAddress:Zt},...ct&&{builderCode:ct},...N==="limit"&&Pe&&{expiration:No(Ve,E,He)}},ui;if(ze)ui=await buildSignedV2OrderPayload({signer:Wt,depositWalletAddress:Zt,input:di,owner:Ke.apiKey});else {let zt=buildCtfExchangeDomain(oa),an=buildOrderMessage({...di,signerAddress:Wt.address,signatureType:Wt.signatureType,feeRateBps:Ne}),pi=await Wt.signTypedData(zt,CTF_ORDER_TYPES,"Order",an),mi=buildSignedOrder(an,pi,di.orderType);ui=buildClobPayload(mi,Ke.apiKey);}await u.executePolymarketOrder({payload:ui,l2_api_key:Ke.apiKey,l2_secret:Ke.secret,l2_passphrase:Ke.passphrase,signer_address:Ke.address,owner:Ke.apiKey}),Sr(),Ue(N==="limit"?"sell-limit":"sell-market",async()=>await buildPolymarketL2Headers(Ke.address,{apiKey:Ke.apiKey,secret:Ke.secret,passphrase:Ke.passphrase,method:"GET",requestPath:"/data/orders"})),Ut(),L(!1),a.current?.();}finally{Re&&R&&v.switchChain(R).catch(()=>{});}},[v,c,Me,h,e,N,Ue,T,D,P,u,Sr,Pe,Ve,E,He,Ut,i,z,Ne,We,et,xe,ct]),Dt=useCallback(async()=>{if(!(!Ur.isValid||!S)){L(true),W(null),ve(false);try{f==="kalshi"?await zr():await Kr();}catch(R){let Re=R instanceof Error?R.message:"",Le=f==="polymarket"&&Re?wo(Re,i,"sell"):Re||void 0;toast.error(Le||i("predict.trade.submitError")),L(false);}}},[Ur.isValid,S,f,zr,Kr,i]);return {outcome:h,orderType:N,quantity:P,limitPrice:T,shares:Hr,effectivePrice:De,grossReturn:Te,estimatedFee:It,estimatedReturn:yo,pricePerShare:Ce,isMarketDataLoading:f==="polymarket"&&(me||O),isSubmitting:X,authStatus:l,validation:Ur,supportsLimitOrder:g,kycRequired:se,needsKyc:mt,needsSetup:St,kycUrl:Qe,totalShares:Fr,activeOrderShares:Ot,availableShares:sr,isAvailableLoading:li,isSellAll:G,precision:ft,expirationEnabled:Pe,expirationPreset:Ve,customDuration:E,customDurationUnit:He,setOutcome:Xt,setOrderType:Jt,setQuantity:gt,setLimitPrice:rn,setSellAll:ci,setExpirationEnabled:pt,setExpirationPreset:Be,setCustomDuration:st,setCustomDurationUnit:he,submit:Dt}}var Sf=["5m","1h","12h","24h","eod","custom"],Pf={"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"},Nf=["minutes","hours","days"],Mf={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},wf={maximumFractionDigits:0},Io="-";function rs({event:e,market:t,variant:r="bordered",outcome:o,orderType:n,quantity:i,limitPrice:s,effectivePrice:a,grossReturn:l,estimatedFee:m,estimatedReturn:u,isMarketDataLoading:c,isSubmitting:p,authStatus:d,isValid:f,validationErrors:g,supportsLimitOrder:b,kycRequired:v,needsKyc:S,needsSetup:x,onSetupRequired:y,kycUrl:h,totalShares:k,activeOrderShares:N,availableShares:w,isAvailableLoading:P,precision:M,expirationEnabled:T,expirationPreset:A,customDuration:X,customDurationUnit:L,oddsFormatter:G,outcomeLabels:U,onOutcomeChange:oe,onOrderTypeChange:W,onQuantityChange:te,onLimitPriceChange:ne,onSellAll:se,onExpirationEnabledChange:ve,onExpirationPresetChange:Pe,onCustomDurationChange:pt,onCustomDurationUnitChange:Ve,onSubmit:Be}){let{t:E}=useTranslation(),[st,He]=useState(false),[he,at]=useState(true),we=useDisclosure(),[Ue,qe]=useState(""),C=useRef(false);useEffect(()=>{C.current||qe(isNaN(i)?"":String(i));},[i]);let[O,z]=useState(""),Z=useRef(false);useEffect(()=>{Z.current||(isNaN(s)?z(""):z(String(parseFloat((s*100).toFixed(2)))));},[s]);let me=useCallback(I=>{if(I!==""&&!/^\d*\.?\d{0,2}$/.test(I))return;if(z(I),I===""||I==="."){ne(NaN);return}let Xe=parseFloat(I);isNaN(Xe)||ne(Xe/100);},[ne]),Ne=useCallback(I=>{let _e=new RegExp(`^\\d*\\.?\\d{0,${M}}$`);if(I!==""&&!_e.test(I))return;if(qe(I),He(false),I===""||I==="."){te(NaN);return}let Xe=parseFloat(I);isNaN(Xe)||te(Xe);},[te,M]);useEffect(()=>{v&&!we.isOpen&&we.onOpen();},[v,we]);let lt=useMemo(()=>{let I=o==="yes"?t.yesBid:t.noBid;return I!=null?parseFloat((Number(I)*100).toFixed(2)):null},[o,t]),ct=o==="yes"?t.yesBid:t.noBid,kt=ct!=null&&G?G(Number(ct)):lt!=null?`${lt} \xA2`:null,Qe=Number.isFinite(a)?parseFloat((a*100).toFixed(2)):null,Yt=Number.isFinite(a)&&G?G(a):Qe!=null?`${Qe} \xA2`:null,We=!isNaN(i)&&i>0,et=We&&i>0?u/i:0,xe=et>0&&G?G(et):et>0?`${parseFloat((et*100).toFixed(2))} \xA2`:Io,mt=d==="authenticated",St=d==="authenticating"||d==="deauthenticating",Me=mt&&(S||x),tt=useCallback(I=>U?.[I]??E(I==="yes"?"predict.trade.yes":"predict.trade.no"),[U,E]),Ce=useMemo(()=>{if(St)return E("predict.trade.checkingLogin");if(!mt)return E("predict.trade.loginToTrade");if(S)return E("predict.trade.kycRequired");if(x)return E("predict.trade.setupRequired");if(P)return E("predict.trade.loadingBalance");if(c)return E("predict.trade.loadingMarketData");if(p)return E("predict.trade.submitting");if(v)return E("predict.trade.kycRequired");if(!We)return E("predict.trade.enterAmount");let I=tt(o);return `${E("predict.trade.sell")} ${I}`},[St,mt,S,x,P,c,p,v,We,o,tt,E]),Lt=()=>{if(!mt){He(false),Be();return}if(S){we.onOpen();return}if(x&&y){He(false),y();return}if(v){we.onOpen();return}if(!f){He(true);return}He(false),Be();};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 var(--color-border-subtle)",background:"hsl(var(--heroui-content2) / 0.4)",transition:"border-color 0.2s"}:void 0,onMouseEnter:I=>{r==="bordered"&&(I.currentTarget.style.borderColor="hsl(var(--heroui-content4) / 0.8)");},onMouseLeave:I=>{r==="bordered"&&(I.currentTarget.style.borderColor="hsl(var(--heroui-content3) / 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-text-muted leading-tight line-clamp-1",children:e.title}),jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsx("span",{className:"text-foreground",children:t.yesSubTitle}),jsx("span",{className:"text-foreground",children:" \xB7 "}),jsxs("span",{className:"text-negative",children:[E("predict.trade.sell")," ",tt(o)]})]})]})]}),jsxs("div",{className:"flex items-center justify-between",children:[b?jsxs(Tabs,{variant:"underlined",selectedKey:n,onSelectionChange:I=>W(I),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsx(Tab,{title:E("predict.trade.market")},"market"),jsx(Tab,{title:E("predict.trade.limit")},"limit")]}):jsx("span",{className:"text-sm font-medium text-foreground",children:E("predict.trade.market")}),n==="limit"&&b?jsx(StyledInput,{"aria-label":E("predict.trade.limitPrice"),placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:O,onChange:I=>me(I.target.value),onFocus:()=>{Z.current=true;},onBlur:()=>{Z.current=false,isNaN(s)?z(""):z(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"}}):kt!=null&&jsx("span",{className:"text-xl font-bold tabular-nums",children:kt})]}),jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(I=>{let _e=I==="yes"?t.yesBid:t.noBid;return jsx("div",{className:"flex flex-1 flex-col gap-y-1",children:jsxs("button",{type:"button",onClick:()=>oe(I),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${o===I?"border-negative bg-negative/10 text-negative":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsx("span",{children:tt(I)}),_e!=null&&jsx("span",{className:"ml-1 opacity-70",children:G?G(Number(_e)):`${parseFloat((Number(_e)*100).toFixed(2))}\xA2`})]})},I)})}),jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxs("div",{className:"flex items-center justify-between text-xs text-text-muted",children:[jsx("span",{className:"text-sm font-medium text-foreground",children:E("predict.trade.sellContracts")}),jsxs("div",{className:"flex items-center gap-x-2",children:[[25,50].map(I=>{let _e=Math.pow(10,M);return jsxs("button",{type:"button",onClick:()=>{te(Math.floor(w*I/100*_e)/_e);},className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-text-muted hover:text-foreground font-medium",children:[I,"%"]},I)}),jsx("button",{type:"button",onClick:se,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-text-muted hover:text-foreground font-medium",children:E("common.all")})]})]}),jsx(StyledInput,{"aria-label":E("predict.trade.sellQuantity"),fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:Ue,onChange:I=>Ne(I.target.value),onFocus:()=>{C.current=true;},onBlur:()=>{C.current=false,qe(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"}}),st&&g.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:g.map(I=>jsx("span",{className:"text-xs text-danger",children:I},I))})]}),jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-text-muted",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:E("predict.trade.totalShares")}),jsx("span",{className:"tabular-nums text-foreground",children:P?"\u2013":`${be(k,M).toFixed(M)}${E("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:E("predict.trade.activeOrders")}),jsx("span",{className:"tabular-nums text-warning",children:P?"\u2013":N>0?`-${be(N,M).toFixed(M)}${E("predict.trade.sharesUnit")}`:`0${E("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:E("predict.trade.availableShares")}),jsx("span",{className:"tabular-nums text-success font-medium",children:P?"\u2013":`${be(w,M).toFixed(M)}${E("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:E("predict.trade.estReturn")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${u.toFixed(2)}`:"\u2013"})]})]}),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:()=>at(I=>!I),className:"flex items-center gap-x-1 text-text-muted hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{children:E("predict.trade.odds")}),jsx(ChevronDownIcon,{className:cn("h-3.5 w-3.5 transition-transform",he&&"rotate-180")})]}),jsx("span",{className:"text-foreground font-medium tabular-nums",children:G&&Number.isFinite(a)?Yt:Qe!=null?E("predict.trade.chance",{percent:Qe}):Io})]}),he&&jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-text-muted",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:E("predict.trade.numContracts")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?Mr(i):Io})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:E("predict.trade.totalSize")}),jsx("span",{className:"tabular-nums text-foreground",children:We?`$${l.toFixed(2)}`:Io})]}),(m??0)>0&&jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:E("predict.trade.estFee")}),jsx("span",{className:"tabular-nums text-foreground",children:`$${(m??0).toFixed(2)}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:E("predict.trade.estReturnAfterFees")}),jsx("span",{className:"tabular-nums text-foreground",children:We?`$${u.toFixed(2)}`:Io})]}),(m??0)>0&&jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:E("predict.trade.effectiveOdds")}),jsx("span",{className:"tabular-nums text-foreground",children:xe})]})]})]}),n==="limit"&&b&&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:E("predict.trade.setExpiration")}),jsx(StyledSwitch,{size:"sm",color:"primary",isSelected:T,onValueChange:ve,"aria-label":E("predict.trade.setExpiration")})]}),T&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":E("predict.trade.setExpiration"),selectedKeys:[A],onSelectionChange:I=>{let _e=Array.from(I)[0];_e&&Pe(_e);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Sf.map(I=>jsx(SelectItem,{children:E(Pf[I])},I))}),A==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":E("predict.trade.durationAmount"),size:"sm",radius:"lg",value:isNaN(X)?void 0:X,onValueChange:pt,minValue:1,step:1,formatOptions:wf,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":E("predict.trade.durationUnit"),selectedKeys:[L],onSelectionChange:I=>{let _e=Array.from(I)[0];_e&&Ve(_e);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Nf.map(I=>jsx(SelectItem,{children:E(Mf[I])},I))})]})]})]}),jsx(Button,{color:"secondary",fullWidth:true,radius:"lg",size:"lg",isDisabled:St||mt&&!Me&&(P||c||!We||p),isLoading:St||mt&&!Me&&(p||P||c),spinner:jsx(Spinner,{size:"sm",color:"current"}),onPress:Lt,children:Ce})]}),jsx(Co,{isOpen:we.isOpen,onClose:we.onClose,kycUrl:h})]})}function Do({event:e,market:t,variant:r,initialOutcome:o,initialPositionSide:n,chain:i,slippageBps:s,onOutcomeChange:a,onSetupRequired:l,onSuccess:m,oddsFormatter:u,outcomeLabels:c}){let{outcome:p,orderType:d,quantity:f,limitPrice:g,effectivePrice:b,grossReturn:v,estimatedFee:S,estimatedReturn:x,pricePerShare:y,isMarketDataLoading:h,isSubmitting:k,authStatus:N,validation:w,supportsLimitOrder:P,kycRequired:M,needsKyc:T,needsSetup:A,kycUrl:X,totalShares:L,activeOrderShares:G,availableShares:U,isAvailableLoading:oe,precision:W,expirationEnabled:te,expirationPreset:ne,customDuration:se,customDurationUnit:ve,setOutcome:Pe,setOrderType:pt,setQuantity:Ve,setLimitPrice:Be,setSellAll:E,setExpirationEnabled:st,setExpirationPreset:He,setCustomDuration:he,setCustomDurationUnit:at,submit:we}=Zi({market:t,initialOutcome:o,initialPositionSide:n,slippageBps:s,onSuccess:m}),Ue=useAuthCallback(we),qe=useCallback(z=>{Pe(z),a?.(z);},[Pe,a]),C=useMemo(()=>e?pn(e):void 0,[e]),O=useMemo(()=>mn(t,{yesBid:p==="yes"?y:void 0,noBid:p==="no"?y:void 0}),[t,p,y]);return jsx(rs,{event:C,market:O,variant:r,outcome:p,orderType:d,quantity:f,limitPrice:g,effectivePrice:b,grossReturn:v,estimatedFee:S,estimatedReturn:x,isMarketDataLoading:h,isSubmitting:k,authStatus:N,isValid:w.isValid,validationErrors:w.errors,supportsLimitOrder:P,kycRequired:M,needsKyc:T,needsSetup:A,onSetupRequired:l,kycUrl:X,totalShares:L,activeOrderShares:G,availableShares:U,isAvailableLoading:oe,precision:W,expirationEnabled:te,expirationPreset:ne,customDuration:se,customDurationUnit:ve,oddsFormatter:u,outcomeLabels:c,onOutcomeChange:qe,onOrderTypeChange:pt,onQuantityChange:Ve,onLimitPriceChange:Be,onSellAll:E,onExpirationEnabledChange:st,onExpirationPresetChange:He,onCustomDurationChange:he,onCustomDurationUnitChange:at,onSubmit:Ue})}var Cn="predict-sell";function os({id:e=Cn}){return jsx(AsyncModal,{id:e,children:t=>jsx(Af,{...t})})}function Af({params:e,isOpen:t,onOpenChange:r}){let{t:o}=useTranslation(),{isMobile:n}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:n?"lg":"md",backdrop:"opaque",hideCloseButton:true,classNames:{base:THEMED_MODAL_BASE_CLASS,body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{className:n?"":"p-2",children:[jsx(Do,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,initialPositionSide:e.initialPositionSide,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-text-secondary hover:text-text-primary hover:bg-surface-strong/50 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 ss=40,Rn=36,Bo=480,as=Bo-Rn;function ls({event:e,walletAddress:t,onCancelOrder:r}){let{t:o}=useTranslation(),[n,i]=useState("positions"),s=useMemo(()=>e.markets?.map(c=>c.slug)??[],[e.markets]),{data:a}=usePositionsMulti({kalshi_user:e.source==="kalshi"?t:void 0,polymarket_user:e.source==="polymarket"?t:void 0}),l=useMemo(()=>!a?.positions||!t?0:s.length===0?a.positions.length:a.positions.filter(c=>c.market&&s.includes(c.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(c=>jsx("button",{type:"button",onClick:()=>i(c.key),className:cn("px-3 py-2 text-sm font-medium transition-colors cursor-pointer",n===c.key?"text-foreground border-b-2 border-primary":"text-text-muted hover:text-foreground"),children:c.label},c.key))}),t?jsxs("div",{style:{height:Bo},children:[n==="positions"&&jsx(Kf,{source:e.source,walletAddress:t,marketSlugs:s}),n==="orders"&&jsx(Vf,{source:e.source,walletAddress:t,marketSlugs:s,onCancelOrder:r}),n==="trades"&&jsx(Yf,{source:e.source,walletAddress:t})]}):jsx("div",{className:"flex items-center justify-center text-sm text-text-muted",style:{height:Bo},children:o("predict.trade.connectWallet")})]})}function Kf({source:e,walletAddress:t,marketSlugs:r}){let{t:o}=useTranslation(),{data:n,isLoading:i}=usePositionsMulti({kalshi_user:e==="kalshi"?t:void 0,polymarket_user:e==="polymarket"?t:void 0}),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(ds,{}):s.length===0?jsx(cs,{message:o("predict.positions.empty")}):jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex items-center text-text-muted text-xs lg:text-sm font-normal shrink-0",style:{height:Rn},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:as},rowComponent:$f,rowCount:s.length,rowHeight:ss,rowProps:{positions:s,closeLabel:o("predict.positions.close")}})]})}function $f({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,m=i>0?"text-success":i<0?"text-danger":"text-foreground",u=i>0?"+":"",c=n.market?.outcomes?.[0]?.label??n.market?.question??"\u2014",p=n.side,d=n.size,f=n.size*l,g=n.market?.end_at?Xf(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:c}),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: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:Tn(a)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:Tn(l)}),jsxs("div",{className:cn("flex-[1.5] pr-2 text-right font-mono whitespace-nowrap",m),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-text-muted whitespace-nowrap",children:g}),jsx("div",{className:"w-16 shrink-0 text-right",children:jsx("button",{type:"button",className:"text-xs text-text-muted hover:text-foreground cursor-pointer transition-colors rounded px-2 py-0.5 border border-border hover:border-foreground/40",children:o})})]})}function Vf({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}),m=useCancelOrder(),u=useMemo(()=>{let v=i?.pages?.flatMap(y=>y.items)??[],S=new Set(["live","open","submitted","pending"]),x=v.filter(y=>S.has(y.status));return r.length>0&&(x=x.filter(y=>y.market_id&&r.includes(y.market_id))),x},[i?.pages,r]),c=useCallback(v=>{o?o(v.id):m.mutate({source:v.source,id:v.id});},[o,m]),p=u.length,d=p+(l?1:0),f=useCallback(v=>v<p,[p]),g=useCallback(async()=>{await a();},[a]),b=useInfiniteLoader({isRowLoaded:f,loadMoreRows:g,rowCount:d,threshold:5});return s?jsx(ds,{}):u.length===0&&!l?jsx(cs,{message:n("predict.openOrders.empty")}):jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex items-center text-text-muted text-xs lg:text-sm font-normal shrink-0",style:{height:Rn},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:as},onRowsRendered:b,rowComponent:jf,rowCount:d,rowHeight:ss,rowProps:{orders:u,itemCount:p,onCancel:c,isCancelling:m.isPending,cancelLabel:n("predict.openOrders.cancel")}})]})}function jf({index:e,style:t,orders:r,itemCount:o,onCancel:n,isCancelling:i,cancelLabel:s}){let{t:a}=useTranslation();if(e>=o)return jsx("div",{style:t,className:"flex justify-center items-center",children:jsx(Spinner,{size:"sm"})});let l=r[e];if(!l)return null;let m=l.side==="BUY";return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:jsx("span",{className:cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",m?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:l.side})}),jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:l.outcome??"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-text-muted capitalize",children:l.order_type?.toLowerCase()==="market"?a("predict.trade.market"):a("predict.trade.limit")}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:l.price?Tn(parseFloat(l.price)):"\u2014"}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:[l.size_matched??"0","/",l.original_size??"\u2014"]}),jsx("div",{className:"w-20 shrink-0 pr-2",children:jsx(Gf,{status:l.status})}),jsx("div",{className:"w-16 shrink-0 text-right",children:jsx("button",{type:"button",onClick:()=>n(l),disabled:i,className:"text-[10px] text-danger hover:text-danger/80 cursor-pointer disabled:opacity-50 transition-colors",children:i?jsx(Spinner,{size:"sm"}):s})})]})}function Gf({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-text-muted/10 text-text-muted",failed:"bg-danger/10 text-danger",expired:"bg-text-muted/10 text-text-muted"}[e]??"bg-text-muted/10 text-text-muted"),children:e})}function Yf({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(d=>d.items)??[],[o?.pages]),l=a.length,m=l+(s?1:0),u=useCallback(d=>d<l,[l]),c=useCallback(async()=>{await i();},[i]),p=useInfiniteLoader({isRowLoaded:u,loadMoreRows:c,rowCount:m,threshold:5});return n?jsx(ds,{}):a.length===0&&!s?jsx(cs,{message:r("predict.tradeHistory.empty")}):jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex items-center text-text-muted text-xs lg:text-sm font-normal shrink-0",style:{height:Rn},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:as},onRowsRendered:p,rowComponent:qf,rowCount:m,rowHeight:ss,rowProps:{trades:a,itemCount:l}})]})}function qf({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=Qf(n.timestamp),a=n.price??0,l=n.usd_size??0;return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:jsx("span",{className:cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",i?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:n.side})}),jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:n.outcome??"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Tn(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-text-muted whitespace-nowrap",children:s})]})}function cs({message:e}){return jsx("div",{className:"flex items-center justify-center text-sm text-text-muted",style:{height:Bo},children:e})}function ds(){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:Bo},children:Array.from({length:6}).map((e,t)=>jsx(Skeleton,{className:"h-8 w-full rounded-md"},t))})}function Tn(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(1)}\xA2`}function Qf(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 Xf(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return "\u2014"}}var yl=`
|
|
75
75
|
@keyframes detailShimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}
|
|
76
|
-
`,bl={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 ye(e){return {...bl,animationDelay:`${e}ms`}}function ro({marketCount:e=4,showBack:t}){return jsxs(Fragment,{children:[jsx("style",{children:xl}),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:{...bl,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:{...ye(0),height:14,width:48}}),jsx("div",{style:{...ye(30),height:14,width:40}}),jsx("div",{style:{...ye(60),height:14,width:40}})]}),jsx("div",{style:{...ye(80),height:20,width:"80%",maxWidth:384,borderRadius:4}})]})]}),jsx("div",{style:{...ye(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:{...ye(120),height:16,width:96}}),jsx("div",{style:{...ye(140),height:16,width:80}})]}),jsx("div",{style:{...ye(160),height:300,width:"100%",borderRadius:12}}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[jsx("div",{style:{...ye(180),height:16,width:80}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsx("div",{style:{...ye(200),height:28,width:200,borderRadius:8}}),jsx("div",{style:{...ye(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:{...ye(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 var(--color-border-subtle)"},children:[jsx("div",{style:{...ye(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:{...ye(280+o*40),height:14,width:o%2===0?192:160}}),jsx("div",{style:{...ye(300+o*40),height:10,width:64}})]}),jsx("div",{style:{...ye(320+o*40),height:16,width:40}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsx("div",{style:{...ye(340+o*40),height:32,width:80,borderRadius:8}}),jsx("div",{style:{...ye(360+o*40),height:32,width:80,borderRadius:8}})]})]},o))]}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[jsx("div",{style:{...ye(400),height:16,width:64}}),jsx("div",{style:{...ye(420),height:14,width:"100%"}}),jsx("div",{style:{...ye(440),height:14,width:"80%"}}),jsx("div",{style:{...ye(460),height:14,width:"60%"}})]})]})]})}function cs(){return jsxs(Fragment,{children:[jsx("style",{children:xl}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,borderRadius:14,border:"1px solid var(--color-border-subtle)",background:"hsl(var(--heroui-content2) / 0.4)",padding:16},children:[jsx("div",{style:{...ye(0),height:40,width:"100%",borderRadius:8}}),jsx("div",{style:{...ye(60),height:96,width:"100%",borderRadius:8}}),jsx("div",{style:{...ye(120),height:40,width:"100%",borderRadius:8}})]})]})}function kl(e,t,r){return e===t||!r?null:{marketSlug:t,outcomeKey:r}}function Sl(e,t){return {marketSlug:e,outcomeKey:t}}function Pl(e){return e.slice(0,2).map((t,r)=>({catalogOutcome:t,tradeOutcome:r===0?"yes":"no"}))}function Ze(e,t){return `${e}:${t}`}function Nl({marketDataEnabled:e,marketSlug:t,outcomeKey:r,books:o}){return e?{legacyEnabled:false,orderbook:o?.get(Ze(t,r))??null}:{legacyEnabled:true,orderbook:void 0}}var Cl="var(--color-bullish)",Tl="var(--color-bearish)";function oo(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 Qf(e,t){return e<=0||t<=0?0:Math.pow(e/t,.3)}function Xf(e,t){let r=new Float64Array(101),o=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&&(o[f]+=d.quantity);}let n=0,i=0,s=new Float64Array(101),a=new Float64Array(101);for(let d=100;d>=0;d--)n+=r[d],i+=r[d]*d/100,s[d]=n,a[d]=i;let l=0,m=0,u=new Float64Array(101),c=new Float64Array(101);for(let d=0;d<=100;d++)l+=o[d],m+=o[d]*d/100,u[d]=l,c[d]=m;let p=Math.max(s[0]??0,u[100]??0);return Array.from({length:101},(d,f)=>{let g=s[f]>0,b=u[f]>0,h=s[f]||u[f],S=r[f]>0||o[f]>0;return {priceCents:f,displayHeight:Qf(h,p),opacity:h>0?S?1:.5:0,isBid:g,isAsk:b,bidCumTotal:s[f],askCumTotal:u[f],bidCumCost:a[f],askCumCost:c[f]}})}function Jf({info:e}){let{t}=useTranslation(),r=e.isBid?Cl:Tl,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:"var(--color-text-primary)",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:oo(Math.round(e.cumTotal))})}),jsxs("div",{style:{color:r},children:["$",oo(Math.round(e.cumCost))]})]})}var Zf=memo(function({slot:t,onEnter:r,onLeave:o}){let n=useRef(null),i=t.isBid||t.isAsk,s=t.isBid?Cl:t.isAsk?Tl: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}})})}),eg=[0,10,20,30,40,50,60,70,80,90,100];function tg(){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:eg.map(e=>jsx("span",{className:"absolute text-text-muted font-normal",style:{fontSize:10,left:`${e}%`,transform:e===0?"translateX(0px)":e===100?"translateX(-100%)":"translateX(-50%)"},children:e},e))})}function us({bids:e,asks:t}){let{t:r}=useTranslation(),o=useMemo(()=>Xf(e,t),[e,t]),n=useMemo(()=>{let c=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((c+p)/2*100)},[e,t]),i=useMemo(()=>o.some(c=>c.isBid||c.isAsk),[o]),[s,a]=useState(null),l=useRef(null),m=useCallback((c,p)=>{l.current&&(l.current.style.filter=""),p?(p.style.filter="brightness(1.5)",l.current=p):l.current=null,c.isBid||c.isAsk?a({priceCents:c.priceCents,isBid:c.isBid,cumTotal:c.isBid?c.bidCumTotal:c.askCumTotal,cumCost:c.isBid?c.bidCumCost:c.askCumCost,leftPct:c.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(Jf,{info:s}),o.map(c=>jsx(Zf,{slot:c,onEnter:m,onLeave:u},c.priceCents))]}),jsx(tg,{})]}):jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--color-text-muted)",fontSize:13},children:r("predict.orderBook.noData")})}function Dl(e){let t=e*100,r=Math.round(t*10)/10;return Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`}function Ll(){let{t:e}=useTranslation();return jsx("div",{className:"absolute inset-0 flex items-center justify-center text-text-muted text-xs",children:jsx("span",{children:e("predict.orderBook.loading")})})}function fs({market:e,outcome:t="yes",initialViewMode:r="depth",className:o,oddsFormatter:n,enabled:i=true,orderbook:s}){let{t:a}=useTranslation(),[l,m]=useState(r),u=n??Dl,c=e.source,{data:p,isLoading:d,isFetching:f,refetch:g}=useRealtimeOrderbook({slug:e.slug,source:c,outcome:t},{enabled:i}),b=s!==void 0,h=b?s:p,S=!b&&d,x=!b&&f,y=useMemo(()=>(h?.bids??[]).map(P=>({price:P.price,quantity:P.size})),[h?.bids]),v=useMemo(()=>(h?.asks??[]).map(P=>({price:P.price,quantity:P.size})),[h?.asks]),k=useMemo(()=>y.length>0?Math.max(...y.map(P=>P.price)):null,[y]),N=useMemo(()=>v.length>0?Math.min(...v.map(P=>P.price)):null,[v]),w=useMemo(()=>{if(k==null||N==null)return null;let P=(N-k)*100;return Math.round(P*10)/10},[k,N]);return jsxs("div",{className:cn$1("flex flex-col",o??"h-[262px]"),children:[jsxs("div",{className:"flex h-9 items-center border-b border-border px-1 text-xs",children:[jsx("span",{className:"flex-1 text-left text-text-muted",children:w!=null?`${a("predict.orderBook.spread")}: ${Number.isInteger(w)?`${w}\xA2`:`${w.toFixed(1)}\xA2`}`:null}),jsxs("span",{className:"flex flex-1 items-center justify-center gap-x-1 whitespace-nowrap",children:[k!=null&&jsxs("span",{style:{color:"var(--color-bullish)"},children:[a("predict.trade.bestBid"),": ",u(k)]}),k!=null&&N!=null&&jsx("span",{className:"text-text-muted",children:"|"}),N!=null&&jsxs("span",{style:{color:"var(--color-bearish)"},children:[a("predict.trade.bestAsk"),": ",u(N)]})]}),jsxs("div",{className:"flex flex-1 items-center justify-end gap-x-2",children:[jsx("button",{type:"button",title:a(l==="depth"?"predict.orderBook.tableView":"predict.orderBook.depthView"),onClick:()=>m(P=>P==="depth"?"table":"depth"),className:"flex items-center text-text-muted transition-colors cursor-pointer hover:text-foreground",children:l==="depth"?jsx(OrderbookTableIcon,{className:"h-4 w-4"}):jsx(OrderbookDepthIcon,{className:"h-4 w-4"})}),jsx("button",{type:"button",title:a("predict.orderBook.refresh"),onClick:()=>{b||g();},disabled:b||x,className:cn$1("flex items-center text-text-muted transition-colors cursor-pointer hover:text-foreground disabled:cursor-default disabled:opacity-50",x&&"animate-spin"),children:jsx(RefreshIcon,{className:"h-4 w-4"})})]})]}),jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[l==="depth"&&jsx(Fragment,{children:S?jsx(Ll,{}):jsx(us,{bids:y,asks:v})}),l==="table"&&jsx(Fragment,{children:S?jsx(Ll,{}):jsx(ag,{bids:y,asks:v,bestBid:k??void 0,bestAsk:N??void 0,spread:w??void 0,oddsFormatter:n})})]})]})}var ps=4,sg=8;function ag({bids:e,asks:t,spread:r,oddsFormatter:o}){let{t:n}=useTranslation(),[i,s]=useState(false),a=i?sg:ps,l=t.length>ps||e.length>ps,m=useMemo(()=>[...t].sort((d,f)=>d.price-f.price).slice(0,a).reverse(),[t,a]),u=useMemo(()=>[...e].sort((d,f)=>f.price-d.price).slice(0,a),[e,a]),c=useMemo(()=>{let d=[...m,...u].map(f=>f.quantity);return Math.max(...d,1)},[m,u]);return m.length===0&&u.length===0?jsx("div",{className:"flex items-center justify-center h-full text-xs text-text-muted",children:n("predict.orderBook.empty")}):jsxs("div",{className:"flex flex-col h-full overflow-y-auto text-xs font-mono select-none",children:[m.map(d=>jsx(Ol,{price:d.price,quantity:d.quantity,side:"ask",maxQty:c,oddsFormatter:o},`ask-${d.price}`)),jsxs("div",{className:"relative flex items-center justify-center gap-x-2 py-1 border-y border-border text-text-muted text-[10px]",children:[r!=null&&jsxs("span",{children:[n("predict.orderBook.spread"),":"," ",Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`]}),l&&jsx("button",{type:"button",onClick:()=>s(d=>!d),className:"absolute right-2 text-[10px] text-text-muted transition-colors cursor-pointer hover:text-foreground",children:n(i?"predict.orderBook.collapse":"predict.orderBook.expand")})]}),u.map(d=>jsx(Ol,{price:d.price,quantity:d.quantity,side:"bid",maxQty:c,oddsFormatter:o},`bid-${d.price}`)),jsxs("div",{className:"grid grid-cols-3 px-2 pt-2 pb-0.5 text-[10px] text-text-muted 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 Ol({price:e,quantity:t,side:r,maxQty:o,oddsFormatter:n}){let i=r==="ask",s=Math.min(t/o*100,100),a=i?"bg-negative/10":"bg-positive/10",l=i?"text-negative":"text-positive",m=oo(Math.round(t)),u=Math.round(t*e),c=`$${oo(u)}`;return jsxs("div",{className:"relative grid grid-cols-3 px-2 py-1 hover:bg-content2 transition-colors cursor-default",children:[jsx("div",{className:`absolute inset-y-0 left-0 ${a} transition-[width] duration-200`,style:{width:`${s}%`}}),jsx("span",{className:`relative z-10 ${l}`,children:n?n(e):Dl(e)}),jsx("span",{className:"relative z-10 text-foreground text-center",children:m}),jsx("span",{className:"relative z-10 text-foreground text-right",children:c})]})}var Ln=new Map,gs=new Set,Fl=0;function Bl(){Fl+=1,gs.forEach(e=>e());}function pg(e){return gs.add(e),()=>gs.delete(e)}function Al(){return Fl}function mg(e,t){return e?.bestAsk===t.bestAsk&&e?.bestBid===t.bestBid}function On(e){return e!=null&&e>0&&Number.isFinite(e)?e:void 0}function fg(e,t,r){if(!e||!t)return;let o={bestAsk:On(r.bestAsk),bestBid:On(r.bestBid)};if(o.bestAsk===void 0&&o.bestBid===void 0){_n(e,t);return}let n=Ze(e,t);mg(Ln.get(n),o)||(Ln.set(n,o),Bl());}function Hl(e,t,r){!e||!t||!r||fg(e,t,{bestAsk:On(pickBestAsk(r,t)),bestBid:On(pickBestBid(r,t))});}function _n(e,t){if(!e||!t)return;let r=Ze(e,t);Ln.delete(r)&&Bl();}function Ul(e){let t=useSyncExternalStore(pg,Al,Al);return useMemo(()=>{let r=new Map;for(let o of e){let n=Ze(o.slug,o.outcome),i=Ln.get(n);i!==void 0&&r.set(n,i);}return r},[e,t])}function In(e){return e.status==="closed"||e.status==="voided"?e.markets??[]:(e.markets??[]).filter(t=>t.status==="open")}var so=themeSemanticColors.text.muted,hs=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:"var(--color-text-muted)",fontSize:13},children:[jsx(Translation,{children:t=>jsx("span",{children:t("predict.chart.unavailable")})}),jsx("span",{style:{fontSize:11,opacity:.7},children:this.state.error.message})]}):this.props.children}},Wo=4,Wl=["#22d3ee","#a3e635","#f97316","#f472b6","#a78bfa"];function Tg(e,t){let r=new Date(e);return t===K.ONE_HOUR||t===K.SIX_HOURS||t===K.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):t===K.ALL?r.toLocaleDateString("en-US",{month:"numeric",day:"numeric"}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Rg(e,t){let r=new Date(e);return t===K.ONE_HOUR||t===K.SIX_HOURS||t===K.ONE_DAY?r.toLocaleTimeString("en-US",{month:t===K.ONE_DAY?"short":void 0,day:t===K.ONE_DAY?"numeric":void 0,hour:"2-digit",minute:"2-digit",hour12:false}):t===K.ONE_MONTH||t===K.ALL?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 zl(e){return `${(e*100).toFixed(2)}%`}function Lg(e){if(!e)return;let t=Date.parse(e);return Number.isFinite(t)?t:void 0}function Og(e,t,r){let o=r*1e3,n=t.map(a=>Lg(a.created_at)).filter(a=>a!=null),i=n.length>0?Math.min(...n):void 0,s=xi[e];if(s!=null){let a=o-s*1e3;return [i!=null?Math.max(i,a):a,o]}return [i??o-7*864e5,o]}function _g([e,t]){if(!Number.isFinite(e)||!Number.isFinite(t)||t<=e)return [];let r=5,o=(t-e)/(r-1);return Array.from({length:r},(n,i)=>Math.round(e+o*i))}function Ig(e){switch(e){case K.ONE_HOUR:case K.SIX_HOURS:return 3e4;case K.ONE_DAY:return 6e4;case K.ONE_MONTH:case K.ALL:return 5*6e4;default:return 6e4}}function Dg(e){return e.status==="open"||e.status==="pending"}var Ag=[{range:K.ONE_HOUR,value:1,unit:"hour"},{range:K.SIX_HOURS,value:6,unit:"hour"},{range:K.ONE_DAY,value:1,unit:"day"},{range:K.ONE_MONTH,value:1,unit:"month"},{range:K.ALL}];function Fg({value:e,onChange:t}){let{t:r}=useTranslation(),{formatUnit:o}=useLocalizedTimeFormatter();return jsx("div",{style:{display:"flex",alignItems:"center",gap:2},children:Ag.map(({range:n,value:i,unit:s})=>{let a=n===e,l=i!=null&&s?o(i,s):r("common.all");return jsx("button",{onClick:()=>t(n),style:{padding:"2px 8px",border:"none",background:"transparent",color:a?"var(--color-text-primary)":"var(--color-text-muted)",fontWeight:a?700:400,fontSize:12,cursor:"pointer",borderRadius:4,letterSpacing:"0.02em",transition:"color 0.15s",userSelect:"none"},children:l},n)})})}function Bg(){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 Hg({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:"var(--color-text-secondary)",marginBottom:6,fontWeight:500},children:typeof r=="number"?Rg(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:"var(--color-text-secondary)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:120},children:o.get(l.dataKey)??l.dataKey}),jsx("span",{style:{color:"var(--color-text-primary)",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:l.value!=null?zl(l.value):"--"})]},l.dataKey))]})}function Ug({onPayload:e,...t}){let{active:r,label:o,payload:n}=t;return useEffect(()=>{r&&e(o,n);},[r,o,e,n]),jsx(Hg,{...t})}function Wg({markets:e,selectedSlugs:t,colorMap:r,onToggle:o}){let{t:n}=useTranslation(),[i,s]=useState(false),a=useRef(null);useEffect(()=>{if(!i)return;function u(c){a.current&&!a.current.contains(c.target)&&s(false);}return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[i]);let l=t.length>=Wo,m=jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},children:[jsx("div",{style:{display:"flex",gap:3,flexShrink:0},children:t.map(u=>jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:r.get(u)??so,display:"inline-block"}},u))}),jsx("span",{style:{color:"#e5e7eb",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.length===1?(()=>{let u=e.find(c=>c.slug===t[0]);return u?lr(u):n("predict.chart.singleMarket")})():n("predict.chart.marketCount",{selected:t.length,total:e.length})})]});return jsxs("div",{ref:a,style:{position:"relative",display:"inline-block",width:200},children:[jsxs("button",{onClick:()=>s(u=>!u),style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:8,border:"1px solid rgba(255,255,255,0.12)",background:"hsl(var(--heroui-foreground) / 0.05)",cursor:"pointer",width:"100%",userSelect:"none"},children:[m,jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{flexShrink:0,transform:i?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.15s",color:"var(--color-text-muted)"},children:jsx("path",{d:"M2 4l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),i&&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:[jsx("div",{style:{padding:"4px 12px 8px",fontSize:11,color:"var(--color-text-muted)",borderBottom:"1px solid rgba(255,255,255,0.06)",marginBottom:4},children:n("predict.chart.selectMarkets",{count:Wo})}),e.map((u,c)=>{let p=t.includes(u.slug),d=!p&&l,f=p&&t.length===1,g=r.get(u.slug)??so,b=u.outcomes.find(S=>S.label.toLowerCase()==="yes")??u.outcomes[0],h=b?.price!=null?`${Math.round(b.price*100)}%`:null;return jsxs("button",{onClick:()=>{f||d||o(u.slug);},style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"7px 12px",border:"none",background:p?"hsl(var(--heroui-foreground) / 0.05)":"transparent",cursor:d||f?"not-allowed":"pointer",opacity:d?.35:1,textAlign:"left",transition:"background 0.1s"},onMouseEnter:S=>{!d&&!f&&(S.currentTarget.style.background="rgba(255,255,255,0.07)");},onMouseLeave:S=>{S.currentTarget.style.background=p?"hsl(var(--heroui-foreground) / 0.05)":"transparent";},children:[jsx("span",{style:{width:16,height:16,borderRadius:4,border:p?`2px solid ${g}`:"2px solid rgba(255,255,255,0.2)",background:p?`${g}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:g,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:g,flexShrink:0}}),jsx("span",{style:{color:p?"var(--color-text-primary)":"var(--color-text-secondary)",fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:lr(u)}),h&&jsx("span",{style:{color:g,fontWeight:700,fontSize:12,flexShrink:0},children:h})]},u.id??`${c}-${u.slug}`)})]})]})}function zg({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)??so,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:"var(--color-text-secondary)",fontSize:12,lineHeight:"17px",whiteSpace:"nowrap"},children:o.label}),jsx("span",{style:{color:"var(--color-text-primary)",fontSize:14,fontWeight:700,lineHeight:"20px",fontVariantNumeric:"tabular-nums"},children:i!=null?zl(i):"--"})]})]},o.marketSlug)})})}function Kg(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[a.length-1];l&&r.push(l);}return r}function $g(e,t=200){if(e.length===0)return [];let r=e.map(a=>({...a,data:Kg(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(m=>l.set(m.timestamp,m.price)),{slug:a.marketSlug,map:l}}),s=new Map;return n.map(a=>{let l={timestamp:a};return i.forEach(({slug:m,map:u})=>{let c=u.get(a);if(c!==void 0)s.set(m,c),l[m]=c;else {let p=s.get(m);p!==void 0&&(l[m]=p);}}),l})}function xs(e){return jsx(hs,{children:jsx(Vg,{...e})})}function Vg({event:e,marketDataEnabled:t=false,isLoading:r,className:o,volume:n,fillHeight:i=false,orderbookQuotes:s}){let{t:a}=useTranslation(),l=useMemo(()=>{let C=new Set;return In(e).filter(O=>C.has(O.slug)?false:(C.add(O.slug),true))},[e]),m=useMemo(()=>[...l].sort((C,O)=>{let z=Z=>(Z.outcomes.find(me=>me.label.toLowerCase()==="yes")??Z.outcomes[0])?.price??0;return z(O)-z(C)}),[l]),[u,c]=useState(()=>m.slice(0,Wo).map(C=>C.slug));useEffect(()=>{let C=new Set(l.map(O=>O.slug));c(O=>{let z=O.filter(Z=>C.has(Z));return z.length===O.length?O:z.length>0?z:m.slice(0,Wo).map(Z=>Z.slug)});},[l,m]);let[p,d]=useState(yo),f=useMemo(()=>{let C=new Map;return u.forEach((O,z)=>{C.set(O,Wl[z%Wl.length]);}),C},[u]),g=useMemo(()=>l.filter(C=>u.includes(C.slug)),[l,u]),b=useMemo(()=>g.map(C=>C.slug).join("|"),[g]),[h,S]=useState(()=>Math.floor(Date.now()/1e3)),x=useMemo(()=>Ig(p),[p]),y=useMemo(()=>g.some(Dg),[g]);useEffect(()=>{S(Math.floor(Date.now()/1e3));},[p,b]),useEffect(()=>{if(!y)return;let C=()=>{let z=Math.floor(Date.now()/1e3);S(Z=>Z===z?Z:z);},O=window.setInterval(C,x);return ()=>window.clearInterval(O)},[x,y]);let v=useMemo(()=>Og(p,g,h),[p,g,h]),k=useMemo(()=>_g(v),[v]),{series:N,isLoading:w}=useMarketHistory(g,p,{endTs:h}),P=`${p}:${b}`,M=useRef(new Map),T=M.current.get(P),A=w&&T!=null&&T.length>0,X=A?T:N;useEffect(()=>{!w&&N.length>0&&M.current.set(P,N);},[P,w,N]);let L=!!(r||w&&!A),G=useMemo(()=>{let C=new Map;return s&&g.forEach(O=>{let z=s.get(Ze(O.slug,"yes"))?.bestAsk;z!=null&&z>0&&Number.isFinite(z)&&C.set(O.slug,z);}),C},[s,g]),U=useMemo(()=>X.length>0&&X.some(C=>C.data.length>0)?X.map(C=>{let O=G.get(C.marketSlug);if(O==null||C.data.length===0)return C;let z=C.data[C.data.length-1];if(Math.abs(z.price-O)<1e-6)return C;let Z=Math.min(Date.now(),v[1]),me={timestamp:Z,price:O},Ne=Z-z.timestamp<5e3?[...C.data.slice(0,-1),{...z,price:O}]:[...C.data,me];return {...C,data:Ne}}):L?[]:g.flatMap(C=>{let O=C.outcomes?.find(Z=>Z.label.toLowerCase()==="yes")??C.outcomes?.[0],z=G.get(C.slug)??O?.best_ask??O?.best_bid??O?.price??(t?void 0:.5);return z===void 0?[]:[{marketSlug:C.slug,label:lr(C),data:[{timestamp:v[0],price:z},{timestamp:v[1],price:z}]}]}),[X,L,G,t,g,v]),oe=useMemo(()=>p===K.ONE_HOUR?80:p===K.SIX_HOURS?400:p===K.ONE_DAY?320:p===K.ONE_MONTH?3e3:2e3,[p]),W=useMemo(()=>$g(U,oe),[U,oe]),te=useMemo(()=>{if(W.length===0)return [0,1];let C=1/0,O=-1/0;if(u.forEach(Z=>{W.forEach(me=>{let Ne=me[Z];Ne!=null&&(Ne<C&&(C=Ne),Ne>O&&(O=Ne));});}),!isFinite(C))return [0,1];let z=Math.max((O-C)*.15,.05);return [Math.max(0,C-z),Math.min(1,O+z)]},[W,u]),ne=useMemo(()=>{let C=new Map;return U.forEach(O=>{O.data.length>0&&C.set(O.marketSlug,O.data[O.data.length-1].price);}),C},[U]),se=useMemo(()=>{let C=new Map;return U.forEach(O=>C.set(O.marketSlug,O.label)),C},[U]),he=useMemo(()=>U.map(C=>({slug:C.marketSlug,color:f.get(C.marketSlug)??so})),[U,f]),{wrapperRef:Pe,overlayRef:pt,onMouseMove:Ve,onMouseLeave:Be}=Bg(),E=useCallback(C=>{c(O=>O.includes(C)?O.length<=1?O:O.filter(z=>z!==C):O.length>=Wo?O:[...O,C]);},[]),[st,He]=useState(null),ve=useRef(""),at=useRef(0),we=useCallback((C,O)=>{if(!O?.length)return;let z=`${C}:${O.map(me=>`${me.dataKey}:${me.value}`).join(",")}`;if(z===ve.current)return;ve.current=z;let Z=new Map;O.forEach(me=>{me.value!=null&&Z.set(me.dataKey,me.value);}),cancelAnimationFrame(at.current),at.current=requestAnimationFrame(()=>{He(Z);});},[]),Ue=useCallback(()=>{Be(),cancelAnimationFrame(at.current),ve.current="",He(null);},[Be]),qe=!L&&W.length>0;return jsxs("div",{className:o,style:{display:"flex",flexDirection:"column",gap:12,...i?{height:"100%",minHeight:0}:null},children:[jsx(zg,{series:U,colorMap:f,displayValues:st??ne}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,...i?{flex:1,minHeight:0}:null},children:[jsx("div",{ref:Pe,style:{width:"100%",userSelect:"none",position:"relative",...i?{flex:1,minHeight:240}:{height:300}},onMouseMove:qe?C=>{Ve(C);}:void 0,onMouseLeave:qe?Ue:void 0,children:L?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"}})}):W.length===0?jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--color-text-muted)",fontSize:13},children:a("predict.chart.noPriceHistory")}):jsxs(Fragment,{children:[jsx("div",{ref:pt,style:{position:"absolute",inset:0,opacity:0,pointerEvents:"none",zIndex:1}}),jsx(ResponsiveContainer,{width:"100%",height:"100%",children:jsxs(LineChart,{data:W,margin:{top:8,right:16,left:0,bottom:0},onMouseLeave:Ue,children:[jsx(CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"#374151",opacity:.5}),jsx(XAxis,{dataKey:"timestamp",type:"number",scale:"time",domain:v,ticks:k,interval:0,tickFormatter:C=>Tg(C,p),axisLine:false,tickLine:false,tick:{fill:"var(--color-text-muted)",fontSize:11},minTickGap:70}),jsx(YAxis,{domain:te,tickFormatter:C=>`${Math.round(C*100)}%`,axisLine:false,tickLine:false,tick:{fill:"var(--color-text-muted)",fontSize:11},width:40,tickCount:6}),jsx(Tooltip,{content:C=>jsx(Ug,{...C,labelMap:se,allSeries:he,range:p,onPayload:we}),cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},wrapperStyle:{zIndex:2},isAnimationActive:false}),U.map(C=>{let O=f.get(C.marketSlug)??so;return jsx(Line,{type:"monotone",dataKey:C.marketSlug,stroke:O,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:O},connectNulls:true,isAnimationActive:false},C.marketSlug)}),st==null&&W.length>0&&U.map(C=>{let O=W[W.length-1],z=O[C.marketSlug];if(z==null)return null;let Z=f.get(C.marketSlug)??so;return jsx(ReferenceDot,{x:O.timestamp,y:z,ifOverflow:"extendDomain",shape:me=>{let{cx:Ne,cy:lt}=me;return Ne==null||lt==null?jsx("g",{}):jsxs("g",{children:[jsxs("circle",{cx:Ne,cy:lt,r:6,fill:Z,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:Ne,cy:lt,r:3.5,fill:Z})]})}},`pulse-${C.marketSlug}`)})]})})]})}),jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"6px 8px",marginTop:6},children:[n!=null&&n>0&&jsx("span",{style:{color:"var(--color-text-muted)",fontSize:12},children:a("predict.chart.volume",{value:formatAmountInUsd(n)})}),jsx("div",{style:{flex:1,minWidth:0}}),jsx(Fg,{value:p,onChange:d}),m.length>1&&jsx("div",{style:{width:"100%",display:"flex",alignItems:"center"},children:jsx(Wg,{markets:m,selectedSlugs:u,colorMap:f,onToggle:E})})]})]})]})}function Dn(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Kl(e,t){let r=e.outcomes[t==="yes"?0:1];return r?.best_ask??r?.price}function sh(e){return e===void 0?"\u2014":`${parseFloat((e*100).toFixed(2))}%`}function ah(e){if(e===void 0)return "\u2014";let t=e*100;return t<1&&t>0?"< 1":parseFloat(t.toFixed(2)).toString()}function An(e){return lr(e)}function lh(e){switch(e){case "polymarket":return "Polymarket";case "kalshi":return "Kalshi";default:return e}}function zo(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 $l(e){let{formatUnit:t}=useLocalizedTimeFormatter(),[r,o]=useState(0);if(useEffect(()=>{if(!e)return;o(Date.now());let c=setInterval(()=>o(Date.now()),1e3);return ()=>clearInterval(c)},[e]),!e||r===0)return null;let n=new Date(e).getTime();if(isNaN(n))return null;let i=n-r;if(i<=0)return null;let s=Math.floor(i/864e5),a=Math.floor(i%864e5/36e5),l=Math.floor(i%36e5/6e4),m=Math.floor(i%6e4/1e3),u=[];return s>0&&u.push(t(s,"day")),u.push(t(a,"hour")),u.push(t(l,"minute")),u.push(t(m,"second")),u.join(" ")}function Vl(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?"+":"-",m=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${o} ${n}/${i}/${s} (${l}${m})`}function $o({event:e,marketDataEnabled:t=false,marketDataOrderbooks:r,onMarketDataBookSelectionChange:o,orderbookQuotes:n,onTradeAction:i}){let{t:s}=useTranslation(),{ref:a,isCollapsed:l}=useScrollCollapse(),m=$r(e),u=useMemo(()=>{let b=[...e.markets||[]],h=b.filter(x=>x.status==="open").sort((x,y)=>Dn(y)-Dn(x)),S=b.filter(x=>x.status!=="open").sort((x,y)=>Dn(y)-Dn(x));return [...h,...S]},[e.markets]),c=e.status==="closed"||e.status==="voided",p=$l(c?void 0:e.start_at),d=$l(c?void 0:e.end_at),f=Vl(e.start_at),g=Vl(e.end_at);return jsxs("div",{className:"w-full flex flex-col gap-y-4 lg:gap-y-6",children:[jsxs("div",{ref:a,className:`sticky top-0 z-30 flex items-center backdrop-blur-md transition-all duration-300 ${l?"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:m||s("predict.event.fallbackName"),radius:"lg",classNames:{base:"bg-transparent"},className:`flex-shrink-0 transition-all duration-300 ${l?"!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:[!l&&jsxs("div",{className:"flex items-center gap-1.5",children:[e.tags?.slice(0,3).map((b,h)=>jsxs(Fragment$1,{children:[h>0&&jsx("span",{className:"text-sm text-text-muted/50",children:"\xB7"}),jsx("span",{className:"text-sm text-text-muted truncate",children:b.label})]},b.slug)),jsx(ph,{source:e.source})]}),jsx("span",{className:`font-semibold truncate transition-all duration-300 ${l?"text-sm lg:text-base":"text-lg lg:text-xl"}`,children:m})]})]}),(p||d||c)&&jsx("div",{className:"flex items-center gap-x-2 text-xs lg:text-sm font-mono",children:c?g&&jsx("span",{className:"text-text-muted",children:s("predict.event.endedAt",{time:g})}):p?jsxs(Fragment,{children:[jsx("span",{className:"text-foreground",children:s("predict.event.beginsIn",{time:p})}),f&&jsxs(Fragment,{children:[jsx("span",{className:"text-text-muted/50",children:"\xB7"}),jsx("span",{className:"text-text-muted",children:f})]})]}):d?jsxs(Fragment,{children:[jsx("span",{className:"text-foreground",children:s("predict.event.endsIn",{time:d})}),g&&jsxs(Fragment,{children:[jsx("span",{className:"text-text-muted/50",children:"\xB7"}),jsx("span",{className:"text-text-muted",children:g})]})]}):null}),jsx(xs,{event:e,marketDataEnabled:t,volume:e.volume??void 0,orderbookQuotes:n}),jsx(ch,{markets:u,marketDataEnabled:t,marketDataOrderbooks:r,onMarketDataBookSelectionChange:o,orderbookQuotes:n,onTradeAction:i}),jsx(uh,{markets:u,event:e})]})}var jl=5;function ch({markets:e,marketDataEnabled:t,marketDataOrderbooks:r,onMarketDataBookSelectionChange:o,orderbookQuotes:n,onTradeAction:i}){let{t:s}=useTranslation(),{isDesktop:a}=useScreen(),[l,m]=useState(false),[u,c]=useState(null),p=useMemo(()=>{let x=new Set;return e.filter(y=>x.has(y.slug)?false:(x.add(y.slug),true))},[e]),[d,f]=useState(null);if(p.length===0)return null;let g=p.length>jl,b=l?p:p.slice(0,jl),h=x=>{t&&o?.(kl(u,x.slug,d?.marketSlug===x.slug?d.outcomeKey:void 0)),c(y=>y===x.slug?null:x.slug);},S=(x,y,v,k)=>{f({marketSlug:x.slug,tradeOutcome:y,outcomeKey:k}),t&&o?.(Sl(x.slug,k)),a&&c(x.slug),i?.(x,y,v);};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-text-muted font-normal lg:text-center lg:text-sm",children:s("predict.market.table.chance")}),jsx("th",{})]})}),jsx("tbody",{children:b.map((x,y)=>{let v=u===x.slug;return jsx(dh,{market:x,activeSelection:d?.marketSlug===x.slug?d:void 0,isExpanded:v,orderbookQuotes:n,marketDataEnabled:t,marketDataOrderbooks:r,onToggleExpand:()=>h(x),onTradeAction:S,onUnselectedTradeAction:i},x.id??`${y}-${x.slug}`)})})]}),g&&jsxs("button",{type:"button",onClick:()=>m(x=>!x),className:"flex w-full items-center justify-start gap-x-2 py-2 pl-1 text-xs text-text-muted lg:pl-2 lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsx("span",{children:s(l?"predict.event.rules.collapse":"predict.event.moreMarketsLabel")}),jsx(ChevronDownIcon,{className:cn$1("h-4 w-4 transition-transform",l&&"rotate-180")})]})]})}function dh({market:e,activeSelection:t,isExpanded:r,orderbookQuotes:o,marketDataEnabled:n,marketDataOrderbooks:i,onToggleExpand:s,onTradeAction:a,onUnselectedTradeAction:l}){let{t:m}=useTranslation(),u=e.status==="open",c=e.volume?`${formatAmountInUsd(e.volume)} vol`:void 0,p=o?.get(Ze(e.slug,"yes"))?.bestAsk??Kl(e,"yes"),d=o?.get(Ze(e.slug,"no"))?.bestAsk??Kl(e,"no"),f=t?.tradeOutcome??"yes",g=t?.outcomeKey,b=Pl(e.outcomes).map(S=>({...S,price:S.tradeOutcome==="yes"?p:d})),h=Nl({marketDataEnabled:n,marketSlug:e.slug,outcomeKey:g??"",books:i});return jsxs(Fragment,{children:[jsxs("tr",{className:"cursor-pointer border-b border-border text-xs hover:bg-content2 lg:text-base",onClick:s,role:"button",tabIndex:0,onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),s());},children:[jsx("td",{className:"py-2 pl-1 lg:pl-2",children:jsxs("div",{className:"flex items-center gap-x-1 lg:gap-x-2",children:[e.image_url&&jsx(Avatar,{src:e.image_url,name:An(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:An(e)}),c&&jsx("span",{className:"text-[8px] text-text-muted lg:text-xxs",children:c})]})]})}),jsx("td",{className:"py-2 text-left text-foreground lg:text-center",children:sh(p)}),jsx("td",{className:"py-2 pr-1 lg:pr-2",children:u?jsx("div",{className:"flex items-center justify-end gap-x-2",children:b.map(({catalogOutcome:S,tradeOutcome:x,price:y})=>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",x==="yes"?t?.outcomeKey===S.key?"bg-primary text-primary-foreground":"bg-primary/10 text-primary":t?.outcomeKey===S.key?"bg-secondary text-secondary-foreground":"bg-secondary/10 text-secondary"),onClick:v=>{v.stopPropagation(),a?.(e,x,"buy",S.key);},children:y!=null?m(x==="yes"?"predict.market.action.yes":"predict.market.action.no",{price:ah(y)}):x==="yes"&&n?`${m("predict.market.yes")} \u2014`:m(x==="yes"?"predict.market.yes":"predict.market.no")},S.key))}):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-text-muted/10 text-text-muted":e.status==="voided"?"bg-warning/10 text-warning":"bg-primary/10 text-primary"),children:e.status==="closed"?m("predict.event.status.closed"):e.status==="voided"?m("predict.event.status.voided"):m("predict.event.status.pending")})})})]}),r&&jsx("tr",{children:jsx("td",{colSpan:3,className:"pb-3",children:jsx("div",{className:"max-h-100 overflow-y-auto",children:jsx(fs,{market:e,outcome:f,onTradeAction:(S,x,y)=>{if(!g){l?.(S,x,y);return}a?.(S,x,y,g);},enabled:h.legacyEnabled,orderbook:h.orderbook})})})})]})}function uh({markets:e,event:t}){let{t:r}=useTranslation(),[o,n]=useState(false),[i,s]=useState(false),[a,l]=useState(0),m=e.filter(d=>d.rules&&d.rules.length>0||vi(d));if(m.length===0)return null;let u=m[a]??m[0],c=u.rules&&u.rules.length>0?u.rules.join(`
|
|
76
|
+
`,kl={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 ye(e){return {...kl,animationDelay:`${e}ms`}}function oo({marketCount:e=4,showBack:t}){return jsxs(Fragment,{children:[jsx("style",{children:yl}),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:{...kl,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:{...ye(0),height:14,width:48}}),jsx("div",{style:{...ye(30),height:14,width:40}}),jsx("div",{style:{...ye(60),height:14,width:40}})]}),jsx("div",{style:{...ye(80),height:20,width:"80%",maxWidth:384,borderRadius:4}})]})]}),jsx("div",{style:{...ye(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:{...ye(120),height:16,width:96}}),jsx("div",{style:{...ye(140),height:16,width:80}})]}),jsx("div",{style:{...ye(160),height:300,width:"100%",borderRadius:12}}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[jsx("div",{style:{...ye(180),height:16,width:80}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsx("div",{style:{...ye(200),height:28,width:200,borderRadius:8}}),jsx("div",{style:{...ye(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:{...ye(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 var(--color-border-subtle)"},children:[jsx("div",{style:{...ye(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:{...ye(280+o*40),height:14,width:o%2===0?192:160}}),jsx("div",{style:{...ye(300+o*40),height:10,width:64}})]}),jsx("div",{style:{...ye(320+o*40),height:16,width:40}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsx("div",{style:{...ye(340+o*40),height:32,width:80,borderRadius:8}}),jsx("div",{style:{...ye(360+o*40),height:32,width:80,borderRadius:8}})]})]},o))]}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[jsx("div",{style:{...ye(400),height:16,width:64}}),jsx("div",{style:{...ye(420),height:14,width:"100%"}}),jsx("div",{style:{...ye(440),height:14,width:"80%"}}),jsx("div",{style:{...ye(460),height:14,width:"60%"}})]})]})]})}function us(){return jsxs(Fragment,{children:[jsx("style",{children:yl}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,borderRadius:14,border:"1px solid var(--color-border-subtle)",background:"hsl(var(--heroui-content2) / 0.4)",padding:16},children:[jsx("div",{style:{...ye(0),height:40,width:"100%",borderRadius:8}}),jsx("div",{style:{...ye(60),height:96,width:"100%",borderRadius:8}}),jsx("div",{style:{...ye(120),height:40,width:"100%",borderRadius:8}})]})]})}function Pl(e,t,r){return e===t||!r?null:{marketSlug:t,outcomeKey:r}}function Nl(e,t){return {marketSlug:e,outcomeKey:t}}function Ml(e){return e.slice(0,2).map((t,r)=>({catalogOutcome:t,tradeOutcome:r===0?"yes":"no"}))}function Ze(e,t){return `${e}:${t}`}function wl({marketDataEnabled:e,marketSlug:t,outcomeKey:r,books:o}){return e?{legacyEnabled:false,orderbook:o?.get(Ze(t,r))??null}:{legacyEnabled:true,orderbook:void 0}}var Rl="var(--color-bullish)",Ll="var(--color-bearish)";function no(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 eg(e,t){return e<=0||t<=0?0:Math.pow(e/t,.3)}function tg(e,t){let r=new Float64Array(101),o=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&&(o[f]+=d.quantity);}let n=0,i=0,s=new Float64Array(101),a=new Float64Array(101);for(let d=100;d>=0;d--)n+=r[d],i+=r[d]*d/100,s[d]=n,a[d]=i;let l=0,m=0,u=new Float64Array(101),c=new Float64Array(101);for(let d=0;d<=100;d++)l+=o[d],m+=o[d]*d/100,u[d]=l,c[d]=m;let p=Math.max(s[0]??0,u[100]??0);return Array.from({length:101},(d,f)=>{let g=s[f]>0,b=u[f]>0,v=s[f]||u[f],S=r[f]>0||o[f]>0;return {priceCents:f,displayHeight:eg(v,p),opacity:v>0?S?1:.5:0,isBid:g,isAsk:b,bidCumTotal:s[f],askCumTotal:u[f],bidCumCost:a[f],askCumCost:c[f]}})}function rg({info:e}){let{t}=useTranslation(),r=e.isBid?Rl:Ll,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:"var(--color-text-primary)",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:no(Math.round(e.cumTotal))})}),jsxs("div",{style:{color:r},children:["$",no(Math.round(e.cumCost))]})]})}var og=memo(function({slot:t,onEnter:r,onLeave:o}){let n=useRef(null),i=t.isBid||t.isAsk,s=t.isBid?Rl:t.isAsk?Ll: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}})})}),ng=[0,10,20,30,40,50,60,70,80,90,100];function ig(){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:ng.map(e=>jsx("span",{className:"absolute text-text-muted font-normal",style:{fontSize:10,left:`${e}%`,transform:e===0?"translateX(0px)":e===100?"translateX(-100%)":"translateX(-50%)"},children:e},e))})}function ms({bids:e,asks:t}){let{t:r}=useTranslation(),o=useMemo(()=>tg(e,t),[e,t]),n=useMemo(()=>{let c=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((c+p)/2*100)},[e,t]),i=useMemo(()=>o.some(c=>c.isBid||c.isAsk),[o]),[s,a]=useState(null),l=useRef(null),m=useCallback((c,p)=>{l.current&&(l.current.style.filter=""),p?(p.style.filter="brightness(1.5)",l.current=p):l.current=null,c.isBid||c.isAsk?a({priceCents:c.priceCents,isBid:c.isBid,cumTotal:c.isBid?c.bidCumTotal:c.askCumTotal,cumCost:c.isBid?c.bidCumCost:c.askCumCost,leftPct:c.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(rg,{info:s}),o.map(c=>jsx(og,{slot:c,onEnter:m,onLeave:u},c.priceCents))]}),jsx(ig,{})]}):jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--color-text-muted)",fontSize:13},children:r("predict.orderBook.noData")})}function Fl(e){let t=e*100,r=Math.round(t*10)/10;return Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`}function _l(){let{t:e}=useTranslation();return jsx("div",{className:"absolute inset-0 flex items-center justify-center text-text-muted text-xs",children:jsx("span",{children:e("predict.orderBook.loading")})})}function vs({market:e,outcome:t="yes",initialViewMode:r="depth",className:o,oddsFormatter:n,enabled:i=true,orderbook:s}){let{t:a}=useTranslation(),[l,m]=useState(r),u=n??Fl,c=e.source,{data:p,isLoading:d,isFetching:f,refetch:g}=useRealtimeOrderbook({slug:e.slug,source:c,outcome:t},{enabled:i}),b=s!==void 0,v=b?s:p,S=!b&&d,x=!b&&f,y=useMemo(()=>(v?.bids??[]).map(P=>({price:P.price,quantity:P.size})),[v?.bids]),h=useMemo(()=>(v?.asks??[]).map(P=>({price:P.price,quantity:P.size})),[v?.asks]),k=useMemo(()=>y.length>0?Math.max(...y.map(P=>P.price)):null,[y]),N=useMemo(()=>h.length>0?Math.min(...h.map(P=>P.price)):null,[h]),w=useMemo(()=>{if(k==null||N==null)return null;let P=(N-k)*100;return Math.round(P*10)/10},[k,N]);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-text-muted",children:w!=null?`${a("predict.orderBook.spread")}: ${Number.isInteger(w)?`${w}\xA2`:`${w.toFixed(1)}\xA2`}`:null}),jsxs("span",{className:"flex flex-1 items-center justify-center gap-x-1 whitespace-nowrap",children:[k!=null&&jsxs("span",{style:{color:"var(--color-bullish)"},children:[a("predict.trade.bestBid"),": ",u(k)]}),k!=null&&N!=null&&jsx("span",{className:"text-text-muted",children:"|"}),N!=null&&jsxs("span",{style:{color:"var(--color-bearish)"},children:[a("predict.trade.bestAsk"),": ",u(N)]})]}),jsxs("div",{className:"flex flex-1 items-center justify-end gap-x-2",children:[jsx("button",{type:"button",title:a(l==="depth"?"predict.orderBook.tableView":"predict.orderBook.depthView"),onClick:()=>m(P=>P==="depth"?"table":"depth"),className:"flex items-center text-text-muted transition-colors cursor-pointer hover:text-foreground",children:l==="depth"?jsx(OrderbookTableIcon,{className:"h-4 w-4"}):jsx(OrderbookDepthIcon,{className:"h-4 w-4"})}),jsx("button",{type:"button",title:a("predict.orderBook.refresh"),onClick:()=>{b||g();},disabled:b||x,className:cn("flex items-center text-text-muted transition-colors cursor-pointer hover:text-foreground disabled:cursor-default disabled:opacity-50",x&&"animate-spin"),children:jsx(RefreshIcon,{className:"h-4 w-4"})})]})]}),jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[l==="depth"&&jsx(Fragment,{children:S?jsx(_l,{}):jsx(ms,{bids:y,asks:h})}),l==="table"&&jsx(Fragment,{children:S?jsx(_l,{}):jsx(ug,{bids:y,asks:h,bestBid:k??void 0,bestAsk:N??void 0,spread:w??void 0,oddsFormatter:n})})]})]})}var fs=4,dg=8;function ug({bids:e,asks:t,spread:r,oddsFormatter:o}){let{t:n}=useTranslation(),[i,s]=useState(false),a=i?dg:fs,l=t.length>fs||e.length>fs,m=useMemo(()=>[...t].sort((d,f)=>d.price-f.price).slice(0,a).reverse(),[t,a]),u=useMemo(()=>[...e].sort((d,f)=>f.price-d.price).slice(0,a),[e,a]),c=useMemo(()=>{let d=[...m,...u].map(f=>f.quantity);return Math.max(...d,1)},[m,u]);return m.length===0&&u.length===0?jsx("div",{className:"flex items-center justify-center h-full text-xs text-text-muted",children:n("predict.orderBook.empty")}):jsxs("div",{className:"flex flex-col h-full overflow-y-auto text-xs font-mono select-none",children:[m.map(d=>jsx(Il,{price:d.price,quantity:d.quantity,side:"ask",maxQty:c,oddsFormatter:o},`ask-${d.price}`)),jsxs("div",{className:"relative flex items-center justify-center gap-x-2 py-1 border-y border-border text-text-muted text-[10px]",children:[r!=null&&jsxs("span",{children:[n("predict.orderBook.spread"),":"," ",Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`]}),l&&jsx("button",{type:"button",onClick:()=>s(d=>!d),className:"absolute right-2 text-[10px] text-text-muted transition-colors cursor-pointer hover:text-foreground",children:n(i?"predict.orderBook.collapse":"predict.orderBook.expand")})]}),u.map(d=>jsx(Il,{price:d.price,quantity:d.quantity,side:"bid",maxQty:c,oddsFormatter:o},`bid-${d.price}`)),jsxs("div",{className:"grid grid-cols-3 px-2 pt-2 pb-0.5 text-[10px] text-text-muted 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 Il({price:e,quantity:t,side:r,maxQty:o,oddsFormatter:n}){let i=r==="ask",s=Math.min(t/o*100,100),a=i?"bg-negative/10":"bg-positive/10",l=i?"text-negative":"text-positive",m=no(Math.round(t)),u=Math.round(t*e),c=`$${no(u)}`;return jsxs("div",{className:"relative grid grid-cols-3 px-2 py-1 hover:bg-content2 transition-colors cursor-default",children:[jsx("div",{className:`absolute inset-y-0 left-0 ${a} transition-[width] duration-200`,style:{width:`${s}%`}}),jsx("span",{className:`relative z-10 ${l}`,children:n?n(e):Fl(e)}),jsx("span",{className:"relative z-10 text-foreground text-center",children:m}),jsx("span",{className:"relative z-10 text-foreground text-right",children:c})]})}var On=new Map,hs=new Set,Hl=0;function Ul(){Hl+=1,hs.forEach(e=>e());}function vg(e){return hs.add(e),()=>hs.delete(e)}function Bl(){return Hl}function hg(e,t){return e?.bestAsk===t.bestAsk&&e?.bestBid===t.bestBid}function _n(e){return e!=null&&e>0&&Number.isFinite(e)?e:void 0}function xg(e,t,r){if(!e||!t)return;let o={bestAsk:_n(r.bestAsk),bestBid:_n(r.bestBid)};if(o.bestAsk===void 0&&o.bestBid===void 0){In(e,t);return}let n=Ze(e,t);hg(On.get(n),o)||(On.set(n,o),Ul());}function Wl(e,t,r){!e||!t||!r||xg(e,t,{bestAsk:_n(pickBestAsk(r,t)),bestBid:_n(pickBestBid(r,t))});}function In(e,t){if(!e||!t)return;let r=Ze(e,t);On.delete(r)&&Ul();}function zl(e){let t=useSyncExternalStore(vg,Bl,Bl);return useMemo(()=>{let r=new Map;for(let o of e){let n=Ze(o.slug,o.outcome),i=On.get(n);i!==void 0&&r.set(n,i);}return r},[e,t])}function Dn(e){return e.status==="closed"||e.status==="voided"?e.markets??[]:(e.markets??[]).filter(t=>t.status==="open")}var ao=themeSemanticColors.text.muted,xs=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:"var(--color-text-muted)",fontSize:13},children:[jsx(Translation,{children:t=>jsx("span",{children:t("predict.chart.unavailable")})}),jsx("span",{style:{fontSize:11,opacity:.7},children:this.state.error.message})]}):this.props.children}},zo=4,Kl=["#22d3ee","#a3e635","#f97316","#f472b6","#a78bfa"];function _g(e,t){let r=new Date(e);return t===K.ONE_HOUR||t===K.SIX_HOURS||t===K.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):t===K.ALL?r.toLocaleDateString("en-US",{month:"numeric",day:"numeric"}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Ig(e,t){let r=new Date(e);return t===K.ONE_HOUR||t===K.SIX_HOURS||t===K.ONE_DAY?r.toLocaleTimeString("en-US",{month:t===K.ONE_DAY?"short":void 0,day:t===K.ONE_DAY?"numeric":void 0,hour:"2-digit",minute:"2-digit",hour12:false}):t===K.ONE_MONTH||t===K.ALL?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 $l(e){return `${(e*100).toFixed(2)}%`}function Dg(e){if(!e)return;let t=Date.parse(e);return Number.isFinite(t)?t:void 0}function Ag(e,t,r){let o=r*1e3,n=t.map(a=>Dg(a.created_at)).filter(a=>a!=null),i=n.length>0?Math.min(...n):void 0,s=bi[e];if(s!=null){let a=o-s*1e3;return [i!=null?Math.max(i,a):a,o]}return [i??o-7*864e5,o]}function Fg([e,t]){if(!Number.isFinite(e)||!Number.isFinite(t)||t<=e)return [];let r=5,o=(t-e)/(r-1);return Array.from({length:r},(n,i)=>Math.round(e+o*i))}function Bg(e){switch(e){case K.ONE_HOUR:case K.SIX_HOURS:return 3e4;case K.ONE_DAY:return 6e4;case K.ONE_MONTH:case K.ALL:return 5*6e4;default:return 6e4}}function Hg(e){return e.status==="open"||e.status==="pending"}var Ug=[{range:K.ONE_HOUR,value:1,unit:"hour"},{range:K.SIX_HOURS,value:6,unit:"hour"},{range:K.ONE_DAY,value:1,unit:"day"},{range:K.ONE_MONTH,value:1,unit:"month"},{range:K.ALL}];function Wg({value:e,onChange:t}){let{t:r}=useTranslation(),{formatUnit:o}=useLocalizedTimeFormatter();return jsx("div",{style:{display:"flex",alignItems:"center",gap:2},children:Ug.map(({range:n,value:i,unit:s})=>{let a=n===e,l=i!=null&&s?o(i,s):r("common.all");return jsx("button",{onClick:()=>t(n),style:{padding:"2px 8px",border:"none",background:"transparent",color:a?"var(--color-text-primary)":"var(--color-text-muted)",fontWeight:a?700:400,fontSize:12,cursor:"pointer",borderRadius:4,letterSpacing:"0.02em",transition:"color 0.15s",userSelect:"none"},children:l},n)})})}function zg(){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 Kg({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:"var(--color-text-secondary)",marginBottom:6,fontWeight:500},children:typeof r=="number"?Ig(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:"var(--color-text-secondary)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:120},children:o.get(l.dataKey)??l.dataKey}),jsx("span",{style:{color:"var(--color-text-primary)",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:l.value!=null?$l(l.value):"--"})]},l.dataKey))]})}function $g({onPayload:e,...t}){let{active:r,label:o,payload:n}=t;return useEffect(()=>{r&&e(o,n);},[r,o,e,n]),jsx(Kg,{...t})}function Vg({markets:e,selectedSlugs:t,colorMap:r,onToggle:o}){let{t:n}=useTranslation(),[i,s]=useState(false),a=useRef(null);useEffect(()=>{if(!i)return;function u(c){a.current&&!a.current.contains(c.target)&&s(false);}return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[i]);let l=t.length>=zo,m=jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},children:[jsx("div",{style:{display:"flex",gap:3,flexShrink:0},children:t.map(u=>jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:r.get(u)??ao,display:"inline-block"}},u))}),jsx("span",{style:{color:"#e5e7eb",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.length===1?(()=>{let u=e.find(c=>c.slug===t[0]);return u?lr(u):n("predict.chart.singleMarket")})():n("predict.chart.marketCount",{selected:t.length,total:e.length})})]});return jsxs("div",{ref:a,style:{position:"relative",display:"inline-block",width:200},children:[jsxs("button",{onClick:()=>s(u=>!u),style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:8,border:"1px solid rgba(255,255,255,0.12)",background:"hsl(var(--heroui-foreground) / 0.05)",cursor:"pointer",width:"100%",userSelect:"none"},children:[m,jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{flexShrink:0,transform:i?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.15s",color:"var(--color-text-muted)"},children:jsx("path",{d:"M2 4l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),i&&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:[jsx("div",{style:{padding:"4px 12px 8px",fontSize:11,color:"var(--color-text-muted)",borderBottom:"1px solid rgba(255,255,255,0.06)",marginBottom:4},children:n("predict.chart.selectMarkets",{count:zo})}),e.map((u,c)=>{let p=t.includes(u.slug),d=!p&&l,f=p&&t.length===1,g=r.get(u.slug)??ao,b=u.outcomes.find(S=>S.label.toLowerCase()==="yes")??u.outcomes[0],v=b?.price!=null?`${Math.round(b.price*100)}%`:null;return jsxs("button",{onClick:()=>{f||d||o(u.slug);},style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"7px 12px",border:"none",background:p?"hsl(var(--heroui-foreground) / 0.05)":"transparent",cursor:d||f?"not-allowed":"pointer",opacity:d?.35:1,textAlign:"left",transition:"background 0.1s"},onMouseEnter:S=>{!d&&!f&&(S.currentTarget.style.background="rgba(255,255,255,0.07)");},onMouseLeave:S=>{S.currentTarget.style.background=p?"hsl(var(--heroui-foreground) / 0.05)":"transparent";},children:[jsx("span",{style:{width:16,height:16,borderRadius:4,border:p?`2px solid ${g}`:"2px solid rgba(255,255,255,0.2)",background:p?`${g}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:g,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:g,flexShrink:0}}),jsx("span",{style:{color:p?"var(--color-text-primary)":"var(--color-text-secondary)",fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:lr(u)}),v&&jsx("span",{style:{color:g,fontWeight:700,fontSize:12,flexShrink:0},children:v})]},u.id??`${c}-${u.slug}`)})]})]})}function jg({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)??ao,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:"var(--color-text-secondary)",fontSize:12,lineHeight:"17px",whiteSpace:"nowrap"},children:o.label}),jsx("span",{style:{color:"var(--color-text-primary)",fontSize:14,fontWeight:700,lineHeight:"20px",fontVariantNumeric:"tabular-nums"},children:i!=null?$l(i):"--"})]})]},o.marketSlug)})})}function Gg(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[a.length-1];l&&r.push(l);}return r}function Yg(e,t=200){if(e.length===0)return [];let r=e.map(a=>({...a,data:Gg(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(m=>l.set(m.timestamp,m.price)),{slug:a.marketSlug,map:l}}),s=new Map;return n.map(a=>{let l={timestamp:a};return i.forEach(({slug:m,map:u})=>{let c=u.get(a);if(c!==void 0)s.set(m,c),l[m]=c;else {let p=s.get(m);p!==void 0&&(l[m]=p);}}),l})}function ys(e){return jsx(xs,{children:jsx(qg,{...e})})}function qg({event:e,marketDataEnabled:t=false,isLoading:r,className:o,volume:n,fillHeight:i=false,orderbookQuotes:s}){let{t:a}=useTranslation(),l=useMemo(()=>{let C=new Set;return Dn(e).filter(O=>C.has(O.slug)?false:(C.add(O.slug),true))},[e]),m=useMemo(()=>[...l].sort((C,O)=>{let z=Z=>(Z.outcomes.find(me=>me.label.toLowerCase()==="yes")??Z.outcomes[0])?.price??0;return z(O)-z(C)}),[l]),[u,c]=useState(()=>m.slice(0,zo).map(C=>C.slug));useEffect(()=>{let C=new Set(l.map(O=>O.slug));c(O=>{let z=O.filter(Z=>C.has(Z));return z.length===O.length?O:z.length>0?z:m.slice(0,zo).map(Z=>Z.slug)});},[l,m]);let[p,d]=useState(ko),f=useMemo(()=>{let C=new Map;return u.forEach((O,z)=>{C.set(O,Kl[z%Kl.length]);}),C},[u]),g=useMemo(()=>l.filter(C=>u.includes(C.slug)),[l,u]),b=useMemo(()=>g.map(C=>C.slug).join("|"),[g]),[v,S]=useState(()=>Math.floor(Date.now()/1e3)),x=useMemo(()=>Bg(p),[p]),y=useMemo(()=>g.some(Hg),[g]);useEffect(()=>{S(Math.floor(Date.now()/1e3));},[p,b]),useEffect(()=>{if(!y)return;let C=()=>{let z=Math.floor(Date.now()/1e3);S(Z=>Z===z?Z:z);},O=window.setInterval(C,x);return ()=>window.clearInterval(O)},[x,y]);let h=useMemo(()=>Ag(p,g,v),[p,g,v]),k=useMemo(()=>Fg(h),[h]),{series:N,isLoading:w}=useMarketHistory(g,p,{endTs:v}),P=`${p}:${b}`,M=useRef(new Map),T=M.current.get(P),A=w&&T!=null&&T.length>0,X=A?T:N;useEffect(()=>{!w&&N.length>0&&M.current.set(P,N);},[P,w,N]);let L=!!(r||w&&!A),G=useMemo(()=>{let C=new Map;return s&&g.forEach(O=>{let z=s.get(Ze(O.slug,"yes"))?.bestAsk;z!=null&&z>0&&Number.isFinite(z)&&C.set(O.slug,z);}),C},[s,g]),U=useMemo(()=>X.length>0&&X.some(C=>C.data.length>0)?X.map(C=>{let O=G.get(C.marketSlug);if(O==null||C.data.length===0)return C;let z=C.data[C.data.length-1];if(Math.abs(z.price-O)<1e-6)return C;let Z=Math.min(Date.now(),h[1]),me={timestamp:Z,price:O},Ne=Z-z.timestamp<5e3?[...C.data.slice(0,-1),{...z,price:O}]:[...C.data,me];return {...C,data:Ne}}):L?[]:g.flatMap(C=>{let O=C.outcomes?.find(Z=>Z.label.toLowerCase()==="yes")??C.outcomes?.[0],z=G.get(C.slug)??O?.best_ask??O?.best_bid??O?.price??(t?void 0:.5);return z===void 0?[]:[{marketSlug:C.slug,label:lr(C),data:[{timestamp:h[0],price:z},{timestamp:h[1],price:z}]}]}),[X,L,G,t,g,h]),oe=useMemo(()=>p===K.ONE_HOUR?80:p===K.SIX_HOURS?400:p===K.ONE_DAY?320:p===K.ONE_MONTH?3e3:2e3,[p]),W=useMemo(()=>Yg(U,oe),[U,oe]),te=useMemo(()=>{if(W.length===0)return [0,1];let C=1/0,O=-1/0;if(u.forEach(Z=>{W.forEach(me=>{let Ne=me[Z];Ne!=null&&(Ne<C&&(C=Ne),Ne>O&&(O=Ne));});}),!isFinite(C))return [0,1];let z=Math.max((O-C)*.15,.05);return [Math.max(0,C-z),Math.min(1,O+z)]},[W,u]),ne=useMemo(()=>{let C=new Map;return U.forEach(O=>{O.data.length>0&&C.set(O.marketSlug,O.data[O.data.length-1].price);}),C},[U]),se=useMemo(()=>{let C=new Map;return U.forEach(O=>C.set(O.marketSlug,O.label)),C},[U]),ve=useMemo(()=>U.map(C=>({slug:C.marketSlug,color:f.get(C.marketSlug)??ao})),[U,f]),{wrapperRef:Pe,overlayRef:pt,onMouseMove:Ve,onMouseLeave:Be}=zg(),E=useCallback(C=>{c(O=>O.includes(C)?O.length<=1?O:O.filter(z=>z!==C):O.length>=zo?O:[...O,C]);},[]),[st,He]=useState(null),he=useRef(""),at=useRef(0),we=useCallback((C,O)=>{if(!O?.length)return;let z=`${C}:${O.map(me=>`${me.dataKey}:${me.value}`).join(",")}`;if(z===he.current)return;he.current=z;let Z=new Map;O.forEach(me=>{me.value!=null&&Z.set(me.dataKey,me.value);}),cancelAnimationFrame(at.current),at.current=requestAnimationFrame(()=>{He(Z);});},[]),Ue=useCallback(()=>{Be(),cancelAnimationFrame(at.current),he.current="",He(null);},[Be]),qe=!L&&W.length>0;return jsxs("div",{className:o,style:{display:"flex",flexDirection:"column",gap:12,...i?{height:"100%",minHeight:0}:null},children:[jsx(jg,{series:U,colorMap:f,displayValues:st??ne}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,...i?{flex:1,minHeight:0}:null},children:[jsx("div",{ref:Pe,style:{width:"100%",userSelect:"none",position:"relative",...i?{flex:1,minHeight:240}:{height:300}},onMouseMove:qe?C=>{Ve(C);}:void 0,onMouseLeave:qe?Ue:void 0,children:L?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"}})}):W.length===0?jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--color-text-muted)",fontSize:13},children:a("predict.chart.noPriceHistory")}):jsxs(Fragment,{children:[jsx("div",{ref:pt,style:{position:"absolute",inset:0,opacity:0,pointerEvents:"none",zIndex:1}}),jsx(ResponsiveContainer,{width:"100%",height:"100%",children:jsxs(LineChart,{data:W,margin:{top:8,right:16,left:0,bottom:0},onMouseLeave:Ue,children:[jsx(CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"#374151",opacity:.5}),jsx(XAxis,{dataKey:"timestamp",type:"number",scale:"time",domain:h,ticks:k,interval:0,tickFormatter:C=>_g(C,p),axisLine:false,tickLine:false,tick:{fill:"var(--color-text-muted)",fontSize:11},minTickGap:70}),jsx(YAxis,{domain:te,tickFormatter:C=>`${Math.round(C*100)}%`,axisLine:false,tickLine:false,tick:{fill:"var(--color-text-muted)",fontSize:11},width:40,tickCount:6}),jsx(Tooltip,{content:C=>jsx($g,{...C,labelMap:se,allSeries:ve,range:p,onPayload:we}),cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},wrapperStyle:{zIndex:2},isAnimationActive:false}),U.map(C=>{let O=f.get(C.marketSlug)??ao;return jsx(Line,{type:"monotone",dataKey:C.marketSlug,stroke:O,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:O},connectNulls:true,isAnimationActive:false},C.marketSlug)}),st==null&&W.length>0&&U.map(C=>{let O=W[W.length-1],z=O[C.marketSlug];if(z==null)return null;let Z=f.get(C.marketSlug)??ao;return jsx(ReferenceDot,{x:O.timestamp,y:z,ifOverflow:"extendDomain",shape:me=>{let{cx:Ne,cy:lt}=me;return Ne==null||lt==null?jsx("g",{}):jsxs("g",{children:[jsxs("circle",{cx:Ne,cy:lt,r:6,fill:Z,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:Ne,cy:lt,r:3.5,fill:Z})]})}},`pulse-${C.marketSlug}`)})]})})]})}),jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"6px 8px",marginTop:6},children:[n!=null&&n>0&&jsx("span",{style:{color:"var(--color-text-muted)",fontSize:12},children:a("predict.chart.volume",{value:formatAmountInUsd(n)})}),jsx("div",{style:{flex:1,minWidth:0}}),jsx(Wg,{value:p,onChange:d}),m.length>1&&jsx("div",{style:{width:"100%",display:"flex",alignItems:"center"},children:jsx(Vg,{markets:m,selectedSlugs:u,colorMap:f,onToggle:E})})]})]})]})}function An(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Vl(e,t){let r=e.outcomes[t==="yes"?0:1];return r?.best_ask??r?.price}function dv(e){return e===void 0?"\u2014":`${parseFloat((e*100).toFixed(2))}%`}function uv(e){if(e===void 0)return "\u2014";let t=e*100;return t<1&&t>0?"< 1":parseFloat(t.toFixed(2)).toString()}function Fn(e){return lr(e)}function pv(e){switch(e){case "polymarket":return "Polymarket";case "kalshi":return "Kalshi";default:return e}}function Ko(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 jl(e){let{formatUnit:t}=useLocalizedTimeFormatter(),[r,o]=useState(0);if(useEffect(()=>{if(!e)return;o(Date.now());let c=setInterval(()=>o(Date.now()),1e3);return ()=>clearInterval(c)},[e]),!e||r===0)return null;let n=new Date(e).getTime();if(isNaN(n))return null;let i=n-r;if(i<=0)return null;let s=Math.floor(i/864e5),a=Math.floor(i%864e5/36e5),l=Math.floor(i%36e5/6e4),m=Math.floor(i%6e4/1e3),u=[];return s>0&&u.push(t(s,"day")),u.push(t(a,"hour")),u.push(t(l,"minute")),u.push(t(m,"second")),u.join(" ")}function Gl(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?"+":"-",m=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${o} ${n}/${i}/${s} (${l}${m})`}function Vo({event:e,marketDataEnabled:t=false,marketDataOrderbooks:r,onMarketDataBookSelectionChange:o,orderbookQuotes:n,onTradeAction:i}){let{t:s}=useTranslation(),{ref:a,isCollapsed:l}=useScrollCollapse(),m=Vr(e),u=useMemo(()=>{let b=[...e.markets||[]],v=b.filter(x=>x.status==="open").sort((x,y)=>An(y)-An(x)),S=b.filter(x=>x.status!=="open").sort((x,y)=>An(y)-An(x));return [...v,...S]},[e.markets]),c=e.status==="closed"||e.status==="voided",p=jl(c?void 0:e.start_at),d=jl(c?void 0:e.end_at),f=Gl(e.start_at),g=Gl(e.end_at);return jsxs("div",{className:"w-full flex flex-col gap-y-4 lg:gap-y-6",children:[jsxs("div",{ref:a,className:`sticky top-0 z-30 flex items-center backdrop-blur-md transition-all duration-300 ${l?"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:m||s("predict.event.fallbackName"),radius:"lg",classNames:{base:"bg-transparent"},className:`flex-shrink-0 transition-all duration-300 ${l?"!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:[!l&&jsxs("div",{className:"flex items-center gap-1.5",children:[e.tags?.slice(0,3).map((b,v)=>jsxs(Fragment$1,{children:[v>0&&jsx("span",{className:"text-sm text-text-muted/50",children:"\xB7"}),jsx("span",{className:"text-sm text-text-muted truncate",children:b.label})]},b.slug)),jsx(vv,{source:e.source})]}),jsx("span",{className:`font-semibold truncate transition-all duration-300 ${l?"text-sm lg:text-base":"text-lg lg:text-xl"}`,children:m})]})]}),(p||d||c)&&jsx("div",{className:"flex items-center gap-x-2 text-xs lg:text-sm font-mono",children:c?g&&jsx("span",{className:"text-text-muted",children:s("predict.event.endedAt",{time:g})}):p?jsxs(Fragment,{children:[jsx("span",{className:"text-foreground",children:s("predict.event.beginsIn",{time:p})}),f&&jsxs(Fragment,{children:[jsx("span",{className:"text-text-muted/50",children:"\xB7"}),jsx("span",{className:"text-text-muted",children:f})]})]}):d?jsxs(Fragment,{children:[jsx("span",{className:"text-foreground",children:s("predict.event.endsIn",{time:d})}),g&&jsxs(Fragment,{children:[jsx("span",{className:"text-text-muted/50",children:"\xB7"}),jsx("span",{className:"text-text-muted",children:g})]})]}):null}),jsx(ys,{event:e,marketDataEnabled:t,volume:e.volume??void 0,orderbookQuotes:n}),jsx(mv,{markets:u,marketDataEnabled:t,marketDataOrderbooks:r,onMarketDataBookSelectionChange:o,orderbookQuotes:n,onTradeAction:i}),jsx(gv,{markets:u,event:e})]})}var Yl=5;function mv({markets:e,marketDataEnabled:t,marketDataOrderbooks:r,onMarketDataBookSelectionChange:o,orderbookQuotes:n,onTradeAction:i}){let{t:s}=useTranslation(),{isDesktop:a}=useScreen(),[l,m]=useState(false),[u,c]=useState(null),p=useMemo(()=>{let x=new Set;return e.filter(y=>x.has(y.slug)?false:(x.add(y.slug),true))},[e]),[d,f]=useState(null);if(p.length===0)return null;let g=p.length>Yl,b=l?p:p.slice(0,Yl),v=x=>{t&&o?.(Pl(u,x.slug,d?.marketSlug===x.slug?d.outcomeKey:void 0)),c(y=>y===x.slug?null:x.slug);},S=(x,y,h,k)=>{f({marketSlug:x.slug,tradeOutcome:y,outcomeKey:k}),t&&o?.(Nl(x.slug,k)),a&&c(x.slug),i?.(x,y,h);};return jsxs("div",{className:"flex flex-col",children:[jsxs("table",{className:"w-full border-collapse",children:[jsx("thead",{children:jsxs("tr",{children:[jsx("th",{}),jsx("th",{className:"py-2 text-left text-xs text-text-muted font-normal lg:text-center lg:text-sm",children:s("predict.market.table.chance")}),jsx("th",{})]})}),jsx("tbody",{children:b.map((x,y)=>{let h=u===x.slug;return jsx(fv,{market:x,activeSelection:d?.marketSlug===x.slug?d:void 0,isExpanded:h,orderbookQuotes:n,marketDataEnabled:t,marketDataOrderbooks:r,onToggleExpand:()=>v(x),onTradeAction:S,onUnselectedTradeAction:i},x.id??`${y}-${x.slug}`)})})]}),g&&jsxs("button",{type:"button",onClick:()=>m(x=>!x),className:"flex w-full items-center justify-start gap-x-2 py-2 pl-1 text-xs text-text-muted lg:pl-2 lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsx("span",{children:s(l?"predict.event.rules.collapse":"predict.event.moreMarketsLabel")}),jsx(ChevronDownIcon,{className:cn("h-4 w-4 transition-transform",l&&"rotate-180")})]})]})}function fv({market:e,activeSelection:t,isExpanded:r,orderbookQuotes:o,marketDataEnabled:n,marketDataOrderbooks:i,onToggleExpand:s,onTradeAction:a,onUnselectedTradeAction:l}){let{t:m}=useTranslation(),u=e.status==="open",c=e.volume?`${formatAmountInUsd(e.volume)} vol`:void 0,p=o?.get(Ze(e.slug,"yes"))?.bestAsk??Vl(e,"yes"),d=o?.get(Ze(e.slug,"no"))?.bestAsk??Vl(e,"no"),f=t?.tradeOutcome??"yes",g=t?.outcomeKey,b=Ml(e.outcomes).map(S=>({...S,price:S.tradeOutcome==="yes"?p:d})),v=wl({marketDataEnabled:n,marketSlug:e.slug,outcomeKey:g??"",books:i});return jsxs(Fragment,{children:[jsxs("tr",{className:"cursor-pointer border-b border-border text-xs hover:bg-content2 lg:text-base",onClick:s,role:"button",tabIndex:0,onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),s());},children:[jsx("td",{className:"py-2 pl-1 lg:pl-2",children:jsxs("div",{className:"flex items-center gap-x-1 lg:gap-x-2",children:[e.image_url&&jsx(Avatar,{src:e.image_url,name:Fn(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:Fn(e)}),c&&jsx("span",{className:"text-[8px] text-text-muted lg:text-xxs",children:c})]})]})}),jsx("td",{className:"py-2 text-left text-foreground lg:text-center",children:dv(p)}),jsx("td",{className:"py-2 pr-1 lg:pr-2",children:u?jsx("div",{className:"flex items-center justify-end gap-x-2",children:b.map(({catalogOutcome:S,tradeOutcome:x,price:y})=>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",x==="yes"?t?.outcomeKey===S.key?"bg-primary text-primary-foreground":"bg-primary/10 text-primary":t?.outcomeKey===S.key?"bg-secondary text-secondary-foreground":"bg-secondary/10 text-secondary"),onClick:h=>{h.stopPropagation(),a?.(e,x,"buy",S.key);},children:y!=null?m(x==="yes"?"predict.market.action.yes":"predict.market.action.no",{price:uv(y)}):x==="yes"&&n?`${m("predict.market.yes")} \u2014`:m(x==="yes"?"predict.market.yes":"predict.market.no")},S.key))}):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-text-muted/10 text-text-muted":e.status==="voided"?"bg-warning/10 text-warning":"bg-primary/10 text-primary"),children:e.status==="closed"?m("predict.event.status.closed"):e.status==="voided"?m("predict.event.status.voided"):m("predict.event.status.pending")})})})]}),r&&jsx("tr",{children:jsx("td",{colSpan:3,className:"pb-3",children:jsx("div",{className:"max-h-100 overflow-y-auto",children:jsx(vs,{market:e,outcome:f,onTradeAction:(S,x,y)=>{if(!g){l?.(S,x,y);return}a?.(S,x,y,g);},enabled:v.legacyEnabled,orderbook:v.orderbook})})})})]})}function gv({markets:e,event:t}){let{t:r}=useTranslation(),[o,n]=useState(false),[i,s]=useState(false),[a,l]=useState(0),m=e.filter(d=>d.rules&&d.rules.length>0||xi(d));if(m.length===0)return null;let u=m[a]??m[0],c=u.rules&&u.rules.length>0?u.rules.join(`
|
|
77
77
|
|
|
78
|
-
`):vi(u)??"";if(!c)return null;let p=c.length>200&&!o?c.slice(0,200)+"...":c;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")}),m.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:An(u)})}),jsx(DropdownMenu,{"aria-label":r("predict.event.selectRules"),selectionMode:"single",selectedKeys:[String(a)],onAction:d=>{l(Number(d)),n(false);},classNames:{list:"gap-1"},itemClasses:{base:"rounded-md px-3 h-8"},children:m.map((d,f)=>jsx(DropdownItem,{className:cn$1(f===a?"bg-content2 text-foreground":"text-text-muted","data-[hover=true]:bg-content2 data-[hover=true]:text-foreground"),children:An(d)},String(f)))})]})]}),jsx("div",{className:"text-xs text-foreground/80 lg:text-sm whitespace-pre-wrap",children:p}),c.length>200&&jsx("button",{type:"button",onClick:()=>n(d=>!d),className:"text-xs text-text-muted 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(d=>!d),className:"flex items-center justify-between w-full mt-2 text-xs font-medium text-text-muted 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 d=u.status,f=[];return u.created_at&&f.push({label:r("predict.event.timeline.created"),value:zo(u.created_at),isActive:true}),f.push({label:r("predict.event.timeline.open"),value:zo(u.start_at),isActive:d!=="pending"}),d==="voided"?f.push({label:r("predict.event.timeline.voided"),value:zo(u.closed_at??u.end_at),isActive:true}):d==="closed"?f.push({label:r("predict.event.timeline.closed"),value:zo(u.closed_at??u.end_at),isActive:true}):f.push({label:r("predict.event.timeline.close"),value:zo(u.end_at),isActive:false}),f})().map((d,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 ${d.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:d.label}),jsx("span",{className:"text-xs text-text-muted lg:text-sm",children:d.value})]})]},d.label))}),jsxs("div",{className:"flex flex-wrap items-center gap-x-3 text-xxs text-text-muted mt-2 lg:text-xs",children:[jsxs("span",{children:[jsxs("span",{className:"text-text-muted",children:[r("predict.event.id.event"),":"]})," ",jsx("span",{className:"text-foreground",children:t.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-text-muted",children:[r("predict.event.id.market"),":"]})," ",jsx("span",{className:"text-foreground",children:u.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-text-muted",children:[r("predict.event.id.source"),":"]})," ",jsx("span",{className:"text-foreground",children:lh(u.source)})]})]})]})]})}function ph({source:e}){return jsxs("span",{className:"inline-flex items-center gap-x-1 text-text-secondary",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsx("span",{className:"text-text-muted",children:"\xB7"}),e==="polymarket"?jsx(PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsx(KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}var ql="hsl(var(--heroui-content3) / 0.6)",xh="hsl(var(--heroui-content4) / 0.8)";function bh(e){return e==null?"-":formatAmountInUsd(e)}function ys({eventSlug:e,source:t,lang:r,limit:o=4,onEventClick:n,onEventHover:i}){let{t:s}=useTranslation(),{data:a,isLoading:l}=useSimilarEvents({slug:e,source:t,lang:r,limit:o});return l||!a||a.length===0?null:jsxs("div",{className:"flex flex-col gap-y-3 mt-6 px-1 lg:px-0",children:[jsx("div",{className:"-mx-1 px-1 py-1.5 lg:sticky lg:top-0 lg:z-10 lg:bg-surface-base",children:jsx("span",{style:{color:"var(--color-text-primary)",fontSize:14,fontWeight:600},children:s("predict.similar.title")})}),jsx("div",{className:"grid grid-cols-1 gap-2",children:a.map(m=>jsx(Xl,{event:m,onClick:n,onHover:i},`${m.source}-${m.slug}`))})]})}function Xl({event:e,onClick:t,onHover:r}){let{t:o}=useTranslation(),n=$r(e),i=useMemo(()=>bh(e.volume),[e.volume]);return jsxs("button",{type:"button",onClick:()=>t?.(e),onMouseEnter:s=>{s.currentTarget.style.borderColor=xh,r?.(e);},onMouseLeave:s=>{s.currentTarget.style.borderColor=ql;},style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",borderRadius:14,border:`1px solid ${ql}`,background:"hsl(var(--heroui-content2) / 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:n[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:"var(--color-text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n}),jsxs("span",{style:{fontSize:10,color:"var(--color-text-secondary)"},children:[i," ",o("predict.event.volume")]})]}),jsx(ChevronRightIcon,{width:14,height:14,className:"shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",style:{color:"var(--color-text-muted)"}})]})}var Un=100,Nh=15e3,Wn=["yes","no"];function Mh(e){return e.source??"polymarket"}function wh(e){return {market_id:e.market_slug,outcome:e.outcome,bids:e.bids,asks:e.asks,spread:e.spread}}function Eh(e){let t=e.filter(r=>r.status==="open").map(r=>({slug:r.slug,source:Mh(r)})).sort((r,o)=>r.slug.localeCompare(o.slug));return JSON.stringify(t)}function Ch(e){let t=e.filter(r=>r.status==="open").flatMap(r=>Wn.map(o=>({slug:r.slug,outcome:o}))).sort((r,o)=>{let n=r.slug.localeCompare(o.slug);return n!==0?n:r.outcome.localeCompare(o.outcome)});return JSON.stringify(t)}function Zl(e,t={}){let r=t.enabled??true,o=usePredictClient(),{wsClient:n}=usePredictWsClient(),i=useQueryClient(),s=useRef(new Set),a=useMemo(()=>r?Eh(e):"[]",[r,e]),l=useMemo(()=>JSON.parse(a),[a]),m=useMemo(()=>new Map(l.map(x=>[x.slug,x])),[l]),u=useMemo(()=>new Set(l.map(x=>x.slug)),[l]),c=useRef(u);c.current=u;let p=useRef(m);p.current=m;let d=useMemo(()=>r?Ch(e):"[]",[r,e]),f=useMemo(()=>JSON.parse(d),[d]),g=Ul(f),b=useCallback((x,y,v,k)=>{if(!k){_n(x,v);return}let N={...k,market_id:k.market_id||x,outcome:v};i.setQueryData(orderbookQueryKey(x,y,v),N),Hl(x,v,N);},[i]),h=useCallback(async(x,y)=>{try{let v=x.flatMap(N=>Wn.map(w=>({slug:N.slug,source:N.source,outcome:w}))),k=await o.getOrderbooks(v);if(y?.cancelled?.())return;for(let N of k){let w=N.outcome,P=Ze(N.slug,w);y?.markSeeded&&s.current.add(P),b(N.slug,N.source,w,N.orderbook);}}catch{if(!y?.markSeeded||y?.cancelled?.())return;for(let v of x)for(let k of Wn)s.current.add(Ze(v.slug,k));}},[b,o]);useEffect(()=>{if(!r){s.current.clear();return}let x=l.filter(v=>Wn.some(k=>!s.current.has(Ze(v.slug,k))));if(x.length===0)return;let y=false;return (async()=>{for(let v=0;v<x.length;v+=Un){if(y)return;await h(x.slice(v,v+Un),{cancelled:()=>y,markSeeded:true});}})(),()=>{y=true;}},[r,h,l]),useEffect(()=>{if(!r||l.length===0)return;let x=false,y=async()=>{for(let k=0;k<l.length;k+=Un){if(x)return;await h(l.slice(k,k+Un),{cancelled:()=>x});}},v=window.setInterval(()=>{y();},Nh);return ()=>{x=true,window.clearInterval(v);}},[r,h,l]),useEffect(()=>{s.current.forEach(x=>{let[y,v]=x.split(":");u.has(y)||(s.current.delete(x),_n(y,v));});},[u]),useEffect(()=>{if(r&&n)return n.on("orderbook",x=>{let y=x.data.market_slug,v=x.data.outcome;if(v!=="yes"&&v!=="no"||!c.current.has(y))return;let k=p.current.get(y);k&&b(y,k.source,v,wh(x.data));})},[b,r,n]);let S=useRef(new Set);return useEffect(()=>{if(!r){let k=S.current;n&&k.size>0&&n.unsubscribe(["orderbook"],Array.from(k)),S.current=new Set;return}if(!n)return;let x=S.current,y=[],v=[];u.forEach(k=>{x.has(k)||y.push(k);}),x.forEach(k=>{u.has(k)||v.push(k);}),y.length>0&&n.subscribe(["orderbook"],y),v.length>0&&n.unsubscribe(["orderbook"],v),S.current=new Set(u);},[r,u,n]),useEffect(()=>{if(n)return ()=>{let x=Array.from(S.current);x.length>0&&n.unsubscribe(["orderbook"],x),S.current=new Set;}},[n]),g}var Ah={enabled:false};function zn(e,t){return Jr(e.outcomes[0],t)??Number.NEGATIVE_INFINITY}function Kn(e,t){if(!e.outcomes?.length)return e;let r=false,o=e.outcomes.map((n,i)=>{let s=i===0?"yes":"no",a=t.get(Ze(e.slug,s));if(!a)return n;let l=a.bestBid??n.best_bid,m=a.bestAsk??n.best_ask,u=a.bestAsk??n.price;return l===n.best_bid&&m===n.best_ask&&u===n.price?n:(r=true,{...n,best_bid:l,best_ask:m,price:u})});return r?{...e,outcomes:o}:e}function Fh(e,t){if(!e.markets?.length||t.size===0)return e;let r=false,o=e.markets.map(n=>{let i=Kn(n,t);return i!==n&&(r=true),i});return r?{...e,markets:o}:e}function Bh({eventSlug:e,source:t,chain:r,lang:o,walletAddress:n,onSimilarEventClick:i,onSimilarEventHover:s,onBack:a,renderActivitySection:l,onInsufficientBalance:m,onSetupRequired:u,slippageBps:c,marketDataCapability:p=Ah,marketDataEvent:d,marketDataOrderbooks:f,onMarketDataBookSelectionChange:g}){let{t:b}=useTranslation(),{isDesktop:h}=useScreen(),{onOpen:S}=useAsyncModal(qr),{onOpen:x}=useAsyncModal(En),{data:y,isLoading:v}=useEvent({slug:e,source:t,lang:o}),k=useMemo(()=>y&&Sn({capability:p,legacyEvent:y,marketDataEvent:d}),[y,p,d]),N=useMemo(()=>{let W=[...k?.markets||[]],te=W.filter(se=>se.status==="open").sort((se,he)=>zn(he,p.enabled)-zn(se,p.enabled)),ne=W.filter(se=>se.status!=="open").sort((se,he)=>zn(he,p.enabled)-zn(se,p.enabled));return [...te,...ne]},[k?.markets,p.enabled]),w=Zl(N,{enabled:!p.enabled}),P=useMemo(()=>k&&Fh(k,w),[k,w]),M=useMemo(()=>w.size===0?N:N.map(W=>Kn(W,w)),[N,w]),[T,A]=useState(null),X=useCallback((W,te,ne)=>{let se=M.find(Pe=>Pe.slug===W.slug)??Kn(W,w),he=P??k;A(Pe=>({market:se,outcome:te,side:ne,version:(Pe?.version??0)+1})),!h&&he&&(ne==="sell"?x({params:{event:he,market:se,initialOutcome:te,chain:r,slippageBps:c,onSetupRequired:u}}):S({params:{event:he,market:se,initialOutcome:te,chain:r,slippageBps:c,onInsufficientBalance:m}}));},[h,k,P,M,w,r,c,S,x,m,u]),L=useMemo(()=>{let W=T?.market.slug;return W?M.find(te=>te.slug===W)??Kn(T.market,w):M[0]},[M,w,T?.market]);if(v){let W=!!a;return h?jsxs("div",{className:"flex w-full max-w-6xl mx-auto gap-x-4 lg:gap-x-6",children:[jsx("div",{className:"min-w-0 flex-1 max-w-3xl",children:jsx(ro,{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(cs,{})})})]}):jsx(ro,{showBack:W})}if(!y)return jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:b("predict.event.notFound")});let G=P??k??y,U=T?`${T.market.slug}-${T.version}`:L?.slug??"default",oe=T?.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:[a&&jsx("div",{className:"flex items-center justify-between",children:jsx(Button,{as:"a",onPress:a,startContent:jsx(ChevronLeftIcon,{className:"h-4 w-4"}),className:"text-text-muted bg-transparent h-5 min-h-5 gap-x-2 p-0 text-base w-auto min-w-auto",children:b("common.back")})}),jsx($o,{event:G,marketDataEnabled:p.enabled,marketDataOrderbooks:f,onMarketDataBookSelectionChange:g,orderbookQuotes:w,onTradeAction:X})]}),jsxs("div",{className:"hidden flex-none w-md flex-col gap-y-4 lg:sticky lg:top-4 lg:flex lg:self-start",children:[L&&(oe?jsx(Io,{event:G,market:L,initialOutcome:T?.outcome,chain:r,slippageBps:c,onSetupRequired:u},U):jsx(Co,{event:G,market:L,initialOutcome:T?.outcome,chain:r,slippageBps:c,onInsufficientBalance:m},U)),y&&jsx(ys,{eventSlug:e,source:G.source,lang:o,onEventClick:i,onEventHover:s})]})]}),y&&jsx("div",{className:"flex w-full flex-col",children:l?l({event:G,walletAddress:n}):jsx(ss,{event:G,walletAddress:n})}),jsx(To,{}),jsx(ts,{}),jsx(Gi,{})]})}function Wh({eventSlug:e,source:t,lang:r,onTradeAction:o}){let{t:n}=useTranslation(),{data:i,isLoading:s,error:a}=useEvent({slug:e,source:t,lang:r});return s?jsx(ro,{}):a||!i?jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:a?.message||n("predict.event.notFound")}):jsx($o,{event:i,onTradeAction:o})}function tc(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function jh(e){switch(e){case K.ONE_HOUR:return {interval:"1m",limit:100};case K.SIX_HOURS:return {interval:"5m",limit:72};case K.ONE_DAY:return {interval:"5m",limit:288};case K.ONE_MONTH:return {interval:"1h",limit:720};case K.ALL:return {interval:"1d",limit:300};default:return {interval:"1h",limit:100}}}var Gh=e=>{let{candlestickMarketSlugs:t,chartRange:r=yo,source:o}=e,n=usePredictClient(),i=useMemo(()=>jh(r),[r]),{data:s,isLoading:a,error:l}=useEvent({slug:e.eventSlug,source:o}),m=useMemo(()=>{if(!s)return [];let f=new Set,g=In(s).filter(h=>f.has(h.slug)?false:(f.add(h.slug),true));return (t&&t.length>0?t.slice(0,4).map(h=>g.find(S=>S.slug===h)).filter(h=>h!==void 0):[...g].sort((h,S)=>tc(S)-tc(h)).slice(0,4)).map(h=>h.slug)},[t,s]),u=useQueries({queries:m.map(f=>({queryKey:candlesticksQueryKey(f,i),queryFn:()=>n.listCandlesticks(f,i),enabled:m.length>0}))}),c=u.some(f=>f.isLoading),p=useMemo(()=>{let f=new Map;return m.forEach((g,b)=>{let h=u[b]?.error;h&&f.set(g,h);}),f},[m,u]),d=useMemo(()=>{let f=new Map;return m.forEach((g,b)=>{let h=u[b]?.data;h&&f.set(g,h);}),f},[m,u]);return {event:s,isEventLoading:a,eventError:l,candlestickParams:i,candlesticks:d,isCandlesticksLoading:c,candlestickErrors:p}};function Gn({comment:e,anonymousLabel:t,isReply:r=false}){let{formatAgeSince:o}=useLocalizedTimeFormatter(),{profile:n}=e,i=n.name||n.pseudonym||t,s=useMemo(()=>o(e.created_at),[e.created_at,o]);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(qh,{src:n.profile_image,name:i,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:i}),jsx("span",{className:"ml-auto shrink-0 text-xs text-text-muted",children:s})]}),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-text-muted",children:[jsx(Qh,{className:"size-3.5"}),jsx("span",{className:"text-xs tabular-nums",children:e.reaction_count})]})]})]})}function qh({src:e,name:t,className:r}){let o=t.trim().charAt(0).toUpperCase()||"?",n=useMemo(()=>Xh(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-text-primary",r),style:{backgroundColor:n},"aria-hidden":true,children:o})}function Qh({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 Xh(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%)`}var av={latest:{order:"createdAt",ascending:false},oldest:{order:"createdAt",ascending:true},mostLiked:{order:"reactionCount",ascending:false}},nc={latest:"predict.comments.sortLatest",oldest:"predict.comments.sortOldest",mostLiked:"predict.comments.sortMostLiked"},lv=["latest","oldest","mostLiked"],cv=600,dv=112;function lc({slug:e,source:t,limit:r=20,height:o,className:n}){let{t:i}=useTranslation(),[s,a]=useState("latest"),[l,m]=useState(false),u=av[s],{data:c,isLoading:p,isFetchingNextPage:d,hasNextPage:f,fetchNextPage:g}=useInfiniteComments({slug:e,source:t,limit:r,order:u.order,ascending:u.ascending,holders_only:l}),b=useMemo(()=>c?.pages?.flatMap(M=>M.items)??[],[c?.pages]),h=useRef(null),{height:S}=useResizeObserver({ref:h}),x=o??(S||cv),y=useDynamicRowHeight({defaultRowHeight:dv,key:`${e}:${t}:${s}:${l}`}),v=b.length,k=v+(f?1:0),N=useCallback(M=>M<v,[v]),w=useCallback(async()=>{f&&!d&&await g();},[f,d,g]),P=useInfiniteLoader({isRowLoaded:N,loadMoreRows:w,rowCount:k,threshold:5});return jsxs("div",{className:cn$1("flex h-full w-full flex-col",n),children:[jsx(pv,{sort:s,onSortChange:a,holdersOnly:l,onHoldersOnlyChange:m}),jsx("div",{className:"min-h-0 flex-auto overflow-hidden",ref:h,children:p?jsx(mv,{}):b.length===0?jsx(fv,{message:i("predict.comments.empty")}):jsx(List,{className:"no-scrollbar",style:{height:x},onRowsRendered:P,rowComponent:uv,rowCount:k,rowHeight:y,rowProps:{comments:b,itemCount:v,anonymousLabel:i("predict.comments.anonymous")},overscanCount:4})})]})}function uv({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(Gn,{comment:i,anonymousLabel:n,isReply:!!i.parent_comment_id})}):null}function pv({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);},m=u=>{u.key==="Escape"&&s(false);};return document.addEventListener("mousedown",l),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",m);}},[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(gv,{className:"size-3.5 text-text-muted"}),jsx("span",{children:n(nc[e])}),jsx(hv,{className:cn$1("size-3.5 text-text-muted 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:lv.map(l=>{let m=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",m?"bg-primary/10 text-primary":"text-text-muted hover:bg-content2 hover:text-foreground"),children:[jsx("span",{className:"flex-1 font-medium",children:n(nc[l])}),m&&jsx(ic,{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-text-muted hover:text-foreground"),children:[jsx("span",{className:cn$1("flex size-4 items-center justify-center rounded border",r?"border-primary bg-primary":"border-border-control"),children:r&&jsx(ic,{className:"size-3 text-background"})}),n("predict.comments.holdersOnly")]})]})}function mv(){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 fv({message:e}){return jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[jsx(EmptyIcon,{width:28,height:28,className:"text-text-muted"}),jsx("p",{className:"mt-2 text-sm text-text-muted",children:e})]})}function gv({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 hv({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 ic({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 vv=["signing","submitting","confirming","succeeded"];function xv(e){return {status:e,canSubmit:!vv.includes(e),canCancel:e!=="succeeded"&&e!=="submitting"&&e!=="confirming"}}var Nv=10,dc="liberfi:predict_search_histories";function uo(){return createBrowserSearchHistoryStorage({key:dc,fallback:createMemorySearchHistoryStorage()})}function Mv(e,t){return e.length===t.length&&e.every((r,o)=>r===t[o])}function Ps(){let e=useMemo(()=>uo(),[]),t=useRef(e.read()),r=()=>{let s=e.read();return Mv(t.current,s)?t.current:(t.current=s,s)},o=useSyncExternalStore(e.subscribe,r,r),n=useCallback(s=>{let a=s.trim();if(!a)return;let l=e.read().filter(m=>m!==a);e.write([a,...l].slice(0,Nv));},[e]),i=useCallback(()=>{e.clear();},[e]);return {histories:o,addHistory:n,clearHistories:i}}function Ns({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-text-muted",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-text-muted","border-border border-1","cursor-pointer","hover:opacity-hover"),onClick:()=>t?.(i),children:jsx("span",{children:i})},i))})]})}function Ms({onSelect:e,histories:t,onClear:r,className:o}){let n=Ps(),i=t?[...t]:n.histories,s=r??n.clearHistories;return jsx(Ns,{className:cn$1(o),histories:i,onSelect:e,onClear:s})}var Bv=["ArrowDown","ArrowUp","Enter","Escape"];function Hv(e){return Bv.includes(e)}function ws({value:e,onValueChange:t,onClear:r,onEscape:o,onNavigateKey:n,className:i}){let{t:s}=useTranslation();return jsx("div",{className:i,children:jsx(StyledInput,{autoFocus:true,variant:"bordered",radius:"lg",value:e,onValueChange:t,onKeyDown:a=>{Hv(a.key)&&(a.key!=="Escape"&&a.preventDefault(),n?.(a.key));},placeholder:s("predict.search.placeholder"),classNames:{inputWrapper:["!bg-surface-strong/60","!border-border-control/50","data-[hover=true]:!bg-surface-strong","group-data-[focus=true]:!bg-surface-strong","group-data-[focus=true]:!border-border-control/80"].join(" ")},startContent:jsx(SearchIcon,{width:20,height:20,className:"text-text-muted"}),endContent:e?jsx(Button,{isIconOnly:true,className:"bg-transparent min-w-6 w-6 h-6 text-text-muted",onPress:r,children:jsx(XCloseIcon,{width:20,height:20})}):jsx(Kbd,{className:"min-w-8 justify-center text-xs text-text-muted bg-transparent border border-border-control/50 rounded-lg cursor-pointer select-none",onMouseDown:a=>{a.preventDefault(),o?.();},children:"ESC"})})})}function Vv(e){switch(e.result_type){case "match_group":return "predict.search.type.match";case "prop_event":return "predict.search.type.prop";case "market":return "predict.search.type.market";default:return "predict.search.type.event"}}function jv({actionRef:e,...t}){return jsx("div",{ref:e,...t})}function Cs({result:e,href:t,LinkComponent:r,onSelect:o,onHover:n,highlighted:i=false,actionRef:s,className:a}){let{t:l}=useTranslation(),m=e.title,u=useMemo(()=>[l(Vv(e)),e.section,e.status].filter(Boolean).join(" \xB7 "),[e,l]),c=useMemo(()=>{function d({...f}){return jsx(r??"a",{ref:s,...f})}return d},[r,s]),p=useMemo(()=>{function d(f){return jsx(jv,{...f,actionRef:s})}return d},[s]);return jsxs(Linkable,{href:t,LinkComponent:c,as:p,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&&"bg-content2",a),"data-highlighted":i?"true":"false","aria-selected":i,onClick:d=>{t&&o&&d.preventDefault(),o?.(e);},onMouseEnter:()=>n?.(e),children:[jsx(Avatar,{src:void 0,name:m||l("predict.event.fallbackName"),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:m}),jsx("div",{className:"flex items-center gap-x-2 text-[10px] font-normal text-text-muted lg:text-xs",children:jsx("span",{className:"text-text-secondary",children:u||l("predict.search.title")})})]}),jsx(ChevronRightIcon,{width:16,height:16,className:"shrink-0 text-text-muted opacity-0 group-hover:opacity-100 transition-opacity"})]})}function Ts({keyword:e="",limit:t,source:r}){let{data:o,isLoading:n,isFetchingNextPage:i,hasNextPage:s,fetchNextPage:a}=useInfinitePredictSearch({q:e,limit:t,source:r,sort_by:e?void 0:"volume",sort_asc:e?void 0:false},{enabled:true}),l=useMemo(()=>o?.pages.flatMap(m=>m.items).filter(m=>m!=null)??[],[o]);return {results:l,items:l,isLoading:n,isFetchingNextPage:i,hasNextPage:s??false,fetchNextPage:a}}var ox=64;function Ls({onSelect:e,getEventHref:t,LinkComponent:r,onHover:o,className:n,navigationRef:i,onEscape:s,...a}){let{results:l,isLoading:m,isFetchingNextPage:u,hasNextPage:c,fetchNextPage:p}=Ts(a),d=useRef(null),{height:f}=useResizeObserver({ref:d}),g=useRef(null),[b,h]=useState(null),S=useRef(null);S.current=b;let x=a.keyword??"",y=x==="",v=y||m?0:l.length,k=useCallback(L=>L<l.length,[l]),N=useCallback(async()=>{c&&!u&&await p();},[c,u,p]),w=useMemo(()=>c?l.length+1:l.length,[l,c]),P=useInfiniteLoader({isRowLoaded:k,loadMoreRows:N,rowCount:w,threshold:5}),M=useCallback(()=>{S.current=null,h(null);},[]),T=useCallback(L=>{if(L<0||L>=l.length){M();return}S.current=L,h(L),g.current?.scrollToRow({index:L,align:"smart",behavior:"auto"});},[M,g,l.length]),A=useSearchKeyboardNavigation({itemCount:v,hasNextPage:c&&!y&&!m,isFetchingNextPage:u,onSelectIndex:L=>{T(L);},onRequestNextPage:()=>{c&&!u&&p();},onEscape:()=>s?.()});i&&(i.current=A),useEffect(()=>()=>{i&&i.current===A&&(i.current=null);},[A,i]),useEffect(()=>(A.reset(),M(),()=>{M();}),[x,A,M]);let X=useCallback(L=>S.current!==L?false:(S.current=null,h(null),true),[]);return m?jsx(ix,{className:n}):l.length===0?jsx(sx,{className:n}):jsx("div",{className:cn$1("w-full h-full flex flex-col",n),children:jsx("div",{className:"flex-auto min-h-0",ref:d,children:jsx(List,{className:"no-scrollbar",style:{height:f},listRef:g,onRowsRendered:P,rowComponent:nx,rowCount:w,rowHeight:ox,rowProps:{results:l,onSelect:e,getEventHref:t,LinkComponent:r,onHover:o,highlightedIndex:y?null:A.highlightedIndex,pendingIndex:y?null:b,consumePending:X},overscanCount:5})})})}function nx({index:e,style:t,results:r,onSelect:o,getEventHref:n,LinkComponent:i,onHover:s,highlightedIndex:a,pendingIndex:l,consumePending:m}){let u=r[e],c=useRef(null);return useLayoutEffect(()=>{l===e&&m(e)&&c.current?.click();},[m,e,l]),u?jsx("div",{style:t,"data-index":e,children:jsx(Cs,{result:u,href:n?.(u)??u.detail_url,LinkComponent:i,onSelect:o,onHover:s,highlighted:a===e,actionRef:c})}):jsx("div",{style:t,className:"flex items-center justify-center",children:jsx(Spinner,{size:"sm"})})}function ix({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-text-muted",children:t("predict.search.loading")})]})}function sx({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-text-muted"}),jsx("p",{className:"mt-2 text-sm text-text-muted",children:t("predict.search.noResults")})]})}var xc=()=>{};function _s({onKeywordChange:e,onSelectResult:t,getEventHref:r,LinkComponent:o,onHover:n,onEscape:i,source:s}){let a=useMemo(()=>uo(),[]),l=useSearchController({storage:a,onQueryChange:e??xc,onDismiss:i??xc}),m=useRef(null),u=l.dismiss,c=useCallback(p=>{if(m.current){m.current.onKey(p);return}p==="Escape"&&u();},[u]);return jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsx(ws,{value:l.text,onValueChange:l.setText,onClear:l.clearQuery,onEscape:l.dismiss,onNavigateKey:c}),!l.query&&jsx(Ms,{histories:l.history,onSelect:l.commitQuery,onClear:l.clearHistory}),jsx(Ls,{className:"flex-auto min-h-0",keyword:l.query,onSelect:t,getEventHref:r,LinkComponent:o,onHover:n,source:s,navigationRef:m,onEscape:l.dismiss})]})}var Qn="predict-search";function kx({id:e=Qn}){return jsx(AsyncModal,{id:e,children:t=>jsx(Sx,{...t})})}function Sx({params:e,isOpen:t,onOpenChange:r,onResult:o}){let{t:n}=useTranslation(),{isMobile:i}=useScreen(),s=useCallback(l=>{o(l);},[o]),a=useCallback(()=>{r(false);},[r]);return jsx(StyledModal,{isOpen:t,onOpenChange:r,size:i?"full":"lg",hideCloseButton:true,backdrop:"opaque",radius:"lg",children:jsxs(ModalContent,{className:"w-full h-full",style:{borderRadius:i?void 0:14,border:i?void 0:"1px solid var(--color-border-control)",background:"var(--color-surface-interactive)",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(_s,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectResult:s,onEscape:a})})]})})}function Cx({onSelectEvent:e,modalParams:t,className:r}){let{t:o}=useTranslation(),{isDesktop:n}=useScreen(),{onOpen:i,onClose:s}=useAsyncModal(Qn),a=useCallbackRef(e),l=useCallbackRef(async()=>{let u=await i({params:t});u&&a(u);}),m=useCallbackRef(()=>{s();});return useEffect(()=>{let u=c=>{let p=document.activeElement,d=!!p&&(p.tagName==="INPUT"||p.tagName==="TEXTAREA"||p.getAttribute("contenteditable")==="true");c.key==="/"&&!d&&(c.preventDefault(),l()),c.key==="Escape"&&(c.preventDefault(),m());};return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u);}},[l,m]),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-text-muted",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 Nc=()=>{};function Lx({onKeywordChange:e}){let t=useMemo(()=>uo(),[]),r=useSearchController({storage:t,onQueryChange:e??Nc,onDismiss:Nc});return {text:r.text,keyword:r.query,setText:r.setText,setKeyword:r.commitQuery,clearKeyword:r.clearQuery}}var Ds=[{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"}],Rc=[{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}],Ec={display:"inline-flex",alignItems:"center",gap:8,borderRadius:10,border:"1px solid var(--color-border-subtle)",background:"hsl(var(--heroui-content3) / 0.6)",padding:"8px 12px",fontSize:14,color:"var(--color-text-primary)",cursor:"pointer",transition:"all 0.15s"},Cc={position:"absolute",right:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid var(--color-border-control)",background:"var(--color-surface-interactive)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function Ix(e,t){if(!e)return "$5K+";let r=Rc.find(o=>o.value===e);return r?r.labelKey?t(r.labelKey):r.label:`$${e}`}function As({sortBy:e,onSortChange:t,sortAsc:r,onSortAscChange:o,minVolume:n,onMinVolumeChange:i,onRefresh:s}){let{t:a}=useTranslation(),[l,m]=useState(false),[u,c]=useState(false),[p,d]=useState(false),[f,g]=useState(false),b=useRef(null),h=useRef(null),S=Ds.find(v=>v.value===e)??Ds[0],x=useCallback(v=>{b.current&&!b.current.contains(v.target)&&m(false),h.current&&!h.current.contains(v.target)&&c(false);},[]);useEffect(()=>(document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)),[x]);let y=useCallback(()=>{s?.(),g(true),setTimeout(()=>g(false),700);},[s]);return jsxs(Fragment,{children:[jsx("style",{children:`
|
|
78
|
+
`):xi(u)??"";if(!c)return null;let p=c.length>200&&!o?c.slice(0,200)+"...":c;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")}),m.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:Fn(u)})}),jsx(DropdownMenu,{"aria-label":r("predict.event.selectRules"),selectionMode:"single",selectedKeys:[String(a)],onAction:d=>{l(Number(d)),n(false);},classNames:{list:"gap-1"},itemClasses:{base:"rounded-md px-3 h-8"},children:m.map((d,f)=>jsx(DropdownItem,{className:cn(f===a?"bg-content2 text-foreground":"text-text-muted","data-[hover=true]:bg-content2 data-[hover=true]:text-foreground"),children:Fn(d)},String(f)))})]})]}),jsx("div",{className:"text-xs text-foreground/80 lg:text-sm whitespace-pre-wrap",children:p}),c.length>200&&jsx("button",{type:"button",onClick:()=>n(d=>!d),className:"text-xs text-text-muted 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(d=>!d),className:"flex items-center justify-between w-full mt-2 text-xs font-medium text-text-muted 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:Ko(u.created_at),isActive:true}),f.push({label:r("predict.event.timeline.open"),value:Ko(u.start_at),isActive:d!=="pending"}),d==="voided"?f.push({label:r("predict.event.timeline.voided"),value:Ko(u.closed_at??u.end_at),isActive:true}):d==="closed"?f.push({label:r("predict.event.timeline.closed"),value:Ko(u.closed_at??u.end_at),isActive:true}):f.push({label:r("predict.event.timeline.close"),value:Ko(u.end_at),isActive:false}),f})().map((d,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 ${d.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:d.label}),jsx("span",{className:"text-xs text-text-muted lg:text-sm",children:d.value})]})]},d.label))}),jsxs("div",{className:"flex flex-wrap items-center gap-x-3 text-xxs text-text-muted mt-2 lg:text-xs",children:[jsxs("span",{children:[jsxs("span",{className:"text-text-muted",children:[r("predict.event.id.event"),":"]})," ",jsx("span",{className:"text-foreground",children:t.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-text-muted",children:[r("predict.event.id.market"),":"]})," ",jsx("span",{className:"text-foreground",children:u.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-text-muted",children:[r("predict.event.id.source"),":"]})," ",jsx("span",{className:"text-foreground",children:pv(u.source)})]})]})]})]})}function vv({source:e}){return jsxs("span",{className:"inline-flex items-center gap-x-1 text-text-secondary",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsx("span",{className:"text-text-muted",children:"\xB7"}),e==="polymarket"?jsx(PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsx(KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}var Xl="hsl(var(--heroui-content3) / 0.6)",Sv="hsl(var(--heroui-content4) / 0.8)";function Pv(e){return e==null?"-":formatAmountInUsd(e)}function Ss({eventSlug:e,source:t,lang:r,limit:o=4,onEventClick:n,onEventHover:i}){let{t:s}=useTranslation(),{data:a,isLoading:l}=useSimilarEvents({slug:e,source:t,lang:r,limit:o});return l||!a||a.length===0?null:jsxs("div",{className:"flex flex-col gap-y-3 mt-6 px-1 lg:px-0",children:[jsx("div",{className:"-mx-1 px-1 py-1.5 lg:sticky lg:top-0 lg:z-10 lg:bg-surface-base",children:jsx("span",{style:{color:"var(--color-text-primary)",fontSize:14,fontWeight:600},children:s("predict.similar.title")})}),jsx("div",{className:"grid grid-cols-1 gap-2",children:a.map(m=>jsx(Zl,{event:m,onClick:n,onHover:i},`${m.source}-${m.slug}`))})]})}function Zl({event:e,onClick:t,onHover:r}){let{t:o}=useTranslation(),n=Vr(e),i=useMemo(()=>Pv(e.volume),[e.volume]);return jsxs("button",{type:"button",onClick:()=>t?.(e),onMouseEnter:s=>{s.currentTarget.style.borderColor=Sv,r?.(e);},onMouseLeave:s=>{s.currentTarget.style.borderColor=Xl;},style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",borderRadius:14,border:`1px solid ${Xl}`,background:"hsl(var(--heroui-content2) / 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:n[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:"var(--color-text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n}),jsxs("span",{style:{fontSize:10,color:"var(--color-text-secondary)"},children:[i," ",o("predict.event.volume")]})]}),jsx(ChevronRightIcon,{width:14,height:14,className:"shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",style:{color:"var(--color-text-muted)"}})]})}var Wn=100,Cv=15e3,zn=["yes","no"];function Tv(e){return e.source??"polymarket"}function Rv(e){return {market_id:e.market_slug,outcome:e.outcome,bids:e.bids,asks:e.asks,spread:e.spread}}function Lv(e){let t=e.filter(r=>r.status==="open").map(r=>({slug:r.slug,source:Tv(r)})).sort((r,o)=>r.slug.localeCompare(o.slug));return JSON.stringify(t)}function Ov(e){let t=e.filter(r=>r.status==="open").flatMap(r=>zn.map(o=>({slug:r.slug,outcome:o}))).sort((r,o)=>{let n=r.slug.localeCompare(o.slug);return n!==0?n:r.outcome.localeCompare(o.outcome)});return JSON.stringify(t)}function tc(e,t={}){let r=t.enabled??true,o=usePredictClient(),{wsClient:n}=usePredictWsClient(),i=useQueryClient(),s=useRef(new Set),a=useMemo(()=>r?Lv(e):"[]",[r,e]),l=useMemo(()=>JSON.parse(a),[a]),m=useMemo(()=>new Map(l.map(x=>[x.slug,x])),[l]),u=useMemo(()=>new Set(l.map(x=>x.slug)),[l]),c=useRef(u);c.current=u;let p=useRef(m);p.current=m;let d=useMemo(()=>r?Ov(e):"[]",[r,e]),f=useMemo(()=>JSON.parse(d),[d]),g=zl(f),b=useCallback((x,y,h,k)=>{if(!k){In(x,h);return}let N={...k,market_id:k.market_id||x,outcome:h};i.setQueryData(orderbookQueryKey(x,y,h),N),Wl(x,h,N);},[i]),v=useCallback(async(x,y)=>{try{let h=x.flatMap(N=>zn.map(w=>({slug:N.slug,source:N.source,outcome:w}))),k=await o.getOrderbooks(h);if(y?.cancelled?.())return;for(let N of k){let w=N.outcome,P=Ze(N.slug,w);y?.markSeeded&&s.current.add(P),b(N.slug,N.source,w,N.orderbook);}}catch{if(!y?.markSeeded||y?.cancelled?.())return;for(let h of x)for(let k of zn)s.current.add(Ze(h.slug,k));}},[b,o]);useEffect(()=>{if(!r){s.current.clear();return}let x=l.filter(h=>zn.some(k=>!s.current.has(Ze(h.slug,k))));if(x.length===0)return;let y=false;return (async()=>{for(let h=0;h<x.length;h+=Wn){if(y)return;await v(x.slice(h,h+Wn),{cancelled:()=>y,markSeeded:true});}})(),()=>{y=true;}},[r,v,l]),useEffect(()=>{if(!r||l.length===0)return;let x=false,y=async()=>{for(let k=0;k<l.length;k+=Wn){if(x)return;await v(l.slice(k,k+Wn),{cancelled:()=>x});}},h=window.setInterval(()=>{y();},Cv);return ()=>{x=true,window.clearInterval(h);}},[r,v,l]),useEffect(()=>{s.current.forEach(x=>{let[y,h]=x.split(":");u.has(y)||(s.current.delete(x),In(y,h));});},[u]),useEffect(()=>{if(r&&n)return n.on("orderbook",x=>{let y=x.data.market_slug,h=x.data.outcome;if(h!=="yes"&&h!=="no"||!c.current.has(y))return;let k=p.current.get(y);k&&b(y,k.source,h,Rv(x.data));})},[b,r,n]);let S=useRef(new Set);return useEffect(()=>{if(!r){let k=S.current;n&&k.size>0&&n.unsubscribe(["orderbook"],Array.from(k)),S.current=new Set;return}if(!n)return;let x=S.current,y=[],h=[];u.forEach(k=>{x.has(k)||y.push(k);}),x.forEach(k=>{u.has(k)||h.push(k);}),y.length>0&&n.subscribe(["orderbook"],y),h.length>0&&n.unsubscribe(["orderbook"],h),S.current=new Set(u);},[r,u,n]),useEffect(()=>{if(n)return ()=>{let x=Array.from(S.current);x.length>0&&n.unsubscribe(["orderbook"],x),S.current=new Set;}},[n]),g}var Uv={enabled:false};function Kn(e,t){return Zr(e.outcomes[0],t)??Number.NEGATIVE_INFINITY}function $n(e,t){if(!e.outcomes?.length)return e;let r=false,o=e.outcomes.map((n,i)=>{let s=i===0?"yes":"no",a=t.get(Ze(e.slug,s));if(!a)return n;let l=a.bestBid??n.best_bid,m=a.bestAsk??n.best_ask,u=a.bestAsk??n.price;return l===n.best_bid&&m===n.best_ask&&u===n.price?n:(r=true,{...n,best_bid:l,best_ask:m,price:u})});return r?{...e,outcomes:o}:e}function Wv(e,t){if(!e.markets?.length||t.size===0)return e;let r=false,o=e.markets.map(n=>{let i=$n(n,t);return i!==n&&(r=true),i});return r?{...e,markets:o}:e}function zv({eventSlug:e,source:t,chain:r,lang:o,walletAddress:n,onSimilarEventClick:i,onSimilarEventHover:s,onBack:a,renderActivitySection:l,onInsufficientBalance:m,onSetupRequired:u,slippageBps:c,marketDataCapability:p=Uv,marketDataEvent:d,marketDataOrderbooks:f,onMarketDataBookSelectionChange:g}){let{t:b}=useTranslation(),{isDesktop:v}=useScreen(),{onOpen:S}=useAsyncModal(Qr),{onOpen:x}=useAsyncModal(Cn),{data:y,isLoading:h}=useEvent({slug:e,source:t,lang:o}),k=useMemo(()=>y&&Pn({capability:p,legacyEvent:y,marketDataEvent:d}),[y,p,d]),N=useMemo(()=>{let W=[...k?.markets||[]],te=W.filter(se=>se.status==="open").sort((se,ve)=>Kn(ve,p.enabled)-Kn(se,p.enabled)),ne=W.filter(se=>se.status!=="open").sort((se,ve)=>Kn(ve,p.enabled)-Kn(se,p.enabled));return [...te,...ne]},[k?.markets,p.enabled]),w=tc(N,{enabled:!p.enabled}),P=useMemo(()=>k&&Wv(k,w),[k,w]),M=useMemo(()=>w.size===0?N:N.map(W=>$n(W,w)),[N,w]),[T,A]=useState(null),X=useCallback((W,te,ne)=>{let se=M.find(Pe=>Pe.slug===W.slug)??$n(W,w),ve=P??k;A(Pe=>({market:se,outcome:te,side:ne,version:(Pe?.version??0)+1})),!v&&ve&&(ne==="sell"?x({params:{event:ve,market:se,initialOutcome:te,chain:r,slippageBps:c,onSetupRequired:u}}):S({params:{event:ve,market:se,initialOutcome:te,chain:r,slippageBps:c,onInsufficientBalance:m}}));},[v,k,P,M,w,r,c,S,x,m,u]),L=useMemo(()=>{let W=T?.market.slug;return W?M.find(te=>te.slug===W)??$n(T.market,w):M[0]},[M,w,T?.market]);if(h){let W=!!a;return v?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(oo,{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(oo,{showBack:W})}if(!y)return jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:b("predict.event.notFound")});let G=P??k??y,U=T?`${T.market.slug}-${T.version}`:L?.slug??"default",oe=T?.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:[a&&jsx("div",{className:"flex items-center justify-between",children:jsx(Button,{as:"a",onPress:a,startContent:jsx(ChevronLeftIcon,{className:"h-4 w-4"}),className:"text-text-muted bg-transparent h-5 min-h-5 gap-x-2 p-0 text-base w-auto min-w-auto",children:b("common.back")})}),jsx(Vo,{event:G,marketDataEnabled:p.enabled,marketDataOrderbooks:f,onMarketDataBookSelectionChange:g,orderbookQuotes:w,onTradeAction:X})]}),jsxs("div",{className:"hidden flex-none w-md flex-col gap-y-4 lg:sticky lg:top-4 lg:flex lg:self-start",children:[L&&(oe?jsx(Do,{event:G,market:L,initialOutcome:T?.outcome,chain:r,slippageBps:c,onSetupRequired:u},U):jsx(To,{event:G,market:L,initialOutcome:T?.outcome,chain:r,slippageBps:c,onInsufficientBalance:m},U)),y&&jsx(Ss,{eventSlug:e,source:G.source,lang:o,onEventClick:i,onEventHover:s})]})]}),y&&jsx("div",{className:"flex w-full flex-col",children:l?l({event:G,walletAddress:n}):jsx(ls,{event:G,walletAddress:n})}),jsx(Ro,{}),jsx(os,{}),jsx(qi,{})]})}function Vv({eventSlug:e,source:t,lang:r,onTradeAction:o}){let{t:n}=useTranslation(),{data:i,isLoading:s,error:a}=useEvent({slug:e,source:t,lang:r});return s?jsx(oo,{}):a||!i?jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:a?.message||n("predict.event.notFound")}):jsx(Vo,{event:i,onTradeAction:o})}function oc(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Qv(e){switch(e){case K.ONE_HOUR:return {interval:"1m",limit:100};case K.SIX_HOURS:return {interval:"5m",limit:72};case K.ONE_DAY:return {interval:"5m",limit:288};case K.ONE_MONTH:return {interval:"1h",limit:720};case K.ALL:return {interval:"1d",limit:300};default:return {interval:"1h",limit:100}}}var Xv=e=>{let{candlestickMarketSlugs:t,chartRange:r=ko,source:o}=e,n=usePredictClient(),i=useMemo(()=>Qv(r),[r]),{data:s,isLoading:a,error:l}=useEvent({slug:e.eventSlug,source:o}),m=useMemo(()=>{if(!s)return [];let f=new Set,g=Dn(s).filter(v=>f.has(v.slug)?false:(f.add(v.slug),true));return (t&&t.length>0?t.slice(0,4).map(v=>g.find(S=>S.slug===v)).filter(v=>v!==void 0):[...g].sort((v,S)=>oc(S)-oc(v)).slice(0,4)).map(v=>v.slug)},[t,s]),u=useQueries({queries:m.map(f=>({queryKey:candlesticksQueryKey(f,i),queryFn:()=>n.listCandlesticks(f,i),enabled:m.length>0}))}),c=u.some(f=>f.isLoading),p=useMemo(()=>{let f=new Map;return m.forEach((g,b)=>{let v=u[b]?.error;v&&f.set(g,v);}),f},[m,u]),d=useMemo(()=>{let f=new Map;return m.forEach((g,b)=>{let v=u[b]?.data;v&&f.set(g,v);}),f},[m,u]);return {event:s,isEventLoading:a,eventError:l,candlestickParams:i,candlesticks:d,isCandlesticksLoading:c,candlestickErrors:p}};function Yn({comment:e,anonymousLabel:t,isReply:r=false}){let{formatAgeSince:o}=useLocalizedTimeFormatter(),{profile:n}=e,i=n.name||n.pseudonym||t,s=useMemo(()=>o(e.created_at),[e.created_at,o]);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(Zv,{src:n.profile_image,name:i,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:i}),jsx("span",{className:"ml-auto shrink-0 text-xs text-text-muted",children:s})]}),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-text-muted",children:[jsx(eh,{className:"size-3.5"}),jsx("span",{className:"text-xs tabular-nums",children:e.reaction_count})]})]})]})}function Zv({src:e,name:t,className:r}){let o=t.trim().charAt(0).toUpperCase()||"?",n=useMemo(()=>th(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-text-primary",r),style:{backgroundColor:n},"aria-hidden":true,children:o})}function eh({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 th(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%)`}var uh={latest:{order:"createdAt",ascending:false},oldest:{order:"createdAt",ascending:true},mostLiked:{order:"reactionCount",ascending:false}},sc={latest:"predict.comments.sortLatest",oldest:"predict.comments.sortOldest",mostLiked:"predict.comments.sortMostLiked"},ph=["latest","oldest","mostLiked"],mh=600,fh=112;function dc({slug:e,source:t,limit:r=20,height:o,className:n}){let{t:i}=useTranslation(),[s,a]=useState("latest"),[l,m]=useState(false),u=uh[s],{data:c,isLoading:p,isFetchingNextPage:d,hasNextPage:f,fetchNextPage:g}=useInfiniteComments({slug:e,source:t,limit:r,order:u.order,ascending:u.ascending,holders_only:l}),b=useMemo(()=>c?.pages?.flatMap(M=>M.items)??[],[c?.pages]),v=useRef(null),{height:S}=useResizeObserver({ref:v}),x=o??(S||mh),y=useDynamicRowHeight({defaultRowHeight:fh,key:`${e}:${t}:${s}:${l}`}),h=b.length,k=h+(f?1:0),N=useCallback(M=>M<h,[h]),w=useCallback(async()=>{f&&!d&&await g();},[f,d,g]),P=useInfiniteLoader({isRowLoaded:N,loadMoreRows:w,rowCount:k,threshold:5});return jsxs("div",{className:cn("flex h-full w-full flex-col",n),children:[jsx(vh,{sort:s,onSortChange:a,holdersOnly:l,onHoldersOnlyChange:m}),jsx("div",{className:"min-h-0 flex-auto overflow-hidden",ref:v,children:p?jsx(hh,{}):b.length===0?jsx(xh,{message:i("predict.comments.empty")}):jsx(List,{className:"no-scrollbar",style:{height:x},onRowsRendered:P,rowComponent:gh,rowCount:k,rowHeight:y,rowProps:{comments:b,itemCount:h,anonymousLabel:i("predict.comments.anonymous")},overscanCount:4})})]})}function gh({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(Yn,{comment:i,anonymousLabel:n,isReply:!!i.parent_comment_id})}):null}function vh({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);},m=u=>{u.key==="Escape"&&s(false);};return document.addEventListener("mousedown",l),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",m);}},[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(bh,{className:"size-3.5 text-text-muted"}),jsx("span",{children:n(sc[e])}),jsx(yh,{className:cn("size-3.5 text-text-muted 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:ph.map(l=>{let m=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",m?"bg-primary/10 text-primary":"text-text-muted hover:bg-content2 hover:text-foreground"),children:[jsx("span",{className:"flex-1 font-medium",children:n(sc[l])}),m&&jsx(ac,{className:"size-4 text-primary"})]},l)})})]}),jsxs("button",{type:"button",role:"switch","aria-checked":r,onClick:()=>o(!r),className:cn("inline-flex items-center gap-x-1.5 rounded-lg border px-3 py-1.5 text-sm transition-colors cursor-pointer",r?"border-primary/40 bg-primary/10 text-primary":"border-border bg-content2/40 text-text-muted hover:text-foreground"),children:[jsx("span",{className:cn("flex size-4 items-center justify-center rounded border",r?"border-primary bg-primary":"border-border-control"),children:r&&jsx(ac,{className:"size-3 text-background"})}),n("predict.comments.holdersOnly")]})]})}function hh(){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 xh({message:e}){return jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[jsx(EmptyIcon,{width:28,height:28,className:"text-text-muted"}),jsx("p",{className:"mt-2 text-sm text-text-muted",children:e})]})}function bh({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 yh({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 ac({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 kh=["signing","submitting","confirming","succeeded"];function Sh(e){return {status:e,canSubmit:!kh.includes(e),canCancel:e!=="succeeded"&&e!=="submitting"&&e!=="confirming"}}var Ch=10,pc="liberfi:predict_search_histories";function po(){return createBrowserSearchHistoryStorage({key:pc,fallback:createMemorySearchHistoryStorage()})}function Th(e,t){return e.length===t.length&&e.every((r,o)=>r===t[o])}function Ms(){let e=useMemo(()=>po(),[]),t=useRef(e.read()),r=()=>{let s=e.read();return Th(t.current,s)?t.current:(t.current=s,s)},o=useSyncExternalStore(e.subscribe,r,r),n=useCallback(s=>{let a=s.trim();if(!a)return;let l=e.read().filter(m=>m!==a);e.write([a,...l].slice(0,Ch));},[e]),i=useCallback(()=>{e.clear();},[e]);return {histories:o,addHistory:n,clearHistories:i}}function ws({histories:e,onSelect:t,onClear:r,className:o}){let{t:n}=useTranslation();return e.length===0?null:jsxs("div",{className:cn("px-4 pb-4",o),children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-medium",children:n("predict.search.history")}),jsx(Button,{isIconOnly:true,size:"sm",className:"bg-transparent min-w-6 w-6 h-6 text-text-muted",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-text-muted","border-border border-1","cursor-pointer","hover:opacity-hover"),onClick:()=>t?.(i),children:jsx("span",{children:i})},i))})]})}function Es({onSelect:e,histories:t,onClear:r,className:o}){let n=Ms(),i=t?[...t]:n.histories,s=r??n.clearHistories;return jsx(ws,{className:cn(o),histories:i,onSelect:e,onClear:s})}var zh=["ArrowDown","ArrowUp","Enter","Escape"];function Kh(e){return zh.includes(e)}function Cs({value:e,onValueChange:t,onClear:r,onEscape:o,onNavigateKey:n,className:i}){let{t:s}=useTranslation();return jsx("div",{className:i,children:jsx(StyledInput,{autoFocus:true,variant:"bordered",radius:"lg",value:e,onValueChange:t,onKeyDown:a=>{Kh(a.key)&&(a.key!=="Escape"&&a.preventDefault(),n?.(a.key));},placeholder:s("predict.search.placeholder"),classNames:{inputWrapper:["!bg-surface-strong/60","!border-border-control/50","data-[hover=true]:!bg-surface-strong","group-data-[focus=true]:!bg-surface-strong","group-data-[focus=true]:!border-border-control/80"].join(" ")},startContent:jsx(SearchIcon,{width:20,height:20,className:"text-text-muted"}),endContent:e?jsx(Button,{isIconOnly:true,className:"bg-transparent min-w-6 w-6 h-6 text-text-muted",onPress:r,children:jsx(XCloseIcon,{width:20,height:20})}):jsx(Kbd,{className:"min-w-8 justify-center text-xs text-text-muted bg-transparent border border-border-control/50 rounded-lg cursor-pointer select-none",onMouseDown:a=>{a.preventDefault(),o?.();},children:"ESC"})})})}function qh(e){switch(e.result_type){case "match_group":return "predict.search.type.match";case "prop_event":return "predict.search.type.prop";case "market":return "predict.search.type.market";default:return "predict.search.type.event"}}function Qh({actionRef:e,...t}){return jsx("div",{ref:e,...t})}function Rs({result:e,href:t,LinkComponent:r,onSelect:o,onHover:n,highlighted:i=false,actionRef:s,className:a}){let{t:l}=useTranslation(),m=e.title,u=useMemo(()=>[l(qh(e)),e.section,e.status].filter(Boolean).join(" \xB7 "),[e,l]),c=useMemo(()=>{function d({...f}){return jsx(r??"a",{ref:s,...f})}return d},[r,s]),p=useMemo(()=>{function d(f){return jsx(Qh,{...f,actionRef:s})}return d},[s]);return jsxs(Linkable,{href:t,LinkComponent:c,as:p,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&&"bg-content2",a),"data-highlighted":i?"true":"false","aria-selected":i,onClick:d=>{t&&o&&d.preventDefault(),o?.(e);},onMouseEnter:()=>n?.(e),children:[jsx(Avatar,{src:void 0,name:m||l("predict.event.fallbackName"),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:m}),jsx("div",{className:"flex items-center gap-x-2 text-[10px] font-normal text-text-muted lg:text-xs",children:jsx("span",{className:"text-text-secondary",children:u||l("predict.search.title")})})]}),jsx(ChevronRightIcon,{width:16,height:16,className:"shrink-0 text-text-muted opacity-0 group-hover:opacity-100 transition-opacity"})]})}function Ls({keyword:e="",limit:t,source:r}){let{data:o,isLoading:n,isFetchingNextPage:i,hasNextPage:s,fetchNextPage:a}=useInfinitePredictSearch({q:e,limit:t,source:r,sort_by:e?void 0:"volume",sort_asc:e?void 0:false},{enabled:true}),l=useMemo(()=>o?.pages.flatMap(m=>m.items).filter(m=>m!=null)??[],[o]);return {results:l,items:l,isLoading:n,isFetchingNextPage:i,hasNextPage:s??false,fetchNextPage:a}}var ax=64;function _s({onSelect:e,getEventHref:t,LinkComponent:r,onHover:o,className:n,navigationRef:i,onEscape:s,...a}){let{results:l,isLoading:m,isFetchingNextPage:u,hasNextPage:c,fetchNextPage:p}=Ls(a),d=useRef(null),{height:f}=useResizeObserver({ref:d}),g=useRef(null),[b,v]=useState(null),S=useRef(null);S.current=b;let x=a.keyword??"",y=x==="",h=y||m?0:l.length,k=useCallback(L=>L<l.length,[l]),N=useCallback(async()=>{c&&!u&&await p();},[c,u,p]),w=useMemo(()=>c?l.length+1:l.length,[l,c]),P=useInfiniteLoader({isRowLoaded:k,loadMoreRows:N,rowCount:w,threshold:5}),M=useCallback(()=>{S.current=null,v(null);},[]),T=useCallback(L=>{if(L<0||L>=l.length){M();return}S.current=L,v(L),g.current?.scrollToRow({index:L,align:"smart",behavior:"auto"});},[M,g,l.length]),A=useSearchKeyboardNavigation({itemCount:h,hasNextPage:c&&!y&&!m,isFetchingNextPage:u,onSelectIndex:L=>{T(L);},onRequestNextPage:()=>{c&&!u&&p();},onEscape:()=>s?.()});i&&(i.current=A),useEffect(()=>()=>{i&&i.current===A&&(i.current=null);},[A,i]),useEffect(()=>(A.reset(),M(),()=>{M();}),[x,A,M]);let X=useCallback(L=>S.current!==L?false:(S.current=null,v(null),true),[]);return m?jsx(cx,{className:n}):l.length===0?jsx(dx,{className:n}):jsx("div",{className:cn("w-full h-full flex flex-col",n),children:jsx("div",{className:"flex-auto min-h-0",ref:d,children:jsx(List,{className:"no-scrollbar",style:{height:f},listRef:g,onRowsRendered:P,rowComponent:lx,rowCount:w,rowHeight:ax,rowProps:{results:l,onSelect:e,getEventHref:t,LinkComponent:r,onHover:o,highlightedIndex:y?null:A.highlightedIndex,pendingIndex:y?null:b,consumePending:X},overscanCount:5})})})}function lx({index:e,style:t,results:r,onSelect:o,getEventHref:n,LinkComponent:i,onHover:s,highlightedIndex:a,pendingIndex:l,consumePending:m}){let u=r[e],c=useRef(null);return useLayoutEffect(()=>{l===e&&m(e)&&c.current?.click();},[m,e,l]),u?jsx("div",{style:t,"data-index":e,children:jsx(Rs,{result:u,href:n?.(u)??u.detail_url,LinkComponent:i,onSelect:o,onHover:s,highlighted:a===e,actionRef:c})}):jsx("div",{style:t,className:"flex items-center justify-center",children:jsx(Spinner,{size:"sm"})})}function cx({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-text-muted",children:t("predict.search.loading")})]})}function dx({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-text-muted"}),jsx("p",{className:"mt-2 text-sm text-text-muted",children:t("predict.search.noResults")})]})}var yc=()=>{};function Ds({onKeywordChange:e,onSelectResult:t,getEventHref:r,LinkComponent:o,onHover:n,onEscape:i,source:s}){let a=useMemo(()=>po(),[]),l=useSearchController({storage:a,onQueryChange:e??yc,onDismiss:i??yc}),m=useRef(null),u=l.dismiss,c=useCallback(p=>{if(m.current){m.current.onKey(p);return}p==="Escape"&&u();},[u]);return jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsx(Cs,{value:l.text,onValueChange:l.setText,onClear:l.clearQuery,onEscape:l.dismiss,onNavigateKey:c}),!l.query&&jsx(Es,{histories:l.history,onSelect:l.commitQuery,onClear:l.clearHistory}),jsx(_s,{className:"flex-auto min-h-0",keyword:l.query,onSelect:t,getEventHref:r,LinkComponent:o,onHover:n,source:s,navigationRef:m,onEscape:l.dismiss})]})}var Xn="predict-search";function Mx({id:e=Xn}){return jsx(AsyncModal,{id:e,children:t=>jsx(wx,{...t})})}function wx({params:e,isOpen:t,onOpenChange:r,onResult:o}){let{t:n}=useTranslation(),{isMobile:i}=useScreen(),s=useCallback(l=>{o(l);},[o]),a=useCallback(()=>{r(false);},[r]);return jsx(StyledModal,{isOpen:t,onOpenChange:r,size:i?"full":"lg",hideCloseButton:true,backdrop:"opaque",radius:"lg",children:jsxs(ModalContent,{className:"w-full h-full",style:{borderRadius:i?void 0:14,border:i?void 0:"1px solid var(--color-border-control)",background:"var(--color-surface-interactive)",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(Ds,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectResult:s,onEscape:a})})]})})}function Ox({onSelectEvent:e,modalParams:t,className:r}){let{t:o}=useTranslation(),{isDesktop:n}=useScreen(),{onOpen:i,onClose:s}=useAsyncModal(Xn),a=useCallbackRef(e),l=useCallbackRef(async()=>{let u=await i({params:t});u&&a(u);}),m=useCallbackRef(()=>{s();});return useEffect(()=>{let u=c=>{let p=document.activeElement,d=!!p&&(p.tagName==="INPUT"||p.tagName==="TEXTAREA"||p.getAttribute("contenteditable")==="true");c.key==="/"&&!d&&(c.preventDefault(),l()),c.key==="Escape"&&(c.preventDefault(),m());};return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u);}},[l,m]),n?jsx(Button,{size:"sm",radius:"full",onPress:l,variant:"bordered",startContent:jsx(SearchIcon,{width:16,height:16,className:"text-foreground"}),endContent:jsx(Kbd,{className:"min-w-6 justify-center text-xs text-foreground bg-content3 rounded-lg",children:"/"}),className:cn("w-56 min-w-0 h-8 min-h-0 border-transparent hover:border-border bg-content2 pl-3 pr-1.5 text-text-muted",r),children:o("predict.search.placeholder")}):jsx(Button,{size:"sm",radius:"full",isIconOnly:true,onPress:l,variant:"bordered",className:cn("w-8 min-w-0 h-8 min-h-0 border-1 border-border bg-content2",r),children:jsx(SearchIcon,{width:16,height:16,className:"text-foreground"})})}var wc=()=>{};function Dx({onKeywordChange:e}){let t=useMemo(()=>po(),[]),r=useSearchController({storage:t,onQueryChange:e??wc,onDismiss:wc});return {text:r.text,keyword:r.query,setText:r.setText,setKeyword:r.commitQuery,clearKeyword:r.clearQuery}}var Fs=[{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"}],Oc=[{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}],Tc={display:"inline-flex",alignItems:"center",gap:8,borderRadius:10,border:"1px solid var(--color-border-subtle)",background:"hsl(var(--heroui-content3) / 0.6)",padding:"8px 12px",fontSize:14,color:"var(--color-text-primary)",cursor:"pointer",transition:"all 0.15s"},Rc={position:"absolute",right:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid var(--color-border-control)",background:"var(--color-surface-interactive)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function Bx(e,t){if(!e)return "$5K+";let r=Oc.find(o=>o.value===e);return r?r.labelKey?t(r.labelKey):r.label:`$${e}`}function Bs({sortBy:e,onSortChange:t,sortAsc:r,onSortAscChange:o,minVolume:n,onMinVolumeChange:i,onRefresh:s}){let{t:a}=useTranslation(),[l,m]=useState(false),[u,c]=useState(false),[p,d]=useState(false),[f,g]=useState(false),b=useRef(null),v=useRef(null),S=Fs.find(h=>h.value===e)??Fs[0],x=useCallback(h=>{b.current&&!b.current.contains(h.target)&&m(false),v.current&&!v.current.contains(h.target)&&c(false);},[]);useEffect(()=>(document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)),[x]);let y=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 var(--color-focus);outline-offset:2px;z-index:10}
|
|
82
|
-
`}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxs("div",{ref:b,style:{position:"relative"},children:[jsxs("button",{type:"button",className:"match-btn",style:
|
|
82
|
+
`}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxs("div",{ref:b,style:{position:"relative"},children:[jsxs("button",{type:"button",className:"match-btn",style:Tc,onMouseEnter:h=>{h.currentTarget.style.background="var(--color-surface-strong)";},onMouseLeave:h=>{h.currentTarget.style.background="hsl(var(--heroui-content3) / 0.6)";},onClick:()=>{m(h=>!h),c(false);},children:[jsx(Hx,{}),jsx("span",{className:"hidden sm:block",style:{color:"var(--color-text-primary)"},children:a(S.labelKey)}),jsx(Lc,{open:l})]}),l&&jsx("div",{style:{...Rc,width:224,padding:4},children:Fs.map(h=>{let k=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:k?"color-mix(in srgb, var(--color-action-primary) 8%, transparent)":"transparent",color:k?"var(--color-action-primary)":"var(--color-text-secondary)",borderRadius:10},onMouseEnter:N=>{k||(N.currentTarget.style.background="hsl(var(--heroui-content3) / 0.5)",N.currentTarget.style.color="var(--color-text-primary)");},onMouseLeave:N=>{k||(N.currentTarget.style.background="transparent",N.currentTarget.style.color="var(--color-text-secondary)");},onClick:()=>{e===h.value?o(!r):t(h.value),m(false);},children:[jsx("div",{style:{color:k?"var(--color-action-primary)":"var(--color-text-muted)"},children:jsx(Ux,{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:"var(--color-text-muted)",marginTop:1},children:a(h.descKey)})]}),k&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"var(--color-action-primary)",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:v,style:{position:"relative"},children:[jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxs("button",{type:"button",className:"match-btn",style:Tc,onMouseEnter:h=>{h.currentTarget.style.background="var(--color-surface-strong)";},onMouseLeave:h=>{h.currentTarget.style.background="hsl(var(--heroui-content3) / 0.6)";},onClick:()=>{c(h=>!h),m(false);},children:[jsx(Wx,{}),jsx("span",{className:"hidden sm:block",style:{color:"var(--color-text-primary)"},children:Bx(n,a)}),jsx(zx,{onMouseEnter:()=>d(true),onMouseLeave:()=>d(false)}),jsx(Lc,{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:"var(--color-surface-interactive)",border:"1px solid var(--color-border-subtle)",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:"var(--color-surface-interactive)",borderLeft:"1px solid var(--color-border-subtle)",borderTop:"1px solid var(--color-border-subtle)"}}),jsxs("div",{style:{position:"relative",fontSize:12,color:"var(--color-text-primary)",lineHeight:1.625},children:[jsxs("div",{style:{fontWeight:600,color:"var(--color-text-primary)",display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"var(--color-action-primary)",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:"var(--color-text-secondary)",margin:"0 0 4px"},children:a("predict.matches.filter.tooltipDesc")}),jsx("p",{style:{color:"var(--color-text-muted)",fontSize:11,margin:0},children:a("predict.matches.filter.tooltipNote")})]})]})]}),u&&jsxs("div",{style:{...Rc,right:0,width:176},children:[jsx("div",{style:{padding:"8px 12px",borderBottom:"1px solid var(--color-border-control)"},children:jsx("span",{style:{fontSize:11,fontWeight:500,color:"var(--color-text-muted)",textTransform:"uppercase",letterSpacing:"0.05em"},children:a("predict.matches.filter.minVolumeEach")})}),jsx("div",{style:{padding:4},children:Oc.map(h=>{let k=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:k?"color-mix(in srgb, var(--color-action-primary) 8%, transparent)":"transparent",color:k?"var(--color-action-primary)":"var(--color-text-secondary)",borderRadius:10,transition:"all 0.15s"},onMouseEnter:N=>{k||(N.currentTarget.style.background="hsl(var(--heroui-content3) / 0.5)",N.currentTarget.style.color="var(--color-text-primary)");},onMouseLeave:N=>{k||(N.currentTarget.style.background="transparent",N.currentTarget.style.color="var(--color-text-secondary)");},onClick:()=>{i?.(h.value===0?void 0:h.value),c(false);},children:[jsx("span",{children:h.labelKey?a(h.labelKey):h.label}),k&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"var(--color-action-primary)"},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 var(--color-border-subtle)",background:"hsl(var(--heroui-content3) / 0.6)",width:36,height:36,color:"var(--color-text-secondary)",cursor:"pointer",transition:"all 0.15s",display:"inline-flex",alignItems:"center",justifyContent:"center"},onMouseEnter:h=>{h.currentTarget.style.background="var(--color-surface-strong)",h.currentTarget.style.color="var(--color-text-primary)";},onMouseLeave:h=>{h.currentTarget.style.background="hsl(var(--heroui-content3) / 0.6)",h.currentTarget.style.color="var(--color-text-secondary)";},onClick:y,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 Hx(){return jsxs("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"var(--color-text-secondary)"},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 Ux({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 Wx(){return jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"var(--color-text-secondary)"},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 zx({onMouseEnter:e,onMouseLeave:t}){return jsxs("svg",{viewBox:"0 0 24 24",className:"hidden sm:block",style:{width:12,height:12,color:"var(--color-text-disabled)",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 Lc({open:e}){return jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"var(--color-text-muted)",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 jx(e){return formatAmountInUsd(e)}var Gx=[{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:jx,valueColor:"#f5a524",gradientFrom:"rgba(245,165,36,0.18)",gradientTo:"rgba(245,165,36,0.04)",borderColor:"rgba(245,165,36,0.18)"}];function Hs({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:"hsl(var(--heroui-content3) / 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:"var(--color-text-primary)",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:"var(--color-text-muted)",maxWidth:460},children:String(t("predict.matches.heroSubtitle")).split(`
|
|
120
|
-
`).map((r,o)=>jsxs("span",{children:[o>0&&jsx("br",{className:"hidden sm:block"}),r,o===0?" ":""]},o))})]}),jsx("div",{className:"matches-stat-grid",style:{display:"grid",borderRadius:16,border:"1px solid var(--color-border-subtle)",overflow:"hidden",flexShrink:0,backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",...e?{animation:"matchStatsEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:"0.1s"}:{}},children:
|
|
120
|
+
`).map((r,o)=>jsxs("span",{children:[o>0&&jsx("br",{className:"hidden sm:block"}),r,o===0?" ":""]},o))})]}),jsx("div",{className:"matches-stat-grid",style:{display:"grid",borderRadius:16,border:"1px solid var(--color-border-subtle)",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:Gx.map((r,o)=>jsxs("div",{style:{padding:"16px 20px",background:e?`linear-gradient(to bottom, ${r.gradientFrom}, ${r.gradientTo})`:"hsl(var(--heroui-foreground) / 0.02)",borderRight:o%2===0?"1px solid var(--color-border-subtle)":"none",borderBottom:o<2?"1px solid var(--color-border-subtle)":"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:"hsl(var(--heroui-foreground) / 0.06)",animation:"matchStatCardEnter 0.6s ease-out both",animationDelay:`${o*80}ms`}})}),jsx("div",{className:"matches-stat-label",style:{fontWeight:500,color:e?"var(--color-text-muted)":"transparent",marginTop:2,display:"flex",alignItems:"center"},children:e?t(r.labelKey):jsx("div",{style:{height:10,width:64,borderRadius:4,background:"hsl(var(--heroui-foreground) / 0.04)",animation:"matchStatCardEnter 0.6s ease-out both",animationDelay:`${50+o*80}ms`}})})]},r.key))})]})]})}var Dc={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}},Zx={label:"Unknown",color:"rgb(156, 163, 175)",bgColor:"rgba(156, 163, 175, 0.12)",icon:null};function _r(e){return Dc[e]??Zx}function eb({source:e,className:t}){let{t:r}=useTranslation(),o=_r(e),n=Dc[e]?o.label:r("common.unknown");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:o.bgColor,color:o.color},children:[o.icon,n]})}var nb="\u2605";function Us(e){return e==null?"-":formatAmountInUsd(e)}function ib(e){return e==null?"narrow":e>=5?"wide":e>=3?"moderate":"narrow"}var Hc={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:"var(--color-text-muted)",bandFrom:"rgba(113,113,122,0.08)",bandTo:"transparent",gaugeActive:"var(--color-text-muted)",gaugeInactive:"rgba(113,113,122,0.12)"}},sb={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)"}},Ac={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:"var(--color-text-muted)",label:"predict.matches.signalStaleData"}};function ab(e){return e==null?null:e<120?"fresh":e<300?"aging":"stale"}var lb={fresh:"#17c964",aging:"#f5a524",stale:"var(--color-text-muted)"},cb={polymarket:{text:"#50a2ff",icon:"#50a2ff"},kalshi:{text:"#00d492",icon:"#00d492"}},db={text:"var(--color-text-secondary)",icon:"var(--color-text-secondary)"};function ub(e){return cb[e]??db}var pb=`
|
|
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 cb({tier:e}){let t=Fc[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 db(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 Hs({match:e,onSelectMatch:t,getMatchHref:r,onSelectLeg:o,getLegHref:n,onHover:i,getMarketHref:s,LinkComponent:a}){let{t:l}=useTranslation(),{formatAgeInSeconds:m}=useLocalizedTimeFormatter(),u=db(e);if(!u)return null;let[c,p]=u,d=e.spread_percent!=null?e.spread_percent:e.spread!=null?e.spread*100:null,f=tb(d),g=Fc[f],b=c.best_price!=null&&p.best_price!=null?c.best_price<=p.best_price?c.source:p.source:null,h=c.event_title||p.event_title,S=e.signal_tag??"stale_data",x=Ic[S]??Ic.stale_data,y=r?.(e),v=jsxs(Fragment,{children:[jsx("style",{children:lb}),d!=null&&jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",background:`linear-gradient(90deg, ${g.bandFrom}, ${g.bandTo})`,borderBottom:"1px solid var(--color-border-subtle)"},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:g.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:g.color},children:[d.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(cb,{tier:f})]}),jsxs("div",{style:{padding:"14px 14px 12px"},children:[jsx("h3",{style:{fontSize:13,fontWeight:600,lineHeight:1.4,letterSpacing:"-0.2px",color:"var(--color-text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",margin:"0 0 12px"},children:h}),jsxs("div",{style:{borderRadius:10,border:"1px solid var(--color-border-subtle)",overflow:"hidden"},children:[jsx(Dc,{leg:c,isCheaper:b===c.source,externalUrlFallback:s?.(e,c.source),internalHref:n?.(e,c),onSelect:o?()=>o(e,c):void 0,LinkComponent:a}),jsx("div",{style:{height:1,background:"hsl(var(--heroui-content3) / 0.3)"}}),jsx(Dc,{leg:p,isCheaper:b===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 var(--color-border-subtle)",background:"hsl(var(--heroui-content3) / 0.15)",padding:"8px 14px"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,fontSize:10,color:"var(--color-text-muted)"},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"})]}),Bs(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"})}),Bs(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"})]}),m(e.age_seconds)]})]}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,color:"var(--color-text-disabled)"},children:[jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:x.dot,flexShrink:0}}),l(x.label)]})]})]}),k={display:"block",color:"inherit",textDecoration:"none",borderRadius:14,border:"1px solid var(--color-border-subtle)",background:"hsl(var(--heroui-content2) / 0.4)",overflow:"hidden",transition:"all 0.2s",cursor:y||t?"pointer":void 0},N=P=>{let M=P.currentTarget,T=rb[f];M.style.borderColor=T.border,M.style.boxShadow=T.shadow,i?.(e);},w=P=>{let M=P.currentTarget;M.style.borderColor="hsl(var(--heroui-content3) / 0.6)",M.style.boxShadow="none";};return y&&a?jsx(a,{href:y,className:"group match-card",children:jsx("div",{style:k,onMouseEnter:N,onMouseLeave:w,onClick:()=>t?.(e),children:v})}):jsx("div",{className:"group match-card",role:t?"button":void 0,tabIndex:t?0:void 0,style:k,onMouseEnter:N,onMouseLeave:w,onClick:()=>t?.(e),onKeyDown:P=>{t&&(P.key==="Enter"||P.key===" ")&&(P.preventDefault(),t(e));},children:v})}function Dc({leg:e,isCheaper:t,externalUrlFallback:r,internalHref:o,onSelect:n,LinkComponent:i}){let{t:s}=useTranslation(),a=Or(e.source),l=ab(e.source),m=e.best_price,u=e.outcomes?.[0]?.label??null,c=e.external_url??r,p=ob(e.age_seconds),d=h=>{h.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"},b=jsxs(Fragment,{children:[t?jsx("span",{style:{fontSize:10,color:"#c7ff2e",flexShrink:0},children:eb}):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:nb[p],flexShrink:0}})]}),jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:1},children:[u&&jsx("span",{style:{fontSize:10,color:"var(--color-text-muted)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u}),jsxs("span",{style:{fontSize:9,color:"var(--color-text-disabled)"},children:[Bs(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":"var(--color-text-primary)"},children:m!=null?(m*100).toFixed(1):"-"}),jsx("span",{style:{fontSize:9,color:"var(--color-text-muted)"},children:s("predict.matches.centsYes")})]}),c?jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer","aria-label":s("predict.matches.viewOn",{platform:a.label}),title:s("predict.matches.viewOn",{platform:a.label}),onClick:h=>h.stopPropagation(),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,borderRadius:4,color:"var(--color-text-muted)",flexShrink:0},onMouseEnter:h=>{h.currentTarget.style.color="var(--color-text-primary)",h.currentTarget.style.background="hsl(var(--heroui-foreground) / 0.05)";},onMouseLeave:h=>{h.currentTarget.style.color="var(--color-text-muted)",h.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:h=>{d(h),n?.();},children:jsx("div",{style:g,children:b})}):f?jsx("div",{role:"link",tabIndex:0,style:g,onClick:h=>{d(h),n?.();},onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),d(h),n?.());},children:b}):jsx("div",{style:g,children:b})}var Ws=forwardRef(function({sortBy:t,sortAsc:r,minVolume:o,signal:n,onSelectMatch:i,getMatchHref:s,onSelectLeg:a,getLegHref:l,onSelect:m,onHover:u,getMarketHref:c,LinkComponent:p,onStatsChange:d},f){let{t:g}=useTranslation(),{data:b,hasNextPage:h,fetchNextPage:S,isFetchingNextPage:x,isLoading:y,isPlaceholderData:v,refetch:k}=useInfiniteMatchMarkets({sort_by:t,sort_asc:r,min_volume:o,signal:n,status:"active",limit:20},{placeholderData:keepPreviousData}),[N,w]=useState(0),[P,M]=useState(false);P&&!v?(M(false),w(oe=>oe+1)):v&&!P&&M(true),useImperativeHandle(f,()=>({refetch:()=>{k();}}),[k]);let T=useMemo(()=>b?.pages.flatMap(oe=>oe.items??[])??[],[b]),A=b?.pages[0]?.total,X=useMemo(()=>{let oe=0,W=0,te=0;for(let ne of T){let se=ne.spread??0;se>oe&&(oe=se),se>=.03&&te++,ne.combined_volume!=null&&(W+=ne.combined_volume);}return {activePairs:A??T.length,maxSpread:oe,highSpreadCount:te,totalVolume:W}},[T,A]);useEffect(()=>{X.activePairs>0&&d?.(X);},[X,d]);let L=useRef(null),G=useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]);if(useEffect(()=>{let oe=L.current;if(!oe)return;let W=new IntersectionObserver(te=>{te[0]?.isIntersecting&&h&&!x&&S();},{rootMargin:"200px"});return W.observe(oe),()=>W.disconnect()},[h,x,S]),useEffect(()=>{if(h)return document.documentElement.style.overscrollBehaviorY="none",()=>{document.documentElement.style.overscrollBehaviorY="";}},[h]),y)return jsx(xb,{});if(T.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 U=!h&&T.length>0;return jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[jsx("style",{children:`
|
|
127
|
+
`;function mb({tier:e}){let t=Hc[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 fb(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 Ws({match:e,onSelectMatch:t,getMatchHref:r,onSelectLeg:o,getLegHref:n,onHover:i,getMarketHref:s,LinkComponent:a}){let{t:l}=useTranslation(),{formatAgeInSeconds:m}=useLocalizedTimeFormatter(),u=fb(e);if(!u)return null;let[c,p]=u,d=e.spread_percent!=null?e.spread_percent:e.spread!=null?e.spread*100:null,f=ib(d),g=Hc[f],b=c.best_price!=null&&p.best_price!=null?c.best_price<=p.best_price?c.source:p.source:null,v=c.event_title||p.event_title,S=e.signal_tag??"stale_data",x=Ac[S]??Ac.stale_data,y=r?.(e),h=jsxs(Fragment,{children:[jsx("style",{children:pb}),d!=null&&jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",background:`linear-gradient(90deg, ${g.bandFrom}, ${g.bandTo})`,borderBottom:"1px solid var(--color-border-subtle)"},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:g.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:g.color},children:[d.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(mb,{tier:f})]}),jsxs("div",{style:{padding:"14px 14px 12px"},children:[jsx("h3",{style:{fontSize:13,fontWeight:600,lineHeight:1.4,letterSpacing:"-0.2px",color:"var(--color-text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",margin:"0 0 12px"},children:v}),jsxs("div",{style:{borderRadius:10,border:"1px solid var(--color-border-subtle)",overflow:"hidden"},children:[jsx(Fc,{leg:c,isCheaper:b===c.source,externalUrlFallback:s?.(e,c.source),internalHref:n?.(e,c),onSelect:o?()=>o(e,c):void 0,LinkComponent:a}),jsx("div",{style:{height:1,background:"hsl(var(--heroui-content3) / 0.3)"}}),jsx(Fc,{leg:p,isCheaper:b===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 var(--color-border-subtle)",background:"hsl(var(--heroui-content3) / 0.15)",padding:"8px 14px"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,fontSize:10,color:"var(--color-text-muted)"},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"})]}),Us(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"})}),Us(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"})]}),m(e.age_seconds)]})]}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,color:"var(--color-text-disabled)"},children:[jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:x.dot,flexShrink:0}}),l(x.label)]})]})]}),k={display:"block",color:"inherit",textDecoration:"none",borderRadius:14,border:"1px solid var(--color-border-subtle)",background:"hsl(var(--heroui-content2) / 0.4)",overflow:"hidden",transition:"all 0.2s",cursor:y||t?"pointer":void 0},N=P=>{let M=P.currentTarget,T=sb[f];M.style.borderColor=T.border,M.style.boxShadow=T.shadow,i?.(e);},w=P=>{let M=P.currentTarget;M.style.borderColor="hsl(var(--heroui-content3) / 0.6)",M.style.boxShadow="none";};return y&&a?jsx(a,{href:y,className:"group match-card",children:jsx("div",{style:k,onMouseEnter:N,onMouseLeave:w,onClick:()=>t?.(e),children:h})}):jsx("div",{className:"group match-card",role:t?"button":void 0,tabIndex:t?0:void 0,style:k,onMouseEnter:N,onMouseLeave:w,onClick:()=>t?.(e),onKeyDown:P=>{t&&(P.key==="Enter"||P.key===" ")&&(P.preventDefault(),t(e));},children:h})}function Fc({leg:e,isCheaper:t,externalUrlFallback:r,internalHref:o,onSelect:n,LinkComponent:i}){let{t:s}=useTranslation(),a=_r(e.source),l=ub(e.source),m=e.best_price,u=e.outcomes?.[0]?.label??null,c=e.external_url??r,p=ab(e.age_seconds),d=v=>{v.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"},b=jsxs(Fragment,{children:[t?jsx("span",{style:{fontSize:10,color:"#c7ff2e",flexShrink:0},children:nb}):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:lb[p],flexShrink:0}})]}),jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:1},children:[u&&jsx("span",{style:{fontSize:10,color:"var(--color-text-muted)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u}),jsxs("span",{style:{fontSize:9,color:"var(--color-text-disabled)"},children:[Us(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":"var(--color-text-primary)"},children:m!=null?(m*100).toFixed(1):"-"}),jsx("span",{style:{fontSize:9,color:"var(--color-text-muted)"},children:s("predict.matches.centsYes")})]}),c?jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer","aria-label":s("predict.matches.viewOn",{platform:a.label}),title:s("predict.matches.viewOn",{platform:a.label}),onClick:v=>v.stopPropagation(),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,borderRadius:4,color:"var(--color-text-muted)",flexShrink:0},onMouseEnter:v=>{v.currentTarget.style.color="var(--color-text-primary)",v.currentTarget.style.background="hsl(var(--heroui-foreground) / 0.05)";},onMouseLeave:v=>{v.currentTarget.style.color="var(--color-text-muted)",v.currentTarget.style.background="transparent";},children:jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M7 7h10v10"}),jsx("path",{d:"M7 17 17 7"})]})}):jsx("span",{style:{width:18,flexShrink:0}})]});return o&&i?jsx(i,{href:o,className:"match-card-leg-link",onClick:v=>{d(v),n?.();},children:jsx("div",{style:g,children:b})}):f?jsx("div",{role:"link",tabIndex:0,style:g,onClick:v=>{d(v),n?.();},onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),d(v),n?.());},children:b}):jsx("div",{style:g,children:b})}var Ks=forwardRef(function({sortBy:t,sortAsc:r,minVolume:o,signal:n,onSelectMatch:i,getMatchHref:s,onSelectLeg:a,getLegHref:l,onSelect:m,onHover:u,getMarketHref:c,LinkComponent:p,onStatsChange:d},f){let{t:g}=useTranslation(),{data:b,hasNextPage:v,fetchNextPage:S,isFetchingNextPage:x,isLoading:y,isPlaceholderData:h,refetch:k}=useInfiniteMatchMarkets({sort_by:t,sort_asc:r,min_volume:o,signal:n,status:"active",limit:20},{placeholderData:keepPreviousData}),[N,w]=useState(0),[P,M]=useState(false);P&&!h?(M(false),w(oe=>oe+1)):h&&!P&&M(true),useImperativeHandle(f,()=>({refetch:()=>{k();}}),[k]);let T=useMemo(()=>b?.pages.flatMap(oe=>oe.items??[])??[],[b]),A=b?.pages[0]?.total,X=useMemo(()=>{let oe=0,W=0,te=0;for(let ne of T){let se=ne.spread??0;se>oe&&(oe=se),se>=.03&&te++,ne.combined_volume!=null&&(W+=ne.combined_volume);}return {activePairs:A??T.length,maxSpread:oe,highSpreadCount:te,totalVolume:W}},[T,A]);useEffect(()=>{X.activePairs>0&&d?.(X);},[X,d]);let L=useRef(null),G=useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]);if(useEffect(()=>{let oe=L.current;if(!oe)return;let W=new IntersectionObserver(te=>{te[0]?.isIntersecting&&v&&!x&&S();},{rootMargin:"200px"});return W.observe(oe),()=>W.disconnect()},[v,x,S]),useEffect(()=>{if(v)return document.documentElement.style.overscrollBehaviorY="none",()=>{document.documentElement.style.overscrollBehaviorY="";}},[v]),y)return jsx(Sb,{});if(T.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 U=!v&&T.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:b?.pages.map(oe=>oe.items?.map((W,te)=>jsx("div",{style:{animation:`matchCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${te*35}ms both`},children:jsx(Hs,{match:W,onSelectMatch:i,getMatchHref:s,onSelectLeg:a,getLegHref:l,onHover:u,onSelect:m,getMarketHref:c,LinkComponent:p})},`${N}-${W.match_id}-${W.source_a}-${W.market_a?.slug??te}`)))}),jsxs("div",{ref:L,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)}}"}),x&&jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"var(--color-text-muted)",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")]})]}),U&&jsx(vb,{onScrollToTop:G})]})});function vb({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:"var(--color-text-muted)"},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:"var(--color-text-secondary)",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 xb(){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(bb,{index:t},t))})]})}function bb({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 var(--color-border-subtle)",background:"hsl(var(--heroui-content2) / 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:"hsl(var(--heroui-foreground) / 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 var(--color-border-subtle)",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 Mb={spread:"predict.matches.topOpportunities",volume:"predict.matches.highestVolume",confidence:"predict.matches.trendingToday"};function wb(){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 Eb({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 var(--color-border-subtle)",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:"hsl(var(--heroui-content3) / 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:"var(--color-text-muted)"},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:"var(--color-text-disabled)"},children:t("predict.matches.status.markets")}),jsx("span",{style:{color:"var(--color-text-primary)",fontWeight:500,fontVariantNumeric:"tabular-nums"},children:formatAmount(e.activePairs)})]}),jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,color:"var(--color-text-muted)"},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:"var(--color-text-disabled)"},children:t("predict.matches.status.vol24h")}),jsx("span",{style:{color:"var(--color-text-primary)",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:"var(--color-text-muted)",textDecoration:"none",transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="var(--color-text-primary)",r.currentTarget.style.background="hsl(var(--heroui-content3) / 0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="var(--color-text-muted)",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:"var(--color-text-muted)",textDecoration:"none",transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="var(--color-text-primary)",r.currentTarget.style.background="hsl(var(--heroui-content3) / 0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="var(--color-text-muted)",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:"hsl(var(--heroui-content3) / 0.8)",margin:"0 4px"}}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"var(--color-text-muted)",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="var(--color-text-primary)",r.currentTarget.style.background="hsl(var(--heroui-content3) / 0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="var(--color-text-muted)",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:"var(--color-text-muted)",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="var(--color-text-primary)",r.currentTarget.style.background="hsl(var(--heroui-content3) / 0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="var(--color-text-muted)",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:"var(--color-text-muted)",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="var(--color-text-primary)",r.currentTarget.style.background="hsl(var(--heroui-content3) / 0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="var(--color-text-muted)",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:"hsl(var(--heroui-content3) / 0.8)",margin:"0 4px"}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,color:"var(--color-text-muted)"},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(wb,{})]})]})]})]})}function Cb({onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:o,onHover:n,onSelect:i,getMarketHref:s,LinkComponent:a,bgImageSrc:l}){let{t:m}=useTranslation(),[u,c]=useState("spread"),[p,d]=useState(false),[f,g]=useState(void 0),[b,h]=useState(),S=useRef(null),x=useCallback(N=>{c(N);},[]),y=useCallback(N=>{d(N);},[]),v=useCallback(N=>{startTransition(()=>{h(N);});},[]),k=useCallback(()=>{S.current?.refetch();},[]);return jsxs("div",{style:{minHeight:"100vh",position:"relative"},children:[jsx("style",{children:`
|
|
130
|
+
`}),jsx("div",{className:"matches-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:16},children:b?.pages.map(oe=>oe.items?.map((W,te)=>jsx("div",{style:{animation:`matchCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${te*35}ms both`},children:jsx(Ws,{match:W,onSelectMatch:i,getMatchHref:s,onSelectLeg:a,getLegHref:l,onHover:u,onSelect:m,getMarketHref:c,LinkComponent:p})},`${N}-${W.match_id}-${W.source_a}-${W.market_a?.slug??te}`)))}),jsxs("div",{ref:L,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)}}"}),x&&jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"var(--color-text-muted)",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")]})]}),U&&jsx(kb,{onScrollToTop:G})]})});function kb({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:"var(--color-text-muted)"},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:"var(--color-text-secondary)",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 Sb(){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(Pb,{index:t},t))})]})}function Pb({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 var(--color-border-subtle)",background:"hsl(var(--heroui-content2) / 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:"hsl(var(--heroui-foreground) / 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 var(--color-border-subtle)",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 Tb={spread:"predict.matches.topOpportunities",volume:"predict.matches.highestVolume",confidence:"predict.matches.trendingToday"};function Rb(){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 Lb({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 var(--color-border-subtle)",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:"hsl(var(--heroui-content3) / 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:"var(--color-text-muted)"},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:"var(--color-text-disabled)"},children:t("predict.matches.status.markets")}),jsx("span",{style:{color:"var(--color-text-primary)",fontWeight:500,fontVariantNumeric:"tabular-nums"},children:formatAmount(e.activePairs)})]}),jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,color:"var(--color-text-muted)"},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:"var(--color-text-disabled)"},children:t("predict.matches.status.vol24h")}),jsx("span",{style:{color:"var(--color-text-primary)",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:"var(--color-text-muted)",textDecoration:"none",transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="var(--color-text-primary)",r.currentTarget.style.background="hsl(var(--heroui-content3) / 0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="var(--color-text-muted)",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:"var(--color-text-muted)",textDecoration:"none",transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="var(--color-text-primary)",r.currentTarget.style.background="hsl(var(--heroui-content3) / 0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="var(--color-text-muted)",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:"hsl(var(--heroui-content3) / 0.8)",margin:"0 4px"}}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"var(--color-text-muted)",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="var(--color-text-primary)",r.currentTarget.style.background="hsl(var(--heroui-content3) / 0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="var(--color-text-muted)",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:"var(--color-text-muted)",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="var(--color-text-primary)",r.currentTarget.style.background="hsl(var(--heroui-content3) / 0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="var(--color-text-muted)",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:"var(--color-text-muted)",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="var(--color-text-primary)",r.currentTarget.style.background="hsl(var(--heroui-content3) / 0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="var(--color-text-muted)",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:"hsl(var(--heroui-content3) / 0.8)",margin:"0 4px"}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,color:"var(--color-text-muted)"},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(Rb,{})]})]})]})]})}function Ob({onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:o,onHover:n,onSelect:i,getMarketHref:s,LinkComponent:a,bgImageSrc:l}){let{t:m}=useTranslation(),[u,c]=useState("spread"),[p,d]=useState(false),[f,g]=useState(void 0),[b,v]=useState(),S=useRef(null),x=useCallback(N=>{c(N);},[]),y=useCallback(N=>{d(N);},[]),h=useCallback(N=>{startTransition(()=>{v(N);});},[]),k=useCallback(()=>{S.current?.refetch();},[]);return jsxs("div",{style:{minHeight:"100vh",position:"relative"},children:[jsx("style",{children:`
|
|
131
131
|
@keyframes matchFadeIn{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}
|
|
132
132
|
.match-fade-in{animation:matchFadeIn .5s ease-out both}
|
|
133
133
|
.match-fade-in-d1{animation:matchFadeIn .5s ease-out .1s both}
|
|
134
134
|
.match-fade-in-d2{animation:matchFadeIn .5s ease-out .2s both}
|
|
135
|
-
`}),jsxs("div",{style:{position:"relative",overflow:"hidden",borderBottom:"1px solid var(--color-border-subtle)"},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(Fs,{stats:b})})]}),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 var(--color-border-subtle)"},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:m(Mb[u])}),b&&b.activePairs>0&&jsx("p",{className:"hidden sm:block",style:{fontSize:11,color:"var(--color-text-muted)",margin:0},children:m("predict.matches.pairsFound",{count:b.activePairs})})]})]}),jsx(As,{sortBy:u,onSortChange:x,sortAsc:p,onSortAscChange:y,minVolume:f,onMinVolumeChange:g,onRefresh:k})]})]}),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 var(--color-border-subtle)",background:"rgba(24,24,27,0.25)"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"var(--color-text-disabled)",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:"var(--color-text-disabled)",lineHeight:1.5,margin:0},children:[jsx("span",{style:{color:"var(--color-text-muted)",fontWeight:500},children:m("predict.matches.experimentalFeature")})," \u2014 ",m("predict.matches.disclaimer")]})]}),jsx(Ws,{ref:S,sortBy:u,sortAsc:p,minVolume:f,onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:o,onHover:n,onSelect:i,getMarketHref:s,LinkComponent:a,onStatsChange:v})]}),jsx(Eb,{stats:b})]})}function zs(e){return e==null?"-":formatAmountInUsd(e)}var Lb={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"}},Ob={text:"var(--color-text-secondary)",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 _b(e){return Lb[e]??Ob}function Ib(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 Db(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 Ab({group:e,onSelectEntry:t,getEventHref:r,LinkComponent:o}){let{t:n}=useTranslation(),i=useMemo(()=>Ib(e),[e]),s=e.max_spread!=null?e.max_spread*100:null,[a,l]=useMemo(()=>Db(e,i),[e,i]),m=s!=null&&s>=3,u=a.yesPrice!=null&&l.yesPrice!=null?a.yesPrice<=l.yesPrice?a:l:null,c=u?Or(u.source):null,p=m?"amber":"violet";return jsxs("div",{className:"group",style:{borderRadius:16,border:"1px solid var(--color-border-subtle)",background:"hsl(var(--heroui-content2) / 0.4)",overflow:"hidden",transition:"all 0.2s",position:"relative"},onMouseEnter:d=>{let f=d.currentTarget;f.style.borderColor="hsl(var(--heroui-content4) / 0.6)",f.style.boxShadow="0 10px 15px -3px rgba(0,0,0,0.2)";},onMouseLeave:d=>{let f=d.currentTarget;f.style.borderColor="hsl(var(--heroui-content3) / 0.6)",f.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 ${m?"rgba(255,185,0,0.3)":s>=2?"rgba(166,132,255,0.3)":"rgba(156,163,175,0.3)"}`,background:m?"rgba(255,185,0,0.15)":s>=2?"rgba(166,132,255,0.15)":"rgba(156,163,175,0.12)",color:m?"#ffb900":s>=2?"#a684ff":"var(--color-text-secondary)"},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:"var(--color-text-primary)",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($c,{data:a,isCheaper:u===a,onSelect:t,getEventHref:r,LinkComponent:o}),jsx($c,{data:l,isCheaper:u===l,onSelect:t,getEventHref:r,LinkComponent:o})]}),u&&c&&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 ${p==="amber"?"rgba(255,185,0,0.15)":"rgba(166,132,255,0.15)"}`,background:p==="amber"?"rgba(255,185,0,0.05)":"rgba(166,132,255,0.05)"},onClick:()=>u.event&&t?.(u.event),children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,flexShrink:0,color:p==="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:p==="amber"?"rgba(255,185,0,0.9)":"rgba(166,132,255,0.9)"},children:n("predict.matches.buyEdge",{platform:u.source.charAt(0).toUpperCase()+u.source.slice(1),spread:s.toFixed(1)})}),jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,marginLeft:"auto",color:p==="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 var(--color-border-subtle)",background:"hsl(var(--heroui-content3) / 0.2)",padding:"10px 16px"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,fontSize:10,color:"var(--color-text-muted)"},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"})]}),zs(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"})}),zs(e.combined_volume_24h)," ",n("predict.matches.vol24h")]})]}),e.confidence!=null&&jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,fontSize:10,color:"var(--color-text-disabled)"},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 $c({data:e,isCheaper:t,onSelect:r,getEventHref:o,LinkComponent:n}){let{t:i}=useTranslation(),s=Or(e.source),a=_b(e.source),l=e.event?o?.(e.event):void 0,m=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:"var(--color-text-disabled)",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:"var(--color-text-muted)",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:"var(--color-text-muted)"},children:i("predict.matches.centsYes")})]}),jsxs("div",{style:{fontSize:10,color:"var(--color-text-disabled)",marginTop:6},children:[zs(e.volume)," ",i("predict.matches.volume")]})]});return l&&n?jsx(n,{href:l,className:"block",children:m}):m}function Ub(e){return formatAmountInUsd(e)}function Wb({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(Zn,{label:r("predict.matches.stats.matchedMarkets"),value:o.count.toLocaleString()}),jsx(Ks,{}),jsx(Zn,{label:r("predict.matches.stats.totalVolume"),value:Ub(o.totalVolume)}),jsx(Ks,{}),jsx(Zn,{label:r("predict.matches.stats.highestSpread"),value:`${(o.maxSpread*100).toFixed(1)}\xA2`,valueClassName:"text-success"}),jsx(Ks,{}),jsx(Zn,{label:r("predict.matches.stats.platforms"),value:String(o.platformCount)})]})}function Zn({label:e,value:t,valueClassName:r="text-text-primary"}){return jsxs("div",{className:"flex items-center gap-x-1.5",children:[jsxs("span",{className:"text-text-muted",children:[e,":"]}),jsx("span",{className:`font-semibold ${r}`,children:t})]})}function Ks(){return jsx("span",{className:"hidden text-text-disabled sm:inline",children:"|"})}function Gc(e){return `${(e*100).toFixed(1)}\xA2`}function zb(e){return e>=.05?"text-success":e>=.02?"text-warning":"text-text-secondary"}function Kb({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",zb(e)),children:Gc(e)}),o&&jsxs("span",{className:"text-xs text-success/80",children:["+",Gc(t)]})]})}var Xo=10,qb=64,Xc=40,ei=48;function Jc({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:o}=useTranslation(),[n,i]=useState(1),{data:s,isLoading:a,fetchNextPage:l,hasNextPage:m,isFetchingNextPage:u}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:50}),{data:c,isLoading:p,fetchNextPage:d,hasNextPage:f,isFetchingNextPage:g}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:50}),b=a||p,h=u||g,S=m||f,x=useMemo(()=>{let A=[];return s?.pages&&A.push(...s.pages.flatMap(X=>X.items)),c?.pages&&A.push(...c.pages.flatMap(X=>X.items)),A.sort((X,L)=>(L.timestamp??0)-(X.timestamp??0)),A},[s,c]),y=Math.max(1,Math.ceil(x.length/Xo)+(S?1:0)),v=(n-1)*Xo,k=x.slice(v,v+Xo),N=useCallback(()=>{i(A=>Math.max(1,A-1));},[]),w=useCallback(async()=>{n*Xo>=x.length&&S&&(m&&await l(),f&&await d()),i(X=>X+1);},[n,x.length,S,m,f,l,d]),P=n>1,M=n*Xo<x.length||S;if(b)return jsx(ty,{height:r});if(x.length===0&&!S)return jsx(ey,{message:o("predict.profile.noHistory"),height:r});let T=r-Xc-ei;return jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxs("div",{className:"hidden lg:flex items-center text-text-muted text-xs font-normal shrink-0 border-b border-border/50",style:{height:Xc},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:T},children:[k.map((A,X)=>jsx(Qb,{trade:A},A.id??`${v+X}`)),h&&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:ei},children:[jsxs("button",{type:"button",disabled:!P,onClick:N,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",P?"text-text-muted hover:text-foreground":"text-text-muted/40 cursor-not-allowed"),children:["\u2190 ",o("predict.profile.previous")]}),Array.from({length:Math.min(y,5)},(A,X)=>{let L=X+1;return jsx("button",{type:"button",onClick:()=>i(L),className:cn$1("w-8 h-8 rounded text-sm transition-colors cursor-pointer",L===n?"bg-foreground/10 text-foreground font-medium":"text-text-muted hover:text-foreground"),children:L},L)}),jsxs("button",{type:"button",disabled:!M,onClick:w,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",M?"text-text-muted hover:text-foreground":"text-text-muted/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-ei},children:k.map((A,X)=>jsx(Xb,{trade:A},A.id??`m-${v+X}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:ei},children:[jsx("button",{type:"button",disabled:!P,onClick:N,className:cn$1("text-sm cursor-pointer",P?"text-text-muted hover:text-foreground":"text-text-muted/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:n}),jsx("button",{type:"button",disabled:!M,onClick:w,className:cn$1("text-sm cursor-pointer",M?"text-text-muted hover:text-foreground":"text-text-muted/40 cursor-not-allowed"),children:"\u2192"})]})]})}function Qb({trade:e}){let{t}=useTranslation(),r=e.type==="REDEEM",o=e.side?.toUpperCase()==="BUY",n=e.price??0,i=e.usd_size??0,s=Zc(e.type,h=>String(t(h))),a=r||o,l=a?"+":"-",m=a?"text-success":"text-foreground",u=e.event?.title??e.market?.question??"\u2014",c=e.event?.image_url,p=e.outcome??"",d=od(e.timestamp),f=ed(e),g=Jb(e),b=Zb(e);return jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:qb},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:[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:u}),jsxs("span",{className:"text-[11px] text-text-muted",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$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:rd(n)}),jsx("div",{className:cn$1("flex-[1.5] pr-2 text-right font-mono",m),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-text-muted"),children:g!==null?`${g>=0?"+":"-"}$${Math.abs(g).toFixed(2)}`:"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-text-muted",children:b!==null?`$${b.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-text-muted hover:text-foreground transition-colors","aria-label":t("common.viewTransaction"),children:jsx(td,{})})})]})}function Xb({trade:e}){let{t}=useTranslation(),r=e.type==="REDEEM",o=e.side?.toUpperCase()==="BUY",n=e.price??0,i=e.usd_size??0,s=Zc(e.type,u=>String(t(u))),a=e.event?.title??e.market?.question??"\u2014",l=od(e.timestamp),m=ed(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-text-muted 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-text-muted",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-text-muted",children:t("predict.profile.status")}),jsx("span",{className:"text-foreground",children:s})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-text-muted",children:t("predict.profile.price")}),jsx("span",{className:"font-mono text-foreground",children:rd(n)})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-text-muted",children:t("predict.profile.depositWithdraw")}),jsx("span",{className:"font-mono text-foreground",children:i>0?`$${i.toFixed(2)}`:"\u2014"})]}),m&&jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"ml-auto text-text-muted hover:text-foreground transition-colors",children:jsx(td,{})})]})]})}function Zc(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 ed(e){if(e.tx_hash)return e.source==="polymarket"?`https://polygonscan.com/tx/${e.tx_hash}`:`https://solscan.io/tx/${e.tx_hash}`}function Jb(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 Zb(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 td(){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 ey({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-text-muted",style:{height:t},children:e})}function ty({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 rd(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function od(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?"+":"-",m=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${o} ${n}/${i}/${s} (${l}${m})`}var Jo=10,ly=64,id=40,ti=48;function ad({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:o}=useTranslation(),n=useCancelOrder(),[i,s]=useState(1),{data:a,isLoading:l,fetchNextPage:m,hasNextPage:u,isFetchingNextPage:c}=useInfiniteOrders({source:"kalshi",wallet_address:e??""}),{data:p,isLoading:d,fetchNextPage:f,hasNextPage:g,isFetchingNextPage:b}=useInfiniteOrders({source:"polymarket",wallet_address:t??""}),h=l||d,S=c||b,x=u||g,y=useMemo(()=>{let L=[],G=new Set(["live","open","submitted","pending"]);return a?.pages&&L.push(...a.pages.flatMap(U=>U.items).filter(U=>G.has(U.status))),p?.pages&&L.push(...p.pages.flatMap(U=>U.items).filter(U=>G.has(U.status))),L},[a,p]),v=useCallback(L=>{n.mutate({source:L.source,id:L.id});},[n]),k=Math.max(1,Math.ceil(y.length/Jo)+(x?1:0)),N=(i-1)*Jo,w=y.slice(N,N+Jo),P=useCallback(()=>{s(L=>Math.max(1,L-1));},[]),M=useCallback(async()=>{i*Jo>=y.length&&x&&(u&&await m(),g&&await f()),s(G=>G+1);},[i,y.length,x,u,g,m,f]),T=i>1,A=i*Jo<y.length||x;if(h)return jsx(py,{height:r});if(y.length===0&&!x)return jsx(uy,{message:o("predict.profile.noOrders"),height:r});let X=r-id-ti;return jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxs("div",{className:"hidden lg:flex items-center text-text-muted text-xs font-normal shrink-0 border-b border-border/50",style:{height:id},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:X},children:[w.map(L=>jsx(cy,{order:L,onCancel:v},L.id)),S&&jsx("div",{className:"flex justify-center items-center py-4",children:jsx(Spinner,{size:"sm"})})]}),jsx(sd,{className:"hidden lg:flex",currentPage:i,totalPages:k,canGoPrev:T,canGoNext:A,onPrev:P,onNext:M,onPage:s,paginationLabel:L=>String(o(L))}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-ti},children:w.map(L=>jsx(dy,{order:L,onCancel:v},L.id))}),jsx(sd,{className:"lg:hidden",currentPage:i,totalPages:k,canGoPrev:T,canGoNext:A,onPrev:P,onNext:M,onPage:s,paginationLabel:L=>String(o(L)),compact:true})]})}function cy({order:e}){let{t}=useTranslation(),r=e.side==="BUY",o=e.price?parseFloat(e.price):0,n=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:ly},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",r?"text-success":"text-danger"),children:t(r?"predict.profile.buy":"predict.profile.sell")})}),jsx("div",{className:"flex-1 pr-2 text-text-muted capitalize text-sm",children:e.order_type?.toLowerCase()==="market"?t("predict.trade.market"):t("predict.trade.limit")}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:o>0?ld(o):"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:n>0?`$${n.toFixed(2)}`:"\u2014"})]})}function dy({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-text-muted capitalize",children:e.order_type?.toLowerCase()==="market"?r("predict.trade.market"):r("predict.trade.limit")})]}),jsxs("div",{className:"flex items-center gap-4 text-xs",children:[jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-text-muted",children:r("predict.profile.fillPrice")}),jsx("span",{className:"font-mono text-foreground",children:n>0?ld(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 sd({className:e,currentPage:t,totalPages:r,canGoPrev:o,canGoNext:n,onPrev:i,onNext:s,onPage:a,paginationLabel:l,compact:m}){return m?jsxs("div",{className:cn$1("flex items-center justify-center gap-3 shrink-0",e),style:{height:ti},children:[jsx("button",{type:"button",disabled:!o,onClick:i,className:cn$1("text-sm cursor-pointer",o?"text-text-muted hover:text-foreground":"text-text-muted/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-text-muted hover:text-foreground":"text-text-muted/40 cursor-not-allowed"),children:"\u2192"})]}):jsxs("div",{className:cn$1("flex items-center justify-center gap-2 shrink-0",e),style:{height:ti},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-text-muted hover:text-foreground":"text-text-muted/40 cursor-not-allowed"),children:["\u2190 ",l("predict.profile.previous")]}),Array.from({length:Math.min(r,5)},(u,c)=>{let p=c+1;return jsx("button",{type:"button",onClick:()=>a(p),className:cn$1("w-8 h-8 rounded text-sm transition-colors cursor-pointer",p===t?"bg-foreground/10 text-foreground font-medium":"text-text-muted hover:text-foreground"),children:p},p)}),jsxs("button",{type:"button",disabled:!n,onClick:s,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",n?"text-text-muted hover:text-foreground":"text-text-muted/40 cursor-not-allowed"),children:[l("predict.profile.next")," \u2192"]})]})}function uy({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-text-muted",style:{height:t},children:e})}function py({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 ld(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}var Ys=10,hy=64,cd=40,ri=48,vy="\u2715";function dd({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(ky,{height:r});if(e.length===0)return jsx(yy,{message:i("predict.profile.noPositions"),height:r});let m=Math.max(1,Math.ceil(e.length/Ys)),u=(s-1)*Ys,c=e.slice(u,u+Ys),p=s>1,d=s<m,f=r-cd-ri;return jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxs("div",{className:"hidden lg:flex items-center text-text-muted text-xs font-normal shrink-0 border-b border-border/50",style:{height:cd},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:c.map((g,b)=>jsx(xy,{position:g,onClosePosition:o,onEventClick:n},`${g.source}-${g.market?.slug??u+b}`))}),jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:ri},children:[jsxs("button",{type:"button",disabled:!p,onClick:()=>a(g=>Math.max(1,g-1)),className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",p?"text-text-muted hover:text-foreground":"text-text-muted/40 cursor-not-allowed"),children:["\u2190 ",i("predict.profile.previous")]}),Array.from({length:Math.min(m,5)},(g,b)=>{let h=b+1;return jsx("button",{type:"button",onClick:()=>a(h),className:cn$1("w-8 h-8 rounded text-sm transition-colors cursor-pointer",h===s?"bg-foreground/10 text-foreground font-medium":"text-text-muted hover:text-foreground"),children:h},h)}),jsxs("button",{type:"button",disabled:!d,onClick:()=>a(g=>g+1),className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",d?"text-text-muted hover:text-foreground":"text-text-muted/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-ri},children:c.map((g,b)=>jsx(by,{position:g,onClose:o,onEventClick:n},`${g.source}-${g.market?.slug??`m-${u+b}`}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:ri},children:[jsx("button",{type:"button",disabled:!p,onClick:()=>a(g=>Math.max(1,g-1)),className:cn$1("text-sm cursor-pointer",p?"text-text-muted hover:text-foreground":"text-text-muted/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(g=>g+1),className:cn$1("text-sm cursor-pointer",d?"text-text-muted hover:text-foreground":"text-text-muted/40 cursor-not-allowed"),children:"\u2192"})]})]})}function xy({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,m=e.size,u=n>0?"text-success":n<0?"text-danger":"text-foreground",c=n>0?"+":"",p=e.event?.title??e.market?.question??"\u2014",d=e.event?.image_url,f=e.side,g=e.market?.outcomes?.[0]?.label??"",b=e.market?.end_at?Sy(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:hy},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-text-muted",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-text-muted",children:o("predict.profile.contracts",{count: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:qs(s)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:qs(a)}),jsxs("div",{className:cn$1("flex-[1.5] pr-2 text-right font-mono",u),children:[jsxs("span",{children:[c,"$",Math.abs(n).toFixed(2)]}),jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",c,i.toFixed(2),"%)"]})]}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",m.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-text-muted whitespace-nowrap text-xs",children:b}),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-text-muted hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{className:"text-danger",children:vy}),o("predict.profile.close")]})})]})}function by({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?"+":"",m=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:m})]}),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(oi,{label:o("predict.profile.totalSize"),value:Nr(e.size)}),jsx(oi,{label:o("predict.profile.markPrice"),value:qs(s)}),jsx(oi,{label:o("predict.profile.pnl"),value:`${l}$${Math.abs(n).toFixed(2)} (${l}${i.toFixed(1)}%)`,className:a}),jsx(oi,{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 oi({label:e,value:t,className:r}){return jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-text-muted",children:e}),jsx("span",{className:cn$1("font-mono text-foreground",r),children:t})]})}function yy({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-text-muted",style:{height:t},children:e})}function ky({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 qs(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function Sy(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?"+":"-",m=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${o} ${n}/${i}/${s} (${l}${m})`}catch{return "\u2014"}}function pd({positions:e,trades:t,isLoading:r,positionsValue:o,positionsValueLoading:n}){let{t:i}=useTranslation(),s=useMemo(()=>{let m=0,u=0;for(let g of e)m+=g.realized_pnl??0,u+=g.current_value??g.size*(g.current_price??0);let c=0,p=0,d=0;for(let g of t)c+=g.usd_size??0,g.type==="REDEEM"&&(d++,(g.usd_size??0)>0&&p++);let f=d>0?`${p} / ${d}`:"0 / 0";return {realizedPnl:m,positionsValue:o??u,volume:c,winRateStr:f}},[e,o,t]),a=s.realizedPnl>0?"text-success":s.realizedPnl<0?"text-danger":"text-foreground",l=s.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-text-muted",children:i("predict.profile.realizedPnl")}),r?jsx(Skeleton,{className:"h-14 w-48 rounded-md"}):jsxs("span",{className:cn$1("text-5xl font-bold tabular-nums",a),children:[l,"$",Math.abs(s.realizedPnl).toFixed(2)]})]}),jsxs("div",{className:"flex items-end gap-8 sm:gap-10",children:[jsx(Xs,{label:i("predict.profile.winRate"),value:s.winRateStr,isLoading:r}),jsx(Xs,{label:i("predict.profile.positions"),value:`$${s.positionsValue.toFixed(2)}`,isLoading:n??r}),jsx(Xs,{label:i("predict.profile.volume"),value:`$${s.volume.toFixed(2)}`,isLoading:r})]})]})}function Xs({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-text-muted 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 Zs=600;function hd({solanaAddress:e,evmAddress:t,onClosePosition:r,onEventClick:o}){let{t:n}=useTranslation(),[i,s]=useState("positions"),a=!!(e||t),{data:l,isLoading:m}=usePositions({source:"kalshi",user:e??""}),{data:u,isLoading:c}=usePositions({source:"polymarket",user:t??""}),p=useMemo(()=>{let M=[];return l?.positions&&M.push(...l.positions),u?.positions&&M.push(...u.positions),M},[l,u]),d=m||c,{data:f,isLoading:g}=usePositionValueMulti({kalshi_user:e||void 0,polymarket_user:t||void 0}),b=useMemo(()=>{if(!f)return;let M=Number(f.value);return Number.isFinite(M)?M:void 0},[f]),{data:h,isLoading:S}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:100}),{data:x,isLoading:y}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:100}),v=useMemo(()=>[...h?.pages?.flatMap(T=>T.items)??[],...x?.pages?.flatMap(T=>T.items)??[]],[h,x]),k=d||S||y,N=p.length,P=[{key:"positions",label:N>0?`${n("predict.profile.positionsTab")} (${N})`: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(pd,{positions:p,trades:v,isLoading:k,positionsValue:b,positionsValueLoading:g}),jsx("div",{className:"flex items-center gap-1 border-b border-border",children:P.map(M=>jsx("button",{type:"button",onClick:()=>s(M.key),className:cn$1("px-3 py-3 text-base font-normal transition-colors cursor-pointer whitespace-nowrap",i===M.key?"text-foreground border-b-2 border-foreground":"text-text-muted hover:text-foreground"),children:M.label},M.key))}),jsxs("div",{className:"py-2",children:[i==="positions"&&jsx(dd,{positions:p,isLoading:d,listHeight:Zs,onClosePosition:r,onEventClick:o}),i==="orders"&&jsx(ad,{solanaAddress:e,evmAddress:t,listHeight:Zs}),i==="history"&&jsx(Jc,{solanaAddress:e,evmAddress:t,listHeight:Zs})]})]}):jsx("div",{className:"flex items-center justify-center text-sm text-text-muted py-24 px-4",children:n("predict.profile.connectWallet")})}function Ay({isOpen:e,onClose:t,safeDeployed:r,tokenApproved:o,onDeployAndApprove:n}){let{t:i}=useTranslation(),[s,a]=useState(false),[l,m]=useState(null),[u,c]=useState(false),p=r||u,d=o||u,f=p?"done":s?"running":"pending",g=d?"done":p&&s?"running":"pending",b=p&&d,h=useCallback(async()=>{m(null),c(false),a(true);try{await n(),c(!0);}catch(v){m(v instanceof Error?v.message:String(v));}finally{a(false);}},[n]),S=[{key:"step1",label:i("predict.setup.step1"),desc:i("predict.setup.step1Desc"),status:f},{key:"step2",label:i("predict.setup.step2"),desc:i("predict.setup.step2Desc"),status:g}],x=()=>{b?t():h();},y=i(b?"predict.setup.done":"predict.setup.setupButton");return jsx(StyledModal,{isOpen:e,onOpenChange:v=>{v||t();},size:"md",classNames:{base:THEMED_MODAL_BASE_CLASS,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-text-primary",children:i("predict.setup.modalTitle")}),jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-surface-strong/50 text-text-secondary hover:text-text-primary 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-text-secondary text-left",children:i("predict.setup.modalDescription")}),jsx("div",{className:"space-y-2.5",children:S.map((v,k)=>jsxs("div",{className:"flex gap-3 rounded-[10px] border border-border-control/50 bg-surface-interactive/50 px-3 py-3",children:[jsx(Fy,{index:k+1,status:v.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-text-primary",children:v.label}),jsx("span",{className:`text-[11px] leading-none ${v.status==="done"?"text-brand-primary":v.status==="running"?"text-brand-primary/70":"text-text-muted"}`,children:v.status==="done"?i("predict.setup.stepComplete"):v.status==="running"?i("predict.setup.stepRunning"):i("predict.setup.stepPending")})]}),jsx("p",{className:"text-xs text-text-muted mt-1",children:v.desc})]})]},v.key))}),l&&jsx("div",{className:"rounded-[10px] bg-danger/10 border border-danger/20 px-3 py-2",children:jsx("p",{className:"text-xs text-danger",children:l})}),jsx("button",{type:"button",onClick:x,disabled:s,className:b?"w-full py-3 rounded-[10px] bg-action-primary text-text-inverse text-sm font-semibold hover:bg-action-primary-hover 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-action-primary text-text-inverse text-sm font-semibold hover:bg-action-primary-hover 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")]}):y}),!b&&jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] text-sm text-text-secondary hover:text-text-primary hover:bg-surface-strong/50 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 Fy({index:e,status:t}){return t==="done"?jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-action-primary/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-brand-primary",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-action-primary/10 shrink-0",children:jsxs("svg",{className:"animate-spin h-4 w-4 text-brand-primary",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-surface-strong/50 text-xs font-bold text-text-secondary shrink-0",children:e})}
|
|
136
|
-
export{
|
|
135
|
+
`}),jsxs("div",{style:{position:"relative",overflow:"hidden",borderBottom:"1px solid var(--color-border-subtle)"},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(Hs,{stats:b})})]}),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 var(--color-border-subtle)"},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:m(Tb[u])}),b&&b.activePairs>0&&jsx("p",{className:"hidden sm:block",style:{fontSize:11,color:"var(--color-text-muted)",margin:0},children:m("predict.matches.pairsFound",{count:b.activePairs})})]})]}),jsx(Bs,{sortBy:u,onSortChange:x,sortAsc:p,onSortAscChange:y,minVolume:f,onMinVolumeChange:g,onRefresh:k})]})]}),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 var(--color-border-subtle)",background:"rgba(24,24,27,0.25)"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"var(--color-text-disabled)",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:"var(--color-text-disabled)",lineHeight:1.5,margin:0},children:[jsx("span",{style:{color:"var(--color-text-muted)",fontWeight:500},children:m("predict.matches.experimentalFeature")})," \u2014 ",m("predict.matches.disclaimer")]})]}),jsx(Ks,{ref:S,sortBy:u,sortAsc:p,minVolume:f,onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:o,onHover:n,onSelect:i,getMarketHref:s,LinkComponent:a,onStatsChange:h})]}),jsx(Lb,{stats:b})]})}function $s(e){return e==null?"-":formatAmountInUsd(e)}var Db={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"}},Ab={text:"var(--color-text-secondary)",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 Fb(e){return Db[e]??Ab}function Bb(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 Hb(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 Ub({group:e,onSelectEntry:t,getEventHref:r,LinkComponent:o}){let{t:n}=useTranslation(),i=useMemo(()=>Bb(e),[e]),s=e.max_spread!=null?e.max_spread*100:null,[a,l]=useMemo(()=>Hb(e,i),[e,i]),m=s!=null&&s>=3,u=a.yesPrice!=null&&l.yesPrice!=null?a.yesPrice<=l.yesPrice?a:l:null,c=u?_r(u.source):null,p=m?"amber":"violet";return jsxs("div",{className:"group",style:{borderRadius:16,border:"1px solid var(--color-border-subtle)",background:"hsl(var(--heroui-content2) / 0.4)",overflow:"hidden",transition:"all 0.2s",position:"relative"},onMouseEnter:d=>{let f=d.currentTarget;f.style.borderColor="hsl(var(--heroui-content4) / 0.6)",f.style.boxShadow="0 10px 15px -3px rgba(0,0,0,0.2)";},onMouseLeave:d=>{let f=d.currentTarget;f.style.borderColor="hsl(var(--heroui-content3) / 0.6)",f.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 ${m?"rgba(255,185,0,0.3)":s>=2?"rgba(166,132,255,0.3)":"rgba(156,163,175,0.3)"}`,background:m?"rgba(255,185,0,0.15)":s>=2?"rgba(166,132,255,0.15)":"rgba(156,163,175,0.12)",color:m?"#ffb900":s>=2?"#a684ff":"var(--color-text-secondary)"},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:"var(--color-text-primary)",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(jc,{data:a,isCheaper:u===a,onSelect:t,getEventHref:r,LinkComponent:o}),jsx(jc,{data:l,isCheaper:u===l,onSelect:t,getEventHref:r,LinkComponent:o})]}),u&&c&&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 ${p==="amber"?"rgba(255,185,0,0.15)":"rgba(166,132,255,0.15)"}`,background:p==="amber"?"rgba(255,185,0,0.05)":"rgba(166,132,255,0.05)"},onClick:()=>u.event&&t?.(u.event),children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,flexShrink:0,color:p==="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:p==="amber"?"rgba(255,185,0,0.9)":"rgba(166,132,255,0.9)"},children:n("predict.matches.buyEdge",{platform:u.source.charAt(0).toUpperCase()+u.source.slice(1),spread:s.toFixed(1)})}),jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,marginLeft:"auto",color:p==="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 var(--color-border-subtle)",background:"hsl(var(--heroui-content3) / 0.2)",padding:"10px 16px"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,fontSize:10,color:"var(--color-text-muted)"},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"})]}),$s(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"})}),$s(e.combined_volume_24h)," ",n("predict.matches.vol24h")]})]}),e.confidence!=null&&jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,fontSize:10,color:"var(--color-text-disabled)"},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 jc({data:e,isCheaper:t,onSelect:r,getEventHref:o,LinkComponent:n}){let{t:i}=useTranslation(),s=_r(e.source),a=Fb(e.source),l=e.event?o?.(e.event):void 0,m=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:"var(--color-text-disabled)",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:"var(--color-text-muted)",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:"var(--color-text-muted)"},children:i("predict.matches.centsYes")})]}),jsxs("div",{style:{fontSize:10,color:"var(--color-text-disabled)",marginTop:6},children:[$s(e.volume)," ",i("predict.matches.volume")]})]});return l&&n?jsx(n,{href:l,className:"block",children:m}):m}function $b(e){return formatAmountInUsd(e)}function Vb({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(ei,{label:r("predict.matches.stats.matchedMarkets"),value:o.count.toLocaleString()}),jsx(Vs,{}),jsx(ei,{label:r("predict.matches.stats.totalVolume"),value:$b(o.totalVolume)}),jsx(Vs,{}),jsx(ei,{label:r("predict.matches.stats.highestSpread"),value:`${(o.maxSpread*100).toFixed(1)}\xA2`,valueClassName:"text-success"}),jsx(Vs,{}),jsx(ei,{label:r("predict.matches.stats.platforms"),value:String(o.platformCount)})]})}function ei({label:e,value:t,valueClassName:r="text-text-primary"}){return jsxs("div",{className:"flex items-center gap-x-1.5",children:[jsxs("span",{className:"text-text-muted",children:[e,":"]}),jsx("span",{className:`font-semibold ${r}`,children:t})]})}function Vs(){return jsx("span",{className:"hidden text-text-disabled sm:inline",children:"|"})}function qc(e){return `${(e*100).toFixed(1)}\xA2`}function jb(e){return e>=.05?"text-success":e>=.02?"text-warning":"text-text-secondary"}function Gb({spread:e,arbProfit:t,className:r}){if(e==null)return null;let o=t!=null&&t>0;return jsxs("div",{className:cn("flex items-center gap-x-2",r),children:[jsx("span",{className:cn("text-sm font-semibold",jb(e)),children:qc(e)}),o&&jsxs("span",{className:"text-xs text-success/80",children:["+",qc(t)]})]})}var Jo=10,Zb=64,Zc=40,ti=48;function ed({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:o}=useTranslation(),[n,i]=useState(1),{data:s,isLoading:a,fetchNextPage:l,hasNextPage:m,isFetchingNextPage:u}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:50}),{data:c,isLoading:p,fetchNextPage:d,hasNextPage:f,isFetchingNextPage:g}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:50}),b=a||p,v=u||g,S=m||f,x=useMemo(()=>{let A=[];return s?.pages&&A.push(...s.pages.flatMap(X=>X.items)),c?.pages&&A.push(...c.pages.flatMap(X=>X.items)),A.sort((X,L)=>(L.timestamp??0)-(X.timestamp??0)),A},[s,c]),y=Math.max(1,Math.ceil(x.length/Jo)+(S?1:0)),h=(n-1)*Jo,k=x.slice(h,h+Jo),N=useCallback(()=>{i(A=>Math.max(1,A-1));},[]),w=useCallback(async()=>{n*Jo>=x.length&&S&&(m&&await l(),f&&await d()),i(X=>X+1);},[n,x.length,S,m,f,l,d]),P=n>1,M=n*Jo<x.length||S;if(b)return jsx(iy,{height:r});if(x.length===0&&!S)return jsx(ny,{message:o("predict.profile.noHistory"),height:r});let T=r-Zc-ti;return jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxs("div",{className:"hidden lg:flex items-center text-text-muted text-xs font-normal shrink-0 border-b border-border/50",style:{height:Zc},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:T},children:[k.map((A,X)=>jsx(ey,{trade:A},A.id??`${h+X}`)),v&&jsx("div",{className:"flex justify-center items-center py-4",children:jsx(Spinner,{size:"sm"})})]}),jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:ti},children:[jsxs("button",{type:"button",disabled:!P,onClick:N,className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",P?"text-text-muted hover:text-foreground":"text-text-muted/40 cursor-not-allowed"),children:["\u2190 ",o("predict.profile.previous")]}),Array.from({length:Math.min(y,5)},(A,X)=>{let L=X+1;return jsx("button",{type:"button",onClick:()=>i(L),className:cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",L===n?"bg-foreground/10 text-foreground font-medium":"text-text-muted hover:text-foreground"),children:L},L)}),jsxs("button",{type:"button",disabled:!M,onClick:w,className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",M?"text-text-muted hover:text-foreground":"text-text-muted/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-ti},children:k.map((A,X)=>jsx(ty,{trade:A},A.id??`m-${h+X}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:ti},children:[jsx("button",{type:"button",disabled:!P,onClick:N,className:cn("text-sm cursor-pointer",P?"text-text-muted hover:text-foreground":"text-text-muted/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:n}),jsx("button",{type:"button",disabled:!M,onClick:w,className:cn("text-sm cursor-pointer",M?"text-text-muted hover:text-foreground":"text-text-muted/40 cursor-not-allowed"),children:"\u2192"})]})]})}function ey({trade:e}){let{t}=useTranslation(),r=e.type==="REDEEM",o=e.side?.toUpperCase()==="BUY",n=e.price??0,i=e.usd_size??0,s=td(e.type,v=>String(t(v))),a=r||o,l=a?"+":"-",m=a?"text-success":"text-foreground",u=e.event?.title??e.market?.question??"\u2014",c=e.event?.image_url,p=e.outcome??"",d=id(e.timestamp),f=rd(e),g=ry(e),b=oy(e);return jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:Zb},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:[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:u}),jsxs("span",{className:"text-[11px] text-text-muted",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":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:nd(n)}),jsx("div",{className:cn("flex-[1.5] pr-2 text-right font-mono",m),children:i>0?jsxs(Fragment,{children:[l,"$",i.toFixed(2)]}):"\u2014"}),jsx("div",{className:cn("flex-1 pr-2 text-right font-mono",g!==null?g>=0?"text-success":"text-danger":"text-text-muted"),children:g!==null?`${g>=0?"+":"-"}$${Math.abs(g).toFixed(2)}`:"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-text-muted",children:b!==null?`$${b.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-text-muted hover:text-foreground transition-colors","aria-label":t("common.viewTransaction"),children:jsx(od,{})})})]})}function ty({trade:e}){let{t}=useTranslation(),r=e.type==="REDEEM",o=e.side?.toUpperCase()==="BUY",n=e.price??0,i=e.usd_size??0,s=td(e.type,u=>String(t(u))),a=e.event?.title??e.market?.question??"\u2014",l=id(e.timestamp),m=rd(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-text-muted 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-text-muted",children:t("predict.profile.action")}),jsx("span",{className:cn("font-medium",r?"text-primary":o?"text-success":"text-danger"),children:t(r?"predict.profile.redeem":o?"predict.profile.buy":"predict.profile.sell")})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-text-muted",children:t("predict.profile.status")}),jsx("span",{className:"text-foreground",children:s})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-text-muted",children:t("predict.profile.price")}),jsx("span",{className:"font-mono text-foreground",children:nd(n)})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-text-muted",children:t("predict.profile.depositWithdraw")}),jsx("span",{className:"font-mono text-foreground",children:i>0?`$${i.toFixed(2)}`:"\u2014"})]}),m&&jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"ml-auto text-text-muted hover:text-foreground transition-colors",children:jsx(od,{})})]})]})}function td(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 rd(e){if(e.tx_hash)return e.source==="polymarket"?`https://polygonscan.com/tx/${e.tx_hash}`:`https://solscan.io/tx/${e.tx_hash}`}function ry(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 oy(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 od(){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 ny({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-text-muted",style:{height:t},children:e})}function iy({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 nd(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function id(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?"+":"-",m=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${o} ${n}/${i}/${s} (${l}${m})`}var Zo=10,py=64,ad=40,ri=48;function cd({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:o}=useTranslation(),n=useCancelOrder(),[i,s]=useState(1),{data:a,isLoading:l,fetchNextPage:m,hasNextPage:u,isFetchingNextPage:c}=useInfiniteOrders({source:"kalshi",wallet_address:e??""}),{data:p,isLoading:d,fetchNextPage:f,hasNextPage:g,isFetchingNextPage:b}=useInfiniteOrders({source:"polymarket",wallet_address:t??""}),v=l||d,S=c||b,x=u||g,y=useMemo(()=>{let L=[],G=new Set(["live","open","submitted","pending"]);return a?.pages&&L.push(...a.pages.flatMap(U=>U.items).filter(U=>G.has(U.status))),p?.pages&&L.push(...p.pages.flatMap(U=>U.items).filter(U=>G.has(U.status))),L},[a,p]),h=useCallback(L=>{n.mutate({source:L.source,id:L.id});},[n]),k=Math.max(1,Math.ceil(y.length/Zo)+(x?1:0)),N=(i-1)*Zo,w=y.slice(N,N+Zo),P=useCallback(()=>{s(L=>Math.max(1,L-1));},[]),M=useCallback(async()=>{i*Zo>=y.length&&x&&(u&&await m(),g&&await f()),s(G=>G+1);},[i,y.length,x,u,g,m,f]),T=i>1,A=i*Zo<y.length||x;if(v)return jsx(vy,{height:r});if(y.length===0&&!x)return jsx(gy,{message:o("predict.profile.noOrders"),height:r});let X=r-ad-ri;return jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxs("div",{className:"hidden lg:flex items-center text-text-muted text-xs font-normal shrink-0 border-b border-border/50",style:{height:ad},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:X},children:[w.map(L=>jsx(my,{order:L,onCancel:h},L.id)),S&&jsx("div",{className:"flex justify-center items-center py-4",children:jsx(Spinner,{size:"sm"})})]}),jsx(ld,{className:"hidden lg:flex",currentPage:i,totalPages:k,canGoPrev:T,canGoNext:A,onPrev:P,onNext:M,onPage:s,paginationLabel:L=>String(o(L))}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-ri},children:w.map(L=>jsx(fy,{order:L,onCancel:h},L.id))}),jsx(ld,{className:"lg:hidden",currentPage:i,totalPages:k,canGoPrev:T,canGoNext:A,onPrev:P,onNext:M,onPage:s,paginationLabel:L=>String(o(L)),compact:true})]})}function my({order:e}){let{t}=useTranslation(),r=e.side==="BUY",o=e.price?parseFloat(e.price):0,n=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:py},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",r?"text-success":"text-danger"),children:t(r?"predict.profile.buy":"predict.profile.sell")})}),jsx("div",{className:"flex-1 pr-2 text-text-muted capitalize text-sm",children:e.order_type?.toLowerCase()==="market"?t("predict.trade.market"):t("predict.trade.limit")}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:o>0?dd(o):"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:n>0?`$${n.toFixed(2)}`:"\u2014"})]})}function fy({order:e,onCancel:t}){let{t:r}=useTranslation(),o=e.side==="BUY",n=e.price?parseFloat(e.price):0;return jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:cn("text-xs font-medium px-1.5 py-0.5 rounded",o?"bg-success/10 text-success":"bg-danger/10 text-danger"),children:e.side}),jsx("span",{className:"text-sm text-foreground capitalize",children:e.outcome??"\u2014"})]}),jsx("span",{className:"text-xs text-text-muted capitalize",children:e.order_type?.toLowerCase()==="market"?r("predict.trade.market"):r("predict.trade.limit")})]}),jsxs("div",{className:"flex items-center gap-4 text-xs",children:[jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-text-muted",children:r("predict.profile.fillPrice")}),jsx("span",{className:"font-mono text-foreground",children:n>0?dd(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 ld({className:e,currentPage:t,totalPages:r,canGoPrev:o,canGoNext:n,onPrev:i,onNext:s,onPage:a,paginationLabel:l,compact:m}){return m?jsxs("div",{className:cn("flex items-center justify-center gap-3 shrink-0",e),style:{height:ri},children:[jsx("button",{type:"button",disabled:!o,onClick:i,className:cn("text-sm cursor-pointer",o?"text-text-muted hover:text-foreground":"text-text-muted/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:t}),jsx("button",{type:"button",disabled:!n,onClick:s,className:cn("text-sm cursor-pointer",n?"text-text-muted hover:text-foreground":"text-text-muted/40 cursor-not-allowed"),children:"\u2192"})]}):jsxs("div",{className:cn("flex items-center justify-center gap-2 shrink-0",e),style:{height:ri},children:[jsxs("button",{type:"button",disabled:!o,onClick:i,className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",o?"text-text-muted hover:text-foreground":"text-text-muted/40 cursor-not-allowed"),children:["\u2190 ",l("predict.profile.previous")]}),Array.from({length:Math.min(r,5)},(u,c)=>{let p=c+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-text-muted hover:text-foreground"),children:p},p)}),jsxs("button",{type:"button",disabled:!n,onClick:s,className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",n?"text-text-muted hover:text-foreground":"text-text-muted/40 cursor-not-allowed"),children:[l("predict.profile.next")," \u2192"]})]})}function gy({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-text-muted",style:{height:t},children:e})}function vy({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 dd(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}var Qs=10,yy=64,ud=40,oi=48,ky="\u2715";function pd({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(My,{height:r});if(e.length===0)return jsx(Ny,{message:i("predict.profile.noPositions"),height:r});let m=Math.max(1,Math.ceil(e.length/Qs)),u=(s-1)*Qs,c=e.slice(u,u+Qs),p=s>1,d=s<m,f=r-ud-oi;return jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxs("div",{className:"hidden lg:flex items-center text-text-muted text-xs font-normal shrink-0 border-b border-border/50",style:{height:ud},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:c.map((g,b)=>jsx(Sy,{position:g,onClosePosition:o,onEventClick:n},`${g.source}-${g.market?.slug??u+b}`))}),jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:oi},children:[jsxs("button",{type:"button",disabled:!p,onClick:()=>a(g=>Math.max(1,g-1)),className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",p?"text-text-muted hover:text-foreground":"text-text-muted/40 cursor-not-allowed"),children:["\u2190 ",i("predict.profile.previous")]}),Array.from({length:Math.min(m,5)},(g,b)=>{let v=b+1;return jsx("button",{type:"button",onClick:()=>a(v),className:cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",v===s?"bg-foreground/10 text-foreground font-medium":"text-text-muted hover:text-foreground"),children:v},v)}),jsxs("button",{type:"button",disabled:!d,onClick:()=>a(g=>g+1),className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",d?"text-text-muted hover:text-foreground":"text-text-muted/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-oi},children:c.map((g,b)=>jsx(Py,{position:g,onClose:o,onEventClick:n},`${g.source}-${g.market?.slug??`m-${u+b}`}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:oi},children:[jsx("button",{type:"button",disabled:!p,onClick:()=>a(g=>Math.max(1,g-1)),className:cn("text-sm cursor-pointer",p?"text-text-muted hover:text-foreground":"text-text-muted/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(g=>g+1),className:cn("text-sm cursor-pointer",d?"text-text-muted hover:text-foreground":"text-text-muted/40 cursor-not-allowed"),children:"\u2192"})]})]})}function Sy({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,m=e.size,u=n>0?"text-success":n<0?"text-danger":"text-foreground",c=n>0?"+":"",p=e.event?.title??e.market?.question??"\u2014",d=e.event?.image_url,f=e.side,g=e.market?.outcomes?.[0]?.label??"",b=e.market?.end_at?wy(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:yy},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-text-muted",children:[jsx("span",{className:cn("font-medium",f.toLowerCase()==="yes"?"text-success":"text-danger"),children:f}),g&&jsxs(Fragment,{children:[jsx("span",{className:"mx-1",children:"\xB7"}),jsx("span",{children:g})]})]})]})]})}),jsx("div",{className:"flex-1 pr-2 text-right",children:jsxs("div",{className:"flex flex-col items-end",children:[jsxs("span",{className:"font-mono text-foreground",children:["$",l.toFixed(2)]}),jsx("span",{className:"text-[10px] text-text-muted",children:o("predict.profile.contracts",{count: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:Xs(s)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Xs(a)}),jsxs("div",{className:cn("flex-[1.5] pr-2 text-right font-mono",u),children:[jsxs("span",{children:[c,"$",Math.abs(n).toFixed(2)]}),jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",c,i.toFixed(2),"%)"]})]}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",m.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-text-muted whitespace-nowrap text-xs",children:b}),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-text-muted hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{className:"text-danger",children:ky}),o("predict.profile.close")]})})]})}function Py({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?"+":"",m=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:m})]}),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(ni,{label:o("predict.profile.totalSize"),value:Mr(e.size)}),jsx(ni,{label:o("predict.profile.markPrice"),value:Xs(s)}),jsx(ni,{label:o("predict.profile.pnl"),value:`${l}$${Math.abs(n).toFixed(2)} (${l}${i.toFixed(1)}%)`,className:a}),jsx(ni,{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 ni({label:e,value:t,className:r}){return jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-text-muted",children:e}),jsx("span",{className:cn("font-mono text-foreground",r),children:t})]})}function Ny({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-text-muted",style:{height:t},children:e})}function My({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 Xs(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function wy(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?"+":"-",m=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${o} ${n}/${i}/${s} (${l}${m})`}catch{return "\u2014"}}function fd({positions:e,trades:t,isLoading:r,positionsValue:o,positionsValueLoading:n}){let{t:i}=useTranslation(),s=useMemo(()=>{let m=0,u=0;for(let g of e)m+=g.realized_pnl??0,u+=g.current_value??g.size*(g.current_price??0);let c=0,p=0,d=0;for(let g of t)c+=g.usd_size??0,g.type==="REDEEM"&&(d++,(g.usd_size??0)>0&&p++);let f=d>0?`${p} / ${d}`:"0 / 0";return {realizedPnl:m,positionsValue:o??u,volume:c,winRateStr:f}},[e,o,t]),a=s.realizedPnl>0?"text-success":s.realizedPnl<0?"text-danger":"text-foreground",l=s.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-text-muted",children:i("predict.profile.realizedPnl")}),r?jsx(Skeleton,{className:"h-14 w-48 rounded-md"}):jsxs("span",{className:cn("text-5xl font-bold tabular-nums",a),children:[l,"$",Math.abs(s.realizedPnl).toFixed(2)]})]}),jsxs("div",{className:"flex items-end gap-8 sm:gap-10",children:[jsx(Zs,{label:i("predict.profile.winRate"),value:s.winRateStr,isLoading:r}),jsx(Zs,{label:i("predict.profile.positions"),value:`$${s.positionsValue.toFixed(2)}`,isLoading:n??r}),jsx(Zs,{label:i("predict.profile.volume"),value:`$${s.volume.toFixed(2)}`,isLoading:r})]})]})}function Zs({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-text-muted 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 ta=600;function xd({solanaAddress:e,evmAddress:t,onClosePosition:r,onEventClick:o}){let{t:n}=useTranslation(),[i,s]=useState("positions"),a=!!(e||t),{data:l,isLoading:m}=usePositions({source:"kalshi",user:e??""}),{data:u,isLoading:c}=usePositions({source:"polymarket",user:t??""}),p=useMemo(()=>{let M=[];return l?.positions&&M.push(...l.positions),u?.positions&&M.push(...u.positions),M},[l,u]),d=m||c,{data:f,isLoading:g}=usePositionValueMulti({kalshi_user:e||void 0,polymarket_user:t||void 0}),b=useMemo(()=>{if(!f)return;let M=Number(f.value);return Number.isFinite(M)?M:void 0},[f]),{data:v,isLoading:S}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:100}),{data:x,isLoading:y}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:100}),h=useMemo(()=>[...v?.pages?.flatMap(T=>T.items)??[],...x?.pages?.flatMap(T=>T.items)??[]],[v,x]),k=d||S||y,N=p.length,P=[{key:"positions",label:N>0?`${n("predict.profile.positionsTab")} (${N})`: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(fd,{positions:p,trades:h,isLoading:k,positionsValue:b,positionsValueLoading:g}),jsx("div",{className:"flex items-center gap-1 border-b border-border",children:P.map(M=>jsx("button",{type:"button",onClick:()=>s(M.key),className:cn("px-3 py-3 text-base font-normal transition-colors cursor-pointer whitespace-nowrap",i===M.key?"text-foreground border-b-2 border-foreground":"text-text-muted hover:text-foreground"),children:M.label},M.key))}),jsxs("div",{className:"py-2",children:[i==="positions"&&jsx(pd,{positions:p,isLoading:d,listHeight:ta,onClosePosition:r,onEventClick:o}),i==="orders"&&jsx(cd,{solanaAddress:e,evmAddress:t,listHeight:ta}),i==="history"&&jsx(ed,{solanaAddress:e,evmAddress:t,listHeight:ta})]})]}):jsx("div",{className:"flex items-center justify-center text-sm text-text-muted py-24 px-4",children:n("predict.profile.connectWallet")})}function Uy({isOpen:e,onClose:t,safeDeployed:r,tokenApproved:o,onDeployAndApprove:n}){let{t:i}=useTranslation(),[s,a]=useState(false),[l,m]=useState(null),[u,c]=useState(false),p=r||u,d=o||u,f=p?"done":s?"running":"pending",g=d?"done":p&&s?"running":"pending",b=p&&d,v=useCallback(async()=>{m(null),c(false),a(true);try{await n(),c(!0);}catch(h){m(h instanceof Error?h.message:String(h));}finally{a(false);}},[n]),S=[{key:"step1",label:i("predict.setup.step1"),desc:i("predict.setup.step1Desc"),status:f},{key:"step2",label:i("predict.setup.step2"),desc:i("predict.setup.step2Desc"),status:g}],x=()=>{b?t():v();},y=i(b?"predict.setup.done":"predict.setup.setupButton");return jsx(StyledModal,{isOpen:e,onOpenChange:h=>{h||t();},size:"md",classNames:{base:THEMED_MODAL_BASE_CLASS,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-text-primary",children:i("predict.setup.modalTitle")}),jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-surface-strong/50 text-text-secondary hover:text-text-primary 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-text-secondary text-left",children:i("predict.setup.modalDescription")}),jsx("div",{className:"space-y-2.5",children:S.map((h,k)=>jsxs("div",{className:"flex gap-3 rounded-[10px] border border-border-control/50 bg-surface-interactive/50 px-3 py-3",children:[jsx(Wy,{index:k+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-text-primary",children:h.label}),jsx("span",{className:`text-[11px] leading-none ${h.status==="done"?"text-brand-primary":h.status==="running"?"text-brand-primary/70":"text-text-muted"}`,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-text-muted mt-1",children:h.desc})]})]},h.key))}),l&&jsx("div",{className:"rounded-[10px] bg-danger/10 border border-danger/20 px-3 py-2",children:jsx("p",{className:"text-xs text-danger",children:l})}),jsx("button",{type:"button",onClick:x,disabled:s,className:b?"w-full py-3 rounded-[10px] bg-action-primary text-text-inverse text-sm font-semibold hover:bg-action-primary-hover 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-action-primary text-text-inverse text-sm font-semibold hover:bg-action-primary-hover 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")]}):y}),!b&&jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] text-sm text-text-secondary hover:text-text-primary hover:bg-surface-strong/50 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 Wy({index:e,status:t}){return t==="done"?jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-action-primary/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-brand-primary",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-action-primary/10 shrink-0",children:jsxs("svg",{className:"animate-spin h-4 w-4 text-brand-primary",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-surface-strong/50 text-xs font-bold text-text-secondary shrink-0",children:e})}
|
|
136
|
+
export{bi as CHART_RANGE_DURATION,Dd as CHART_RANGE_FIDELITY_MINUTES,_d as CHART_RANGE_PERIOD,Id as CHART_RANGE_SAMPLE_INTERVAL,jr as CandlestickPeriod,Ed as CategoriesSkeleton,fi as CategoriesUI,vi as CategoriesWidget,K as ChartRange,Yn as CommentItemUI,ko as DEFAULT_CHART_RANGE,Jr as DEFAULT_FILTER_STATE,Gr as DEFAULT_PAGE_SIZE,Hd as DEFAULT_PRICE_HISTORY_INTERVAL,dc as EventCommentsWidget,zv as EventDetailPage,oo as EventDetailSkeleton,Vo as EventDetailUI,Vv as EventDetailWidget,Wi as EventItem,ms as EventMarketDepthChartUI,vs as EventMarketDetailWidget,ys as EventPriceChart,_i as EventsFilterUI,bm as EventsHero,gm as EventsPage,Ep as EventsPageSkeleton,Sn as EventsSkeleton,Di as EventsToolbarUI,Ki as EventsUI,Vi as EventsWidget,Co as KycModal,fn as MAX_PRICE_HISTORY_MARKETS,Ub as MatchGroupCard,Ws as MatchMarketCard,Bs as MatchesFilterBar,Hs as MatchesHero,Ob as MatchesPage,Vb as MatchesStatsBar,Ks as MatchesWidget,Bd as ORDER_MAX_PRICE,Fd as ORDER_MIN_PRICE,So as ORDER_MIN_QUANTITY,Po as ORDER_MIN_USDC,Ad as ORDER_PRICE_STEP,ga as POLYMARKET_BUILDER_TAKER_FEE_BPS,va as POLYMARKET_SPORTS_TAKER_FEE_BPS,il as PREDICT_REDEEM_MODAL_ID,pc as PREDICT_SEARCH_HISTORY_KEY,Xn as PREDICT_SEARCH_MODAL_ID,Cn as PREDICT_SELL_MODAL_ID,Qr as PREDICT_TRADE_MODAL_ID,Ud as PRICE_HISTORY_SAMPLE_INTERVAL,qi as PredictRedeemModal,Mx as PredictSearchModal,os as PredictSellModal,Ro as PredictTradeModal,ma as PredictWalletProvider,Nr as PriceHistoryInterval,xd as ProfilePage,Yi as RedeemFormWidget,Ii as SORT_PRESETS,ln as STATIC_CATEGORIES,Ox as SearchEventsButton,ws as SearchHistoryUI,Es as SearchHistoryWidget,Cs as SearchInputUI,Rs as SearchResultItemUI,_s as SearchResultListWidget,Ds as SearchWidget,rs as SellFormUI,Do as SellFormWidget,Uy as SetupModal,Zl as SimilarEventCard,Ss as SimilarEventsSection,eb as SourceBadge,Gb as SpreadIndicator,us as TradeFormSkeleton,Oi as TradeFormUI,To as TradeFormWidget,ls as UserActivitySection,Ni as computeMaxBuyAmount,yn as countActiveFilters,po as createPredictSearchHistoryStorage,wr as createTradeResultToast,Mi as estimatePolymarketBuyFee,wi as estimatePolymarketSellFee,Ei as fireCelebration,be as floorToDecimals,no as formatKMB,Mr as formatShares,_r as getSourceMeta,Sh as orderIntentView,wo as parsePolymarketError,fa as polymarketFeeFactor,No as resolveExpiration,Pi as resolvePolymarketDisplayFeeRateBps,Mo as roundToTickSize,Xv as useEventDetail,Ai as useEventsInfinite,Ms as usePredictSearchHistory,cr as usePredictWallet,Ls as useSearchResultListScript,Dx as useSearchScript,Zi as useSellForm,Ti as useTradeForm};//# sourceMappingURL=index.mjs.map
|
|
137
137
|
//# sourceMappingURL=index.mjs.map
|